Aave V3 Origin
repository·main·Indexed 43 days ago
https://github.com/aave-dao/aave-v3-originThe complete Foundry-based codebase for the Aave V3 protocol, including version 3.7. It serves as the source of truth for protocol implementation, featuring isolated eMode, liquidation rounding, and the stataToken EIP-4626 compliant vault. The repository includes technical specifications, security audit reports from v3 Base through v3.7, and the AaveV3ConfigEngine for managing governance proposal payloads.
What's inside Aave V3
- Aave V3.7 Origin is the complete codebase for Aave V3.7, built using the Foundry framework. It serves as the source of truth for the Aave V3 protocol implementation, including features like isolated eMode and liquidation rounding introduced in version 3.7.
What is stataToken?
mainstataTokenis an EIP-4626 compliant generic token vault/wrapper designed specifically for use with Aave V3 aTokens. It allows users to wrap their aTokens into a standardized vault format while maintaining eligibility for liquidity mining rewards.Key Features
- EIP-4626 Compatibility: Standardized interface for token vaults.
- Liquidity Mining Support: Automatically accounts for rewards from the Aave ecosystem or community. Note that while the design supports infinite reward tokens, each new reward must be permissionlessly registered.
- Governance Upgradable: Deployed instances can be upgraded by Aave governance via the Level 1 executor.
- Permissionless Deployment: New
stataTokeninstances for newly listed assets can be deployed by anyone using theStataTokenFactory.
Overview of Aave v3.3 Key Changes
mainAave v3.3 is an upgrade to the Aave V3 protocol designed to improve debt management, liquidations, and compatibility with the upcoming Umbrella system.
Key functional improvements include:
- Bad Debt Management: Implementation of bad debt logging and burn functionality to handle unresolvable debts, enabling compatibility with automated bad debt coverage via the Umbrella system.
- Liquidation Optimisations: Refined liquidation algorithms aimed at reducing 'dust' debt positions and improving economic efficiency for liquidators.
- Protocol Optimisations: Various improvements to data reading and protocol configurations.
Understand the solvency proofs for the repay() function
mainThe solvency property for the
repay()function is verified using Certora specifications split into two primary files:main.spec: Contains the primary proof for the main solvency property.lemma.spec: Contains proofs for several assumptions required bymain.specto ensure the verification process is efficient and avoids timeouts.
Key assumptions proven in
lemma.specinclude:- Non-zero supply: Proves that if the
scaled-total-supplyofvariable-debtis 0, the call torepay()reverts. - Index Summarization: To prevent verification timeouts, the functions
getNormalizedIncome()andgetNormalizedDebt()are summarized as the constant valuesLIQUIDITY_INDEXandDEBT_INDEX, respectively. This relationship is justified in therepay__index_unchanged()rule withinlemma.spec.
Key changes in the Aave v3.4 Upgrade
mainThe Aave v3.4 upgrade introduces several architectural improvements and feature additions to the v3 protocol:
- GHO Logic Migration: Custom GHO logic and a/v tokens are migrated to a standard asset model to simplify the codebase.
- Multicall Support: Added to the
Poolcontract. - Position Manager Role: Allows users to assign a role to other addresses to perform specific actions on their behalf, such as switching Liquid modes or enabling/disabling an asset as collateral.
- Code Cleanup: Removed unused
BridgeLogicand the concept of "unbacked" assets. - Immutability: Various variables have been made immutable to prevent accidental changes.
- Error Handling: Refactored to use Error signatures instead of error codes.
- aToken Unification: Unified storage and implementation for all aTokens (including
aAAVE). - Compiler Upgrade: Updated to version
0.8.27for better tooling compatibility.
Key changes in Aave v3.4
mainAave v3.4 is an upgrade to the v3 protocol that introduces several architectural improvements and feature additions:
- GHO Migration: Custom GHO logic and aTokens are migrated to a standard asset model to simplify the codebase.
- Multicall Support: Added to the
Poolcontract. - Position Manager Role: Users can assign a Position Manager to perform specific actions on their behalf, such as switching Liquidation modes and enabling/disabling assets as collateral.
- Code Cleanup: Removed unused
BridgeLogicand the concept of "unbacked" assets. - Immutability: Various variables have been made
immutableto align with protocol design. - Error Handling: Refactored to use Error signatures instead of error codes.
- aToken Unification: Unified storage and implementation for all aTokens (previously
aAAVEhad a unique implementation for governance). - Compiler Upgrade: Upgraded to Solidity
0.8.27. - Optimizations: Multiple minor improvements and optimizations.
What is the AaveV3ConfigEngine?
mainThe
AaveV3ConfigEngineis a helper smart contract designed to abstract best practices for performing 'admin' interactions with the Aave v3 protocol. It acts as an orchestration layer that sits on top of core contracts without modifying them. It provides a simplified interface for developers to create governance proposal payloads for common tasks such as:- Listing new assets
- Modifying supply and borrow caps
- Changing collateral or borrow-related parameters
- Updating asset price feeds
- Managing eMode (Efficiency Mode) configurations
Use Stateful Interest Rate Strategy in Aave v3.1
mainAave v3.1 introduced a stateful interest rate strategy to reduce errors when connecting new strategy contracts. Instead of using immutable parameters on separate contracts for each asset, parameters are now stored in a mapping within a single default interest rate contract.
Key Features:
- Single Contract: A single
DefaultReserveInterestRateStrategyV2can be connected to all assets. - Rate Limits: A strict upper limit is enforced (currently 1000%) to prevent chaotic protocol reactions to extreme rate configurations.
- Configuration: Rate parameters (base variable borrow rate, slope1, slope2) are managed via the
PoolConfiguratorusingsetReserveInterestRateData().
- Single Contract: A single
Understand Deficit Management in Aave v3.3
mainIn Aave v3.3, deficits are used to manage bad debt. Deficits are tracked via
reserve.deficitand accumulate over time.Key behaviors:
- Creation: A deficit is created during a liquidation if the user's total collateral across all reserves becomes zero in the base currency, while their total debt remains non-zero.
- Reduction: Deficits can only be reduced by burning claims, which reduces the protocol's obligations in
reserve.deficit. - Interest Rates: For interest rate calculations, the deficit is treated as an 'unbacked' parameter, meaning it reduces the utilization rate.
- Constraints: Deficits can only be created or eliminated for
activereserves. However, an edge case allows deficit creation/elimination onpausedreserves if they are not the main liquidated asset.
Note breaking change: Self-liquidation is forbidden in Aave v3.4
mainStarting with Aave v3.4, self-liquidation is no longer permitted. This is a breaking change for any logic that relied on a user being able to liquidate their own position.Understand AToken fee accounting and minting
mainAave handles
ATokenfees (from liquidations or accrued debt interest) by first "accounting" for them inreserve.accruedToTreasuryrather than minting them immediately to the treasury. The actual minting is performed later via the permissionlessPool.mintToTreasuryfunction.Implications for developers:
- Complexity: When calculating or fetching
AToken.totalSupply, you must account forreserve.accruedToTreasuryto get the real total supply. - Gas vs. Predictability: This approach reduces gas costs for the user triggering the state update, but it makes the value of non-minted shares less predictable and introduces potential rounding imprecisions due to multiple asset-to-share conversions.
- Complexity: When calculating or fetching
Batch transactions using Multicall in Aave v3.4
mainAave v3.4 includes native multicall support, allowing users or contracts to batch multiple transactions into a single call. This is useful for improving UX (e.g., supplying, enabling eMode, and borrowing in one step) or enabling transaction subsidization by allowing a separate entity to execute transactions on a user's behalf.