Skip to main content
Legacy version of Aave lending protocol.

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, not supply; approve the LendingPool first.
  • onBehalfOf receives the aTokens. The caller is the Pot, so pot keeps them in the Pot, not in the user’s wallet: choose which, and pass the wallet as a main parameter 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 for onBehalfOf, 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