The contract uses the stake token amount to convert it into the equivalent share amount during withdrawals. This design makes it nearly impossible for users to fully withdraw their shares, leaving behind dust balances in the account.
For example, let's consider the withdrawal process in PriorityPool::withdraw(). As marked with @>, when a user calls withdraw() to retrieve funds, the actual number of shares is calculated using getSharesByStake(). Due to rounding inaccuracies and changes in the exchange rate between when the user initiates the call and when the transaction is executed, it becomes highly unlikely that shares[_sender] == sharesToTransfer. To ensure the call succeeds, in most cases, the system opts for shares[_sender] > sharesToTransfer, which results in users being unable to completely withdraw their shares, leaving dust amounts in their accounts.
The reliance on converting stake tokens into share for withdrawal purposes makes it nearly impossible for users to fully withdraw their shares. This leaves small amounts, or dust, in user accounts
Manual Review
It is recommended to modify the withdrawal logic to use share as the basis for withdrawals, which would then be converted into the corresponding stake token amount. This would prevent dust from accumulating in user accounts and allow for more precise withdrawals.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.