Lets hack Flash Loans | Flash loan assignment/discussion

i did the flash loan. the manual was before.

I have done all the whole process at the end

Great Course Amadeo

I must admit the flashloan hacking was a bit too in depth for me , since I really need to finish Ethereum programming 201 .

Arbitrage is very opportunistic and in my mind not really an opportunity unless you want to program a bot who does this automatically

I see a lot of potential in the lending side of DEI, when will there be a Defi 301 course? :slight_smile:
Looking forward to it

Kindr regards

Thomas

1 Like

Bro can you please give me your email. I want to contact with you and know something about arbitrage.
my email: [email protected]

@amadeobrands

I went ahead and created a flash loan contract that borrows from AAVE, and then swaps at Uniswap and then at Kyber before paying back. It of course checks at the end to see if there is a profit and revert if not.

Now, monitoring the prices on these exchanges I try to run an arb but it always give me the message:

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
execution reverted: Did not profit...

But what doesn’t make any sense to me is that when I go to invoke the initial function to start this whole process it IMMEDIATELY gives me the did not profit message. How is that even possible? A complex transaction of sending some tokens to someone else takes minutes to complete AT LEAST, but somehow my contract is managing to request a flash loan and get the money, then swap on uniswap then swap on kyber and then get that money back all before seeing if I profited and finding that I didn’t and all that happens in ONE SECOND???

What am I missing here?

1 Like

Thank you for trying to do more complex functions.
This is always hard to analyze and next lvl complex.

We programmed in the Did not profit function so that you get the feedback that the transaction was reverted and so the whole transaction is not executed.

Maybe just try a simple function first?
If that works add other steps.

Then let’s go :smiley:
I am also still searching for that amazing Flash Loan arbitrage it is really complex and it seems a lot of people will jump on it if the opportunity presents it self.

1 Like

Thanks for the response but not sure you are getting my point. My point is that the SPEED of response on my contract doesn’t make sense to me.

For example. if I were to send you some Eth right now, how long might that take to arrive in your wallet? At least a few minutes typically?

OK, so in my arb contract I am invoking a function on Aave, which then should send my contract a bunch of eth. That alone could take a few minutes logically to receive those funds.Then I am inviking a function on Uniswap which is swapping the Eth for WETH, then swapping for a token, and then sending that to my contract. Then I am invoking a function on Kyber to swap the token back for eth.

So all that needs to happen before my contract checks if I have profited. How can all that occur in one second? Doesn’t make sense. yet Remix is telling me a didn’t profit IMMEDIATELY after I click the button to invoke the initial flash loan function on Aave.

So there is something I clearly don’t get here. Either there is something seriously wrong in my contract or there is a big misunderstanding I have on how these contracts execute. I was hoping someone could explain this to me.

1 Like

This is a great question thank you.
The TX can see if it makes a profit or not so it kind of never happens this data as available before the transaction is singed so you directly get feedback.

This also shows that ZK Rollups etc are much better solution then how it now functions only isssue is the UX and getting everyone to understand this.

I don’t really know about ZKRollups. I guess I should learn about it.

So somehow the transaction can sort of virtually walk through the transaction and predict it’s outcome ahead of time, before it does it? I guess that would explain it and I wondered if this is possible. Where can I read more about this facet of solidity? I’ve never seen it discussed.

1 Like

Hi man, it is indeed super amazing but jet complex with indeed not that much material of it online just jet. TIME TO GET AN ADVANTAGE!

With solidity, you can basically explore the mempool: https://www.blocknative.com/explorer
Try to understand this concept then you will also understand what I just said more I think.

Basically all data is known since it already happened … so you now broadcast a flash loan and in a mater of milliseconds it is known if the transaction will be profitable or not since time basically did not move jet.

2 Likes

My First Flash Loan

2 Likes

@amadeobrands
I am attempting the “Program a Basics Flash Loan Part 1” and can’t seem to get past getting test ETH. The link https://faucet.kovan.network/ doesn’t seem to work. I get 502 Bad Gateway - Page missing.
Did this site move or is something messed up on my computer?
Thanks.

3 Likes

Hey @Samm, hope you are well.

Some times the faucet does not work correctly, have to try it in another moment.
Also you can try to use another one, like this one: https://faucet.metamask.io/

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

Thanks very much, but also this doesn´t work no more. I get an error: to many request…

other alternatives to https://faucet.kovan.network ?

Ellecrypto

3 Likes

This one could also work, you have to register yourself and ask in the chat to “send” some ethers to your kovan address.
https://gitter.im/kovan-testnet/faucet

Carlos Z.

3 Likes

Amazing :smiley:
Good job.

1 Like

Thanks for the trick :slight_smile:

1 Like

Hi Amadeo, hi Carlos
I tried also https://gitter.im/kovan-testnet/faucet one hour ago, but nothing is happened.
If is possible I need 1 Kovan ETH to diese Adresse: 0x02cf403244eef54e7919b7ee8EC650c30565A8E7

Thanks guys
Lorenzo

1 Like

I’ve sent you 0.5 KETH (kovan ETH), please verify your wallet :nerd_face:

Also here is the tx id: https://kovan.etherscan.io/tx/0x7c3109879d6b56e3feee9b997542556905cb3be5d6413b4af7c583d0c0c2f193

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

Hello, can I please have some KETH to try out the course flash loan? All the other web sites don’t work… Thanks! 0x05B256927b8b4e6D931dA099Ce522eD88E5648f6