Convert Figma logo to code with AI

aave logoaave-v3-core

This repository contains the core smart contracts of the Aave V3 protocol.

1,018
672
1,018
48

Top Related Projects

The Compound On-Chain Protocol

4,724

🦄 🦄 🦄 Core smart contracts of Uniswap v3

Quick Overview

Aave V3 Core is the latest version of the Aave Protocol, a decentralized non-custodial liquidity protocol where users can participate as depositors or borrowers. It allows users to deposit assets as collateral to borrow other assets or earn yield on their deposits. This repository contains the core smart contracts for the Aave V3 protocol.

Pros

  • Enhanced capital efficiency with isolated markets and high-efficiency mode
  • Improved risk management with risk administrators and configurable parameters
  • Cross-chain functionality, enabling deployment on multiple networks
  • Upgraded liquidation and repayment mechanisms for better protocol stability

Cons

  • Increased complexity compared to previous versions, potentially leading to a steeper learning curve
  • Higher gas costs for some operations due to additional features
  • Potential for new security vulnerabilities due to expanded functionality
  • Requires careful parameter configuration to maintain optimal performance across different markets

Code Examples

  1. Supplying assets to the Aave protocol:
function supplyAsset(address asset, uint256 amount) external {
    IERC20(asset).transferFrom(msg.sender, address(this), amount);
    pool.supply(asset, amount, msg.sender, 0);
}
  1. Borrowing assets from the Aave protocol:
function borrowAsset(address asset, uint256 amount, uint256 interestRateMode) external {
    pool.borrow(asset, amount, interestRateMode, 0, msg.sender);
}
  1. Repaying a borrowed asset:
function repayAsset(address asset, uint256 amount, uint256 interestRateMode) external {
    IERC20(asset).transferFrom(msg.sender, address(this), amount);
    pool.repay(asset, amount, interestRateMode, msg.sender);
}

Getting Started

To get started with Aave V3 Core:

  1. Clone the repository:

    git clone https://github.com/aave/aave-v3-core.git
    
  2. Install dependencies:

    npm install
    
  3. Compile the contracts:

    npx hardhat compile
    
  4. Run tests:

    npx hardhat test
    

For more detailed instructions and documentation, refer to the repository's README and official Aave documentation.

Competitor Comparisons

The Compound On-Chain Protocol

Pros of Compound Protocol

  • Simpler architecture, making it easier for developers to understand and integrate
  • Longer track record in the DeFi space, potentially offering more stability
  • More established ecosystem with a wider range of supported assets

Cons of Compound Protocol

  • Less flexible interest rate model compared to Aave V3
  • Limited risk management features compared to Aave's more advanced risk parameters
  • Slower to implement new features and upgrades

Code Comparison

Aave V3 Core (Solidity):

function supply(
    address asset,
    uint256 amount,
    address onBehalfOf,
    uint16 referralCode
) external override whenNotPaused {
    SupplyLogic.executeSupply(
        _reserves,
        _usersConfig[onBehalfOf],
        DataTypes.ExecuteSupplyParams({
            asset: asset,
            amount: amount,
            onBehalfOf: onBehalfOf,
            referralCode: referralCode
        })
    );
}

Compound Protocol (Solidity):

function mint(uint mintAmount) external returns (uint) {
    (uint err,) = mintInternal(msg.sender, mintAmount);
    return err;
}

function mintInternal(address minter, uint mintAmount) internal returns (uint, uint) {
    uint error = accrueInterest();
    if (error != uint(Error.NO_ERROR)) {
        return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0);
    }
    // Additional logic...
}

Both protocols implement lending and borrowing functionalities, but Aave V3 Core offers more advanced features and flexibility in its implementation.

4,724

🦄 🦄 🦄 Core smart contracts of Uniswap v3

Pros of v3-core

  • Implements concentrated liquidity, allowing for more efficient capital utilization
  • Supports multiple fee tiers, providing flexibility for different trading pairs
  • Includes a robust oracle system for secure price feeds

Cons of v3-core

  • Higher complexity for liquidity providers compared to v2
  • Potential for increased gas costs due to more complex operations
  • Narrower liquidity ranges may lead to more frequent rebalancing

Code Comparison

v3-core:

function swap(
    address recipient,
    bool zeroForOne,
    int256 amountSpecified,
    uint160 sqrtPriceLimitX96,
    bytes calldata data
) external returns (int256 amount0, int256 amount1);

aave-v3-core:

function supply(
    address asset,
    uint256 amount,
    address onBehalfOf,
    uint16 referralCode
) external;

The v3-core swap function handles complex AMM operations, while aave-v3-core's supply function focuses on lending pool interactions. v3-core's implementation reflects its advanced liquidity management, whereas aave-v3-core emphasizes simplicity in supplying assets to the protocol.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

⚠️ This repository is DEPRECATED and no longer maintained ⚠️

For the latest Aave V3 code visit the V3 Origin Repository here.

Build pass codecov

        .///.                .///.     //.            .//  `/////////////-
       `++:++`              .++:++`    :++`          `++:  `++:......---.`
      `/+: -+/`            `++- :+/`    /+/         `/+/   `++.
      /+/   :+/            /+:   /+/    `/+/        /+/`   `++.
  -::/++::`  /+:       -::/++::` `/+:    `++:      :++`    `++/:::::::::.
  -:+++::-`  `/+:      --++/---`  `++-    .++-    -++.     `++/:::::::::.
   -++.       .++-      -++`       .++.    .++.  .++-      `++.
  .++-         -++.    .++.         -++.    -++``++-       `++.
 `++:           :++`  .++-           :++`    :+//+:        `++:----------`
 -/:             :/-  -/:             :/.     ://:         `/////////////-

Aave Protocol v3

This repository contains the smart contracts source code and markets configuration for Aave Protocol V3. The repository uses Docker Compose and Hardhat as development environment for compilation, testing and deployment tasks.

What is Aave?

Aave is a decentralized non-custodial liquidity markets protocol where users can participate as suppliers or borrowers. Suppliers provide liquidity to the market to earn a passive income, while borrowers are able to borrow in an overcollateralized (perpetually) or undercollateralized (one-block liquidity) fashion.

Documentation

See the link to the technical paper or visit the Aave Developer docs

Audits and Formal Verification

You can find all audit reports under the audits folder

V3.0.1 - December 2022

V3 Round 1 - October 2021

V3 Round 2 - December 2021

Formal Verification - November 2021-January 2022

Connect with the community

You can join the Discord channel or the Governance Forum to ask questions about the protocol or talk about Aave with other peers.

Getting Started

You can install @aave/core-v3 as an NPM package in your Hardhat or Truffle project to import the contracts and interfaces:

npm install @aave/core-v3

Import at Solidity files:

import {IPool} from "@aave/core-v3/contracts/interfaces/IPool.sol";

contract Misc {

  function supply(address pool, address token, address user, uint256 amount) public {
    IPool(pool).supply(token, amount, user, 0);
    {...}
  }
}

The JSON artifacts with the ABI and Bytecode are also included in the bundled NPM package at artifacts/ directory.

Import JSON file via Node JS require:

const PoolV3Artifact = require('@aave/core-v3/artifacts/contracts/protocol/pool/Pool.sol/Pool.json');

// Log the ABI into console
console.log(PoolV3Artifact.abi)

Setup

The repository uses Docker Compose to manage sensitive keys and load the configuration. Prior to any action like test or deploy, you must run docker-compose up to start the contracts-env container, and then connect to the container console via docker-compose exec contracts-env bash.

Follow the next steps to setup the repository:

  • Install docker and docker-compose
  • Create an environment file named .env and fill the next environment variables
# Add Alchemy or Infura provider keys, alchemy takes preference at the config level
ALCHEMY_KEY=""
INFURA_KEY=""


# Optional, if you plan to use Tenderly scripts
TENDERLY_PROJECT=""
TENDERLY_USERNAME=""

Test

You can run the full test suite with the following commands:

# In one terminal
docker-compose up

# Open another tab or terminal
docker-compose exec contracts-env bash

# A new Bash terminal is prompted, connected to the container
npm run test

NPM DownloadsLast 30 Days