Aave.

Bài viết

Chia sẻ kiến thức của bạn.

Aaveator.
Mar 07, 2023
Hỏi đáp Chuyên Gia

Fail with error 'SafeERC20: low-level call failed when deposit to Aave v2

Hi,I need help, I try to depoist to Aave lending pool v2 contract from my contract,but fail .

Fail info Fail with error 'SafeERC20: low-level call failed

pragma solidity *@.6.12;
import "https://github.com/aave/protocol-v2/blob/ice/mainnet-dep Loyment-03-12-2020/contracts/protocol/lendingpool/Lendir

contract MyDeposit{l
LendingPool public lendingPool;
address public myUSDCaddress;

constructor() public {
lendingPool = LendingPool(0x4bd5643ac6f66a5237E18bfA7d47cF22f1c9F210) 5
myUSDCaddress = @x9FD21bE27A2B0@59a288229361E2fA632D8D2d074;

function deposit(uint256 _amount) public{

lendingPool.deposit(myUSDCaddress, _amount, 0x9041a80B8fB42f1A2858698925A48EDA268b224A, @) ;
  • Aave Protocol
  • Aave v2
0
2
Chia sẻ
Bình luận
.

Câu trả lời

2
Kryptouutiset.
Mar 10 2023, 08:00

Based on the error message you received, it seems like the issue is related to the SafeERC20 library. The error message indicates that a low-level call failed, which may be caused by an issue with the transfer or transferFrom function from the SafeERC20 library.

Here are some possible solutions to this issue:

Make sure that you have approved the LendingPool contract to spend your USDC tokens. You can do this by calling the approve function on the USDC token contract before calling the deposit function on the LendingPool contract.

Check that the address of the USDC token contract and the LendingPool contract are correct.

Ensure that you are passing the correct arguments to the deposit function. The amount parameter should be in the smallest unit of the token (e.g., for USDC, this would be 6 decimal places), and the onBehalfOf parameter should be set to the address that will receive the deposited funds.

Verify that your contract has enough balance of USDC to deposit.

1
Bình luận
.
Aaveator.
Mar 9 2023, 14:00

You can use tenderly.io to debug the failed transaction, but it's most likely that your contract is not approved to spend the user's USDC.

0
Bình luận
.

Bạn có biết câu trả lời không?

Hãy đăng nhập và chia sẻ nó.

Chúng tôi sử dụng cookie để đảm bảo bạn có trải nghiệm tốt nhất trên trang web của chúng tôi.
Thêm thông tin