Market utilization ratio near 100% will DoS deposits as harvest tries to withdraw and reverts
Summary
StakedEXA::_update() harvests when depositing, withdrawing assets from the provider in the given market. However, due to the utilization ratio check in the market, it may not be possible to withdraw these assets, reverting. This will halt deposits and secure some extra yield for users that potentially make this happen.
Root Cause
In StakedEXA::356 it withdraws without checking if there is enough protocol liquidity in the market such that it is possible to withdraw. If there is too much debt, it will revert and halt deposits.
Internal pre-conditions
None.
External pre-conditions
Market needs to be close to maximum utilization ratio.
Attack Path
Users borrow a lot from the underlying market, making the utilization ratio reach 100%
Users try to deposit but revert due to trying to withdraw assets from the provider in the market that would leave the market with less deposits than borrows.
Impact
Deposits are DoSed leading to extra yield for current depositors and loss of yield for future ones that can't stake.
PoC
Add the following test to StakedEXA.t.sol as proof.
Cap the amount to withdraw to the maximum amount that does not revert, that is, the amount that makes the utilization ratio reach 100% but not over it.
0x73696d616f
Medium
Market utilization ratio near 100% will DoS deposits as harvest tries to withdraw and reverts
Summary
StakedEXA::_update()
harvests when depositing, withdrawing assets from the provider in the given market. However, due to the utilization ratio check in the market, it may not be possible to withdraw these assets, reverting. This will halt deposits and secure some extra yield for users that potentially make this happen.Root Cause
In
StakedEXA::356
it withdraws without checking if there is enough protocol liquidity in the market such that it is possible to withdraw. If there is too much debt, it will revert and halt deposits.Internal pre-conditions
None.
External pre-conditions
Attack Path
Impact
Deposits are DoSed leading to extra yield for current depositors and loss of yield for future ones that can't stake.
PoC
Add the following test to
StakedEXA.t.sol
as proof.Mitigation
Cap the amount to withdraw to the maximum amount that does not revert, that is, the amount that makes the utilization ratio reach 100% but not over it.