A production-grade, secure Flash Loan smart contract built on Solana using the Anchor Framework and Instruction Introspection (solana_program::sysvar::instructions).
- Atomic Flash Loans via Sysvar Introspection:
- Verifies within
borrow_flash_loanthat a correspondingrepay_flash_loaninstruction targeting the same program exists in the same atomic transaction.
- Verifies within
- Deterministic PDA Vaults:
- Vault PDA seeds:
[b"flash_loan_vault", mint.key()] - Pool PDA seeds:
[b"flash_loan_pool", mint.key()]
- Vault PDA seeds:
- Protocol Fees:
- 0.09% (9 basis points) fee per flash loan, accumulating autonomously into pool fees.
- Safety & Overflow Protection:
checked_add,checked_mul,checked_divarithmetic across all fee and balance calculations.- SPL Token CPI transfers with PDA signer seeds.
initialize_pool: Creates pool & vault for an SPL token mint.deposit_liquidity: Allows LPs to supply liquidity.borrow_flash_loan: Issues flash loan and asserts repayment index.repay_flash_loan: Repays borrowed capital + 0.09% fee.withdraw_admin: Enables pool admin to claim collected fees.
anchor test