diff --git a/src/generated/PythWords.pointers.sol b/src/generated/PythWords.pointers.sol index 198ba60..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(0x9ab8c9a8f8a4e84b78bf88cca39d259813ac779e61f7a08d6d1cab511e9512f5); +bytes32 constant BYTECODE_HASH = bytes32(0x7ae213fa0dca1d8672f2a27ff945cae82c23f3d917b36485c6e603ecbc7210ea); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xe7bb5842b2cf1d25681a9885109fbf8943495bcebb9ec049bc3790e5db57fa80); diff --git a/src/lib/pyth/LibPyth.sol b/src/lib/pyth/LibPyth.sol index 2eb8345..b35f3a0 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; @@ -177,13 +218,45 @@ 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 = + 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 = + 0x974571756974792e55532e434f494e2f5553442e504f53540000000000000000; /// SIVR/USD bytes32 constant PRICE_FEED_ID_EQUITY_US_SIVR_USD = 0x0a5ee42b0f7287a777926d08bc185a6a60f42f40a9b63d78d85d4a03ee2e3737; // 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); + 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; + // 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) { @@ -231,24 +304,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) { @@ -257,6 +350,14 @@ 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 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 { revert UnsupportedFeedSymbol(); } diff --git a/test/lib/LibFork.sol b/test/lib/LibFork.sol index 370e714..6ae5646 100644 --- a/test/lib/LibFork.sol +++ b/test/lib/LibFork.sol @@ -6,4 +6,6 @@ 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; +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 9b40d58..8522ca6 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")) @@ -129,5 +169,21 @@ 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")) + ); + 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 52428d7..21485c8 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")) @@ -122,6 +162,14 @@ 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")) + ); + assertEq( + LibPyth.PRICE_FEED_ID_EQUITY_US_PPLT_USD, + LibPyth.getPriceFeedId(LibIntOrAString.fromString2("Equity.US.PPLT/USD")) + ); } function testPriceFeedIdUnknownMappings(IntOrAString symbol) external { @@ -142,19 +190,39 @@ 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")) && 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); this.getPriceFeedIdExternal(symbol); diff --git a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol index b2df84e..429e211 100644 --- a/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol +++ b/test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol @@ -4,7 +4,14 @@ 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, + 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"; @@ -177,87 +184,179 @@ 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.268e5, -5), + LibDecimalFloat.packLossless(0.12973e5, -5) + ); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.AMZN/USD.PRE"), + LibDecimalFloat.packLossless(24 hours, 0), + LibDecimalFloat.packLossless(230.835e5, -5), + LibDecimalFloat.packLossless(0.095e5, -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.73e5, -5), + LibDecimalFloat.packLossless(0.441e5, -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.8466e5, -5), + LibDecimalFloat.packLossless(0.0144e5, -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.951e5, -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.9818e5, -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) + ); + } + + function testPriceNoOlderThanBaseCrcl() external { + vm.createSelectFork(FORK_RPC_URL_BASE, FORK_BLOCK_BASE_CRCL); + checkPriceNoOlderThan( + LibIntOrAString.fromString2("Equity.US.CRCL/USD"), + LibDecimalFloat.packLossless(24 hours, 0), + 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.7755e5, -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) + ); + } + + 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) ); } }