Skip to content

About

Research and Development for Aave Leverage Utils

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Aave Utils

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-owner LeverageAave instances.
  • 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 Package Scripts

// 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"

1. Install dependencies

yarn install

2. Set Environment

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

3. Develop Smart Contracts

Develop your contracts in the /contracts directory and compile with:

yarn run compile					# Compiles all contracts

4. Testing

All 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 report

5. Write Deployment Scripts (via ignition deploy and verify)

Deployment 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 LeverageAave01

This 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

5.1 Manual Verify

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

6. Contracts Overview

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

7. Prepare NPM Package Support

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

About

Research and Development for Aave Leverage Utils

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages