When to use it
- The previous Aave generation, where a chain still runs its market. Where a chain has both,
Aave V3 is the current market (
aave-v3).
Pitfalls for a program
- The supply call is
deposit, notsupply; approve the LendingPool first. onBehalfOfreceives the aTokens. The caller is the Pot, sopotkeeps them in the Pot, not in the user’s wallet: choose which, and pass the wallet as amainparameter to deliver them.- aTokens are rebasing: measure balances as deltas.
- A frozen reserve refuses new deposits: check the reserve accepts them before relying on it.
- Borrowing and liquidation work as in Aave V3, by health factor.
In a Sauce program
Deposit the Pot’s USDC foronBehalfOf, the user’s wallet or the Pot (pot):
Notes
- interestRateMode: 1 = stable, 2 = variable. Most users use variable rate
- referralCode is always 0 (referral program inactive)
- Legacy protocol — consider Aave V3 for new deployments
- All deposit/repay operations require prior ERC-20 approval to the LendingPool address
Its names in a program
On Ethereum,AaveV2 is a namespace: its contracts need no import.
Deployments
ABI
LendingPoolABI
import LendingPoolABI from "./protocols/aave-v2/LendingPoolABI.json"; Speaks for: lendingPool.
deposit(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 rateMode, address onBehalfOf) returns (uint256)
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.
