@gibs/bridge-sdk 1.12.0 → 1.13.1

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 (118) 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 +60 -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 +149 -0
  65. package/dist/routing/carriers/pulsex.js +453 -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 +653 -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 +353 -0
  89. package/dist/routing/search/score.js +427 -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/llms.txt +169 -0
  101. package/package.json +204 -23
  102. package/src/chain-info.test.ts +0 -968
  103. package/src/chain-info.ts +0 -498
  104. package/src/chains.test.ts +0 -123
  105. package/src/chains.ts +0 -88
  106. package/src/config.test.ts +0 -679
  107. package/src/config.ts +0 -500
  108. package/src/fee-type.test.ts +0 -45
  109. package/src/fee-type.ts +0 -14
  110. package/src/image-links.test.ts +0 -160
  111. package/src/image-links.ts +0 -65
  112. package/src/index.ts +0 -8
  113. package/src/settings.test.ts +0 -2754
  114. package/src/settings.ts +0 -875
  115. package/src/types.ts +0 -48
  116. package/tsconfig.json +0 -17
  117. package/vitest.config.ts +0 -13
  118. /package/{src/abis.ts → dist/abis.js} +0 -0
@@ -0,0 +1,554 @@
1
+ import type { Hex } from 'viem';
2
+ import type { DestinationCall } from './destination-calldata.js';
3
+ import type { Ecosystem } from './ecosystems.js';
4
+ import { type EvmDeposit, type OriginDeposit } from './origin-deposit.js';
5
+ import type { ProviderId, ProviderQuoteContext } from './providers.js';
6
+ import { type QuoteFee } from './quote-fees.js';
7
+ import type { RouteStep, Token } from './types.js';
8
+ /**
9
+ * The LI.FI `integrator` sent when a request leaves
10
+ * {@link ConsolidatedQuoteRequest.lifiIntegrator} out.
11
+ *
12
+ * KEPT AS A DEFAULT BECAUSE IT COSTS THE CALLER NOTHING. LI.FI's `integrator`
13
+ * is an optional label: it changes neither the quote nor the rate limit, and it
14
+ * moves no money unless a `fee` rides with it. A fee is the one case where the
15
+ * label decides who gets paid, so a request that charges a fee must name its
16
+ * own integrator — see {@link lifiAttribution}.
17
+ */
18
+ export declare const lifiIntegrator = "gibs.finance";
19
+ /** Referral fee charged by this integrator on LI.FI routes (0.001 = 0.1%). */
20
+ export declare const lifiReferralFeePercent = 0.001;
21
+ /**
22
+ * LI.FI's HTTP origin when the interface's `PUBLIC_LIFI_API_URL` build flag is
23
+ * unset. Points straight at LI.FI rather than through the server-side proxy,
24
+ * so local development and the anonymous IPFS build still get real quotes —
25
+ * at LI.FI's shared, unauthenticated tier — with no configuration at all.
26
+ */
27
+ export declare const lifiDefaultApiOrigin = "https://li.quest";
28
+ /**
29
+ * Every LI.FI endpoint address this codebase calls, built from one origin.
30
+ *
31
+ * @see {@link lifiEndpoints}
32
+ */
33
+ export type LifiEndpoints = {
34
+ /** The plain quote endpoint: carry funds and stop. A GET; parameters ride in the query string. */
35
+ readonly quote: string;
36
+ /** Quote endpoint that accepts destination contract calls. A POST. */
37
+ readonly contractCallsQuote: string;
38
+ /** Chain listing endpoint. */
39
+ readonly chains: string;
40
+ /** Builds the per-chain token listing address. */
41
+ readonly tokens: (chainId: number) => string;
42
+ /** Builds the status-poll address for an origin transaction. */
43
+ readonly status: (params: {
44
+ txHash: string;
45
+ fromChainId?: number;
46
+ toChainId?: number;
47
+ }) => string;
48
+ };
49
+ /**
50
+ * Builds every LI.FI endpoint address from one origin — THE ONE PLACE the
51
+ * `/v1/...` paths are spelled, so a caller pointed at a different origin (the
52
+ * server-side proxy at `https://lifi.gibs.finance`, or LI.FI itself) never
53
+ * duplicates them by hand.
54
+ *
55
+ * `apiOrigin` is the scheme-plus-host ONLY (e.g. `https://lifi.gibs.finance`),
56
+ * never a path — a trailing slash is trimmed, but this throws for anything
57
+ * that is not an absolute `http:`/`https:` URL, so a malformed configuration
58
+ * fails at startup rather than silently building a broken address.
59
+ *
60
+ * @param apiOrigin - the scheme-plus-host to reach LI.FI's `/v1` interface through
61
+ * @returns a frozen object of every endpoint this codebase calls
62
+ */
63
+ export declare const lifiEndpoints: (apiOrigin: string) => LifiEndpoints;
64
+ /** Quote endpoint that accepts destination contract calls, at {@link lifiDefaultApiOrigin}. */
65
+ export declare const lifiContractCallsQuoteUrl: string;
66
+ /**
67
+ * The plain quote endpoint, at {@link lifiDefaultApiOrigin}: carry funds and stop.
68
+ *
69
+ * WHICH ENDPOINT A ROUTE USES IS DECIDED BY WHETHER ANYTHING RUNS ON ARRIVAL,
70
+ * not by which chains the provider covers. A crossing into the omnibridge needs
71
+ * a call made on the entry chain, so it goes to
72
+ * {@link lifiContractCallsQuoteUrl} and arrives as one signature. A route the
73
+ * omnibridge does not touch has nothing to run on arrival, so it asks here.
74
+ *
75
+ * A GET, unlike its sibling — the parameters are a query string.
76
+ */
77
+ export declare const lifiQuoteUrl: string;
78
+ /**
79
+ * Builds the headers for a LI.FI request.
80
+ *
81
+ * CARRIES NO API KEY. LI.FI's own documentation forbids setting
82
+ * `x-lifi-api-key` in a browser — "Never expose your x-lifi-api-key in
83
+ * client-side environments such as browser-based JavaScript" — so this
84
+ * codebase never attaches one here. The key lives on the server-side proxy
85
+ * (`https://lifi.gibs.finance`) that fronts `lifiApiOrigin`, added to the
86
+ * outbound request there, never in this bundle. LI.FI answers every endpoint
87
+ * with no key at a lower, shared rate limit, so a request built from this is a
88
+ * normal operating state, not a degraded one.
89
+ *
90
+ * ONE HELPER FOR EVERY LI.FI ENDPOINT — the plain quote, the contract-calls
91
+ * quote, `/v1/chains`, `/v1/tokens`, and `/v1/status` all build their headers
92
+ * through this, rather than each call site duplicating the content-type.
93
+ */
94
+ export declare const lifiRequestHeaders: () => Record<string, string>;
95
+ /**
96
+ * Provider-agnostic input for a consolidated quote: bridge `toAmount` of the
97
+ * Ethereum-side token onto Ethereum and have the aggregator's executor perform
98
+ * `destinationCall` to relay it onward through the omnibridge.
99
+ */
100
+ /**
101
+ * The virtual-machine family of a NON-ETHEREUM origin chain. The destination
102
+ * half of a consolidated route is always an Ethereum Virtual Machine entry
103
+ * chain (Ethereum or Binance Smart Chain), so only the origin can differ, and
104
+ * "Ethereum origin" is spelled by leaving this field UNSET, never by setting
105
+ * it to `'evm'`.
106
+ *
107
+ * - `svm` — Solana Virtual Machine (base58 addresses, native lamports)
108
+ * - `bvm` — Bitcoin Virtual Machine (bech32/base58 addresses, native satoshis)
109
+ * - `tvm` — Tron Virtual Machine (base58check addresses, native sun)
110
+ * - `tonvm` — The Open Network (base64url or raw addresses, native nanotons)
111
+ * - `hypevm` — Hyperliquid (Ethereum-style accounts, HyperCore token identifiers)
112
+ * - `zcash` — a pay-by-hand origin (no wallet, no signer; see `chain-names.ts`)
113
+ *
114
+ * EXCLUDES `'evm'` ON PURPOSE. `Ecosystem` (this type's source union) includes
115
+ * `'evm'`, and until this exclusion the field's own type allowed a request to
116
+ * set `originVmType: 'evm'` explicitly — a request that CONTRADICTS "absent
117
+ * means Ethereum" without being rejected by anything. `isNonEthereumVirtualMachineOrigin`
118
+ * and every other reader here treat "absent" and "'evm'" as the same state,
119
+ * but a caller that built the request the other way used `recipient` as the
120
+ * Ethereum identity instead of the connected account, silently. Excluding
121
+ * `'evm'` from the type makes that request impossible to construct, rather
122
+ * than merely unlikely — the same shape of fix `near-intents.ts` applies to
123
+ * its own request-building for exactly this reason.
124
+ */
125
+ export type OriginVmType = Exclude<Ecosystem, 'evm'>;
126
+ export type ConsolidatedQuoteRequest = {
127
+ /** Chain the user's funds start on (any aggregator-supported chain) */
128
+ fromChainId: number;
129
+ /**
130
+ * Token the user pays with on the origin chain (zero address for an Ethereum
131
+ * Virtual Machine native asset). Typed as `string` rather than `Hex` so a
132
+ * non-Ethereum native currency address can flow through unchanged — a Solana
133
+ * base58 mint or the Bitcoin native-currency string Relay expects. Existing
134
+ * Ethereum Virtual Machine callers are unaffected: `Hex` is a subset of
135
+ * `string`, so this is a safe widening.
136
+ */
137
+ fromTokenAddress: string;
138
+ /**
139
+ * The user's address on the origin chain. Typed as `string` rather than `Hex`
140
+ * for the same reason as `fromTokenAddress`: a non-Ethereum origin carries a
141
+ * base58 (Solana) or bech32 (Bitcoin) address here. Ethereum Virtual Machine
142
+ * callers pass the same `0x` address they always have.
143
+ *
144
+ * A CHAIN THE READER PAYS BY HAND HAS NO ORIGIN ADDRESS, because no wallet
145
+ * connects to it (see `isDepositAddressChain`). Nothing reads this field for
146
+ * such a route; the refund account travels in
147
+ * {@link ConsolidatedQuoteRequest.connectedEthereumAccount} instead, under a
148
+ * name that says what it is.
149
+ */
150
+ fromAddress: string;
151
+ /**
152
+ * The reader's CONNECTED Ethereum account, exactly as the wallet connection
153
+ * reports it — never a value from any field the reader can type or a link
154
+ * can seed.
155
+ *
156
+ * Read only for an origin the reader pays by hand. There the NEAR Intents
157
+ * builder names it, lower-cased, as the refund account inside NEAR Intents:
158
+ * the reader holds no origin-chain address to refund to, and an Ethereum key
159
+ * controls the implicit NEAR account of the same name. The service accepts
160
+ * any string shaped like a NEAR account name, so its acceptance proves
161
+ * nothing — this field's source is the only proof the refund reaches the
162
+ * reader. Absent, a pay-by-hand route builds no request at all. See
163
+ * `docs/near-implicit-account-refunds.md`.
164
+ */
165
+ connectedEthereumAccount?: Hex;
166
+ /** Ethereum-side token the omnibridge mapping accepts */
167
+ toTokenAddress: Hex;
168
+ /** Guaranteed minimum amount of the Ethereum-side token arriving, in base units */
169
+ toAmount: bigint;
170
+ /**
171
+ * The omnibridge entry call the executor performs with exactly `toAmount`.
172
+ *
173
+ * ABSENT ON A ROUTE THAT DOES NOT TOUCH THE OMNIBRIDGE. Every route this type
174
+ * described used to end on PulseChain, so an entry call was always part of
175
+ * the answer: the aggregator carried funds to Ethereum or Binance Smart
176
+ * Chain, and this call handed them to the bridge. A route between two chains
177
+ * the bridge's own contracts do not run on has no such leg — the provider
178
+ * delivers to the recipient and the journey is over — so this is optional and
179
+ * its absence is what distinguishes the two kinds.
180
+ */
181
+ destinationCall?: DestinationCall;
182
+ /**
183
+ * What the reader is spending, in the origin token's base units.
184
+ *
185
+ * Carried only for a route with no {@link destinationCall}, and it is what
186
+ * makes that route a different QUESTION rather than the same one with a
187
+ * missing field. A route into the omnibridge is solved BACKWARDS: the entry
188
+ * call must receive an exact amount, so the provider is asked for an exact
189
+ * OUTPUT and works out the input. A direct route has no such constraint — the
190
+ * reader says what they are sending — so the provider is asked for an exact
191
+ * INPUT and the delivered amount is whatever the market gives.
192
+ */
193
+ fromAmount?: bigint;
194
+ /**
195
+ * Where the bridged tokens are delivered on PulseChain. Already encoded inside
196
+ * `destinationCall`; carried here as well so the resume record and the
197
+ * confirmation surface can show the destination without decoding calldata.
198
+ */
199
+ recipient: Hex;
200
+ /** Where tokens land on Ethereum if the destination call reverts */
201
+ fallbackAddress: Hex;
202
+ /** Maximum slippage as a fraction (e.g. 0.005); provider default when omitted */
203
+ slippage?: number;
204
+ /**
205
+ * The omnibridge entry chain the aggregator bridges to (Ethereum or Binance
206
+ * Smart Chain). Defaults to Ethereum when omitted, preserving the original
207
+ * single-entry behavior.
208
+ */
209
+ toChainId?: number;
210
+ /**
211
+ * Virtual-machine family of the ORIGIN chain. Defaults to Ethereum Virtual
212
+ * Machine semantics when absent, so every existing caller behaves exactly as
213
+ * before. Set to `svm` or `bvm` for a non-Ethereum origin: this is what gates
214
+ * the provider that may quote the route (only Relay can cross ecosystems) and
215
+ * what selects the origin-side refund address inside the Relay request
216
+ * builder.
217
+ */
218
+ originVmType?: OriginVmType;
219
+ /**
220
+ * Bitcoin pay-to-script-hash public key. Relay requires it via the request's
221
+ * `additionalData.userPublicKey` to construct a Bitcoin deposit. Only consulted
222
+ * for a Bitcoin origin (`originVmType` of `bvm`); ignored otherwise.
223
+ */
224
+ bitcoinPublicKey?: string;
225
+ /**
226
+ * Solana fee-payer address. Relay accepts it as `depositFeePayer` to sponsor
227
+ * the deposit transaction's fee on Solana. Only consulted for a Solana origin
228
+ * (`originVmType` of `svm`); ignored otherwise.
229
+ */
230
+ solanaFeePayer?: string;
231
+ /**
232
+ * LI.FI referral fee as a decimal fraction (e.g. 0.001 = 0.1%). When set and
233
+ * positive, forwarded as the `fee` parameter in LI.FI quote requests. Omitted
234
+ * when zero or absent so no fee is charged on unannotated requests.
235
+ */
236
+ lifiFee?: number;
237
+ /**
238
+ * The LI.FI `integrator` label. Left out, {@link lifiIntegrator} is sent;
239
+ * `null` omits the field; a string is sent as-is. REQUIRED (as a string)
240
+ * whenever {@link lifiFee} is positive: LI.FI pays a fee to the account behind
241
+ * the integrator label, so a fee under the default label would pay Gibs
242
+ * Finance, not you.
243
+ */
244
+ lifiIntegrator?: string | null;
245
+ /**
246
+ * The Relay `referrer`. Left out or `null`, the field is not sent: Relay
247
+ * reads any `referrer` as "a referrer was supplied" and then requires an API
248
+ * key, so a default would break a caller who has none. A string is sent as-is.
249
+ */
250
+ relayReferrer?: string | null;
251
+ /**
252
+ * Relay app-fee configuration. When set, the Relay quote builder attaches the
253
+ * fee recipient and basis-point amount to the request. Wired in Task 5.
254
+ */
255
+ relayAppFee?: {
256
+ recipient: Hex;
257
+ basisPoints: bigint;
258
+ };
259
+ };
260
+ /**
261
+ * Whether a consolidated quote request originates on a non-Ethereum-Virtual-
262
+ * Machine chain. A missing `originVmType` is treated as Ethereum Virtual
263
+ * Machine, so existing callers are never classified non-Ethereum.
264
+ *
265
+ * Deliberately expressed as "anything that is not Ethereum" rather than as a
266
+ * list of the non-Ethereum families. The two behaviors this gates — excluding a
267
+ * route from LI.FI, and refunding on the ORIGIN chain instead of to an Ethereum
268
+ * fallback address — are both wrong by default for an unlisted ecosystem, and a
269
+ * positive list fails open: a newly registered family would be handed to LI.FI
270
+ * with a non-Ethereum address cast to `Hex`, and would name an Ethereum address
271
+ * as its origin-chain refund target. Inverting the test makes every future
272
+ * ecosystem safe on arrival.
273
+ *
274
+ * Hyperliquid counts as non-Ethereum here despite using Ethereum-style account
275
+ * addresses: Relay's origin for it is HyperCore, whose deposit is a signed
276
+ * typed-data action posted to an API rather than a broadcast transaction, and
277
+ * which LI.FI does not carry.
278
+ *
279
+ * @param request - the consolidated quote request to classify
280
+ * @returns true when the origin is any ecosystem other than Ethereum
281
+ */
282
+ export declare const isNonEthereumVirtualMachineOrigin: (request: Pick<ConsolidatedQuoteRequest, "originVmType">) => boolean;
283
+ /** One destination contract call in the LI.FI request body. */
284
+ export type LifiContractCall = {
285
+ fromAmount: string;
286
+ fromTokenAddress: Hex;
287
+ toContractAddress: Hex;
288
+ toContractCallData: Hex;
289
+ toContractGasLimit: string;
290
+ toApprovalAddress?: Hex;
291
+ };
292
+ /** The JSON body for `POST /v1/quote/contractCalls`. */
293
+ export type LifiContractCallsRequestBody = {
294
+ fromChain: number;
295
+ fromToken: Hex;
296
+ fromAddress: Hex;
297
+ toChain: number;
298
+ toToken: Hex;
299
+ toAmount: string;
300
+ toFallbackAddress: Hex;
301
+ /** Omitted when the request set `lifiIntegrator: null`. */
302
+ integrator?: string;
303
+ /** Referral fee as a decimal fraction (e.g. 0.001 = 0.1%). Omitted when not charging a fee. */
304
+ fee?: number;
305
+ slippage?: number;
306
+ contractCalls: LifiContractCall[];
307
+ };
308
+ /**
309
+ * The attribution fields of a LI.FI request: the `integrator` label and, when
310
+ * one is charged, the referral `fee`. Shared by both LI.FI builders so the two
311
+ * endpoints can never attribute or charge differently.
312
+ *
313
+ * @param request - the consolidated request's attribution fields
314
+ * @returns the fields to merge into the request; empty when none apply
315
+ * @throws when a positive `lifiFee` arrives without an explicit `lifiIntegrator`
316
+ * string — that fee would otherwise be paid to the default integrator
317
+ */
318
+ export declare const lifiAttribution: (request: Pick<ConsolidatedQuoteRequest, "lifiFee" | "lifiIntegrator">) => {
319
+ integrator?: string;
320
+ fee?: number;
321
+ };
322
+ /**
323
+ * Builds the LI.FI contract-calls quote request from a provider-agnostic
324
+ * consolidated request. LI.FI quotes backwards from `toAmount` (the guaranteed
325
+ * minimum arriving on Ethereum), which is what makes the fixed amount inside
326
+ * the destination calldata safe.
327
+ *
328
+ * @returns the request body, or null when the inputs cannot form a valid call
329
+ */
330
+ /**
331
+ * Builds the query string for LI.FI's plain `GET /v1/quote`.
332
+ *
333
+ * THE ROUTE THIS EXISTS FOR. A crossing with no omnibridge leg had exactly one
334
+ * bidder — Relay — because our only LI.FI endpoint was the contract-calls one,
335
+ * which cannot express a route that calls nothing. Every any-to-any quote was
336
+ * therefore a price with nothing to rank it against.
337
+ *
338
+ * SOLVED FORWARDS, WHICH IS THE OPPOSITE OF ITS SIBLING. An omnibridge route is
339
+ * asked for an exact OUTPUT, because the entry call must receive an exact
340
+ * amount. Here the reader names what they spend and the delivered amount is
341
+ * whatever the market gives, so `fromAmount` is the input and the answer's
342
+ * `toAmount` is the thing that differs between providers. Ranking two forward
343
+ * quotes on what they cost compares two identical numbers — see
344
+ * `orderQuotesByCost` in the interface, which ranks these on what ARRIVES.
345
+ *
346
+ * Returns null for a request carrying a `destinationCall`: that route belongs
347
+ * to the other endpoint, and sending it here would quote a crossing that stops
348
+ * on the entry chain and never enters the bridge.
349
+ *
350
+ * @param request - the consolidated request to express
351
+ * @returns the query string, or null when this endpoint cannot express it
352
+ * @throws when `lifiFee` is positive and `lifiIntegrator` is not a string — see {@link lifiAttribution}
353
+ */
354
+ export declare const buildLifiQuoteRequest: (request: ConsolidatedQuoteRequest) => string | null;
355
+ export declare const buildLifiContractCallsRequest: (request: ConsolidatedQuoteRequest) => LifiContractCallsRequestBody | null;
356
+ /** Aggregators that can quote the consolidated route. Alias of the registry's id. */
357
+ export type ConsolidatedProvider = ProviderId;
358
+ /**
359
+ * A provider-agnostic, normalized consolidated quote. The guaranteed minimum
360
+ * arriving on Ethereum is NOT in here — the response echoes it as zero because
361
+ * the destination contract call consumes it; callers already hold it on the
362
+ * request they quoted with.
363
+ */
364
+ export type ConsolidatedQuote = {
365
+ provider: ConsolidatedProvider;
366
+ /** The provider's quote identifier, kept for support and resume records */
367
+ quoteId: string;
368
+ /** Bridging tool the provider selected (e.g. stargateV2) */
369
+ tool: string;
370
+ /** Human-readable tool name for display */
371
+ toolName: string;
372
+ /** Amount of the origin token the user pays, in base units */
373
+ fromAmount: bigint;
374
+ /**
375
+ * What the route delivers, in the destination token's base units, when the
376
+ * provider is the only one who knows.
377
+ *
378
+ * Absent on an omnibridge route and deliberately so: that route asks for an
379
+ * exact OUTPUT, so the caller already named the delivered amount and reading
380
+ * it back off the answer would be asking the provider to confirm arithmetic
381
+ * the caller did. A DIRECT route asks for an exact INPUT, so the delivered
382
+ * amount exists nowhere until the provider says it.
383
+ */
384
+ toAmount?: bigint;
385
+ /** United States dollar value of `fromAmount`, as reported by the provider */
386
+ fromAmountUsd: string | null;
387
+ /**
388
+ * United States dollar value of {@link toAmount}, as reported by the SAME
389
+ * provider that valued `fromAmount`.
390
+ *
391
+ * WHY THE PROVIDER'S OWN NUMBER AND NOT A PRICE FEED. A route's cost is the
392
+ * gap between what was paid and what arrived, and that gap is only a cost if
393
+ * both figures come from one feed — two feeds disagree by more than a small
394
+ * route's whole fee, which is how a zero-fee crossing once reported a loss.
395
+ * The provider prices both sides in one answer, so the difference is the
396
+ * route and nothing else.
397
+ *
398
+ * Absent on an omnibridge route for the same reason as {@link toAmount}: the
399
+ * provider's delivered side there is the ENTRY chain's tokens, not what
400
+ * finally lands on PulseChain, so its valuation answers a different question.
401
+ */
402
+ toAmountUsd?: string;
403
+ /** Contract the user must approve for token spends on the origin chain, null for native */
404
+ approvalAddress: Hex | null;
405
+ /** Provider's estimate of seconds until the route completes */
406
+ executionDurationSeconds: number;
407
+ /**
408
+ * Ordered list of normalized route legs the UI can display as a "steps" view.
409
+ * Empty when the provider response carries no per-leg breakdown — never undefined.
410
+ */
411
+ steps: RouteStep[];
412
+ /** The signable origin deposit for the user to submit on the source chain */
413
+ originDeposit: OriginDeposit;
414
+ /**
415
+ * What the route charges, normalized across providers.
416
+ *
417
+ * Read `includedInFromAmount` before totalling: a charge marked false is paid
418
+ * ON TOP of `fromAmount`, so `fromAmount` alone is not what the route costs.
419
+ * See `totalQuoteCostUsd`. Empty when the provider reported no breakdown -
420
+ * never undefined.
421
+ */
422
+ fees: QuoteFee[];
423
+ };
424
+ /**
425
+ * Narrows a quote's origin deposit to the Ethereum-Virtual-Machine variant.
426
+ * Throws when the deposit is not Ethereum, because the Ethereum-only execute
427
+ * path must never silently proceed on a Solana or Bitcoin payload.
428
+ */
429
+ export declare const evmDepositOf: (quote: ConsolidatedQuote) => EvmDeposit;
430
+ /**
431
+ * Normalizes a quote response from the contract-calls endpoint.
432
+ *
433
+ * A present but malformed `transactionRequest.value` fails the parse — silently
434
+ * sending zero native value would produce a transaction that under-pays the
435
+ * provider's bridging fee.
436
+ *
437
+ * REQUIRES `context.request` — see {@link lifiEvmDeposit}. Every live caller
438
+ * (`providers.ts`'s registry entry, the interface's `consolidated-quote.ts`
439
+ * store) supplies it; a caller that omits it gets a thrown
440
+ * {@link LifiExecutionRefusedError} rather than a silently unchecked
441
+ * execution transaction.
442
+ *
443
+ * @returns the normalized quote, or null when the payload shape is unexpected
444
+ * @throws {LifiExecutionRefusedError} when the response's execution
445
+ * transaction disagrees with `context.request` — see `lifi-execution-guard.ts`
446
+ */
447
+ export declare const parseLifiContractCallsQuote: (payload: unknown, context?: ProviderQuoteContext) => ConsolidatedQuote | null;
448
+ /**
449
+ * Normalizes a quote response from LI.FI's plain `GET /v1/quote`.
450
+ *
451
+ * `request` IS REQUIRED FOR AN ETHEREUM ORIGIN, though its type stays
452
+ * optional — omitting it there throws {@link LifiExecutionRefusedError}
453
+ * rather than returning an unverified deposit; see `lifiEvmDeposit`'s doc
454
+ * comment for why the type cannot say so directly. It is genuinely optional
455
+ * for a Solana or Bitcoin origin, which never reach the execution guard.
456
+ *
457
+ * @param payload - the raw JSON body from `GET /v1/quote`
458
+ * @param options.originEcosystem - the virtual-machine family the route starts from
459
+ * @param options.request - the consolidated request this response answers
460
+ * @returns the normalized quote, or null when the payload does not match that ecosystem
461
+ * @throws {LifiExecutionRefusedError} for an Ethereum origin, when `request`
462
+ * is absent or the execution transaction disagrees with it
463
+ */
464
+ export declare const parseLifiQuote: (payload: unknown, { originEcosystem, request }: {
465
+ originEcosystem: Ecosystem;
466
+ request?: ConsolidatedQuoteRequest;
467
+ }) => ConsolidatedQuote | null;
468
+ declare const consolidatedStatusValues: readonly ["NOT_FOUND", "INVALID", "PENDING", "DONE", "FAILED"];
469
+ /** Transfer status values reported by the provider's status endpoint. */
470
+ export type ConsolidatedStatusValue = (typeof consolidatedStatusValues)[number];
471
+ /** Normalized status of an in-flight consolidated bridge. */
472
+ export type ConsolidatedStatus = {
473
+ status: ConsolidatedStatusValue;
474
+ /** Provider-specific refinement (e.g. WAIT_DESTINATION_TRANSACTION, REFUNDED) */
475
+ substatus: string | null;
476
+ /** The Ethereum-side transaction hash, once the provider has executed it */
477
+ receivingTxHash: Hex | null;
478
+ /**
479
+ * Where a refund was credited, when the provider says it refunded into an
480
+ * account of its own that the reader must withdraw from. Absent or null for
481
+ * every other answer, including a refund sent straight back to the origin
482
+ * chain, which leaves the reader nothing to do.
483
+ */
484
+ refund?: ConsolidatedAccountRefund | null;
485
+ };
486
+ /**
487
+ * A refund the provider credited to an account inside its own settlement
488
+ * contract rather than sending back on chain. NEAR Intents does this for a
489
+ * pay-by-hand origin with no wallet here: the refund lands in the ledger entry
490
+ * named for the reader's lower-cased Ethereum address, and the reader has to
491
+ * withdraw it from there.
492
+ */
493
+ export type ConsolidatedAccountRefund = {
494
+ /** The ledger account the refund was credited to, lower case. */
495
+ account: string;
496
+ /** The provider's own identifier for the refunded asset, e.g. `nep141:zec.omft.near`. */
497
+ assetId: string;
498
+ /** How much was refunded, in that asset's base units, as a decimal string. */
499
+ baseUnits: string;
500
+ };
501
+ /**
502
+ * Builds the status-poll address for an origin transaction, at
503
+ * {@link lifiDefaultApiOrigin}. Chain hints narrow the provider's lookup and
504
+ * are recommended when known. `txHash` is typed as `string` rather than `Hex`
505
+ * because a non-Ethereum origin (Solana base58 signature, Bitcoin transaction
506
+ * id) is not `0x`-prefixed.
507
+ */
508
+ export declare const lifiStatusUrl: ({ txHash, fromChainId, toChainId, }: {
509
+ txHash: string;
510
+ fromChainId?: number;
511
+ toChainId?: number;
512
+ }) => string;
513
+ /**
514
+ * Normalizes a status response for an in-flight consolidated bridge.
515
+ *
516
+ * The receiving hash gates the handover from provider polling to the
517
+ * omnibridge indexer, so it must be a full 32-byte transaction hash — an
518
+ * empty or malformed value collapses to null rather than masquerading as a
519
+ * real transaction.
520
+ *
521
+ * @returns the normalized status, or null when the payload shape is unexpected
522
+ */
523
+ export declare const parseLifiStatus: (payload: unknown) => ConsolidatedStatus | null;
524
+ /**
525
+ * Chain listing endpoint, at {@link lifiDefaultApiOrigin}. Deliberately
526
+ * carries no query parameters: the `chainTypes` filter requires an API key on
527
+ * the anonymous tier (verified live 2026-06-12, error code 1010), and the
528
+ * default response is EVM-only.
529
+ */
530
+ export declare const lifiChainsUrl: string;
531
+ /** A chain the aggregator can originate a consolidated route from. */
532
+ export type ConsolidatedOriginChain = {
533
+ id: number;
534
+ name: string;
535
+ logoURI: string | null;
536
+ };
537
+ /**
538
+ * Normalizes a `GET /v1/chains` response body to mainnet EVM chains.
539
+ *
540
+ * @returns the chain list, or null when the payload shape is unexpected
541
+ */
542
+ export declare const parseLifiChains: (payload: unknown) => ConsolidatedOriginChain[] | null;
543
+ /** Builds the per-chain token listing URL, at {@link lifiDefaultApiOrigin}. */
544
+ export declare const lifiTokensUrl: (chainId: number) => string;
545
+ /**
546
+ * Normalizes a `GET /v1/tokens?chains=<id>` response body into the shared
547
+ * token shape used across the bridge frontend. Malformed entries are skipped
548
+ * rather than failing the whole list; `logoURI` is optional on the live
549
+ * interface.
550
+ *
551
+ * @returns the token list, or null when the payload shape is unexpected
552
+ */
553
+ export declare const parseLifiTokens: (payload: unknown, chainId: number) => Token[] | null;
554
+ export {};