Skip to content

Commit

Permalink
fix: rm unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
xenide committed Jul 4, 2024
1 parent 2b0f808 commit b34cd83
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 97 deletions.
25 changes: 0 additions & 25 deletions src/ReservoirPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 //
///////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
22 changes: 0 additions & 22 deletions src/interfaces/IReservoirPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
50 changes: 0 additions & 50 deletions test/unit/ReservoirPriceOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b34cd83

Please sign in to comment.