Repository Structure
A. contracts/dependencies
-
Chainlink
- AggregatorInterface.sol
- Purpose: Defines the interface to interact with Chainlink oracles.
- Details: Includes methods to retrieve the latest answer, timestamp, and round data, enabling the protocol to obtain reliable off-chain price feeds.
- AggregatorInterface.sol
-
Gnosis
- GPv2SafeERC20.sol
- Purpose: Provides a safe, gas-optimized wrapper for ERC20 token transfers.
- Details: Uses low-level calls and inline assembly to ensure that transfers (and transferFrom calls) are executed securely, even with non-standard ERC20 implementations.
- GPv2SafeERC20.sol
-
OpenZeppelin
- Contracts (core libraries):
- AccessControl.sol
- Purpose: Implements role-based access control for managing permissions.
- Details: Allows the assignment and revocation of roles to control access to sensitive functions.
- ERC20.sol
- Purpose: Standard implementation of the ERC20 token.
- Details: Provides the basic functionalities of token transfer, allowance, and balance tracking.
- SafeMath.sol
- Purpose: Offers arithmetic functions with overflow and underflow protection.
- Details: Although Solidity 0.8+ has built-in overflow checks, this remains in use for legacy or explicit safety.
- Address.sol
- Purpose: Contains utility functions for address type checking and low-level calls.
- Details: Verifies if an address is a contract and safely sends ETH.
- Context.sol
- Purpose: Supplies information about the current execution context (e.g., msg.sender and msg.data).
- Details: Useful for meta-transaction patterns.
- ERC165.sol & IERC165.sol
- Purpose: Provides a standard for contract interface detection.
- Details: Enables contracts to declare which interfaces they implement.
- IERC20Detailed.sol
- Purpose: Extends ERC20 with functions for token name, symbol, and decimals.
- Details: Enhances user interfaces with readable token information.
- Ownable.sol
- Purpose: Implements basic ownership access control.
- Details: Ensures that only the contract owner can perform certain actions.
- SafeCast.sol
- Purpose: Provides safe casting functions between different numeric types.
- Details: Prevents data loss during downcasting.
- SafeERC20.sol
- Purpose: Wraps ERC20 operations to ensure they revert on failure.
- Details: Works in tandem with Address.sol to secure token transfers.
- Strings.sol
- Purpose: Contains functions for converting numbers to strings (especially hexadecimal).
- Details: Useful for logging and generating human-readable output.
- AccessControl.sol
- Upgradeability Modules:
- AdminUpgradeabilityProxy.sol, BaseAdminUpgradeabilityProxy.sol, BaseUpgradeabilityProxy.sol, Initializable.sol, InitializableAdminUpgradeabilityProxy.sol, InitializableUpgradeabilityProxy.sol, Proxy.sol, UpgradeabilityProxy.sol
- Purpose: Implement proxy patterns that allow the logic of a contract to be upgraded while retaining its state.
- Details: These contracts form the backbone for upgradeable contracts in the protocol.
- AdminUpgradeabilityProxy.sol, BaseAdminUpgradeabilityProxy.sol, BaseUpgradeabilityProxy.sol, Initializable.sol, InitializableAdminUpgradeabilityProxy.sol, InitializableUpgradeabilityProxy.sol, Proxy.sol, UpgradeabilityProxy.sol
- ReentrancyGuard.sol
- Purpose: Prevents reentrant calls to functions.
- Details: Ensures that state changes are not exploited by malicious reentrancy attacks.
- Contracts (core libraries):
-
WETH
- WETH9.sol
- Purpose: Wraps native Ether (ETH) into an ERC20-compliant token (WETH).
- Details: Enables ETH to be used in ERC20 interactions throughout the protocol.
- WETH9.sol
B. contracts/extensions
- Paraswap Adapters
- Interfaces:
- IParaSwapAugustus.sol
- Purpose: Defines the interface for interacting with Paraswap’s main contract.
- Details: Used to initiate asset swaps via Paraswap.
- IParaSwapAugustusRegistry.sol
- Purpose: Provides a registry interface for Paraswap adapters.
- Details: Helps manage adapter addresses and configurations.
- IParaSwapAugustus.sol
- Adapters:
- BaseParaSwapAdapter.sol
- Purpose: Serves as the base adapter that other Paraswap adapters extend.
- Details: Contains common logic for handling swaps.
- BaseParaSwapBuyAdapter.sol & BaseParaSwapSellAdapter.sol
- Purpose: Specialize the base adapter for buy and sell operations respectively.
- Details: Tailor transaction parameters for different swap directions.
- ParaSwapLiquiditySwapAdapter.sol
- Purpose: Facilitates liquidity swap operations through Paraswap.
- Details: Enables efficient conversion between assets while preserving liquidity.
- ParaSwapRepayAdapter.sol
- Purpose: Assists in repaying loans using Paraswap for asset conversion.
- Details: Integrates swap and repayment operations into a single flow.
- ParaSwapWithdrawSwapAdapter.sol
- Purpose: Allows users to swap assets during the withdrawal process.
- Details: Ensures users receive the desired asset when exiting the protocol.
- BaseParaSwapAdapter.sol
- Interfaces:
- Stata Token & ERC4626 Implementation
- Interfaces:
- IAToken.sol
- Purpose: Defines the interface for Aave’s interest-bearing tokens (aTokens).
- Details: Specifies methods for tracking accrual and interest.
- IERC20AaveLM.sol
- Purpose: A specialized ERC20 interface for Aave’s liquidity mining tokens.
- Details: May include extra methods for reward distribution.
- IERC4626StataToken.sol
- Purpose: Extends the ERC4626 standard for yield-bearing vault tokens.
- Details: Standardizes deposit and withdrawal operations.
- IStataTokenFactory.sol & IStataTokenV2.sol
- Purpose: Manage the creation and versioning of Stata tokens.
- Details: Enable upgradeable or configurable token deployments.
- IAToken.sol
- Implementations:
- ERC20AaveLMUpgradeable.sol
- Purpose: An upgradeable ERC20 token tailored for liquidity mining.
- Details: Supports dynamic adjustments and upgrades.
- ERC4626StataTokenUpgradeable.sol
- Purpose: Implements the ERC4626 interface for yield-bearing tokens in an upgradeable format.
- Details: Ensures compatibility with emerging yield standards.
- StataTokenFactory.sol
- Purpose: A factory contract for deploying new Stata tokens.
- Details: Encapsulates the creation logic for token versions.
- StataTokenV2.sol
- Purpose: Represents the second version of the Stata token with enhanced features.
- Details: Improves on earlier implementations with added functionality.
- ERC20AaveLMUpgradeable.sol
- Interfaces:
- V3 Configuration Engine
- Libraries:
- BorrowEngine.sol
- Purpose: Contains logic for computing borrowing limits and related metrics.
- Details: Helps set dynamic borrowing parameters.
- CapsEngine.sol
- Purpose: Manages upper limits (caps) for borrowing and supply.
- Details: Ensures protocol risk remains within defined bounds.
- CollateralEngine.sol
- Purpose: Calculates collateralization parameters.
- Details: Determines how much a user can borrow against their deposits.
- EModeEngine.sol
- Purpose: Implements logic for the eMode (efficient mode) configuration.
- Details: Supports high borrowing power for similar-asset classes.
- ListingEngine.sol
- Purpose: Manages the process of listing new assets on the protocol.
- Details: Validates and configures new reserve entries.
- PriceFeedEngine.sol
- Purpose: Interfaces with oracles to update asset pricing.
- Details: Ensures that reserve valuations reflect current market conditions.
- RateEngine.sol
- Purpose: Computes dynamic interest rates based on reserve conditions.
- Details: Adjusts borrowing and liquidity rates in real time.
- BorrowEngine.sol
- Core Contracts:
- AaveV3ConfigEngine.sol
- Purpose: Orchestrates the overall configuration of protocol parameters.
- Details: Provides functions for updating risk parameters and reserve settings.
- AaveV3Payload.sol
- Purpose: Packages configuration changes into a deployable payload.
- Details: Often used during protocol upgrades.
- EngineFlags.sol
- Purpose: Defines flag values and constants used across the configuration engine.
- Details: Ensures consistency in parameter encoding.
- IAaveV3ConfigEngine.sol
- Purpose: Provides the interface for the configuration engine.
- Details: Allows for interaction with the engine in a standardized manner.
- AaveV3ConfigEngine.sol
- Libraries:
C. contracts/helpers
- Interfaces for Helpers:
- IEACAggregatorProxy.sol
- Purpose: Defines an interface for a proxy to Chainlink Aggregators.
- Details: Used for aggregating and caching price data.
- IERC20DetailedBytes.sol
- Purpose: An extension to support bytes-level detailed token information.
- Details: Useful when additional token metadata is required.
- IUiIncentiveDataProviderV3.sol & IUiPoolDataProviderV3.sol
- Purpose: Provide structured data for front-end UI applications regarding incentives and pool information.
- Details: Aggregate protocol data into a consumable format.
- IWETH.sol
- Purpose: Specifies the interface for WETH interactions.
- Details: Standardizes operations for wrapping and unwrapping ETH.
- IWrappedTokenGatewayV3.sol
- Purpose: Provides a gateway interface for wrapped token operations.
- Details: Simplifies cross-token interactions.
- IEACAggregatorProxy.sol
- Standalone Helpers:
- AaveProtocolDataProvider.sol
- Purpose: Aggregates data across the protocol’s reserves and user positions.
- Details: Simplifies on-chain queries by collating data from multiple sources.
- L2Encoder.sol
- Purpose: Encodes data for Layer 2 interactions.
- Details: Ensures consistency when interfacing with L2 solutions.
- UiIncentiveDataProviderV3.sol & UiPoolDataProviderV3.sol
- Purpose: Provide detailed, UI-friendly views of protocol state.
- Details: Serve data to dashboards and analytics tools.
- WalletBalanceProvider.sol
- Purpose: Consolidates balance information for user wallets across different tokens.
- Details: Reduces the number of on-chain calls needed for balance verification.
- WrappedTokenGatewayV3.sol
- Purpose: Manages the conversion between native and wrapped tokens.
- Details: Facilitates seamless token wrapping and unwrapping.
- AaveProtocolDataProvider.sol
D. contracts/instances
- ATokenInstance.sol
- Purpose: An instance (or mock) implementation of an interest-bearing token.
- Details: Demonstrates how aTokens function in the protocol.
- L2PoolInstance.sol
- Purpose: Represents a Layer 2 pool instance for scaling purposes.
- Details: Useful for testing L2-specific functionalities.
- PoolConfiguratorInstance.sol
- Purpose: Simulates the pool configuration process.
- Details: Provides insight into how reserves are set up and managed.
- PoolInstance.sol
- Purpose: A concrete instance of the main pool contract.
- Details: Handles deposits, withdrawals, borrowing, and repayments.
- VariableDebtTokenInstance.sol
- Purpose: Illustrates a deployed instance of a variable debt token.
- Details: Tracks variable-rate borrowing balances.
E. contracts/interfaces
These files define standard interfaces ensuring interoperability across protocol components:
- IAaveIncentivesController.sol
- Purpose: Defines how incentive rewards are calculated and distributed.
- Details: Standardizes methods for reward claiming and balance queries.
- IAaveOracle.sol
- Purpose: Outlines the interface for the price oracle used by the protocol.
- Details: Provides methods to fetch asset prices and historical data.
- IACLManager.sol
- Purpose: Specifies methods for managing access control and administrative roles.
- Details: Ensures that only authorized entities can change protocol parameters.
- IAToken.sol
- Purpose: Standardizes the functions for interest-bearing tokens.
- Details: Covers minting, burning, and balance tracking for aTokens.
- ICreditDelegationToken.sol
- Purpose: Defines the interface for tokens that support credit delegation.
- Details: Enables users to delegate borrowing power.
- IDefaultInterestRateStrategyV2.sol
- Purpose: Specifies how default interest rates are calculated for reserves.
- Details: Provides a blueprint for implementing rate strategies.
- IDelegationToken.sol
- Purpose: Outlines the interface for tokens used in delegation scenarios.
- Details: Facilitates borrowing on behalf of another user.
- IERC20WithPermit.sol
- Purpose: Extends ERC20 to support approvals via signatures (permit functionality).
- Details: Enables gasless approvals.
- IInitializableAToken.sol & IInitializableDebtToken.sol
- Purpose: Define initialization methods for aTokens and debt tokens respectively.
- Details: Ensure tokens are set up correctly upon deployment.
- IL2Pool.sol
- Purpose: Describes the interface for Layer 2 pool operations.
- Details: Contains functions specific to L2 interactions.
- IPool.sol
- Purpose: The core interface for pool operations (deposits, withdrawals, borrowing, repayment).
- Details: Acts as the central hub for user interactions.
- IPoolAddressesProvider.sol & IPoolAddressesProviderRegistry.sol
- Purpose: Manage the addresses of deployed protocol components.
- Details: Facilitate lookup and upgradeability.
- IPoolConfigurator.sol
- Purpose: Outlines functions for configuring reserve parameters.
- Details: Used during protocol initialization and upgrades.
- IPoolDataProvider.sol
- Purpose: Provides methods to fetch aggregated data about reserves and users.
- Details: Supports front-end applications.
- IPriceOracle.sol, IPriceOracleGetter.sol & IPriceOracleSentinel.sol
- Purpose: Define methods for price retrieval and validation.
- Details: Crucial for collateral management and liquidation logic.
- IReserveInterestRateStrategy.sol
- Purpose: Standardizes the approach for computing dynamic interest rates.
- Details: Ensures uniform rate calculation across reserves.
- IScaledBalanceToken.sol
- Purpose: Represents tokens whose balances scale over time with interest accrual.
- Details: Fundamental for both aTokens and debt tokens.
- ISequencerOracle.sol
- Purpose: Interfaces with sequencer nodes for L2 solutions.
- Details: Assists in maintaining ordering and timing on Layer 2.
- IVariableDebtToken.sol
- Purpose: Specifies functions for variable-rate debt tokens.
- Details: Tracks borrowers’ debt under variable interest conditions.
F. contracts/misc
- aave-upgradeability
- BaseImmutableAdminUpgradeabilityProxy.sol
- Purpose: A proxy contract that delegates calls to an implementation and ensures the admin cannot be changed after deployment.
- InitializableImmutableAdminUpgradeabilityProxy.sol
- Purpose: Similar to the base proxy but designed to be initialized once.
- VersionedInitializable.sol
- Purpose: Provides a mechanism for version control during contract initialization.
- BaseImmutableAdminUpgradeabilityProxy.sol
- flashloan
- base/FlashLoanReceiverBase.sol & FlashLoanSimpleReceiverBase.sol
- Purpose: Abstract base contracts for building flashloan receivers.
- Details: Implement common logic to handle flashloan callbacks.
- interfaces/IFlashLoanReceiver.sol & IFlashLoanSimpleReceiver.sol
- Purpose: Define the interfaces that flashloan receivers must implement.
- base/FlashLoanReceiverBase.sol & FlashLoanSimpleReceiverBase.sol
- AaveOracle.sol
- Purpose: Implements the protocol’s oracle, integrating with external data sources for asset prices.
- DefaultReserveInterestRateStrategyV2.sol
- Purpose: A default strategy for computing interest rates based on reserve conditions.
- PriceOracleSentinel.sol
- Purpose: Provides additional checks and safeguards around price feed data.
G. contracts/mocks
Mocks are used exclusively for testing and simulation.
- flashloan
- MockFlashLoanReceiver.sol & MockSimpleFlashLoanReceiver.sol
- Purpose: Simulate flashloan receiver behavior for testing flashloan functionalities.
- MockFlashLoanReceiver.sol & MockSimpleFlashLoanReceiver.sol
- helpers
- MockIncentivesController.sol
- Purpose: Mimics the behavior of the incentives controller for testing reward distributions.
- MockL2Pool.sol, MockPeripheryContract.sol, MockPool.sol, MockReserveConfiguration.sol
- Purpose: Provide controlled environments to test interactions with pool and reserve configuration logic.
- MockIncentivesController.sol
- oracle
- CLAggregators/MockAggregator.sol
- Purpose: Simulate Chainlink aggregator responses for price feeds.
- PriceOracle.sol & SequencerOracle.sol (Mocks)
- Purpose: Supply fixed or simulated price data for testing.
- CLAggregators/MockAggregator.sol
- swap
- MockParaSwapAugustus.sol, MockParaSwapAugustusRegistry.sol, MockParaSwapTokenTransferProxy.sol
- Purpose: Emulate Paraswap adapter functionality for asset swaps.
- MockParaSwapAugustus.sol, MockParaSwapAugustusRegistry.sol, MockParaSwapTokenTransferProxy.sol
- testnet-helpers
- Faucet.sol, IFaucet.sol, TestnetERC20.sol
- Purpose: Provide tokens and faucet functionalities to simulate testnet conditions.
- Faucet.sol, IFaucet.sol, TestnetERC20.sol
- tests
- FlashloanAttacker.sol, MathUtilsWrapper.sol, MockReserveInterestRateStrategy.sol, PercentageMathWrapper.sol, WadRayMathWrapper.sol
- Purpose: Test contracts for simulating attacks, wrapping math functions, and validating core logic.
- FlashloanAttacker.sol, MathUtilsWrapper.sol, MockReserveInterestRateStrategy.sol, PercentageMathWrapper.sol, WadRayMathWrapper.sol
- tokens
- MintableDelegationERC20.sol, MintableERC20.sol, MockATokenRepayment.sol, MockDebtTokens.sol, MockScaledToken.sol, WETH9Mocked.sol
- Purpose: Create mock tokens for testing deposits, repayments, and debt management.
- MintableDelegationERC20.sol, MintableERC20.sol, MockATokenRepayment.sol, MockDebtTokens.sol, MockScaledToken.sol, WETH9Mocked.sol
- upgradeability
- MockAToken.sol, MockInitializableImplementation.sol, MockVariableDebtToken.sol
- Purpose: Test proxy upgrade mechanisms and token behaviors during upgrades.
- MockAToken.sol, MockInitializableImplementation.sol, MockVariableDebtToken.sol
- ATokenMock.sol, MockBadTransferStrategy.sol, WETH9Mock.sol
- Purpose: Additional mocks to simulate problematic scenarios and verify system resilience.
H. contracts/protocol
- configuration
- ACLManager.sol
- Purpose: Manages access control lists and permissions for protocol administration.
- PoolAddressesProvider.sol & PoolAddressesProviderRegistry.sol
- Purpose: Maintain a registry of key protocol contract addresses, facilitating upgrades and component lookups.
- ACLManager.sol
- libraries
- configuration
- EModeConfiguration.sol
- Purpose: Implements logic for configuring efficient modes (eMode) for groups of assets.
- ReserveConfiguration.sol
- Purpose: Handles the encoding/decoding and management of reserve configuration data (collateral, borrow limits, etc.).
- UserConfiguration.sol
- Purpose: Manages users’ configuration data regarding which assets are used as collateral.
- EModeConfiguration.sol
- helpers
- Errors.sol
- Purpose: Defines standardized error codes and messages for protocol operations.
- Errors.sol
- logic
- BorrowLogic.sol
- Purpose: Implements the logic for borrowing assets from the pool.
- BridgeLogic.sol
- Purpose: Facilitates cross-chain or bridge interactions.
- CalldataLogic.sol
- Purpose: Provides utilities for packing and unpacking function call data.
- ConfiguratorLogic.sol
- Purpose: Manages logic for configuring reserves and protocol parameters.
- EModeLogic.sol
- Purpose: Contains the rules for eMode operations and adjustments.
- FlashLoanLogic.sol
- Purpose: Governs the calculations and state changes during flashloan execution.
- GenericLogic.sol
- Purpose: Offers generic utility functions for various protocol operations.
- IsolationModeLogic.sol
- Purpose: Implements logic for managing assets in isolation mode (assets with special risk profiles).
- LiquidationLogic.sol
- Purpose: Handles the procedures and calculations for liquidating undercollateralized positions.
- PoolLogic.sol
- Purpose: Centralizes the core functionalities of the pool (deposit, withdrawal, debt management).
- ReserveLogic.sol
- Purpose: Manages reserve-specific operations including rate updates and interest accrual.
- SupplyLogic.sol
- Purpose: Contains the logic for supplying assets to the protocol.
- ValidationLogic.sol
- Purpose: Provides functions to validate actions against protocol rules and risk parameters.
- BorrowLogic.sol
- math
- MathUtils.sol
- Purpose: Provides generic math utility functions.
- PercentageMath.sol
- Purpose: Implements calculations involving percentages (e.g., fee calculations).
- WadRayMath.sol
- Purpose: Offers fixed-point math operations using “wad” and “ray” units, critical for interest calculations.
- MathUtils.sol
- types
- ConfiguratorInputTypes.sol
- Purpose: Defines data types and structures for configuration inputs.
- DataTypes.sol
- Purpose: Consolidates all data structures used across the protocol (reserve data, user configuration, etc.).
- ConfiguratorInputTypes.sol
- configuration
- pool
- L2Pool.sol
- Purpose: Implements pool logic specifically optimized for Layer 2 solutions.
- Pool.sol
- Purpose: The main pool contract that facilitates deposits, withdrawals, borrowing, and repayments.
- PoolConfigurator.sol
- Purpose: Provides functions to adjust reserve parameters and configure the pool settings.
- PoolStorage.sol
- Purpose: Defines the storage layout for pool state variables.
- L2Pool.sol
- tokenization
- base
- DebtTokenBase.sol
- Purpose: Serves as the base contract for all debt token implementations.
- EIP712Base.sol
- Purpose: Provides functionality for EIP712 domain separation for signature validation.
- IncentivizedERC20.sol
- Purpose: An ERC20 implementation that supports reward distribution mechanisms.
- MintableIncentivizedERC20.sol
- Purpose: Extends IncentivizedERC20 to support minting for deposit tracking.
- ScaledBalanceTokenBase.sol
- Purpose: Implements the logic for tokens whose balances scale over time (accruing interest).
- DebtTokenBase.sol
- AToken.sol
- Purpose: Implements the interest-bearing token representing a user’s deposit.
- Details: Tracks accrued interest and integrates with the pool.
- VariableDebtToken.sol
- Purpose: Represents the debt incurred under variable interest rate terms.
- Details: Manages dynamic borrowing balances that change with interest accrual.
- base
I. contracts/rewards
- Interfaces
- IEmissionManager.sol
- Purpose: Defines the interface for managing the emission of reward tokens.
- IPullRewardsTransferStrategy.sol
- Purpose: Specifies how rewards should be transferred when “pulled” from the protocol.
- IRewardsController.sol
- Purpose: Outlines the functions for controlling and distributing rewards.
- IRewardsDistributor.sol
- Purpose: Provides an interface for the contract responsible for splitting and distributing rewards.
- IStakedToken.sol & IStakedTokenTransferStrategy.sol
- Purpose: Define the behavior for tokens that can be staked to earn rewards and the strategy for transferring them.
- ITransferStrategyBase.sol
- Purpose: A base interface for various reward transfer strategies.
- IEmissionManager.sol
- Libraries
- RewardsDataTypes.sol
- Purpose: Contains data structures used for managing reward information.
- RewardsDataTypes.sol
- Transfer Strategies
- PullRewardsTransferStrategy.sol
- Purpose: Implements a mechanism to pull rewards from various sources.
- StakedTokenTransferStrategy.sol
- Purpose: Manages the logic for transferring staked tokens during reward distribution.
- TransferStrategyBase.sol
- Purpose: Provides common functions for reward transfer strategies.
- PullRewardsTransferStrategy.sol
- Core Reward Contracts
- EmissionManager.sol
- Purpose: Controls the emission of reward tokens into the protocol ecosystem.
- RewardsController.sol
- Purpose: Centralizes the logic for calculating, claiming, and distributing rewards.
- RewardsDistributor.sol
- Purpose: Splits and distributes rewards to the appropriate parties (e.g., depositors, borrowers).
- EmissionManager.sol
J. contracts/treasury
- Collector.sol
- Purpose: Collects fees generated by protocol activities.
- Details: Acts as the primary treasury contract for accumulating protocol revenue.
- ICollector.sol
- Purpose: Defines the interface for the treasury collector.
- IRevenueSplitter.sol
- Purpose: Outlines how revenue is split among various stakeholders.
- RevenueSplitter.sol
- Purpose: Implements the logic to distribute collected fees to designated recipients according to preset ratios.

