AAVE Token
The Aave protocol is migrating from its native LEND token to the AAVE token, as detailed in Aavenomics. The AAVE token is an ERC-20 compatible token with the addition of a snapshot feature (used in governance balance tracking) and integrates EIP 2612 permit function, allowing gas-less transactions and one transaction approval/transfer.
This section will cover the technical aspects of the token and token migration. For governance, security, and incentive details, see the Aavenomics documentation.
The source code for the AAVE token and migration can be found on Github here.

Deployed Contracts

Mainnet
When integrating, only the proxy contracts should be used.
The following are the current implementation of the contracts, which may be subject to change. Therefore always integrate the above proxy contracts only.
For details of staking and stkAAVE, see the Safety Module section.

Audits

Auditor
Audit Type
Consensys Diligence (AAVE token)
Smart Contract
Certik (AAVE token)
Smart Contract
Certora (AAVE token)
Properties Verification

LEND to AAVE migration

The LEND to AAVE migration will occur via user initiated actions, using the LendToAaaveMigrator contract. This can be performed in our app or by calling the LendToAaveMigrator contract directly.
For each amount of LEND migrated, amount/LEND_AAVE_RATIO of AAVE will be redeemed. The LEND_AAVE_RATIO is set at the time the contract is deployed and can be fetched by calling LEND_AAVE_RATIO() on the LendToAaveMigrator contract.
When the governance proposal for the token migration passes, the LendToAaveMigrator contract will be enabled. This is estimated to happen at Block 10978863.

Important considerations

Since the AAVE total supply will be lower than LEND total supply, the LEND_AAVE_RATIO must always be greater than 1, causing a loss of precision for amounts of LEND that are not multiples of LEND_AAVE_RATIO. For example, a person migrating 1.000000000000000022 LEND, with a LEND_AAVE_RATIO == 100, will receive 0.01 AAVE, losing the value of the last 22 units of LEND. For more details on the reasons for this approach, see the Github repo.

migrateFromLend()

function migrateFromLEND(uint256 amount) external
Migrates a certain amount of LEND to AAVE.
The user must approve() the amount for the LendToAaveMigrator contract to migrate, before execution.
Parameter
Type
Description
amount
uint256
The amount of LEND to be migrated

_totalLendMigrated()

function _totalLendMigrated() view public
Returns the total amount of LEND that has been migrated to AAVE.
Return Parameter
Type
Description
_totalLendMigrated
uint256
The amount of LEND already migrated

event LendMigrated()

event LendMigrated(address indexed sender, uint256 indexed amount)
An event emitted when a migrateFromLend() executes successfully.
Parameter
Type
Description
sender
address
The owner of the LEND and migrated AAVE
amount
uint256
The amount of LEND migrated

AAVE Token

As mentioned above, the AAVE token is an ERC-20 compatible token with the addition of a snapshot feature (used in governance balance tracking) and integrates EIP 2612 permit function, allowing gas-less transactions and one transaction approval/transfer.
Besides the standard ERC20 token features (transfer(), balanceOf(), allowance(), etc), the following features are also available.

permit()

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external
Allows a user to permit another account (or contract) to use their funds using a signed message. This enables gas-less transactions and single approval/transfer transactions.
Parameter
Type
Description
owner
address
The owner of the funds
spender
address
The spender for the funds
value
uint256
The amount the spender is permitted to use
deadline
uint256
The deadline timestamp that the permit is valid. Use uint(-1) for no deadline.
v
uint8
Signature parameter
r
bytes32
Signature parameter
s
bytes32
Signature parameter
Web3.js
1
import { signTypedData_v4 } from 'eth-sig-util'
2
import { fromRpcSig } from 'ethereumjs-util'
3
4
// ... other imports
5
6
import AaveTokenAbi from "./AaveTokenAbi.json"
7
8
// ... setup your web3 provider
9
10
const aaveTokenAddress = "AAVE_TOKEN_ADDRESS"
11
const aaveTokenContract = new web3.eth.Contract(AaveTokenAbi, aaveTokenAddress)
12
13
const privateKey = "YOUR_PRIVATE_KEY_WITHOUT_0x"
14
const chainId = 1
15
const owner = "OWNER_ADDRESS"
16
const spender = "SPENDER_ADDRESS"
17
const value = 100 // Amount the spender is permitted
18
const nonce = 1 // The next valid nonce, use `_nonces()`
19
const deadline = 1600093162
20
21
const permitParams = {
22
types: {
23
EIP712Domain: [
24
{ name: "name", type: "string" },
25
{ name: "version", type: "string" },
26
{ name: "chainId", type: "uint256" },
27
{ name: "verifyingContract", type: "address" },
28
],
29
Permit: [
30
{ name: "owner", type: "address" },
31
{ name: "spender", type: "address" },
32
{ name: "value", type: "uint256" },
33
{ name: "nonce", type: "uint256" },
34
{ name: "deadline", type: "uint256" },
35
],
36
},
37
primaryType: "Permit",
38
domain: {
39
name: "Aave Token",
40
version: "1",
41
chainId: chainId,
42
verifyingContract: aaveTokenAddress,
43
},
44
message: {
45
owner,
46
spender,
47
value,
48
nonce,
49
deadline,
50
},
51
}
52
53
const signature = signTypedData_v4(
54
Buffer.from(privateKey, "hex"),
55
{ data: permitParams }
56
)
57
58
const { v, r, s } = fromRpcSig(signature)
59
60
await aaveTokenContract.methods
61
.permit({
62
owner,
63
spender,
64
value,
65
deadline,
66
v,
67
r,
68
s
69
})
70
.send()
71
.catch((e) => {
72
throw Error(`Error permitting: ${e.message}`)
73
})
Copied!

_nonces()

function _nonces(address owner) public
Returns the next valid nonce to submit when calling permit()

event SnapshotDone

event SnapshotDone(address owner, uint128 oldValue, uint128 newValue)
An event emitted on every transfer, mint (with a valid to address), and burn (with a valid from address).
The snapshots are used for governance balance tracking.
Parameter
Type
Description
owner
address
The owner of the AAVE tokens
oldValue
uint128
The value before the operation was executed
newValue
uint128
The value after the operation was executed.
Last modified 1yr ago