Open code423n4 opened 3 years ago
Optimization is confirmed (basically constructs x^3/2 then applies root on it). Given that this is a gas optimization, perhaps the severity should be noted down to 1? I'll leave this up to the judges.
Fixed in PR#6.
Labeling this as gas optimization.
Handle
shw
Vulnerability details
Impact
Gas optimization is possible for the current
rootPows
implementation.Proof of Concept
The original implementation of
rootPows
requires 4mul
and 2sqrt
:However, the calculation process can be simplified to be more gas-efficient than the original with only 1
mul
and 2sqrt
requried:Referenced code: FairSideFormula.sol#L67-L75
Recommended Mitigation Steps
To save gas, change the implementation of
rootPows
as mentioned above.