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_accountdefget_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 txdefmain():get_weth()
dotenv:.envnetworks:default:developmentrinkeby:weth_token:'0xc778417E063141139Fce010982780140Aa0cD5Ab'#WEthGateway contractverify:Truekovan:weth_token:'0xd0A1E359811322d97991E03f863a0C30C2cF029C'#WEthGateway contractverify:Truemainnet-fork:#development env, fork uses live mainnet addresses weth_token:'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'#WEthGateway contractmainnet:# for productionweth_token:'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'#WEthGateway contractwallets:wallet1:${PRIVATE_KEY}
from brownie import network,accounts,configLOCAL_BLOCKCHAIN_ENV = ["development","ganache-local"]FORKED_LOCAL_ENV = ["mainnet-fork","mainnet-fork-dev"]defget_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 accountreturn accounts[index]ifid: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.yamlreturn 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.