Also I need arb detection to call
Good for you! What was the solution in the end for you?
It seems like you are still stuck on this problem, so can you verify the contract, I will have a try by myself.
Initially I sent DAI into contract creation address instead of smart contract address.
And I make sure I have enough ether and token borrow in smart contract. And the whole process is right on money.
You don’t need to put anything in Wei box. Also make sure you have enough ether in smart contract plus the asset you are borrowing.
Make sure to put lendingpooladdressprovider in the box beside deploy.,before you deploy.
You were just testing the loan, right?
If you are just testing the loan process by itself then yeah you need to add some coin to your contract to pay the fee. But if you are doing an arbitrage then my understanding is that the arb itself would pay the fee or revert if not profitable.
Yeah only testing, but I go contrary to your basis whether testnet or mainnet you have have sufficient amount of borrowing asset and ether for it to be successful otherwise it will revert. Also if you are using DEX that are not in support of lending it won’t go. May be @abcoathup can shed more light to it
What’s you rationale that you need to have money in the contract already for an arb to work? Did you read this somewhere? A flash loan costs no money to initiate and you only pay a fee if the whole thing goes through. If there is no money at the end then it all reverts. You are only out the gas you paid.
You are right, you don’t need money to execute flash loan, what am saying is you must have gas fee in your contract for the operation to be successful if there is not gas fee to execute it will revert the whole operation.
Unlike what you said that the arb will pay the fee itself.
Do you know anything about arb detection?
Wait, why would you need the contract to have gas in it? When you initiate the arb typically your metamask would popup and THAT is where you pay the gas… right from your wallet. So why would you need gas in the contract? Am I missing something?
OK, I resolved my earlier bugs, but I have a new question.
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?
Emmm, I think when test, had better one step at a time, so if there is no arb, you just pay the fee, will it pass?
You are not getting my point. The loan part obviously works or it would not get to the error I am showing.
I want to know how my transaction can get through all those functions in one second. How can a contract know what will happen at the end of the execution in one second when these actions typically take much more time?
can i see the full code? also note that to profit is not easy because its competitive, there some flash loan buffet out there that already front run your transaction., you need to implement arb detection bot in your code to detect when market is favorable.
the 0.09% fee to pay back with your flash loan can not be pay by your arb you must have that already in your wallet before execution can be successful.
with this error its showing 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…
when calling your arb function, it means you dont have enough gas.
You are not correct about the arb not paying for the loan. Aave doesn’t care where the money comes from. You should recheck your assumptions on that.
As for the gas, that is not because I have nothing int he contract, it is because when a “require” fails and it reverts it automatically uses up the rest of the gas. That is normal behavior for a revert.
Anyway, does anyone else know the answer t my question about how FAST the transaction goes through my code versus how long it should realistically take?
In a function, you can do whatever you want, you can continuously buy token and sell token as long as executing these actions would not exceed the gas limit.
Not sure you are getting my point. I know you can do a lot in a function. My point is that the SPEED of response 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.
It depends on the gas price, that is it depends on when this transaction will be confirmed.
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.
All your operations in a transaction, maybe this transaction will have got to wait for a long time to be confirmed, such as 10 minutes, but once it has been confirmed, all operations will be executed in a block, just like in a second.
I don’t know if you think you are helping, but these responses of yours aren’t answering my question actually or telling me anything I don’t know.
The point is, how can it tell me it won’t profit if it hasn’t executed the transactions yet? And how can it possibly do all those transactions in 1 second. Do you see how this doesn’t appear to make sense?
I’m very sorry to make you even more confused!