PatrickAlphaC / aave_brownie_py_freecode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transaction confirmed (SafeERC20: low-level call failed)

Benakich opened this issue · comments

I dont know why this happens.

here is my code
convert ETH to WETH
from brownie import network, config, interface
from webbrowser import get
from scripts.helpful_scripts import get_account
from scripts.get_weth import get_weth
from web3 import Web3

amount = Web3.toWei(0.1, "ether")

def main():
account = get_account()
erc20_address = config["networks"][network.show_active()]["weth_token"]
if network.show_active() in ["mainnet-fork"]:
get_weth()
# ABI
# Address
lending_pool = get_lending_pool()
# Approve sending out ERC20 tokens
approve_tx = approve_erc20(amount, lending_pool.address, erc20_address, account)
# approve_erc20()
print("Depositing...")
tx =lending_pool.deposit(erc20_address, amount, account.address, 0, {"from": account})
tx.wait(1)
print("Deposited!")

def approve_erc20(amount, spender, erc20_address,account):
print("Approving ERC20 token...")
erc20 = interface.IERC20(erc20_address)
tx = erc20.approve(spender, amount, {"from": account})
tx.wait(1)
print("Approved")
return tx

#abi
#address

def get_lending_pool():
#whenever we need to work with a contract, we need
# ABI
# Address
lending_pool_addresses_provider = interface.ILendingPoolAddressesProvider(
config["networks"][network.show_active()]["lending_pool_addresses_provider"]
)
lending_pool_address = lending_pool_addresses_provider.getLendingPool()
lending_pool = interface.ILendingPool(lending_pool_address)
return lending_pool

Here is my terminal
Screenshot (188)

Pls Help

Looks like you are receiving less WETH (0.085 as terminal output state) than the amount you are trying to deposit (0.1).
Is your get_weth function ok?

Oh, yes, thank you very much, corrected it to 0.1 and it worked. Weird though it was 0.085 in the video. Again thank you very much