The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: low
Valid

Liquidity providers will lose some of their fees in the function`LiquidationPool.sol`::`distributeFees` due to precision errors

Summary

Liquidity providers will lose some of their fees in the functionLiquidationPool.sol::distributeFees due to precision errors in the fee calculation

Vulnerability Details

}
for (uint256 i = 0; i < pendingStakes.length; i++) {
pendingStakes[i].EUROs += _amount * pendingStakes[i].TST / tstTotal;```
The division by tstTotal before multiplication can lead to rounding errors due to integer division truncation. You might want to consider distributing fees in a way that multiplies before dividing to reduce the loss of precision.
## Impact
Liquidity providers will lose some of their fees due to precision loss or fee truncation.
## Tools Used
Manual Review
## Recommendations
`-positions[_holder].EUROs += _amount * positions[_holder].TST / tstTotal;
pendingStakes[i].EUROs += _amount * pendingStakes[i].TST / tstTotal;`
`+positions[_holder].EUROs += (_amount * positions[_holder].TST) / tstTotal;
pendingStakes[i].EUROs += (_amount * pendingStakes[i].TST) / tstTotal;`
Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

precision

precision-distributeFees

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.