When to use it
- Earn interest on an asset the market lists, or borrow one against everything you supplied in that market. One Pool per market holds every reserve.
- Choose it over Compound V3 when you need to borrow more than one asset against shared collateral, and over Morpho Blue when you want one shared market rather than isolated ones.
Pitfalls for a program
supplypulls the asset withtransferFrom: approve the Pool for exactly the amount first.onBehalfOfreceives the aTokens, and with them the position. Every call comes from the Pot, sopotthere keeps the position in the Pot, not in the user’s wallet; choose which, and pass the wallet as amainparameter to give it to the user. A position in the wallet is the wallet’s:withdrawburns the caller’s aTokens, so a later cook withdraws it only once they are back in the Pot, and borrows against it only with the wallet’s credit delegation.- The aToken minted to
onBehalfOfis rebasing: its balance grows with interest, so measure it as a delta, not as the amount supplied. - A reserve can be frozen, paused or at its supply cap, and then
supplyreverts. - Borrowing needs collateral and keeps the position’s health factor (from
getUserAccountData, scaled by 1e18) above 1; below it, anyone may liquidate. withdrawwith~0withdraws everything; it reverts if that would leave a borrow undercollateralized.flashLoanSimplecalls back a receiver contract, which a Sauce program cannot be.
In a Sauce program
Supply the Pot’s USDC foronBehalfOf (the user’s wallet, or pot to keep the position in
the Pot) and check the position now has collateral:
Notes
- interestRateMode: 1 = stable (deprecated on most markets), 2 = variable
- referralCode is always 0 (referral program inactive)
- V3 introduced efficiency mode (eMode) for correlated assets, isolation mode for new assets, and siloed borrowing
- All supply/repay operations require prior ERC-20 approval to the Pool address
- healthFactor < 1e18 means position is liquidatable
Its names in a program
On Ethereum,AaveV3 is a namespace: its contracts need no import.
Deployments
ABI
PoolABI
import PoolABI from "./protocols/aave-v3/PoolABI.json"; Speaks for: pool.
supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)withdraw(address asset, uint256 amount, address to) returns (uint256)borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf)repay(address asset, uint256 amount, uint256 interestRateMode, address onBehalfOf) returns (uint256)flashLoanSimple(address receiverAddress, address asset, uint256 amount, bytes params, uint16 referralCode)liquidationCall(address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken)getUserAccountData(address user) view returns (uint256 totalCollateralBase, uint256 totalDebtBase, uint256 availableBorrowsBase, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor)
Next steps
- Protocols: the other protocols, by what they do.
- Protocols and tokens: calling a contract by its namespace, or through its ABI.
- Glossary: the words these pages use, in plain terms.
