lynx-client 0.0.39 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/dist/cjs/index.js +8 -3
  2. package/dist/cjs/lib/addresses/lensAddresses.js +10 -8
  3. package/dist/cjs/lib/contractsIntegration/LexLensService/ILexLensService.js +7 -1
  4. package/dist/cjs/lib/contractsIntegration/LexLensService/LexLensService.js +6 -0
  5. package/dist/cjs/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.js +6 -1
  6. package/dist/cjs/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.js +4 -0
  7. package/dist/cjs/lib/contractsIntegration/TradingFloorService/TradingFloorService.js +12 -0
  8. package/dist/cjs/lib/devex/getChainAddresses.js +1 -1
  9. package/dist/cjs/lib/priceFeeds/pyth/{pythFeedConstants.js → hermes/hermesFeedConstants.js} +5 -5
  10. package/dist/cjs/lib/priceFeeds/pyth/hermes/hermesFeedFunctions.js +24 -0
  11. package/dist/{esm/lib/priceFeeds/pyth/pythPriceData.js → cjs/lib/priceFeeds/pyth/hermes/hermesPriceData.js} +11 -9
  12. package/dist/cjs/lib/priceFeeds/pyth/lazer/lazerFeedConstants.js +166 -0
  13. package/dist/cjs/lib/priceFeeds/pyth/lazer/lazerFeedFunctions.js +25 -0
  14. package/dist/cjs/lib/priceFeeds/pyth/lazer/lazerPayloadTypes.js +2 -0
  15. package/dist/cjs/lib/priceFeeds/pyth/lazer/lazerPriceData.js +60 -0
  16. package/dist/cjs/lib/priceFeeds/pyth/lazer/lazerSigningFormats.js +27 -0
  17. package/dist/cjs/lib/typechain/factories/contracts/Lynx/IntentsVerifier/TradeIntentsVerifierV1__factory.js +1 -1
  18. package/dist/cjs/lib/typechain/factories/contracts/Lynx/Lex/LexPool/LexPoolV1__factory.js +1 -1
  19. package/dist/cjs/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.js +1 -1
  20. package/dist/cjs/lib/typechain/factories/contracts/Lynx/OrderBook/OrderBookV1__factory.js +1 -1
  21. package/dist/cjs/lib/typechain/factories/contracts/Lynx/Registry/RegistryV1__factory.js +1 -1
  22. package/dist/cjs/lib/typechain/factories/contracts/Lynx/TradersPortal/TradersPortalV1__factory.js +1 -1
  23. package/dist/cjs/lib/typechain/factories/contracts/Lynx/TradingFloor/TradingFloorV1__factory.js +82 -1
  24. package/dist/cjs/lib/typechain/factories/contracts/Lynx/Triggers/TriggersV1__factory.js +1 -1
  25. package/dist/cjs/lib/typechain/factories/contracts/Peripheral/Lens/LexLens__factory.js +81 -1
  26. package/dist/cjs/lib/typechain/factories/contracts/Peripheral/Lens/TradingFloorLens__factory.js +42 -1
  27. package/dist/cjs/lib/typechain/factories/contracts/Peripheral/Lens/TriggersAndPortalLens__factory.js +1 -1
  28. package/dist/esm/index.d.ts +8 -3
  29. package/dist/esm/index.d.ts.map +1 -1
  30. package/dist/esm/index.js +8 -3
  31. package/dist/esm/lib/addresses/lensAddresses.d.ts +10 -8
  32. package/dist/esm/lib/addresses/lensAddresses.d.ts.map +1 -1
  33. package/dist/esm/lib/addresses/lensAddresses.js +10 -8
  34. package/dist/esm/lib/contractsIntegration/LexLensService/ILexLensService.d.ts +4 -1
  35. package/dist/esm/lib/contractsIntegration/LexLensService/ILexLensService.d.ts.map +1 -1
  36. package/dist/esm/lib/contractsIntegration/LexLensService/ILexLensService.js +7 -1
  37. package/dist/esm/lib/contractsIntegration/LexLensService/LexLensService.d.ts +2 -1
  38. package/dist/esm/lib/contractsIntegration/LexLensService/LexLensService.d.ts.map +1 -1
  39. package/dist/esm/lib/contractsIntegration/LexLensService/LexLensService.js +6 -0
  40. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.d.ts +4 -1
  41. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.d.ts.map +1 -1
  42. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.js +6 -1
  43. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.d.ts +2 -1
  44. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.d.ts.map +1 -1
  45. package/dist/esm/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.js +4 -0
  46. package/dist/esm/lib/contractsIntegration/TradingFloorService/ITradingFloorService.d.ts +6 -1
  47. package/dist/esm/lib/contractsIntegration/TradingFloorService/ITradingFloorService.d.ts.map +1 -1
  48. package/dist/esm/lib/contractsIntegration/TradingFloorService/TradingFloorService.d.ts +2 -1
  49. package/dist/esm/lib/contractsIntegration/TradingFloorService/TradingFloorService.d.ts.map +1 -1
  50. package/dist/esm/lib/contractsIntegration/TradingFloorService/TradingFloorService.js +12 -0
  51. package/dist/esm/lib/devex/getChainAddresses.js +1 -1
  52. package/dist/esm/lib/priceFeeds/pyth/hermes/hermesFeedConstants.d.ts +5 -0
  53. package/dist/esm/lib/priceFeeds/pyth/hermes/hermesFeedConstants.d.ts.map +1 -0
  54. package/dist/esm/lib/priceFeeds/pyth/{pythFeedConstants.js → hermes/hermesFeedConstants.js} +5 -5
  55. package/dist/esm/lib/priceFeeds/pyth/hermes/hermesFeedFunctions.d.ts +14 -0
  56. package/dist/esm/lib/priceFeeds/pyth/hermes/hermesFeedFunctions.d.ts.map +1 -0
  57. package/dist/esm/lib/priceFeeds/pyth/hermes/hermesFeedFunctions.js +24 -0
  58. package/dist/esm/lib/priceFeeds/pyth/hermes/hermesPriceData.d.ts +11 -0
  59. package/dist/esm/lib/priceFeeds/pyth/hermes/hermesPriceData.d.ts.map +1 -0
  60. package/dist/{cjs/lib/priceFeeds/pyth/pythPriceData.js → esm/lib/priceFeeds/pyth/hermes/hermesPriceData.js} +11 -9
  61. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerFeedConstants.d.ts +54 -0
  62. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerFeedConstants.d.ts.map +1 -0
  63. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerFeedConstants.js +166 -0
  64. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerFeedFunctions.d.ts +16 -0
  65. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerFeedFunctions.d.ts.map +1 -0
  66. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerFeedFunctions.js +25 -0
  67. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerPayloadTypes.d.ts +64 -0
  68. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerPayloadTypes.d.ts.map +1 -0
  69. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerPayloadTypes.js +2 -0
  70. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerPriceData.d.ts +26 -0
  71. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerPriceData.d.ts.map +1 -0
  72. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerPriceData.js +60 -0
  73. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerSigningFormats.d.ts +36 -0
  74. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerSigningFormats.d.ts.map +1 -0
  75. package/dist/esm/lib/priceFeeds/pyth/lazer/lazerSigningFormats.js +27 -0
  76. package/dist/esm/lib/typechain/contracts/Lynx/TradingFloor/TradingFloorV1.d.ts +63 -2
  77. package/dist/esm/lib/typechain/contracts/Lynx/TradingFloor/TradingFloorV1.d.ts.map +1 -1
  78. package/dist/esm/lib/typechain/contracts/Peripheral/Lens/LexLens.d.ts +30 -1
  79. package/dist/esm/lib/typechain/contracts/Peripheral/Lens/LexLens.d.ts.map +1 -1
  80. package/dist/esm/lib/typechain/contracts/Peripheral/Lens/TradingFloorLens.d.ts +29 -1
  81. package/dist/esm/lib/typechain/contracts/Peripheral/Lens/TradingFloorLens.d.ts.map +1 -1
  82. package/dist/esm/lib/typechain/factories/contracts/Lynx/IntentsVerifier/TradeIntentsVerifierV1__factory.d.ts +1 -1
  83. package/dist/esm/lib/typechain/factories/contracts/Lynx/IntentsVerifier/TradeIntentsVerifierV1__factory.js +1 -1
  84. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/LexPool/LexPoolV1__factory.d.ts +1 -1
  85. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/LexPool/LexPoolV1__factory.js +1 -1
  86. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.d.ts +1 -1
  87. package/dist/esm/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.js +1 -1
  88. package/dist/esm/lib/typechain/factories/contracts/Lynx/OrderBook/OrderBookV1__factory.d.ts +1 -1
  89. package/dist/esm/lib/typechain/factories/contracts/Lynx/OrderBook/OrderBookV1__factory.js +1 -1
  90. package/dist/esm/lib/typechain/factories/contracts/Lynx/Registry/RegistryV1__factory.d.ts +1 -1
  91. package/dist/esm/lib/typechain/factories/contracts/Lynx/Registry/RegistryV1__factory.js +1 -1
  92. package/dist/esm/lib/typechain/factories/contracts/Lynx/TradersPortal/TradersPortalV1__factory.d.ts +1 -1
  93. package/dist/esm/lib/typechain/factories/contracts/Lynx/TradersPortal/TradersPortalV1__factory.js +1 -1
  94. package/dist/esm/lib/typechain/factories/contracts/Lynx/TradingFloor/TradingFloorV1__factory.d.ts +64 -1
  95. package/dist/esm/lib/typechain/factories/contracts/Lynx/TradingFloor/TradingFloorV1__factory.d.ts.map +1 -1
  96. package/dist/esm/lib/typechain/factories/contracts/Lynx/TradingFloor/TradingFloorV1__factory.js +82 -1
  97. package/dist/esm/lib/typechain/factories/contracts/Lynx/Triggers/TriggersV1__factory.d.ts +1 -1
  98. package/dist/esm/lib/typechain/factories/contracts/Lynx/Triggers/TriggersV1__factory.d.ts.map +1 -1
  99. package/dist/esm/lib/typechain/factories/contracts/Lynx/Triggers/TriggersV1__factory.js +1 -1
  100. package/dist/esm/lib/typechain/factories/contracts/Peripheral/Lens/LexLens__factory.d.ts +62 -1
  101. package/dist/esm/lib/typechain/factories/contracts/Peripheral/Lens/LexLens__factory.d.ts.map +1 -1
  102. package/dist/esm/lib/typechain/factories/contracts/Peripheral/Lens/LexLens__factory.js +81 -1
  103. package/dist/esm/lib/typechain/factories/contracts/Peripheral/Lens/TradingFloorLens__factory.d.ts +32 -1
  104. package/dist/esm/lib/typechain/factories/contracts/Peripheral/Lens/TradingFloorLens__factory.d.ts.map +1 -1
  105. package/dist/esm/lib/typechain/factories/contracts/Peripheral/Lens/TradingFloorLens__factory.js +42 -1
  106. package/dist/esm/lib/typechain/factories/contracts/Peripheral/Lens/TriggersAndPortalLens__factory.d.ts +1 -1
  107. package/dist/esm/lib/typechain/factories/contracts/Peripheral/Lens/TriggersAndPortalLens__factory.js +1 -1
  108. package/dist/types/index.d.ts +8 -3
  109. package/dist/types/index.d.ts.map +1 -1
  110. package/dist/types/lib/addresses/lensAddresses.d.ts +10 -8
  111. package/dist/types/lib/addresses/lensAddresses.d.ts.map +1 -1
  112. package/dist/types/lib/contractsIntegration/LexLensService/ILexLensService.d.ts +4 -1
  113. package/dist/types/lib/contractsIntegration/LexLensService/ILexLensService.d.ts.map +1 -1
  114. package/dist/types/lib/contractsIntegration/LexLensService/LexLensService.d.ts +2 -1
  115. package/dist/types/lib/contractsIntegration/LexLensService/LexLensService.d.ts.map +1 -1
  116. package/dist/types/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.d.ts +4 -1
  117. package/dist/types/lib/contractsIntegration/TradingFloorLensService/ITradingFloorLensService.d.ts.map +1 -1
  118. package/dist/types/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.d.ts +2 -1
  119. package/dist/types/lib/contractsIntegration/TradingFloorLensService/TradingFloorLensService.d.ts.map +1 -1
  120. package/dist/types/lib/contractsIntegration/TradingFloorService/ITradingFloorService.d.ts +6 -1
  121. package/dist/types/lib/contractsIntegration/TradingFloorService/ITradingFloorService.d.ts.map +1 -1
  122. package/dist/types/lib/contractsIntegration/TradingFloorService/TradingFloorService.d.ts +2 -1
  123. package/dist/types/lib/contractsIntegration/TradingFloorService/TradingFloorService.d.ts.map +1 -1
  124. package/dist/types/lib/priceFeeds/pyth/hermes/hermesFeedConstants.d.ts +5 -0
  125. package/dist/types/lib/priceFeeds/pyth/hermes/hermesFeedConstants.d.ts.map +1 -0
  126. package/dist/types/lib/priceFeeds/pyth/hermes/hermesFeedFunctions.d.ts +14 -0
  127. package/dist/types/lib/priceFeeds/pyth/hermes/hermesFeedFunctions.d.ts.map +1 -0
  128. package/dist/types/lib/priceFeeds/pyth/hermes/hermesPriceData.d.ts +11 -0
  129. package/dist/types/lib/priceFeeds/pyth/hermes/hermesPriceData.d.ts.map +1 -0
  130. package/dist/types/lib/priceFeeds/pyth/lazer/lazerFeedConstants.d.ts +54 -0
  131. package/dist/types/lib/priceFeeds/pyth/lazer/lazerFeedConstants.d.ts.map +1 -0
  132. package/dist/types/lib/priceFeeds/pyth/lazer/lazerFeedFunctions.d.ts +16 -0
  133. package/dist/types/lib/priceFeeds/pyth/lazer/lazerFeedFunctions.d.ts.map +1 -0
  134. package/dist/types/lib/priceFeeds/pyth/lazer/lazerPayloadTypes.d.ts +64 -0
  135. package/dist/types/lib/priceFeeds/pyth/lazer/lazerPayloadTypes.d.ts.map +1 -0
  136. package/dist/types/lib/priceFeeds/pyth/lazer/lazerPriceData.d.ts +26 -0
  137. package/dist/types/lib/priceFeeds/pyth/lazer/lazerPriceData.d.ts.map +1 -0
  138. package/dist/types/lib/priceFeeds/pyth/lazer/lazerSigningFormats.d.ts +36 -0
  139. package/dist/types/lib/priceFeeds/pyth/lazer/lazerSigningFormats.d.ts.map +1 -0
  140. package/dist/types/lib/typechain/contracts/Lynx/TradingFloor/TradingFloorV1.d.ts +63 -2
  141. package/dist/types/lib/typechain/contracts/Lynx/TradingFloor/TradingFloorV1.d.ts.map +1 -1
  142. package/dist/types/lib/typechain/contracts/Peripheral/Lens/LexLens.d.ts +30 -1
  143. package/dist/types/lib/typechain/contracts/Peripheral/Lens/LexLens.d.ts.map +1 -1
  144. package/dist/types/lib/typechain/contracts/Peripheral/Lens/TradingFloorLens.d.ts +29 -1
  145. package/dist/types/lib/typechain/contracts/Peripheral/Lens/TradingFloorLens.d.ts.map +1 -1
  146. package/dist/types/lib/typechain/factories/contracts/Lynx/IntentsVerifier/TradeIntentsVerifierV1__factory.d.ts +1 -1
  147. package/dist/types/lib/typechain/factories/contracts/Lynx/Lex/LexPool/LexPoolV1__factory.d.ts +1 -1
  148. package/dist/types/lib/typechain/factories/contracts/Lynx/Lex/PoolAccountant/PoolAccountantV1__factory.d.ts +1 -1
  149. package/dist/types/lib/typechain/factories/contracts/Lynx/OrderBook/OrderBookV1__factory.d.ts +1 -1
  150. package/dist/types/lib/typechain/factories/contracts/Lynx/Registry/RegistryV1__factory.d.ts +1 -1
  151. package/dist/types/lib/typechain/factories/contracts/Lynx/TradersPortal/TradersPortalV1__factory.d.ts +1 -1
  152. package/dist/types/lib/typechain/factories/contracts/Lynx/TradingFloor/TradingFloorV1__factory.d.ts +64 -1
  153. package/dist/types/lib/typechain/factories/contracts/Lynx/TradingFloor/TradingFloorV1__factory.d.ts.map +1 -1
  154. package/dist/types/lib/typechain/factories/contracts/Lynx/Triggers/TriggersV1__factory.d.ts +1 -1
  155. package/dist/types/lib/typechain/factories/contracts/Lynx/Triggers/TriggersV1__factory.d.ts.map +1 -1
  156. package/dist/types/lib/typechain/factories/contracts/Peripheral/Lens/LexLens__factory.d.ts +62 -1
  157. package/dist/types/lib/typechain/factories/contracts/Peripheral/Lens/LexLens__factory.d.ts.map +1 -1
  158. package/dist/types/lib/typechain/factories/contracts/Peripheral/Lens/TradingFloorLens__factory.d.ts +32 -1
  159. package/dist/types/lib/typechain/factories/contracts/Peripheral/Lens/TradingFloorLens__factory.d.ts.map +1 -1
  160. package/dist/types/lib/typechain/factories/contracts/Peripheral/Lens/TriggersAndPortalLens__factory.d.ts +1 -1
  161. package/package.json +13 -13
  162. package/dist/cjs/lib/priceFeeds/pyth/pythFeedFunctions.js +0 -27
  163. package/dist/esm/lib/priceFeeds/pyth/pythFeedConstants.d.ts +0 -5
  164. package/dist/esm/lib/priceFeeds/pyth/pythFeedConstants.d.ts.map +0 -1
  165. package/dist/esm/lib/priceFeeds/pyth/pythFeedFunctions.d.ts +0 -17
  166. package/dist/esm/lib/priceFeeds/pyth/pythFeedFunctions.d.ts.map +0 -1
  167. package/dist/esm/lib/priceFeeds/pyth/pythFeedFunctions.js +0 -27
  168. package/dist/esm/lib/priceFeeds/pyth/pythPriceData.d.ts +0 -10
  169. package/dist/esm/lib/priceFeeds/pyth/pythPriceData.d.ts.map +0 -1
  170. package/dist/types/lib/priceFeeds/pyth/pythFeedConstants.d.ts +0 -5
  171. package/dist/types/lib/priceFeeds/pyth/pythFeedConstants.d.ts.map +0 -1
  172. package/dist/types/lib/priceFeeds/pyth/pythFeedFunctions.d.ts +0 -17
  173. package/dist/types/lib/priceFeeds/pyth/pythFeedFunctions.d.ts.map +0 -1
  174. package/dist/types/lib/priceFeeds/pyth/pythPriceData.d.ts +0 -10
  175. package/dist/types/lib/priceFeeds/pyth/pythPriceData.d.ts.map +0 -1
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHermesPriceKeyForPair = getHermesPriceKeyForPair;
4
+ exports.getHermesFeedIdForPair = getHermesFeedIdForPair;
5
+ exports.getPairIdForHermesFeedId = getPairIdForHermesFeedId;
6
+ const hermesFeedConstants_1 = require("./hermesFeedConstants");
7
+ /**
8
+ * Get the Pyth Hermes symbol (e.g. "Crypto.BTC/USD") for a pair
9
+ */
10
+ function getHermesPriceKeyForPair(pairId) {
11
+ return hermesFeedConstants_1.PYTH_HERMES_PRICE_KEYS[pairId];
12
+ }
13
+ /**
14
+ * Get the Pyth Hermes feed id (32-byte hex hash) for a pair
15
+ */
16
+ function getHermesFeedIdForPair(pairId) {
17
+ return hermesFeedConstants_1.PYTH_HERMES_FEED_IDS[pairId];
18
+ }
19
+ /**
20
+ * Get the pair id for a Pyth Hermes feed id (reverse lookup)
21
+ */
22
+ function getPairIdForHermesFeedId(feedId) {
23
+ return hermesFeedConstants_1.PYTH_HERMES_FEED_ID_TO_PAIR[feedId];
24
+ }
@@ -0,0 +1,11 @@
1
+ import { CombinedPriceData } from "../../interfaces";
2
+ /**
3
+ * Fetches historical price data from Pyth Hermes for a specific timestamp or later
4
+ * Only searches forward in time (timestamp >= startTimestamp), never backwards
5
+ * @param priceFeedId - The Pyth Hermes price feed ID (32-byte hex hash)
6
+ * @param startTimestamp - The minimum timestamp to search from
7
+ * @param maxTimeGap - Maximum seconds to search forward from startTimestamp
8
+ * @param pairId - Optional pair identifier included in error messages for context
9
+ */
10
+ export declare function getHermesPriceForTimestamp(priceFeedId: string, startTimestamp: number, maxTimeGap: number, pairId?: number): Promise<CombinedPriceData>;
11
+ //# sourceMappingURL=hermesPriceData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hermesPriceData.d.ts","sourceRoot":"","sources":["../../../../../../lib/priceFeeds/pyth/hermes/hermesPriceData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAgCrD;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,CAkB5B"}
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPricesForTimestamp = getPricesForTimestamp;
4
- const scales_1 = require("../../constants/scales");
5
- const lynxScalesUtils_1 = require("../../lynxSystem/lynxScalesUtils");
6
- const bignumbers_1 = require("../../utils/bignumbers");
3
+ exports.getHermesPriceForTimestamp = getHermesPriceForTimestamp;
4
+ const scales_1 = require("../../../constants/scales");
5
+ const lynxScalesUtils_1 = require("../../../lynxSystem/lynxScalesUtils");
6
+ const bignumbers_1 = require("../../../utils/bignumbers");
7
7
  /**
8
- * Helper function to parse Pyth API response data into CombinedPriceData
8
+ * Helper function to parse Pyth Hermes API response data into CombinedPriceData
9
9
  */
10
10
  function parseResponse(data) {
11
11
  const encodedPrice = data.binary?.data ? `0x${data.binary.data}` : "";
@@ -30,13 +30,14 @@ function parseResponse(data) {
30
30
  };
31
31
  }
32
32
  /**
33
- * Fetches historical price data from Pyth for a specific timestamp or later
33
+ * Fetches historical price data from Pyth Hermes for a specific timestamp or later
34
34
  * Only searches forward in time (timestamp >= startTimestamp), never backwards
35
- * @param priceFeedId - The Pyth price feed ID
35
+ * @param priceFeedId - The Pyth Hermes price feed ID (32-byte hex hash)
36
36
  * @param startTimestamp - The minimum timestamp to search from
37
37
  * @param maxTimeGap - Maximum seconds to search forward from startTimestamp
38
+ * @param pairId - Optional pair identifier included in error messages for context
38
39
  */
39
- async function getPricesForTimestamp(priceFeedId, startTimestamp, maxTimeGap) {
40
+ async function getHermesPriceForTimestamp(priceFeedId, startTimestamp, maxTimeGap, pairId) {
40
41
  const hermesUrl = "https://hermes.pyth.network";
41
42
  const buildUrl = (timestamp) => `${hermesUrl}/v2/updates/price/${timestamp}?ids[]=${priceFeedId}&encoding=hex`;
42
43
  // Try timestamps from startTimestamp onwards, incrementing by 1 second
@@ -47,5 +48,6 @@ async function getPricesForTimestamp(priceFeedId, startTimestamp, maxTimeGap) {
47
48
  return parseResponse(await response.json());
48
49
  }
49
50
  }
50
- throw new Error(`No price found for asset ${priceFeedId} at or within ${maxTimeGap}s after timestamp ${startTimestamp}`);
51
+ const pairContext = pairId !== undefined ? ` (pair ${pairId})` : "";
52
+ throw new Error(`No price found for Pyth Hermes feed ${priceFeedId}${pairContext} at or within ${maxTimeGap}s after timestamp ${startTimestamp}`);
51
53
  }
@@ -0,0 +1,54 @@
1
+ import { TPairIds } from "../../../constants/pairIds";
2
+ /**
3
+ * Pyth Lazer feed identifiers are u32 integers (not 32-byte hex hashes like Hermes).
4
+ * Branding this as a distinct nominal type prevents accidentally passing a Hermes
5
+ * hash where a Lazer numeric id is expected, and vice versa.
6
+ */
7
+ export type PythLazerFeedId = number & {
8
+ readonly __brand: "PythLazerFeedId";
9
+ };
10
+ /**
11
+ * Pyth Lazer symbol per pair. Mirrors PYTH_HERMES_PRICE_KEYS but uses Lazer's
12
+ * symbol convention (e.g. "FX." uppercase prefix instead of Hermes' "Fx.").
13
+ */
14
+ export declare const PYTH_LAZER_PRICE_KEYS: Record<TPairIds, string>;
15
+ /**
16
+ * Pyth Lazer u32 feed identifiers per pair. Source of truth is
17
+ * https://pyth.dourolabs.app/v1/symbols (pyth_lazer_id field).
18
+ *
19
+ * CAT pairs intentionally share the same feed id as their non-CAT counterpart
20
+ * (the underlying market data is identical). This is a behavior change vs the
21
+ * Hermes map, which uses empty-string sentinels for CAT pairs — Lazer callers
22
+ * always get a usable id back.
23
+ *
24
+ * Feed availability on Lazer at the time these were captured (verify with
25
+ * scripts/verifyLazerMapping.ts before relying on any of this).
26
+ *
27
+ * IMPORTANT — MIGRATION CONTEXT: Hermes is scheduled for deprecation
28
+ * (~2026-07). Lazer is the long-term path. The two entries below are
29
+ * migration blockers that need to be resolved (Pyth state change OR feed
30
+ * replacement) before Hermes shutoff, otherwise we lose pricing entirely:
31
+ *
32
+ * - Crypto.FLR/USD (id 191) — Lazer state `coming_soon`. Querying returns
33
+ * HTTP 400 "Price feed id 191 is not ready". Today FLR pricing works via
34
+ * Hermes and Flare; post-Hermes-shutoff only Flare remains if Pyth has
35
+ * not yet promoted 191 to `stable`. Re-run scripts/verifyLazerMapping.ts
36
+ * to check current state.
37
+ *
38
+ * - Commodities.USOILSPOT (id 657) — Lazer state `inactive`. Querying
39
+ * returns HTTP 400 "Price feed id 657 is not ready". Today USOIL pricing
40
+ * works via Hermes only (the Flare oracle does NOT publish USOIL). This
41
+ * is the more urgent migration blocker: if Pyth does not reactivate 657
42
+ * before Hermes shutoff, we need an alternative provider for USOIL or
43
+ * we lose the pair.
44
+ *
45
+ * All other ids are `stable`.
46
+ */
47
+ export declare const PYTH_LAZER_FEED_IDS: Record<TPairIds, PythLazerFeedId>;
48
+ /**
49
+ * Reverse lookup: Lazer feed id → pair id. CAT pairs share an id with their
50
+ * non-CAT base, so only the base pair is present — the reverse map returns the
51
+ * "canonical" non-CAT pair for any given Lazer feed id.
52
+ */
53
+ export declare const PYTH_LAZER_FEED_ID_TO_PAIR: Record<number, TPairIds>;
54
+ //# sourceMappingURL=lazerFeedConstants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazerFeedConstants.d.ts","sourceRoot":"","sources":["../../../../../../lib/priceFeeds/pyth/lazer/lazerFeedConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAiCxE;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAI/E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAsD1D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,QAAQ,EAAE,eAAe,CAsDjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAiB5D,CAAC"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PYTH_LAZER_FEED_ID_TO_PAIR = exports.PYTH_LAZER_FEED_IDS = exports.PYTH_LAZER_PRICE_KEYS = void 0;
4
+ const pairIds_1 = require("../../../constants/pairIds");
5
+ const lazerId = (n) => n;
6
+ /**
7
+ * Pyth Lazer symbol per pair. Mirrors PYTH_HERMES_PRICE_KEYS but uses Lazer's
8
+ * symbol convention (e.g. "FX." uppercase prefix instead of Hermes' "Fx.").
9
+ */
10
+ exports.PYTH_LAZER_PRICE_KEYS = {
11
+ // Crypto
12
+ [pairIds_1.PAIR_CONFIGS_IDS.BTC_USD]: "Crypto.BTC/USD",
13
+ [pairIds_1.PAIR_CONFIGS_IDS.ETH_USD]: "Crypto.ETH/USD",
14
+ [pairIds_1.PAIR_CONFIGS_IDS.BNB_USD]: "Crypto.BNB/USD",
15
+ // Crypto.FTM/USD is deprecated; reuses Crypto.S/USD (same convention as Hermes map)
16
+ [pairIds_1.PAIR_CONFIGS_IDS.FTM_USD]: "Crypto.S/USD",
17
+ [pairIds_1.PAIR_CONFIGS_IDS.SOL_USD]: "Crypto.SOL/USD",
18
+ [pairIds_1.PAIR_CONFIGS_IDS.XRP_USD]: "Crypto.XRP/USD",
19
+ [pairIds_1.PAIR_CONFIGS_IDS.FLR_USD]: "Crypto.FLR/USD",
20
+ [pairIds_1.PAIR_CONFIGS_IDS.SEI_USD]: "Crypto.SEI/USD",
21
+ [pairIds_1.PAIR_CONFIGS_IDS.S_USD]: "Crypto.S/USD",
22
+ // Forex (Lazer uses uppercase "FX." prefix)
23
+ [pairIds_1.PAIR_CONFIGS_IDS.EUR_USD]: "FX.EUR/USD",
24
+ [pairIds_1.PAIR_CONFIGS_IDS.GBP_USD]: "FX.GBP/USD",
25
+ [pairIds_1.PAIR_CONFIGS_IDS.AUD_USD]: "FX.AUD/USD",
26
+ [pairIds_1.PAIR_CONFIGS_IDS.NZD_USD]: "FX.NZD/USD",
27
+ [pairIds_1.PAIR_CONFIGS_IDS.USD_JPY]: "FX.USD/JPY",
28
+ [pairIds_1.PAIR_CONFIGS_IDS.USD_CHF]: "FX.USD/CHF",
29
+ // Stocks
30
+ [pairIds_1.PAIR_CONFIGS_IDS.TSLA_USD]: "Equity.US.TSLA/USD",
31
+ [pairIds_1.PAIR_CONFIGS_IDS.AAPL_USD]: "Equity.US.AAPL/USD",
32
+ [pairIds_1.PAIR_CONFIGS_IDS.NVDA_USD]: "Equity.US.NVDA/USD",
33
+ [pairIds_1.PAIR_CONFIGS_IDS.AMZN_USD]: "Equity.US.AMZN/USD",
34
+ [pairIds_1.PAIR_CONFIGS_IDS.GOOGL_USD]: "Equity.US.GOOGL/USD",
35
+ [pairIds_1.PAIR_CONFIGS_IDS.MSFT_USD]: "Equity.US.MSFT/USD",
36
+ [pairIds_1.PAIR_CONFIGS_IDS.META_USD]: "Equity.US.META/USD",
37
+ // Commodities
38
+ [pairIds_1.PAIR_CONFIGS_IDS.GOLD_USD]: "Metal.XAU/USD",
39
+ [pairIds_1.PAIR_CONFIGS_IDS.SILVER_USD]: "Metal.XAG/USD",
40
+ [pairIds_1.PAIR_CONFIGS_IDS.USOIL_USD]: "Commodities.USOILSPOT",
41
+ // CAT mode — share the symbol of the corresponding non-CAT pair
42
+ [pairIds_1.PAIR_CONFIGS_IDS.BTC_USD_CAT]: "Crypto.BTC/USD",
43
+ [pairIds_1.PAIR_CONFIGS_IDS.ETH_USD_CAT]: "Crypto.ETH/USD",
44
+ [pairIds_1.PAIR_CONFIGS_IDS.EUR_USD_CAT]: "FX.EUR/USD",
45
+ [pairIds_1.PAIR_CONFIGS_IDS.GBP_USD_CAT]: "FX.GBP/USD",
46
+ [pairIds_1.PAIR_CONFIGS_IDS.AUD_USD_CAT]: "FX.AUD/USD",
47
+ [pairIds_1.PAIR_CONFIGS_IDS.NZD_USD_CAT]: "FX.NZD/USD",
48
+ [pairIds_1.PAIR_CONFIGS_IDS.USD_JPY_CAT]: "FX.USD/JPY",
49
+ [pairIds_1.PAIR_CONFIGS_IDS.USD_CHF_CAT]: "FX.USD/CHF",
50
+ [pairIds_1.PAIR_CONFIGS_IDS.TSLA_USD_CAT]: "Equity.US.TSLA/USD",
51
+ [pairIds_1.PAIR_CONFIGS_IDS.AAPL_USD_CAT]: "Equity.US.AAPL/USD",
52
+ [pairIds_1.PAIR_CONFIGS_IDS.NVDA_USD_CAT]: "Equity.US.NVDA/USD",
53
+ [pairIds_1.PAIR_CONFIGS_IDS.AMZN_USD_CAT]: "Equity.US.AMZN/USD",
54
+ [pairIds_1.PAIR_CONFIGS_IDS.GOOGL_USD_CAT]: "Equity.US.GOOGL/USD",
55
+ [pairIds_1.PAIR_CONFIGS_IDS.MSFT_USD_CAT]: "Equity.US.MSFT/USD",
56
+ [pairIds_1.PAIR_CONFIGS_IDS.META_USD_CAT]: "Equity.US.META/USD",
57
+ [pairIds_1.PAIR_CONFIGS_IDS.GOLD_USD_CAT]: "Metal.XAU/USD",
58
+ [pairIds_1.PAIR_CONFIGS_IDS.SILVER_USD_CAT]: "Metal.XAG/USD",
59
+ [pairIds_1.PAIR_CONFIGS_IDS.USOIL_USD_CAT]: "Commodities.USOILSPOT",
60
+ };
61
+ /**
62
+ * Pyth Lazer u32 feed identifiers per pair. Source of truth is
63
+ * https://pyth.dourolabs.app/v1/symbols (pyth_lazer_id field).
64
+ *
65
+ * CAT pairs intentionally share the same feed id as their non-CAT counterpart
66
+ * (the underlying market data is identical). This is a behavior change vs the
67
+ * Hermes map, which uses empty-string sentinels for CAT pairs — Lazer callers
68
+ * always get a usable id back.
69
+ *
70
+ * Feed availability on Lazer at the time these were captured (verify with
71
+ * scripts/verifyLazerMapping.ts before relying on any of this).
72
+ *
73
+ * IMPORTANT — MIGRATION CONTEXT: Hermes is scheduled for deprecation
74
+ * (~2026-07). Lazer is the long-term path. The two entries below are
75
+ * migration blockers that need to be resolved (Pyth state change OR feed
76
+ * replacement) before Hermes shutoff, otherwise we lose pricing entirely:
77
+ *
78
+ * - Crypto.FLR/USD (id 191) — Lazer state `coming_soon`. Querying returns
79
+ * HTTP 400 "Price feed id 191 is not ready". Today FLR pricing works via
80
+ * Hermes and Flare; post-Hermes-shutoff only Flare remains if Pyth has
81
+ * not yet promoted 191 to `stable`. Re-run scripts/verifyLazerMapping.ts
82
+ * to check current state.
83
+ *
84
+ * - Commodities.USOILSPOT (id 657) — Lazer state `inactive`. Querying
85
+ * returns HTTP 400 "Price feed id 657 is not ready". Today USOIL pricing
86
+ * works via Hermes only (the Flare oracle does NOT publish USOIL). This
87
+ * is the more urgent migration blocker: if Pyth does not reactivate 657
88
+ * before Hermes shutoff, we need an alternative provider for USOIL or
89
+ * we lose the pair.
90
+ *
91
+ * All other ids are `stable`.
92
+ */
93
+ exports.PYTH_LAZER_FEED_IDS = {
94
+ // Crypto
95
+ [pairIds_1.PAIR_CONFIGS_IDS.BTC_USD]: lazerId(1),
96
+ [pairIds_1.PAIR_CONFIGS_IDS.ETH_USD]: lazerId(2),
97
+ [pairIds_1.PAIR_CONFIGS_IDS.BNB_USD]: lazerId(15),
98
+ // FTM is deprecated; route to S/USD's Lazer id, matching the Hermes map convention.
99
+ [pairIds_1.PAIR_CONFIGS_IDS.FTM_USD]: lazerId(190),
100
+ [pairIds_1.PAIR_CONFIGS_IDS.SOL_USD]: lazerId(6),
101
+ [pairIds_1.PAIR_CONFIGS_IDS.XRP_USD]: lazerId(14),
102
+ [pairIds_1.PAIR_CONFIGS_IDS.FLR_USD]: lazerId(191), // state=coming_soon at time of writing
103
+ [pairIds_1.PAIR_CONFIGS_IDS.SEI_USD]: lazerId(51),
104
+ [pairIds_1.PAIR_CONFIGS_IDS.S_USD]: lazerId(190),
105
+ // Forex
106
+ [pairIds_1.PAIR_CONFIGS_IDS.EUR_USD]: lazerId(327),
107
+ [pairIds_1.PAIR_CONFIGS_IDS.GBP_USD]: lazerId(333),
108
+ [pairIds_1.PAIR_CONFIGS_IDS.AUD_USD]: lazerId(315),
109
+ [pairIds_1.PAIR_CONFIGS_IDS.NZD_USD]: lazerId(337),
110
+ [pairIds_1.PAIR_CONFIGS_IDS.USD_JPY]: lazerId(340),
111
+ [pairIds_1.PAIR_CONFIGS_IDS.USD_CHF]: lazerId(339),
112
+ // Stocks
113
+ [pairIds_1.PAIR_CONFIGS_IDS.TSLA_USD]: lazerId(1435),
114
+ [pairIds_1.PAIR_CONFIGS_IDS.AAPL_USD]: lazerId(922),
115
+ [pairIds_1.PAIR_CONFIGS_IDS.NVDA_USD]: lazerId(1314),
116
+ [pairIds_1.PAIR_CONFIGS_IDS.AMZN_USD]: lazerId(954),
117
+ [pairIds_1.PAIR_CONFIGS_IDS.GOOGL_USD]: lazerId(1163),
118
+ [pairIds_1.PAIR_CONFIGS_IDS.MSFT_USD]: lazerId(1292),
119
+ [pairIds_1.PAIR_CONFIGS_IDS.META_USD]: lazerId(1272),
120
+ // Commodities
121
+ [pairIds_1.PAIR_CONFIGS_IDS.GOLD_USD]: lazerId(346),
122
+ [pairIds_1.PAIR_CONFIGS_IDS.SILVER_USD]: lazerId(345),
123
+ [pairIds_1.PAIR_CONFIGS_IDS.USOIL_USD]: lazerId(657), // state=inactive at time of writing
124
+ // CAT mode — share the feed id of the corresponding non-CAT pair
125
+ [pairIds_1.PAIR_CONFIGS_IDS.BTC_USD_CAT]: lazerId(1),
126
+ [pairIds_1.PAIR_CONFIGS_IDS.ETH_USD_CAT]: lazerId(2),
127
+ [pairIds_1.PAIR_CONFIGS_IDS.EUR_USD_CAT]: lazerId(327),
128
+ [pairIds_1.PAIR_CONFIGS_IDS.GBP_USD_CAT]: lazerId(333),
129
+ [pairIds_1.PAIR_CONFIGS_IDS.AUD_USD_CAT]: lazerId(315),
130
+ [pairIds_1.PAIR_CONFIGS_IDS.NZD_USD_CAT]: lazerId(337),
131
+ [pairIds_1.PAIR_CONFIGS_IDS.USD_JPY_CAT]: lazerId(340),
132
+ [pairIds_1.PAIR_CONFIGS_IDS.USD_CHF_CAT]: lazerId(339),
133
+ [pairIds_1.PAIR_CONFIGS_IDS.TSLA_USD_CAT]: lazerId(1435),
134
+ [pairIds_1.PAIR_CONFIGS_IDS.AAPL_USD_CAT]: lazerId(922),
135
+ [pairIds_1.PAIR_CONFIGS_IDS.NVDA_USD_CAT]: lazerId(1314),
136
+ [pairIds_1.PAIR_CONFIGS_IDS.AMZN_USD_CAT]: lazerId(954),
137
+ [pairIds_1.PAIR_CONFIGS_IDS.GOOGL_USD_CAT]: lazerId(1163),
138
+ [pairIds_1.PAIR_CONFIGS_IDS.MSFT_USD_CAT]: lazerId(1292),
139
+ [pairIds_1.PAIR_CONFIGS_IDS.META_USD_CAT]: lazerId(1272),
140
+ [pairIds_1.PAIR_CONFIGS_IDS.GOLD_USD_CAT]: lazerId(346),
141
+ [pairIds_1.PAIR_CONFIGS_IDS.SILVER_USD_CAT]: lazerId(345),
142
+ [pairIds_1.PAIR_CONFIGS_IDS.USOIL_USD_CAT]: lazerId(657),
143
+ };
144
+ /**
145
+ * Reverse lookup: Lazer feed id → pair id. CAT pairs share an id with their
146
+ * non-CAT base, so only the base pair is present — the reverse map returns the
147
+ * "canonical" non-CAT pair for any given Lazer feed id.
148
+ */
149
+ exports.PYTH_LAZER_FEED_ID_TO_PAIR = (() => {
150
+ const acc = {};
151
+ // Iterate non-CAT pairs first so CAT entries don't overwrite them
152
+ const catSuffix = "_CAT";
153
+ const orderedPairNames = Object.keys(pairIds_1.PAIR_CONFIGS_IDS).sort((a, b) => {
154
+ const aCat = a.endsWith(catSuffix);
155
+ const bCat = b.endsWith(catSuffix);
156
+ return Number(aCat) - Number(bCat);
157
+ });
158
+ for (const name of orderedPairNames) {
159
+ const pairId = pairIds_1.PAIR_CONFIGS_IDS[name];
160
+ const feedId = exports.PYTH_LAZER_FEED_IDS[pairId];
161
+ if (feedId !== undefined && !(feedId in acc)) {
162
+ acc[feedId] = pairId;
163
+ }
164
+ }
165
+ return acc;
166
+ })();
@@ -0,0 +1,16 @@
1
+ import { PythLazerFeedId } from "./lazerFeedConstants";
2
+ import { TPairIds } from "../../../constants/pairIds";
3
+ /**
4
+ * Get the Pyth Lazer symbol (e.g. "Crypto.BTC/USD") for a pair
5
+ */
6
+ export declare function getLazerPriceKeyForPair(pairId: TPairIds): string;
7
+ /**
8
+ * Get the Pyth Lazer u32 feed id for a pair
9
+ */
10
+ export declare function getLazerFeedIdForPair(pairId: TPairIds): PythLazerFeedId;
11
+ /**
12
+ * Get the canonical (non-CAT) pair id for a Pyth Lazer feed id, or undefined
13
+ * if no pair is registered for that feed id.
14
+ */
15
+ export declare function getPairIdForLazerFeedId(feedId: PythLazerFeedId): TPairIds | undefined;
16
+ //# sourceMappingURL=lazerFeedFunctions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazerFeedFunctions.d.ts","sourceRoot":"","sources":["../../../../../../lib/priceFeeds/pyth/lazer/lazerFeedFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAEhE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,GAAG,eAAe,CAEvE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,eAAe,GACtB,QAAQ,GAAG,SAAS,CAEtB"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLazerPriceKeyForPair = getLazerPriceKeyForPair;
4
+ exports.getLazerFeedIdForPair = getLazerFeedIdForPair;
5
+ exports.getPairIdForLazerFeedId = getPairIdForLazerFeedId;
6
+ const lazerFeedConstants_1 = require("./lazerFeedConstants");
7
+ /**
8
+ * Get the Pyth Lazer symbol (e.g. "Crypto.BTC/USD") for a pair
9
+ */
10
+ function getLazerPriceKeyForPair(pairId) {
11
+ return lazerFeedConstants_1.PYTH_LAZER_PRICE_KEYS[pairId];
12
+ }
13
+ /**
14
+ * Get the Pyth Lazer u32 feed id for a pair
15
+ */
16
+ function getLazerFeedIdForPair(pairId) {
17
+ return lazerFeedConstants_1.PYTH_LAZER_FEED_IDS[pairId];
18
+ }
19
+ /**
20
+ * Get the canonical (non-CAT) pair id for a Pyth Lazer feed id, or undefined
21
+ * if no pair is registered for that feed id.
22
+ */
23
+ function getPairIdForLazerFeedId(feedId) {
24
+ return lazerFeedConstants_1.PYTH_LAZER_FEED_ID_TO_PAIR[feedId];
25
+ }
@@ -0,0 +1,64 @@
1
+ import { PythLazerFeedId } from "./lazerFeedConstants";
2
+ import { LazerVerifiablePayload } from "./lazerSigningFormats";
3
+ /**
4
+ * Subscription channel — selects update cadence. `real_time` pushes every
5
+ * publisher update; fixed-rate channels coalesce updates onto a fixed cadence.
6
+ */
7
+ export type LazerChannel = "real_time" | "fixed_rate@50ms" | "fixed_rate@200ms" | "fixed_rate@1000ms";
8
+ /**
9
+ * Trading session of an underlying market at the time of the update.
10
+ * Some markets (FX, equities, commodities) have non-regular sessions; crypto
11
+ * is always `regular`.
12
+ */
13
+ export type LazerMarketSession = "regular" | "pre" | "post" | "closed" | (string & {});
14
+ /**
15
+ * A single price feed update inside a `streamUpdated` message.
16
+ * Optional fields appear only when requested via the subscription `properties`.
17
+ *
18
+ * Numeric fields delivered as strings by the wire format (large `i64` values
19
+ * exceed JS safe-integer range) are kept as strings here; consumers should
20
+ * `BigInt(...)` them before arithmetic.
21
+ */
22
+ export interface LazerPriceFeedUpdate {
23
+ priceFeedId: PythLazerFeedId;
24
+ /** i64 mantissa as string. Actual price = `BigInt(price) * 10n ** BigInt(exponent)`. */
25
+ price: string;
26
+ /** i16 power-of-ten exponent (typically negative, e.g. -8). */
27
+ exponent: number;
28
+ /** i64 confidence interval, same scale as price. */
29
+ confidence: number;
30
+ /** Number of publishers contributing to this update. */
31
+ publisherCount: number;
32
+ marketSession: LazerMarketSession;
33
+ /** Microsecond Unix timestamp of when the price was generated. */
34
+ feedUpdateTimestamp: number;
35
+ bestBidPrice?: string;
36
+ bestAskPrice?: string;
37
+ emaPrice?: string;
38
+ emaConfidence?: number;
39
+ fundingRate?: string;
40
+ fundingTimestamp?: number;
41
+ fundingRateInterval?: number;
42
+ }
43
+ /**
44
+ * Wire shape of a Pyth Lazer `streamUpdated` WebSocket message.
45
+ *
46
+ * The `evm` / `solana` / `leEcdsa` / `leUnsigned` keys hold the binary signed
47
+ * payload(s) for whichever signing formats were requested in the subscription.
48
+ * Use {@link lazerPayloadToBytes} to convert a payload into the bytes that
49
+ * `PythLazer.verifyUpdate(bytes)` expects on EVM chains.
50
+ */
51
+ export interface LazerStreamUpdated {
52
+ type: "streamUpdated";
53
+ subscriptionId: number;
54
+ parsed: {
55
+ /** Microsecond Unix timestamp as a string (does not fit in JS Number for far-future values). */
56
+ timestampUs: string;
57
+ priceFeeds: LazerPriceFeedUpdate[];
58
+ };
59
+ evm?: LazerVerifiablePayload;
60
+ solana?: LazerVerifiablePayload;
61
+ leEcdsa?: LazerVerifiablePayload;
62
+ leUnsigned?: LazerVerifiablePayload;
63
+ }
64
+ //# sourceMappingURL=lazerPayloadTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazerPayloadTypes.d.ts","sourceRoot":"","sources":["../../../../../../lib/priceFeeds/pyth/lazer/lazerPayloadTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,CAAC;AAExB;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,KAAK,GACL,MAAM,GACN,QAAQ,GACR,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,eAAe,CAAC;IAC7B,wFAAwF;IACxF,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,kBAAkB,CAAC;IAClC,kEAAkE;IAClE,mBAAmB,EAAE,MAAM,CAAC;IAG5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,eAAe,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE;QACN,gGAAgG;QAChG,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,oBAAoB,EAAE,CAAC;KACpC,CAAC;IACF,GAAG,CAAC,EAAE,sBAAsB,CAAC;IAC7B,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,UAAU,CAAC,EAAE,sBAAsB,CAAC;CACrC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ import { CombinedPriceData } from "../../interfaces";
2
+ import { PythLazerFeedId } from "./lazerFeedConstants";
3
+ import { LazerChannel } from "./lazerPayloadTypes";
4
+ export interface GetLazerPriceOptions {
5
+ /** Update channel to query. Defaults to `real_time`. */
6
+ channel?: LazerChannel;
7
+ /** Pair identifier included in error messages for context. */
8
+ pairId?: number;
9
+ /** Override the Lazer history base URL (e.g. for testing). */
10
+ baseUrl?: string;
11
+ }
12
+ /**
13
+ * Fetch unsigned historical price data from Pyth Lazer's History REST API
14
+ * for a single feed id at a specific timestamp.
15
+ *
16
+ * Returns the price snapshot the History API resolves at that timestamp.
17
+ * Throws if the API returns no row for the feed.
18
+ *
19
+ * @param feedId - Pyth Lazer u32 feed identifier
20
+ * @param timestampSec - Unix timestamp in seconds
21
+ * @param options.channel - `real_time` | `fixed_rate@50ms` | `fixed_rate@200ms` | `fixed_rate@1000ms` (default `real_time`)
22
+ * @param options.pairId - Pair id for error message context
23
+ * @param options.baseUrl - Override the API base URL
24
+ */
25
+ export declare function getLazerPriceForTimestamp(feedId: PythLazerFeedId, timestampSec: number, options?: GetLazerPriceOptions): Promise<CombinedPriceData>;
26
+ //# sourceMappingURL=lazerPriceData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazerPriceData.d.ts","sourceRoot":"","sources":["../../../../../../lib/priceFeeds/pyth/lazer/lazerPriceData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAmDnD,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,iBAAiB,CAAC,CA2B5B"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLazerPriceForTimestamp = getLazerPriceForTimestamp;
4
+ const scales_1 = require("../../../constants/scales");
5
+ const lynxScalesUtils_1 = require("../../../lynxSystem/lynxScalesUtils");
6
+ const bignumbers_1 = require("../../../utils/bignumbers");
7
+ const LAZER_HISTORY_BASE_URL = "https://pyth.dourolabs.app";
8
+ function parseHistoryRow(row) {
9
+ const expo = row.exponent;
10
+ const price = Number(row.price);
11
+ const conf = Number(row.confidence);
12
+ const priceInScale = (0, bignumbers_1.floatToUnitsBn)(price, scales_1.PRICES_SCALE + expo);
13
+ const confInScale = (0, bignumbers_1.floatToUnitsBn)(conf, scales_1.PRICES_SCALE + expo);
14
+ return {
15
+ // History endpoint returns unsigned price data; encodedPrice stays empty.
16
+ // Verifiable bytes for on-chain submission must come from the WebSocket
17
+ // stream's `evm` field (see LazerStreamUpdated).
18
+ encodedPrice: "",
19
+ priceInUnits: (0, lynxScalesUtils_1.priceBnToFloat)(priceInScale),
20
+ priceConfidenceInUnits: (0, lynxScalesUtils_1.priceBnToFloat)(confInScale),
21
+ // publish_time is microseconds on Lazer; CombinedPriceData.priceTimestamp
22
+ // is seconds, matching the Hermes convention.
23
+ priceTimestamp: Math.floor(row.publish_time / 1000000),
24
+ priceInScale,
25
+ confInScale,
26
+ };
27
+ }
28
+ /**
29
+ * Fetch unsigned historical price data from Pyth Lazer's History REST API
30
+ * for a single feed id at a specific timestamp.
31
+ *
32
+ * Returns the price snapshot the History API resolves at that timestamp.
33
+ * Throws if the API returns no row for the feed.
34
+ *
35
+ * @param feedId - Pyth Lazer u32 feed identifier
36
+ * @param timestampSec - Unix timestamp in seconds
37
+ * @param options.channel - `real_time` | `fixed_rate@50ms` | `fixed_rate@200ms` | `fixed_rate@1000ms` (default `real_time`)
38
+ * @param options.pairId - Pair id for error message context
39
+ * @param options.baseUrl - Override the API base URL
40
+ */
41
+ async function getLazerPriceForTimestamp(feedId, timestampSec, options = {}) {
42
+ const channel = options.channel ?? "real_time";
43
+ const baseUrl = options.baseUrl ?? LAZER_HISTORY_BASE_URL;
44
+ const timestampMicros = timestampSec * 1000000;
45
+ const url = `${baseUrl}/v1/${channel}/price?ids=${feedId}&timestamp=${timestampMicros}`;
46
+ const response = await fetch(url);
47
+ if (!response.ok) {
48
+ const pairContext = options.pairId !== undefined ? ` (pair ${options.pairId})` : "";
49
+ throw new Error(`Pyth Lazer history request failed for feed ${feedId}${pairContext} at timestamp ${timestampSec}s on channel '${channel}': HTTP ${response.status}`);
50
+ }
51
+ const rows = (await response.json());
52
+ const row = Array.isArray(rows)
53
+ ? rows.find((r) => r.price_feed_id === feedId)
54
+ : undefined;
55
+ if (!row) {
56
+ const pairContext = options.pairId !== undefined ? ` (pair ${options.pairId})` : "";
57
+ throw new Error(`No price found for Pyth Lazer feed ${feedId}${pairContext} at timestamp ${timestampSec}s on channel '${channel}'`);
58
+ }
59
+ return parseHistoryRow(row);
60
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Pyth Lazer binary payload encoding format, selected per subscription.
3
+ * The chosen format determines the on-chain verifier that can validate it.
4
+ *
5
+ * - `evm` — secp256k1 ECDSA, 65-byte signature. For EVM chains
6
+ * (Ethereum, Arbitrum, Optimism, Polygon, BSC, Avalanche).
7
+ * - `solana` — Ed25519 EdDSA, 64-byte signature. For Solana / Fogo /
8
+ * Ed25519-native chains.
9
+ * - `leEcdsa` — secp256k1 ECDSA in little-endian byte order. For custom
10
+ * integrations.
11
+ * - `leUnsigned` — No signature. Off-chain / dev only.
12
+ */
13
+ export type LazerSigningFormat = "evm" | "solana" | "leEcdsa" | "leUnsigned";
14
+ /**
15
+ * Verifiable on-chain payload as returned by Pyth Lazer in the WebSocket
16
+ * `streamUpdated` message under the `evm` (or `solana`, etc.) key.
17
+ *
18
+ * The encoding is chosen by the subscriber via `jsonBinaryEncoding` on the
19
+ * subscribe request, and the server echoes the choice back in `encoding`:
20
+ * - `'base64'` (Pyth's default) — `data` is a base64 string. Smaller
21
+ * WebSocket frames; needs decoding before on-chain submission.
22
+ * - `'hex'` — `data` is a hex string (may or may not be `0x`-prefixed;
23
+ * `lazerPayloadToBytes` handles either). Larger frames, but feeds
24
+ * straight into ethers/viem `bytes` args without a decode step.
25
+ */
26
+ export interface LazerVerifiablePayload {
27
+ encoding: "base64" | "hex";
28
+ data: string;
29
+ }
30
+ /**
31
+ * Convert a Lazer verifiable payload into a 0x-prefixed hex string suitable for
32
+ * submitting as the `bytes priceUpdate` argument to `PythLazer.verifyUpdate`
33
+ * (or any EVM contract method expecting raw payload bytes).
34
+ */
35
+ export declare function lazerPayloadToBytes(payload: LazerVerifiablePayload): string;
36
+ //# sourceMappingURL=lazerSigningFormats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazerSigningFormats.d.ts","sourceRoot":"","sources":["../../../../../../lib/priceFeeds/pyth/lazer/lazerSigningFormats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,CAAC;AAE7E;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAW3E"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lazerPayloadToBytes = lazerPayloadToBytes;
4
+ /**
5
+ * Convert a Lazer verifiable payload into a 0x-prefixed hex string suitable for
6
+ * submitting as the `bytes priceUpdate` argument to `PythLazer.verifyUpdate`
7
+ * (or any EVM contract method expecting raw payload bytes).
8
+ */
9
+ function lazerPayloadToBytes(payload) {
10
+ if (payload.encoding === "hex") {
11
+ return payload.data.startsWith("0x") ? payload.data : `0x${payload.data}`;
12
+ }
13
+ // base64 → hex
14
+ const base64 = payload.data;
15
+ const binary = typeof Buffer !== "undefined"
16
+ ? Buffer.from(base64, "base64").toString("hex")
17
+ : base64ToHexBrowser(base64);
18
+ return `0x${binary}`;
19
+ }
20
+ function base64ToHexBrowser(base64) {
21
+ const binaryString = atob(base64);
22
+ let hex = "";
23
+ for (let i = 0; i < binaryString.length; i++) {
24
+ hex += binaryString.charCodeAt(i).toString(16).padStart(2, "0");
25
+ }
26
+ return hex;
27
+ }