Lev3x Aave Leverage
Lev3xAaveLeverageModule.sol
lever
MANAGER ONLY: Increases leverage for a given base (collateral) token using an enabled borrow asset (e.g. usdc in bull case). Borrows _borrowAsset from Aave. Performs a DEX trade, exchanging the _borrowAsset for _collateralAsset. Deposits _collateralAsset to Aave and mints corresponding aToken.
Note: Both collateral and borrow assets need to be enabled, and they must not be the same asset. Do this on Initialize.
Example:
_setToken Instance of the SetToken
_borrowAsset Address of underlying asset being borrowed for leverage
_collateralAsset Address of underlying collateral asset
_borrowQuantityUnits Borrow quantity of asset in position units
_minReceiveQuantityUnits Min receive quantity of collateral asset to receive post-trade in position units
_tradeAdapterName Name of trade adapter
_tradeData Arbitrary data for trade
delever
MANAGER ONLY: Decrease leverage for a given collateral (base) token using an enabled borrow asset. Withdraws _collateralAsset from Aave. Performs a DEX trade, exchanging the _collateralAsset for _repayAsset (i.e. borrowAsset). Repays _repayAsset to Aave and decreases leverage of index accordingly.
Note: Both collateral and borrow assets need to be enabled, and they must not be the same asset. Do this on initialize.
_setToken Instance of the SetToken
_collateralAsset Address of underlying collateral asset being withdrawn
_repayAsset Address of underlying borrowed asset being repaid
_redeemQuantityUnits Quantity of collateral asset to delever in position units
_minRepayQuantityUnits Minimum amount of repay asset to receive post trade in position units
_tradeAdapterName Name of trade adapter
_tradeData Arbitrary data for trade
autoLever
AUTHORIZED CALLER (BOT) ONLY: Increases leverage for a given base (collateral) token using an enabled borrow asset (e.g. usdc in bull case). Borrows _borrowAsset from Aave. Performs a DEX trade, exchanging the _borrowAsset for _collateralAsset. Deposits _collateralAsset to Aave and mints corresponding aToken.
Note: Both collateral and borrow assets need to be enabled, and they must not be the same asset. Do this on Initialize.
_setToken Instance of the SetToken
_borrowAsset Address of underlying asset being borrowed for leverage
_collateralAsset Address of underlying collateral asset
_borrowQuantityUnits Borrow quantity of asset in position units
_minReceiveQuantityUnits Min receive quantity of collateral asset to receive post-trade in position units
_tradeAdapterName Name of trade adapter
_tradeData Arbitrary data for trade
autoLever
AUTHORIZED CALLER (BOT) ONLY: Decrease leverage for a given collateral (base) token using an enabled borrow asset. Withdraws _collateralAsset from Aave. Performs a DEX trade, exchanging the _collateralAsset for _repayAsset (i.e. borrowAsset). Repays _repayAsset to Aave and decreases leverage of index accordingly. Note: Both collateral and borrow assets need to be enabled, and they must not be the same asset. Do this on initialize.
Note: This is CRITICAL to be called if position health factor becomes low.
_setToken Instance of the SetToken
_collateralAsset Address of underlying collateral asset being withdrawn
_repayAsset Address of underlying borrowed asset being repaid
_redeemQuantityUnits Quantity of collateral asset to delever in position units
_minRepayQuantityUnits Minimum amount of repay asset to receive post trade in position units
_tradeAdapterName Name of trade adapter
_tradeData Arbitrary data for trade
initialize
MANAGER ONLY: Initializes this module to the SetToken. Either the SetToken needs to be on the allowed list or anySetAllowed needs to be true. Only callable by the SetToken's manager.
Note: Managers can enable collateral and borrow assets that don't exist as positions on the SetToken
_setToken Instance of the SetToken to initialize
_collateralAssets Underlying tokens to be enabled as collateral in the SetToken
_borrowAssets Underlying tokens to be enabled as borrow in the SetToken
registerToModule
MANAGER ONLY: Add registration of this module on the debt issuance module for the SetToken.
Note: if the debt issuance module is not added to SetToken before this module is initialized, then this function needs to be called if the debt issuance module is later added and initialized to prevent state inconsistencies
_setToken Instance of the SetToken
_debtIssuanceModule Debt issuance module address to register
updateAllowedSetToken
GOVERNANCE ONLY: Enable/disable ability of a SetToken to initialize this module. Only callable by governance.
_setToken Instance of the SetToken
_status Bool indicating if _setToken is allowed to initialize this module
updateAnySetAllowed
GOVERNANCE ONLY: Toggle whether ANY SetToken is allowed to initialize this module. Only callable by governance.
_anySetAllowed Bool indicating if ANY SetToken is allowed to initialize this module
Last updated