<!-- canonical: https://0xsimao.com/findings/maple-finance-iv-aave-revert-trying-withdraw -->

# Aave and SavingsUsds strategies may revert when trying to withdraw all funds

Medium · Three Sigma · Institutional lending · 26th November, 2024

Finding 3S-Maple-L02 of the Maple Cash Strategies security review.

- Protocol: https://maple.finance/
- Report: /reports/maple-finance-iv
- Source: https://cdn.sanity.io/files/qoqld077/staging/a68d604be9eca467b1f656c2ca775e1cebc2a468.pdf

---

### Description

Withdrawing all the Aave or Usds balance from the strategy may revert when there is yield. It
withdraws first the fee to the treasury, which internally rounds up in Aave and SavingUsds,
then it withdraws the remaining of the funds, but as it rounded up when withdrawing before,
it will revert.
For confirmation, run testFork_aaveStrategy_withdraw_withFeesAndYield(), change
warp to vm.warp(block.timestamp + 1980526); and just before the
withdrawFromStrategy() call, add amountToWithdraw =
aaveToken.balanceOf(address(aaveStrategy)) - fee;.
It will revert with 32, which is the [error](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/libraries/helpers/Errors.sol#L40) for not enough balance.

### Recommendation

Either accept the issue and send a slightly smaller amount to withdraw or cap the
withdrawal to the maximum withdrawal value after the fee has been collected to the
treasury.

### Status

Acknowledged

---

Related findings:

- [Admin new issuance or user calling `Vault::redeemExpiredLv()` after `Psm::redeemWithCt()` will lead to stuck funds when trying to withdraw](https://0xsimao.com/findings/cork-protocol-issuance-redeem-stuck-withdraw): Cork Protocol
- [DoSed StrategyRouter:withdrawFromStrategies() if strategyTokenBalancesUsd[i] is too small in the swapping phase](https://0xsimao.com/findings/clip-finance-i-withdraw-balances-usd-phase): Clip Finance Strategies
- [Batch:withdraw() can be DoSed by frontrunning it with strategyRouter:allocateToStrategies()](https://0xsimao.com/findings/clip-finance-i-withdraw-frontrunning-allocate-strategies): Clip Finance Strategies
- [Strategy withdraw may fail if weights of strategies differ from the real values and might lead to frozen ReservePool](https://0xsimao.com/findings/glacier-withdraw-weights-differ-real): Glacier
