code-423n4 / 2021-12-defiprotocol-findings

0 stars 0 forks source link

Division with `BASE` twice can be optimized #147

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

0x0x0x

Vulnerability details

In pushUnderlying and pullUnderlying, to compute the tokenAmount it is required to divide by BASE twice. Square of BASE can be saved in a constant to avoid applying this division twice. Simply a new variable called BASE2 (representing square of BASE) can apply the same logic for less gas.