Users are incentivized to not withdraw immediately after market is closed.
Proof of Concept
Within a withdraw batch, all users within said batch are paid equally - at the same rate, despite what exactly was the rate when each individual one created their withdraw.
While this usually is not a problem as it is a way to reward users who queue the withdrawal and start the expiry cooldown, it creates a problematic situation when the market is closed with an outstanding expiry batch.
The problem is that up until the expiry timestamp comes, all new withdraw requests are added to this old batch where the rate of the previous requests drags the overall withdraw rate down.
Consider the following scenario:
A withdraw batch is created and its expiry time is 1 year.
6 months in, the withdraw batch has half of the markets value in it and the market is closed. The current rate is 1.12 and the batch is currently filled at 1.06
Now users have two choices - to either withdraw their funds now at ~1.06 rate or wait 6 months to be able to withdraw their funds at 1.12 rate.
This creates a very unpleasant situation as the users have an incentive to hold their funds within the contract, despite not providing any value.
Looked from slightly different POV, these early withdraw requesters force everyone else to lock their funds for additional 6 months, for the APY they should've usually received for just holding up until now.
Tools Used
Manual review
Recommended Mitigation Steps
After closing a market and filling the current expiry, delete it from pendingWithdrawalExpiry. Introduce a closedExpiry variable so you later make sure a future expiry is not made at that same timestamp to avoid collision.
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/market/WildcatMarketBase.sol#L665
Vulnerability details
Impact
Users are incentivized to not withdraw immediately after market is closed.
Proof of Concept
Within a withdraw batch, all users within said batch are paid equally - at the same rate, despite what exactly was the rate when each individual one created their withdraw.
While this usually is not a problem as it is a way to reward users who queue the withdrawal and start the expiry cooldown, it creates a problematic situation when the market is closed with an outstanding expiry batch.
The problem is that up until the expiry timestamp comes, all new withdraw requests are added to this old batch where the rate of the previous requests drags the overall withdraw rate down.
Consider the following scenario:
1.12
and the batch is currently filled at1.06
~1.06
rate or wait 6 months to be able to withdraw their funds at1.12
rate.This creates a very unpleasant situation as the users have an incentive to hold their funds within the contract, despite not providing any value.
Looked from slightly different POV, these early withdraw requesters force everyone else to lock their funds for additional 6 months, for the APY they should've usually received for just holding up until now.
Tools Used
Manual review
Recommended Mitigation Steps
After closing a market and filling the current expiry, delete it from
pendingWithdrawalExpiry
. Introduce aclosedExpiry
variable so you later make sure a future expiry is not made at that same timestamp to avoid collision.Assessed type
Context