diff --git a/src/ReservoirPriceOracle.sol b/src/ReservoirPriceOracle.sol index 0ec11da..4fbb091 100644 --- a/src/ReservoirPriceOracle.sol +++ b/src/ReservoirPriceOracle.sol @@ -190,31 +190,6 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg. return lResult; } - /// @inheritdoc IReservoirPriceOracle - function getPastAccumulators(OracleAccumulatorQuery[] memory aQueries) - external - view - returns (int256[] memory rResults) - { - rResults = new int256[](aQueries.length); - - OracleAccumulatorQuery memory lQuery; - for (uint256 i = 0; i < aQueries.length; ++i) { - lQuery = aQueries[i]; - ReservoirPair lPair = pairs[lQuery.base][lQuery.quote]; - _validatePair(lPair); - - (,,, uint16 lIndex) = lPair.getReserves(); - int256 lAcc = lPair.getPastAccumulator(lQuery.priceType, lIndex, lQuery.ago); - rResults[i] = lAcc; - } - } - - /// @inheritdoc IReservoirPriceOracle - function getLargestSafeQueryWindow() external pure returns (uint256) { - return Buffer.SIZE; - } - /////////////////////////////////////////////////////////////////////////////////////////////// // INTERNAL FUNCTIONS // /////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/interfaces/IReservoirPriceOracle.sol b/src/interfaces/IReservoirPriceOracle.sol index 56f4ff3..cd0d47e 100644 --- a/src/interfaces/IReservoirPriceOracle.sol +++ b/src/interfaces/IReservoirPriceOracle.sol @@ -40,26 +40,4 @@ interface IReservoirPriceOracle { * @dev Returns latest sample of `priceType`. Prices are represented as 18 decimal fixed point values. */ function getLatest(OracleLatestQuery calldata priceType) external view returns (uint256); - - // REVIEW: Who calls this? - /** - * @dev Returns largest time window that can be safely queried, where 'safely' means the Oracle is guaranteed to be - * able to produce a result and not revert. - * - * If a query has a non-zero `ago` value, then `secs + ago` (the oldest point in time) must be smaller than this - * value for 'safe' queries. - * - * Since ReservoirPair's oracle writes every second, the largest safe query window is the number of seconds - * same as the size of the buffer. - */ - function getLargestSafeQueryWindow() external view returns (uint256); - - // REVIEW: Who calls this? - /** - * @dev Returns the accumulators corresponding to each of `queries`. - */ - function getPastAccumulators(OracleAccumulatorQuery[] memory queries) - external - view - returns (int256[] memory results); } diff --git a/test/unit/ReservoirPriceOracle.t.sol b/test/unit/ReservoirPriceOracle.t.sol index 9b2dced..6ec1f4d 100644 --- a/test/unit/ReservoirPriceOracle.t.sol +++ b/test/unit/ReservoirPriceOracle.t.sol @@ -808,37 +808,6 @@ contract ReservoirPriceOracleTest is BaseTest { assertEq(lLatestPrice, 98_918_868_099_219_913_512); } - function testGetPastAccumulators() external { - // arrange - skip(1 hours); - _pair.sync(); - skip(1 hours); - _pair.sync(); - skip(1 hours); - _pair.sync(); - _oracle.designatePair(address(_tokenA), address(_tokenB), _pair); - OracleAccumulatorQuery[] memory lQueries = new OracleAccumulatorQuery[](3); - lQueries[0] = OracleAccumulatorQuery(PriceType.RAW_PRICE, address(_tokenA), address(_tokenB), 0); - lQueries[1] = OracleAccumulatorQuery(PriceType.RAW_PRICE, address(_tokenA), address(_tokenB), 1 hours); - lQueries[2] = OracleAccumulatorQuery(PriceType.RAW_PRICE, address(_tokenA), address(_tokenB), 2 hours); - - // act - int256[] memory lResults = _oracle.getPastAccumulators(lQueries); - - // assert - assertEq(lResults.length, lQueries.length); - vm.startPrank(address(_oracle)); - assertEq(lResults[0], _pair.observation(2).logAccRawPrice); - assertEq(lResults[1], _pair.observation(1).logAccRawPrice); - assertEq(lResults[2], _pair.observation(0).logAccRawPrice); - vm.stopPrank(); - } - - function testGetLargestSafeQueryWindow() external view { - // assert - assertEq(_oracle.getLargestSafeQueryWindow(), Buffer.SIZE); - } - function testDesignatePair() external { // act vm.expectEmit(false, false, false, true); @@ -884,25 +853,6 @@ contract ReservoirPriceOracleTest is BaseTest { _oracle.getLatest(OracleLatestQuery(PriceType.RAW_PRICE, address(_tokenB), address(_tokenA))); } - function testGetPastAccumulators_Inverted() external { - // arrange - skip(1 hours); - _pair.sync(); - skip(1 hours); - _pair.sync(); - skip(1 hours); - _pair.sync(); - _oracle.designatePair(address(_tokenA), address(_tokenB), _pair); - OracleAccumulatorQuery[] memory lQueries = new OracleAccumulatorQuery[](3); - lQueries[0] = OracleAccumulatorQuery(PriceType.RAW_PRICE, address(_tokenB), address(_tokenA), 0); - lQueries[1] = OracleAccumulatorQuery(PriceType.RAW_PRICE, address(_tokenB), address(_tokenA), 1 hours); - lQueries[2] = OracleAccumulatorQuery(PriceType.RAW_PRICE, address(_tokenB), address(_tokenA), 2 hours); - - // act & assert - vm.expectRevert(OracleErrors.NoDesignatedPair.selector); - _oracle.getPastAccumulators(lQueries); - } - function testGetTimeWeightedAverage_Inverted() external { // arrange skip(60);