Aave Token
ERC20
This contract is an ERC20 token.
Name
Aave Token
Symbol
AAVE
Decimals
18
Total Supply
16,000,000 AAVE
About link description
Aave (AAVE) is a cryptocurrency and operates on the Ethereum platform. Aave has a current supply of 16,000,000 with 12,840,891.1171971 in circulation. The last known price of Aave is 267.2030478 USD and is down -0.69 over the last 24 hours. It is currently trading on 217 active market(s) with $321,413,072.46 traded over the last 24 hours. More information can be found at https://aave.com/.
Stats
Public Functions
21
Event Types
4
Code Size
46,232 bytes
Library Use
Uses SafeMath for uint256.
Events (4) keyboard_arrow_up
Constants (9) keyboard_arrow_up
State Variables (17) keyboard_arrow_up
_propositionPowerSnapshots Variable
mapping(address => mapping(uint256 => Snapshot)) help
Internal Variable
Functions
name keyboard_arrow_up
symbol keyboard_arrow_up
decimals keyboard_arrow_up
totalSupply keyboard_arrow_up
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
Requirements help
Source Code
function transfer(address recipient, uint256 amount)
public
virtual
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
allowance keyboard_arrow_up
approve keyboard_arrow_up
Requirements help
Source Code
function approve(address spender, uint256 amount)
public
virtual
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
transferFrom keyboard_arrow_up
Requirements help
Source Code
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
increaseAllowance keyboard_arrow_up
Requirements help
Source Code
function increaseAllowance(address spender, uint256 addedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].add(addedValue)
);
return true;
}
decreaseAllowance keyboard_arrow_up
Requirements help
Source Code
function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(
subtractedValue,
"ERC20: decreased allowance below zero"
)
);
return true;
}
delegateByType keyboard_arrow_up
Source Code
function delegateByType(address delegatee, DelegationType delegationType)
external
override
{
_delegateByType(msg.sender, delegatee, delegationType);
}
delegate keyboard_arrow_up
Requirements help
Source Code
function delegate(address delegatee) external override {
_delegateByType(msg.sender, delegatee, DelegationType.VOTING_POWER);
_delegateByType(msg.sender, delegatee, DelegationType.PROPOSITION_POWER);
}
getDelegateeByType keyboard_arrow_up
Source Code
function getDelegateeByType(address delegator, DelegationType delegationType)
external
view
override
returns (address)
{
(
,
,
mapping(address => address) storage delegates
) = _getDelegationDataByType(delegationType);
return _getDelegatee(delegator, delegates);
}
getPowerCurrent keyboard_arrow_up
Requirements help
Source Code
function getPowerCurrent(address user, DelegationType delegationType)
external
view
override
returns (uint256)
{
(
mapping(address => mapping(uint256 => Snapshot)) storage snapshots,
mapping(address => uint256) storage snapshotsCounts,
) = _getDelegationDataByType(delegationType);
return _searchByBlockNumber(snapshots, snapshotsCounts, user, block.number);
}
getPowerAtBlock keyboard_arrow_up
Parameters help
Requirements help
Source Code
function getPowerAtBlock(
address user,
uint256 blockNumber,
DelegationType delegationType
) external view override returns (uint256) {
(
mapping(address => mapping(uint256 => Snapshot)) storage snapshots,
mapping(address => uint256) storage snapshotsCounts,
) = _getDelegationDataByType(delegationType);
return _searchByBlockNumber(snapshots, snapshotsCounts, user, blockNumber);
}
totalSupplyAt keyboard_arrow_up
initialize keyboard_arrow_up
permit keyboard_arrow_up
Parameters help
Requirements help
Source Code
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external {
require(owner != address(0), "INVALID_OWNER");
//solium-disable-next-line
require(block.timestamp <= deadline, "INVALID_EXPIRATION");
uint256 currentValidNonce = _nonces[owner];
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR,
keccak256(
abi.encode(
PERMIT_TYPEHASH,
owner,
spender,
value,
currentValidNonce,
deadline
)
)
)
);
require(owner == ecrecover(digest, v, r, s), "INVALID_SIGNATURE");
_nonces[owner] = currentValidNonce.add(1);
_approve(owner, spender, value);
}
delegateByTypeBySig keyboard_arrow_up
Parameters help
Requirements help
Source Code
function delegateByTypeBySig(
address delegatee,
DelegationType delegationType,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) public {
bytes32 structHash = keccak256(
abi.encode(
DELEGATE_BY_TYPE_TYPEHASH,
delegatee,
uint256(delegationType),
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, structHash)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "INVALID_SIGNATURE");
require(nonce == _nonces[signatory]++, "INVALID_NONCE");
require(block.timestamp <= expiry, "INVALID_EXPIRATION");
_delegateByType(signatory, delegatee, delegationType);
}
delegateBySig keyboard_arrow_up
Parameters help
Requirements help
Source Code
function delegateBySig(
address delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) public {
bytes32 structHash = keccak256(
abi.encode(DELEGATE_TYPEHASH, delegatee, nonce, expiry)
);
bytes32 digest = keccak256(
abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, structHash)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "INVALID_SIGNATURE");
require(nonce == _nonces[signatory]++, "INVALID_NONCE");
require(block.timestamp <= expiry, "INVALID_EXPIRATION");
_delegateByType(signatory, delegatee, DelegationType.VOTING_POWER);
_delegateByType(signatory, delegatee, DelegationType.PROPOSITION_POWER);
}
Internal Functions
Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.
internal AaveTokenV2.getRevision keyboard_arrow_up
internal AaveTokenV2._beforeTokenTransfer keyboard_arrow_up
Source Code
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal override {
address votingFromDelegatee = _getDelegatee(from, _votingDelegates);
address votingToDelegatee = _getDelegatee(to, _votingDelegates);
_moveDelegatesByType(
votingFromDelegatee,
votingToDelegatee,
amount,
DelegationType.VOTING_POWER
);
address propPowerFromDelegatee = _getDelegatee(
from,
_propositionPowerDelegates
);
address propPowerToDelegatee = _getDelegatee(to, _propositionPowerDelegates);
_moveDelegatesByType(
propPowerFromDelegatee,
propPowerToDelegatee,
amount,
DelegationType.PROPOSITION_POWER
);
// caching the aave governance address to avoid multiple state loads
ITransferHook aaveGovernance = _aaveGovernance;
if (aaveGovernance != ITransferHook(0)) {
aaveGovernance.onTransfer(from, to, amount);
}
}
internal AaveTokenV2._getDelegationDataByType keyboard_arrow_up
Source Code
function _getDelegationDataByType(DelegationType delegationType)
internal
view
override
returns (
mapping(address => mapping(uint256 => Snapshot)) storage, //snapshots
mapping(address => uint256) storage, //snapshots count
mapping(address => address) storage //delegatees list
)
{
if (delegationType == DelegationType.VOTING_POWER) {
return (_votingSnapshots, _votingSnapshotsCounts, _votingDelegates);
} else {
return (
_propositionPowerSnapshots,
_propositionPowerSnapshotsCounts,
_propositionPowerDelegates
);
}
}
internal GovernancePowerDelegationERC20._delegateByType keyboard_arrow_up
Parameters help
Source Code
function _delegateByType(
address delegator,
address delegatee,
DelegationType delegationType
) internal {
require(delegatee != address(0), "INVALID_DELEGATEE");
(
,
,
mapping(address => address) storage delegates
) = _getDelegationDataByType(delegationType);
uint256 delegatorBalance = balanceOf(delegator);
address previousDelegatee = _getDelegatee(delegator, delegates);
delegates[delegator] = delegatee;
_moveDelegatesByType(
previousDelegatee,
delegatee,
delegatorBalance,
delegationType
);
emit DelegateChanged(delegator, delegatee, delegationType);
}
internal GovernancePowerDelegationERC20._moveDelegatesByType keyboard_arrow_up
Parameters help
Source Code
function _moveDelegatesByType(
address from,
address to,
uint256 amount,
DelegationType delegationType
) internal {
if (from == to) {
return;
}
(
mapping(address => mapping(uint256 => Snapshot)) storage snapshots,
mapping(address => uint256) storage snapshotsCounts,
) = _getDelegationDataByType(delegationType);
if (from != address(0)) {
uint256 previous = 0;
uint256 fromSnapshotsCount = snapshotsCounts[from];
if (fromSnapshotsCount != 0) {
previous = snapshots[from][fromSnapshotsCount - 1].value;
} else {
previous = balanceOf(from);
}
_writeSnapshot(
snapshots,
snapshotsCounts,
from,
uint128(previous),
uint128(previous.sub(amount))
);
emit DelegatedPowerChanged(from, previous.sub(amount), delegationType);
}
if (to != address(0)) {
uint256 previous = 0;
uint256 toSnapshotsCount = snapshotsCounts[to];
if (toSnapshotsCount != 0) {
previous = snapshots[to][toSnapshotsCount - 1].value;
} else {
previous = balanceOf(to);
}
_writeSnapshot(
snapshots,
snapshotsCounts,
to,
uint128(previous),
uint128(previous.add(amount))
);
emit DelegatedPowerChanged(to, previous.add(amount), delegationType);
}
}
internal GovernancePowerDelegationERC20._searchByBlockNumber keyboard_arrow_up
Parameters help
Requirements help
Source Code
function _searchByBlockNumber(
mapping(address => mapping(uint256 => Snapshot)) storage snapshots,
mapping(address => uint256) storage snapshotsCounts,
address user,
uint256 blockNumber
) internal view returns (uint256) {
require(blockNumber <= block.number, "INVALID_BLOCK_NUMBER");
uint256 snapshotsCount = snapshotsCounts[user];
if (snapshotsCount == 0) {
return balanceOf(user);
}
// First check most recent balance
if (snapshots[user][snapshotsCount - 1].blockNumber <= blockNumber) {
return snapshots[user][snapshotsCount - 1].value;
}
// Next check implicit zero balance
if (snapshots[user][0].blockNumber > blockNumber) {
return 0;
}
uint256 lower = 0;
uint256 upper = snapshotsCount - 1;
while (upper > lower) {
uint256 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Snapshot memory snapshot = snapshots[user][center];
if (snapshot.blockNumber == blockNumber) {
return snapshot.value;
} else if (snapshot.blockNumber < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return snapshots[user][lower].value;
}
internal GovernancePowerDelegationERC20._getDelegationDataByType keyboard_arrow_up
Source Code
function _getDelegationDataByType(DelegationType delegationType)
internal
view
virtual
returns (
mapping(address => mapping(uint256 => Snapshot)) storage, //snapshots
mapping(address => uint256) storage, //snapshots count
mapping(address => address) storage //delegatees list
);
internal GovernancePowerDelegationERC20._writeSnapshot keyboard_arrow_up
Parameters help
Source Code
function _writeSnapshot(
mapping(address => mapping(uint256 => Snapshot)) storage snapshots,
mapping(address => uint256) storage snapshotsCounts,
address owner,
uint128 oldValue,
uint128 newValue
) internal {
uint128 currentBlock = uint128(block.number);
uint256 ownerSnapshotsCount = snapshotsCounts[owner];
mapping(uint256 => Snapshot) storage snapshotsOwner = snapshots[owner];
// Doing multiple operations in the same block
if (
ownerSnapshotsCount != 0 &&
snapshotsOwner[ownerSnapshotsCount - 1].blockNumber == currentBlock
) {
snapshotsOwner[ownerSnapshotsCount - 1].value = newValue;
} else {
snapshotsOwner[ownerSnapshotsCount] = Snapshot(currentBlock, newValue);
snapshotsCounts[owner] = ownerSnapshotsCount + 1;
}
}
internal GovernancePowerDelegationERC20._getDelegatee keyboard_arrow_up
Source Code
function _getDelegatee(
address delegator,
mapping(address => address) storage delegates
) internal view returns (address) {
address previousDelegatee = delegates[delegator];
if (previousDelegatee == address(0)) {
return delegator;
}
return previousDelegatee;
}
internal ERC20._transfer keyboard_arrow_up
Requirements help
Source Code
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(
amount,
"ERC20: transfer amount exceeds balance"
);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
internal ERC20._mint keyboard_arrow_up
Source Code
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
internal ERC20._burn keyboard_arrow_up
Source Code
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(
amount,
"ERC20: burn amount exceeds balance"
);
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
internal ERC20._approve keyboard_arrow_up
Requirements help
Source Code
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
internal ERC20._setupDecimals keyboard_arrow_up
internal ERC20._beforeTokenTransfer keyboard_arrow_up
internal Context._msgSender keyboard_arrow_up
internal Context._msgData keyboard_arrow_up
Parameters help
This function has no parameters.
Source Code
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}