AaveLeverageModule

The AaveLeverageModule is a smart contract that enables leverage trading using Aave as the lending protocol. This module is paired with a debt issuance module that will call functions on this module to keep interest accrual and liquidation state updated. This does not allow borrowing of assets from Aave alone. Each asset is leveraged when using this module.

Integrations mappings to specify the exchange to trade on is stored in the IntegrationRegistry

Note: Do not use this module in conjunction with other debt modules that allow Aave debt positions as it could lead to double counting of debt when borrowed assets are the same.

Select Methods

lever()

function lever(ISetToken _setToken, IERC20 _borrowAsset, IERC20 _collateralAsset, uint256 _borrowQuantity, uint256 _minReceiveQuantity, string memory _tradeAdapterName, bytes memory _tradeData)

Manager only. Increases leverage for a given collateral position using an enabled borrow asset. 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

delever()

function delever(ISetToken _setToken, IERC20 _collateralAsset, IERC20 _repayAsset, uint256 _redeemQuantity, uint256 _minRepayQuantity, string memory _tradeAdapterName, bytes memory _tradeData)

Manager only. Decrease leverage for a given collateral position using an enabled borrow asset. Withdraws _collateralAsset from Aave. Performs a DEX trade, exchanging the _collateralAsset for _repayAsset. Repays _repayAsset to Aave and burns corresponding debt tokens. Note: Both collateral and borrow assets need to be enabled, and they must not be the same asset.

deleverToZeroBorrowBalance()

function deleverToZeroBorrowBalance(ISetToken _setToken, IERC20 _collateralAsset, IERC20 _repayAsset, uint256 _redeemQuantity, string memory _tradeAdapterName, bytes memory _tradeData)

Manager only. Pays down the borrow asset to 0 selling off a given amount of collateral asset. Withdraws _collateralAsset from Aave. Performs a DEX trade, exchanging the _collateralAsset for _repayAsset. Minimum receive amount for the DEX trade is set to the current variable debt balance of the borrow asset. Repays received _repayAsset to Aave which burns corresponding debt tokens. Any extra received borrow asset is updated as equity. No protocol fee is charged.

Note: Both collateral and borrow assets need to be enabled, and they must not be the same asset. The function reverts if not enough collateral asset is redeemed to buy the required minimum amount of _repayAsset.

sync()

function sync(ISetToken _setToken)

Anyone callable. Sync Set positions with ALL enabled Aave collateral and borrow positions. For collateral assets, update aToken default position. For borrow assets, update external borrow position.

  • Collateral assets may come out of sync when interest is accrued or a position is liquidated

  • Borrow assets may come out of sync when interest is accrued or position is liquidated and borrow is repaid

Note: In Aave, both collateral and borrow interest is accrued in each block by increasing the balance of aTokens and debtTokens for each user, and 1 aToken = 1 variableDebtToken = 1 underlying.

initialize()

function initialize(ISetToken _setToken, IERC20[] memory _collateralAssets, IERC20[] memory _borrowAssets)

Manager only. Initializes this module to the SetToken. Only callable by the SetToken's manager. Note: managers can enable collateral and borrow assets that don't exist as positions on the SetToken

Last updated