You will receive aETH which is the interest bearing token, reflective of your deposit and the interest it accrues.
The Aave deposit function will handle all the necessary conversions from ETH. However, we can save on gas by locking our ETH for WETH directly with the WETHGateway contract.
Create get_weth()
Objective: Get WETH by depositing ETH [call deposit function on WEth contract].
To interact with the contract, we need ABI + Address.
For ABI, use interface, IWEth.sol, from https://github.com/PatrickAlphaC/aave_brownie_py_freecode/tree/main/interfaces
create IWeth.sol in interfaces folder -> copy and paste github code into it.
from brownie import config, network, interface
from scripts.helpful_scripts import get_account
def get_weth():
"""
how to get Weth?
deposit eth to WETH contract, it gives us ETH
https://kovan.etherscan.io/token/0xd0a1e359811322d97991e03f863a0c30c2cf029c#writeContract
to interact with this contract we need: address + ABI
ABI: use interface, IWEth.sol, from https://github.com/PatrickAlphaC/aave_brownie_py_freecode/tree/main/interfaces
create IWeth.sol in interfaces folder -> copy and paste github code into it.
"""
account = get_account()
weth = interface.IWeth(config["networks"][network.show_active()]["weth_token"])
#deposit 0.1 ETH, should get back 0.1 WETH
tx = weth.deposit({"from": account, "value": 0.1 * 10**18})
tx.wait(1)
print("...Received 0.1WETH...")
return tx
def main():
get_weth()
from brownie import network,accounts,config
LOCAL_BLOCKCHAIN_ENV = ["development", "ganache-local"]
FORKED_LOCAL_ENV = ["mainnet-fork", "mainnet-fork-dev"]
def get_account(index=None,id=None):
# accounts[0] -- ganache accounts
# accounts.add("env") -- private key from env file -> accounts.add(config["wallets"]["wallet1"])
# accounts.load("id") -- load from brownie accounts list
if index:
# if index was passed return ganache account
return accounts[index]
if id:
return accounts.load(id)
if network.show_active() in LOCAL_BLOCKCHAIN_ENV or network.show_active() in FORKED_LOCAL_ENV:
return accounts[0] #use ganache generated account.
else: #look in config.yaml
return accounts.add(config["wallets"]["wallet1"])
On running get_weth.py successfully, you should see 0.1 WEth in your Metamask wallet.
If you want to convert Weth back to Eth, call the withdraw function. The function will return us the ETH we stored with the contract, on reclaiming the WETH.