PatrickAlphaC / aave_brownie_py_freecode

13 stars 31 forks source link

Borrow Contract Gas Fail #6

Open oguzpeker opened 2 years ago

oguzpeker commented 2 years ago

When i run the code i am constantly getting this error can you help? This error occurs specifically when the lending_pool.borrow() line. I can deposit WETH to AAVE but I can not borrow due to this error.
Thanks in advance.

ValueError:Gas estimation failed: 'The execution failed due to an exception.'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

PatrickAlphaC commented 2 years ago

Can you please give more information here? What command you ran, what does your code look like, etc.

oguzpeker commented 2 years ago

I am trying all the code exactly the same in the repository. In mainnet-fork everything is fine I can deposit, borrow and repay however in kovan testnet I can only deposit weth, then when i try to borrow some dai, the error above occurs.

"brownie run scripts/aave_borrow.py --network kovan" This is what i try to run.

"Approved Depositing You have deposited 0.20109089403806154 eth You have available 0.160872714378948343 borrowable eth You have borrowed 8.51500889E-10 eth Now Let's BORROW some ERC20 The DAI/ETH price is 0.000266046291239913 borrowable eth is 0.16087271437894834 and dai_eth_price is 0.000266046291239913 I am going to borrow 453.5095573852913 DAI"

These are my comments in the code. 453 DAI is avaliable to borrow, after this, code below is in next in line and after this the gas estimation fail occurs.

"dai_address = config["networks"][network.show_active()]["dai_address"] borrow_tx = lending_pool.borrow( dai_address, Web3.toWei(amount_dai_to_borrow, "ether"), 1, 0, account.address, {"from": account}, )"

FifthRooter commented 2 years ago

Having same exact issue!

DanteYcY commented 2 years ago

Same here. "ValueError: Gas estimation failed: 'The execution failed due to an exception.'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually."

PatrickAlphaC commented 2 years ago

Can you try adding a gas strategy?

https://eth-brownie.readthedocs.io/en/stable/api-network.html#gas-strategies

If that works, please make a PR to improve this repo :)

KomoderHell commented 2 years ago

The same error occurred with me during lending_pool.deposit() it was because my account did not have WETH. try running get_weth() script once and then try this.

TiagoBlauth commented 2 years ago

Solved!!! I had the same issue. This is because I was using the wrong DAI token. When using google I was getting this one: https://kovan.etherscan.io/token/0x4f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa ... but the right one is this: https://kovan.etherscan.io/address/0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD

Just change brownie-config.yaml and be happy networks: default: mainnet-fork kovan: dai_token_old: '0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa' dai_token: '0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD'

Glad to serve.

PatrickAlphaC commented 2 years ago

Awesome! Thanks! Want to make a PR :)

TiagoBlauth commented 2 years ago

Not sure if it is a PR case as your code is correct, as such your training. In the training section, your orientation is to Google search "kovan dai token" and nowadays the first result is "Dai Stablecoin (DAI) Token Tracker", but what we really want is the second result that is "Kovan Dai (DAI) Token Tracker" (at least this is what is showing to me). Take care.

yashr10 commented 2 years ago

Issue still not solved. when depositing I am getting this error. Used the correct dai_token, still getting an error ValueError: Gas estimation failed: 'The execution failed due to an exception.'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually. @PatrickAlphaC @TiagoBlauth

tutnyal commented 2 years ago

@yashr10 I just got to this part and got the same error as you did. I solved it the same way that @TiagoBlauth did. see below:

  1. the code below will check if our network is mainnet-fork, Since the network is kovan, it will skip the get_weth() function
    if network.show_active() in ["mainnet-fork"]:
        get_weth()

    You need to run get_weth() function at least once, so just add it below and make sure its not inside of the if-statement

Also - You are the best! @PatrickAlphaC