Blockwell

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

Approval Event

Parameters help
owner
address help
spender
address help
value
uint256 help

DelegateChanged Event

Parameters help
delegator
address help
delegatee
address help
delegationType
DelegationType help

DelegatedPowerChanged Event

Parameters help
user
address help
amount
uint256 help
delegationType
DelegationType help

Transfer Event

Parameters help
from
address help
to
address help
value
uint256 help

NAME Constant

string help
Aave Token

SYMBOL Constant

string help
AAVE

DECIMALS Constant

uint8 help
18

REVISION Constant

uint256 help
2

EIP712_REVISION Constant

bytes help
UNKNOWN VALUE

EIP712_DOMAIN Constant

bytes32 help
the result of calling keccak256 with "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"

PERMIT_TYPEHASH Constant

bytes32 help
the result of calling keccak256 with "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"

DELEGATE_BY_TYPE_TYPEHASH Constant

bytes32 help
the result of calling keccak256 with "DelegateByType(address delegatee,uint256 type,uint256 nonce,uint256 expiry)"

DELEGATE_TYPEHASH Constant

bytes32 help
the result of calling keccak256 with "Delegate(address delegatee,uint256 nonce,uint256 expiry)"

_aaveGovernance Variable

address help

DOMAIN_SEPARATOR Variable

bytes32 help

_nonces Variable

mapping(address => uint256) help

_votingSnapshotsCounts Variable

mapping(address => uint256) help

_votingSnapshots Variable

mapping(address => mapping(uint256 => Snapshot)) help
Internal Variable

_votingDelegates Variable

mapping(address => address) help
Internal Variable

_propositionPowerSnapshots Variable

mapping(address => mapping(uint256 => Snapshot)) help
Internal Variable

_propositionPowerSnapshotsCounts Variable

mapping(address => uint256) help
Internal Variable

_propositionPowerDelegates Variable

mapping(address => address) help
Internal Variable

_balances Variable

mapping(address => uint256) help
Internal Variable

_allowances Variable

mapping(address => mapping(address => uint256)) help
Internal Variable

_totalSupply Variable

uint256 help
Internal Variable

_name Variable

string help
Internal Variable

_symbol Variable

string help
Internal Variable

_decimals Variable

uint8 help
Internal Variable

lastInitializedRevision Variable

uint256 help
Internal Variable

______gap Variable

uint256[] help
Internal Variable

Functions Expand All Collapse All

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function name() public view returns (string memory) {
  return _name;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function symbol() public view returns (string memory) {
  return _symbol;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function decimals() public view returns (uint8) {
  return _decimals;
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function totalSupply() public view override returns (uint256) {
  return _totalSupply;
}

Parameters help

Name Type
account
address help

Properties

Visibility help public
Mutability help view
Source Code
function balanceOf(address account) public view override returns (uint256) {
  return _balances[account];
}

Parameters help

Name Type
recipient
address help
amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function transfer(address recipient, uint256 amount)
  public
  virtual
  override
  returns (bool)
{
  _transfer(_msgSender(), recipient, amount);
  return true;
}

Parameters help

Name Type
owner
address help
spender
address help

Properties

Visibility help public
Mutability help view
Source Code
function allowance(address owner, address spender)
  public
  view
  virtual
  override
  returns (uint256)
{
  return _allowances[owner][spender];
}

Parameters help

Name Type
spender
address help
amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function approve(address spender, uint256 amount)
  public
  virtual
  override
  returns (bool)
{
  _approve(_msgSender(), spender, amount);
  return true;
}

Parameters help

Name Type
sender
address help
recipient
address help
amount
uint256 help

Properties

Visibility help public
Mutability help transaction

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;
}

Parameters help

Name Type
spender
address help
addedValue
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function increaseAllowance(address spender, uint256 addedValue)
  public
  virtual
  returns (bool)
{
  _approve(
    _msgSender(),
    spender,
    _allowances[_msgSender()][spender].add(addedValue)
  );
  return true;
}

Parameters help

Name Type
spender
address help
subtractedValue
uint256 help

Properties

Visibility help public
Mutability help transaction

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

Parameters help

Name Type
delegatee
address help
delegationType
DelegationType help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function delegateByType(address delegatee, DelegationType delegationType)
  external
  override
{
  _delegateByType(msg.sender, delegatee, delegationType);
}

delegate keyboard_arrow_up

Parameters help

Name Type
delegatee
address help

Properties

Visibility help public
Mutability help transaction

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

Parameters help

Name Type
delegator
address help
delegationType
DelegationType help

Properties

Visibility help public
Mutability help view
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

Parameters help

Name Type
user
address help
delegationType
DelegationType help

Properties

Visibility help public
Mutability help view

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

Name Type
user
address help
blockNumber
uint256 help
delegationType
DelegationType help

Properties

Visibility help public
Mutability help view

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

Parameters help

Name Type
blockNumber
uint256 help

Properties

Visibility help public
Mutability help view
Source Code
function totalSupplyAt(uint256 blockNumber)
  external
  view
  override
  returns (uint256)
{
  return super.totalSupply();
}

initialize keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function initialize() external initializer {}

permit keyboard_arrow_up

Parameters help

Name Type
owner
address help
spender
address help
value
uint256 help
deadline
uint256 help
v
uint8 help
r
bytes32 help
s
bytes32 help

Properties

Visibility help public
Mutability help transaction

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

Name Type
delegatee
address help
delegationType
DelegationType help
nonce
uint256 help
expiry
uint256 help
v
uint8 help
r
bytes32 help
s
bytes32 help

Properties

Visibility help public
Mutability help transaction
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

Name Type
delegatee
address help
nonce
uint256 help
expiry
uint256 help
v
uint8 help
r
bytes32 help
s
bytes32 help

Properties

Visibility help public
Mutability help transaction
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 Expand All Collapse All

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

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help pure
Source Code
function getRevision() internal pure override returns (uint256) {
  return REVISION;
}

internal AaveTokenV2._beforeTokenTransfer keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction
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

Parameters help

Name Type
delegationType
DelegationType help

Properties

Visibility help internal
Mutability help view
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

Name Type
delegator
address help
delegatee
address help
delegationType
DelegationType help

Properties

Visibility help internal
Mutability help transaction

Requirements 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

Name Type
from
address help
to
address help
amount
uint256 help
delegationType
DelegationType help

Properties

Visibility help internal
Mutability help transaction
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

Name Type
snapshots
mapping(address => mapping(uint256 => Snapshot)) help
snapshotsCounts
mapping(address => uint256) help
user
address help
blockNumber
uint256 help

Properties

Visibility help internal
Mutability help view

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

Parameters help

Name Type
delegationType
DelegationType help

Properties

Visibility help internal
Mutability help view
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

Name Type
snapshots
mapping(address => mapping(uint256 => Snapshot)) help
snapshotsCounts
mapping(address => uint256) help
owner
address help
oldValue
uint128 help
newValue
uint128 help

Properties

Visibility help internal
Mutability help transaction
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

Parameters help

Name Type
delegator
address help
delegates
mapping(address => address) help

Properties

Visibility help internal
Mutability help view
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

Parameters help

Name Type
sender
address help
recipient
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction

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

Parameters help

Name Type
account
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

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

Parameters help

Name Type
account
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

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

Parameters help

Name Type
owner
address help
spender
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction

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

Parameters help

Name Type
decimals_
uint8 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _setupDecimals(uint8 decimals_) internal {
  _decimals = decimals_;
}

internal ERC20._beforeTokenTransfer keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _beforeTokenTransfer(
  address from,
  address to,
  uint256 amount
) internal virtual {}

internal Context._msgSender keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help view
Source Code
function _msgSender() internal view virtual returns (address payable) {
  return msg.sender;
}

internal Context._msgData keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help view
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;
}

internal VersionedInitializable.getRevision keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help pure
Source Code
function getRevision() internal pure virtual returns (uint256);