POC Aave V3 flash loan with composability requests to Solana
-
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
-
Tech Stackβ
-
Neon EVM β EVM-compatible layer on Solana
-
Aave V3 Fork β DeFi protocol for flash loans on Neon
-
Orca β Solana-based DEX used for token swaps
-
USDC / SAMO β Arbitrary SPL tokens used in swap
-
Solidity β Smart contract logic
-
Composability Precompile β 0xFF00000000000000000000000000000000000006
-
Hardhat β Development framework
-
Blockscout β Explorer for Neon devnet
-
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.
-
Contract & Transaction Linksβ
- Verified Smart Contract:
0x1f464349eEAC5DbAD27c38cCe222d4D28bAc0824 (Blockscout) - Sample Transaction:
0x5d4a2c7aefebd85f7fc2c726f81496953655238125b7efc535c9efa6189ce8c0
-
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
-
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:
-
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