I have here a contract where I can deposit dai into the aave lending pool. I am able to deposit it, but unable to withdraw. Here is the contract:

// dai
ERC20 public TOKEN = ERC20(0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063);

ILendingPoolAddressesProvider provider = ILendingPoolAddressesProvider(0xd05e3E715d945B59290df0ae8eF85c1BdB684744);
ILendingPool pool = ILendingPool(provider.getLendingPool());

// put in 1 dai
function putInMoney() external {
    TOKEN.approve(address(pool), 1);
    pool.deposit(address(TOKEN), 1, msg.sender, 0);

// dai out 1 dai
function takeOut() external {
    pool.withdraw(address(TOKEN), 1, msg.sender);

Here is the error that it gives:

 Warning! Error encountered during contract execution [execution reverted] 


Also, it only deposits 0.000000000000000001 dai instead of 1. I'm not sure why that is.

How can I fix the withdrawal issue and the amount of dai issue?

Thank you so much!

1 Answer 1


when putInMoney() is called, dai is deposited onBehlaf of msg.sender (i.e who calls putInMoney() function ).

while calling takeOut(), you are basically withdrawing the contract's fund to msg.sender (i.e who calls takeOut() function ), but the contract does not have any funds deposited on its behalf and hence it is failing.

It is depositing 0.000000000000000001 because dai has 18 decimals and the default unit is Wei. so to deposit & withdraw 1 dai, you should change it to:

pool.deposit(address(TOKEN), 1 ether, msg.sender, 0);

(note: ether is unit, 1 ether = 10**18 wei) or

pool.deposit(address(TOKEN), 10**18, msg.sender, 0);

and similarly for withdraw


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.