Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Withdraw ETH sometimes fails with ERROR 5 on Kovan #243

Open
softskillpro opened this issue Nov 3, 2021 · 1 comment
Open

Withdraw ETH sometimes fails with ERROR 5 on Kovan #243

softskillpro opened this issue Nov 3, 2021 · 1 comment

Comments

@softskillpro
Copy link

Regarding depositWTH/withdrawETH of aave, I've faced to an issue.
Withdraw is failed with error 5 (VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE) sometimes on Kovan testnet.
No problem on hardhat(mainnet fork).

While repeating depositETH/withdrawETH, I was able to see withdrawing is failed randomly.

AAVE validates the amount and user balance before withdrawing as follows.

function validateWithdraw() {
require(amount != 0, Errors.VL_INVALID_AMOUNT);
require(amount <= userBalance, Errors.VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE);
}

userBalance is gotten by following code in aave.
uint256 userBalance = IAToken(aToken).balanceOf(msg.sender);
I think msg.sender must be WETH GATEWAY.
So it means aTokens are not sent to WETH GATEWAY or delayed or spent by others, etc?

I confirmed my contract receives aTokens correctly after deposit and it has enough amount of aTokens before withdrawing.
By using following code.

uint256 lpamount = AToken(aWETHToken).balanceOf(address(this));
AaveDataProviderInterface aave = AaveDataProviderInterface(0x3c73A5E5785cAC854D468F727c606C07488a29D6);//kovan
(uint256 ctokenAmount, , , , , , , , ) = aave.getUserReserveData(wethaddr, address(this));

To summarize what I experienced:

  1. it receives aTokens correctly after deposit.
  2. Approved aTokens before withdraw correctly.
  3. Withdraw works fine sometimes, but failed sometimes.
  4. Cannot reproduce it on Hardhat-forked mainnet.
  5. It happens on Kovan test net randomly.

Any ideas why this is happening?

Here is example of transaction which is failed.
https://kovan.etherscan.io/tx/0x4fafd5770b768a38d9185b8304955d580dd8c3bb236e8145b4e354722d64b86b

@vengeance1464
Copy link

hey did you get a solution to this issue as I am facing the same issue on mumbai testnet -polygon network?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants