From 4dd19149879fec7d9640dd477a455b946ef296bc Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Fri, 12 Dec 2025 12:41:15 +0530 Subject: [PATCH 01/14] pre, post market --- src/lib/pyth/LibPyth.sol | 71 +++++++++++ test/lib/LibFork.sol | 2 +- test/src/lib/pyth/LibPyth.constants.t.sol | 42 ++++++- .../src/lib/pyth/LibPyth.getPriceFeedId.t.sol | 50 ++++++++ .../pyth/LibPyth.getPriceNoOlderThan.t.sol | 117 +++++++++++++----- 5 files changed, 252 insertions(+), 30 deletions(-) diff --git a/src/lib/pyth/LibPyth.sol b/src/lib/pyth/LibPyth.sol index 2eb8345..b979970 100644 --- a/src/lib/pyth/LibPyth.sol +++ b/src/lib/pyth/LibPyth.sol @@ -112,6 +112,16 @@ library LibPyth { // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AMZN_USD = 0x924571756974792e55532e414d5a4e2f55534400000000000000000000000000; + bytes32 constant PRICE_FEED_ID_EQUITY_US_AMZN_USD_PRE = + 0x82c59e36a8e0247e15283748d6cd51f5fa1019d73fbf3ab6d927e17d9e357a7f; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AMZN_USD_PRE = + 0x964571756974792e55532e414d5a4e2f5553442e505245000000000000000000; + bytes32 constant PRICE_FEED_ID_EQUITY_US_AMZN_USD_POST = + 0x62731dfcc8b8542e52753f208248c3e73fab2ec15422d6f65c2decda71ccea0d; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AMZN_USD_POST = + 0x974571756974792e55532e414d5a4e2f5553442e504f53540000000000000000; /// Apple. bytes32 constant PRICE_FEED_ID_EQUITY_US_AAPL_USD = 0x49f6b65cb1de6b10eaf75e7c03ca029c306d0357e91b5311b175084a5ad55688; @@ -130,12 +140,32 @@ library LibPyth { // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSLA_USD = 0x924571756974792e55532e54534c412f55534400000000000000000000000000; + bytes32 constant PRICE_FEED_ID_EQUITY_US_TSLA_USD_PRE = + 0x42676a595d0099c381687124805c8bb22c75424dffcaa55e3dc6549854ebe20a; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSLA_USD_PRE = + 0x964571756974792e55532e54534c412f5553442e505245000000000000000000; + bytes32 constant PRICE_FEED_ID_EQUITY_US_TSLA_USD_POST = + 0x2a797e196973b72447e0ab8e841d9f5706c37dc581fe66a0bd21bcd256cdb9b9; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSLA_USD_POST = + 0x974571756974792e55532e54534c412f5553442e504f53540000000000000000; /// Nvidia. bytes32 constant PRICE_FEED_ID_EQUITY_US_NVDA_USD = 0xb1073854ed24cbc755dc527418f52b7d271f6cc967bbf8d8129112b18860a593; // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_NVDA_USD = 0x924571756974792e55532e4e5644412f55534400000000000000000000000000; + bytes32 constant PRICE_FEED_ID_EQUITY_US_NVDA_USD_PRE = + 0x61c4ca5b9731a79e285a01e24432d57d89f0ecdd4cd7828196ca8992d5eafef6; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_NVDA_USD_PRE = + 0x964571756974792e55532e4e5644412f5553442e505245000000000000000000; + bytes32 constant PRICE_FEED_ID_EQUITY_US_NVDA_USD_POST = + 0x25719379353a508b1531945f3c466759d6efd866f52fbaeb3631decb70ba381f; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_NVDA_USD_POST = + 0x974571756974792e55532e4e5644412f5553442e504f53540000000000000000; /// Meta Platforms (Facebook). bytes32 constant PRICE_FEED_ID_EQUITY_US_META_USD = 0x78a3e3b8e676a8f73c439f5d749737034b139bbbe899ba5775216fba596607fe; @@ -154,6 +184,17 @@ library LibPyth { // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD = 0x924571756974792e55532e4d5354522f55534400000000000000000000000000; + bytes32 constant PRICE_FEED_ID_EQUITY_US_MSTR_USD_PRE = + 0x1a11eb21c271f3127e4c9ec8a0e9b1042dc088ccba7a94a1a7d1aa37599a00f6; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD_PRE = + 0x964571756974792e55532e4d5354522f5553442e505245000000000000000000; + bytes32 constant PRICE_FEED_ID_EQUITY_US_MSTR_USD_POST = + 0xd8b856d7e17c467877d2d947f27b832db0d65b362ddb6f728797d46b0a8b54c0; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD_POST = + 0x974571756974792e55532e4d5354522f5553442e504f53540000000000000000; + /// Berkshire Hathaway Class B (BRK-B) bytes32 constant PRICE_FEED_ID_EQUITY_US_BRK_B_USD = 0xe21c688b7fc65b4606a50f3635f466f6986db129bf16979875d160f9c508e8c7; @@ -178,6 +219,16 @@ library LibPyth { // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD = uint256(0x924571756974792e55532e434f494e2f55534400000000000000000000000000); + bytes32 constant PRICE_FEED_ID_EQUITY_US_COIN_USD_PRE = + 0x8bdee6bc9dc5a61b971e31dcfae96fc0c7eae37b2604aa6002ad22980bd3517c; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD_PRE = + uint256(0x964571756974792e55532e434f494e2f5553442e505245000000000000000000); + bytes32 constant PRICE_FEED_ID_EQUITY_US_COIN_USD_POST = + 0x5c3bd92f2eed33779040caea9f82fac705f5121d26251f8f5e17ec35b9559cd4; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD_POST = + uint256(0x974571756974792e55532e434f494e2f5553442e504f53540000000000000000); /// SIVR/USD bytes32 constant PRICE_FEED_ID_EQUITY_US_SIVR_USD = 0x0a5ee42b0f7287a777926d08bc185a6a60f42f40a9b63d78d85d4a03ee2e3737; @@ -231,24 +282,44 @@ library LibPyth { return PRICE_FEED_ID_CRYPTO_XRP_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD) { return PRICE_FEED_ID_EQUITY_US_COIN_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD_PRE) { + return PRICE_FEED_ID_EQUITY_US_COIN_USD_PRE; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD_POST) { + return PRICE_FEED_ID_EQUITY_US_COIN_USD_POST; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_GOOG_USD) { return PRICE_FEED_ID_EQUITY_US_GOOG_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AMZN_USD) { return PRICE_FEED_ID_EQUITY_US_AMZN_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AMZN_USD_PRE) { + return PRICE_FEED_ID_EQUITY_US_AMZN_USD_PRE; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AMZN_USD_POST) { + return PRICE_FEED_ID_EQUITY_US_AMZN_USD_POST; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AAPL_USD) { return PRICE_FEED_ID_EQUITY_US_AAPL_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSFT_USD) { return PRICE_FEED_ID_EQUITY_US_MSFT_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSLA_USD) { return PRICE_FEED_ID_EQUITY_US_TSLA_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSLA_USD_PRE) { + return PRICE_FEED_ID_EQUITY_US_TSLA_USD_PRE; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSLA_USD_POST) { + return PRICE_FEED_ID_EQUITY_US_TSLA_USD_POST; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_NVDA_USD) { return PRICE_FEED_ID_EQUITY_US_NVDA_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_NVDA_USD_PRE) { + return PRICE_FEED_ID_EQUITY_US_NVDA_USD_PRE; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_NVDA_USD_POST) { + return PRICE_FEED_ID_EQUITY_US_NVDA_USD_POST; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_META_USD) { return PRICE_FEED_ID_EQUITY_US_META_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_GME_USD) { return PRICE_FEED_ID_EQUITY_US_GME_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD) { return PRICE_FEED_ID_EQUITY_US_MSTR_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD_PRE) { + return PRICE_FEED_ID_EQUITY_US_MSTR_USD_PRE; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD_POST) { + return PRICE_FEED_ID_EQUITY_US_MSTR_USD_POST; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_BRK_B_USD) { return PRICE_FEED_ID_EQUITY_US_BRK_B_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SPLG_USD) { diff --git a/test/lib/LibFork.sol b/test/lib/LibFork.sol index 370e714..830a8fe 100644 --- a/test/lib/LibFork.sol +++ b/test/lib/LibFork.sol @@ -6,4 +6,4 @@ string constant FORK_RPC_URL_ARBITRUM = "https://arbitrum.gateway.tenderly.co"; string constant FORK_RPC_URL_BASE = "https://base.gateway.tenderly.co"; uint256 constant FORK_BLOCK_ARBITRUM = 399225617; -uint256 constant FORK_BLOCK_BASE = 38996123; +uint256 constant FORK_BLOCK_BASE = 39366248; diff --git a/test/src/lib/pyth/LibPyth.constants.t.sol b/test/src/lib/pyth/LibPyth.constants.t.sol index 9b40d58..f4ff275 100644 --- a/test/src/lib/pyth/LibPyth.constants.t.sol +++ b/test/src/lib/pyth/LibPyth.constants.t.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {Test} from "forge-std/Test.sol"; +import {Test, console2} from "forge-std/Test.sol"; import {LibIntOrAString, IntOrAString} from "rain.intorastring/lib/LibIntOrAString.sol"; import {LibPyth} from "src/lib/pyth/LibPyth.sol"; @@ -77,6 +77,14 @@ contract LibPythConstantsTest is Test { LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD")) ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD_PRE, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD_POST, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_GOOG_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.GOOG/USD")) @@ -85,6 +93,14 @@ contract LibPythConstantsTest is Test { LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AMZN_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD")) ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AMZN_USD_PRE, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AMZN_USD_POST, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_AAPL_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AAPL/USD")) @@ -97,10 +113,26 @@ contract LibPythConstantsTest is Test { LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSLA_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD")) ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSLA_USD_PRE, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_TSLA_USD_POST, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_NVDA_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD")) ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_NVDA_USD_PRE, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_NVDA_USD_POST, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_META_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.META/USD")) @@ -113,6 +145,14 @@ contract LibPythConstantsTest is Test { LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD")) ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD_PRE, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD_POST, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_BRK_B_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.BRK-B/USD")) diff --git a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol index 52428d7..843b9aa 100644 --- a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol @@ -70,6 +70,14 @@ contract LibPythGetPriceFeedIdTest is Test { LibPyth.PRICE_FEED_ID_EQUITY_US_COIN_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.COIN/USD")) ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_COIN_USD_PRE, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.COIN/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_COIN_USD_POST, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.COIN/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_ID_EQUITY_US_GOOG_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.GOOG/USD")) @@ -78,6 +86,14 @@ contract LibPythGetPriceFeedIdTest is Test { LibPyth.PRICE_FEED_ID_EQUITY_US_AMZN_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.AMZN/USD")) ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_AMZN_USD_PRE, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.AMZN/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_AMZN_USD_POST, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_ID_EQUITY_US_AAPL_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.AAPL/USD")) @@ -90,10 +106,26 @@ contract LibPythGetPriceFeedIdTest is Test { LibPyth.PRICE_FEED_ID_EQUITY_US_TSLA_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.TSLA/USD")) ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_TSLA_USD_PRE, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.TSLA/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_TSLA_USD_POST, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.TSLA/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_ID_EQUITY_US_NVDA_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.NVDA/USD")) ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_NVDA_USD_PRE, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.NVDA/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_NVDA_USD_POST, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.NVDA/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_ID_EQUITY_US_META_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.META/USD")) @@ -106,6 +138,14 @@ contract LibPythGetPriceFeedIdTest is Test { LibPyth.PRICE_FEED_ID_EQUITY_US_MSTR_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.MSTR/USD")) ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_MSTR_USD_PRE, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.MSTR/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_MSTR_USD_POST, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_ID_EQUITY_US_BRK_B_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.BRK-B/USD")) @@ -142,15 +182,25 @@ contract LibPythGetPriceFeedIdTest is Test { && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Crypto.XAUT/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Crypto.XRP/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.PRE")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.GOOG/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.PRE")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AAPL/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSFT/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.PRE")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.PRE")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.META/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.GME/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.PRE")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST")) && 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")) diff --git a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol index b2df84e..674f543 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -177,87 +177,148 @@ contract LibPythGetPriceNoOlderThanTest is Test { checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.GOOG/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(320.88133e5, -5), - LibDecimalFloat.packLossless(0.18307e5, -5) + LibDecimalFloat.packLossless(313.73366e5, -5), + LibDecimalFloat.packLossless(0.19353e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.AMZN/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(232.175e5, -5), - LibDecimalFloat.packLossless(0.1211e5, -5) + LibDecimalFloat.packLossless(230.26800e5, -5), + LibDecimalFloat.packLossless(0.12973e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.AMZN/USD.PRE"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(230.83500e5, -5), + LibDecimalFloat.packLossless(0.09500e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(230.48083e5, -5), + LibDecimalFloat.packLossless(0.23048e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.AAPL/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(285.835e5, -5), - LibDecimalFloat.packLossless(0.15289e5, -5) + LibDecimalFloat.packLossless(278.03001e5, -5), + LibDecimalFloat.packLossless(0.14901e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.MSFT/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(480.64507e5, -5), - LibDecimalFloat.packLossless(0.25532e5, -5) + LibDecimalFloat.packLossless(483.60399e5, -5), + LibDecimalFloat.packLossless(0.28499e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.TSLA/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(439.80344e5, -5), - LibDecimalFloat.packLossless(0.41908e5, -5) + LibDecimalFloat.packLossless(446.87528e5, -5), + LibDecimalFloat.packLossless(0.34964e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.TSLA/USD.PRE"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(448.91742e5, -5), + LibDecimalFloat.packLossless(0.19742e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.TSLA/USD.POST"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(445.93044e5, -5), + LibDecimalFloat.packLossless(0.31883e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.NVDA/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(180.12973e5, -5), - LibDecimalFloat.packLossless(0.11972e5, -5) + LibDecimalFloat.packLossless(180.94301e5, -5), + LibDecimalFloat.packLossless(0.19339e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.NVDA/USD.PRE"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(180.23899e5, -5), + LibDecimalFloat.packLossless(0.12079e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.NVDA/USD.POST"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(179.82749e5, -5), + LibDecimalFloat.packLossless(0.39375e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.META/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(643.79845e5, -5), - LibDecimalFloat.packLossless(0.43843e5, -5) + LibDecimalFloat.packLossless(652.73000e5, -5), + LibDecimalFloat.packLossless(0.44100e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.GME/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(22.97525e5, -5), - LibDecimalFloat.packLossless(0.02761e5, -5) + LibDecimalFloat.packLossless(21.84660e5, -5), + LibDecimalFloat.packLossless(0.01440e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.MSTR/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(182.31004e5, -5), - LibDecimalFloat.packLossless(0.22037e5, -5) + LibDecimalFloat.packLossless(183.25417e5, -5), + LibDecimalFloat.packLossless(0.20417e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.MSTR/USD.PRE"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(179.84019e5, -5), + LibDecimalFloat.packLossless(0.06519e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(181.95100e5, -5), + LibDecimalFloat.packLossless(0.62959e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.BRK-B/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(505.8986e5, -5), - LibDecimalFloat.packLossless(0.34141e5, -5) + LibDecimalFloat.packLossless(495.57678e5, -5), + LibDecimalFloat.packLossless(0.24109e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.SPLG/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(80.29697e5, -5), - LibDecimalFloat.packLossless(0.09321e5, -5) + LibDecimalFloat.packLossless(80.85443e5, -5), + LibDecimalFloat.packLossless(0.19559e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.IAU/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(79.20001e5, -5), - LibDecimalFloat.packLossless(0.04676e5, -5) + LibDecimalFloat.packLossless(80.52521e5, -5), + LibDecimalFloat.packLossless(0.04537e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.COIN/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(273.28007e5, -5), - LibDecimalFloat.packLossless(0.24511e5, -5) + LibDecimalFloat.packLossless(268.98180e5, -5), + LibDecimalFloat.packLossless(0.20161e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.COIN/USD.PRE"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(267.38083e5, -5), + LibDecimalFloat.packLossless(0.31649e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.COIN/USD.POST"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(268.25803e5, -5), + LibDecimalFloat.packLossless(0.53598e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.SIVR/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(55.44866e5, -5), - LibDecimalFloat.packLossless(0.04631e5, -5) + LibDecimalFloat.packLossless(60.48632e5, -5), + LibDecimalFloat.packLossless(0.05473e5, -5) ); } + } From 9153dad67f59ad3e2253e872e51c7f93e901512a Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Fri, 12 Dec 2025 12:44:47 +0530 Subject: [PATCH 02/14] 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 198ba60..136811a 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(0x9ab8c9a8f8a4e84b78bf88cca39d259813ac779e61f7a08d6d1cab511e9512f5); +bytes32 constant BYTECODE_HASH = bytes32(0x5f559a981e7cef1a50a48c59dd0b5a5ac2ffb517d93778550859929b64ad593a); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xe7bb5842b2cf1d25681a9885109fbf8943495bcebb9ec049bc3790e5db57fa80); From bd458a06545e4e554c1842956054555bbe4c112b Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Fri, 12 Dec 2025 12:45:04 +0530 Subject: [PATCH 03/14] fmt --- test/src/concrete/PythFork.t.sol | 26 +++++++++++++++++++ .../src/lib/pyth/LibPyth.getPriceFeedId.t.sol | 15 +++++++---- .../pyth/LibPyth.getPriceNoOlderThan.t.sol | 19 +++++++------- 3 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 test/src/concrete/PythFork.t.sol diff --git a/test/src/concrete/PythFork.t.sol b/test/src/concrete/PythFork.t.sol new file mode 100644 index 0000000..d303ee4 --- /dev/null +++ b/test/src/concrete/PythFork.t.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: LicenseRef-DCL-1.0 +// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd +pragma solidity =0.8.25; + +import {Test, console2} from "forge-std/Test.sol"; +import {IPyth} from "pyth-sdk/IPyth.sol"; + +contract PythForkTest is Test { + IPyth constant PRICE_FEED_CONTRACT_BASE = IPyth(0x8250f4aF4B972684F7b336503E2D6dFeDeB1487a); + + bytes32 constant feed = 0x82c59e36a8e0247e15283748d6cd51f5fa1019d73fbf3ab6d927e17d9e357a7f; + + function testPythFor() external { + vm.createSelectFork("https://base-mainnet.g.alchemy.com/v2/y3BXawVv5uuP_g8BaDlKbKoTBGHo9zD9", 39362994); + console2.log("current block : ", block.number); + + bytes[] memory updateData = new bytes[](1); + updateData[0] = + hex"504e41550100000003b801000000040d00159e6b960c6392d97ae8705a333964b25f2f3b2b2cd841fba8af81aa1c350daf368dd056546714c311c8e4628ab41f11b14c2ef66c01549391ca8878ad23898100039d3c0f5450fe8b546d7d3f26355bfc25df13c17fef945a254a2fee6ced0181770c6b0e0102a3218ee500809e462c7b514ef461d1ec62d9da0f626be55316dcb501040a962e83afe97b8b58a5bbedbde8b2fbdc5e8eb1b8a90b1bfcedfc3b864543d47bceb74ac46847c9f54bc902e200f7a5fd60ac7b74c489f681bb1f65958cb51b000668315fe5f8b512a84504e430940f458a3da333615c9985ea4ec9b0b32303f284104b9ff8235751798a40aa549d1f17f9c511303266449570e0450dd3cad247ab0008acb1a29b4fc10eb5a995db6ad7ddce9220211dc3b5b4eedc0f1938aa49aee73d2cda222a0b2471aeb0658873c71a9ad8591e0c0329ec7dad9c6a07a546879014000a56e408774a54835e9d4b074e7e4be818de49feb191e59ac70bea16de832df7a7307564e7d1062963a4b06f0a86063c5996f868525778beab3a96ead237887a61010b5beea51befaa3941048c8990704fd70f536eb7a4b1e9d4077082cd1e864c8b0b7ef3fd72736ea16487a26d73e4ae741376086648099b5800855d6cfe8aba6e6a010c9488fc063a6f95941bdd6752904867f9e006627cebbe884913ec701c4251b72919638539ad56b185faa297de9d9489585f9a29eff07b20eafb5a52cb654c7e81010dbdc2d481f010dabfc0283410e5426fe89f53fd668c69b6cbdc8698dc1ac3e2317f54d1fbb13abd5ac9bd77faac2fd643787129632d5ce598ef8d7014acad0d62000e1fb96a04565f0747c217748b30e6140ff4a3a0c038e0f511c8fc2fafee543d12361a8e5e821b329bd762330f3ceba0cb5f060969b91ea18d4518cf40ff78c8c8010fec3273ec5215c53922fb7cc3b4911415b92372654b2fa7a753236ba04905a6316d399ea32dc07de0cc2d1f9635e4a11280b2008c8a3e3051aa032d92d20849360110e760acc46e9ecdede1fcb4ea92f3de5aab0a9e5cd948f2b7b06357a22da872fc44154e654019b37e2c07a0611f46e8e743bb5457726ba115e7763aa5e0b9a1110111b0a0a2bc5e683767a445b6b7087f70c55e133629aefac20839ece436671aa6af3dee03d62dbdbcb0d34613b0655eb51fd4d2fe76a0f2bf13261c1a883dd2f81100693b9e8600000000001ae101faedac5851e32b9b23b5f9411a8c2bac4aae3ed4dd7b811dd1a72ea4aa71000000000a77dcee014155575600000000000f8583fb00002710adfe79e76112c350f04eea002302a3af75bf09cc0100550082c59e36a8e0247e15283748d6cd51f5fa1019d73fbf3ab6d927e17d9e357a7f00000000016039ec000000000000251cfffffffb00000000693ad57900000000693ad57900000000015f76830000000000004d460d7493f0f0082bad7458aa5c04943296ddd9366b0937026b4c51a3ba0b5567bed705b8b4b6142934c9ca49017f7876c7434dfa3eda425d7c21bb95a22cc0cc2d5c09379f239a154b2d550dff279eac7b22076439f569364336e5613b58ec013d6faec4c984ef459a6d7d744197bb2ddf66bbb461e645f665eeb19edb0618038ac520200a2d1ffa27bd00cf87a207fbccb791252b6a85a21d5602f4903d6ea116b9ce483dadbdc3831fe8cff3747f939a9d1a6bd3e8f6a3e2084f06355159c6b4c1a73b84f745894deeb5cde5411c7d4ea12b4a13ee68f3924d2a8791e1af4d0570d85f91f9ef3efc5e1673076e99a73e0fc287ccec3d7e2e6a24c9b4c1d873aa4b5dca84f7"; + + uint256 fee = PRICE_FEED_CONTRACT_BASE.getUpdateFee(updateData); + console2.log("fee : ", fee); + PRICE_FEED_CONTRACT_BASE.updatePriceFeeds{value: fee}(updateData); + PRICE_FEED_CONTRACT_BASE.getPriceUnsafe(feed); + } +} diff --git a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol index 843b9aa..363c336 100644 --- a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol @@ -183,24 +183,29 @@ contract LibPythGetPriceFeedIdTest is Test { && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Crypto.XRP/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.PRE")) - && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.POST")) + && IntOrAString.unwrap(symbol) + != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.GOOG/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.PRE")) - && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST")) + && IntOrAString.unwrap(symbol) + != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AAPL/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSFT/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.PRE")) - && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.POST")) + && IntOrAString.unwrap(symbol) + != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.PRE")) - && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.POST")) + && IntOrAString.unwrap(symbol) + != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.META/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.GME/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.PRE")) - && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST")) + && IntOrAString.unwrap(symbol) + != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST")) && 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")) diff --git a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol index 674f543..01ce876 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -183,14 +183,14 @@ contract LibPythGetPriceNoOlderThanTest is Test { checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.AMZN/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(230.26800e5, -5), + LibDecimalFloat.packLossless(230.268e5, -5), LibDecimalFloat.packLossless(0.12973e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.AMZN/USD.PRE"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(230.83500e5, -5), - LibDecimalFloat.packLossless(0.09500e5, -5) + LibDecimalFloat.packLossless(230.835e5, -5), + LibDecimalFloat.packLossless(0.095e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST"), @@ -249,14 +249,14 @@ contract LibPythGetPriceNoOlderThanTest is Test { checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.META/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(652.73000e5, -5), - LibDecimalFloat.packLossless(0.44100e5, -5) + LibDecimalFloat.packLossless(652.73e5, -5), + LibDecimalFloat.packLossless(0.441e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.GME/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(21.84660e5, -5), - LibDecimalFloat.packLossless(0.01440e5, -5) + LibDecimalFloat.packLossless(21.8466e5, -5), + LibDecimalFloat.packLossless(0.0144e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.MSTR/USD"), @@ -273,7 +273,7 @@ contract LibPythGetPriceNoOlderThanTest is Test { checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(181.95100e5, -5), + LibDecimalFloat.packLossless(181.951e5, -5), LibDecimalFloat.packLossless(0.62959e5, -5) ); checkPriceNoOlderThan( @@ -298,7 +298,7 @@ contract LibPythGetPriceNoOlderThanTest is Test { checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.COIN/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(268.98180e5, -5), + LibDecimalFloat.packLossless(268.9818e5, -5), LibDecimalFloat.packLossless(0.20161e5, -5) ); checkPriceNoOlderThan( @@ -320,5 +320,4 @@ contract LibPythGetPriceNoOlderThanTest is Test { LibDecimalFloat.packLossless(0.05473e5, -5) ); } - } From 4794da104edaa2714089be65e2af99f7dc2c1b26 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Fri, 12 Dec 2025 13:24:30 +0530 Subject: [PATCH 04/14] fmt --- src/lib/pyth/LibPyth.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/pyth/LibPyth.sol b/src/lib/pyth/LibPyth.sol index b979970..313d8af 100644 --- a/src/lib/pyth/LibPyth.sol +++ b/src/lib/pyth/LibPyth.sol @@ -194,7 +194,7 @@ library LibPyth { // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_MSTR_USD_POST = 0x974571756974792e55532e4d5354522f5553442e504f53540000000000000000; - + /// Berkshire Hathaway Class B (BRK-B) bytes32 constant PRICE_FEED_ID_EQUITY_US_BRK_B_USD = 0xe21c688b7fc65b4606a50f3635f466f6986db129bf16979875d160f9c508e8c7; From 02013e09b4894668ee1f76c9c6d298b8d85e44e8 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Fri, 12 Dec 2025 14:07:26 +0530 Subject: [PATCH 05/14] remove uint256 cast --- src/lib/pyth/LibPyth.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/pyth/LibPyth.sol b/src/lib/pyth/LibPyth.sol index 313d8af..14be715 100644 --- a/src/lib/pyth/LibPyth.sol +++ b/src/lib/pyth/LibPyth.sol @@ -218,17 +218,17 @@ library LibPyth { 0xfee33f2a978bf32dd6b662b65ba8083c6773b494f8401194ec1870c640860245; // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD = - uint256(0x924571756974792e55532e434f494e2f55534400000000000000000000000000); + 0x924571756974792e55532e434f494e2f55534400000000000000000000000000; bytes32 constant PRICE_FEED_ID_EQUITY_US_COIN_USD_PRE = 0x8bdee6bc9dc5a61b971e31dcfae96fc0c7eae37b2604aa6002ad22980bd3517c; // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD_PRE = - uint256(0x964571756974792e55532e434f494e2f5553442e505245000000000000000000); + 0x964571756974792e55532e434f494e2f5553442e505245000000000000000000; bytes32 constant PRICE_FEED_ID_EQUITY_US_COIN_USD_POST = 0x5c3bd92f2eed33779040caea9f82fac705f5121d26251f8f5e17ec35b9559cd4; // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_COIN_USD_POST = - uint256(0x974571756974792e55532e434f494e2f5553442e504f53540000000000000000); + 0x974571756974792e55532e434f494e2f5553442e504f53540000000000000000; /// SIVR/USD bytes32 constant PRICE_FEED_ID_EQUITY_US_SIVR_USD = 0x0a5ee42b0f7287a777926d08bc185a6a60f42f40a9b63d78d85d4a03ee2e3737; From fd723ae8d7ded6298be7e8c8628d001abae210cf Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Fri, 12 Dec 2025 14:16:16 +0530 Subject: [PATCH 06/14] remove test --- test/src/concrete/PythFork.t.sol | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 test/src/concrete/PythFork.t.sol diff --git a/test/src/concrete/PythFork.t.sol b/test/src/concrete/PythFork.t.sol deleted file mode 100644 index d303ee4..0000000 --- a/test/src/concrete/PythFork.t.sol +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: LicenseRef-DCL-1.0 -// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd -pragma solidity =0.8.25; - -import {Test, console2} from "forge-std/Test.sol"; -import {IPyth} from "pyth-sdk/IPyth.sol"; - -contract PythForkTest is Test { - IPyth constant PRICE_FEED_CONTRACT_BASE = IPyth(0x8250f4aF4B972684F7b336503E2D6dFeDeB1487a); - - bytes32 constant feed = 0x82c59e36a8e0247e15283748d6cd51f5fa1019d73fbf3ab6d927e17d9e357a7f; - - function testPythFor() external { - vm.createSelectFork("https://base-mainnet.g.alchemy.com/v2/y3BXawVv5uuP_g8BaDlKbKoTBGHo9zD9", 39362994); - console2.log("current block : ", block.number); - - bytes[] memory updateData = new bytes[](1); - updateData[0] = - hex"504e41550100000003b801000000040d00159e6b960c6392d97ae8705a333964b25f2f3b2b2cd841fba8af81aa1c350daf368dd056546714c311c8e4628ab41f11b14c2ef66c01549391ca8878ad23898100039d3c0f5450fe8b546d7d3f26355bfc25df13c17fef945a254a2fee6ced0181770c6b0e0102a3218ee500809e462c7b514ef461d1ec62d9da0f626be55316dcb501040a962e83afe97b8b58a5bbedbde8b2fbdc5e8eb1b8a90b1bfcedfc3b864543d47bceb74ac46847c9f54bc902e200f7a5fd60ac7b74c489f681bb1f65958cb51b000668315fe5f8b512a84504e430940f458a3da333615c9985ea4ec9b0b32303f284104b9ff8235751798a40aa549d1f17f9c511303266449570e0450dd3cad247ab0008acb1a29b4fc10eb5a995db6ad7ddce9220211dc3b5b4eedc0f1938aa49aee73d2cda222a0b2471aeb0658873c71a9ad8591e0c0329ec7dad9c6a07a546879014000a56e408774a54835e9d4b074e7e4be818de49feb191e59ac70bea16de832df7a7307564e7d1062963a4b06f0a86063c5996f868525778beab3a96ead237887a61010b5beea51befaa3941048c8990704fd70f536eb7a4b1e9d4077082cd1e864c8b0b7ef3fd72736ea16487a26d73e4ae741376086648099b5800855d6cfe8aba6e6a010c9488fc063a6f95941bdd6752904867f9e006627cebbe884913ec701c4251b72919638539ad56b185faa297de9d9489585f9a29eff07b20eafb5a52cb654c7e81010dbdc2d481f010dabfc0283410e5426fe89f53fd668c69b6cbdc8698dc1ac3e2317f54d1fbb13abd5ac9bd77faac2fd643787129632d5ce598ef8d7014acad0d62000e1fb96a04565f0747c217748b30e6140ff4a3a0c038e0f511c8fc2fafee543d12361a8e5e821b329bd762330f3ceba0cb5f060969b91ea18d4518cf40ff78c8c8010fec3273ec5215c53922fb7cc3b4911415b92372654b2fa7a753236ba04905a6316d399ea32dc07de0cc2d1f9635e4a11280b2008c8a3e3051aa032d92d20849360110e760acc46e9ecdede1fcb4ea92f3de5aab0a9e5cd948f2b7b06357a22da872fc44154e654019b37e2c07a0611f46e8e743bb5457726ba115e7763aa5e0b9a1110111b0a0a2bc5e683767a445b6b7087f70c55e133629aefac20839ece436671aa6af3dee03d62dbdbcb0d34613b0655eb51fd4d2fe76a0f2bf13261c1a883dd2f81100693b9e8600000000001ae101faedac5851e32b9b23b5f9411a8c2bac4aae3ed4dd7b811dd1a72ea4aa71000000000a77dcee014155575600000000000f8583fb00002710adfe79e76112c350f04eea002302a3af75bf09cc0100550082c59e36a8e0247e15283748d6cd51f5fa1019d73fbf3ab6d927e17d9e357a7f00000000016039ec000000000000251cfffffffb00000000693ad57900000000693ad57900000000015f76830000000000004d460d7493f0f0082bad7458aa5c04943296ddd9366b0937026b4c51a3ba0b5567bed705b8b4b6142934c9ca49017f7876c7434dfa3eda425d7c21bb95a22cc0cc2d5c09379f239a154b2d550dff279eac7b22076439f569364336e5613b58ec013d6faec4c984ef459a6d7d744197bb2ddf66bbb461e645f665eeb19edb0618038ac520200a2d1ffa27bd00cf87a207fbccb791252b6a85a21d5602f4903d6ea116b9ce483dadbdc3831fe8cff3747f939a9d1a6bd3e8f6a3e2084f06355159c6b4c1a73b84f745894deeb5cde5411c7d4ea12b4a13ee68f3924d2a8791e1af4d0570d85f91f9ef3efc5e1673076e99a73e0fc287ccec3d7e2e6a24c9b4c1d873aa4b5dca84f7"; - - uint256 fee = PRICE_FEED_CONTRACT_BASE.getUpdateFee(updateData); - console2.log("fee : ", fee); - PRICE_FEED_CONTRACT_BASE.updatePriceFeeds{value: fee}(updateData); - PRICE_FEED_CONTRACT_BASE.getPriceUnsafe(feed); - } -} From a8446e702fe922410bf63f52765b93813119d01c Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Mon, 15 Dec 2025 22:56:34 +0530 Subject: [PATCH 07/14] crcl --- src/lib/pyth/LibPyth.sol | 8 ++++++++ test/src/lib/pyth/LibPyth.constants.t.sol | 4 ++++ test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol | 5 +++++ test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol | 10 ++++++++++ 4 files changed, 27 insertions(+) diff --git a/src/lib/pyth/LibPyth.sol b/src/lib/pyth/LibPyth.sol index 14be715..3507a1f 100644 --- a/src/lib/pyth/LibPyth.sol +++ b/src/lib/pyth/LibPyth.sol @@ -235,6 +235,12 @@ library LibPyth { // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SIVR_USD = uint256(0x924571756974792e55532e534956522f55534400000000000000000000000000); + /// CRCL/USD + bytes32 constant PRICE_FEED_ID_EQUITY_US_CRCL_USD = + 0x92b8527aabe59ea2b12230f7b532769b133ffb118dfbd48ff676f14b273f1365; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD = + uint256(0x924571756974792e55532e4352434c2f55534400000000000000000000000000); /// TODO replace with O(1) lookup table. function getPriceFeedContract(uint256 chainId) internal pure returns (IPyth) { @@ -328,6 +334,8 @@ library LibPyth { return PRICE_FEED_ID_EQUITY_US_IAU_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SIVR_USD) { return PRICE_FEED_ID_EQUITY_US_SIVR_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD) { + return PRICE_FEED_ID_EQUITY_US_CRCL_USD; } else { revert UnsupportedFeedSymbol(); } diff --git a/test/src/lib/pyth/LibPyth.constants.t.sol b/test/src/lib/pyth/LibPyth.constants.t.sol index f4ff275..4cb7dc0 100644 --- a/test/src/lib/pyth/LibPyth.constants.t.sol +++ b/test/src/lib/pyth/LibPyth.constants.t.sol @@ -169,5 +169,9 @@ contract LibPythConstantsTest is Test { LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_SIVR_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SIVR/USD")) ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD")) + ); } } diff --git a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol index 363c336..748d960 100644 --- a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol @@ -162,6 +162,10 @@ contract LibPythGetPriceFeedIdTest is Test { LibPyth.PRICE_FEED_ID_EQUITY_US_SIVR_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.SIVR/USD")) ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_CRCL_USD, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.CRCL/USD")) + ); } function testPriceFeedIdUnknownMappings(IntOrAString symbol) external { @@ -210,6 +214,7 @@ contract LibPythGetPriceFeedIdTest is Test { && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SPLG/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SIVR/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD")) ); 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 01ce876..571e2c9 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -320,4 +320,14 @@ contract LibPythGetPriceNoOlderThanTest is Test { LibDecimalFloat.packLossless(0.05473e5, -5) ); } + + function testPriceNoOlderThanBaseCrcl() external { + vm.createSelectFork(FORK_RPC_URL_BASE, 39514975); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.CRCL/USD"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(76.60999e5, -5), + LibDecimalFloat.packLossless(0.07508e5, -5) + ); + } } From e0ee130cfbadfe2ad34dfef802b58aa2a4c4f818 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Tue, 16 Dec 2025 08:27:37 +0530 Subject: [PATCH 08/14] test --- test/lib/LibFork.sol | 1 + test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/test/lib/LibFork.sol b/test/lib/LibFork.sol index 830a8fe..515a0aa 100644 --- a/test/lib/LibFork.sol +++ b/test/lib/LibFork.sol @@ -7,3 +7,4 @@ string constant FORK_RPC_URL_BASE = "https://base.gateway.tenderly.co"; uint256 constant FORK_BLOCK_ARBITRUM = 399225617; uint256 constant FORK_BLOCK_BASE = 39366248; +uint256 constant FORK_BLOCK_BASE_CRCL = 39514975; diff --git a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol index 571e2c9..64f7e29 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -4,7 +4,13 @@ pragma solidity ^0.8.25; import {Test, console2} from "forge-std/Test.sol"; import {LibPyth} from "src/lib/pyth/LibPyth.sol"; -import {FORK_RPC_URL_ARBITRUM, FORK_RPC_URL_BASE, FORK_BLOCK_ARBITRUM, FORK_BLOCK_BASE} from "test/lib/LibFork.sol"; +import { + FORK_RPC_URL_ARBITRUM, + FORK_RPC_URL_BASE, + FORK_BLOCK_ARBITRUM, + FORK_BLOCK_BASE, + FORK_BLOCK_BASE_CRCL +} from "test/lib/LibFork.sol"; import {IntOrAString, LibIntOrAString} from "rain.intorastring/lib/LibIntOrAString.sol"; import {Float, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol"; @@ -322,7 +328,7 @@ contract LibPythGetPriceNoOlderThanTest is Test { } function testPriceNoOlderThanBaseCrcl() external { - vm.createSelectFork(FORK_RPC_URL_BASE, 39514975); + vm.createSelectFork(FORK_RPC_URL_BASE, FORK_BLOCK_BASE_CRCL); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.CRCL/USD"), LibDecimalFloat.packLossless(24 hours, 0), From d3c80597b9178f045fecb796247862a271d60992 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Tue, 16 Dec 2025 08:27:48 +0530 Subject: [PATCH 09/14] 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 136811a..b9ddb13 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(0x5f559a981e7cef1a50a48c59dd0b5a5ac2ffb517d93778550859929b64ad593a); +bytes32 constant BYTECODE_HASH = bytes32(0xf076a17b8c90db0bd5642497bb243a082299a5442b0743583b4c67bb2c12c18e); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xe7bb5842b2cf1d25681a9885109fbf8943495bcebb9ec049bc3790e5db57fa80); From c28cbd57d6bfed76d8ea1cf74304e3ce21f00dad Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Wed, 17 Dec 2025 15:51:11 +0530 Subject: [PATCH 10/14] pplt --- src/lib/pyth/LibPyth.sol | 8 ++++++++ test/lib/LibFork.sol | 1 + test/src/lib/pyth/LibPyth.constants.t.sol | 4 ++++ test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol | 5 +++++ test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol | 13 ++++++++++++- 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/lib/pyth/LibPyth.sol b/src/lib/pyth/LibPyth.sol index 3507a1f..a006aa2 100644 --- a/src/lib/pyth/LibPyth.sol +++ b/src/lib/pyth/LibPyth.sol @@ -241,6 +241,12 @@ library LibPyth { // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD = uint256(0x924571756974792e55532e4352434c2f55534400000000000000000000000000); + /// PPLT/USD + bytes32 constant PRICE_FEED_ID_EQUITY_US_PPLT_USD = + 0x782410278b6c8aa2d437812281526012808404aa14c243f73fb9939eeb88d430; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_PPLT_USD = + uint256(0x924571756974792e55532e50504c542f55534400000000000000000000000000); /// TODO replace with O(1) lookup table. function getPriceFeedContract(uint256 chainId) internal pure returns (IPyth) { @@ -336,6 +342,8 @@ library LibPyth { return PRICE_FEED_ID_EQUITY_US_SIVR_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD) { return PRICE_FEED_ID_EQUITY_US_CRCL_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_PPLT_USD) { + return PRICE_FEED_ID_EQUITY_US_PPLT_USD; } else { revert UnsupportedFeedSymbol(); } diff --git a/test/lib/LibFork.sol b/test/lib/LibFork.sol index 515a0aa..1d46dac 100644 --- a/test/lib/LibFork.sol +++ b/test/lib/LibFork.sol @@ -8,3 +8,4 @@ string constant FORK_RPC_URL_BASE = "https://base.gateway.tenderly.co"; uint256 constant FORK_BLOCK_ARBITRUM = 399225617; uint256 constant FORK_BLOCK_BASE = 39366248; uint256 constant FORK_BLOCK_BASE_CRCL = 39514975; +uint256 constant FORK_BLOCK_BASE_PPLT = 39588538; diff --git a/test/src/lib/pyth/LibPyth.constants.t.sol b/test/src/lib/pyth/LibPyth.constants.t.sol index 4cb7dc0..f8b4de2 100644 --- a/test/src/lib/pyth/LibPyth.constants.t.sol +++ b/test/src/lib/pyth/LibPyth.constants.t.sol @@ -173,5 +173,9 @@ contract LibPythConstantsTest is Test { LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD")) ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_PPLT_USD, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.PPLT/USD")) + ); } } diff --git a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol index 748d960..a06ce16 100644 --- a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol @@ -166,6 +166,10 @@ contract LibPythGetPriceFeedIdTest is Test { LibPyth.PRICE_FEED_ID_EQUITY_US_CRCL_USD, LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.CRCL/USD")) ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_PPLT_USD, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.PPLT/USD")) + ); } function testPriceFeedIdUnknownMappings(IntOrAString symbol) external { @@ -215,6 +219,7 @@ contract LibPythGetPriceFeedIdTest is Test { && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SIVR/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.PPLT/USD")) ); 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 64f7e29..5549a8c 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -9,7 +9,8 @@ import { FORK_RPC_URL_BASE, FORK_BLOCK_ARBITRUM, FORK_BLOCK_BASE, - FORK_BLOCK_BASE_CRCL + FORK_BLOCK_BASE_CRCL, + FORK_BLOCK_BASE_PPLT } from "test/lib/LibFork.sol"; import {IntOrAString, LibIntOrAString} from "rain.intorastring/lib/LibIntOrAString.sol"; import {Float, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol"; @@ -336,4 +337,14 @@ contract LibPythGetPriceNoOlderThanTest is Test { LibDecimalFloat.packLossless(0.07508e5, -5) ); } + + function testPriceNoOlderThanBasePplt() external { + vm.createSelectFork(FORK_RPC_URL_BASE, FORK_BLOCK_BASE_PPLT); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.PPLT/USD"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(167.72266e5, -5), + LibDecimalFloat.packLossless(0.16078e5, -5) + ); + } } From 7f4a87c6f629456bb370577b10a4d9769140a199 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Wed, 17 Dec 2025 15:52:38 +0530 Subject: [PATCH 11/14] 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 b9ddb13..9b13a8b 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(0xf076a17b8c90db0bd5642497bb243a082299a5442b0743583b4c67bb2c12c18e); +bytes32 constant BYTECODE_HASH = bytes32(0x9851d8e272465d55a13d0379b2ab03b3435f90719fb5dfaa9a3d0e4752f2b579); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xe7bb5842b2cf1d25681a9885109fbf8943495bcebb9ec049bc3790e5db57fa80); From eb3eb20932553f17067c899316c061d347299156 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Thu, 18 Dec 2025 10:55:09 +0530 Subject: [PATCH 12/14] crcl pre, post --- src/lib/pyth/LibPyth.sol | 14 ++++++++++++++ test/lib/LibFork.sol | 2 +- test/src/lib/pyth/LibPyth.constants.t.sol | 8 ++++++++ test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol | 2 ++ .../lib/pyth/LibPyth.getPriceNoOlderThan.t.sol | 16 ++++++++++++++-- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/lib/pyth/LibPyth.sol b/src/lib/pyth/LibPyth.sol index a006aa2..b35f3a0 100644 --- a/src/lib/pyth/LibPyth.sol +++ b/src/lib/pyth/LibPyth.sol @@ -241,6 +241,16 @@ library LibPyth { // slither-disable-next-line too-many-digits uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD = uint256(0x924571756974792e55532e4352434c2f55534400000000000000000000000000); + bytes32 constant PRICE_FEED_ID_EQUITY_US_CRCL_USD_PRE = + 0xb6ce1644a22bb348f89a81696141c1caaca5e7ea83de289a44fba1a9897ca2d6; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD_PRE = + uint256(0x964571756974792e55532e4352434c2f5553442e505245000000000000000000); + bytes32 constant PRICE_FEED_ID_EQUITY_US_CRCL_USD_POST = + 0x9bdba52fbb3d588d573928b1e781c6441e446a83c011fed92d8362c5b309ce02; + // slither-disable-next-line too-many-digits + uint256 constant PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD_POST = + uint256(0x974571756974792e55532e4352434c2f5553442e504f53540000000000000000); /// PPLT/USD bytes32 constant PRICE_FEED_ID_EQUITY_US_PPLT_USD = 0x782410278b6c8aa2d437812281526012808404aa14c243f73fb9939eeb88d430; @@ -342,6 +352,10 @@ library LibPyth { return PRICE_FEED_ID_EQUITY_US_SIVR_USD; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD) { return PRICE_FEED_ID_EQUITY_US_CRCL_USD; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD_PRE) { + return PRICE_FEED_ID_EQUITY_US_CRCL_USD_PRE; + } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD_POST) { + return PRICE_FEED_ID_EQUITY_US_CRCL_USD_POST; } else if (feedSymbol == PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_PPLT_USD) { return PRICE_FEED_ID_EQUITY_US_PPLT_USD; } else { diff --git a/test/lib/LibFork.sol b/test/lib/LibFork.sol index 1d46dac..6ae5646 100644 --- a/test/lib/LibFork.sol +++ b/test/lib/LibFork.sol @@ -7,5 +7,5 @@ string constant FORK_RPC_URL_BASE = "https://base.gateway.tenderly.co"; uint256 constant FORK_BLOCK_ARBITRUM = 399225617; uint256 constant FORK_BLOCK_BASE = 39366248; -uint256 constant FORK_BLOCK_BASE_CRCL = 39514975; +uint256 constant FORK_BLOCK_BASE_CRCL = 39622962; uint256 constant FORK_BLOCK_BASE_PPLT = 39588538; diff --git a/test/src/lib/pyth/LibPyth.constants.t.sol b/test/src/lib/pyth/LibPyth.constants.t.sol index f8b4de2..8522ca6 100644 --- a/test/src/lib/pyth/LibPyth.constants.t.sol +++ b/test/src/lib/pyth/LibPyth.constants.t.sol @@ -173,6 +173,14 @@ contract LibPythConstantsTest is Test { LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD")) ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD_PRE, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD.PRE")) + ); + assertEq( + LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_CRCL_USD_POST, + IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD.POST")) + ); assertEq( LibPyth.PRICE_FEED_SYMBOL_INTORASTRING_EQUITY_US_PPLT_USD, IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.PPLT/USD")) diff --git a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol index a06ce16..62f48f7 100644 --- a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol @@ -219,6 +219,8 @@ contract LibPythGetPriceFeedIdTest is Test { && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SIVR/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD.PRE")) + && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.PPLT/USD")) ); vm.expectRevert(UnsupportedFeedSymbol.selector); diff --git a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol index 5549a8c..9973c53 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -333,8 +333,20 @@ contract LibPythGetPriceNoOlderThanTest is Test { checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.CRCL/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(76.60999e5, -5), - LibDecimalFloat.packLossless(0.07508e5, -5) + LibDecimalFloat.packLossless(79.12510e5, -5), + LibDecimalFloat.packLossless(0.05449e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.CRCL/USD.PRE"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(82.77550e5, -5), + LibDecimalFloat.packLossless(0.17305e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.CRCL/USD.POST"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(79.86199e5, -5), + LibDecimalFloat.packLossless(0.24159e5, -5) ); } From 5a3a04985e455de27f5d835c89d46bc8189eca17 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Thu, 18 Dec 2025 10:55:44 +0530 Subject: [PATCH 13/14] 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 9b13a8b..445c32e 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(0x9851d8e272465d55a13d0379b2ab03b3435f90719fb5dfaa9a3d0e4752f2b579); +bytes32 constant BYTECODE_HASH = bytes32(0x7ae213fa0dca1d8672f2a27ff945cae82c23f3d917b36485c6e603ecbc7210ea); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xe7bb5842b2cf1d25681a9885109fbf8943495bcebb9ec049bc3790e5db57fa80); From 638e09dcb24c7368cec40e707e14e9483f3a4efb Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Thu, 18 Dec 2025 11:13:54 +0530 Subject: [PATCH 14/14] fmt --- test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol | 3 ++- test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol index 62f48f7..21485c8 100644 --- a/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol @@ -220,7 +220,8 @@ contract LibPythGetPriceFeedIdTest is Test { && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SIVR/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD.PRE")) - && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD.POST")) + && IntOrAString.unwrap(symbol) + != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.CRCL/USD.POST")) && IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.PPLT/USD")) ); vm.expectRevert(UnsupportedFeedSymbol.selector); diff --git a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol index 9973c53..429e211 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -333,13 +333,13 @@ contract LibPythGetPriceNoOlderThanTest is Test { checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.CRCL/USD"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(79.12510e5, -5), + LibDecimalFloat.packLossless(79.1251e5, -5), LibDecimalFloat.packLossless(0.05449e5, -5) ); checkPriceNoOlderThan( LibIntOrAString.fromString2("Equity.US.CRCL/USD.PRE"), LibDecimalFloat.packLossless(24 hours, 0), - LibDecimalFloat.packLossless(82.77550e5, -5), + LibDecimalFloat.packLossless(82.7755e5, -5), LibDecimalFloat.packLossless(0.17305e5, -5) ); checkPriceNoOlderThan(