@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,244 @@
1
+ import type { Provider } from '../../config.js';
2
+ import type { QuoteFee } from '../../quote-fees.js';
3
+ import type { Token } from '../../types.js';
4
+ import type { DeferredCrossing, RouteCandidate } from '../candidate.js';
5
+ import type { RouteData, RouteKind } from '../route-data.js';
6
+ import type { RouteScoreInputs } from './score.js';
7
+ import { type AssetNode, type RoutePlan } from './graph.js';
8
+ /**
9
+ * Resolves a graph node to the full display token a `RouteTokenRef` needs.
10
+ *
11
+ * `AssetNode` (`./graph.js`) is deliberately opaque about symbol, name and
12
+ * logo — see that module's own doc for why a coin and its wrapped form stay
13
+ * two distinct nodes there. Whoever built the plan already resolved every
14
+ * node against a live capability index and therefore already has this
15
+ * mapping; this module never invents one.
16
+ */
17
+ export type ResolveNodeToken = (node: AssetNode) => Token;
18
+ /**
19
+ * The plan's omnibridge provider, or null when the plan crosses no bridge
20
+ * hop at all — exactly the derivation `RouteCandidate.plan`'s own TSDoc
21
+ * (`../candidate.ts`) promises: "that same hop's `carrier`... the `to` node's
22
+ * `chainId` of the plan's LAST hop whose carrier is `'pulsechain'` or
23
+ * `'tokensex'`." Reading the LAST such hop, not the first, matters for a
24
+ * plan with two bridge crossings (an outbound leg out of PulseChain followed
25
+ * later by a separate inbound one) — not a shape any of today's four
26
+ * builders draws, but one the general search can.
27
+ *
28
+ * @param plan - the plan to derive from
29
+ * @returns the omnibridge provider, or null
30
+ */
31
+ export declare const deriveOmnibridgeProviderFromPlan: (plan: RoutePlan) => Provider | null;
32
+ /**
33
+ * The plan's entry chain id — the chain the plan's FIRST hop lands on, when
34
+ * that hop is carried by an aggregator (LI.FI, Relay or NEAR Intents); null
35
+ * when the plan's first hop IS the omnibridge itself (a direct, same-chain
36
+ * crossing — `buildDirectCrossingCandidate`'s shape) or is a PulseX swap.
37
+ *
38
+ * MATCHES `RouteCandidate.entryChainId`'S EXISTING MEANING throughout the
39
+ * candidate-based builders — "the chain the omnibridge leg starts on" — for
40
+ * every candidate that carries one, including a candidate whose aggregator
41
+ * reaches its OWN destination with no further bridge hop at all (today's
42
+ * `makeCandidate` test fixtures set `entryChainId` to the destination chain
43
+ * in exactly that case, because it is still where the aggregator's own leg
44
+ * lands).
45
+ *
46
+ * @param plan - the plan to derive from
47
+ * @returns the entry chain id, or null for a direct crossing or a swap-only plan
48
+ */
49
+ export declare const deriveEntryChainIdFromPlan: (plan: RoutePlan) => number | null;
50
+ /**
51
+ * The decimal chain ids every INTERMEDIATE hop of the plan passes through,
52
+ * origin and destination excluded — `RouteData.viaChainIds`'s own contract.
53
+ * Undefined (never an empty array) when the plan has nothing to report, per
54
+ * that field's own "ABSENT... on any route with no intermediate chain" doc.
55
+ *
56
+ * @param plan - the plan to derive from
57
+ * @returns the via chain ids in hop order, or undefined
58
+ */
59
+ export declare const deriveViaChainIdsFromPlan: (plan: RoutePlan) => number[] | undefined;
60
+ /**
61
+ * The plan's `RouteKind`, per the route-search design's section 1: `'direct'`
62
+ * when signature 1 IS the omnibridge crossing itself (no aggregator prefix —
63
+ * `buildDirectCrossingCandidate`'s shape, and `buildOutboundRouteData`'s
64
+ * shape), `'conversion'` when the LAST hop is a PulseX swap
65
+ * (`buildConversionRouteData`'s shape), `'aggregated'` otherwise (an
66
+ * aggregator carries signature 1, fused with a bridge hop or not —
67
+ * `buildNearIntentsTwoStepRouteData`'s shape, and the general
68
+ * aggregator-fused shape).
69
+ *
70
+ * DIVERGES FROM TODAY'S LITERAL OUTPUT FOR ONE CASE, DELIBERATELY: a
71
+ * same-chain candidate built by `buildDirectCrossingCandidate` and rendered
72
+ * through `buildCandidateRouteData` today always comes back `kind:
73
+ * 'aggregated'`, because that builder hard-codes `'aggregated'`
74
+ * unconditionally — an artifact of `RouteCandidate.entryChainId` being
75
+ * non-nullable, so `buildCandidateRouteData` always assumes an
76
+ * aggregator-entry shape even for a candidate with no aggregator leg at all.
77
+ * This function instead answers `'direct'` for that exact plan, matching how
78
+ * `buildDirectRouteData` (the OTHER, non-candidate 'direct' family) already
79
+ * represents the identical real-world same-chain crossing. See this
80
+ * module's test file for the specific case.
81
+ *
82
+ * @param plan - the plan to derive from
83
+ * @returns the route's kind
84
+ */
85
+ export declare const derivePlanKind: (plan: RoutePlan) => RouteKind;
86
+ /**
87
+ * The anchor a two-signature plan leaves the reader holding between its
88
+ * first and second groups — `RouteCandidate.plan`'s own TSDoc: "the anchor
89
+ * the reader is left holding between signatures... taken from the first hop
90
+ * of the second group." Reuses `describeDeferredCrossing`
91
+ * (`../../near-intents-route.js`) rather than re-validating the same
92
+ * "positive amount, resolved token" rule a second time.
93
+ *
94
+ * Null when the plan has only one signature group (there is no deferred
95
+ * crossing to describe) or the plan is malformed (a signature group naming
96
+ * hop indices the plan does not have).
97
+ *
98
+ * @param plan - the plan to derive from
99
+ * @param resolveToken - resolves a graph node to its full display token
100
+ * @param anchorUsdValue - the anchor's own carrier's valuation of the
101
+ * landing, exactly as `DeferredCrossing.anchorUsdValue` expects — supplied
102
+ * by the caller, since a plan carries no United States dollar figures.
103
+ * @returns the deferred crossing, or null
104
+ */
105
+ export declare const deriveDeferredCrossingFromPlan: (plan: RoutePlan, resolveToken: ResolveNodeToken, anchorUsdValue: string | null) => DeferredCrossing | null;
106
+ /**
107
+ * The caller-supplied dollar figures and breakdown for ONE signature group —
108
+ * everything about a section this module cannot derive from the plan's
109
+ * structure alone (see this module's head doc).
110
+ */
111
+ export type PlanSectionPricing = {
112
+ /**
113
+ * What this section leaves the user holding, in United States dollars, or
114
+ * null when unpriced — `RouteLandingData.usdValue` for this section.
115
+ */
116
+ landingUsdValue: number | null;
117
+ /** This section's own cost, in United States dollars, or null when unpriced. */
118
+ feeUsdValue: number | null;
119
+ /** The itemized charges behind `feeUsdValue`, passed straight through to `RouteSectionData.fees`. */
120
+ fees?: readonly QuoteFee[];
121
+ /** Estimated duration for this signature in minutes, or null/undefined to omit. */
122
+ etaMinutes?: number | null;
123
+ /** Estimated duration for this signature in seconds, or null/undefined to omit. */
124
+ etaSeconds?: number | null;
125
+ /** Explanation shown for a deferred section; omitted lets the display adapter supply its default. */
126
+ deferredNote?: string;
127
+ /**
128
+ * Overrides this section's `landing.amount`. Omitted (the default) uses
129
+ * the plan's own composed estimate — the group's last hop's
130
+ * `outcome.deliveredAmount` — which is always present, per design section
131
+ * 3 ("only signature 1 must be binding... every later hop['s] outcome" is
132
+ * still an estimate, never absent). Pass `null` explicitly ONLY to
133
+ * reproduce a builder that states no figure at all for a leg it has not
134
+ * yet quoted by ANY means, composed or otherwise — `buildOutboundRouteData`'s
135
+ * deferred section is the one target shape that does this; see this
136
+ * module's test file for why that is a real, if now avoidable, gap rather
137
+ * than a rule to keep by default.
138
+ */
139
+ landingAmountOverride?: bigint | null;
140
+ };
141
+ /** Everything {@link buildRouteDataFromPlan} needs beyond the plan's own structure. */
142
+ export type PlanRouteDataInputs = {
143
+ /** The priced plan to render. */
144
+ plan: RoutePlan;
145
+ /** Resolves a graph node to its full display token. */
146
+ resolveToken: ResolveNodeToken;
147
+ /** Stable identity for the route's sections, mirroring `RouteCandidate.id`. */
148
+ routeId: string;
149
+ /** One entry per signature group, in `plan.signatures` order. */
150
+ sections: readonly PlanSectionPricing[];
151
+ /** The route's aggregate all-in cost in United States dollars, or null/undefined. */
152
+ totalCostUsdValue?: number | null;
153
+ /** The route's net United States dollar outcome — the figure routes are ranked on. */
154
+ netValueUsd?: number | null;
155
+ /** Estimated end-to-end duration in minutes, or null/undefined. */
156
+ etaMinutes?: number | null;
157
+ };
158
+ /**
159
+ * Turns a priced {@link RoutePlan} into a raw {@link RouteData} — one section
160
+ * per signature group, `deferred` on every group after the first, each
161
+ * section's hops and token flow drawn structurally from the plan, and the
162
+ * dollar figures overlaid from `inputs.sections`. See this module's head doc
163
+ * for why the dollar figures are caller-supplied rather than derived here.
164
+ *
165
+ * NEVER SHOWS AN UNPRICED HEADLINE FIGURE, AND MARKS EVERY OTHER ESTIMATE AS
166
+ * ONE — PHASE 3. A section (and the route's own `output`) whose last hop is
167
+ * grounded on `EstimateBasis` `'unpriced'` lands on `amount: null`, whatever
168
+ * the caller's own pricing says, per {@link sectionLandingAmount}'s own doc.
169
+ * Every OTHER estimate (`'probe-rate'`, `'priced-conversion'`) still shows
170
+ * its figure, with `estimateBasis` set to that basis so a reader is never
171
+ * shown a composed/probed number as if it were a confirmed quote — see
172
+ * `RouteOutputData.estimateBasis`'s own doc (`../route-data.ts`) for the
173
+ * full rule this reads off {@link hopEstimateBasis}.
174
+ *
175
+ * @param inputs - the plan, a token resolver, an id, and per-section pricing
176
+ * @returns the raw route data
177
+ */
178
+ export declare const buildRouteDataFromPlan: (inputs: PlanRouteDataInputs) => RouteData;
179
+ /** Everything {@link buildRouteCandidateFromPlan} needs beyond the plan's own structure. */
180
+ export type PlanCandidateInputs = {
181
+ /** The priced plan to build a candidate for. */
182
+ plan: RoutePlan;
183
+ /** Resolves a graph node to its full display token. */
184
+ resolveToken: ResolveNodeToken;
185
+ /** Stable identity for the candidate, mirroring today's `candidate.id`. */
186
+ id: string;
187
+ /** The base-unit amount entering the plan's first hop. */
188
+ inputAmount: bigint;
189
+ /** What the reader pays for the plan's first hop, exactly as its own carrier reported it. */
190
+ paidUsdValue: string | null;
191
+ /**
192
+ * What the plan's LAST hop's own carrier valued its delivered side at —
193
+ * read only when the plan crosses no bridge hop, mirroring
194
+ * `candidateDeliveredUsd`'s no-omnibridge branch.
195
+ */
196
+ lastHopDeliveredUsdValue: string | null;
197
+ /** Per-destination-token United States dollar price, or null. */
198
+ destinationUsdPrice: number | null;
199
+ /** The omnibridge crossing fee, in destination-token base units. */
200
+ omnibridgeFeeAmount?: bigint;
201
+ /** The anchor's own carrier's valuation of the deferred-crossing landing, when the plan defers one. */
202
+ anchorUsdValue?: string | null;
203
+ /** The reader's typed amount, when it differs from `inputAmount` (see `RouteCandidate.requestedAmount`). */
204
+ requestedAmount?: bigint | null;
205
+ /** Charges the plan's carriers report outside `fromAmount`. */
206
+ fees?: readonly QuoteFee[];
207
+ /** The plan's first hop's own carrier-claimed execution duration, in seconds. */
208
+ executionDurationSeconds?: number;
209
+ };
210
+ /**
211
+ * Turns a priced {@link RoutePlan} into a {@link RouteCandidate}, filling
212
+ * `plan` and deriving `deferredCrossing`, `entryChainId` and
213
+ * `omnibridgeProvider` from it exactly as `RouteCandidate.plan`'s own TSDoc
214
+ * (`../candidate.ts`) promises.
215
+ *
216
+ * @param inputs - the plan, a token resolver, an id, and the caller's pricing
217
+ * @returns the route candidate
218
+ */
219
+ export declare const buildRouteCandidateFromPlan: (inputs: PlanCandidateInputs) => RouteCandidate;
220
+ /**
221
+ * Everything {@link buildRouteScoreInputsFromPlan} needs beyond the plan's
222
+ * own structure and `gaslessIntermediateChainCount`, which the design's own
223
+ * `RouteScoreInputs` doc says is "an input from the interface" — a live
224
+ * wallet balance read this pure module cannot perform.
225
+ */
226
+ export type PlanValuation = PlanCandidateInputs & {
227
+ /** Each hop's own carrier-claimed execution duration, in seconds, in hop order. */
228
+ legClaimedDurationsSeconds: readonly (number | null | undefined)[];
229
+ };
230
+ /**
231
+ * Turns a priced {@link RoutePlan} into {@link RouteScoreInputs} — reusing
232
+ * `candidateDeliveredUsd`, `candidatePaidUsd` and `candidateOutsideFeesUsd`
233
+ * (`../producers.js`) against the SAME candidate
234
+ * {@link buildRouteCandidateFromPlan} builds, exactly as `RouteScoreInputs`'
235
+ * own doc in `score.ts` asks: "generalized to the plan's LAST hop and FIRST
236
+ * hop respectively... import and reuse them; do not write a second
237
+ * valuation."
238
+ *
239
+ * @param valuation - the plan, a token resolver, an id, and the caller's pricing
240
+ * @param gaslessIntermediateChainCount - intermediate chains the connected
241
+ * account holds no gas on — supplied by the caller, never computed here
242
+ * @returns the plan's score inputs
243
+ */
244
+ export declare const buildRouteScoreInputsFromPlan: (valuation: PlanValuation, gaslessIntermediateChainCount: number) => RouteScoreInputs;