code-423n4 / 2022-04-badger-citadel-findings

0 stars 1 forks source link

Gas Optimizations #193

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

(1)https://github.com/ampleforth/market-oracle/blob/5e7fd1506784f074748ab6bd5df740ca2227b14f/contracts/MedianOracle.sol#L200 (2) https://cs.stackexchange.com/questions/1914/find-median-of-unsorted-array-in-on-time

Search of the median is done in O(n^2) while this can be reduce to O(n), this is a high optimisation as price computation is called for each oracle update.