Back to Blog

How to Fork Aave: Build Your Own Lending Protocol

What Is Aave and Why Fork It?

Aave is one of the largest decentralized lending protocols in DeFi, with billions of dollars in total value locked across multiple chains. At its core, Aave allows users to deposit crypto assets to earn interest and borrow assets against their collateral. Interest rates adjust algorithmically based on supply and demand, and the entire system runs on smart contracts without any centralized intermediary.

So why would you want to fork it? There are several compelling reasons builders consider learning how to fork Aave:

Because Aave's smart contracts are open source (licensed under BUSL-1.1 for V3, with older versions under more permissive licenses), anyone can study, fork, and modify the codebase. However, as we'll explore in this guide, the distance between "cloning a repository" and "running a production lending protocol" is enormous.

Aave V2 vs V3: Which Version to Fork?

When you decide to fork Aave, the first decision is which version to base your project on. Both V2 and V3 are battle-tested and have been deployed on mainnet for years, but they differ significantly in complexity and features.

Feature Aave V2 Aave V3
License GPL-3.0 (permissive) BUSL-1.1 (restrictive, converts to GPL after 2 years)
Code Complexity Moderate (~15 core contracts) High (~25+ core contracts)
Efficiency Mode (eMode) Not available Yes — higher LTV for correlated assets
Isolation Mode Not available Yes — limit risk of new assets
Portals (Cross-Chain) Not available Yes — bridging liquidity across chains
Gas Optimization Higher gas costs 20-25% lower gas costs
Supply/Borrow Caps Not available Yes — per-asset caps
Flash Loan Fees 0.09% fixed Configurable per asset
Existing Forks Many (Geist, Radiant V1, Sturdy) Growing (Seamless, Spark, Radiant V2)
Fork Difficulty Medium High

Our recommendation: If you're building a simple lending market and want the easiest path, V2 is more approachable due to its GPL license and simpler architecture. If you need advanced risk management features like isolation mode and eMode, V3 is the way to go — but be aware of the BUSL-1.1 license implications. According to DeFiLlama, there are now over 50 Aave V3 forks deployed across various chains, demonstrating that the complexity is manageable with the right team.

Architecture Overview

Before you touch any code, you need to understand how Aave's contracts fit together. The protocol is modular by design, which makes it powerful but also means there are many moving parts.

Core Contracts

Supporting Infrastructure

Understanding this architecture is essential because when you fork Aave, you aren't just deploying one contract — you're deploying and correctly wiring together a system of 20+ interrelated contracts.

Step 1 — Clone and Set Up

Start by cloning the Aave V3 core repository and installing dependencies:

# Clone the core protocol contracts
git clone https://github.com/aave/aave-v3-core.git
cd aave-v3-core

# Install dependencies
npm install

# Compile contracts
npx hardhat compile

The repository is organized into several key directories:

aave-v3-core/
  contracts/
    protocol/         # Core protocol (Pool, aTokens, debt tokens)
    misc/             # Helper contracts (WETH gateway, etc.)
    flashloan/        # Flash loan logic
    interfaces/       # All interface definitions
  deploy/             # Deployment scripts
  helpers/            # Deployment helper utilities
  test/               # Test suite
  markets/            # Market configurations per chain

You'll also want the deploy repository, which contains the actual deployment scripts and market configurations:

# Clone the deployment tooling
git clone https://github.com/aave/aave-v3-deploy.git
cd aave-v3-deploy
npm install

Make sure you're running Node.js 16+ and have Hardhat configured properly. The test suite is extensive — run it first to make sure everything compiles and passes before making any changes.

Step 2 — Configure Markets

Market configuration is where you define which assets your lending protocol supports and their risk parameters. In Aave V3, this is done through configuration files in the markets/ directory.

Here's an example of how a reserve configuration looks:

// markets/mychain/reservesConfigs.ts
export const strategyUSDC: IReserveParams = {
  strategy: rateStrategyStableTwo,
  baseLTVAsCollateral: '8000',   // 80% LTV
  liquidationThreshold: '8500',  // 85% liquidation threshold
  liquidationBonus: '10500',     // 5% liquidation bonus
  liquidationProtocolFee: '1000', // 10% of liquidation bonus to protocol
  borrowingEnabled: true,
  stableBorrowRateEnabled: false,
  flashLoanEnabled: true,
  reserveDecimals: '6',
  aTokenImpl: eContractid.AToken,
  reserveFactor: '1000',         // 10% of interest goes to treasury
  supplyCap: '2000000000',       // 2B USDC supply cap
  borrowCap: '2000000000',       // 2B USDC borrow cap
  debtCeiling: '0',
  borrowableIsolation: true,
};

Key parameters you'll need to set for each asset:

You also need to define interest rate strategies. These control how borrow rates change based on utilization:

export const rateStrategyStableTwo: IInterestRateStrategyParams = {
  name: 'rateStrategyStableTwo',
  optimalUsageRatio: ethers.utils.parseUnits('0.8', 27).toString(),
  baseVariableBorrowRate: '0',
  variableRateSlope1: ethers.utils.parseUnits('0.04', 27).toString(),
  variableRateSlope2: ethers.utils.parseUnits('0.75', 27).toString(),
  stableRateSlope1: ethers.utils.parseUnits('0.005', 27).toString(),
  stableRateSlope2: ethers.utils.parseUnits('0.75', 27).toString(),
  baseStableRateOffset: ethers.utils.parseUnits('0.01', 27).toString(),
  stableRateExcessOffset: ethers.utils.parseUnits('0.08', 27).toString(),
  optimalStableToTotalDebtRatio: ethers.utils.parseUnits('0.2', 27).toString(),
};

The interest rate curve uses two slopes: slope1 applies below optimal utilization (encouraging borrowing), and slope2 applies above it (discouraging over-utilization). Getting these numbers right is critical for balancing depositor yields with borrower costs.

Step 3 — Set Up Price Oracles

Price oracles are the backbone of any lending protocol. They determine collateral values, health factors, and liquidation triggers. A faulty oracle can drain your entire protocol in minutes.

Aave uses Chainlink price feeds as its primary oracle source. You'll need to configure the oracle contract to point to the correct Chainlink aggregators on your target chain:

// markets/mychain/commons.ts
export const chainlinkAggregatorProxy: Record<string, string> = {
  USDC: '0x50834F3163758fCC1Df9973b6e91f0F0F0434aD3',
  WETH: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
  WBTC: '0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c',
  // Add your asset price feeds here
};

Important considerations for oracle setup:

// Example: Setting up the oracle in deployment
const aaveOracle = await deploy('AaveOracle', {
  args: [
    addressesProvider.address,
    [USDC_ADDRESS, WETH_ADDRESS, WBTC_ADDRESS],
    [USDC_ORACLE, WETH_ORACLE, WBTC_ORACLE],
    FALLBACK_ORACLE_ADDRESS,
    USD_ADDRESS,
    ethers.utils.parseUnits('1', 8), // base currency unit
  ],
});

Oracle manipulation is one of the most common attack vectors in DeFi. Using Chainlink mitigates most risks, but you should also implement circuit breakers that pause borrowing if prices move beyond expected thresholds within a short window.

Step 4 — Deploy to Testnet

Once your configurations are in place, it's time to deploy. Aave provides deployment scripts, but they require careful configuration.

First, set up your environment variables:

# .env
PRIVATE_KEY=your_deployer_private_key
ALCHEMY_KEY=your_alchemy_api_key
ETHERSCAN_API_KEY=your_etherscan_key

# For testnet deployment
HARDHAT_NETWORK=sepolia

Run the deployment:

# Deploy core protocol
npx hardhat deploy --network sepolia --tags core

# Initialize reserves (add your configured assets)
npx hardhat deploy --network sepolia --tags init

# Verify contracts on Etherscan
npx hardhat verify-contracts --network sepolia

The deployment process will create and wire together approximately 20-30 contracts depending on how many assets you configure. After deployment, verify that:

Expect to spend several days debugging deployment issues. Common problems include incorrect constructor arguments, missing oracle feeds on testnet, and library linking errors.

Step 5 — Build the Frontend

With the contracts deployed, you need a user interface. Aave's official frontend is open source, but it's a complex React application with hundreds of components.

You have three options:

  1. Fork the Aave interface — clone aave/interface from GitHub. It's built with React, Next.js, and uses ethers.js for contract interactions. You'll need to update contract addresses, branding, and supported networks. This is the most feature-complete option but requires significant frontend expertise.
  2. Build from scratch — use a framework like React or Vue and interact with contracts directly via ethers.js or viem. This gives full control but takes months of development for basic functionality (deposit, borrow, repay, withdraw, health factor display).
  3. Use a template — some projects offer pre-built lending frontends that you can configure to point at your deployed contracts.

Key frontend components you'll need:

The frontend alone typically takes 2-4 months of development time for a small team, even when forking the existing Aave interface.

Skip Months of Development — Use Lenda

Lenda is a ready-made lending platform with custom smart contracts. Deploy your own Aave-like protocol without forking, configuring, and auditing the entire Aave codebase. Supports USDT lending, multi-collateral borrowing (WBNB, BTC, ETH), health factor monitoring, and an admin dashboard — all out of the box.

The Hidden Complexity of Aave Forks

Most guides about how to fork Aave stop at deployment. But deploying the contracts is only about 20% of the work. Here's what catches most teams off guard:

Governance Setup

Aave uses a sophisticated governance system with tiered proposal types, time locks, and voting power delegation. If you fork the protocol, you need to decide: do you implement on-chain governance from day one, or start with a multisig? Most forks start with a multisig (like Gnosis Safe) and plan to decentralize later — but "later" often never comes, leaving users trusting a small team with full admin control.

Oracle Reliability

Chainlink feeds are reliable on major chains, but if you deploy on a newer L2 or alt-L1, you may find that feeds are missing, update infrequently, or have wider deviation thresholds. Some Aave forks have been exploited because they used oracle sources that could be manipulated through flash loans or low-liquidity pools.

Liquidation Bot Infrastructure

Your protocol is only as safe as its liquidation infrastructure. If borrowers become undercollateralized and nobody liquidates them, the protocol accrues bad debt. You need:

Running this infrastructure costs $500-2000/month in cloud hosting and gas fees, and requires ongoing maintenance.

Security Audits

Any lending protocol handling real user funds must be audited. Even if you only changed a few configuration files, auditors need to verify that your changes don't introduce vulnerabilities. Professional audits from firms like Trail of Bits, OpenZeppelin, or Spearbit cost $100,000-$500,000 depending on scope, and take 4-8 weeks.

Ongoing Maintenance

Post-launch, you'll need to monitor for:

Alternative Approaches to Building a Lending Protocol

Forking Aave is one approach, but it's not the only one. Here's how the alternatives compare:

Approach Time to Launch Cost Flexibility Security Risk
Full Aave V3 Fork 4-8 months $150K-$500K+ Very High High (large attack surface)
Aave V2 Fork 3-6 months $100K-$300K+ High Medium-High
Simplified Lending Contracts 2-4 months $50K-$150K Medium Medium (smaller codebase to audit)
Ready-made Platform (Lenda) Days Under $1K Medium Lower (tested, focused scope)

The "simplified lending contracts" approach means writing your own pool contract from scratch with only the features you need: deposit, borrow, repay, withdraw, and liquidate. Without the complexity of flash loans, stable rates, eMode, isolation mode, and portals, the codebase shrinks by 80%, making it far easier to audit and maintain. This is the approach taken by projects like Lenda, which implements an ERC4626-inspired vault with Chainlink oracles and multi-collateral support in a fraction of the code.

List of Notable Aave Forks

Dozens of teams have already forked Aave with varying degrees of success. Here are the most notable ones:

Protocol Base Chain(s) Notable Changes Status
Spark Protocol Aave V3 Ethereum Built by MakerDAO for DAI lending; uses Maker oracle system Active, $1B+ TVL
Radiant Capital Aave V2/V3 Arbitrum, BSC Cross-chain lending via LayerZero; RDNT token incentives Active (post-exploit recovery)
Seamless Protocol Aave V3 Base Native Base chain lending; integrated borrowing strategies Active
Granary Finance Aave V2 Multi-chain Multi-chain V2 fork with GRAIN token Active
Sturdy Finance Aave V2 Ethereum Interest-free borrowing via yield farming deposits Relaunched after exploit
Geist Finance Aave V2 Fantom Fantom-native lending; GEIST token Wound down

A few important lessons from these forks:

How Much Does It Cost to Fork Aave?

Let's break down the realistic costs of launching an Aave fork from scratch. These numbers are based on actual market rates for Solidity developers, auditors, and infrastructure providers in 2025-2026.

Development Costs

Security Costs

Ongoing Operational Costs

Total Cost Comparison

Full Aave V3 Fork: $200,000-$800,000+ to launch, plus $15,000-$40,000/month to operate.

Simplified Lending Protocol: $50,000-$150,000 to launch, plus $5,000-$15,000/month to operate.

Ready-made Platform like Lenda: Under $1,000, with the smart contracts and frontend already built and tested. This approach trades some customization flexibility for a dramatically lower cost and faster time-to-market.

For teams with limited budgets, understanding how to fork Aave is valuable knowledge, but actually doing it may not be the most practical path. Consider whether a turnkey solution covers your needs before committing six figures to a custom fork.

Frequently Asked Questions

Is forking Aave legal?

Aave V2 is released under the GPL-3.0 license, which allows forking as long as derivative works are also open-sourced under the same license. Aave V3 uses the Business Source License 1.1 (BUSL-1.1), which restricts commercial use for 2 years after release, after which it converts to GPL-2.0. If you're forking V3, check the specific date when the BUSL restriction expires for the version you're using. In practice, many projects have forked Aave V3 commercially — but you should consult a lawyer to understand your legal obligations, especially regarding the BUSL terms and any trademarks.

What chains can I deploy an Aave fork to?

Any EVM-compatible chain works: Ethereum, Arbitrum, Optimism, Base, Polygon, BSC, Avalanche, Fantom, and hundreds of others. The main limiting factor is oracle availability — you need reliable Chainlink price feeds (or an alternative oracle) for every asset you want to support. Newer chains may have limited oracle coverage, which restricts which assets you can list. Gas costs also matter: on Ethereum mainnet, deploying the full Aave V3 suite costs 0.5-1 ETH in gas, while L2s cost a fraction of that.

Do I need a security audit?

If you plan to handle any real user funds: yes, absolutely. Lending protocols are among the highest-risk DeFi applications because they custody user deposits and use leverage. Even if you made minimal changes to the Aave codebase, an auditor needs to verify your configuration is safe — incorrect LTV ratios, missing oracle feeds, or deployment errors can all lead to total loss of funds. Unaudited lending protocols have collectively lost billions of dollars to exploits. At minimum, get a focused review of your changes and configuration from a reputable firm.

How long does it take to fork Aave?

A basic testnet deployment can be done in 1-2 weeks by an experienced Solidity developer. However, a production-ready fork — including custom market configuration, frontend development, oracle setup, liquidation infrastructure, testing, and an audit — typically takes 4-8 months for a team of 2-4 developers. The audit alone usually takes 4-8 weeks. If you need governance, tokenomics, and cross-chain features, add another 2-3 months. This is why many teams opt for simpler alternatives rather than a full Aave fork.

Can I add custom collateral types?

Yes — this is one of the main reasons to fork Aave rather than use the official protocol. You can add any ERC-20 token as collateral by configuring it as a reserve with appropriate risk parameters (LTV, liquidation threshold, liquidation bonus). The key requirement is having a reliable price oracle for the asset. For exotic collateral types like LP tokens, NFTs, or rebasing tokens, you may need to write custom oracle adapters or modify the aToken implementation to handle non-standard ERC-20 behavior. Aave V3's isolation mode is particularly useful for new assets — it allows you to list them with capped exposure while you evaluate their real-world risk profile.

Ready to Launch Your Own Lending Platform?

Skip the months of development, six-figure audit costs, and complex infrastructure. Lenda gives you a working lending protocol with custom smart contracts, multi-collateral support, health factor monitoring, and an admin dashboard — ready to deploy today.