Skip to content

Commit

Permalink
refactor: move internal function to correct section
Browse files Browse the repository at this point in the history
  • Loading branch information
xenide committed Jun 17, 2024
1 parent 2c2e1d5 commit 577a101
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ReservoirPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 577a101

Please sign in to comment.