In the withdraw
function, due to a precision loss the snapshotDebtScaled
cant be made 0. Basically the entire stream cant be withdrawn by the recipient.
Assume the following scenario:
1. totalDebtScaled = 111111111111111111 (18 1's)
2. totalDebt = 111111 (assume token with 6 decimals)
3. If the balance is 30e6, and the amount = 111111 (6 1's), amountScaled = 111111e12
4. Thus the snapshotDebtScaled = 111111111111111111 - 111111e12 = 111111111111 (12 1's).
As can be seen this leftover amount can never be made 0 (provided such a scenario occurs in the first place: which can occur given the rps)(basically this scenarios likelihood relies on the rps provided). Since the debt can never be made 0, the recipient can never completely withdraw his entire amount (Always a small amount will remain, provided a token with <18 decimals is used).
snapshotDebtScaled can never reach 0.
Manual review
Compare using the scaled quantities instead of the descaled ones here.
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.