Lets hack Flash Loans | Flash loan assignment/discussion

Now you have all the knowledge to execute Flash Loans by yourself. There is a lot of opportunity in the market that can result in massive gains but remember that every gain you generate is because you took a risk.

If you’re feeling prompt go to our Github page and perform all three assessments and share your experiences and gains in the forum. The clones and code is set up on a first come first serve basis lets see how stable both Uniswap V1 and Uniswap V2 markets will get :wink:

Github: https://github.com/Robsonsjre/FlashloanUsecases

Uniswap V1: https://kovan-uniswap.netlify.app/swap
Uniswap V2: https://kovan-uniswap2.netlify.app/swap

Also, let‚Äôs discuss all interesting use cases for Flash Loans today Flash Loans are mostly used for arbitrage. But flash loans have other more compelling use cases in DeFi. One example is refinancing loans. Say I have a Maker vault (CDP) with $100 of ETH locked in it, and I drew a loan of 40 DAI from it‚ÄĒso I‚Äôve got a $60 net position minus my debt. Now say I want to refinance into Compound for a better interest rate. Normally I‚Äôd need to go out and repurchase that 40 DAI to close out my CDP, which requires some up-front capital. Instead, I can flash borrow 40 DAI, close out the $100 CDP, deposit $60 of my unlocked ETH into Compound, convert the other $40 of ETH back into DAI through Uniswap, and use that to repay the flash loan. Boom, atomic 0-capital refinancing.

Let me know the results of your assessment and let’s discuss Flash Loan use cases in the forum.


Hi Amadeo!
This is a wonderful course that made me understand ,in more depth, where we are leading to.
I was wandering if i would want to try the Flash Loans in the mainnet , in Uniswap or in other exchanges where could i find the right addresses?
Kindest Regards,

1 Like

hello Amadeo! first of all, i want to thank, for taking your time and provide us with such super good education which could provide people good incomes!.. but now as a trader, i must say that you created the Arbitrage course not in the proper way… and i hope you not get offended for my commentary… i am new at the academy of Ivan… but so far i found everything very confusing… maybe because i am not a programmer and i am not really interested in code and programming… I AM A TRADER… for the last 10 years i was trading all types of instruments… so of course i got interested when i saw Ivan speaking on his videos about arbitrage…

So the thing is that you prepared all this stuff of DEFI 201 and arbitrage, more in a ‚Äúprogrammer way‚ÄĚ and you forgot about traders‚Ķ but in fact‚Ķ if you think about it‚Ķ arbitrage is a pure trading concept and not a programming concept‚Ķ so you should made the course dedicated for traders! because really‚Ķ i have already spent many hours trying to get this working and i just cannot‚Ķ

For couple seconds i ask you to stand on the shoes of a trader who never in his life wrote a line of code and who doesnt understand most of the terms that you are mentioning in the course… and you know? any trader who comes to your courses looking for the arbitrage… when he starts to listen all those terms and when he see the coding thing… he will just run away… same as i wanted just to close the browser and go to my CHARTS to continue doing my work as usually

So please guys… as you said in every of your videos… if we have a request, we could submit it here… then my request and i guess, talking from all traders interested on this… PLEASE, make a little document, slide, video or whatever… specifying each steps, one by one, to do the arbitrage… but make this for TRADERS… not for programmers…

this means that for example… is not necessary that you try to explain all the terms, functions and that because at the end most of traders will not understand it… would be better and easier if you just make a little document like…

Step 1. Get metamask wallet
Step 2. Go to Remix Ethereum
Step 3. copy and paste your wallet address in this place (exact line of code)…
Step 4…

in fact, all the videos that you made, you could resume it in a little document with each step… and then any TRADER could get into this without complications…

I hope you can do this and post it here or in the DEFI 201 files… otherwise i really think that hardly most traders would even be interested on it

so look… finally after many hours of re watching the videos and trying step by step… again and again… i got a flash loan!!! urrra! so now i am trying the most difficult part which is to do the arbitrage…

same as the guy who posted here first… LUCA_DEL_GROSSO… as i understand, what you did in your videos at the courses, is everything done in the pool that you created… but, how can we use this in other exchanges and other places??? how can we use out of the clone that you created?

i have many questions but for now i prefer to wait to see if you could create some special thing for traders, i am sure this will clear most questions so no need to bother you… but for now i just have 1 important question… you wrote here that every gain we generate comes with a risk… but… as per your courses we dont even use real money in all the process… we get the flash loans and then do the arbitrage and generate profit… so… WHERE IS THE RISK???


Hi Amadeo,
amazing followup on Defi 101. Exactly what i was waiting for. So far i have been able to do all the test trades and use the applications mentioned in the course. The more time i spend using them the more my mind was blown away of all the future concepts that this will enable (Have to admit being a big fan of MakerDAO). I am no a developer (yet) but you made the course in a very coherent and easy to follow in my opinion.

I have 3 Questions:
a) What is the reason that your example stated here cannot yet be applied? I saw that the Furucombo does not support any Maker interaction basically. The Vault example would be a perfect for this. Do your think this will follow in the future?
b) Are there no arbitrage bots already that scan the markets for exactly this kind of opportunities? Could that not be applied as a automated service that rewards the liquidity providers (passive investors) with a higher interest of what they would get by just providing liquidity to the pools?
3) How do you look out for arbitrage opportunities? Would be happy to hear your strategic approach.


i really really need help… everything is sooo confusing!!.. i followed step by step as per de videos… letter by letter, symbol by symbol… but anyway i still getting always the message of error of gas… i transferred a lot of DAI to the contract… anyway error and error… please look the code and tell me if i have any mistake…

pragma solidity ^0.5.0;

import ‚Äúhttps://github.com/mrdavey/ez-flashloan/blob/remix/contracts/aave/FlashLoanReceiverBase.sol‚ÄĚ;
import ‚Äúhttps://github.com/mrdavey/ez-flashloan/blob/remix/contracts/aave/ILendingPool.sol‚ÄĚ;
import ‚Äúhttps://github.com/Robsonsjre/FlashloanUsecases/blob/master/contracts/interfaces/IUniswap.sol‚ÄĚ;

// 100 DAI = 100000000000000000000 (Due to 18 decimal number)


  • Arbitrageur is a contract to simulate the usage of flashloans

  • to make profit out of a market inbalacement

  • For this example we deployed 2 Uniswap instances which we‚Äôll

  • call by ExchangeA and ExchangeB

  • The steps happens as following:

    1. Borrow DAI from Aave
    1. Buy BAT with DAI on ExchangeA
    1. Sell BAT for DAI on ExchangeB
    1. Repay Aave loan
    1. Keep the profits
      contract Arbitrageur is FlashLoanReceiverBase(0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5) {
      address public constant DAI_ADDRESS = 0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD;
      address public constant BAT_ADDRESS = 0x2d12186Fbb9f9a8C28B3FfdD4c42920f8539D738;
      address public constant UNISWAP_FACTORY_A = 0xECc6C0542710a0EF07966D7d1B10fA38bbb86523;
      address public constant UNISWAP_FACTORY_B = 0x54Ac34e5cE84C501165674782582ADce2FDdc8F4;

    ILendingPool public lendingPool;
    IUniswapExchange public exchangeA;
    IUniswapExchange public exchangeB;
    IUniswapFactory public uniswapFactoryA;
    IUniswapFactory public uniswapFactoryB;

    constructor () public {
    // Instantiate Uniswap Factory A
    uniswapFactoryA = IUniswapFactory(UNISWAP_FACTORY_A);
    // get Exchange A Address
    address exchangeA_address = uniswapFactoryA.getExchange(DAI_ADDRESS);
    // Instantiate Exchange A
    exchangeA = IUniswapExchange(exchangeA_address);

     //Instantiate Uniswap Factory B
     uniswapFactoryB = IUniswapFactory(UNISWAP_FACTORY_B);
     // get Exchange B Address
     address exchangeB_address = uniswapFactoryB.getExchange(BAT_ADDRESS);
     //Instantiate Exchange B
     exchangeB = IUniswapExchange(exchangeB_address);
     lendingPool = ILendingPool(



    • Start the arbitrage
      function makeArbitrage(uint256 amount) public onlyOwner {
      bytes memory data = ‚Äú‚ÄĚ;

      ERC20 dai = ERC20(DAI_ADDRESS);

      lendingPool.flashLoan(address(this), DAI_ADDRESS, amount, data);

      // Any left amount of DAI is considered profit
      uint256 profit = dai.balanceOf(address(this));

      // Sending back the profits
      require(dai.transfer(msg.sender, profit), ‚ÄúCould not transfer back the profit‚ÄĚ);


    • Called by lending pool to settle the loan operation
      function executeOperation(
      address _reserve,
      uint256 _amount,
      uint256 _fee,
      bytes calldata _params
      // If transactions are not mined until deadline the transaction is reverted
      uint256 deadline = now + 3000;

      ERC20 dai = ERC20(DAI_ADDRESS);
      ERC20 bat = ERC20(BAT_ADDRESS);

      // // Buying BAT at Exchange A
      require(dai.approve(address(exchangeA), _amount), ‚ÄúCould not approve DAI sell‚ÄĚ);

      uint256 tokenBought = exchangeA.tokenToTokenSwapInput(

      require(bat.approve(address(exchangeB), tokenBought), ‚ÄúCould not approve DAI sell‚ÄĚ);

      // Selling ETH at Exchange B
      uint256 daiBought = exchangeB.tokenToTokenSwapInput(

      require(daiBought > _amount, ‚ÄúDid not profit‚ÄĚ);

      // Repay loan
      uint256 totalDebt = _amount.add(_fee);
      transferFundsBackToPoolInternal(_reserve, totalDebt);


i have some questions…

  • in your video you are using the file ‚Äúarbitrageur‚ÄĚ which we can download from github‚Ķ as i understood we can use that file always‚Ķ right? like a template and then just replace the code for what we want to do? for example the terms of the assets as ETH, USDT, BAT‚Ķ right? and of course the wallets‚Ķ so if i want to trade with different tokens then i just replace this info‚Ķ reight?

  • in the video you say in couple words about the Interfaces and you refer to the Defi 101‚Ķ i tried to find this specific part but is very hard and i didnt get what is necessary to do about interfaces for the arbitrage‚Ķ so all what i did is to also put the files of interfaces in the Remix‚Ķ i would thank if you explain what is needed to do

  • in the file arbitrageur, the addresses of the UNISWAP FACTORY are contrary than in the video‚Ķ so how is correct?

  • i checked the Aave documents Kovan and the address for BAT was different‚Ķ so i changed it‚Ķ we should always do this and check for the actual address?

Until now i was not able to do arbitrage… it always say error:

the link is showing the NOT PROFIT… but i dont think this is the problem… right? because how is possible that you in the video did just 1 transaction and it immediately got profit??.. i clicked 1000 times and all got error

1 Like

Thanks for the amazing content.

where do we can find some strategies to use on flashloans?

have anyone being able to make an arbitrage?


1 Like

nope… i tried many many ways and step by step as for the videos… and is just impossible to do what the brazilian guy did… always error


It works for me…, but had to change few things in the Arbitrageur.sol source (copied to an own file in remix):

  • contract Arbitrageur is Addresses {
    contract Arbitrageur is FlashLoanReceiverBase(address(0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5)) {

and set BAT address to correct one (not the MKR address):
address public constant BAT_ADDRESS = 0x2d12186Fbb9f9a8C28B3FfdD4c42920f8539D738;

and use enough GAS…
for 100 dai = 100000000000000000000


hello… i did exactly this set up… you can see i posted the full code here… but it just doesnt work… could you help??

1 Like

I think the code is designed not to work perfectly to encourage us to do more research?


@amadeobrands I‚Äôm very interested in the concept of creating my own financial products, almost more of an index then tokenizing the index with a fixed supply erc 20 token and pooling it on uniswap‚Ķproviding more safe return options for ‚Äėhedge funds‚Äô and as the market cap of the pool increases so does the value of the index tokens I hold‚Ķ is this ethical? also a fun project could be create hyperinflation coin with periodic ‚Äėmass token burns‚Äô written into the script to create more predictable short and long events‚Ķ maybe call it bart coin :joy: ?

I have to express a similar sentiment as some others in the course just quickly‚Ķ I have decent ideas and I understand how all these could potentially be implemented, but the requirement to understand ‚Äėbasic computer programming‚Äô can feel frustrating at times, I think as all of you guys here at Ivan on tech are all computer wizards what seems like an ‚Äėeasy concept to fix‚Äô might have other tearing their hair out for days‚Ķ perhaps those that participate in forums more actively or those that click more links under the video/spend more time re watching videos deserve a bit of a helping hand‚Ķ Proof of commitment‚Ķ I have plenty of ideas from not only this course but many from the academy but whenever I have the time to try and sit down and put any of these into action it all just ends up a bit overwhelming‚Ķ I‚Äôm tired of just being an investor and want to contribute to the space, the space needs more decentralisation to fight the whale situation, but the barrier of entry still seems a bit too high for a lot of people in my opinion‚Ķ I think the banking elite and the blockchain elite share a bit too much in common than they are prepared to admit unfortunately‚Ķ If people are here in a bear market trying to learn instead of some free telegram pump and dump group I think they deserve a bit more than just a little hint.

No offence intended still loving the course and doing my best to soak in what I can…


Would love some help from anyone on the forum here creating an ERC-721 token to use as underlying liquidity for a custom pool on uniswap…

1 Like

you need to edit the gas price for ethereum- once metamask opens up you need to just add a higher gas fee

  • after you hit transact - metamask should open up and where it says gas fee click on edit and crank up the gas fee

Where do yu get the contract addresses from- when I go to

I have complete different contract addresses than you guys have in the video
besides my Token names start with a- for example aDAI, aBAT- is this the same as xyou use.

Please post a documentation of the things you show in the video with links etc…
seriously watching your videos is more confusing than helpfull.

Also let me know why you clone uniswap and if this method you show in your video alos works on mainnet?

And why arent you teachig us a real world example with 2 different decentralized exchanges for example uniswap and mcafeedex or bancor or idex?
Why you use uniswap v1 and uniswap v2?

And the uniswap contract addreses are the opposite of what you show in the video

And when I try to deploy the contract i get following error:

browser/arb1.sol:22:25: DeclarationError: Identifier not found or not unique. contract Arbitrageur is Addresses { ^-------^

browser/arb1.sol:57:51: DeclarationError: Undeclared identifier. function makeArbitrage(uint256 amount) public onlyOwner { ^-------^

Please copy the code you use in your video and paste it somewhere for example pastebin or wherever so we can use it-

Your github code is complete different thn the one you use in the video, how you expect us to learn if you post a code that doesnt even work nor is the same as you talk about in your videos?

These addresses change a lot so you will have to research this by your self also the Main-net Flash loans can be very expansive and I would not recommend doing them if you not at least did 10 test loans on test net.


Thank you for your feedback :slight_smile:
There is also a course focused on trading in the Acedemy this DeFi 201 is also for traders and there is an explanation of how to do arbitrage with an easy drag and drop GUI … The last section shows an basic Flash Loan and how to program it. It shows the basics and it is up to you if you want to dive deeper into the technical or the trading side of it.

If you completed the other courses recommended before doing this course let me know if you still get stuck and where happy to help out.

a) What is the reason that your example stated here cannot yet be applied? I saw that the Furucombo does not support any Maker interaction basically. The Vault example would be a perfect for this. Do your think this will follow in the future?

I do not really understand your question?
Please rephrase and ideally create a Github issue if there is any technical question: https://github.com/Robsonsjre/FlashloanUsecases/issues

b) Are there no arbitrage bots already that scan the markets for exactly this kind of opportunities? Could that not be applied as a automated service that rewards the liquidity providers (passive investors) with a higher interest of what they would get by just providing liquidity to the pools?

This is highly technical and go’s next LvL++ above DeFi 201 I can go deeper into this but it is kinda complex. The market at this point is verry competitive and there is also a lot of risk involved you need to have 1K ETH ++ to get a small seat at the table I also mention this in the course the arbitrage market is highly efficient. I’m thinking about making some strategies public and maybe opening up a DeFi fund where funds can be pooled should I do this?

  1. How do you look out for arbitrage opportunities? Would be happy to hear your strategic approach.

This is a fulltime job and you can better focus on Yield Hacking strategies which involves a bit off arbitrage as I showed with SUSD etc

Great progress do not get frustrated :slight_smile:
It is not as easy as it seems.

Stay calm and go for it.
Do ETH 101/201 first

1 Like

Yes it is all desinged to let you do more reserach but it should work it is not really easy …
But you should be able to do it … I think most people forget there is a FEE involved.



please answer my question, why do i get above errors when trying to deploy your contract?

Please explain why I get these errors:

browser/arb1.sol:22:25: DeclarationError: Identifier not found or not unique. contract Arbitrageur is Addresses { ^-------^

browser/arb1.sol:57:51: DeclarationError: Undeclared identifier. function makeArbitrage(uint256 amount) public onlyOwner { ^-------^

Here is teh code I use