From 8b544e41dfe93d571700dc784c678b88c7b1241d Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Tue, 19 May 2026 12:38:48 +0530 Subject: [PATCH 1/3] add tsm, ceg feeds --- src/lib/pyth/LibPyth.sol | 34 ++++++++++++++++++ test/lib/LibFork.sol | 2 ++ test/src/lib/pyth/LibPyth.constants.t.sol | 16 +++++++++ .../src/lib/pyth/LibPyth.getPriceFeedId.t.sol | 20 +++++++++++ .../pyth/LibPyth.getPriceNoOlderThan.t.sol | 36 ++++++++++++++++++- 5 files changed, 107 insertions(+), 1 deletion(-) diff --git a/src/lib/pyth/LibPyth.sol b/src/lib/pyth/LibPyth.sol index 5023779..29346d9 100644 --- a/src/lib/pyth/LibPyth.sol +++ b/src/lib/pyth/LibPyth.sol @@ -305,6 +305,32 @@ library LibPyth { // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_ARKK_USD = uint256(0x924571756974792e55532e41524b4b2f55534400000000000000000000000000); + /// CEG/USD + bytes32 constant PRICE_FEED_ID_EQUITY_US_CEG_USD = + 0xa541bc5c4b69961442e45e9198c7cce151ff9c2a1003f620c6d4a9785c77a4d9; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CEG_USD = + uint256(0x914571756974792e55532e4345472f5553440000000000000000000000000000); + /// TSM/USD + bytes32 constant PRICE_FEED_ID_EQUITY_US_TSM_USD = + 0xe722560a66e4ab00522ef20a38fa2ba5d1b41f1c5404723ed895d202a7af7cc4; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD = + uint256(0x914571756974792e55532e54534d2f5553440000000000000000000000000000); + /// TSM/USD.PRE + bytes32 constant PRICE_FEED_ID_EQUITY_US_TSM_USD_PRE = + 0x6ad383437975189ea6ff0efad3de790d34ff36091a5a24c965e5f047a5de45de; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD_PRE = + uint256(0x954571756974792e55532e54534d2f5553442e50524500000000000000000000); + /// TSM/USD.POST + bytes32 constant PRICE_FEED_ID_EQUITY_US_TSM_USD_POST = + 0x763b87165de66edfce13a7c98c13eb781a44b01ff474b61a6155833b12a65ec3; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD_POST = + uint256(0x964571756974792e55532e54534d2f5553442e504f5354000000000000000000); + + /// TODO replace with O(1) lookup table. function getPriceFeedContract(uint256 chainId) internal pure returns (IPyth) { @@ -422,6 +448,14 @@ library LibPyth { return PRICE_FEED_ID_EQUITY_US_VWO_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_ARKK_USD) { return PRICE_FEED_ID_EQUITY_US_ARKK_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CEG_USD) { + return PRICE_FEED_ID_EQUITY_US_CEG_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD) { + return PRICE_FEED_ID_EQUITY_US_TSM_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD_PRE) { + return PRICE_FEED_ID_EQUITY_US_TSM_USD_PRE; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD_POST) { + return PRICE_FEED_ID_EQUITY_US_TSM_USD_POST; } else { revert UnsupportedFeedSymbol(); } diff --git a/test/lib/LibFork.sol b/test/lib/LibFork.sol index c70c0dd..a6556c3 100644 --- a/test/lib/LibFork.sol +++ b/test/lib/LibFork.sol @@ -15,3 +15,5 @@ uint256 constant FORK_BLOCK_BASE_SGOV = 44912388; uint256 constant FORK_BLOCK_BASE_QQQM = 45610515; uint256 constant FORK_BLOCK_BASE_VWO = 45610515; uint256 constant FORK_BLOCK_BASE_ARKK = 45610515; +uint256 constant FORK_BLOCK_BASE_CEG = 46192140; +uint256 constant FORK_BLOCK_BASE_TSM = 46192140; diff --git a/test/src/lib/pyth/LibPyth.constants.t.sol b/test/src/lib/pyth/LibPyth.constants.t.sol index 81fe90d..9e47b99 100644 --- a/test/src/lib/pyth/LibPyth.constants.t.sol +++ b/test/src/lib/pyth/LibPyth.constants.t.sol @@ -217,5 +217,21 @@ contract LibPythConstantsTest is Test { LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_ARKK_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.ARKK/USD")) ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CEG_USD, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CEG/USD")) + ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD")) + ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD_PRE, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD_POST, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD.POST")) + ); } } diff --git a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol index 473b489..c29cedc 100644 --- a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol @@ -202,6 +202,22 @@ contract LibPythGetPriceFeedIdTest is Test { LibPyth.PRICE_FEED_ID_EQUITY_US_ARKK_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.ARKK/USD")) ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_CEG_USD, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.CEG/USD")) + ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_TSM_USD, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.TSM/USD")) + ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_TSM_USD_PRE, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.TSM/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_TSM_USD_POST, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.TSM/USD.POST")) + ); } function testPriceFeedIdUnknownMappings(IntOrAString symbol) external { @@ -272,6 +288,10 @@ contract LibPythGetPriceFeedIdTest is Test { && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.QQQM/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.VWO/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.ARKK/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CEG/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD.PRE")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD.POST")) ); vm.expectRevert(UnsupportedFeedSymbol.selector); this.getPriceFeedIdExternal(symbol); diff --git a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol index cafe281..20a096b 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -16,7 +16,9 @@ import { FORK_BLOCK_BASE_SGOV, FORK_BLOCK_BASE_QQQM, FORK_BLOCK_BASE_VWO, - FORK_BLOCK_BASE_ARKK + FORK_BLOCK_BASE_ARKK, + FORK_BLOCK_BASE_CEG, + FORK_BLOCK_BASE_TSM } from "test/lib/LibFork.sol"; import {IntOrAString, LibIntOrAString} from "rain.intorastring/lib/LibIntOrAString.sol"; import {Float, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol"; @@ -437,4 +439,36 @@ contract LibPythGetPriceNoOlderThanTest is Test { LibDecimalFloat.packLossless(0.04361e5, -5) ); } + + function testPriceNoOlderThanBaseCeg() external { + vm.createSelectFork(FORK_RPC_URL_BASE, FORK_BLOCK_BASE_CEG); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.CEG/USD"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(262.06400e5, -5), + LibDecimalFloat.packLossless(0.42330e5, -5) + ); + } + + function testPriceNoOlderThanBaseTsm() external { + vm.createSelectFork(FORK_RPC_URL_BASE, FORK_BLOCK_BASE_TSM); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.TSM/USD"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(396.08005e5, -5), + LibDecimalFloat.packLossless(0.23804e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.TSM/USD.PRE"), + LibDecimalFloat.packLossless(36 hours, 0), + LibDecimalFloat.packLossless(409.37000e5, -5), + LibDecimalFloat.packLossless(2.37000e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.TSM/USD.POST"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(396.45964e5, -5), + LibDecimalFloat.packLossless(0.45688e5, -5) + ); + } } From 4870e8f6d6b9c15a17548cd5d610a06682a1c1f4 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Tue, 19 May 2026 12:40:21 +0530 Subject: [PATCH 2/3] pointers --- src/generated/PythWords.pointers.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generated/PythWords.pointers.sol b/src/generated/PythWords.pointers.sol index baf1459..ed75384 100644 --- a/src/generated/PythWords.pointers.sol +++ b/src/generated/PythWords.pointers.sol @@ -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(0x5d94c45d9a500c4e7faac0ed6cce231d1c5fd68d3a4a2783213dc5ae00c8fe97); +bytes32 constant BYTECODE_HASH = bytes32(0x722de02276682e53411ffcc00f434daadbc3540bc68d3c26d5582e9b7a4874fb); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xe7bb5842b2cf1d25681a9885109fbf8943495bcebb9ec049bc3790e5db57fa80); From b02517b7c2b33e0f4bd7fc08bfb51e7f01a6e21d Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Tue, 19 May 2026 12:40:35 +0530 Subject: [PATCH 3/3] fmt --- src/lib/pyth/LibPyth.sol | 2 -- test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol | 6 ++++-- test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/pyth/LibPyth.sol b/src/lib/pyth/LibPyth.sol index 29346d9..937f513 100644 --- a/src/lib/pyth/LibPyth.sol +++ b/src/lib/pyth/LibPyth.sol @@ -330,8 +330,6 @@ library LibPyth { uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSM_USD_POST = uint256(0x964571756974792e55532e54534d2f5553442e504f5354000000000000000000); - - /// TODO replace with O(1) lookup table. function getPriceFeedContract(uint256 chainId) internal pure returns (IPyth) { if (chainId == CHAIN_ID_ARBITRUM) { diff --git a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol index c29cedc..4fd9e0d 100644 --- a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol @@ -290,8 +290,10 @@ contract LibPythGetPriceFeedIdTest is Test { && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.ARKK/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CEG/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD")) - && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD.PRE")) - && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD.POST")) + && IntOrAString.unwrap(symbol) + != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD.PRE")) + && IntOrAString.unwrap(symbol) + != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSM/USD.POST")) ); vm.expectRevert(UnsupportedFeedSymbol.selector); this.getPriceFeedIdExternal(symbol); diff --git a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol index 20a096b..b93926e 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -445,8 +445,8 @@ contract LibPythGetPriceNoOlderThanTest is Test { checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.CEG/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(262.06400e5, -5), - LibDecimalFloat.packLossless(0.42330e5, -5) + LibDecimalFloat.packLossless(262.064e5, -5), + LibDecimalFloat.packLossless(0.4233e5, -5) ); } @@ -461,8 +461,8 @@ contract LibPythGetPriceNoOlderThanTest is Test { checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.TSM/USD.PRE"), LibDecimalFloat.packLossless(36 hours, 0), - LibDecimalFloat.packLossless(409.37000e5, -5), - LibDecimalFloat.packLossless(2.37000e5, -5) + LibDecimalFloat.packLossless(409.37e5, -5), + LibDecimalFloat.packLossless(2.37e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.TSM/USD.POST"),