ReinvestModule
Inherits: IReinvestModule
Author: EridianAlpha
This contract contains the functions for AavePM to borrow USDC, swap to wstETH, and supply to Aave maintaining the target health factor.
State Variables
VERSION
The version of the contract.
Contract is upgradeable so the version is a constant set on each implementation contract.
string public constant VERSION = "0.0.1";
aavePMProxyAddress
The address of the AavePM proxy contract.
The AavePM proxy address is set on deployment and is immutable.
address public immutable aavePMProxyAddress;
REINVEST_HFT_BUFFER
The buffer for the Health Factor Target reinvest calculation
uint16 public constant REINVEST_HFT_BUFFER = 10;
Functions
constructor
Contract constructor to set the AavePM proxy address.
The AavePM proxy address is set on deployment and is immutable.
constructor(address _aavePMProxyAddress);
Parameters
Name | Type | Description |
---|---|---|
_aavePMProxyAddress | address | The address of the AavePM proxy contract. |
onlyAavePM
Modifier to check that only the AavePM contract is the caller.
Uses address(this)
since this contract is called by the AavePM contract using delegatecall.
modifier onlyAavePM();
reinvest
Reinvest the Aave position.
This function reinvests the Aave position by borrowing USDC, swapping to wstETH, and supplying it back to Aave.
function reinvest() public onlyAavePM returns (uint256 reinvestedDebt);
Returns
Name | Type | Description |
---|---|---|
reinvestedDebt | uint256 | The amount of debt reinvested. |
_reinvestAction
Reinvest the Aave position.
This function actions the reinvestment of the Aave position.
function _reinvestAction(
IAavePM aavePM,
uint256 totalDebtBase,
address aavePoolAddress,
address usdcAddress,
address wstETHAddress,
uint256 initialCollateralBase,
uint256 currentLiquidationThreshold,
uint16 healthFactorTarget
) private returns (uint256 borrowAmountUSDC);
Parameters
Name | Type | Description |
---|---|---|
aavePM | IAavePM | The Aave Position Manager contract. |
totalDebtBase | uint256 | The total debt in base units. |
aavePoolAddress | address | The address of the Aave pool. |
usdcAddress | address | The address of the USDC token. |
wstETHAddress | address | The address of the wstETH token. |
initialCollateralBase | uint256 | The initial collateral in base units. |
currentLiquidationThreshold | uint256 | The current liquidation threshold. |
healthFactorTarget | uint16 | The target health factor. |
Returns
Name | Type | Description |
---|---|---|
borrowAmountUSDC | uint256 | The amount of USDC borrowed. |