๐Ÿ“Š Profitability Check

Profitability Check

Estimate all costs and determine if your flash loan is profitable before sending. Uses real-time fee data from the VAEA API.

Usage

const check = await flash.isProfitable({
  token: 'SOL',
  amount: 1000,
  expectedRevenue: 0.5,    // expected profit in SOL
  jitoTip: 0.01,           // Jito tip
  priorityFee: 0.001,      // priority fee
});

if (check.recommendation === 'send') {
  const sig = await flash.executeLocal(params);
  console.log('Net profit:', check.netProfit, 'SOL');
} else {
  console.log('Skip โ€” recommendation:', check.recommendation);
}

Recommendation Levels

LevelConditionSuggested Action
sendNet profit > 2ร— total costsExecute immediately โ€” clearly profitable
waitNet profit > costs but < 2ร—Marginal โ€” consider waiting for better opportunity
abortTotal costs > expected revenueSkip โ€” you would lose money

Cost Breakdown

typescript
{
  profitable: true,
  netProfit: 0.189,            // revenue - totalCost
  breakdown: {
    revenue: 0.5,              // your expectedRevenue
    vaeFee: 0.2,               // VAEA fee (0.02% of 1000 SOL)
    swapFees: 0,               // swap_in + swap_out (0 for direct)
    networkFee: 0.000005,      // ~5000 lamports base fee
    priorityFee: 0.001,        // your priority fee
    jitoTip: 0.01,             // your Jito tip
    totalCost: 0.311005,       // sum of all costs
  },
  recommendation: 'send',     // 'send' | 'wait' | 'abort'
}
โ„น๏ธ Note
For synthetic routes, swap costs are estimated based on current Jupiter/Sanctum quotes. The calculator factors in all known costs.