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

0 stars 0 forks source link

Loss of precision #224

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

0xsanson

Vulnerability details

Impact

In Router.sol, there's a loss of precision that can be corrected by shifting the operations.

Proof of Concept

https://github.com/code-423n4/2021-07-spartan/blob/main/contracts/Router.sol#L274

Tools Used

editor

Recommended Mitigation Steps

Consider rewriting L274-275 with uint numerator = (_fees * reserve) / eraLength / maxTrades;.

verifyfirst commented 3 years ago

Suggested mitigation is valid