-
Hey :) I came across following error when running cmd Here is my config dependencies:
- aave/[email protected]
- smartcontractkit/[email protected]
compiler:
solc:
remappings:
- "@aave=aave/[email protected]"
- "@chainlink=smartcontractkit/[email protected]"
networks:
mainnet-fork:
lending_pool: "0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5"
weth_token: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
dai_eth_price_feed: "0x773616E4d11A78F511299002da57A0a94577F1f4"
kovan:
weth_token: "0xd0a1e359811322d97991e03f863a0c30c2cf029c"
lending_pool: "0x88757f2f99175387aB4C6a4b3067c77A695b0349"
dai_eth_price_feed: "0x22B58f1EbEDfCA50feF632bD73368b2FdA96D541"
dotenv: .env
wallets:
from_key: ${PRIVATE_KEY} and also regular get_account() function def get_account():
if (
network.show_active() in LOCAL_ENVIRONMENTS
or network.show_active() in LOCAL_FORK_ENVIRONMENTS
):
return accounts[0]
else:
return accounts.add(config["wallets"]["from_key"]) Any idea what can be wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hello @asiaziola it seems your get account is returning accounts[0] meaning that it will use the accounts from ganache-cli, but if you are deploying to kovan you would use your account "from_key", make sure kovan is not on LOCAL_ENVIRONMENTS or LOCAL_FORK_ENVIRONMENTS. Additionally please copy and paste your deploy script here so we can check it. |
Beta Was this translation helpful? Give feedback.
-
Thanks @cromewar ! Removing kovan from LOCAL_ENVIRONMENTS worked for me. However, I guess I really do not have luck with this transaction. I run into another problem which was gas limit being too low, it was already surprising for me but I set it manually to the higher one and another error occurred :) I fixed it as suggested (with "allow_revert" being set to true) but execution got reverted Sth is definitely not right :) from brownie import network, config, interface
from scripts.helpful_scripts import get_account, get_contract
from scripts.get_weth import get_weth
from web3 import Web3
amount = Web3.toWei(0.1, "ether")
def main():
account = get_account()
network.gas_limit(670000)
erc20_address = config["networks"][network.show_active()]["weth_token"]
if network.show_active() in ["mainnet-fork"]:
get_weth()
lending_pool = get_lending_pool()
approve_tx = approve_erc20(amount, lending_pool.address, erc20_address, account)
print("Depositing...")
tx = lending_pool.deposit(
erc20_address,
amount,
account.address,
0,
{"allow_revert": True, "from": account},
)
tx.wait(1)
borrowable_eth, total_debt = get_borrowable_data(lending_pool, account)
# dai in terms of ether
dai_eth_price = get_asset_price(get_contract())
def get_asset_price(dai_eth_price_address):
# abi
# addresses
dai_eth_price_feed = interface.AggregatorV3Interface(dai_eth_price_address)
latest_price = dai_eth_price_feed.latestRoundData()[1]
return float(latest_price)
def get_borrowable_data(lending_pool, account):
(
total_collateral_eth,
total_debt_eth,
available_borrow_eth,
current_liquidation_threshold,
ltv,
health_factor,
) = lending_pool.getUserAccountData(account.address)
available_borrow_eth = Web3.fromWei(available_borrow_eth, "ether")
total_collateral_eth = Web3.fromWei(total_collateral_eth, "ether")
total_debt_eth = Web3.fromWei(total_debt_eth, "ether")
print(f"You have {total_collateral_eth} worth of ETH deposited.")
print(f"You have {total_debt_eth} worth of ETH borrowed.")
print(f"You can borrow {available_borrow_eth} worth of ETH.")
return (float(available_borrow_eth), float(total_debt_eth))
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
def get_lending_pool():
lending_pool_addresses_provider = interface.ILendingPoolAddressProvider(
config["networks"][network.show_active()]["lending_pool"]
)
lending_pool_address = lending_pool_addresses_provider.getLendingPool()
lending_pool = interface.ILendingPool(lending_pool_address)
return lending_pool Any suggestions will be more than welcome. |
Beta Was this translation helpful? Give feedback.
Hello @asiaziola it seems your get account is returning accounts[0] meaning that it will use the accounts from ganache-cli, but if you are deploying to kovan you would use your account "from_key", make sure kovan is not on LOCAL_ENVIRONMENTS or LOCAL_FORK_ENVIRONMENTS.
Additionally please copy and paste your deploy script here so we can check it.