Giter Club home page Giter Club logo

aave-flash-loan-tutorial's Introduction

Aave Flash Loan Tutorial

Create an Aave Flash Loan arbitrage smart contract from scratch in this comprehensive flash loan tutorial by Block Explorer.

Project repo:

https://github.com/jspruance/aave-flash-loan-tutorial

Aave v3 Flash Loan documentation:

https://docs.aave.com/developers/guides/flash-loans https://docs.aave.com/developers/deployed-contracts/v3-testnet-addresses

DAI-TestnetMintableERC20-Aave token (Goerli):

0xDF1742fE5b0bFc12331D8EAec6b478DfDbD31464

USDC-TestnetMintableERC20-Aave token(Goerli):

0xA2025B15a1757311bfD68cb14eaeFCc237AF5b43

AAVE PoolAddressProvider (Goerli):

0x5E52dEc931FFb32f609681B8438A51c675cc232d

Remix imports:

import {FlashLoanReceiverBase} from "https://github.com/aave/protocol-v2/blob/master/contracts/flashloan/base/FlashLoanReceiverBase.sol"; import {ILendingPool} from "https://github.com/aave/protocol-v2/blob/master/contracts/interfaces/ILendingPool.sol"; import {ILendingPoolAddressesProvider} from "https://github.com/aave/protocol-v2/blob/master/contracts/interfaces/ILendingPoolAddressesProvider.sol"; import {IERC20} from "https://github.com/aave/protocol-v2/blob/master/contracts/dependencies/openzeppelin/contracts/IERC20.sol";

Dex.sol deployed (Goerli):

0xD6e8c479B6B62d8Ce985C0f686D39e96af9424df

Add liquidity to Dex.sol:

USDC 1500 DAI 1500

Approve:

USDC 1000000000 DAI 1200000000000000000000

Request Loan - USDC (6 decimal):

0xA2025B15a1757311bfD68cb14eaeFCc237AF5b43,1000000000 // 1,000 USDC 0xA2025B15a1757311bfD68cb14eaeFCc237AF5b43,1000000 // 1 USDC

aave-flash-loan-tutorial's People

Contributors

jspruance avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aave-flash-loan-tutorial's Issues

where and which dexContractAddress in FlashLoanArbitrage.sol

Hi

Thank you for your code
if you have a change to reply my issue,
Please give me an guidance

it's been long time to follow up your course.
so it might change some contract address
I've tried to find the dexContractAddress but I can't yet
please which address whould I replace for the dexContractAddress in FlashLoanArbitrage.sol

contract FlashLoanArbitrage is FlashLoanSimpleReceiverBase {
address payable owner;

// Aave ERC20 Token addresses on Goerli network
address private immutable daiAddress =
    0xBa8DCeD3512925e52FE67b1b5329187589072A55;
address private immutable usdcAddress =
    0x65aFADD39029741B3b8f0756952C74678c9cEC93;
address private dexContractAddress =0xC911B590248d127aD18546B186cC6B324e99F02c(this is what I found it please let me know if it's right)

i found like
PoolAddressesProvider-Aave โ”‚ '0xC911B590248d127aD18546B186cC6B324e99F02c' โ”‚

is it right address to replace?

Please let me find the right dexContractAddress

Thank you so much

dependancies need updated

revised works:

{
  "name": "hardhat-project",
  "devDependencies": {
    "@ethersproject/abi": "^5.7.0",
    "@ethersproject/providers": "^5.7.2",
    "@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.7",
    "@nomicfoundation/hardhat-toolbox": "^2.0.0",
    "@nomiclabs/hardhat-ethers": "^2.2.1",
    "@nomiclabs/hardhat-etherscan": "^3.1.4",
    "chai": "^4.3.7",
    "ethers": "^5.7.2",
    "hardhat": "^2.12.5",
    "hardhat-gas-reporter": "^1.0.9",
    "solidity-coverage": "^0.8.2",
    "@typechain/ethers-v5": "^10.1.0",
    "@typechain/hardhat": "^6.1.3",
    "typechain": "^8.1.0"
  },
  "dependencies": {
    "@aave/core-v3": "^1.16.2",
    "@openzeppelin/contracts": "^4.7.3",
    "dotenv": "^16.0.3"
  }
}

Executing the FlashLoanArbitrage gives a Gas estimation error

Thanks for the great video walk-through tutorial on YouTube for this.
I am trying the run the arbitrage function with dex contract and always get the following error,

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? Returned error: {"jsonrpc":"2.0","error":"execution reverted: Check the token allowance","id":2683750395878379}

Obviously, if I choose to continue it fails like it says it will.
Is this a code problem or a problem with remix.ethereum.org?

I appreciate any advice given on this issue.

I get this error when i tried to deploy my contract following the tutorial

Watching /Users/macbookair2014/Flash Loan aave and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles.
/Users/macbookair2014/.npm/_npx/755986f37193a6d8/node_modules/run/run.js:127
if (minimatch(file, pattern)) {
^

TypeError: minimatch is not a function
at /Users/macbookair2014/.npm/_npx/755986f37193a6d8/node_modules/run/run.js:127:13
at Array.forEach ()
at parseFolder (/Users/macbookair2014/.npm/_npx/755986f37193a6d8/node_modules/run/run.js:113:9)
at Object. (/Users/macbookair2014/.npm/_npx/755986f37193a6d8/node_modules/run/run.js:63:12)
at Module._compile (node:internal/modules/cjs/loader:1275:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
at Module.load (node:internal/modules/cjs/loader:1133:32)
at Module._load (node:internal/modules/cjs/loader:972:12)
at Module.require (node:internal/modules/cjs/loader:1157:19)
at require (node:internal/modules/helpers:119:18)

Node.js v19.9.0

TypeError: Invalid type for argument in modifier invocation.

Issue Summary:

I encountered a TypeError in the code while trying to invoke a modifier in the flashloan.sol contract. The error message suggests an invalid type for the argument in the modifier invocation, specifically an invalid implicit conversion from contract IPoolAddressesProvider to contract IPoolAddressesProvider is being requested.

Steps to Reproduce:

  • Deploy the contract with the given code.
  • Attempt to invoke the modifier in the flashloan.sol contract.
  • Observe the TypeError mentioned in the error message.

Expected Behavior:

The code should compile without any errors, and the modifier should be invoked successfully without type conversion issues.

Actual Behavior:

Encountered a TypeError with the following details:

TypeError: Invalid type for argument in modifier invocation. Invalid implicit conversion from contract IPoolAddressesProvider to contract IPoolAddressesProvider requested.
  --> contracts/flashloan.sol:13:35:
   |
13 |     ) FlashLoanSimpleReceiverBase(IPoolAddressesProvider(_addressProvider)) {
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Environment:

  • Solidity Compiler version: "0.8.10"
  • Operating system: Windows x64

I also tried fixing the code with Remix Ide also, after spending times fixing it on local using Hardhat but no results unfortunately, please let me know how it can be fixed thanks!

issue with FlashLoan.deploy()

const FlashLoan = await hre.ethers.getContractFactory("FlashLoan");

const flashLoan = await FlashLoan.deploy("0x012bAC54348C0E635dCAc9D5FB99f06F24136C9A");

Flash Loan is not deployed.

Address is POOLADDRESSPROVIDER AAVE-V3 for Ethereum Sepolia Testnet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.