Closed vintrocode closed 3 years ago
Thanks for such a detailed issue @vintrocode! Looking over this briefly I'm not sure why you'd need to call the implementation
function? It looks like you should be able to do all of the external facing tasks - deposit, withdraw, borrow, etc. from the lending pool address that you have: 0xE0fBa4Fc209b4948668006B2bE61711b7f465bAe
. Am I misunderstanding?
The error you're getting back is a Solidity revert
which I suspect is being triggered by the isAdmin check, like you said.
You should check the adresses in https://docs.aave.com/developers/getting-started/deployed-contracts , Kovan tab. Then you can either just copy the LendingPool adress now or at least compare it with your current target.
Do something like:
lp_addr = web3.eth.contract(address= 0xE0fBa4Fc209b4948668006B2bE61711b7f465bAe, abi=lp_abi)
, where you put the ABI of the current implementation, usually by having https://github.com/aave/protocol-v2 compiled aside your project.
The kovan tab has a note that says to make sure you go through the LendingPoolAddressesProvider
to get the latest LendingPool
. That address provider returns 0xE0fBa4Fc209b4948668006B2bE61711b7f465bAe
, which is the address to the proxy contract. @kclowes the Aave devs said exactly what you did -- i should be able to do all those things apparently. But when I create the contract object with the appropriate ABI, these are the functions available to me:
lp_proxy_contract.all_functions()
[<Function admin()>,
<Function implementation()>,
<Function initialize(address,bytes)>,
<Function upgradeTo(address)>,
<Function upgradeToAndCall(address,bytes)>]
@Huge I do not currently have the aave V2 protocol contracts compiled aside my project. Do I need that even though I'm not deploying any contracts myself? Is that a best-practice or something?
I'll be damned. @Huge if I do as you're saying, and just use that proxy address like it's the LP address along with the LP ABI, it works. That's wild to me. I do my due diligence, check the addresses on etherscan, and it leads me astray when in reality I should have been ignorant and everything would have worked! Haha thanks both of you @kclowes and @Huge for your help.
pip freeze
outputI'm trying to access the Aave lending pool contract via web3py. I'm not sure if my issue is because I'm missing something with web3py or there's something with the Aave contracts, but I'll explain what I tried.
First, I connected to the Kovan testnet with no problem
Aave has a lending pool addresses provider contract that you can use to get the actual lending pool's address, so I created that contract object first.
I called the
getLendingPool()
function which returns (what I found out to be) a proxy address:0xE0fBa4Fc209b4948668006B2bE61711b7f465bAe
If you find that address on Kovan Etherscan, you'll see it's called
InitializableImmutableAdminUpgradeabilityProxy
. A few discord discussions later, I found out that's a proxy contract and learned about EIP-1967, which says you can retrieve the address of the logic contract from this proxy or "beacon" contract using animplementation()
method. I was able to verify this method exists with the.all_functions()
command, so I tried calling it and this is what I got:My research on that led me to the source code of the solidity contract, which seems to have an admin lock on almost all of the functions:
I asked the Aave devs what to do but they seemed perplexed that I was even dealing with the proxy contract in the first place, as it seemed no one had familiarity with web3py and this hasn't occurred before in JS. They said my logic should have just worked, but the ultimate solution was to forget the proxy and hard code the address of the lending pool which works, but is ultimately a bandaid solution. Any help or direction is greatly appreciated, thanks in advance.