AaveLendingModule.sol
Lending functions are standardized for STEX AMM using a Lending Module, upgradable under timelock in the Withdrawal Module. This allows new lending markets with custom integration logic to be added without redeploying STEX AMM.
The AAVE Lending Module Facilitate deposits and withdrawals with Aave v3 protocol for yield generation on supported assets. Owner of this contract is set as the Withdrawal Module.
Core Market Interactions
1. deposit()
Purpose: Deposit Native Token (token1) into Aave v3 pool
Checks:
Can only be called by owner, which is set as the Withdrawal Module
Reentrancy safety handled by Aave
Flow:
Transfer asset from sender (Withdrawal Module) to Lending Module contract
Approve Aave pool to spend assets
Call Aave's
supply()
to mint aTokenaTokens are held in the
AaveLendingModule
2. Withdraw()
Purpose: Redeem assets from Aave v3Parameters
Parameters:
_amount
: aTokens to redeem_
recipient
: Asset receiver addressIn the case where withdraw is initiated by owner, recipient is the pool
In the case where withdraw is initiated by
STEXAMM
for an LP withdraw: recipient can be the user directly, orDepositWrapper
when unwrapping is neededIn the case where withdraw is initiated as a result of a change to the
Lending Module
, recipient is theWithdrawal Module
Checks:
Only callable by Owner (Withdraw Module)
Recipient cannot be zero address (enforced by Aave)
Sufficient aToken balance
Flow:
Calls Aave's withdraw()
Transfers underlying asset directly to recipient
Burns corresponding aTokens
Helper Functions
1. assetBalance()
Purpose: Check current aToken holdings
Returns:
aToken balance of contract
Represents total deposited token1 + yield earned
\
Last updated
Was this helpful?