Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Solana Anchor Flash Loan Protocol

A production-grade, secure Flash Loan smart contract built on Solana using the Anchor Framework and Instruction Introspection (solana_program::sysvar::instructions).


💡 Architecture & Security Highlights

  1. Atomic Flash Loans via Sysvar Introspection:
    • Verifies within borrow_flash_loan that a corresponding repay_flash_loan instruction targeting the same program exists in the same atomic transaction.
  2. Deterministic PDA Vaults:
    • Vault PDA seeds: [b"flash_loan_vault", mint.key()]
    • Pool PDA seeds: [b"flash_loan_pool", mint.key()]
  3. Protocol Fees:
    • 0.09% (9 basis points) fee per flash loan, accumulating autonomously into pool fees.
  4. Safety & Overflow Protection:
    • checked_add, checked_mul, checked_div arithmetic across all fee and balance calculations.
    • SPL Token CPI transfers with PDA signer seeds.

🛠️ Instructions Included

  • 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.

🧪 Testing

anchor test

About

Production-grade Solana Anchor Flash Loan protocol with instruction sysvar introspection

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages