Skip to main content

POC Aave V3 flash loan with composability requests to Solana

  1. Overview​

This Proof of Concept (POC) demonstrates the use of a flash loan requested from a DeFi protocol (Aave V3 fork) deployed on Neon EVM, with subsequent on-chain composability requests to Solana, particularly to interact with Orca for token swaps.

The key goal is to prove:

  • That it’s technically feasible to borrow funds via flash loan on Neon EVM
  • Use the borrowed assets within the Solana runtime (via Orca)
  • Repay the loan within the same transaction lifecycle
  1. Tech Stack​

  2. Neon EVM – EVM-compatible layer on Solana

  3. Aave V3 Fork – DeFi protocol for flash loans on Neon

  4. Orca – Solana-based DEX used for token swaps

  5. USDC / SAMO – Arbitrary SPL tokens used in swap

  6. Solidity – Smart contract logic

  7. Composability Precompile – 0xFF00000000000000000000000000000000000006

  8. Hardhat – Development framework

  9. Blockscout – Explorer for Neon devnet

  10. Flow Diagram Description​

Below is a breakdown of each step in the flash loan lifecycle from the diagram:

1. Request Flash Loan from Aave V3 on Neon EVM

  • The smart contract deployed on Neon requests a flash loan of 10 USDC.
  • This triggers the Aave V3 fork flash loan mechanism.
  • The smart contract must implement the executeOperation callback per Aave V3 standards.

2. Receive 10 USDC

  • Aave V3 sends the borrowed amount (10 USDC) to the Neon EVM smart contract.

3. First Swap: USDC ➝ SAMO on Orca (via Solana composability)

  • The smart contract calls the composability precompile at address 0xFF00000000000000000000000000000000000006.
  • This call is bridged to a Solana runtime instruction to interact with the Orca swap program.
  • The contract swaps 10 USDC for ~995.76 SAMO using Orca’s swap pool.

4. Second Swap: SAMO ➝ USDC

  • Another composability call is made to Orca to swap back 995.76 SAMO for ~9.96 USDC.

5. Repay Loan

  • The contract repays the original flash loan of 10 USDC, plus a 0.005 USDC fee.
  • All of this happens within the same atomic transaction, as required by flash loan logic.
  1. Running the POC​

Use Hardhat to run the test file:

npx hardhat test test/AaveFlashLoan.js --network neondevnet

Make sure to:

  • Configure the neondevnet network in your hardhat.config.js
  • Have the contract deployed on Neon
  • Use mock tokens (USDC/SAMO) supported by Orca for testnet
  • Set up a test Orca pool if needed for devnet testing
  1. About Neon EVM Composability​

The composability layer allows Solidity contracts on Neon EVM to send Solana CPI (Cross-Program Invocations) through a precompiled contract:

Reference:

Neon Composability Docs

  1. Conclusion​

This POC validates that:

  • Flash loans on Neon EVM (via Aave V3 fork) are functional
  • Assets borrowed in EVM runtime can be used in Solana via composability
  • Atomic execution across runtimes is possible
  • Loans can be repaid within the same transaction, fulfilling flash loan conditions
Was this page helpful?