makerdao / univ2-lp-oracle

GNU Affero General Public License v3.0
23 stars 13 forks source link

Address CVF-26, CVF-55, CVF-56, CVF-57 #43

Closed WilfredTA closed 3 years ago

WilfredTA commented 3 years ago

The product of normalizers can be stored. Beforehand, we do: `(normalizer1 reserve1) (normalizer2 * reserve2)

which is equivalent to (normalizer1 * normalizer2) * (reserve1 * reserve2)

Therefore, we can simply store the product of the normalizers since we only ever use their product.

Further, the casts in seek to uint112 can result in overflows when casting the product of a reserve by its normalizer. This fixes that as well.

Finally, there is no need to conditionally normalize the reserves. Either their precision is less than 18 or equivalent to 18. The former case results in normalizer > 1, so we should multiple by the normalizer. The latter case results in normalizer == 1, so we can still multiply by the normalizer.

WilfredTA commented 3 years ago

Evidently, I turned on an auto-formatter without even realizing it...

kmbarry1 commented 3 years ago

Evidently, I turned on an auto-formatter without even realizing it...

Lmk when you've reverted all the unintentional formatting changes, I'll review then.