Flash Loans and Callbacks

Learn how Lotus flash loans and operation callbacks enable atomic strategies like leveraged positions, refinancing, collateral swaps, and liquidation flows.

Lotus exposes flash loans and optional callbacks on key protocol functions — enabling atomic strategies like leveraged positions, refinancing, collateral swaps, and liquidation integrations.

Flash loans

A flash loan transfers assets to the caller, executes a callback, and requires repayment within the same transaction. Callbacks are also available on supply, repay, liquidate, and supply collateral. See Build → Flash Actions for developer guidance.

┌─────────────────────────────────────────────────────────────────────┐
│                   Flash Loan Flow                                   │
└─────────────────────────────────────────────────────────────────────┘

  User               Lotus Core           User Callback
   │                     │                      │
   │  flashLoan()        │                      │
   ├────────────────────►│                      │
   │                     │  Transfer assets     │
   │◄────────────────────┤                      │
   │                     │                      │
   │                     │  Invoke callback     │
   │                     ├─────────────────────►│
   │                     │                      │
   │                     │               Execute strategy
   │                     │               (swap, supply, etc.)
   │                     │                      │
   │                     │  Return success      │
   │                     │◄─────────────────────┤
   │                     │                      │
   │                     │  Verify repayment    │
   │                     │  Pull assets         │
   │                     │                      │
   │  Success            │                      │
   │◄────────────────────┤                      │

Callback Support:
─────────────────
• supply() - optional callback
• repay() - optional callback
• liquidate() - optional callback
• flashLoan() - required callback
• supplyCollateral() - optional callback

Constraints:
────────────
✓ Callback must succeed
✓ Must repay flash loan (exact amount, no fee)
✓ No reentrancy allowed
✓ Atomic: reverts on failure

Last updated