Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: low
Valid

Precision loss due rounding off when calculating percentages in `swan:: transferRoyalties` can lead to un expected returns

Vulnerability Details

Using x/100 when calculating royality fees and platform fees percentages in swan:: transferRoyalties leads to high precision losses and the expected amounts won't be reached since solidity rounds down.

uint256 buyerFee = (asset.price * asset.royaltyFee) / 100;
uint256 driaFee = (buyerFee * getCurrentMarketParameters().platformFee) / 100;
  • https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/swan/Swan.sol#L260C8-L261C87

Impact

Lower than deserved return amounts

Tools Used

Manual Review

Recommendations

Consider using 10000 for a higher precision and percentages between 0 - 10000. So that precision losses can be highly limited.

Updates

Lead Judging Commences

inallhonesty Lead Judge 9 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Rounding Issue in `Swan.sol::transferRoyalties` function

Support

FAQs

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