Skip to content

Commit 8e0404b

Browse files
committed
iau
1 parent 71ea980 commit 8e0404b

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

src/lib/pyth/LibPyth.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ library LibPyth {
8787
// slither-disable-next-line too-many-digits
8888
uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD =
8989
0x924571756974792e55532e53504c472f55534400000000000000000000000000;
90+
/// iShares Gold Trust (IAU)
91+
bytes32 constant PRICE_FEED_ID_EQUITY_US_IAU_USD =
92+
0xf703fbded84f7da4bd9ff4661b5d1ffefa8a9c90b7fa12f247edc8251efac914;
93+
// slither-disable-next-line too-many-digits
94+
uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD =
95+
0x914571756974792e55532e4941552f5553440000000000000000000000000000;
9096

9197
/// TODO replace with O(1) lookup table.
9298
function getPriceFeedContract(uint256 chainId) internal pure returns (IPyth) {
@@ -124,6 +130,8 @@ library LibPyth {
124130
return PRICE_FEED_ID_EQUITY_US_BRK_B_USD;
125131
} else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD) {
126132
return PRICE_FEED_ID_EQUITY_US_SPLG_USD;
133+
} else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD) {
134+
return PRICE_FEED_ID_EQUITY_US_IAU_USD;
127135
} else {
128136
revert UnsupportedFeedSymbol();
129137
}

test/src/lib/pyth/LibPyth.constants.t.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@ contract LibPythConstantsTest is Test {
5757
LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD,
5858
IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
5959
);
60+
assertEq(
61+
LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD,
62+
IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD"))
63+
);
6064
}
6165
}

test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ contract LibPythGetPriceFeedIdTest is Test {
5757
LibPyth.PRICE_FEED_ID_EQUITY_US_SPLG_USD,
5858
LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
5959
);
60+
assertEq(
61+
LibPyth.PRICE_FEED_ID_EQUITY_US_IAU_USD,
62+
LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.IAU/USD"))
63+
);
6064
}
6165

6266
function testPriceFeedIdUnknownMappings(IntOrAString symbol) external {
@@ -72,6 +76,7 @@ contract LibPythGetPriceFeedIdTest is Test {
7276
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD"))
7377
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.BRK-B/USD"))
7478
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
79+
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD"))
7580
);
7681
vm.expectRevert(UnsupportedFeedSymbol.selector);
7782
this.getPriceFeedIdExternal(symbol);

test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,12 @@ contract LibPythGetPriceNoOlderThanTest is Test {
150150
LibDecimalFloat.packLossless(78.71367e5, -5),
151151
LibDecimalFloat.packLossless(0.03281e5, -5)
152152
);
153+
154+
checkPriceNoOlderThan(
155+
LibIntOrAString.fromString2("Equity.US.IAU/USD"),
156+
LibDecimalFloat.packLossless(24 hours, 0),
157+
LibDecimalFloat.packLossless(71.99028e5, -5),
158+
LibDecimalFloat.packLossless(0.07147e5, -5)
159+
);
153160
}
154161
}

0 commit comments

Comments
 (0)