The calculation of the toDistribute amount in the KittyPool::purrgeBadPawsition function is incorrect, leading to potential errors in distributing the appropriate collateral after purging a user's bad debt.
In the KittyPool::purrgeBadPawsition function, the toDistribute value is intended to represent the amount of collateral that should be distributed from a user's vault based on the redeemPercent. However, the calculation mistakenly uses PRECISION (a value of 1e18) in a way that causes the toDistribute value to be incorrect. Specifically, when the redeemPercent is much smaller than PRECISION, the result of the multiplication and division produces an incorrect, often zero, value.
The problematic code is as follows:
Add the following to KittyFiTest.t.sol test file:
Incorrect Collateral Distribution: The incorrect toDistribute value can lead to insufficient distribution of collateral, potentially leaving users with unresolved debts or misallocated rewards.
Financial Discrepancies: Users may experience financial discrepancies due to incorrect distribution amounts, leading to potential loss of funds or imbalanced contract states.
Manual review
Foundry (Testing Framework)
Correct the Calculation: Modify the calculation to correctly compute the toDistribute value.
Alternatively, ensure that redeemPercent is already a proportion without the need to divide by PRECISION.
Implement Range Validation: Add validation checks to ensure that toDistribute falls within a reasonable range and that the result is non-zero when expected.
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.