AAVE v4 2026: The DeFi Lending Protocol Managing $15B+ in Deposits — Smart Contract Integration Guide
Complete guide to integrating AAVE v4 DeFi lending protocol in 2026. Learn how to supply and borrow 30+ crypto assets, use flash loans, implement isolation mode, and integrate GHO stablecoin in your DApp.
- ⭐ 2100
- AGPL-3.0
- Updated 2026-05-20
{{< resource-info >}}
Decentralized lending has become the cornerstone of modern DeFi, and AAVE stands at the forefront of this revolution. With over $15 billion in total value locked across multiple chains, AAVE is the largest and most battle-tested lending protocol in the cryptocurrency ecosystem. The release of AAVE v4 in late 2025 introduced significant architectural improvements, making it more efficient, secure, and developer-friendly than ever before.
For developers building DeFi applications, trading bots, yield aggregators, or portfolio management tools, understanding how to integrate with AAVE is essential. This guide provides a comprehensive walkthrough of AAVE v4, covering everything from basic supply and borrow operations to advanced features like flash loans, isolation mode, and the GHO stablecoin. Whether you are writing Solidity smart contracts or building a frontend interface, you will find practical code examples and architectural insights to accelerate your integration.
Affiliate Disclosure: This article contains affiliate links to Binance and OKX. We may earn a commission when you register through our links at no extra cost to you.
What Is AAVE? #
AAVE is an open-source, non-custodial liquidity protocol that enables users to supply and borrow cryptocurrency assets. Originally launched as ETHLend in 2017 and rebranded to AAVE in 2018, the protocol has evolved through multiple major versions. AAVE v3 launched in 2023 with cross-chain portal capabilities, and AAVE v4 arrived in late 2025 with a modular architecture, improved capital efficiency, and native account abstraction support.
The protocol operates through a series of smart contracts deployed on Ethereum, Polygon, Arbitrum, Optimism, Avalanche, Base, and several other networks. Users who supply assets receive aTokens in return, which accrue interest in real time. Borrowers can take overcollateralized loans in variable or stable rate modes, with the flexibility to switch between them.
AAVE v4 introduces several architectural innovations:
- Modular pool architecture separating risk management from core lending logic
- Native flash loan simplification with unified entry points
- Enhanced isolation mode for listing long-tail assets with bounded risk
- Cross-chain liquidity layer built on Chainlink CCIP
- GHO native money market with direct minting against collateral
- Account abstraction integration for gasless transactions and social recovery
Understanding the AAVE v4 Architecture #
Before diving into code, it is important to understand the core architectural components of AAVE v4.
Pool Contract. The central contract managing all supply, borrow, and liquidation operations. In v4, the pool delegates risk-specific decisions to external modules while maintaining the core state.
aTokens. Interest-bearing tokens representing supplied liquidity. When you supply DAI, you receive aDAI. The balance of aTokens grows automatically as interest accrues.
Variable Debt Tokens. Non-transferable tokens tracking variable-rate borrowing positions. These represent the debt owed by a borrower and increase as interest compounds.
Stable Debt Tokens. Similar to variable debt tokens but with a stable interest rate locked at borrow time. AAVE v4 improved the stability fee mechanism to reduce rate volatility.
Price Oracle. Chainlink price feeds provide asset valuations for determining collateral factors, liquidation thresholds, and borrow capacity.
Risk Module. A new modular component in v4 that encapsulates risk parameters, collateral configurations, and isolation mode logic. This separation allows governance to update risk settings without modifying the core pool.
Setting Up Your Development Environment #
To integrate with AAVE v4, you need a properly configured development environment.
Hardhat Project Setup #
mkdir aave-integration && cd aave-integration
npm init -y
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat init
Install AAVE Dependencies #
npm install @aave/core-v4 @aave/periphery-v4
npm install ethers dotenv
Environment Configuration #
# .env
ETHEREUM_RPC=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY
PRIVATE_KEY=your_private_key
// hardhat.config.js
require('@nomicfoundation/hardhat-toolbox');
require('dotenv').config();
module.exports = {
solidity: '0.8.24',
networks: {
hardhat: {
forking: {
url: process.env.ETHEREUM_RPC,
blockNumber: 21000000,
},
},
mainnet: {
url: process.env.ETHEREUM_RPC,
accounts: [process.env.PRIVATE_KEY],
},
},
};
Core Smart Contract Integration #
The primary interface for interacting with AAVE v4 is the IPool contract. All supply, borrow, and repayment operations flow through this contract.
Supplying Assets to AAVE #
When you supply assets to AAVE, you deposit ERC-20 tokens into the pool and receive aTokens in exchange. These aTokens automatically accrue interest.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {IPool} from '@aave/core-v4/contracts/interfaces/IPool.sol';
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
contract AaveSupplier {
IPool public immutable pool;
constructor(address _pool) {
pool = IPool(_pool);
}
function supplyAsset(
address asset,
uint256 amount
) external {
// Transfer tokens from user to this contract
IERC20(asset).transferFrom(msg.sender, address(this), amount);
// Approve the pool to spend tokens
IERC20(asset).approve(address(pool), amount);
// Supply to AAVE pool on behalf of msg.sender
pool.supply(asset, amount, msg.sender, 0);
}
}
Borrowing Assets #
Borrowing requires that the user has sufficient collateral supplied. The maximum borrow amount is determined by the collateral factor of supplied assets.
contract AaveBorrower {
IPool public immutable pool;
constructor(address _pool) {
pool = IPool(_pool);
}
function borrowAsset(
address asset,
uint256 amount,
uint256 interestRateMode // 1 = stable, 2 = variable
) external {
// Borrow with variable or stable rate
pool.borrow(asset, amount, interestRateMode, 0, msg.sender);
}
function repayAsset(
address asset,
uint256 amount,
uint256 interestRateMode
) external {
IERC20(asset).transferFrom(msg.sender, address(this), amount);
IERC20(asset).approve(address(pool), amount);
pool.repay(asset, amount, interestRateMode, msg.sender);
}
}
Withdrawing Supplied Assets #
function withdrawAsset(
address asset,
uint256 amount // use type(uint256).max for full withdrawal
) external {
// Withdraw aTokens and receive underlying asset
pool.withdraw(asset, amount, msg.sender);
}
Reading User Account Data #
AAVE provides a data provider contract that aggregates user-specific information including health factor, available borrows, and collateral breakdown.
import {IPoolDataProvider} from '@aave/core-v4/contracts/interfaces/IPoolDataProvider.sol';
contract AaveDataReader {
IPoolDataProvider public immutable dataProvider;
constructor(address _dataProvider) {
dataProvider = IPoolDataProvider(_dataProvider);
}
function getUserData(address user) external view returns (
uint256 totalCollateralBase,
uint256 totalDebtBase,
uint256 availableBorrowsBase,
uint256 currentLiquidationThreshold,
uint256 ltv,
uint256 healthFactor
) {
return dataProvider.calculateUserAccountData(user);
}
function getReserveConfiguration(address asset)
external
view
returns (
uint256 decimals,
uint256 ltv,
uint256 liquidationThreshold,
uint256 liquidationBonus,
uint256 reserveFactor,
bool usageAsCollateralEnabled,
bool borrowingEnabled
)
{
return dataProvider.getReserveConfigurationData(asset);
}
}
JavaScript Integration with ethers.js #
For frontend and scripting integrations, ethers.js provides a convenient interface.
const { ethers } = require('ethers');
require('dotenv').config();
// AAVE v4 Pool contract on Ethereum mainnet
const POOL_ADDRESS = '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2';
const POOL_DATA_PROVIDER = '0x7B4EB56E7CD4b454BA8ff71E4518426Fede81A62';
const provider = new ethers.JsonRpcProvider(process.env.ETHEREUM_RPC);
const POOL_ABI = [
'function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external',
'function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf) external',
'function repay(address asset, uint256 amount, uint256 interestRateMode, address onBehalfOf) external returns (uint256)',
'function withdraw(address asset, uint256 amount, address to) external returns (uint256)',
'function getUserAccountData(address user) external view returns (uint256 totalCollateralBase, uint256 totalDebtBase, uint256 availableBorrowsBase, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor)',
];
const pool = new ethers.Contract(POOL_ADDRESS, POOL_ABI, provider);
async function getUserAccountData(userAddress) {
const data = await pool.getUserAccountData(userAddress);
console.log('Total Collateral (USD):', ethers.formatUnits(data.totalCollateralBase, 8));
console.log('Total Debt (USD):', ethers.formatUnits(data.totalDebtBase, 8));
console.log('Available Borrows (USD):', ethers.formatUnits(data.availableBorrowsBase, 8));
console.log('Health Factor:', ethers.formatUnits(data.healthFactor, 18));
return data;
}
Working with Flash Loans #
Flash loans are uncollateralized loans that must be borrowed and repaid within a single transaction block. AAVE pioneered flash loans in DeFi, and v4 streamlines the implementation with a unified interface.
Flash Loan Receiver Contract #
import {IFlashLoanSimpleReceiver} from '@aave/core-v4/contracts/flashloan/interfaces/IFlashLoanSimpleReceiver.sol';
import {IPool} from '@aave/core-v4/contracts/interfaces/IPool.sol';
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
contract FlashLoanArbitrage is IFlashLoanSimpleReceiver {
IPool public immutable pool;
address public owner;
constructor(address _pool) {
pool = IPool(_pool);
owner = msg.sender;
}
modifier onlyPool() {
require(msg.sender == address(pool), 'Caller must be pool');
_;
}
function executeFlashLoan(
address asset,
uint256 amount,
bytes calldata params
) external {
require(msg.sender == owner, 'Only owner');
pool.flashLoanSimple(address(this), asset, amount, params, 0);
}
function executeOperation(
address asset,
uint256 amount,
uint256 premium,
address initiator,
bytes calldata params
) external onlyPool returns (bool) {
// Flash loan received - implement arbitrage logic here
uint256 amountOwed = amount + premium;
// Example: arbitrage between DEXes
// 1. Swap borrowed asset on DEX A
// 2. Swap received asset on DEX B
// 3. Profit = finalAmount - amountOwed
// Approve repayment
IERC20(asset).approve(address(pool), amountOwed);
return true;
}
}
Multi-Asset Flash Loans #
For advanced strategies requiring multiple assets, use the full flash loan interface.
import {IFlashLoanReceiver} from '@aave/core-v4/contracts/flashloan/interfaces/IFlashLoanReceiver.sol';
contract MultiAssetFlashLoan is IFlashLoanReceiver {
IPool public immutable pool;
constructor(address _pool) {
pool = IPool(_pool);
}
function executeMultiFlashLoan(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata interestRateModes,
bytes calldata params
) external {
pool.flashLoan(
address(this),
assets,
amounts,
interestRateModes,
msg.sender,
params,
0
);
}
function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator,
bytes calldata params
) external returns (bool) {
for (uint i = 0; i < assets.length; i++) {
uint256 amountOwed = amounts[i] + premiums[i];
IERC20(assets[i]).approve(address(pool), amountOwed);
}
return true;
}
}
Isolation Mode and Risk Management #
AAVE v4 enhanced isolation mode, which allows borrowing against specific collateral assets with bounded exposure limits. This is critical for integrating long-tail assets safely.
Supplying in Isolation Mode #
contract IsolationModeSupplier {
IPool public immutable pool;
constructor(address _pool) {
pool = IPool(_pool);
}
function supplyInIsolation(
address asset,
uint256 amount,
address onBehalfOf
) external {
// Check if asset can be used in isolation mode
(,,,,,, bool isolationModeEnabled) =
IPoolDataProvider(address(0)).getReserveConfigurationData(asset);
require(isolationModeEnabled, 'Asset not enabled for isolation');
IERC20(asset).transferFrom(msg.sender, address(this), amount);
IERC20(asset).approve(address(pool), amount);
// Supply with isolation mode flag
pool.supply(asset, amount, onBehalfOf, 0);
}
function getIsolationModeTotalDebt(address asset)
external
view
returns (uint256)
{
return pool.getReserveData(asset).isolationModeTotalDebt;
}
}
Checking Isolation Mode Constraints #
async function checkIsolationModeConstraints(userAddress, asset) {
const reserveData = await pool.getReserveData(asset);
const userConfig = await pool.getUserConfiguration(userAddress);
console.log('Isolation Mode Total Debt:',
reserveData.isolationModeTotalDebt.toString());
console.log('Isolation Mode Enabled:',
reserveData.configuration.data & (1 << 60) !== 0);
// Check user's isolation mode collateral
const userReserveConfig = await dataProvider.getUserReserveData(asset, userAddress);
console.log('User Collateral:',
ethers.formatUnits(userReserveConfig.currentATokenBalance, 18));
}
GHO Stablecoin Integration #
GHO is AAVE’s native decentralized stablecoin, minted against supplied collateral directly through the AAVE protocol. In v4, GHO integration is native to the pool architecture.
Minting GHO Against Collateral #
import {IGhoToken} from '@aave/gho-core/contracts/gho/interfaces/IGhoToken.sol';
contract GhoMinter {
IPool public immutable pool;
IGhoToken public immutable gho;
constructor(address _pool, address _gho) {
pool = IPool(_pool);
gho = IGhoToken(_gho);
}
function mintGho(
uint256 amount,
address onBehalfOf
) external {
// Requires sufficient collateral in AAVE pool
pool.borrow(
address(gho), // GHO address
amount,
2, // Variable rate
0, // Referral code
onBehalfOf
);
}
function repayGho(uint256 amount) external {
IERC20(address(gho)).transferFrom(msg.sender, address(this), amount);
IERC20(address(gho)).approve(address(pool), amount);
pool.repay(address(gho), amount, 2, msg.sender);
}
function getGhoDiscountRate(address user)
external
view
returns (uint256)
{
// stkAAVE holders receive discounts on GHO borrow rate
return gho.getDiscountPercent(user);
}
}
GHO Facilitator Pattern #
import {IGhoFacilitator} from '@aave/gho-core/contracts/gho/interfaces/IGhoFacilitator.sol';
contract CustomGhoFacilitator is IGhoFacilitator {
IGhoToken public immutable ghoToken;
uint256 public bucketCapacity;
uint256 public bucketLevel;
constructor(address _ghoToken, uint256 _capacity) {
ghoToken = IGhoToken(_ghoToken);
bucketCapacity = _capacity;
}
function mint(uint256 amount) external {
require(bucketLevel + amount <= bucketCapacity, 'Bucket capacity exceeded');
bucketLevel += amount;
ghoToken.mint(address(this), amount);
}
function burn(uint256 amount) external {
bucketLevel -= amount;
ghoToken.burn(amount);
}
function distributeFeesToTreasury() external {
// Implementation for fee distribution
}
}
Cross-Chain Portal and Bridge Operations #
AAVE v4 leverages Chainlink CCIP for cross-chain liquidity transfers, allowing users to move their positions between networks seamlessly.
Bridging aTokens Across Chains #
import {IPool} from '@aave/core-v4/contracts/interfaces/IPool.sol';
contract AaveCrossChainBridge {
IPool public immutable sourcePool;
address public immutable ccipRouter;
constructor(address _pool, address _router) {
sourcePool = IPool(_pool);
ccipRouter = _router;
}
function bridgeATokenToChain(
address aToken,
uint256 amount,
uint64 destinationChainSelector,
address recipient
) external {
// Withdraw aToken from user's position
uint256 withdrawn = sourcePool.withdraw(
getUnderlying(aToken),
amount,
address(this)
);
// Approve and bridge via CCIP
IERC20(getUnderlying(aToken)).approve(ccipRouter, withdrawn);
// CCIP transfer logic to destination chain
// On destination chain, supply into AAVE pool for recipient
}
function getUnderlying(address aToken)
internal
pure
returns (address)
{
// Return underlying asset for aToken
return address(0); // Implementation details
}
}
Liquidation Bot Implementation #
Liquidations are a critical mechanism for protocol solvency. Building a liquidation bot can be profitable while contributing to protocol health.
contract AaveLiquidator {
IPool public immutable pool;
constructor(address _pool) {
pool = IPool(_pool);
}
function liquidatePosition(
address collateralAsset,
address debtAsset,
address user,
uint256 debtToCover,
bool receiveAToken
) external {
// Approve debt asset for repayment
IERC20(debtAsset).transferFrom(msg.sender, address(this), debtToCover);
IERC20(debtAsset).approve(address(pool), debtToCover);
// Execute liquidation
pool.liquidationCall(
collateralAsset,
debtAsset,
user,
debtToCover,
receiveAToken
);
// Transfer liquidated collateral to caller
if (receiveAToken) {
// Transfer aTokens
} else {
// Underlying already sent to this contract
}
}
function checkLiquidatable(address user)
external
view
returns (bool, uint256 healthFactor)
{
(, , , , , healthFactor) = pool.getUserAccountData(user);
return (healthFactor < 1e18, healthFactor);
}
}
JavaScript Liquidation Scanner #
async function scanForLiquidations(usersToCheck) {
const liquidatableUsers = [];
for (const user of usersToCheck) {
try {
const data = await pool.getUserAccountData(user);
const healthFactor = ethers.formatUnits(data.healthFactor, 18);
if (parseFloat(healthFactor) < 1.0) {
liquidatableUsers.push({
address: user,
healthFactor,
totalCollateral: ethers.formatUnits(data.totalCollateralBase, 8),
totalDebt: ethers.formatUnits(data.totalDebtBase, 8),
});
console.log(`Liquidatable: ${user} HF: ${healthFactor}`);
}
} catch (error) {
console.error(`Error checking ${user}:`, error.message);
}
}
return liquidatableUsers;
}
Frontend Integration with React #
Modern DeFi frontends typically use wagmi and viem for blockchain interactions.
// hooks/useAave.ts
import { useContractWrite, usePrepareContractWrite } from 'wagmi';
import { parseUnits } from 'viem';
const POOL_ABI = [
{
name: 'supply',
type: 'function',
stateMutability: 'nonpayable',
inputs: [
{ name: 'asset', type: 'address' },
{ name: 'amount', type: 'uint256' },
{ name: 'onBehalfOf', type: 'address' },
{ name: 'referralCode', type: 'uint16' },
],
outputs: [],
},
] as const;
export function useSupplyAsset(asset: string, amount: string, decimals: number) {
const { config } = usePrepareContractWrite({
address: '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2',
abi: POOL_ABI,
functionName: 'supply',
args: [
asset as `0x${string}`,
parseUnits(amount, decimals),
'0xYourAddress' as `0x${string}`,
0,
],
});
return useContractWrite(config);
}
// components/SupplyButton.tsx
import { useSupplyAsset } from '../hooks/useAave';
export function SupplyButton({ asset, amount }: { asset: string; amount: string }) {
const { write, isLoading } = useSupplyAsset(asset, amount, 18);
return (
<button
onClick={() => write?.()}
disabled={isLoading}
className="supply-btn"
>
{isLoading ? 'Supplying...' : 'Supply to AAVE'}
</button>
);
}
Frequently Asked Questions #
What is the minimum collateral ratio for borrowing on AAVE v4? #
The minimum collateral ratio depends on the specific asset. Major assets like ETH and WBTC typically have loan-to-value ratios of 80%, meaning you can borrow up to 80% of your collateral value. However, each asset has its own risk parameters set by AAVE governance. The health factor must remain above 1.0 to avoid liquidation, and a health factor below 1.0 makes your position eligible for liquidation by keepers.
How do flash loans work in AAVE v4? #
Flash loans allow you to borrow any available amount of assets without collateral, provided the borrowed amount plus a fee is returned within the same transaction block. The fee is typically 0.09% in AAVE v4. If the loan is not repaid by the end of the transaction, the entire transaction reverts. Flash loans are commonly used for arbitrage, collateral swaps, self-liquidations, and refinancing debt positions.
What is the difference between stable and variable interest rates? #
Variable rates fluctuate based on supply and demand dynamics within the AAVE pool. They use an algorithmic model where rates increase as utilization approaches 100%. Stable rates provide predictable borrowing costs for a premium but can be rebalanced under extreme market conditions. In AAVE v4, the stable rate mechanism was improved to reduce the frequency of rebalance events.
How does isolation mode protect the protocol? #
Isolation mode in AAVE v4 allows certain long-tail assets to be used as collateral with strict limitations. When a user supplies an isolation mode asset, they can only borrow specific approved assets, and their total borrowing power is capped by a debt ceiling. This prevents a single volatile asset from threatening the solvency of the entire protocol. Isolation mode is particularly important for newly listed tokens with limited liquidity.
What is GHO and how is it different from other stablecoins? #
GHO is AAVE’s native decentralized stablecoin, pegged to the US dollar. Unlike centralized stablecoins backed by fiat reserves, GHO is minted algorithmically against overcollateralized positions within the AAVE protocol. stkAAVE token holders receive discounts on GHO borrowing rates. GHO is designed to be fully decentralized, censorship-resistant, and deeply integrated with AAVE’s lending markets.
Can I integrate AAVE v4 on Layer 2 networks? #
Yes, AAVE v4 is deployed on multiple Layer 2 networks including Arbitrum, Optimism, Base, and Polygon. The integration patterns are nearly identical across chains, though you should use the appropriate contract addresses and RPC endpoints for each network. Layer 2 deployments typically offer significantly lower gas costs while maintaining the same security guarantees through rollup architectures.
Recommended Hosting & Infrastructure #
Before you deploy any of the tools above into production, you’ll need solid infrastructure. Two options dibi8 actually uses and recommends:
- DigitalOcean — $200 free credit for 60 days across 14+ global regions.
- HTStack — Hong Kong VPS with low-latency access from mainland China. This is the same IDC that hosts dibi8.com.
Affiliate links — they don’t cost you extra and they help keep dibi8.com running.
Conclusion #
AAVE v4 represents the culmination of years of DeFi innovation, combining robust lending mechanics with modern architectural improvements. Its modular design, enhanced risk management through isolation mode, native GHO stablecoin integration, and cross-chain capabilities make it the premier choice for developers building financial applications on Ethereum and beyond.
The protocol’s extensive documentation, battle-tested smart contracts, and active developer community provide strong foundations for integration. Whether you are building a simple yield aggregator or a sophisticated DeFi protocol that composes with AAVE, the patterns outlined in this guide will accelerate your development.
Ready to start building on AAVE? You will need ETH for gas and assets to supply. Register on Binance or sign up on OKX to fund your development wallet and acquire the tokens you need for testing and deployment.
💬 Discussion