Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/generated/PythWords.pointers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pragma solidity ^0.8.25;
// file needs the contract to exist so that it can be compiled.

/// @dev Hash of the known bytecode.
bytes32 constant BYTECODE_HASH = bytes32(0xa9fe1909ca00897783bf99e68750a319e8294464f653fd428a391d9f68862f8e);
bytes32 constant BYTECODE_HASH = bytes32(0x6ad42cc38a63b0ccefc9db597401a93d114999576e1e6c100ca947b3e8c862d9);

/// @dev The hash of the meta that describes the contract.
bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xe7bb5842b2cf1d25681a9885109fbf8943495bcebb9ec049bc3790e5db57fa80);
Expand Down
8 changes: 8 additions & 0 deletions src/lib/pyth/LibPyth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ library LibPyth {
// slither-disable-next-line too-many-digits
uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD =
0x924571756974792e55532e53504c472f55534400000000000000000000000000;
/// iShares Gold Trust (IAU)
bytes32 constant PRICE_FEED_ID_EQUITY_US_IAU_USD =
0xf703fbded84f7da4bd9ff4661b5d1ffefa8a9c90b7fa12f247edc8251efac914;
// slither-disable-next-line too-many-digits
uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD =
0x914571756974792e55532e4941552f5553440000000000000000000000000000;

/// TODO replace with O(1) lookup table.
function getPriceFeedContract(uint256 chainId) internal pure returns (IPyth) {
Expand Down Expand Up @@ -161,6 +167,8 @@ library LibPyth {
return PRICE_FEED_ID_EQUITY_US_BRK_B_USD;
} else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD) {
return PRICE_FEED_ID_EQUITY_US_SPLG_USD;
} else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD) {
return PRICE_FEED_ID_EQUITY_US_IAU_USD;
} else {
revert UnsupportedFeedSymbol();
}
Expand Down
4 changes: 4 additions & 0 deletions test/src/lib/pyth/LibPyth.constants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,9 @@ contract LibPythConstantsTest is Test {
LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD,
IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
);
assertEq(
LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD,
IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD"))
);
}
}
5 changes: 5 additions & 0 deletions test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ contract LibPythGetPriceFeedIdTest is Test {
LibPyth.PRICE_FEED_ID_EQUITY_US_SPLG_USD,
LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
);
assertEq(
LibPyth.PRICE_FEED_ID_EQUITY_US_IAU_USD,
LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.IAU/USD"))
);
}

function testPriceFeedIdUnknownMappings(IntOrAString symbol) external {
Expand All @@ -94,6 +98,7 @@ contract LibPythGetPriceFeedIdTest is Test {
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD"))
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.BRK-B/USD"))
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD"))
);
vm.expectRevert(UnsupportedFeedSymbol.selector);
this.getPriceFeedIdExternal(symbol);
Expand Down
7 changes: 7 additions & 0 deletions test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,12 @@ contract LibPythGetPriceNoOlderThanTest is Test {
LibDecimalFloat.packLossless(78.71367e5, -5),
LibDecimalFloat.packLossless(0.03281e5, -5)
);

checkPriceNoOlderThan(
LibIntOrAString.fromString2("Equity.US.IAU/USD"),
LibDecimalFloat.packLossless(24 hours, 0),
LibDecimalFloat.packLossless(71.99028e5, -5),
LibDecimalFloat.packLossless(0.07147e5, -5)
);
}
}