How aerodrome-finance/contracts works
Project Type and Purpose
• This is an on-chain protocol written in Solidity for EVM chains: an AMM (constant-product pools + router), paired with ve-tokenomics (vote-escrow NFTs), emissions distribution (gauges, rewards), and governance (on-chain governors).
• Deployment/testing is done via Foundry and Hardhat scripts; CI is configured through GitHub Actions.
File Structure Analysis
• Top-level “contracts/” directory holds all Solidity code organized into subfolders by domain:
• art, factories, gauges, governance, interfaces, libraries, rewards.
• “script/” contains Hardhat deployment scripts and JSON templates for multiple environments (ci, Base, etc.).
• “lib/” has Git-submodule dependencies: OpenZeppelin, ds-test, forge-std, gsn, v3-core.
• Configuration files: hardhat.config.ts, foundry.toml, tsconfig.json, remappings.txt, .env.example.
• “test/” uses Foundry for unit and e2e tests.
• CI workflows in “.github/workflows” automate linting, build, and tests.
README Insights
• README organizes contracts into four key layers:
a. AMM (Pool.sol, Router.sol, PoolFees.sol, FactoryRegistry.sol, ProtocolLibrary.sol)
b. Tokenomy (Aero.sol token, VotingEscrow.sol NFT locks, Minter.sol, RewardsDistributor.sol, VeArtProxy.sol, AirdropDistributor.sol)
c. Protocol mechanics (Voter.sol, Gauge.sol, various Reward implementations under contracts/rewards/)
d. Governance (ProtocolGovernor.sol, EpochGovernor.sol)
• Foundry is the default test/deployment framework; Hardhat is used for scripted multi-stage deployments.
A. Main Components
1. Blockchain Layer (EVM)
2. AMM Core
– PoolFactory → Pool instances ↔ PoolFees
– Router for multi-pool swaps
– FactoryRegistry (registers factories: PoolFactory, GaugeFactory, ManagedRewardsFactory, VotingRewardsFactory)
3. Tokenomy Layer
– Aero ERC20 token
– VotingEscrow (veNFT)
– Minter → distributes new tokens to Voter + RewardsDistributor
– RewardsDistributor handles rebases to ve-holders
– AirdropDistributor for initial veNFT airdrops
– VeArtProxy upgradeable NFT metadata
4. Voting & Emissions Layer
– Voter contract reads veNFT locks to assign weights
– GaugeFactory → Gauge instances
– Gauge ↔ Pool LP tokens staked, emits Aero per epoch
– Rewards module: Reward.sol, VotingReward.sol (FeesVotingReward, BribeVotingReward), ManagedReward variants (LockedManagedReward, FreeManagedReward)
5. Governance Layer
– ProtocolGovernor (OpenZeppelin Governor) for protocol-wide parameter changes (e.g., pool/token whitelists, emissions)
– EpochGovernor for emission rate adjustments per epoch
6. Off-chain Tooling
– Hardhat scripts (script/hardhat/*.ts) for deployments and airdrops
– Foundry tests (test/) and utilities (lib/ds-test, forge-std)
– CI pipelines (.github/workflows)
– Configuration (.env, hardhat.config.ts, foundry.toml)
B. Relationships & Data Flow
• User ↔️ Pool via Router for swaps and liquidity operations
• User locks Aero → VotingEscrow → issues veNFT
• User votes by assigning veNFT to Pools/Gauges → Voter records votes each epoch
• Gauge reads votes → distributes emissions in Aero tokens via Reward contracts
• Minter mints new Aero at epoch boundaries → sends to Voter (for gauges) & RewardsDistributor (rebases)
• Governance proposals → ProtocolGovernor/EpochGovernor → update factories, parameters, emission rates
C. Architectural Patterns & Design Principles
• Modular: one contract per responsibility (Factory, Pool, Gauge, Reward, Governor)
• Factory pattern: abstract factories for Pools, Gauges, Rewards, ManagedRewards
• Dependency injection via FactoryRegistry
• Upgradeability: VeArtProxy uses proxy pattern for NFT metadata
• On-chain composition: Complex behaviors built by composing simple, audited OpenZeppelin modules
D. Key Technologies & Frameworks
• Solidity (contracts/)
• OpenZeppelin Governor & ERC20/ERC721 libraries
• Foundry (forge) for testing & building
• Hardhat for scripted deployments
• GitHub Actions for CI
• JSON-based environment templating for multi-env deployments