Borrow tokens with Aave FLASHLOANS - Solidity tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ธ.ค. 2024

ความคิดเห็น • 143

  • @ArchaicStigma
    @ArchaicStigma 4 ปีที่แล้ว +10

    Great to see someone actually making an instructional video and showing that anyone can follow along if they take the time!!

  • @kevinpellerin6715
    @kevinpellerin6715 10 หลายเดือนก่อน

    An actual video without hype, nice. Thank you

  • @hariselvakumar1358
    @hariselvakumar1358 4 ปีที่แล้ว +20

    Hi! First off all this is a great bare bones tutorial. It would be awesome if you could make a follow-up video of deploying the contract perhaps in Kovan or Ropsten test net. Thanks a lot in advance!

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว +8

      good idea I will think about it :)

    • @ruman_life
      @ruman_life 4 ปีที่แล้ว +1

      Excellent idea! I think the next step would be of value for the space 😅

  • @chloelewis36
    @chloelewis36 4 ปีที่แล้ว +8

    Heard you were asking questions in the Aave chat, have been waiting for this vid! Thanks for the info as always.

  • @pablocastro7952
    @pablocastro7952 4 ปีที่แล้ว +2

    my friend I've watched a lot of your vid"s your helping me so much,i am working on becoming a programmer.thanks for breaking it down and saying what the plugins are for and how to use them properly.on other videos.i will connect all the dots and build a bad As bot lol.

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว

      Happy to hear this Pablo :)

    • @marciofagg
      @marciofagg 2 ปีที่แล้ว +1

      Did you manage to build your bot?

  • @pauleth
    @pauleth 4 ปีที่แล้ว +17

    sir I want more of these

  • @lmnop291
    @lmnop291 3 ปีที่แล้ว +3

    what keeps you from taking a flash loan and converting it to US dollars, buying stocks

    • @EatTheBlocks
      @EatTheBlocks  3 ปีที่แล้ว +10

      you cant, it's only on the blockchain in a single transaction. There is no concept of loan duration with flashloans, it's instant.

    • @moibe182
      @moibe182 3 ปีที่แล้ว +3

      @@EatTheBlocks So it can't be used to farm? How was done the hack to Harvest.finance done?

    • @khalidElAraibi
      @khalidElAraibi 3 ปีที่แล้ว +1

      @@moibe182 @EatTheBlocks can you make about this please?

  • @pubglord23
    @pubglord23 2 ปีที่แล้ว

    @ Eat the blocks these requires laptop right

  • @jodystewart9028
    @jodystewart9028 3 ปีที่แล้ว +1

    After the loan is paid back and fees are paid, how does the money leftover end up in one of my wallets?

  • @MsTaLucifer
    @MsTaLucifer 3 ปีที่แล้ว +2

    What do you mean in the same transaction? If someone gets a flash loan they need to pay it while there taking it out? I’m confused... mb😂😅

    • @MsTaLucifer
      @MsTaLucifer 3 ปีที่แล้ว +1

      @EatTheBlócks 🦧 🦧 🦧

  • @preschoolPT
    @preschoolPT 3 ปีที่แล้ว

    what app are you using. im a total beginner but keen to learn

  • @infinitytrading-ai
    @infinitytrading-ai 4 ปีที่แล้ว +1

    Hi I like your video but can you show the exact steps to take that code and then exactly how to run the flash loan live or even testnet, but how to do everything from scratch assuming the person doesnt have any crypto experience but good programming experience thanks

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว +1

      You can check my playlist on Flashloan I have more videos.
      I also have a course on how to run Arbitrage Flashloan here:
      eattheblocks-pro.teachable.com/p/profitable-flashloans

  • @patricioibarrag
    @patricioibarrag 3 ปีที่แล้ว

    Hi Julien, how do you get the prices avoiding latency?

  • @tim2nz
    @tim2nz 3 ปีที่แล้ว

    I want to ditch my job. How do I get a job working on the block chain?

    • @gpalaces
      @gpalaces 2 ปีที่แล้ว

      Learn Solidity & JS.

  • @sammannuel9287
    @sammannuel9287 4 ปีที่แล้ว +2

    Thanks for this.....great video.......I am new to solidity even though I have being using ethereum defi dapps for while....I really want to learn about this new flash loan concept...can you please share the code you used for this tutorial

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว +1

      sure you only have to register for free on eattheblocks.com to the free course and I will send you the link to the repo (that's only available to free and paid student who registered)
      By the way this is a tutorial series on Solidity, might be interesting if you are getting started:
      th-cam.com/video/p3C7jljTXaA/w-d-xo.html

    • @NIKO-bi9ec
      @NIKO-bi9ec 4 ปีที่แล้ว +6

      pragma solidity ^0.5.0;
      import "openzeppelin-solidity/contracts/math/SafeMath.sol";
      import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
      import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";
      import "../interfaces/IFlashLoanReceiver.sol";
      import "../../interfaces/ILendingPoolAddressesProvider.sol";
      import "../../libraries/EthAddressLib.sol";
      contract FlashLoanReceiverBase is IFlashLoanReceiver {
      using SafeERC20 for IERC20;
      using SafeMath for uint256;
      ILendingPoolAddressesProvider public addressesProvider;
      constructor(ILendingPoolAddressesProvider _provider) public {
      addressesProvider = _provider;
      }
      function () external payable {
      }
      function transferFundsBackToPoolInternal(address _reserve, uint256 _amount) internal {
      address payable core = addressesProvider.getLendingPoolCore();
      transferInternal(core,_reserve, _amount);
      }
      function transferInternal(address payable _destination, address _reserve, uint256 _amount) internal {
      if(_reserve == EthAddressLib.ethAddress()) {
      //solium-disable-next-line
      _destination.call.value(_amount)("");
      return;
      }
      IERC20(_reserve).safeTransfer(_destination, _amount);
      }
      Enjoy it for free ;)

    • @rezachowdhury9812
      @rezachowdhury9812 4 ปีที่แล้ว +1

      @@NIKO-bi9ec Can you help me to take a flash loans?I cant coding.If possible help me.I can give you all the information which you want.

    • @kingsley.gyimah
      @kingsley.gyimah 4 ปีที่แล้ว +1

      ​@@NIKO-bi9ec Hi, thanks. Might I know which sections to tweak to allow it send the profit to my address after the transaction?

    • @sammannuel9287
      @sammannuel9287 4 ปีที่แล้ว +2

      @@EatTheBlocks Thanks very much....I just signed up.....your tutorials are really helpful for starter like me.

  • @ronnie_ooi
    @ronnie_ooi 3 ปีที่แล้ว

    Will the course also show how to actual launch the smart contract and able to perform real trade? If the transaction did not go succeed. Do we waste gas fee?

  • @tayneilson
    @tayneilson 2 ปีที่แล้ว +1

    code starts around 4:00

  • @NOREALESTATEINVESTORLEFTBEHIND
    @NOREALESTATEINVESTORLEFTBEHIND 4 ปีที่แล้ว +2

    Where can we get this smart contract to use for us

  • @ygblffknfrrsVnlmvchnvkkgcc
    @ygblffknfrrsVnlmvchnvkkgcc 3 ปีที่แล้ว

    Another great video!! Thank you bro!!

  • @benjaminpacheco5291
    @benjaminpacheco5291 4 ปีที่แล้ว +1

    Thanks for the video, gained subscriber here. Just a question though? Is it really profitable and how much earning potential here? If it is profitable then senior blockchain developers might exploit it doing arbitrage trading all the time causing prices to balance out between exchanges.

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว +5

      Hey Benjamin. In feb, someone made 1M USD with 2 Flashloans. So it can definetly be profitable.
      This takes work to put in place though, and not everybody has the inclination to do that, including senior devs.

    • @juggernautz
      @juggernautz 3 ปีที่แล้ว +4

      You have to wait for price volatility to increase thereby creating price discrepancy across different exchanges and exploit the transaction before the 2 prices match or get so close that the gas fees + .09% fee eat up profit. For instance 10 ETH borrowed times @ $1850 times .09% would cost $1665 for the AAVE fee plus gas fees. If the prices converge then throw it back and end the transaction do not complete it because you'll lose on the transaction plus fees.

  • @Rationalist101
    @Rationalist101 3 ปีที่แล้ว +1

    Do we have to pay the gas fees with our own money tho???

  • @pubglord23
    @pubglord23 2 ปีที่แล้ว

    @Eattheblock the remix site isn't loading on the site. Is there things to be done before it can show cause it's showing error on my laptop. I need the reply quick

    • @EatTheBlocks
      @EatTheBlocks  2 ปีที่แล้ว

      which error? You can ask your troubleshooting questions on Remix in the Remix discord / gitter, they will know how to help you better than me

    • @pubglord23
      @pubglord23 2 ปีที่แล้ว

      @@EatTheBlocks alright do just that

  • @mainakbanerjee3738
    @mainakbanerjee3738 4 ปีที่แล้ว

    If I deploy the contract as you have shown above , will it start taking the money from the lender from the lending pool automatically ? Or I have to search for a lender or convince him to give me the loan ? Is there any advertisement needed to get the lender?

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว +1

      This is a liquidity pool you don't have to deal with lenders directly. You are limited by the amount in the liquidity pool though

  • @onekycarscanners6002
    @onekycarscanners6002 4 ปีที่แล้ว

    What is or where can I find the number of flash loans issued by Aave. Daily to monthly figures. Do tell me someone did it and made $1m. How many did it and continuously made $5.

  • @msettecasse
    @msettecasse 4 ปีที่แล้ว

    Great! But how do you interact with the other protocols such as using the loan and buying on one dex and selling on another?

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว

      That's something I cover in this course:
      eattheblocks-pro.teachable.com/p/profitable-flashloans

    • @jason18401
      @jason18401 4 ปีที่แล้ว

      EatTheBlocks is this profitable and prod ready?

  • @c-note8959
    @c-note8959 4 ปีที่แล้ว

    Hello @EatTheBlocks when does aave take their fees, when your suppose flashloan is a success?

    • @weirkved
      @weirkved 4 ปีที่แล้ว

      You have to ensure the receiving address / contract of the loan has the borrow amount + fee at the end of the transaction (same block) otherwise the transaction will fail and revert.

  • @seanvera5562
    @seanvera5562 3 ปีที่แล้ว

    how do you run a full test with flashloan v2?

  • @andikahanif672
    @andikahanif672 3 ปีที่แล้ว

    i impresssed boys u need a make a group TG

  • @kathib2571
    @kathib2571 3 ปีที่แล้ว

    where can i get your code?

  • @skatekarim
    @skatekarim 4 ปีที่แล้ว

    so just to make things clear, is it possible to win crypto with out having none?
    Because when you said at 1:44 "with use leverage" you completely confused me man.
    I know its possible, but you not doing that or you doing that?
    pd: Im just starting with code, thanks btw.

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว +1

      you don't "win" crypto, you can borrow crypto without having any, but you have to give it back in the same transaction.

  • @pete275
    @pete275 4 ปีที่แล้ว

    so does this leave the contract installed in the blockchain? is there a way to make it clean up after itself, since you won't be using it again?

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว

      you can use the selfdestruct EVM opcode, but I dont see the point.

    • @pete275
      @pete275 4 ปีที่แล้ว

      @@EatTheBlocks if it's a single use contract, why not ? You'd be leaving it on the blockchain forever and nobody will use it, plus isn't it a lot cheaper ? A transaction that writes new data to the blockchain costs a lot more lot more gas than one that only modifies some values, and transactions that delete data actually get rewarded, it's just good practise

    • @juggernautz
      @juggernautz 3 ปีที่แล้ว

      @@pete275 Its wise to leave the contract so the algorithms and developers can audit the work in case of errors or fraud. One issue with leaving the contract is if too many people borrow at the same time using all available funds creating an illiquid chain event. I assume Aave would cancel borrowing at $10 Million or whatever amount. Those seeking to exploit the system to crash it or steal funds might exploit an exchange and try to hack. Exploit to distract while stealing etc.....

  • @instadz825
    @instadz825 2 ปีที่แล้ว

    Hi. I have a question about this topic. So I learned coding with js solidity and python. And when I heard about these I wanted to try it but since am a student my budget is limited and I still don't know about gas fee. I joined a group on telegram and someone asked: how do you guys spot arbitrage opportunities? And I said that I do it by watching the markets. The most expert member of the group mocked me and said that if I don't get a bot I'll end up loosing my money for the gas fee. I wanted to ask: is it that bad to spot opportunities of 8% profit manually? Am really confused I know the market changes and slippage occurs but this 8% opportunity lasted for more than a day.

    • @jaspernelligan
      @jaspernelligan 2 ปีที่แล้ว +4

      Almost all arbitrage opportunities are carried out by bots

    • @mylifemyjourney4118
      @mylifemyjourney4118 2 ปีที่แล้ว

      @@jaspernelligan how to do arbitrage sir .
      Pls teach me..

  • @BlakeEdwards333
    @BlakeEdwards333 3 ปีที่แล้ว

    Great video, thank you!

  • @alexmelka5324
    @alexmelka5324 4 ปีที่แล้ว +1

    hi julian, as far as i understand to use it you have to call start loan then execute operation ? but if i am right this cant be done in one tx ? i must be missing some stuff i am not dev just learning

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว

      Yes you need to call startLoan. This is all done in 1 transaction thats the whole point of flash loans

    • @alexmelka5324
      @alexmelka5324 4 ปีที่แล้ว

      @@EatTheBlocks but you have to call executeOperation at some point ? maybe from startloan ? i am confused

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว +1

      @@alexmelka5324 No, its the Aave smart contract that will call executeOperation() as a callback

    • @alexmelka5324
      @alexmelka5324 4 ปีที่แล้ว +1

      EatTheBlocks aaaaaaaah ok

    • @alexmelka5324
      @alexmelka5324 4 ปีที่แล้ว

      hi julien i am tryin to send you a mail at julien@lendingblock.com for professionel reasons but aint working

  • @1991niersteen
    @1991niersteen 4 ปีที่แล้ว +1

    I didn't even get passed the first line of code in this video :(
    When I try to import the LendingPoolAddressesProvider contract it throws "Unable to import "openzeppelin-solidity/contracts/ownership/Ownable.sol": File not found"
    Any help with this is much appreciated

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว

      Check out the Github of Openzeppelin they updated to 3.0 some contracts were moved or removed

    • @cryptaccmora1194
      @cryptaccmora1194 4 ปีที่แล้ว +1

      @@EatTheBlocks I don't understand your answer. I have the same issue than @Lennard Mulder. So I tried to manually replace all OpenZeppelin Github links in all imported contracts (from your 3 "import" line on the code start) but they are automatically replaced as soon as main code/contract is auto-compiled...
      Then I have always the bug message quoted by @Lennard Mulder, I tried lot of things for fix it but without success :/

    • @raf6182
      @raf6182 4 ปีที่แล้ว +1

      @@cryptaccmora1194 did you ever figure out the Unable to import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol": File not found error? - same issue

    • @azazelxax5148
      @azazelxax5148 3 ปีที่แล้ว

      I fixed that, do you wanna know i did that?

  • @a2zblockchain673
    @a2zblockchain673 3 ปีที่แล้ว

    Hi, I am getting the " Invalid input source specified" when I am doing import of LendingPoolAddressProvider. Could you please help me on it. Thanks

    • @EatTheBlocks
      @EatTheBlocks  3 ปีที่แล้ว

      I have no idea :(

    • @mvstrat3335
      @mvstrat3335 3 ปีที่แล้ว

      I have the same "Invalid input source" for the same Import (tested on Remix IDE desktop or Remix IDE Online)

  • @cryptoniteblack7563
    @cryptoniteblack7563 4 ปีที่แล้ว

    Any word on when bZx will get their act together ?

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว

      hahaa I dont know the team of bZx so I cant really comment on them :(

  • @MG-by9zw
    @MG-by9zw 3 ปีที่แล้ว

    Which app are you using to code?

    • @EatTheBlocks
      @EatTheBlocks  3 ปีที่แล้ว +1

      vim, but I recommend VSCode for most people

  • @РусланМиров-ш3т
    @РусланМиров-ш3т 4 ปีที่แล้ว +1

    Thanks!

  • @i.wardani
    @i.wardani 3 ปีที่แล้ว

    Jai l'impression que vous parlez francais , dapres votre accent . Si cest le cas , pouvez voua faire des videos wn francais aussi svp sur les flash loans .merci

  • @NOREALESTATEINVESTORLEFTBEHIND
    @NOREALESTATEINVESTORLEFTBEHIND 4 ปีที่แล้ว

    How would we be able to do a refinance loan? What if we have Dia lend out on Compound and we borrowed ETH, would a refi be better or a swap. Thank you very much

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว +1

      you can refinance by borrowing from flash floan, use this to take a loan at a better interest rate, with the money of the loan reimburse the original loan and when you get the collateral from the loan use that to reimburse the loan (and maybe use uniswap to change that collateral to the flash loan ccy if they are different)

  • @woodwadm2512
    @woodwadm2512 4 ปีที่แล้ว

    great video thanks!

  • @ranjithreddych
    @ranjithreddych ปีที่แล้ว

    how to get code?

  • @lackless6267
    @lackless6267 3 ปีที่แล้ว

    still works?

  • @its_kie
    @its_kie 3 ปีที่แล้ว

    bro can you make a video how to take flash loan

    • @EatTheBlocks
      @EatTheBlocks  3 ปีที่แล้ว +1

      mmm, this video is about that :)

  • @gamersvideoclips8309
    @gamersvideoclips8309 4 ปีที่แล้ว

    explain dydx flashloan searched more but cant find video on dydx

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว

      eattheblocks-pro.teachable.com/

  • @vadimsolidity7228
    @vadimsolidity7228 4 ปีที่แล้ว

    Thank you!

  • @stani5041
    @stani5041 4 ปีที่แล้ว +1

    nice!

  • @sp0ng007
    @sp0ng007 3 ปีที่แล้ว

    can we do arbirtage between pancake and uniswap ?

    • @EatTheBlocks
      @EatTheBlocks  3 ปีที่แล้ว +1

      Yes, but not with flashloans

    • @sp0ng007
      @sp0ng007 3 ปีที่แล้ว

      @@EatTheBlocks how we can do it?

  • @josephmesa9232
    @josephmesa9232 4 ปีที่แล้ว

    do a abritrage trading bot??

  • @allgaming9678
    @allgaming9678 4 ปีที่แล้ว +1

    Thq

  • @samuelestrada5010
    @samuelestrada5010 2 ปีที่แล้ว

    But you lose the gas fee

  • @raf6182
    @raf6182 4 ปีที่แล้ว

    Thanks for the tutorial. When I go to compile, it is throwing Unable to import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol" - How can i fix this? Thank You!!

    • @EatTheBlocks
      @EatTheBlocks  4 ปีที่แล้ว

      you need to install openzeppelin with npm

    • @holotwin7917
      @holotwin7917 3 ปีที่แล้ว

      @@EatTheBlocks How can I install it?

    • @gaildian6
      @gaildian6 3 ปีที่แล้ว

      @@EatTheBlocks what is npm?

  • @سرالحضارات-ي4ق
    @سرالحضارات-ي4ق 2 ปีที่แล้ว

    This flash loan way like gameplay you can't ensure when you getting flash loan and pay gas Fees you will make profits more than gas Fees
    For example maybe you pay 1000$ gas Fees and you lose 10000$
    So here you pay gas 1000$ gas Fees without making any profits
    So this bad way
    We need to flash loan way ensure you can make profits more than gas Fees 10 times
    If you know please tell us thank you .

  • @ravencoin_premium_admin_assets
    @ravencoin_premium_admin_assets 4 ปีที่แล้ว +4

    High-frequency trading lol

    • @drshoexu
      @drshoexu 4 ปีที่แล้ว +1

      not possible due to the block time and fees are kinda crazy right now on ethereum

  • @TheChachona
    @TheChachona 3 ปีที่แล้ว

    Line 11 has an error

  • @mr.blanco6763
    @mr.blanco6763 3 ปีที่แล้ว

    Is there a way to code your own with python or java script?

  • @raditzful
    @raditzful 4 ปีที่แล้ว

    How to run the code ? What IDE ?🤔

  • @presidentsktou645
    @presidentsktou645 3 ปีที่แล้ว +1

    You look like Zuckerberg

  • @dprggrmr
    @dprggrmr 3 ปีที่แล้ว

    the classes are just way too expensive for the average guy :/

  • @only_viralclip
    @only_viralclip 3 ปีที่แล้ว

    Your explanation is too complex. I don't understand anything

  • @alihanipekci319
    @alihanipekci319 4 ปีที่แล้ว +8

    No need for all of this. Pawn My Bitcoin gives out crypto loans anonymously.

    • @_DD_15
      @_DD_15 4 ปีที่แล้ว

      Sure no need to learn solidity. Just random click an interface like a 🐑😂 it's always a good idea to get educated!

  • @ltwrapper
    @ltwrapper 3 ปีที่แล้ว

    you cut your hair

  • @sadekbadredine9767
    @sadekbadredine9767 2 ปีที่แล้ว

    Hello
    I followed the steps exactly and the complier threw this error
    not found openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol
    Do anyone know what would be the cause?