Skip to content

Commit

Permalink
fix: remove redundant decimals checks from pyth price feed
Browse files Browse the repository at this point in the history
  • Loading branch information
Van0k committed Jun 25, 2024
1 parent dbf6701 commit f8cf181
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
4 changes: 0 additions & 4 deletions contracts/oracles/updatable/PythPriceFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ interface IPythPriceFeedExceptions {
/// the payload's internal timestamp
error IncorrectExpectedPublishTimestamp();

/// @notice Thrown when the decimals returned by Pyth are outside sane boundaries
error IncorrectPriceDecimals();

/// @notice Thrown when a retrieved price's publish time is too far ahead in the future
error PriceTimestampTooFarAhead();

Expand Down Expand Up @@ -112,7 +109,6 @@ contract PythPriceFeed is IUpdatablePriceFeed, IPythPriceFeedExceptions {
if (price == 0) revert IncorrectPriceException();

if (priceData.expo != -8) {
if (priceData.expo > 0 || priceData.expo < -255) revert IncorrectPriceDecimals();
int256 pythDecimals = int256(uint256(10) ** uint32(-priceData.expo));
price = price * DECIMALS / pythDecimals;
}
Expand Down
10 changes: 0 additions & 10 deletions contracts/test/unit/updatable/PythPriceFeed.unit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,5 @@ contract PythPriceFeedUnitTest is TestHelper, IPythPriceFeedExceptions {
(, price,,,) = pf.latestRoundData();

assertEq(price, 100 * 10 ** 8, "Incorrect price when pyth decimals are 0");

pyth.setPriceData(bytes32(uint256(1)), 100, 0, 2, block.timestamp);

vm.expectRevert(IncorrectPriceDecimals.selector);
pf.latestRoundData();

pyth.setPriceData(bytes32(uint256(1)), 100, 0, -257, block.timestamp);

vm.expectRevert(IncorrectPriceDecimals.selector);
pf.latestRoundData();
}
}

0 comments on commit f8cf181

Please sign in to comment.