{"id":13470823,"url":"https://github.com/aave/protocol-v2","last_synced_at":"2025-05-15T17:03:13.618Z","repository":{"id":37960743,"uuid":"317832067","full_name":"aave/protocol-v2","owner":"aave","description":"Aave Protocol V2","archived":false,"fork":false,"pushed_at":"2024-08-13T11:03:43.000Z","size":19214,"stargazers_count":688,"open_issues_count":132,"forks_count":769,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-04-07T21:15:38.756Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://aave.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aave.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":"audits/Certik-aave-v2-03-12-2020.pdf","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-02T10:52:38.000Z","updated_at":"2025-04-07T10:33:12.000Z","dependencies_parsed_at":"2024-06-11T19:05:03.131Z","dependency_job_id":"4e30089c-640a-4342-9793-fc77792d9368","html_url":"https://github.com/aave/protocol-v2","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aave%2Fprotocol-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aave%2Fprotocol-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aave%2Fprotocol-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aave%2Fprotocol-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aave","download_url":"https://codeload.github.com/aave/protocol-v2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384937,"owners_count":22062421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T16:00:36.288Z","updated_at":"2025-05-15T17:03:13.598Z","avatar_url":"https://github.com/aave.png","language":"TypeScript","funding_links":[],"categories":["DEFI","TypeScript"],"sub_categories":[],"readme":"[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)\n[![Build pass](https://github.com/AAVE/protocol-v2/actions/workflows/node.js.yml/badge.svg)](https://github.com/aave/protocol-v2/actions/workflows/node.js.yml)\n```\n        .///.                .///.     //.            .//  `/////////////-\n       `++:++`              .++:++`    :++`          `++:  `++:......---.`\n      `/+: -+/`            `++- :+/`    /+/         `/+/   `++.\n      /+/   :+/            /+:   /+/    `/+/        /+/`   `++.\n  -::/++::`  /+:       -::/++::` `/+:    `++:      :++`    `++/:::::::::.\n  -:+++::-`  `/+:      --++/---`  `++-    .++-    -++.     `++/:::::::::.\n   -++.       .++-      -++`       .++.    .++.  .++-      `++.\n  .++-         -++.    .++.         -++.    -++``++-       `++.\n `++:           :++`  .++-           :++`    :+//+:        `++:----------`\n -/:             :/-  -/:             :/.     ://:         `/////////////-\n```\n\n# Aave Protocol v2\n\nThis repository contains the smart contracts source code and markets configuration for Aave Protocol V2. The repository uses Docker Compose and Hardhat as development enviroment for compilation, testing and deployment tasks.\n\n## What is Aave?\n\nAave is a decentralized non-custodial liquidity markets protocol where users can participate as depositors or borrowers. Depositors 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.\n\n## Documentation\n\nThe documentation of Aave V2 is in the following [Aave V2 documentation](https://docs.aave.com/developers/v/2.0/) link. At the documentation you can learn more about the protocol, see the contract interfaces, integration guides and audits.\n\nFor getting the latest contracts addresses, please check the [Deployed contracts](https://docs.aave.com/developers/v/2.0/deployed-contracts/deployed-contracts) page at the documentation to stay up to date.\n\nA more detailed and technical description of the protocol can be found in this repository, [here](./aave-v2-whitepaper.pdf)\n\n## Audits\n\n- MixBytes (16/09/2020 - 03/12/2020): [report](./audits/Mixbytes-aave-v2-03-12-2020.pdf)\n- PeckShield (29/09/2020 - 03/12/2020) : [report](./audits/Peckshield-aave-v2-03-12-2020-EN.pdf) (Also available in Chinese in the same folder)\n- CertiK (28/09/2020 - 02/12/2020): [report](./audits/Certik-aave-v2-03-12-2020.pdf)\n- Consensys Diligence (09/09/2020 - 09/10/2020): [report](https://consensys.net/diligence/audits/2020/09/aave-protocol-v2/)\n- Certora, formal verification (02/08/2020 - 29/10/2020): [report](./audits/Certora-FV-aave-v2-03-12-2020.pdf)\n- SigmaPrime (January 2021): [report](./audits/SigmaPrime-aave-v2-01-2021.pdf)\n\n## Connect with the community\n\nYou can join at the [Discord](http://aave.com/discord) channel or at the [Governance Forum](https://governance.aave.com/) for asking questions about the protocol or talk about Aave with other peers.\n\n## Getting Started\n\nYou can install `@aave/protocol-v2` as an NPM package in your Hardhat, Buidler or Truffle project to import the contracts and interfaces:\n\n`npm install @aave/protocol-v2`\n\nImport at Solidity files:\n\n```\nimport {ILendingPool} from \"@aave/protocol-v2/contracts/interfaces/ILendingPool.sol\";\n\ncontract Misc {\n\n  function deposit(address pool, address token, address user, uint256 amount) public {\n    ILendingPool(pool).deposit(token, amount, user, 0);\n    {...}\n  }\n}\n```\n\nThe JSON artifacts with the ABI and Bytecode are also included into the bundled NPM package at `artifacts/` directory.\n\nImport JSON file via Node JS `require`:\n\n```\nconst LendingPoolV2Artifact = require('@aave/protocol-v2/artifacts/contracts/protocol/lendingpool/LendingPool.sol/LendingPool.json');\n\n// Log the ABI into console\nconsole.log(LendingPoolV2Artifact.abi)\n```\n\n## Setup\n\nThe repository uses Docker Compose to manage sensitive keys and load the configuration. Prior 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`.\n\nFollow the next steps to setup the repository:\n\n- Install `docker` and `docker-compose`\n- Create an enviroment file named `.env` and fill the next enviroment variables\n\n```\n# Mnemonic, only first address will be used\nMNEMONIC=\"\"\n\n# Add Alchemy or Infura provider keys, alchemy takes preference at the config level\nALCHEMY_KEY=\"\"\nINFURA_KEY=\"\"\n\n\n# Optional Etherscan key, for automatize the verification of the contracts at Etherscan\nETHERSCAN_KEY=\"\"\n\n# Optional, if you plan to use Tenderly scripts\nTENDERLY_PROJECT=\"\"\nTENDERLY_USERNAME=\"\"\n\n```\n\n## Markets configuration\n\nThe configurations related with the Aave Markets are located at `markets` directory. You can follow the `IAaveConfiguration` interface to create new Markets configuration or extend the current Aave configuration.\n\nEach market should have his own Market configuration file, and their own set of deployment tasks, using the Aave market config and tasks as a reference.\n\n## Test\n\nYou can run the full test suite with the following commands:\n\n```\n# In one terminal\ndocker-compose up\n\n# Open another tab or terminal\ndocker-compose exec contracts-env bash\n\n# A new Bash terminal is prompted, connected to the container\nnpm run test\n```\n\n## Deployments\n\nFor deploying Aave Protocol V2, you can use the available scripts located at `package.json`. For a complete list, run `npm run` to see all the tasks.\n\n### Kovan deployment\n\n```\n# In one terminal\ndocker-compose up\n\n# Open another tab or terminal\ndocker-compose exec contracts-env bash\n\n# A new Bash terminal is prompted, connected to the container\nnpm run aave:kovan:full:migration\n```\n\n### Mainnet fork deployment\n\nYou can deploy Aave Protocol v2 in a forked Mainnet chain using Hardhat built-in fork feature:\n\n```\ndocker-compose run contracts-env npm run aave:fork:main\n```\n\n### Deploy Aave into a Mainnet Fork via console\n\nYou can deploy Aave into the Hardhat console in fork mode, to interact with the protocol inside the fork or for testing purposes.\n\nRun the console in Mainnet fork mode:\n\n```\ndocker-compose run contracts-env npm run console:fork\n```\n\nAt the Hardhat console, interact with the Aave protocol in Mainnet fork mode:\n\n```\n// Deploy the Aave protocol in fork mode\nawait run('aave:mainnet')\n\n// Or your custom Hardhat task\nawait run('your-custom-task');\n\n// After you initialize the HRE via 'set-DRE' task, you can import any TS/JS file\nrun('set-DRE');\n\n// Import contract getters to retrieve an Ethers.js Contract instance\nconst contractGetters = require('./helpers/contracts-getters'); // Import a TS/JS file\n\n// Lending pool instance\nconst lendingPool = await contractGetters.getLendingPool(\"LendingPool address from 'aave:mainnet' task\");\n\n// You can impersonate any Ethereum address\nawait network.provider.request({ method: \"hardhat_impersonateAccount\",  params: [\"0xb1adceddb2941033a090dd166a462fe1c2029484\"]});\n\nconst signer = await ethers.provider.getSigner(\"0xb1adceddb2941033a090dd166a462fe1c2029484\")\n\n// ERC20 token DAI Mainnet instance\nconst DAI = await contractGetters.getIErc20Detailed(\"0x6B175474E89094C44Da98b954EedeAC495271d0F\");\n\n// Approve 100 DAI to LendingPool address\nawait DAI.connect(signer).approve(lendingPool.address, ethers.utils.parseUnits('100'));\n\n// Deposit 100 DAI\nawait lendingPool.connect(signer).deposit(DAI.address, ethers.utils.parseUnits('100'), await signer.getAddress(), '0');\n\n```\n\n## Interact with Aave in Mainnet via console\n\nYou can interact with Aave at Mainnet network using the Hardhat console, in the scenario where the frontend is down or you want to interact directly. You can check the deployed addresses at https://docs.aave.com/developers/deployed-contracts.\n\nRun the Hardhat console pointing to the Mainnet network:\n\n```\ndocker-compose run contracts-env npx hardhat --network main console\n```\n\nAt the Hardhat console, you can interact with the protocol:\n\n```\n// Load the HRE into helpers to access signers\nrun(\"set-DRE\")\n\n// Import getters to instance any Aave contract\nconst contractGetters = require('./helpers/contracts-getters');\n\n// Load the first signer\nconst signer = await contractGetters.getFirstSigner();\n\n// Lending pool instance\nconst lendingPool = await contractGetters.getLendingPool(\"0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9\");\n\n// ERC20 token DAI Mainnet instance\nconst DAI = await contractGetters.getIErc20Detailed(\"0x6B175474E89094C44Da98b954EedeAC495271d0F\");\n\n// Approve 100 DAI to LendingPool address\nawait DAI.connect(signer).approve(lendingPool.address, ethers.utils.parseUnits('100'));\n\n// Deposit 100 DAI\nawait lendingPool.connect(signer).deposit(DAI.address, ethers.utils.parseUnits('100'), await signer.getAddress(), '0');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faave%2Fprotocol-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faave%2Fprotocol-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faave%2Fprotocol-v2/lists"}