Flash Loans

Flash loans are executed by constructing a Solana transaction, where the starting instruction is the FlashLoanBegin and the final instruction is FlashLoanEnd from the LEH V4 program. The intermediate instructions can invoke any Solana program of choice. FlashLoanBegin transfers tokens from the LEH vaults to the designated token accounts, while FlashLoanEnd returns any excess amount per token back to the vaults compared to the initial amount before the transaction.

The swap functionality in the LEH Web UI essentially executes a margin trade using Jupiter.

Constraints:

  • Borrowing for a particular token can only occur once.

  • Flash loans cannot be invoked via cross-program invocation.

  • Only LEH instructions allowed are FlashLoanBegin and FlashLoanEnd.

  • The initial health of the involved LEH account at the end of the transaction must either be above 0 or better than the initial health before the transaction.

Last updated