🧪 ALPHA TESTING PHASE 🧪
- 1. Overview
- 2. WebApp
- 3. Installation
- 4. Testing
- 5. Deployment
- 6. Upgrades
- 7. Interactions
- 7.1. Grant Role
- 7.2. Revoke Role
- 7.3. Fund contract with ETH
- 7.4. Update Health Factor Target
- 7.5. Update Slippage Tolerance
- 7.6. Rebalance Aave Position
- 7.7. Reinvest collateral
- 7.8. Supply from contract balance to Aave
- 7.9. Repay USDC from contract balance
- 7.10. Close Position
- 7.11. Withdraw wstETH to owner
- 7.12. Withdraw Token to owner
- 7.13. Borrow USDC and send it to an owner
- 7.14. Get Contract Balance
- 7.15. Get Aave Account Data
- 8. Build and Deploy Documentation
- 9. License
Docs Site: https://eridianalpha.github.io/aave-position-manager
A smart contract manager for Aave positions.
- Set a desired Health Factor.
- Send assets (ETH, WETH, wstETH, or USDC) to the contract.
- Reinvest and rebalance the position to maintain the desired Health Factor, either manually or with a bot.
- Borrow and withdraw USDC from the position while maintaining the desired Health Factor.
Function | Restrictions | Description |
---|---|---|
upgradeToAndCall | OWNER_ROLE |
Upgrade the contract. |
updateContractAddress | OWNER_ROLE |
Update the specified contract address. |
updateTokenAddress | OWNER_ROLE |
Update the specified token address. |
updateUniswapV3Pool | OWNER_ROLE |
Update the specified Uniswap V3 pool. |
updateManagerDailyInvocationLimit | OWNER_ROLE |
Update the daily invocation limit for the manager role. |
Function | Restrictions | Description |
---|---|---|
rebalance | MANAGER_ROLE |
Rebalance the Aave position to the desired Health Factor. |
reinvest | MANAGER_ROLE |
Reinvest the Aave position to the desired Health Factor target. |
deleverage | MANAGER_ROLE |
Deleverage the Aave position by paying back all reinvested debt. |
aaveSupplyFromContractBalance | MANAGER_ROLE |
Supply all the collateral from the contract balance to Aave. |
aaveRepayUSDCFromContractBalance | MANAGER_ROLE |
Repay Aave position debt using all the USDC from the contract balance. |
withdrawTokensFromContractBalance | MANAGER_ROLE |
Withdraw all the specified tokens from the contract to the specified owner. |
aaveBorrowAndWithdrawUSDC | MANAGER_ROLE |
Borrow USDC from Aave and withdraw to the specified owner. |
aaveWithdrawWstETH | MANAGER_ROLE |
Withdraw wstETH collateral from the Aave position to the specified owner. |
aaveClosePosition | MANAGER_ROLE |
Close the Aave position by repaying all debt and withdrawing all collateral to the specified owner. |
updateHealthFactorTarget | MANAGER_ROLE |
Set the desired Health Factor target. |
updateSlippageTolerance | MANAGER_ROLE |
Set the slippage tolerance for Uniswap V3 swaps. |
rescueEth | MANAGER_ROLE |
Rescue ETH from the contract to the specified owner. |
delegateCallHelper | MANAGER_ROLE |
Execute a delegate call to the specified module. |
A WebApp is being developed to allow easy interaction with the smart contract and will be linked here when available.
git clone https://github.com/EridianAlpha/aave-position-manager.git
This should happen automatically when first running a command, but the installation can be manually triggered with the following commands:
git submodule init
git submodule update
make install
Use the .env.example
file as a template to create a .env
file.
Configure an Ethernal account to interact with the smart contract through a UI. Ethernal is like Etherscan but for a custom network.
https://docs.eridianalpha.com/ethereum-dev/useful-tools/ethernal
make ethernal
make test-fork
make test-fork-v
make test-fork-summary
make coverage
make coverage-report
Deploys AavePM and all modules to the Anvil chain specified in the .env
file.
Chain | Command |
---|---|
Anvil | make deploy anvil |
Base Sepolia | make deploy base-sepolia |
Base Mainnet | make deploy base-mainnet |
Upgrade the contract to a new logic implementation while maintaining the same proxy address. This also redeploys all modules and updates their contract addresses on AavePM.
Chain | Command |
---|---|
Anvil | make upgrade anvil |
Base Sepolia | make upgrade base-sepolia |
Base Mainnet | make upgrade base-mainnet |
Interactions are defined in ./script/Interactions.s.sol
If DEPLOYED_CONTRACT_ADDRESS
is set in the .env
file, that contract address will be used for interactions.
If that variable is not set, the latest deployment on the specified chain will be used.
Grant a role to an address. Requires the caller to be an admin of the role being granted.
Input value 1 as a role e.g. MANAGER_ROLE
.
Input value 2 as an address e.g. 0x123...
.
Combined input value e.g. MANAGER_ROLE,0x123...
.
Chain | Command |
---|---|
Anvil | make grantRole anvil |
Base Sepolia | make grantRole base-sepolia |
Base Mainnet | make grantRole base-mainnet |
Revoke a role from an address. Requires the caller to be an admin of the role being revoked.
Input value 1 as a role e.g. MANAGER_ROLE
.
Input value 2 as an address e.g. 0x123...
.
Combined input value e.g. MANAGER_ROLE,0x123...
.
Chain | Command |
---|---|
Anvil | make revokeRole anvil |
Base Sepolia | make revokeRole base-sepolia |
Base Mainnet | make revokeRole base-mainnet |
Input value in ETH e.g. 0.15
.
Chain | Command |
---|---|
Anvil | make send-ETH anvil |
Base Mainnet | make send-ETH base-mainnet |
Input value to 2 decimal places e.g. 225
for a Health Factor target of 2.25
.
Chain | Command |
---|---|
Anvil | make update-hft anvil |
Base Mainnet | make update-hft base-mainnet |
Input value to 2 decimal places e.g. 200
for a Slippage Tolerance of 0.5%
.
Chain | Command |
---|---|
Anvil | make update-st anvil |
Base Mainnet | make update-st base-mainnet |
Rebalances the Aave position to maintain the desired Health Factor target.
REBALANCE_HFT_BUFFER
is a constant in the module that determines if a rebalance is required.
Chain | Command |
---|---|
Anvil | make rebalance anvil |
Base Mainnet | make rebalance base-mainnet |
Reinvests any collateral above the Health Factor target.
REINVEST_HFT_BUFFER
is a constant in the module that determines if a reinvest is required.
Chain | Command |
---|---|
Anvil | make reinvest anvil |
Base Mainnet | make reinvest base-mainnet |
Supplies any ETH, WETH, wstETH, or USDC in the contract to Aave.
Chain | Command |
---|---|
Anvil | make supply anvil |
Base Mainnet | make supply base-mainnet |
Repay any USDC debt in the contract to repay Aave position debt.
Chain | Command |
---|---|
Anvil | make repay anvil |
Base Mainnet | make repay base-mainnet |
Close the Aave position by repaying all debt and withdrawing all collateral.
Input value as an owner address. e.g. 0x123...
.
Chain | Command |
---|---|
Anvil | make closePosition anvil |
Base Mainnet | make closePosition base-mainnet |
Withdraw wstETH collateral from the Aave position to the specified owner.
Input value 1 in ETH e.g. 0.15
.
Input value 2 as an owner address e.g. 0x123...
.
Combined input value e.g. 0.15,0x123...
.
Chain | Command |
---|---|
Anvil | make withdrawWstETH anvil |
Base Mainnet | make withdrawWstETH base-mainnet |
Withdraw the specified token from the contract to the specified owner.
Input value 1 in token identifier e.g. USDC
.
Input value 2 as an owner address e.g. 0x123...
.
Combined input value e.g. USDC,0x123...
.
Chain | Command |
---|---|
Anvil | make withdrawToken anvil |
Base Mainnet | make withdrawToken base-mainnet |
Borrow USDC from Aave and withdraw to the specified owner.
Input value 1 in USDC e.g. 200
for $200 USDC.
Input value 2 as an owner address e.g. 0x123...
.
Combined input value e.g. 200,0x123...
.
Chain | Command |
---|---|
Anvil | make borrowUSDC anvil |
Base Mainnet | make borrowUSDC base-mainnet |
Input value as token identifier e.g. USDC
.
Chain | Command |
---|---|
Anvil | make getContractBalance anvil |
Base Mainnet | make getContractBalance base-mainnet |
Returns the Aave account data for the contract.
Chain | Command |
---|---|
Anvil | make getAaveAccountData anvil |
Base Mainnet | make getAaveAccountData base-mainnet |
Instructions on how to build and deploy the documentation book are detailed here: https://docs.eridianalpha.com/ethereum-dev/foundry-notes/docs-and-github-pages