makerdao / univ2-lp-oracle

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

Fees #12

Open NiklasKunkel opened 3 years ago

NiklasKunkel commented 3 years ago

I still need to write tests for this, so PR is incomplete. I just wanted to get eyes early on the core logic change in seek(). The logic was grabbed from this open PR from the Uniswap repo: https://github.com/Uniswap/uniswap-v2-periphery/pull/49/files#diff-1ca606855db4c3aae71e6ff06e4d93cf326acb5eeaa92f38e7dde3143f80618a

Note that we forego querying the feeTo() parameter from the factory (which saves us an extra storage slot for the factory, an SREAD to get the factory address, and an external call to the factory) to save on gas fees which could add up to thousands of $ a year. This is only a problem during the time interval between Uniswap Governance toggling fees on/off and liquidity being added/removed from the pair. Even when this problem is "active" it leads to at most 0.05% divergence which is insignificant relative to the drift caused by the hop delay.