@gibs/bridge-sdk 1.13.1 → 1.18.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 (228) hide show
  1. package/README.md +295 -18
  2. package/abis/package.json +6 -0
  3. package/bridge-limits/package.json +6 -0
  4. package/chain-info/package.json +6 -0
  5. package/chain-names/package.json +6 -0
  6. package/chains/package.json +6 -0
  7. package/claims/package.json +6 -0
  8. package/config/package.json +6 -0
  9. package/consolidated-quote/package.json +6 -0
  10. package/destination-calldata/package.json +6 -0
  11. package/dist/chain-info.d.ts +1 -1
  12. package/dist/chain-info.js +11 -12
  13. package/dist/chains.d.ts +25 -0
  14. package/dist/chains.js +55 -20
  15. package/dist/cjs/abis.d.ts +1 -0
  16. package/dist/cjs/abis.js +19 -0
  17. package/dist/cjs/bridge-limits.d.ts +103 -0
  18. package/dist/cjs/bridge-limits.js +89 -0
  19. package/dist/cjs/chain-info.d.ts +169 -0
  20. package/dist/cjs/chain-info.js +452 -0
  21. package/dist/cjs/chain-names.d.ts +160 -0
  22. package/dist/cjs/chain-names.js +207 -0
  23. package/dist/cjs/chains.d.ts +90 -0
  24. package/dist/cjs/chains.js +357 -0
  25. package/dist/cjs/claims.d.ts +198 -0
  26. package/dist/cjs/claims.js +182 -0
  27. package/dist/cjs/config.d.ts +255 -0
  28. package/dist/cjs/config.js +569 -0
  29. package/dist/cjs/consolidated-quote.d.ts +648 -0
  30. package/dist/cjs/consolidated-quote.js +1048 -0
  31. package/dist/cjs/destination-calldata.d.ts +118 -0
  32. package/dist/cjs/destination-calldata.js +156 -0
  33. package/dist/cjs/ecosystems.d.ts +217 -0
  34. package/dist/cjs/ecosystems.js +298 -0
  35. package/dist/cjs/execution.d.ts +359 -0
  36. package/dist/cjs/execution.js +495 -0
  37. package/dist/cjs/fee-type.d.ts +10 -0
  38. package/dist/cjs/fee-type.js +10 -0
  39. package/dist/cjs/hyperliquid-execution.d.ts +152 -0
  40. package/dist/cjs/hyperliquid-execution.js +175 -0
  41. package/dist/cjs/image-links.d.ts +117 -0
  42. package/dist/cjs/image-links.js +153 -0
  43. package/dist/cjs/index.d.ts +24 -0
  44. package/dist/cjs/index.js +40 -0
  45. package/dist/cjs/lifi-execution-guard.d.ts +210 -0
  46. package/dist/cjs/lifi-execution-guard.js +409 -0
  47. package/dist/cjs/near-intents-conformance.d.ts +85 -0
  48. package/dist/cjs/near-intents-conformance.js +337 -0
  49. package/dist/cjs/near-intents-route.d.ts +47 -0
  50. package/dist/cjs/near-intents-route.js +303 -0
  51. package/dist/cjs/near-intents.d.ts +524 -0
  52. package/dist/cjs/near-intents.js +1071 -0
  53. package/dist/cjs/origin-deposit.d.ts +326 -0
  54. package/dist/cjs/origin-deposit.js +82 -0
  55. package/dist/cjs/package.json +3 -0
  56. package/dist/cjs/pre-quote.d.ts +198 -0
  57. package/dist/cjs/pre-quote.js +180 -0
  58. package/dist/cjs/prices.d.ts +117 -0
  59. package/dist/cjs/prices.js +224 -0
  60. package/dist/cjs/providers.d.ts +238 -0
  61. package/dist/cjs/providers.js +171 -0
  62. package/dist/cjs/quote-fees.d.ts +102 -0
  63. package/dist/cjs/quote-fees.js +201 -0
  64. package/dist/cjs/referral.d.ts +85 -0
  65. package/dist/cjs/referral.js +85 -0
  66. package/dist/cjs/relay-currencies.d.ts +47 -0
  67. package/dist/cjs/relay-currencies.js +95 -0
  68. package/dist/cjs/relay-depository.d.ts +2 -0
  69. package/dist/cjs/relay-depository.js +85 -0
  70. package/dist/cjs/relay-quote.d.ts +301 -0
  71. package/dist/cjs/relay-quote.js +996 -0
  72. package/dist/cjs/route-steps.d.ts +138 -0
  73. package/dist/cjs/route-steps.js +310 -0
  74. package/dist/cjs/routing/amounts.d.ts +80 -0
  75. package/dist/cjs/routing/amounts.js +126 -0
  76. package/dist/cjs/routing/candidate-route.d.ts +43 -0
  77. package/dist/cjs/routing/candidate-route.js +50 -0
  78. package/dist/cjs/routing/candidate.d.ts +237 -0
  79. package/dist/cjs/routing/candidate.js +100 -0
  80. package/dist/cjs/routing/carrier-provider-key.d.ts +31 -0
  81. package/dist/cjs/routing/carrier-provider-key.js +42 -0
  82. package/dist/cjs/routing/carriers/ask-answer.d.ts +77 -0
  83. package/dist/cjs/routing/carriers/ask-answer.js +2 -0
  84. package/dist/cjs/routing/carriers/omnibridge.d.ts +137 -0
  85. package/dist/cjs/routing/carriers/omnibridge.js +459 -0
  86. package/dist/cjs/routing/carriers/pulsex-paths.d.ts +80 -0
  87. package/dist/cjs/routing/carriers/pulsex-paths.js +97 -0
  88. package/dist/cjs/routing/carriers/pulsex-split.d.ts +175 -0
  89. package/dist/cjs/routing/carriers/pulsex-split.js +193 -0
  90. package/dist/cjs/routing/carriers/pulsex.d.ts +184 -0
  91. package/dist/cjs/routing/carriers/pulsex.js +615 -0
  92. package/dist/cjs/routing/carriers/wrap.d.ts +25 -0
  93. package/dist/cjs/routing/carriers/wrap.js +119 -0
  94. package/dist/cjs/routing/composed-route-quality.d.ts +125 -0
  95. package/dist/cjs/routing/composed-route-quality.js +144 -0
  96. package/dist/cjs/routing/entry-chain-anchor.d.ts +88 -0
  97. package/dist/cjs/routing/entry-chain-anchor.js +59 -0
  98. package/dist/cjs/routing/format.d.ts +31 -0
  99. package/dist/cjs/routing/format.js +64 -0
  100. package/dist/cjs/routing/index.d.ts +42 -0
  101. package/dist/cjs/routing/index.js +142 -0
  102. package/dist/cjs/routing/producers.d.ts +770 -0
  103. package/dist/cjs/routing/producers.js +1617 -0
  104. package/dist/cjs/routing/providers.d.ts +31 -0
  105. package/dist/cjs/routing/providers.js +48 -0
  106. package/dist/cjs/routing/route-data.d.ts +397 -0
  107. package/dist/cjs/routing/route-data.js +2 -0
  108. package/dist/cjs/routing/search/compose.d.ts +168 -0
  109. package/dist/cjs/routing/search/compose.js +104 -0
  110. package/dist/cjs/routing/search/graph.d.ts +668 -0
  111. package/dist/cjs/routing/search/graph.js +461 -0
  112. package/dist/cjs/routing/search/plan-route-data.d.ts +285 -0
  113. package/dist/cjs/routing/search/plan-route-data.js +871 -0
  114. package/dist/cjs/routing/search/score.d.ts +356 -0
  115. package/dist/cjs/routing/search/score.js +445 -0
  116. package/dist/cjs/routing/swap-transactions.d.ts +95 -0
  117. package/dist/cjs/routing/swap-transactions.js +133 -0
  118. package/dist/cjs/routing/usd-value.d.ts +17 -0
  119. package/dist/cjs/routing/usd-value.js +29 -0
  120. package/dist/cjs/settings.d.ts +785 -0
  121. package/dist/cjs/settings.js +1074 -0
  122. package/dist/cjs/swap-venues.d.ts +43 -0
  123. package/dist/cjs/swap-venues.js +29 -0
  124. package/dist/cjs/ton-connect.d.ts +98 -0
  125. package/dist/cjs/ton-connect.js +206 -0
  126. package/dist/cjs/ton-execution.d.ts +7 -0
  127. package/dist/cjs/ton-execution.js +23 -0
  128. package/dist/cjs/ton.d.ts +37 -0
  129. package/dist/cjs/ton.js +83 -0
  130. package/dist/cjs/tron-execution.d.ts +146 -0
  131. package/dist/cjs/tron-execution.js +248 -0
  132. package/dist/cjs/types.d.ts +51 -0
  133. package/dist/cjs/types.js +2 -0
  134. package/dist/claims.d.ts +198 -0
  135. package/dist/claims.js +140 -0
  136. package/dist/config.d.ts +42 -3
  137. package/dist/config.js +87 -21
  138. package/dist/consolidated-quote.d.ts +109 -15
  139. package/dist/consolidated-quote.js +310 -52
  140. package/dist/execution.d.ts +359 -0
  141. package/dist/execution.js +455 -0
  142. package/dist/hyperliquid-execution.js +2 -3
  143. package/dist/index.d.ts +4 -0
  144. package/dist/index.js +4 -0
  145. package/dist/lifi-execution-guard.d.ts +13 -2
  146. package/dist/lifi-execution-guard.js +4 -0
  147. package/dist/near-intents.js +2 -3
  148. package/dist/pre-quote.d.ts +6 -6
  149. package/dist/pre-quote.js +10 -14
  150. package/dist/prices.d.ts +10 -0
  151. package/dist/prices.js +52 -1
  152. package/dist/providers.d.ts +17 -0
  153. package/dist/providers.js +6 -0
  154. package/dist/referral.d.ts +12 -4
  155. package/dist/referral.js +12 -4
  156. package/dist/relay-depository.d.ts +2 -0
  157. package/dist/relay-depository.js +82 -0
  158. package/dist/relay-quote.js +2 -3
  159. package/dist/routing/candidate.d.ts +3 -3
  160. package/dist/routing/candidate.js +3 -3
  161. package/dist/routing/carrier-provider-key.d.ts +31 -0
  162. package/dist/routing/carrier-provider-key.js +37 -0
  163. package/dist/routing/carriers/ask-answer.d.ts +17 -0
  164. package/dist/routing/carriers/omnibridge.js +23 -21
  165. package/dist/routing/carriers/pulsex-paths.d.ts +80 -0
  166. package/dist/routing/carriers/pulsex-paths.js +92 -0
  167. package/dist/routing/carriers/pulsex-split.d.ts +175 -0
  168. package/dist/routing/carriers/pulsex-split.js +185 -0
  169. package/dist/routing/carriers/pulsex.d.ts +81 -46
  170. package/dist/routing/carriers/pulsex.js +267 -148
  171. package/dist/routing/composed-route-quality.d.ts +28 -6
  172. package/dist/routing/composed-route-quality.js +36 -5
  173. package/dist/routing/entry-chain-anchor.d.ts +1 -1
  174. package/dist/routing/entry-chain-anchor.js +1 -1
  175. package/dist/routing/index.d.ts +11 -3
  176. package/dist/routing/index.js +8 -2
  177. package/dist/routing/producers.js +1 -1
  178. package/dist/routing/providers.d.ts +5 -0
  179. package/dist/routing/providers.js +5 -0
  180. package/dist/routing/route-data.d.ts +47 -5
  181. package/dist/routing/search/graph.d.ts +15 -0
  182. package/dist/routing/search/plan-route-data.d.ts +42 -1
  183. package/dist/routing/search/plan-route-data.js +68 -9
  184. package/dist/routing/search/score.d.ts +3 -0
  185. package/dist/routing/search/score.js +11 -3
  186. package/dist/routing/swap-transactions.d.ts +95 -0
  187. package/dist/routing/swap-transactions.js +127 -0
  188. package/dist/settings.d.ts +94 -1
  189. package/dist/settings.js +95 -3
  190. package/dist/swap-venues.d.ts +43 -0
  191. package/dist/swap-venues.js +24 -0
  192. package/dist/ton-connect.d.ts +98 -0
  193. package/dist/ton-connect.js +200 -0
  194. package/dist/ton-execution.d.ts +4 -114
  195. package/dist/ton-execution.js +4 -244
  196. package/dist/ton.d.ts +37 -0
  197. package/dist/ton.js +65 -0
  198. package/docs/examples/example-a-ether-to-pulse.ts +300 -0
  199. package/docs/examples/example-b-token-pulsechain-to-ethereum.ts +270 -0
  200. package/docs/examples/shared.ts +261 -0
  201. package/docs/examples/tsconfig.json +18 -0
  202. package/docs/integration-guide.md +617 -0
  203. package/ecosystems/package.json +6 -0
  204. package/execution/package.json +6 -0
  205. package/fee-type/package.json +6 -0
  206. package/hyperliquid-execution/package.json +6 -0
  207. package/image-links/package.json +6 -0
  208. package/lifi-execution-guard/package.json +6 -0
  209. package/llms.txt +75 -10
  210. package/near-intents/package.json +6 -0
  211. package/near-intents-route/package.json +6 -0
  212. package/origin-deposit/package.json +6 -0
  213. package/package.json +817 -10
  214. package/pre-quote/package.json +6 -0
  215. package/prices/package.json +6 -0
  216. package/providers/package.json +6 -0
  217. package/quote-fees/package.json +6 -0
  218. package/referral/package.json +6 -0
  219. package/relay-currencies/package.json +6 -0
  220. package/relay-quote/package.json +6 -0
  221. package/route-steps/package.json +6 -0
  222. package/routing/package.json +6 -0
  223. package/settings/package.json +6 -0
  224. package/ton/package.json +6 -0
  225. package/ton-connect/package.json +6 -0
  226. package/ton-execution/package.json +6 -0
  227. package/tron-execution/package.json +6 -0
  228. package/types/package.json +6 -0
@@ -0,0 +1,569 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FOREIGN_TO_HOME_FEE = exports.HOME_TO_FOREIGN_FEE = exports.bridgeConfigs = exports.startBlocks = exports.chainIds = exports.chains = exports.canChangeUnwrap = exports.isUnwrappable = exports.isNative = exports.defaultAssetIn = exports.pathway = exports.pathwayGroup = exports.inferBridgeKey = exports.isTestnetChain = exports.validBridgeKeys = exports.testnetPathways = exports.pathways = exports.nativeTokenName = exports.nativeTokenSymbol = exports.uniV2Factories = exports.uniV2Routers = exports.defaultSwapVenues = exports.deprecatedNativeAssetOut = exports.pulsechainTokenAddresses = exports.nativeAssetOut = exports.Providers = exports.toChainKey = exports.toChain = exports.chainIdToKey = exports.Chains = void 0;
4
+ const viem_1 = require("viem");
5
+ (function (Chains) {
6
+ Chains["PLS"] = "0x171";
7
+ Chains["ETH"] = "0x1";
8
+ Chains["BNB"] = "0x38";
9
+ // testnets
10
+ Chains["SEP"] = "0xaa36a7";
11
+ Chains["V4PLS"] = "0x3af";
12
+ // TBNB = '0x61',
13
+ })(exports.Chains || (exports.Chains = {}));
14
+ /** A map of chain ids to chain keys */
15
+ exports.chainIdToKey = new Map(Object.entries(exports.Chains).map(([key, chain]) => [chain, key]));
16
+ /**
17
+ * Converts a chain id to a chain key
18
+ * @param chainId - the chain id
19
+ * @returns the chain key
20
+ */
21
+ const toChain = (chainId) => `0x${Number(chainId).toString(16)}`;
22
+ exports.toChain = toChain;
23
+ /**
24
+ * Converts a chain id to a chain key
25
+ * @param chainId - the chain id
26
+ * @returns the chain key
27
+ */
28
+ const toChainKey = (chainId) => exports.chainIdToKey.get((0, exports.toChain)(chainId));
29
+ exports.toChainKey = toChainKey;
30
+ // /** The provider of an omnibridge */
31
+ // export enum Provider {
32
+ // PULSECHAIN = 'pulsechain',
33
+ // TOKENSEX = 'tokensex',
34
+ // }
35
+ exports.Providers = {
36
+ PULSECHAIN: 'pulsechain',
37
+ TOKENSEX: 'tokensex',
38
+ };
39
+ /** A map of chains to native asset out addresses */
40
+ exports.nativeAssetOut = {
41
+ [exports.Chains.ETH]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
42
+ [exports.Chains.BNB]: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
43
+ [exports.Chains.PLS]: '0xA1077a294dDE1B09bB078844df40758a5D0f9a27',
44
+ [exports.Chains.SEP]: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9',
45
+ [exports.Chains.V4PLS]: '0x70499adEBB11Efd915E3b69E700c331778628707',
46
+ };
47
+ /**
48
+ * Four PulseChain mainnet tokens that no other constant in this package
49
+ * names. The PulseX carrier routes swaps through them
50
+ * (`routing/carriers/pulsex-paths.ts`), and the interface builds its
51
+ * PulseChain hub nodes from the two stablecoins.
52
+ *
53
+ * Each address was already in the repository before it moved here: USDC and
54
+ * USDT from the interface's `HUB_STABLECOIN_ADDRESSES`
55
+ * (`packages/ui/src/lib/state/useRouteSearch.ts`), PLSX and HEX from
56
+ * `scripts/route-parity-corpus.ts`. Each one was read on chain again on
57
+ * 2026-10-06 (`symbol()`, `decimals()`): PLSX 18, HEX 8, USDC 6, USDT 6.
58
+ * `getAddress` checksums them at load, so a mistyped character fails the
59
+ * build rather than silently matching nothing.
60
+ */
61
+ exports.pulsechainTokenAddresses = Object.freeze({
62
+ /** PulseX, the exchange's own token. */
63
+ PLSX: (0, viem_1.getAddress)('0x95b303987a60c71504d99aa1b13b4da07b0790ab'),
64
+ /** HEX. */
65
+ HEX: (0, viem_1.getAddress)('0x2b591e99afe9f32eaa6214f7b7629768c40eeb39'),
66
+ /** USD Coin, bridged from Ethereum. */
67
+ USDC: (0, viem_1.getAddress)('0x15d38573d2feeb82e7ad5187ab8c1d52810b1f07'),
68
+ /** Tether USD, bridged from Ethereum. */
69
+ USDT: (0, viem_1.getAddress)('0x0cb6f5a34ad42ec934882a05265a7d5f59b51a2f'),
70
+ });
71
+ /** A map of chains to deprecated native asset out addresses */
72
+ exports.deprecatedNativeAssetOut = {
73
+ [exports.Chains.PLS]: new Set(['0x97Ac4a2439A47c07ad535bb1188c989dae755341']),
74
+ };
75
+ /**
76
+ * Routers on chains where this package knows the router but has not verified
77
+ * a factory, so no {@link SwapVenue} can be built for them. They stay in
78
+ * {@link uniV2Routers} for the native-price reads (`chain-info.ts`,
79
+ * `readAmountOut`) that need only a router.
80
+ */
81
+ const routersWithoutVenue = {
82
+ [exports.Chains.ETH]: ['0x7a250d5630b4cf539739df2c5dacb4c659f2488d'],
83
+ [exports.Chains.BNB]: ['0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F'],
84
+ [exports.Chains.SEP]: ['0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3'],
85
+ [exports.Chains.V4PLS]: [
86
+ '0xDaE9dd3d1A52CfCe9d5F2fAC7fDe164D500E50f7',
87
+ '0x636f6407B90661b73b1C0F7e24F4C79f624d0738',
88
+ ],
89
+ };
90
+ /**
91
+ * The swap venues the package ships with: PulseX V1 then V2 on PulseChain.
92
+ * Frozen. A caller who wants other routers passes its own
93
+ * {@link SwapVenues} (see `resolveSwapVenues`); this table is never mutated.
94
+ *
95
+ * Each factory is the router's own `router.factory()` read on chain — see
96
+ * {@link uniV2Factories}'s doc. The fee is 29 basis points for both
97
+ * deployments (measured, same doc).
98
+ */
99
+ exports.defaultSwapVenues = Object.freeze({
100
+ [Number(exports.Chains.PLS)]: Object.freeze([
101
+ Object.freeze({
102
+ kind: 'uniswap-v2',
103
+ chainId: Number(exports.Chains.PLS),
104
+ router: '0x98bf93ebf5c380C0e6Ae8e192A7e2AE08edAcc02',
105
+ factory: '0x1715a3E4A142d8b698131108995174F37aEBA10D',
106
+ feeBasisPoints: 29,
107
+ label: 'PulseX V1',
108
+ }),
109
+ Object.freeze({
110
+ kind: 'uniswap-v2',
111
+ chainId: Number(exports.Chains.PLS),
112
+ router: '0x165C3410fC91EF562C50559f7d2289fEbed552d9',
113
+ factory: '0x29eA7545DEf87022BAdc76323F373EA1e707C523',
114
+ feeBasisPoints: 29,
115
+ label: 'PulseX V2',
116
+ }),
117
+ ]),
118
+ });
119
+ /** One chain's routers: its default venues' routers, else the router-only entries. */
120
+ const defaultRoutersFor = (chain) => exports.defaultSwapVenues[Number(chain)]?.map((venue) => venue.router) ?? routersWithoutVenue[chain] ?? [];
121
+ /**
122
+ * A map of chains to uni v2 router addresses. Frozen. PulseChain's entries
123
+ * derive from {@link defaultSwapVenues}, so the two cannot drift. Kept for
124
+ * compatibility; to swap on other routers pass `swapVenues` instead.
125
+ */
126
+ exports.uniV2Routers = Object.freeze(Object.fromEntries(Object.values(exports.Chains).map((chain) => [chain, Object.freeze([...defaultRoutersFor(chain)])])));
127
+ /**
128
+ * Each {@link uniV2Routers} entry's OWN factory address, same index, same
129
+ * chain — `router.factory()` read live from `one.valve.city` on 2026-09-24.
130
+ * Only PulseChain mainnet is filled: PulseX carries funds nowhere else
131
+ * (`routing/carriers/pulsex.ts`'s own `pulseXCarries`), so no other chain's
132
+ * factory has ever been needed or verified.
133
+ *
134
+ * MEASURED, NOT ASSUMED (owner Rule 13). Reading each factory's `getPair`
135
+ * and the resulting pool's `getReserves`, then recomputing `getAmountsOut`
136
+ * from the standard constant-product formula, showed the SAME fee ratio for
137
+ * both — `9971/10000` (0.29%) — to the base unit, on both a one-hop and a
138
+ * two-hop path. "V1 and V2 differ" was the assumption going in; measurement
139
+ * said otherwise, so `routing/carriers/pulsex.ts`'s `exact` uses one shared
140
+ * fee constant rather than two.
141
+ *
142
+ * `0x1715a3E4A142d8b698131108995174F37aEBA10D` (the V1 factory, index 0) is
143
+ * NOT a copy-paste of the omnibridge's Ethereum mediator address from
144
+ * `pathways` above — it is the same string on a DIFFERENT chain (PulseChain,
145
+ * not Ethereum), confirmed by reading it fresh from `one.valve.city/…/evm/369`.
146
+ * Two unrelated contracts landing on the same address on two different
147
+ * chains is possible (a shared deployer at a matching nonce, or a CREATE2
148
+ * salt collision) and worth this note so a future reader does not assume a
149
+ * transcription error and "fix" it back to something wrong.
150
+ */
151
+ exports.uniV2Factories = Object.freeze(Object.fromEntries(Object.values(exports.Chains).map((chain) => [
152
+ chain,
153
+ Object.freeze((exports.defaultSwapVenues[Number(chain)] ?? []).map((venue) => venue.factory)),
154
+ ])));
155
+ /** A map of chains to native token symbols */
156
+ exports.nativeTokenSymbol = {
157
+ [exports.Chains.PLS]: 'PLS',
158
+ [exports.Chains.V4PLS]: 'V4PLS',
159
+ [exports.Chains.ETH]: 'ETH',
160
+ [exports.Chains.SEP]: 'sepETH',
161
+ [exports.Chains.BNB]: 'BNB',
162
+ };
163
+ /** A map of chains to native token names */
164
+ exports.nativeTokenName = {
165
+ [exports.Chains.PLS]: 'Pulse',
166
+ [exports.Chains.V4PLS]: 'V4 Pulse',
167
+ [exports.Chains.ETH]: 'Ether',
168
+ [exports.Chains.SEP]: 'Sepolia Ether',
169
+ [exports.Chains.BNB]: 'BNB',
170
+ };
171
+ /** The settings for the pulsechain pls eth pathway */
172
+ const pulsechainPLSETHSettings = {
173
+ from: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
174
+ to: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
175
+ destinationRouter: '0x1F0144Ce3BDaf11944Fe0beF6444599a0500695B',
176
+ nativeRouter: '0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D',
177
+ };
178
+ exports.pathways = {
179
+ [exports.Providers.PULSECHAIN]: {
180
+ [exports.Chains.PLS]: {
181
+ [exports.Chains.ETH]: {
182
+ from: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
183
+ to: '0x1715a3E4A142d8b698131108995174F37aEBA10D',
184
+ destinationRouter: '0x2Ed02372C3efF1F239B22a901ceA8Cf6fbf82d8d',
185
+ nativeRouter: '0x612Da68aA7BcA625dD2F27f252cddB573674991A',
186
+ validator: '0x5ECfE77502317F3677f23C3b8Ab17929ACE3D74E',
187
+ usesExtraParam: false,
188
+ feeManager: 'from',
189
+ toHome: false,
190
+ requiresDelivery: true,
191
+ // weth from ethereum on pulsechain
192
+ bridgedNativeAssetOut: '0x02DcdD04e3F455D838cd1249292C58f3B79e3C3C',
193
+ settingOverrides: {
194
+ [viem_1.zeroAddress]: pulsechainPLSETHSettings,
195
+ [(0, viem_1.getAddress)(exports.nativeAssetOut[exports.Chains.PLS])]: pulsechainPLSETHSettings,
196
+ },
197
+ },
198
+ },
199
+ [exports.Chains.ETH]: {
200
+ [exports.Chains.PLS]: {
201
+ from: '0x1715a3E4A142d8b698131108995174F37aEBA10D',
202
+ to: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
203
+ nativeRouter: '0x2Ed02372C3efF1F239B22a901ceA8Cf6fbf82d8d',
204
+ destinationRouter: '0x612Da68aA7BcA625dD2F27f252cddB573674991A',
205
+ validator: '0x5ECfE77502317F3677f23C3b8Ab17929ACE3D74E',
206
+ feeManager: 'to',
207
+ usesExtraParam: false,
208
+ toHome: true,
209
+ requiresDelivery: false,
210
+ // wpls from pulsechain on ethereum
211
+ bridgedNativeAssetOut: '0xA882606494D86804B5514E07e6Bd2D6a6eE6d68A',
212
+ settingOverrides: {
213
+ [(0, viem_1.getAddress)('0xa882606494d86804b5514e07e6bd2d6a6ee6d68a')]: {
214
+ from: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
215
+ to: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
216
+ destinationRouter: '0xE66877Cfe4CEc10ffBbBB3092B7001321AB5809D',
217
+ nativeRouter: '0x1F0144Ce3BDaf11944Fe0beF6444599a0500695B',
218
+ },
219
+ },
220
+ },
221
+ },
222
+ },
223
+ [exports.Providers.TOKENSEX]: {
224
+ [exports.Chains.PLS]: {
225
+ [exports.Chains.BNB]: {
226
+ from: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
227
+ to: '0xb4005881e81a6ecd2c1f75d58e8e41f28d59c6b1',
228
+ destinationRouter: '0x9c50EfD36dF2DBD310fBC981d6D8478cF3484B85',
229
+ nativeRouter: '0xB80B80EBB375BD83a9d6c0761b197d16a8670f81',
230
+ validator: '0xc3c3d5d3ba946a2eb3906878ebe187418b0b524e',
231
+ feeManager: 'from',
232
+ usesExtraParam: true,
233
+ toHome: false,
234
+ requiresDelivery: true,
235
+ // wbnb from bsc on pulsechain (tokensex)
236
+ bridgedNativeAssetOut: '0x518076CCE3729eF1a3877EA3647a26e278e764FE',
237
+ },
238
+ },
239
+ [exports.Chains.BNB]: {
240
+ [exports.Chains.PLS]: {
241
+ from: '0xb4005881e81a6ecd2c1f75d58e8e41f28d59c6b1',
242
+ to: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
243
+ nativeRouter: '0x9c50EfD36dF2DBD310fBC981d6D8478cF3484B85',
244
+ destinationRouter: '0xB80B80EBB375BD83a9d6c0761b197d16a8670f81',
245
+ validator: '0xc3c3d5d3ba946a2eb3906878ebe187418b0b524e',
246
+ feeManager: 'to',
247
+ usesExtraParam: true,
248
+ toHome: true,
249
+ requiresDelivery: false,
250
+ // wpls from pulsechain on bsc (tokensex)
251
+ bridgedNativeAssetOut: '0xF6088134D28eeBEF7128BA41FaDb2FCA0666c64C',
252
+ },
253
+ },
254
+ },
255
+ };
256
+ exports.testnetPathways = {
257
+ [exports.Providers.TOKENSEX]: {
258
+ // plsv4 to bnb home omnibridge: 0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C
259
+ // [Chains.BNB]: {
260
+ // [Chains.V4PLS]: {
261
+ // from: '0xDDf1b0CD7fb7AAA310c703C17995c6671F9DC806',
262
+ // to: '0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C',
263
+ // usesExtraParam: false,
264
+ // requiresDelivery: false,
265
+ // toHome: true,
266
+ // feeManager: 'to',
267
+ // defaultAssetIn: {
268
+ // chainId: 56,
269
+ // address: nativeAssetOut[Chains.TBNB],
270
+ // },
271
+ // },
272
+ // },
273
+ // [Chains.V4PLS]: {
274
+ // [Chains.BNB]: {
275
+ // from: '0xfd0c07C376D27EA0E9fA64Ac5D2481439e36CF9C',
276
+ // to: '0xDDf1b0CD7fb7AAA310c703C17995c6671F9DC806',
277
+ // },
278
+ // },
279
+ },
280
+ [exports.Providers.PULSECHAIN]: {
281
+ [exports.Chains.V4PLS]: {
282
+ [exports.Chains.SEP]: {
283
+ from: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
284
+ to: '0x546e37DAA15cdb82fd1a717E5dEEa4AF08D4349A',
285
+ nativeRouter: '0xCA1BDc038909038C4B3cbab0EA0ec3cC2839F106',
286
+ destinationRouter: '0xCb4057d7DA4CE521B93b71186DfE11f9FBC3e3b1',
287
+ validator: '0xDcd4D88552c86114b2ca029F7F8d4e1a7951d051',
288
+ usesExtraParam: false,
289
+ requiresDelivery: true,
290
+ toHome: false,
291
+ feeManager: 'from',
292
+ bridgedNativeAssetOut: '0x3677bd78ccf4d299328ecfba61790cf8dbfcf686',
293
+ },
294
+ },
295
+ [exports.Chains.SEP]: {
296
+ [exports.Chains.V4PLS]: {
297
+ from: '0x546e37DAA15cdb82fd1a717E5dEEa4AF08D4349A',
298
+ to: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
299
+ nativeRouter: '0xCb4057d7DA4CE521B93b71186DfE11f9FBC3e3b1',
300
+ destinationRouter: '0xCA1BDc038909038C4B3cbab0EA0ec3cC2839F106',
301
+ validator: '0xDcd4D88552c86114b2ca029F7F8d4e1a7951d051',
302
+ usesExtraParam: false,
303
+ requiresDelivery: false,
304
+ toHome: true,
305
+ feeManager: 'to',
306
+ bridgedNativeAssetOut: '0x35807560aD0597E23F452cdc82D4Fb0e7E3c6590',
307
+ },
308
+ },
309
+ },
310
+ };
311
+ /** The mainnet bridge keys */
312
+ const mainnetBridgeKeys = [
313
+ [exports.Providers.PULSECHAIN, exports.Chains.PLS, exports.Chains.ETH],
314
+ [exports.Providers.PULSECHAIN, exports.Chains.ETH, exports.Chains.PLS],
315
+ [exports.Providers.TOKENSEX, exports.Chains.PLS, exports.Chains.BNB],
316
+ [exports.Providers.TOKENSEX, exports.Chains.BNB, exports.Chains.PLS],
317
+ ];
318
+ /** The testnet bridge keys */
319
+ const testnetBridgeKeys = [
320
+ [exports.Providers.PULSECHAIN, exports.Chains.SEP, exports.Chains.V4PLS],
321
+ [exports.Providers.PULSECHAIN, exports.Chains.V4PLS, exports.Chains.SEP],
322
+ ];
323
+ /** Returns the valid bridge keys for the given is prod */
324
+ const validBridgeKeys = (isProd) => [
325
+ ...mainnetBridgeKeys,
326
+ ...(isProd ? [] : testnetBridgeKeys),
327
+ ];
328
+ exports.validBridgeKeys = validBridgeKeys;
329
+ /** Every chain that appears only on a testnet pathway. */
330
+ const testnetChains = new Set(testnetBridgeKeys.flatMap(([, fromChain, toChain]) => [fromChain, toChain]));
331
+ /**
332
+ * Whether a chain belongs to the testnet pathway map rather than the mainnet one.
333
+ * @param chain - the chain to classify
334
+ * @returns true for Sepolia and PulseChain testnet V4
335
+ */
336
+ const isTestnetChain = (chain) => testnetChains.has(chain);
337
+ exports.isTestnetChain = isTestnetChain;
338
+ /**
339
+ * Infers the bridge key from the current key, provider, from chain, and to chain.
340
+ *
341
+ * A chain the provider does not serve falls back to the provider's first chain,
342
+ * so a provider switch lands on a real pathway. That fallback never crosses
343
+ * between the testnet and mainnet maps: when testnets are off and a requested
344
+ * chain is a testnet chain, this returns null rather than a mainnet key for a
345
+ * testnet pair.
346
+ *
347
+ * @param options.currentKey - the current bridge key
348
+ * @param options.provider - the provider
349
+ * @param options.fromChain - the from chain (defaults to the current key's)
350
+ * @param options.toChain - the to chain (defaults to the current key's)
351
+ * @param options.isProd - true leaves testnet pathways out (default false: both maps)
352
+ * @returns the inferred bridge key, or null when no pathway can honour the request
353
+ */
354
+ const inferBridgeKey = ({ currentKey, provider, fromChain, toChain, isProd = false, }) => {
355
+ const [, fromChainKey, toChainKey] = currentKey;
356
+ const from = fromChain ?? fromChainKey;
357
+ const to = toChain ?? toChainKey;
358
+ if (isProd && ((0, exports.isTestnetChain)(from) || (0, exports.isTestnetChain)(to))) {
359
+ return null;
360
+ }
361
+ const network = (0, exports.isTestnetChain)(from) ? exports.testnetPathways : exports.pathways;
362
+ const providerGroups = network[provider] ?? {};
363
+ const nextFromChain = providerGroups[from] ? from : Object.keys(providerGroups)[0];
364
+ if (!nextFromChain) {
365
+ return null;
366
+ }
367
+ const destinations = providerGroups[nextFromChain] ?? {};
368
+ const nextToChain = destinations[to] ? to : Object.keys(destinations)[0];
369
+ if (!nextToChain) {
370
+ return null;
371
+ }
372
+ return [provider, nextFromChain, nextToChain];
373
+ };
374
+ exports.inferBridgeKey = inferBridgeKey;
375
+ /**
376
+ * Returns the pathway for the given bridge key, is prod, and asset in address
377
+ * @param bridgeKey - the bridge key
378
+ * @param isProd - whether to use the production pathway
379
+ * @param assetInAddress - the asset in address
380
+ * @returns the pathway
381
+ */
382
+ /**
383
+ * The pathway group for one provider on one chain, honouring the testnet map.
384
+ *
385
+ * Exists because {@link pathway} already knew that testnet pathways live in a
386
+ * SECOND map and are only in play off production, while other callers reached
387
+ * straight into `pathways` and therefore could not see a testnet route at all.
388
+ * That is the sort of knowledge that has to live in one place: duplicated, one
389
+ * copy silently lags the other, and the symptom is a thrown "no pathway found"
390
+ * on a route the rest of the application considers perfectly valid.
391
+ *
392
+ * @param provider - the bridge provider
393
+ * @param chain - the chain being bridged FROM
394
+ * @param isProd - whether this is a production build; testnets are off when true
395
+ * @returns the group keyed by destination chain, or undefined when unknown
396
+ */
397
+ const pathwayGroup = (provider, chain, isProd) => exports.pathways[provider]?.[chain] || (!isProd ? exports.testnetPathways[provider]?.[chain] : undefined);
398
+ exports.pathwayGroup = pathwayGroup;
399
+ /**
400
+ * Reads one pathway out of a provider, chain and chain map.
401
+ *
402
+ * Every level is optional at runtime: the testnet map leaves whole providers
403
+ * out, and a caller can hold a bridge key built from untrusted input.
404
+ *
405
+ * @param config - the pathway map to read
406
+ * @param bridgeKey - the provider, origin chain and destination chain
407
+ * @returns the pathway, or undefined when any level is missing
408
+ */
409
+ const lookupPathway = (config, [provider, from, to]) => config[provider]?.[from]?.[to];
410
+ const pathway = (bridgeKey, isProd, assetInAddress) => {
411
+ if (!bridgeKey)
412
+ return;
413
+ let pathway = lookupPathway(exports.pathways, bridgeKey) ||
414
+ (!isProd ? lookupPathway(exports.testnetPathways, bridgeKey) : undefined);
415
+ if (assetInAddress) {
416
+ const addr = (0, viem_1.getAddress)(assetInAddress);
417
+ if (pathway?.settingOverrides?.[addr]) {
418
+ pathway = {
419
+ ...pathway,
420
+ ...pathway.settingOverrides[addr],
421
+ };
422
+ }
423
+ }
424
+ return pathway;
425
+ };
426
+ exports.pathway = pathway;
427
+ /**
428
+ * Returns the default asset in for the given bridge key and is prod
429
+ * @param bridgeKey - the bridge key
430
+ * @param isProd - whether to use the production pathway
431
+ * @returns the default asset in
432
+ */
433
+ const defaultAssetIn = ($bridgeKey, isProd) => {
434
+ if (!$bridgeKey)
435
+ return null;
436
+ const conf = (0, exports.pathway)($bridgeKey, isProd);
437
+ const defaultAssetIn = conf?.bridgedNativeAssetOut;
438
+ return defaultAssetIn;
439
+ };
440
+ exports.defaultAssetIn = defaultAssetIn;
441
+ /**
442
+ * Returns whether the given asset is the native asset for the given bridge key.
443
+ *
444
+ * Never throws. A token whose address is not known yet (a {@link TokenOut} for a
445
+ * not-yet-bridged token), an address that is not a valid address, and a bridge
446
+ * key with no pathway each answer false.
447
+ *
448
+ * @param asset - the asset
449
+ * @param bridgeKey - the bridge key
450
+ * @param options - which pathway maps to read; see {@link PathwayLookupOptions}
451
+ * @returns whether the given asset is the native asset for the given bridge key
452
+ */
453
+ const isNative = (asset, bridgeKey, options = {}) => {
454
+ if (!bridgeKey || !asset?.address || !(0, viem_1.isAddress)(asset.address, { strict: false })) {
455
+ return false;
456
+ }
457
+ const path = (0, exports.pathway)(bridgeKey, options.isProd ?? false);
458
+ if (!path) {
459
+ return false;
460
+ }
461
+ if ((0, viem_1.isAddressEqual)(asset.address, path.bridgedNativeAssetOut)) {
462
+ return true;
463
+ }
464
+ const wrappedNative = exports.nativeAssetOut[(0, exports.toChain)(asset.chainId)];
465
+ const isGasTokenOrItsWrapper = (0, viem_1.isAddressEqual)(asset.address, viem_1.zeroAddress) ||
466
+ (!!wrappedNative && (0, viem_1.isAddressEqual)(asset.address, wrappedNative));
467
+ return isGasTokenOrItsWrapper && !asset.name.includes(' from Pulsechain');
468
+ };
469
+ exports.isNative = isNative;
470
+ /**
471
+ * Returns whether the given asset is unwrappable for the given bridge key.
472
+ *
473
+ * Never throws: a missing or malformed address and a bridge key with no
474
+ * pathway each answer false.
475
+ *
476
+ * @param bridgeKey - the bridge key
477
+ * @param assetIn - the asset in
478
+ * @param options - which pathway maps to read; see {@link PathwayLookupOptions}
479
+ * @returns whether the given asset is unwrappable for the given bridge key
480
+ */
481
+ const isUnwrappable = (bridgeKey, assetIn, options = {}) => {
482
+ if (!bridgeKey || !assetIn?.address || !(0, viem_1.isAddress)(assetIn.address, { strict: false })) {
483
+ return false;
484
+ }
485
+ const path = (0, exports.pathway)(bridgeKey, options.isProd ?? false);
486
+ if (!path) {
487
+ return false;
488
+ }
489
+ return (0, viem_1.isAddressEqual)(path.bridgedNativeAssetOut, assetIn.address);
490
+ };
491
+ exports.isUnwrappable = isUnwrappable;
492
+ /**
493
+ * Returns whether the given asset can be unwrapped for the given bridge key
494
+ * @param bridgeKey - the bridge key
495
+ * @param assetIn - the asset in
496
+ * @param options - which pathway maps to read; see {@link PathwayLookupOptions}
497
+ * @returns boolean
498
+ */
499
+ const canChangeUnwrap = (bridgeKey, assetIn, options = {}) => {
500
+ return !!assetIn && (0, exports.isUnwrappable)(bridgeKey, assetIn, options);
501
+ };
502
+ exports.canChangeUnwrap = canChangeUnwrap;
503
+ exports.chains = {
504
+ ethereum: 1,
505
+ bsc: 56,
506
+ pulsechain: 369,
507
+ pulsechainV4: 943,
508
+ sepolia: 11155111,
509
+ };
510
+ exports.chainIds = Object.values(exports.chains);
511
+ /** Start blocks aligned with when bridge validators began operating — canonical reference for all ponder indexers in this monorepo. */
512
+ exports.startBlocks = {
513
+ ethereum: 17_264_119,
514
+ bsc: 28_987_313,
515
+ pulsechain: 17_268_300,
516
+ pulsechainV4: 16_564_233,
517
+ sepolia: 3_331_901,
518
+ };
519
+ // provider -> home -> foreign
520
+ exports.bridgeConfigs = {
521
+ [exports.Providers.PULSECHAIN]: {
522
+ [exports.chains.pulsechain]: {
523
+ [exports.chains.ethereum]: [
524
+ {
525
+ pair: 'mainnet',
526
+ key: 'erc20',
527
+ home: '0x4fD0aaa7506f3d9cB8274bdB946Ec42A1b8751Ef',
528
+ foreign: '0x1715a3e4a142d8b698131108995174f37aeba10d',
529
+ },
530
+ {
531
+ pair: 'mainnet',
532
+ key: 'native',
533
+ home: '0x0e18d0d556b652794EF12Bf68B2dC857EF5f3996',
534
+ foreign: '0xe20E337DB2a00b1C37139c873B92a0AAd3F468bF',
535
+ },
536
+ ],
537
+ },
538
+ [exports.chains.pulsechainV4]: {
539
+ [exports.chains.sepolia]: [
540
+ {
541
+ pair: 'v4',
542
+ key: 'erc20',
543
+ home: '0x6B08a50865aDeCe6e3869D9AfbB316d0a0436B6c',
544
+ foreign: '0x546e37DAA15cdb82fd1a717E5dEEa4AF08D4349A',
545
+ },
546
+ {
547
+ pair: 'v4',
548
+ key: 'native',
549
+ home: '0x81c10846F40fA2B173FC47958D0a892529983F50',
550
+ foreign: '0x5e238ef968467cf443ef5ecb683b76c5a04a0421',
551
+ },
552
+ ],
553
+ },
554
+ },
555
+ [exports.Providers.TOKENSEX]: {
556
+ [exports.chains.pulsechain]: {
557
+ [exports.chains.bsc]: [
558
+ {
559
+ pair: 'bsctokensex',
560
+ key: 'erc20',
561
+ home: '0xf1DFc63e10fF01b8c3d307529b47AefaD2154C0e',
562
+ foreign: '0xb4005881e81a6ecd2c1f75d58e8e41f28d59c6b1',
563
+ },
564
+ ],
565
+ },
566
+ },
567
+ };
568
+ exports.HOME_TO_FOREIGN_FEE = (0, viem_1.keccak256)((0, viem_1.stringToHex)('homeToForeignFee'));
569
+ exports.FOREIGN_TO_HOME_FEE = (0, viem_1.keccak256)((0, viem_1.stringToHex)('foreignToHomeFee'));