code-423n4 / 2021-04-vader-findings

1 stars 0 forks source link

Gas Optimization: Utils.sol Make An Unnecessary Multiplication And Division By An Identical Value #199

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

jvaqa

Vulnerability details

Impact

Gas Optimization: Utils.sol Make An Unnecessary Multiplication And Division By An Identical Value

The value "(T1 B1) / T1" is identical to the value "B1", so you can simplify the expression "B1 + (T1 B1) / T1" to "B1 + B1".

Recommended Mitigation Steps

In Utils.sol, replace this:

uint _redemptionValue = B1 + (T1 * B1) / T1;

With this:

uint _redemptionValue = B1 + B1;

0xBrian commented 3 years ago

https://github.com/vetherasset/vaderprotocol-contracts/pull/164/commits/1fb07632dc4f1252d769566a4353607130604283