My goal: AAVE v3, deposit ETH, and borrow DAI
I played around with AAVE in lesson 10 of the Solidity, Blockchain, and Smart Contract Course, and as long as I stick to the course and use the v2 code provided in the lesson and repo it works just fine. So, I am trying to switch to v3 and here I got stuck.
Trying to deposit some ETH
from brownie import config, network, interface
from scripts.helpful_scripts import get_account
def get_weth(amount_in_eth):
account = get_account()
weth_gateway_address = config["networks"][network.show_active()]["WETHGateway"]
pool_implementation = config["networks"][network.show_active()]["Pool-Implementation"]
weth_gateway = interface.IWETHGateway(weth_gateway_address, account)
tx = weth_gateway.depositETH(
pool_implementation,
account,
0,
{"from": account, "value": amount_in_eth * 10**18},
)
return tx
The script is called either using console or run with
(py39brown) AAVE>brownie run .\scripts\get_weth.py --network rinkeby
The interfaces are nicely converted into ABIs, so this should be OK.
This fails with the message:
ValueError: Gas estimation failed: 'execution reverted'.
This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.
Here is the relevant part of my configuration, the addresses coming from here: AAVE docs, testnet addresses I am using Rinkeby.
networks:
default: development
rinkeby:
WETHGateway: '0xD1DECc6502cc690Bc85fAf618Da487d886E54Abe'
Pool-Implementation: '0x87530ED4bd0ee0e79661D65f8Dd37538F693afD5'
PoolAddressesProvider-Aave: '0xBA6378f1c1D046e9EB0F538560BA7558546edF3C'
dotenv: .env
wallets:
from_key: ${PRIVATE_KEY}
My (probably wrong) understanding
The workflow should be like this:
- To get some collateral into the system I can use rinkeby ETH. Since ETH is not an ERC20 token, I have to use a wrapper. This will be provided by the WETHGateway.
- I am using the interface IWETHGateway.sol from the aave v3 repo like so
weth_gateway = interface.IWETHGateway(weth_gateway_address, account)
. I am using the rinkeby WETHGateway address from here and my own account. - Having the WETHGateway contract object now, I (try to) deposit some ETH to the lending pool (right?) and in return will receive some aWETH on my account.
- Now I am supplying aWETH to an asset-specific pool address I am getting from the PoolAddressesProvider.
- the last step, I can now borrow another asset using the supplied aWETH.
Questions
- Is that generally correct or am I missing a step or mixing things up?
- What would be the address of the 'targeted pool' when using the depositETH function for rinkeby?