From a4db5e7a9e5a9ffe11890a7a4511e63629dc59a1 Mon Sep 17 00:00:00 2001 From: HAMburglar Date: Tue, 1 Sep 2020 14:49:53 +0900 Subject: [PATCH] oracles are hard https://github.com/yam-finance/yam-protocol/issues/77 --- contracts/lib/UniswapV2OracleLibrary.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/lib/UniswapV2OracleLibrary.sol b/contracts/lib/UniswapV2OracleLibrary.sol index 1509e22..fb86762 100644 --- a/contracts/lib/UniswapV2OracleLibrary.sol +++ b/contracts/lib/UniswapV2OracleLibrary.sol @@ -1,6 +1,6 @@ pragma solidity >=0.5.0; -import './IUniswapV2Pair.sol'; +import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import './FixedPoint.sol'; // library with helper methods for oracles that are concerned with computing average prices @@ -18,9 +18,9 @@ library UniswapV2OracleLibrary { bool isToken0 ) internal view returns (uint priceCumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); - (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = UniswapPair(pair).getReserves(); + (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (isToken0) { - priceCumulative = UniswapPair(pair).price0CumulativeLast(); + priceCumulative = IUniswapV2Pair(pair).price0CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values if (blockTimestampLast != blockTimestamp) { @@ -28,10 +28,10 @@ library UniswapV2OracleLibrary { uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual - priceCumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; + priceCumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } else { - priceCumulative = UniswapPair(pair).price1CumulativeLast(); + priceCumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired