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