Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Precision loss when calculating finalAmount in buyOutEstateNFT

Vulnerability Details

When calculating finalAmount, we are first dividing and then multiplying which leads to precision loss.

Impact

Beneficiares will get a slightly less amount and buyer will need to pay a few less cents.

POC

uint256 value = 55287999;
uint256 divisor = 10;
uint256 multiplier = divisor - 1;
(value / divisor) * multiplier = 49759191
(value * multiplier) / divisor = 49759199

Tools Used

Manual Review

Recommendations

First multiply and then divide

--- uint256 finalAmount = (value / divisor) * multiplier;
+++ uint256 finalAmount = (value * multiplier) / divisor;
Updates

Lead Judging Commences

0xtimefliez Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

truncation of integers

Support

FAQs

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