Flash Loan
Navi Flash Loan enables developers to borrow assets without collateral, as long as the borrowed amount plus fees is repaid within the same transaction. It is designed for advanced on-chain use cases such as arbitrage, liquidation protection, and debt restructuring while abstracting protocol-level complexity through a JavaScript/TypeScript SDK.
Flash Loan At A Glance
Before integrating, here are the key facts you should know:
- Atomic execution: Borrow and repay must occur in the same transaction
- No collateral required
- Fees apply: Repayment must include the flash loan fee
- Pool-dependent: Not all assets or pools support flash loans
- Amount-limited: Each asset has a maximum borrowable amount
Supported Assets And Fees
Use the live table below to check currently supported flashloan tokens and their fees. You can switch campaign configs on the fly.
Live Flashloan Fees
| Token | Coin Type | Fee | |
|---|---|---|---|
| Loading supported assets... | |||
When To Use Flash Loans
Flash loans are best suited for:
- Arbitrage trading: Exploit price differences across DEXs in a single transaction
- Debt restructuring: Rebalance positions to reduce borrowing costs
- Liquidation protection: Temporarily replenish collateral to avoid liquidation
- Liquidity management: Access short-term liquidity for complex operations
Quick Start: End-To-End Flow
A typical flash loan flow looks like this:
- Discover available flash loan assets and fees
- Borrow assets using
flashloanPTB - Execute your custom logic (for example arbitrage)
- Repay the loan using
repayFlashLoanPTB - Submit the transaction
Step 1: Discover Available Flash Loan Assets And Fees
Use this API to check which assets support flash loans, along with their limits and fees.
getAllFlashLoanAssets
Returns all available flash loan assets. Results are cached to reduce repeated API calls. See documentation for details.
import { getAllFlashLoanAssets } from '@naviprotocol/lending'
const flashLoanAssets = await getAllFlashLoanAssets({
env: 'prod',
cacheTime: 30000
})Key fields to check before borrowing:
max: Maximum borrowable amountflashloanFee: Fee rate applied to the borrowed amountcoinType: Asset identifier used in subsequent calls
Step 2: Get A Specific Flash Loan Asset
getFlashLoanAsset
Retrieve flash loan details using a coin type, asset ID, or pool object. See documentation for details.
import { getFlashLoanAsset, getPool } from '@naviprotocol/lending'
const assetByCoinType = await getFlashLoanAsset('0x2::sui::SUI')
const assetById = await getFlashLoanAsset(0)
const pool = await getPool('0x2::sui::SUI')
const assetByObject = await getFlashLoanAsset(pool)Step 3: Borrow Assets In A Transaction
flashloanPTB
Creates a flash loan within a Programmable Transaction Block (PTB). See documentation for details.
import { flashloanPTB } from '@naviprotocol/lending'
import { Transaction } from '@mysten/sui/transactions'
const tx = new Transaction()
const [balance, receipt] = await flashloanPTB(
tx,
'0x2::sui::SUI',
1_000_000_000,
{ env: 'prod' }
)Returns:
balance: Borrowed asset balancereceipt: Flash loan receipt (required for repayment)
Step 4: Repay The Flash Loan
repayFlashLoanPTB
Repays the flash loan using the receipt and repayment balance. See documentation for details.
import { repayFlashLoanPTB } from '@naviprotocol/lending'
await repayFlashLoanPTB(
tx,
'0x2::sui::SUI',
receipt,
balance,
{ env: 'prod' }
)The repayment balance must include borrowed amount + flash loan fee.
Complete Example: Flash Loan Arbitrage
import { flashloanPTB, repayFlashLoanPTB } from '@naviprotocol/lending'
import { Transaction } from '@mysten/sui/transactions'
async function executeFlashLoanArbitrage() {
const tx = new Transaction()
const [borrowedBalance, receipt] = await flashloanPTB(
tx,
'0x2::sui::SUI',
1_000_000_000,
{ env: 'prod' }
)
// Execute arbitrage logic here
await repayFlashLoanPTB(
tx,
'0x2::sui::SUI',
receipt,
borrowedBalance,
{ env: 'prod' }
)
// Submit transaction
}Comparison: Navi Vs DeepBook Vs Cetus
| Feature | Navi Flash Loan SDK | DeepBook Flash Loan | Cetus Flash Loan |
|---|---|---|---|
| Abstraction level | High (SDK + PTB helpers) | Medium | Low (Move-level) |
| Language | JS / TS | TS | Move |
| Asset discovery | Built-in APIs | Manual | Manual |
| Transaction safety | Abstracted | Semi-manual | Manual |
| Best for | Fast integration, non-Move devs | Orderbook strategies | Protocol-native control |
Troubleshooting And Common Errors
Transaction Reverted
Cause: Borrow and repay are not executed in the same transaction.
Solution: Ensure both steps are added to the same PTB.
Insufficient Repayment
Cause: Fee is not included in repayment.
Solution: Repay borrowed amount plus flashloanFee.
Unsupported Asset Or Pool
Cause: The pool does not support flash loans.
Solution: Verify availability using getAllFlashLoanAssets.
Borrow Amount Exceeds Limit
Cause: Amount is greater than max.
Solution: Check limits before borrowing.
Missing Or Invalid Receipt
Cause: Receipt is not passed correctly.
Solution: Always use the receipt returned from flashloanPTB.
Debugging Tips
- Start with small borrow amounts
- Log intermediate balances during development
- Test in non-production environments first
- Avoid conditional logic that may skip repayment
Why Use Navi Flash Loan SDK
- JavaScript/TypeScript SDK abstraction
- Safer PTB-based transaction construction
- Built-in asset discovery and limit checking
Navi Flash Loan is designed to help developers focus on strategy and outcomes, not protocol boilerplate.