Im building an DEFIAPP (AAVE)V3
- I do have enough eth
- function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external
- Added settings: gas_limit: "100000000000" in brownie_config.yaml
- Have WETH
- All interfaces are compiled
- No error in get_weth.py and helful_scripts.py
- weth_token, pool_addresses_provider are correctly added in the brownie-config
Here is my aave_borrow.py
from scripts.helpful_scripts import get_account
from scripts.get_weth import get_weth
from brownie import interface, config, network
from web3 import Web3
Amount=Web3.toWei(0.1,"ether")
def main ():
account=get_account()
erc20_address = config["networks"][network.show_active()]["weth_token"]
#get_weth()
if network.show_active() in ["mainnet-fork"]:
get_weth()
pool = get_pool()
approve_ERC20(Amount,pool.address,erc20_address,account)
#deposit for v1/2 supply for v3
print("Depositing ")
tx=pool.deposit(erc20_address,Amount,account.address,0,{"from":account})
tx.wait(2)
print("Deposited")
def get_pool():
#ABI
#Address
pool_addresses_provider=interface.IPoolAddressesProvider(
config["networks"][network.show_active()]["pool_addresses_provider"]
)
pool_address=pool_addresses_provider.getPool()
pool_abi=interface.IPool(pool_address)
return pool_abi
def approve_ERC20(amount,spender,erc20_address,account):
print("Approving Token... ")
erc20=interface.IERC20(erc20_address)
tx=erc20.approve(spender,amount,{"from":account})
tx.wait(2)
print("Approvedddd!!")
return tx
Running the code using brownie run scripts/aave_borrow.py --network sepolia
Error that I had AaveBrowniePyProject is the active project.
Running 'scripts\aave_borrow.py::main'...
Approving Token...
tx=pool.deposit(erc20_address,Amount,account.address,0,{"from":account})
File "C:\Users\Salma, line line, in in
return self.transact(*args)
File "C:\Users\Salma, line line, in in
return tx["from"].transfer(
File "C:\Users\Salma, line line, in in
receipt, exc = self._make_transaction(
File "C:\Users\Salma, line line, in in
raise VirtualMachineError(e) from None
File "C:\Users\Salma, line line, in in
raise ValueError(str(exc)) from None
ValueError: Gas estimation failed: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.