0

Im building an DEFIAPP (AAVE)V3

  1. I do have enough eth
  2. function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external
  3. Added settings: gas_limit: "100000000000" in brownie_config.yaml
  4. Have WETH
  5. All interfaces are compiled
  6. No error in get_weth.py and helful_scripts.py
  7. 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.
1
  • Please add pool_address.
    – xana
    Jun 12 at 0:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.