code-423n4 / 2021-07-sherlock-findings

0 stars 0 forks source link

Division using a division result #137

Closed code423n4 closed 3 years ago

code423n4 commented 3 years ago

Handle

shw

Vulnerability details

Impact

At line 185 of Payout, the deduction is calculated by excludeUsd / (curTotalUsdPool / totalSupply) instead of excludeUsd * totalSupply / curTotalUsdPool. However, the former one is consider less precise than the latter, and could cause a divide-by-zero error if curTotalUsdPool < totalSupply.

Proof of Concept

Referenced code: Payout.sol#L185

Recommended Mitigation Steps

Change the calculation to excludeUsd * totalSupply / curTotalUsdPool.

Evert0x commented 3 years ago

24