Lesson 10: LendingPool.withdraw() function #30
-
| Hello everyone, 
 However the first deposit is still locked inside Aave. To withdraw everything and complete the process, LendingPool documentation have a  The blocking point is, how to withdraw the entire balance (with interest) using python? FYI, I successfully did it inside a Solidity contract by passing the " | 
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 23 replies
-
| from this contract I can see a  In my case, I had to add: function withdraw(uint wad) public;to the interface that @PatrickAlphaC gave us, and then used this code: contract = interface.IWETHGateway(config["networks"][network.show_active()]["weth_token"])
tx = contract.withdraw(contract.balanceOf(account), {
  "from": account,
}) | 
Beta Was this translation helpful? Give feedback.
-
| The  
 I used the WETHGateway, because it easier to withdraw the unwrapped Ether directly (not WETH): def aave_withdrawEth():
    aave_WETHGateway = interface.IWETHGateway(
        config["networks"][network.show_active()]["WETHGateway_address"]
    )
    tx = aave_WETHGateway.withdrawETH(
        lending_pool_address,
        Web3.toHex(2 ** 256 - 1),  # We want to withdraw the max amount on Aave
        account,
        {"from": account},
    )
    tx.wait(1)
    print("You withdrawn Eth from Aave successfully!")you may need to approve the aWETH ERC20 token. | 
Beta Was this translation helpful? Give feedback.
-
| Ok now I'm up to speed with these. Amazing questions all. A few points of confusion. There are 2 kinds of  | 
Beta Was this translation helpful? Give feedback.
-
| Hello, I have just discovered that there is discrepancy between those 2 functions below. Function based on  max_amount = 2 ** 256 - 1
def withdraw_all_collateral(lending_pool, account):
    print("Withdrawing collateral...")
    tx = lending_pool.withdraw(config["networks"][network.show_active()]["weth_token"], max_amount, account, {"from": account})
    tx.wait(1)
    print("Withdrew!")
    return txFunction based on  def withdraw_weth():
    account = get_account()
    weth = interface.IWeth(config["networks"][network.show_active()]["weth_token"])
    print("Withdrawing collateral...")
    tx = weth.withdraw((2 ** 32) - 1, {"from": account})
    tx.wait(1)
    print("Withdrew!")
    return txI'm not really sure why is that... I also still didn't figure out why  | 
Beta Was this translation helpful? Give feedback.



Ok now I'm up to speed with these. Amazing questions all.
A few points of confusion.
There are 2 kinds of
withdrawfunctions in this processThe original question here is asking "How do I withdraw all of my original deposited collateral?"
Which we can do by:
_Note: This brings up a good point, in a bigger project it would be nice to refactor the code so that we had fewer duplicated functions, …