Safety Module

The Aave Safety Module serves as a safeguard for the Aave Protocol against potential shortfall events. By staking AAVE, GHO, or AAVE / wstETH Balancer Pool tokens, participants contribute to the security of the protocol and earn incentives in return. The staked tokens may be slashed in the event of a shortfall to cover any protocol deficits.

The Safety Module operates by allowing users to stake their ERC-20 tokens into StakeToken contracts, which are also ERC-20 tokens. These StakeToken contracts handle the distribution of rewards and manage the slashing mechanism. The implementation details of the StakeToken contracts are available on GitHub.

The Umbrella governance proposal outlines potential changes to the Safety Module, including automated slashing, replacing stkAAVE and stkABPT with aToken staking, and new incentives design, subject to community approval.

Staking

Users stake tokens by calling the stake function on the StakeToken contract with the amount they wish to stake. In exchange, they receive staked tokens adjusted by the current exchange rate, representing their share in the Safety Module.

function stake(address to, uint256 amount) external;

Unstaking

Before withdrawing their staked tokens, users must initiate a cooldown period by invoking the cooldown() function. After the cooldown period, defined by _cooldownSeconds, has elapsed, there is a limited window (UNSTAKE_WINDOW) during which users can redeem their staked tokens by calling the redeem function. If this window is missed, the cooldown process must be restarted.

function cooldown() external;function redeem(address to, uint256 amount) external;

Actions involving staked tokens can affect the cooldown period:

  • Staking More Tokens: Adding more tokens to your stake during an active cooldown doesn't impact the existing cooldown. The new tokens will require a separate cooldown period before they can be unstaked.

  • Unstaking Tokens: Once the cooldown period has passed, only the tokens that were in cooldown can be unstaked. Unstaking resets the cooldown for the withdrawn amount, and any remaining staked tokens will need a new cooldown period for future withdrawals.

  • Claiming Rewards: Collecting earned incentives doesn't affect the cooldown period. Users can claim rewards at any time without influencing their cooldown status.

  • Transferring Staked Tokens: Sending staked tokens to another address doesn't alter the sender's cooldown. The recipient must initiate their own cooldown period to unstake those tokens, as the cooldown is not transferred along with the tokens.

After the cooldown period concludes, users have a two-day window to unstake their tokens. Failing to do so within this timeframe means they must initiate the cooldown process again, waiting the full duration before being able to unstake.

Exchange Rate Mechanism

The exchange rate determines how staked tokens convert back to the underlying assets. Initially set to a 1:1 ratio (1e18), the exchange rate adjusts in response to slashing events or when additional funds are added to the module. This mechanism determines the value of staked tokens to reflect the total assets within the Safety Module after such events. The exchange rate is calculated using the formula:

exchangeRate = (totalAssets * EXCHANGE_RATE_UNIT) / totalShares;

Rewards

Participants earn rewards over time based on emission rates set by Aave Governance. The AaveDistributionManager contract manages the calculation and distribution of these incentives. Rewards are proportional to the amount staked and the duration of staking.

The formula for calculating accrued rewards is:

Accrued Rewards = (User's Stake * (Asset Index - User Index))
  • Asset Index: A cumulative value representing the total rewards per unit staked, updated regularly based on the emission rate and total staked tokens.

  • User Index: The index value recorded during the user's last interaction with the staking contract.

Claiming Rewards

Users can claim their accumulated rewards at any time by calling the claimRewards function:

function claimRewards(address to, uint256 amount) external;

Claimed rewards are transferred to the user's wallet. This action does not affect the staking status or the cooldown period. Users with the appropriate permissions can also claim rewards on behalf of others using claimRewardsOnBehalf. Additionally, there's an option to claim rewards and immediately restake them in one transaction using claimRewardsAndStake, allowing users to compound rewards.

Slashing

Slashing is a mechanism designed to cover losses in the event of a protocol shortfall by utilizing a portion of the staked funds. Only addresses with the SLASH_ADMIN_ROLE (held by Aave Governance) can initiate a slashing event by calling the slash function:

function slash(address destination, uint256 amount) external onlySlashingAdmin returns (uint256);

The maximum slashing amount is determined per-asset by _maxSlashablePercentage, a predefined limit set by the SLASH_ADMIN_ROLE.

After a slashing event, the exchange rate is updated to reflect the reduced total assets, proportionally affecting all stakers. The module then enters a post-slashing period during which:

  • New staking is temporarily disabled to prevent dilution of existing stakers' shares.

  • Stakers can redeem their tokens without waiting for a cooldown period, allowing them to exit the module promptly.

  • No further slashing events can occur until the current one is settled.

To conclude the post-slashing period and resume normal operations, the SLASH_ADMIN_ROLE must call:

function settleSlashing() external onlySlashingAdmin;

Deployed Contracts

Aave.com provides information and resources about the fundamentals of the decentralised non-custodial liquidity protocol called the Aave Protocol, comprised of open-source self-executing smart contracts that are deployed on various permissionless public blockchains, such as Ethereum (the "Aave Protocol" or the "Protocol"). Aave Labs does not control or operate any version of the Aave Protocol on any blockchain network.