@gibs/bridge-sdk 1.12.0 → 1.13.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 (117) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +234 -432
  3. package/dist/abis.d.ts +1 -0
  4. package/dist/bridge-limits.d.ts +103 -0
  5. package/dist/bridge-limits.js +84 -0
  6. package/dist/chain-info.d.ts +169 -0
  7. package/dist/chain-info.js +410 -0
  8. package/dist/chain-names.d.ts +160 -0
  9. package/dist/chain-names.js +200 -0
  10. package/dist/chains.d.ts +65 -0
  11. package/dist/chains.js +284 -0
  12. package/dist/config.d.ts +216 -0
  13. package/dist/config.js +493 -0
  14. package/dist/consolidated-quote.d.ts +554 -0
  15. package/dist/consolidated-quote.js +773 -0
  16. package/dist/destination-calldata.d.ts +118 -0
  17. package/dist/destination-calldata.js +152 -0
  18. package/dist/ecosystems.d.ts +217 -0
  19. package/dist/ecosystems.js +288 -0
  20. package/dist/fee-type.d.ts +10 -0
  21. package/dist/fee-type.js +9 -0
  22. package/dist/hyperliquid-execution.d.ts +152 -0
  23. package/dist/hyperliquid-execution.js +168 -0
  24. package/dist/image-links.d.ts +117 -0
  25. package/dist/image-links.js +142 -0
  26. package/dist/index.d.ts +20 -0
  27. package/dist/index.js +20 -0
  28. package/dist/lifi-execution-guard.d.ts +199 -0
  29. package/dist/lifi-execution-guard.js +400 -0
  30. package/dist/near-intents-conformance.d.ts +85 -0
  31. package/dist/near-intents-conformance.js +329 -0
  32. package/dist/near-intents-route.d.ts +47 -0
  33. package/dist/near-intents-route.js +265 -0
  34. package/dist/near-intents.d.ts +524 -0
  35. package/dist/near-intents.js +1055 -0
  36. package/dist/origin-deposit.d.ts +326 -0
  37. package/dist/origin-deposit.js +68 -0
  38. package/dist/pre-quote.d.ts +198 -0
  39. package/dist/pre-quote.js +175 -0
  40. package/dist/prices.d.ts +107 -0
  41. package/dist/prices.js +162 -0
  42. package/dist/providers.d.ts +221 -0
  43. package/dist/providers.js +157 -0
  44. package/dist/quote-fees.d.ts +102 -0
  45. package/dist/quote-fees.js +195 -0
  46. package/dist/referral.d.ts +77 -0
  47. package/dist/referral.js +72 -0
  48. package/dist/relay-currencies.d.ts +47 -0
  49. package/dist/relay-currencies.js +89 -0
  50. package/dist/relay-quote.d.ts +301 -0
  51. package/dist/relay-quote.js +983 -0
  52. package/dist/route-steps.d.ts +138 -0
  53. package/dist/route-steps.js +305 -0
  54. package/dist/routing/amounts.d.ts +80 -0
  55. package/dist/routing/amounts.js +120 -0
  56. package/dist/routing/candidate-route.d.ts +43 -0
  57. package/dist/routing/candidate-route.js +45 -0
  58. package/dist/routing/candidate.d.ts +237 -0
  59. package/dist/routing/candidate.js +96 -0
  60. package/dist/routing/carriers/ask-answer.d.ts +58 -0
  61. package/dist/routing/carriers/ask-answer.js +1 -0
  62. package/dist/routing/carriers/omnibridge.d.ts +137 -0
  63. package/dist/routing/carriers/omnibridge.js +419 -0
  64. package/dist/routing/carriers/pulsex.d.ts +111 -0
  65. package/dist/routing/carriers/pulsex.js +404 -0
  66. package/dist/routing/carriers/wrap.d.ts +25 -0
  67. package/dist/routing/carriers/wrap.js +115 -0
  68. package/dist/routing/composed-route-quality.d.ts +103 -0
  69. package/dist/routing/composed-route-quality.js +108 -0
  70. package/dist/routing/entry-chain-anchor.d.ts +88 -0
  71. package/dist/routing/entry-chain-anchor.js +55 -0
  72. package/dist/routing/format.d.ts +31 -0
  73. package/dist/routing/format.js +58 -0
  74. package/dist/routing/index.d.ts +34 -0
  75. package/dist/routing/index.js +42 -0
  76. package/dist/routing/producers.d.ts +770 -0
  77. package/dist/routing/producers.js +1564 -0
  78. package/dist/routing/providers.d.ts +26 -0
  79. package/dist/routing/providers.js +38 -0
  80. package/dist/routing/route-data.d.ts +355 -0
  81. package/dist/routing/route-data.js +1 -0
  82. package/dist/routing/search/compose.d.ts +168 -0
  83. package/dist/routing/search/compose.js +98 -0
  84. package/dist/routing/search/graph.d.ts +639 -0
  85. package/dist/routing/search/graph.js +445 -0
  86. package/dist/routing/search/plan-route-data.d.ts +244 -0
  87. package/dist/routing/search/plan-route-data.js +767 -0
  88. package/dist/routing/search/score.d.ts +324 -0
  89. package/dist/routing/search/score.js +400 -0
  90. package/dist/routing/usd-value.d.ts +17 -0
  91. package/dist/routing/usd-value.js +25 -0
  92. package/dist/settings.d.ts +692 -0
  93. package/dist/settings.js +909 -0
  94. package/dist/ton-execution.d.ts +117 -0
  95. package/dist/ton-execution.js +247 -0
  96. package/dist/tron-execution.d.ts +146 -0
  97. package/dist/tron-execution.js +239 -0
  98. package/dist/types.d.ts +51 -0
  99. package/dist/types.js +1 -0
  100. package/package.json +203 -23
  101. package/src/chain-info.test.ts +0 -968
  102. package/src/chain-info.ts +0 -498
  103. package/src/chains.test.ts +0 -123
  104. package/src/chains.ts +0 -88
  105. package/src/config.test.ts +0 -679
  106. package/src/config.ts +0 -500
  107. package/src/fee-type.test.ts +0 -45
  108. package/src/fee-type.ts +0 -14
  109. package/src/image-links.test.ts +0 -160
  110. package/src/image-links.ts +0 -65
  111. package/src/index.ts +0 -8
  112. package/src/settings.test.ts +0 -2754
  113. package/src/settings.ts +0 -875
  114. package/src/types.ts +0 -48
  115. package/tsconfig.json +0 -17
  116. package/vitest.config.ts +0 -13
  117. /package/{src/abis.ts → dist/abis.js} +0 -0
@@ -0,0 +1,692 @@
1
+ import { type Hex } from 'viem';
2
+ import type { TokenBridgeInfo } from './chain-info.js';
3
+ import { type Chains, type Pathway } from './config.js';
4
+ import { FeeType } from './fee-type.js';
5
+ import type { BridgeKey, Token } from './types.js';
6
+ export declare const oneEther: bigint;
7
+ export declare const basisPoints = 10000n;
8
+ /**
9
+ * Returns the bridge pathway (configuration) for a given bridge key, asset in, and whether to use the production pathway
10
+ * @param bridgeKey - the bridge key to use
11
+ * @param isProd - whether to use the production pathway
12
+ * @param assetIn - the asset in to bridge
13
+ * @returns the bridge pathway
14
+ */
15
+ export declare const bridgePathway: ({ bridgeKey, isProd, assetIn, }: {
16
+ bridgeKey: BridgeKey;
17
+ isProd: boolean;
18
+ assetIn: Token | null;
19
+ }) => Pathway | null;
20
+ /**
21
+ * Retrieves the amount to bridge from the amount and asset in. If either of them is nil, returns 0n
22
+ * @param amountIn - the amount to bridge
23
+ * @param assetIn - the asset in to bridge
24
+ * @returns the amount to bridge
25
+ */
26
+ export declare const amountToBridge: ({ amountIn, assetIn, }: {
27
+ amountIn: bigint | null;
28
+ assetIn: Token | null;
29
+ }) => bigint;
30
+ /**
31
+ * Calculates the bridge cost from the amount to bridge and bridge fee
32
+ * @param amountToBridge - the amount to bridge
33
+ * @param bridgeFee - the bridge fee
34
+ * @returns the bridge cost
35
+ */
36
+ export declare const bridgeCost: ({ amountToBridge, bridgeFee, }: {
37
+ amountToBridge: bigint;
38
+ bridgeFee: bigint | null;
39
+ }) => bigint | null;
40
+ /**
41
+ * Calculates the amount after bridge fee from the amount to bridge and bridge cost
42
+ * @param amountToBridge - the amount to bridge
43
+ * @param bridgeCost - the bridge cost
44
+ * @returns the amount after bridge fee
45
+ */
46
+ export declare const amountAfterBridgeFee: ({ amountToBridge, bridgeCost, }: {
47
+ amountToBridge: bigint;
48
+ bridgeCost: bigint | null;
49
+ }) => bigint | null;
50
+ /**
51
+ * Calculates the estimated amount out from the amount after bridge fee and fee
52
+ * @param amountAfterBridgeFee - the amount after bridge fee
53
+ * @param fee - the fee
54
+ * @returns the estimated amount out
55
+ */
56
+ export declare const estimatedAmountOut: ({ amountAfterBridgeFee, fee, }: {
57
+ amountAfterBridgeFee: bigint | null;
58
+ fee: bigint | null;
59
+ }) => bigint | null;
60
+ /**
61
+ * Calculates the estimated fee from the amount after bridge fee, fee, percent fee, fee type, limit, and whether to deliver the costs
62
+ * @param amountAfterBridgeFee - the amount after bridge fee
63
+ * @param fee - the fee
64
+ * @param percentFee - the percent fee
65
+ * @param feeType - the fee type
66
+ * @param limit - the limit
67
+ * @param costsToDeliver - whether to deliver the costs
68
+ * @returns the estimated fee
69
+ */
70
+ export declare const estimatedFee: ({ amountAfterBridgeFee, fee, percentFee, feeType, limit, costsToDeliver, }: {
71
+ amountAfterBridgeFee: bigint | null;
72
+ fee: bigint;
73
+ percentFee: bigint;
74
+ feeType: FeeType;
75
+ limit: bigint | null;
76
+ costsToDeliver: boolean;
77
+ }) => bigint | null;
78
+ /**
79
+ * Calculates the estimated native network cost from the estimated gas and latest base fee per gas
80
+ * @param estimatedGas - the estimated gas
81
+ * @param latestBaseFeePerGas - the latest base fee per gas
82
+ * @param requiresDelivery - whether to deliver the costs
83
+ * @returns the estimated native network cost
84
+ */
85
+ export declare const estimatedNativeNetworkCost: ({ estimatedGas, latestBaseFeePerGas, requiresDelivery, }: {
86
+ estimatedGas: bigint | null;
87
+ latestBaseFeePerGas: bigint | null;
88
+ requiresDelivery: boolean;
89
+ }) => bigint | null;
90
+ /**
91
+ * Calculates the estimated token network cost from the estimated native
92
+ * network cost, price corrective, decimals, and one token int
93
+ * @param estimatedNativeNetworkCost - the estimated native network cost
94
+ * @param priceCorrective - the price corrective
95
+ * @param decimals - the decimals
96
+ * @param oneTokenInt - the one token int
97
+ * @returns the estimated token network cost
98
+ */
99
+ export declare const estimatedTokenNetworkCost: ({ estimatedNativeNetworkCost, priceCorrective, decimals, oneTokenInt, }: {
100
+ estimatedNativeNetworkCost: bigint | null;
101
+ priceCorrective: bigint | null;
102
+ decimals: number | null;
103
+ oneTokenInt: bigint | null;
104
+ }) => bigint | null;
105
+ /**
106
+ * Calculates one token of the asset in as an int
107
+ * @param assetIn - the asset in to bridge
108
+ * @returns the one token int
109
+ */
110
+ export declare const oneTokenInt: ({ assetIn }: {
111
+ assetIn: Token | null;
112
+ }) => bigint;
113
+ /**
114
+ * Returns the limit as a bigint. Nil uses 0n
115
+ * @param lim - the limit
116
+ * @returns the limit
117
+ */
118
+ export declare const limit: (lim: bigint | null) => bigint;
119
+ /**
120
+ * Returns the network switch asset out address from the asset out, unwrap, and to chain
121
+ * @param assetOut - the asset out
122
+ * @param unwrap - whether to unwrap
123
+ * @param toChain - the chain to switch to
124
+ * @returns the network switch asset out address
125
+ */
126
+ export declare const networkSwitchAssetOutAddress: ({ assetOut, unwrap, toChain, }: {
127
+ assetOut: Token | null;
128
+ unwrap: boolean;
129
+ toChain: Chains;
130
+ }) => string | null;
131
+ /**
132
+ * Calculates the desired excess compensation basis points from the path, asset in, asset out, bridge key, fee type, list, and asset out address
133
+ * @param path - the path
134
+ * @param assetIn - the asset in to bridge
135
+ * @param assetOut - the asset out
136
+ * @param bridgeKey - the bridge key
137
+ * @param feeType - the fee type
138
+ * @param list - the list
139
+ * @param assetOutAddress - the asset out address
140
+ * @returns the desired excess compensation basis points
141
+ */
142
+ export declare const desiredExcessCompensationBasisPoints: ({ path, assetIn, assetOut, bridgeKey, feeType, list, assetOutAddress, }: {
143
+ path: Pathway | null;
144
+ assetIn: Token | null;
145
+ assetOut: Token | null;
146
+ bridgeKey: BridgeKey;
147
+ feeType: FeeType;
148
+ list: Set<string>;
149
+ assetOutAddress: string | null;
150
+ }) => 0n | 10000n | 1000n | 5000n;
151
+ /**
152
+ * What the Gibs delivery service takes from a transfer, stated so a reader can
153
+ * tell "no delivery" from "delivery not yet priced".
154
+ *
155
+ * WHY A UNION AND NOT A NULLABLE AMOUNT. The function this replaced returned null
156
+ * both when the reader switched delivery off and when the fee was not known yet. Those
157
+ * two mean opposite things for a route's cost: the first is a real zero, the
158
+ * second makes any total a guess. A cost built from the null could only pick one
159
+ * reading, and whichever it picked was wrong half the time.
160
+ *
161
+ * - `not-requested` — nothing is delivered for a fee, so the fee is zero.
162
+ * - `requested` — delivery is on. `amount` is null until it is known.
163
+ *
164
+ * The amount is in base units of the token the destination router receives:
165
+ * the delivery router takes its fee from the value that arrives on the
166
+ * destination chain, after the bridge's own fee.
167
+ */
168
+ export type DeliveryFee = {
169
+ status: 'not-requested';
170
+ } | {
171
+ status: 'requested';
172
+ /** The fee in base units of the delivered token, or null while unknown. */
173
+ amount: bigint | null;
174
+ /**
175
+ * The share of the arriving value the fee takes, as a fraction of one
176
+ * ether (5e14 is 0.05%). Null when the fee is not a share of the value
177
+ * (fixed and gas modes) or the share is not known yet.
178
+ */
179
+ rate: bigint | null;
180
+ };
181
+ /**
182
+ * Works out the Gibs delivery fee for a transfer, as a {@link DeliveryFee}.
183
+ *
184
+ * Each mode reads the SAME figure the delivered estimate subtracts
185
+ * ({@link estimatedFee}), so a route's cost and its delivered value reconcile:
186
+ *
187
+ * - percent: the arriving value times the rate. The router computes
188
+ * `value * multiplier / 1 ether`.
189
+ * - fixed: the fixed amount. The router takes `limit` as the fee.
190
+ * - gas: the limit. The router takes the gas cost, capped at the limit, so the
191
+ * limit is the most the reader pays and the figure the delivered estimate
192
+ * already assumes.
193
+ *
194
+ * `percentFee` must be null when the rate is not known. Passing a zero stand-in
195
+ * would state a free delivery.
196
+ *
197
+ * @param options.shouldDeliver - whether the reader asked for delivery
198
+ * @param options.routeOffersDelivery - whether this pathway delivers for a fee at all
199
+ * @param options.feeType - the delivery fee mode
200
+ * @param options.amountAfterBridgeFee - the value that reaches the destination router, or null
201
+ * @param options.percentFee - the percent rate as a fraction of one ether, or null when unknown
202
+ * @param options.fixedFee - the fixed fee in base units, or null when unknown
203
+ * @param options.limit - the gas mode cap in base units, or null when unknown
204
+ * @returns the delivery fee
205
+ */
206
+ export declare const deliveryFee: ({ shouldDeliver, routeOffersDelivery, feeType, amountAfterBridgeFee, percentFee, fixedFee, limit, }: {
207
+ shouldDeliver: boolean;
208
+ routeOffersDelivery: boolean;
209
+ feeType: FeeType;
210
+ amountAfterBridgeFee: bigint | null;
211
+ percentFee: bigint | null;
212
+ fixedFee: bigint | null;
213
+ limit: bigint | null;
214
+ }) => DeliveryFee;
215
+ /**
216
+ * Calculates the reasonable fixed fee from the estimated token network cost and desired excess compensation basis points
217
+ * @param estimatedTokenNetworkCost - the estimated token network cost
218
+ * @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
219
+ * @returns the reasonable fixed fee
220
+ */
221
+ export declare const reasonableFixedFee: ({ estimatedTokenNetworkCost, desiredExcessCompensationBasisPoints, }: {
222
+ estimatedTokenNetworkCost: bigint | null;
223
+ desiredExcessCompensationBasisPoints: bigint;
224
+ }) => bigint | null;
225
+ /**
226
+ * Calculates the reasonable percent on gas limit from the gas tip fee and estimated token network cost
227
+ * @param gasTipFee - the gas tip fee
228
+ * @param estimatedTokenNetworkCost - the estimated token network cost
229
+ * @returns the reasonable percent on gas limit
230
+ */
231
+ export declare const reasonablePercentOnGasLimit: ({ gasTipFee, estimatedTokenNetworkCost, }: {
232
+ gasTipFee: bigint | null;
233
+ estimatedTokenNetworkCost: bigint | null;
234
+ }) => bigint;
235
+ /**
236
+ * Calculates the reasonable percent fee from the reasonable fixed fee and amount after bridge fee
237
+ * @param reasonableFixedFee - the reasonable fixed fee
238
+ * @param amountAfterBridgeFee - the amount after bridge fee
239
+ * @returns the reasonable percent fee
240
+ */
241
+ export declare const reasonablePercentFee: ({ reasonableFixedFee, amountAfterBridgeFee, }: {
242
+ reasonableFixedFee: bigint | null;
243
+ amountAfterBridgeFee: bigint | null;
244
+ }) => bigint | null;
245
+ /**
246
+ * Returns whether the asset in address is interacting with a bridge token
247
+ * @param assetLink - the asset link
248
+ * @param assetInAddress - the asset in address
249
+ * @returns whether the asset in address is interacting with a bridge token
250
+ */
251
+ export declare const interactingWithBridgeToken: ({ assetLink, assetInAddress, }: {
252
+ assetLink: TokenBridgeInfo | null;
253
+ assetInAddress: string | null;
254
+ }) => boolean;
255
+ /**
256
+ * Calculates the fee director struct encoded from the recipient, bridge pathway, fee type, price corrective, gas tip fee, percent fee, fee type settings, limit, and asset out
257
+ * @param recipient - the recipient
258
+ * @param bridgePathway - the bridge pathway
259
+ * @param feeType - the fee type
260
+ * @param priceCorrective - the price corrective
261
+ * @param gasTipFee - the gas tip fee
262
+ * @param percentFee - the percent fee
263
+ * @param feeTypeSettings - the fee type settings
264
+ * @param limit - the limit
265
+ * @param assetOut - the asset out
266
+ * @returns the fee director struct encoded
267
+ */
268
+ export declare const feeDirectorStructEncoded: ({ recipient, bridgePathway, feeType, priceCorrective, gasTipFee, percentFee, feeTypeSettings, limit, assetOut, }: {
269
+ recipient: Hex | null;
270
+ feeType: FeeType;
271
+ priceCorrective: bigint | null;
272
+ gasTipFee: bigint | null;
273
+ percentFee: bigint | null;
274
+ feeTypeSettings: bigint;
275
+ limit: bigint;
276
+ bridgePathway: Pathway | null;
277
+ assetOut: Token | null;
278
+ }) => `0x${string}` | null;
279
+ /**
280
+ * Calculates the destination data param from the recipient, bridge pathway, asset in, destination router, fee director struct encoded, asset link, should deliver, and unwrap
281
+ * @param recipient - the recipient
282
+ * @param bridgePathway - the bridge pathway
283
+ * @param assetIn - the asset in to bridge
284
+ * @param destinationRouter - the destination router
285
+ * @param feeDirectorStructEncoded - the fee director struct encoded
286
+ * @param assetLink - the asset link
287
+ * @param shouldDeliver - whether to deliver the costs
288
+ * @param unwrap - whether to unwrap
289
+ * @returns the destination data param
290
+ */
291
+ export declare const destinationDataParam: ({ recipient, bridgePathway, assetIn, destinationRouter, feeDirectorStructEncoded, assetLink, shouldDeliver, unwrap, }: {
292
+ recipient: Hex | null;
293
+ bridgePathway: Pathway | null;
294
+ assetIn: Token | null;
295
+ destinationRouter: Hex | null;
296
+ feeDirectorStructEncoded: Hex | null;
297
+ assetLink: TokenBridgeInfo | null;
298
+ shouldDeliver: boolean;
299
+ unwrap: boolean;
300
+ }) => `0x${string}` | null;
301
+ /**
302
+ * Converts a desired excess compensation basis point value into a percentage as an integer, with the denominator assumed to be 1e18
303
+ * @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
304
+ * @returns the reasonable percent on top of gas fee
305
+ */
306
+ export declare const reasonablePercentOnTopOfGasFee: ({ desiredExcessCompensationBasisPoints, }: {
307
+ desiredExcessCompensationBasisPoints: bigint;
308
+ }) => bigint;
309
+ /**
310
+ * Calculates the desired compensation ratio from the desired excess compensation basis points
311
+ * @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
312
+ * @returns the desired compensation ratio
313
+ */
314
+ export declare const desiredCompensationRatio: ({ desiredExcessCompensationBasisPoints, }: {
315
+ desiredExcessCompensationBasisPoints: bigint;
316
+ }) => bigint;
317
+ /**
318
+ * Calculates the available compensation maximum from the amount after bridge fee, percent fee, fee type, fixed fee, and limit
319
+ * @param amountAfterBridgeFee - the amount after bridge fee
320
+ * @param percentFee - the percent fee
321
+ * @param feeType - the fee type
322
+ * @param fixedFee - the fixed fee
323
+ * @param limit - the limit
324
+ * @returns the available compensation maximum
325
+ */
326
+ export declare const availableCompensationMaximum: ({ amountAfterBridgeFee, percentFee, feeType, fixedFee, limit, }: {
327
+ amountAfterBridgeFee: bigint | null;
328
+ percentFee: bigint | null;
329
+ feeType: FeeType;
330
+ fixedFee: bigint | null;
331
+ limit: bigint;
332
+ }) => bigint | null;
333
+ /**
334
+ * Determines if the bridge is undercompensated based on network costs vs compensation limit using desired compensation rate
335
+ * @param estimatedTokenNetworkCost - the estimated token network cost
336
+ * @param feeType - the fee type
337
+ * @param limit - the maximum compensation limit
338
+ * @param amountAfterBridgeFee - the amount after bridge fee
339
+ * @param desiredExcessCompensationBasisPoints - the desired excess compensation basis points
340
+ * @returns whether the bridge is undercompensated
341
+ */
342
+ export declare const isUndercompensated: ({ estimatedTokenNetworkCost, feeType, limit, amountAfterBridgeFee, desiredExcessCompensationBasisPoints, }: {
343
+ estimatedTokenNetworkCost: bigint | null;
344
+ feeType: FeeType;
345
+ limit: bigint;
346
+ amountAfterBridgeFee: bigint | null;
347
+ desiredExcessCompensationBasisPoints: bigint;
348
+ }) => boolean;
349
+ /**
350
+ * The chain pair a surface is showing the reader, in decimal chain ids.
351
+ *
352
+ * This is what the reader BELIEVES they are doing — the pair in the address bar
353
+ * and on the destination pill — as distinct from the pair the bridge key
354
+ * resolves a pathway for. The two are separate values that nothing forced to
355
+ * agree, which is the whole reason this type exists.
356
+ */
357
+ export type SignedCrossing = {
358
+ /** The chain the reader's funds start on, as the surface states it. */
359
+ originChainId: number;
360
+ /** The chain the reader asked to receive on, as the surface states it. */
361
+ destinationChainId: number;
362
+ };
363
+ /**
364
+ * Why a bridge key must not be built into a transaction for the pair on screen,
365
+ * or null when the two agree.
366
+ *
367
+ * WHY THIS EXISTS, in the reader's words: "i just tried to swap from weth from
368
+ * ethereum on pls, to pls, and the calldata that i must have signed was to
369
+ * bridge back from pls to eth". A selection of PulseChain on BOTH sides is a
370
+ * swap; it has no pathway, so the bridge key kept whatever crossing it last
371
+ * held — or the address bar was repaired to a crossing — and the settings
372
+ * cascade went on building a real, signable transfer of the reader's bridged
373
+ * wrapped ether to Ethereum while the screen still named PulseChain.
374
+ *
375
+ * Three refusals, and each one is a separate way the two can part company:
376
+ *
377
+ * - A SAME-CHAIN SELECTION IS NEVER A CROSSING. Origin and destination on one
378
+ * chain describes a swap. No omnibridge pathway can serve it, so any pathway
379
+ * reached for here belongs to some other journey.
380
+ * - THE PATHWAY MUST LEAVE THE CHAIN THE READER'S FUNDS ARE ON. A key whose
381
+ * source chain differs spends a token the reader is not looking at.
382
+ * - THE PATHWAY MUST LAND WHERE THE READER ASKED. This is the reported defect:
383
+ * the destination silently became Ethereum.
384
+ *
385
+ * `signedCrossing` is `null` for a call no reader composed — the aggregator's
386
+ * executor call built by `buildDestinationCalldata`, where the chain pair IS
387
+ * the pathway and there is no screen to disagree with. Nullable rather than
388
+ * optional so every caller has to decide, and the decision is visible at the
389
+ * call site.
390
+ *
391
+ * @param bridgeKey - the key the pathway was resolved from
392
+ * @param signedCrossing - the pair on screen, or null when no surface composed it
393
+ * @returns the reason to refuse, or null when the two agree
394
+ */
395
+ export declare const crossingRefusal: ({ bridgeKey, signedCrossing, }: {
396
+ bridgeKey: BridgeKey | null;
397
+ signedCrossing: SignedCrossing | null;
398
+ }) => string | null;
399
+ /**
400
+ * Throws when the bridge key and the pair on screen describe different journeys.
401
+ *
402
+ * The LOUD half of {@link crossingRefusal}. {@link transactionInputs} runs
403
+ * during render, where a throw would blank the application, so it refuses
404
+ * quietly by returning null and the button it feeds stays inert. This is for
405
+ * the broadcast funnel, where a disagreement means something reconstructed the
406
+ * call another way and the reader is one signature from a transfer they never
407
+ * asked for — there, silence is the worse failure.
408
+ *
409
+ * @param bridgeKey - the key the pathway was resolved from
410
+ * @param signedCrossing - the pair on screen, or null when no surface composed it
411
+ * @throws when the two describe different journeys
412
+ */
413
+ export declare const assertCrossingAgrees: ({ bridgeKey, signedCrossing, }: {
414
+ bridgeKey: BridgeKey | null;
415
+ signedCrossing: SignedCrossing | null;
416
+ }) => void;
417
+ /**
418
+ * The one chain a surface is showing the reader for a SAME-CHAIN swap — the
419
+ * PulseX leg's own equivalent of {@link SignedCrossing}.
420
+ *
421
+ * KEPT AS ITS OWN TYPE RATHER THAN A `SignedCrossing` WITH BOTH FIELDS EQUAL.
422
+ * That shape still reads as a crossing that goes nowhere, and
423
+ * {@link crossingRefusal} already treats origin-equals-destination as exactly
424
+ * that: a crossing to refuse, because no omnibridge pathway serves it. A swap
425
+ * needs to say the OPPOSITE thing about the very same fact — "this signature
426
+ * never leaves the chain, on purpose, and that is not an error" — so it needs
427
+ * a name a caller cannot confuse with a crossing.
428
+ */
429
+ export type SignedSwap = {
430
+ /** The one chain both the swap's input and output live on. */
431
+ chainId: number;
432
+ };
433
+ /**
434
+ * What a surface believes ONE signature performs: a CROSSING between two
435
+ * chains, or a SWAP that stays on one.
436
+ *
437
+ * THE DISCRIMINANT IS EXPLICIT, never inferred from
438
+ * `originChainId === destinationChainId`. Inferring it would let a same-chain
439
+ * CROSSING selection — the exact case {@link crossingRefusal} already refuses,
440
+ * because no omnibridge pathway serves it — satisfy a caller building a swap
441
+ * transaction, which is a different signature entirely.
442
+ *
443
+ * EXTENDS THE CROSSING GUARD RATHER THAN REPLACING IT. {@link SignedCrossing},
444
+ * {@link crossingRefusal}, {@link assertCrossingAgrees} and
445
+ * {@link transactionInputs} are all UNCHANGED by this type's existence: every
446
+ * crossing still refuses exactly as it did before a swap leg existed at all.
447
+ *
448
+ * FOUR KINDS, ONE PER SENDER. A two-chain move is signed three different
449
+ * ways, and each way is its own kind so a signature built for one can never
450
+ * satisfy a sender built for another:
451
+ *
452
+ * - `'crossing'` — the omnibridge's own entry or exit call, signed by the
453
+ * reader's wallet against the bridge contracts.
454
+ * - `'aggregator'` — a provider's quote (Relay, LI.FI, NEAR Intents) that the
455
+ * reader's wallet signs; the provider carries the funds, and may perform
456
+ * the omnibridge entry call itself on arrival.
457
+ * - `'deposit-address'` — nothing is signed at all: the provider reserves an
458
+ * address and the reader pays it by hand from any wallet.
459
+ * - `'swap'` — a same-chain PulseX trade or native wrap.
460
+ *
461
+ * The three two-chain kinds share {@link SignedCrossing}'s fields, because
462
+ * each one still moves funds from one chain to another.
463
+ */
464
+ export type SignedLeg = ({
465
+ kind: 'crossing';
466
+ } & SignedCrossing) | ({
467
+ kind: 'aggregator';
468
+ } & SignedCrossing) | ({
469
+ kind: 'deposit-address';
470
+ } & SignedCrossing) | ({
471
+ kind: 'swap';
472
+ } & SignedSwap);
473
+ /**
474
+ * Why a same-chain PulseX swap transaction must not be built for the leg on
475
+ * screen, or null when they agree. The swap-side sibling of
476
+ * {@link crossingRefusal}.
477
+ *
478
+ * Two refusals, each a separate way the two can part company:
479
+ *
480
+ * - THE LEG ON SCREEN NAMES A CROSSING. A caller building a swap transaction
481
+ * while the reader is looking at a two-chain crossing would sign the wrong
482
+ * kind of thing for what is on screen.
483
+ * - THE SWAP DOES NOT EXECUTE ON THE CHAIN THE READER IS LOOKING AT. A stale
484
+ * candidate built for a chain the address bar has since left.
485
+ *
486
+ * @param signedLeg - what the surface believes this signature does, or null
487
+ * when no surface composed it
488
+ * @param chainId - the chain the candidate swap transaction actually executes on
489
+ * @returns the reason to refuse, or null when the two agree
490
+ */
491
+ export declare const swapRefusal: ({ signedLeg, chainId, }: {
492
+ signedLeg: SignedLeg | null;
493
+ chainId: number | null;
494
+ }) => string | null;
495
+ /**
496
+ * Throws when the leg on screen and the candidate swap transaction describe
497
+ * different journeys. The swap-side sibling of {@link assertCrossingAgrees} —
498
+ * loud where {@link swapRefusal} is quiet, for the same reason: this runs one
499
+ * step before the wallet, where silence is what lets a reader sign.
500
+ *
501
+ * @param signedLeg - what the surface believes this signature does, or null
502
+ * @param chainId - the chain the candidate swap transaction actually executes on
503
+ * @throws when the two describe different journeys
504
+ */
505
+ export declare const assertSwapAgrees: ({ signedLeg, chainId, }: {
506
+ signedLeg: SignedLeg | null;
507
+ chainId: number | null;
508
+ }) => void;
509
+ /**
510
+ * Which priced {@link import('./routing/candidate.js').RouteCandidate} a
511
+ * route was built to sign, which of the route's `sections` that candidate's
512
+ * quote answers for, and what KIND of leg that section is.
513
+ *
514
+ * WHY A BARE CANDIDATE IDENTIFIER IS NOT ENOUGH. A route's `candidateId` names
515
+ * the priced candidate an execute button broadcasts, but names nothing about
516
+ * WHICH of the route's sections that candidate's quote is for, or whether the
517
+ * section is a two-chain CROSSING or a same-chain SWAP. A composed route can
518
+ * carry more than one section — bridge an anchor token onto PulseChain, then a
519
+ * DEFERRED PulseX swap to the token the reader actually wants — and each
520
+ * section's calldata is built by a DIFFERENT sender component, chosen by the
521
+ * route's `kind`, entirely independently of the candidate id. Nothing today
522
+ * stops a future producer from stamping a candidate id onto a route while
523
+ * leaving its leg unstated, or a future sender from reaching for a candidate
524
+ * built for one leg to sign a different one — the same shape of mistake
525
+ * {@link SignedCrossing}/{@link SignedLeg} already exist to catch for what is
526
+ * on screen, one layer up from here.
527
+ *
528
+ * `leg` reuses {@link SignedLeg}'s own discriminant deliberately: a signature
529
+ * is either a crossing or a swap everywhere else in this codebase, and a
530
+ * candidate's pick has no reason to invent a second vocabulary for the same
531
+ * fact.
532
+ */
533
+ export type CandidatePick = {
534
+ /** The {@link import('./routing/candidate.js').RouteCandidate.id} this pick names. */
535
+ readonly candidateId: string;
536
+ /** The route's `sections` index this candidate's quote signs. */
537
+ readonly sectionIndex: number;
538
+ /** Whether the signed section is a two-chain crossing or a same-chain swap. */
539
+ readonly leg: SignedLeg['kind'];
540
+ };
541
+ /**
542
+ * Why a candidate must not be signed for the leg and section a caller is
543
+ * about to build calldata for, or null when they agree. The candidate-pick
544
+ * sibling of {@link crossingRefusal}/{@link swapRefusal}.
545
+ *
546
+ * UNLIKE THOSE TWO, A MISSING PICK IS ITSELF A REFUSAL. `crossingRefusal` and
547
+ * `swapRefusal` let a null leg through because some calls compose no screen at
548
+ * all (the aggregator's own executor call). A candidate-signing sender always
549
+ * has a screen — the route the reader picked — so a candidate id with no
550
+ * recorded leg is exactly the gap this type exists to close: `candidateId`
551
+ * alone used to be treated as sufficient identity, and this function is what
552
+ * stops it from being treated that way again.
553
+ *
554
+ * @param pick - what the route recorded it picked, or null/undefined when the
555
+ * producer that built the route never set one
556
+ * @param leg - the leg the caller is about to build calldata for
557
+ * @param sectionIndex - the route section the caller is about to build
558
+ * calldata for
559
+ * @returns the reason to refuse, or null when they agree
560
+ */
561
+ export declare const candidatePickRefusal: ({ pick, leg, sectionIndex, }: {
562
+ pick: CandidatePick | null;
563
+ leg: SignedLeg["kind"];
564
+ sectionIndex: number;
565
+ }) => string | null;
566
+ /**
567
+ * Throws when a candidate pick and the leg/section a caller is about to build
568
+ * calldata for describe different signatures. The candidate-pick sibling of
569
+ * {@link assertCrossingAgrees}/{@link assertSwapAgrees} — loud where {@link
570
+ * candidatePickRefusal} is quiet, for the same reason: this runs one step
571
+ * before the wallet, where silence is what lets a reader sign the wrong thing.
572
+ *
573
+ * @param pick - what the route recorded it picked, or null
574
+ * @param leg - the leg the caller is about to build calldata for
575
+ * @param sectionIndex - the route section the caller is about to build
576
+ * calldata for
577
+ * @throws when the pick and the leg/section being built describe different
578
+ * signatures
579
+ */
580
+ export declare const assertCandidatePickAgrees: ({ pick, leg, sectionIndex, }: {
581
+ pick: CandidatePick | null;
582
+ leg: SignedLeg["kind"];
583
+ sectionIndex: number;
584
+ }) => void;
585
+ /**
586
+ * Calculates the same-chain PulseX swap transaction inputs, or null when the
587
+ * inputs cannot form a call — including when the leg on screen and the swap's
588
+ * own chain disagree. The swap-side sibling of {@link transactionInputs}.
589
+ *
590
+ * SAME SHAPE AS `transactionInputs`, deliberately: `{ to, value, data } | null`,
591
+ * so a caller can dispatch either builder's result through one `sendTransaction`
592
+ * without a second shape to handle.
593
+ *
594
+ * WRAPPING AND UNWRAPPING THE NATIVE COIN USE THE ROUTER'S OWN NATIVE-COIN
595
+ * FUNCTIONS, not a separate deposit/withdraw step — one router contract wraps
596
+ * on the way in (`swapExactETHForTokens`) and unwraps on the way out
597
+ * (`swapExactTokensForETH`), the same contract `swapExactTokensForTokens`
598
+ * already targets when neither side is native.
599
+ *
600
+ * @param signedLeg - what the surface believes this signature does, or null
601
+ * @param chainId - the chain the swap actually executes on
602
+ * @param routerAddress - the PulseX router this swap is sent to, or null when
603
+ * none is deployed for this chain
604
+ * @param fromTokenAddress - the input token address, or the zero address for
605
+ * the chain's native coin
606
+ * @param toTokenAddress - the output token address, or the zero address for
607
+ * the chain's native coin
608
+ * @param swapPath - the ordered swap path (see `pulseXConversionSwapPath`),
609
+ * already expressed in the router's own token addresses — the wrapped-native
610
+ * token stands in for either native end
611
+ * @param amountIn - the amount to swap, in the input token's base units
612
+ * @param minAmountOut - the minimum acceptable output after slippage, in the
613
+ * output token's base units
614
+ * @param recipient - the address the swap delivers to
615
+ * @param deadline - the unix-seconds deadline the router enforces
616
+ * @returns the transaction inputs, or null when the inputs cannot form a call
617
+ */
618
+ export declare const pulseXSwapTransactionInputs: ({ signedLeg, chainId, routerAddress, fromTokenAddress, toTokenAddress, swapPath, amountIn, minAmountOut, recipient, deadline, }: {
619
+ signedLeg: SignedLeg | null;
620
+ chainId: number | null;
621
+ routerAddress: Hex | null;
622
+ fromTokenAddress: Hex;
623
+ toTokenAddress: Hex;
624
+ swapPath: readonly Hex[];
625
+ amountIn: bigint;
626
+ minAmountOut: bigint;
627
+ recipient: Hex | null;
628
+ deadline: bigint;
629
+ }) => {
630
+ to: `0x${string}`;
631
+ value: bigint;
632
+ data: `0x${string}`;
633
+ } | null;
634
+ /**
635
+ * Calculates the transaction inputs from the bridge pathway, asset in, recipient, account, asset link, destination data param, amount to bridge, fee director struct encoded, and should deliver
636
+ * @param bridgeKey - the key the pathway was resolved from, for {@link crossingRefusal}
637
+ * @param signedCrossing - the chain pair on screen, or null when no surface composed it
638
+ * @param bridgePathway - the bridge pathway to use
639
+ * @param assetIn - the asset in to bridge
640
+ * @param recipient - the recipient of the bridge
641
+ * @param account - the account to bridge from
642
+ * @param assetLink - the asset link to use
643
+ * @param destinationDataParam - the destination data param to use
644
+ * @param amountToBridge - the amount to bridge
645
+ * @param feeDirectorStructEncoded - the fee director struct encoded to use
646
+ * @param shouldDeliver - whether to deliver the tokens to the recipient
647
+ * @returns the transaction inputs, or null when the inputs cannot form a call —
648
+ * including when the pathway crosses somewhere other than the pair on screen
649
+ */
650
+ export declare const transactionInputs: ({ bridgeKey, signedCrossing, bridgePathway, assetIn, recipient, account, assetLink, destinationDataParam, amountToBridge, feeDirectorStructEncoded, shouldDeliver, }: {
651
+ bridgeKey: BridgeKey | null;
652
+ signedCrossing: SignedCrossing | null;
653
+ bridgePathway: Pathway | null;
654
+ assetIn: Token | null;
655
+ recipient: Hex | null;
656
+ account: Hex | null;
657
+ assetLink: TokenBridgeInfo | null;
658
+ destinationDataParam: Hex | null;
659
+ amountToBridge: bigint;
660
+ feeDirectorStructEncoded: Hex | null;
661
+ shouldDeliver: boolean;
662
+ }) => {
663
+ to: `0x${string}`;
664
+ value: bigint;
665
+ data: `0x${string}`;
666
+ } | null;
667
+ /**
668
+ * Calculates the asset out key from the bridge key path, asset in address, and unwrap
669
+ * @param bridgeKeyPath - the bridge key path
670
+ * @param assetInAddress - the asset in address
671
+ * @param unwrap - whether to unwrap
672
+ * @returns the asset out key
673
+ */
674
+ export declare const assetOutKey: ({ bridgeKeyPath, assetInAddress, unwrap, }: {
675
+ bridgeKeyPath: string;
676
+ assetInAddress?: Hex | null;
677
+ unwrap: boolean;
678
+ }) => string | null;
679
+ /**
680
+ * Returns the asset out from the asset in address, assets out, bridge key path, and unwrap
681
+ * @param assetInAddress - the asset in address
682
+ * @param assetsOut - the assets out
683
+ * @param bridgeKeyPath - the bridge key path
684
+ * @param unwrap - whether to unwrap
685
+ * @returns the asset out
686
+ */
687
+ export declare const assetOut: ({ assetInAddress, assetsOut, bridgeKeyPath, unwrap, }: {
688
+ assetInAddress: Hex | null;
689
+ assetsOut: Map<string, Token>;
690
+ bridgeKeyPath: string;
691
+ unwrap: boolean;
692
+ }) => Token | null;