From 577a101cf46bd043395f43b6da4f272de299b6a0 Mon Sep 17 00:00:00 2001 From: "A.L." Date: Mon, 17 Jun 2024 20:53:04 +0200 Subject: [PATCH] refactor: move internal function to correct section --- src/ReservoirPriceOracle.sol | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ReservoirPriceOracle.sol b/src/ReservoirPriceOracle.sol index 5781156..ca2ab7a 100644 --- a/src/ReservoirPriceOracle.sol +++ b/src/ReservoirPriceOracle.sol @@ -180,14 +180,6 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg. } } - function _getTimeWeightedAverageSingle(OracleAverageQuery memory aQuery) private view returns (uint256 rResult) { - ReservoirPair lPair = pairs[aQuery.base][aQuery.quote]; - _validatePair(lPair); - - (,,, uint16 lIndex) = lPair.getReserves(); - rResult = lPair.getTimeWeightedAverage(aQuery.priceType, aQuery.secs, aQuery.ago, lIndex); - } - /// @inheritdoc IReservoirPriceOracle function getLatest(OracleLatestQuery calldata aQuery) external view returns (uint256) { ReservoirPair lPair = pairs[aQuery.base][aQuery.quote]; @@ -231,6 +223,14 @@ contract ReservoirPriceOracle is IPriceOracle, IReservoirPriceOracle, Owned(msg. if (address(aPair) == address(0)) revert OracleErrors.NoDesignatedPair(); } + function _getTimeWeightedAverageSingle(OracleAverageQuery memory aQuery) internal view returns (uint256 rResult) { + ReservoirPair lPair = pairs[aQuery.base][aQuery.quote]; + _validatePair(lPair); + + (,,, uint16 lIndex) = lPair.getReserves(); + rResult = lPair.getTimeWeightedAverage(aQuery.priceType, aQuery.secs, aQuery.ago, lIndex); + } + // TODO: replace this with safe, audited lib function function _calcPercentageDiff(uint256 aOriginal, uint256 aNew) internal pure returns (uint256) { if (aOriginal == 0) return 0;