Research and Development for an Aave V3 leverage engine: leverage a EURC collateral position by borrowing USDC against it on Aave, swapping the borrowed USDC back into EURC via Uniswap V3, and re-supplying — atomically via a Morpho Blue flashloan (Morpho is used purely as a zero-fee flashloan source here, not as the lending market).
-
LeverageAave- contract to supply/borrow/increase/decrease/close a leveraged Aave position. -
LeverageAaveFactory- deploys per-ownerLeverageAaveinstances. - Off-chain sizing helpers (swap quoting, LTV/health-factor targeting).
- Tests (fork-based round trip + revert paths).
See docs/leverage-mechanism.md for the mechanism and math.
This repo is templated from frankencoin-utils — same Hardhat +
TypeScript + Ignition tooling, adapted for an Aave-based (rather than Frankencoin-based) leverage
mechanism.
// yarn run <command> args...
"wallet": "npx ts-node helper/wallet.info.ts",
"wallet:info": "npx ts-node helper/wallet.info.ts",
"compile": "npx hardhat compile",
"test": "npx hardhat test",
"coverage": "npx hardhat coverage",
"deploy": "npx hardhat ignition deploy",
"verify": "npx hardhat verify",
"npm:build": "tsup",
"npm:publish": "npm publish --access public"yarn install
See .env.example
file: .env
ALCHEMY_RPC_KEY=...
DEPLOYER_SEED="test test test test test test test test test test test junk"
DEPLOYER_SEED_INDEX=1 // optional, select deployer
ETHERSCAN_API=...Create new session or re-navigate to the current directory, to make sure environment is loaded from
.env
Develop your contracts in the
/contractsdirectory and compile with:
yarn run compile # Compiles all contractsAll test files are located in /test directory. Run tests using:
yarn run test # Run all tests
yarn run test test/LeverageAave.ts # Run specific test file
yarn run coverage # Generate test coverage reportDeployment modules are located in /ignition/modules. Fill in
ignition/params/LeverageAave.ts(Aave Pool, Morpho, loan/collateral tokens, aToken/debtToken, Uniswap router, owner) first, then deploy:
yarn run deploy ignition/modules/LeverageAave.ts --network mainnet --verify --deployment-id LeverageAave01This will:
- Compile and deploy contracts
- Verify on Etherscan and Sourcify
- Generate deployment artifacts in /ignition/deployments
Key deployment files:
- deployed_addresses.json: Contains contract addresses
- journal.json: Detailed deployment logs
- constructor-args in /ignition/constructor-args, as JS module export
npx hardhat verify --network mainnet --constructor-args ./ignition/constructor-args/$FILE.js $ADDRESS
or manually include unrelated contracts
npx hardhat ignition verify $DEPLOYMENT --include-unrelated-contracts
contracts/
aave/ Minimal Aave V3 Pool interface (supply/withdraw/borrow/repay)
morpho/ Morpho Blue flashloan interface + callback (flashloan source only)
utils/ IOwnable / ExecuteOwnable — reusable owner-controlled base contracts
leverage-aave/ LeverageAave + LeverageAaveFactory
- Export ready to use TypeScript ABIs
- Export ready to use TypeScript deployed address config
See tsup.config.ts for the bundling entrypoint (./exports/index.ts, not yet created) and
yarn run npm:build / yarn run npm:publish to build/publish the package once exports exist.