Skip to content

Commit 5a85ac1

Browse files
Merge pull request #8 from rainlanguage/2025-10-29-iau
IAU Price Feed
2 parents 33f006a + ad9f77b commit 5a85ac1

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

src/generated/PythWords.pointers.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pragma solidity ^0.8.25;
1010
// file needs the contract to exist so that it can be compiled.
1111

1212
/// @dev Hash of the known bytecode.
13-
bytes32 constant BYTECODE_HASH = bytes32(0xa9fe1909ca00897783bf99e68750a319e8294464f653fd428a391d9f68862f8e);
13+
bytes32 constant BYTECODE_HASH = bytes32(0x6ad42cc38a63b0ccefc9db597401a93d114999576e1e6c100ca947b3e8c862d9);
1414

1515
/// @dev The hash of the meta that describes the contract.
1616
bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xe7bb5842b2cf1d25681a9885109fbf8943495bcebb9ec049bc3790e5db57fa80);

src/lib/pyth/LibPyth.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ library LibPyth {
114114
// slither-disable-next-line too-many-digits
115115
uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD =
116116
0x924571756974792e55532e53504c472f55534400000000000000000000000000;
117+
/// iShares Gold Trust (IAU)
118+
bytes32 constant PRICE_FEED_ID_EQUITY_US_IAU_USD =
119+
0xf703fbded84f7da4bd9ff4661b5d1ffefa8a9c90b7fa12f247edc8251efac914;
120+
// slither-disable-next-line too-many-digits
121+
uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD =
122+
0x914571756974792e55532e4941552f5553440000000000000000000000000000;
117123

118124
/// TODO replace with O(1) lookup table.
119125
function getPriceFeedContract(uint256 chainId) internal pure returns (IPyth) {
@@ -161,6 +167,8 @@ library LibPyth {
161167
return PRICE_FEED_ID_EQUITY_US_BRK_B_USD;
162168
} else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD) {
163169
return PRICE_FEED_ID_EQUITY_US_SPLG_USD;
170+
} else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD) {
171+
return PRICE_FEED_ID_EQUITY_US_IAU_USD;
164172
} else {
165173
revert UnsupportedFeedSymbol();
166174
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,9 @@ contract LibPythConstantsTest is Test {
7777
LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD,
7878
IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
7979
);
80+
assertEq(
81+
LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_IAU_USD,
82+
IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD"))
83+
);
8084
}
8185
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ contract LibPythGetPriceFeedIdTest is Test {
7474
LibPyth.PRICE_FEED_ID_EQUITY_US_SPLG_USD,
7575
LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
7676
);
77+
assertEq(
78+
LibPyth.PRICE_FEED_ID_EQUITY_US_IAU_USD,
79+
LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.IAU/USD"))
80+
);
7781
}
7882

7983
function testPriceFeedIdUnknownMappings(IntOrAString symbol) external {
@@ -94,6 +98,7 @@ contract LibPythGetPriceFeedIdTest is Test {
9498
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD"))
9599
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.BRK-B/USD"))
96100
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
101+
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD"))
97102
);
98103
vm.expectRevert(UnsupportedFeedSymbol.selector);
99104
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
@@ -180,5 +180,12 @@ contract LibPythGetPriceNoOlderThanTest is Test {
180180
LibDecimalFloat.packLossless(78.71367e5, -5),
181181
LibDecimalFloat.packLossless(0.03281e5, -5)
182182
);
183+
184+
checkPriceNoOlderThan(
185+
LibIntOrAString.fromString2("Equity.US.IAU/USD"),
186+
LibDecimalFloat.packLossless(24 hours, 0),
187+
LibDecimalFloat.packLossless(71.99028e5, -5),
188+
LibDecimalFloat.packLossless(0.07147e5, -5)
189+
);
183190
}
184191
}

0 commit comments

Comments
 (0)