0

I'm trying to deposit into AAVE v2 using hardhat.

My code is the following:

const hre = require('hardhat')

...

const contractAddress = '0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9'
const contract = await hre.ethers.getContractAt(AABI, contractAddress)
contract.deposit()

...

But I get the error:

contract.deposit is not a function hardhat-fork_1 | TypeError: contract.deposit is not a function

If I print the variable 'contract' I can see that something is retrieved by the blockchain but it does not contain the method.
Which is weird because I used the address specified here (LendingPool 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9) and the ABI for the LendingPool address specified here.
I didn't put any file inside the hardhat contracts folder, should I?
My assumption is that since the contract is already on the chain I should be able to get it and use its methods.
Any idea on how I can achieve this?

2 Answers 2

0

As mentioned in the documentation, you should retrieve the LendingPool address from the LendingPoolAddressesProvider smart contract: https://docs.aave.com/developers/v/2.0/the-core-protocol/addresses-provider

Here is an example in Solidity: https://github.com/pooltogether/aave-yield-source/blob/d8843c1dfb7327106d3b83af58fc6e4407fd949f/contracts/yield-source/ATokenYieldSource.sol#L300

It should be fairly similar in JavaScript.

Also, the deposit function requires 4 parameters, so it may be why if fails to call it in your example. https://docs.aave.com/developers/v/2.0/the-core-protocol/lendingpool#deposit

0

The error is that I used the ABI provided in the etherscan page which was the ABI of the proxy and not the LendingPool one. I had to use the ABI provided in the AAVE doc instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.