@gibs/bridge-sdk 1.13.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +244 -18
- package/abis/package.json +6 -0
- package/bridge-limits/package.json +6 -0
- package/chain-info/package.json +6 -0
- package/chain-names/package.json +6 -0
- package/chains/package.json +6 -0
- package/claims/package.json +6 -0
- package/config/package.json +6 -0
- package/consolidated-quote/package.json +6 -0
- package/destination-calldata/package.json +6 -0
- package/dist/chain-info.d.ts +1 -1
- package/dist/chain-info.js +11 -12
- package/dist/chains.d.ts +25 -0
- package/dist/chains.js +55 -20
- package/dist/cjs/abis.d.ts +1 -0
- package/dist/cjs/abis.js +19 -0
- package/dist/cjs/bridge-limits.d.ts +103 -0
- package/dist/cjs/bridge-limits.js +89 -0
- package/dist/cjs/chain-info.d.ts +169 -0
- package/dist/cjs/chain-info.js +452 -0
- package/dist/cjs/chain-names.d.ts +160 -0
- package/dist/cjs/chain-names.js +207 -0
- package/dist/cjs/chains.d.ts +90 -0
- package/dist/cjs/chains.js +357 -0
- package/dist/cjs/claims.d.ts +198 -0
- package/dist/cjs/claims.js +182 -0
- package/dist/cjs/config.d.ts +240 -0
- package/dist/cjs/config.js +537 -0
- package/dist/cjs/consolidated-quote.d.ts +648 -0
- package/dist/cjs/consolidated-quote.js +1048 -0
- package/dist/cjs/destination-calldata.d.ts +118 -0
- package/dist/cjs/destination-calldata.js +156 -0
- package/dist/cjs/ecosystems.d.ts +217 -0
- package/dist/cjs/ecosystems.js +298 -0
- package/dist/cjs/execution.d.ts +346 -0
- package/dist/cjs/execution.js +468 -0
- package/dist/cjs/fee-type.d.ts +10 -0
- package/dist/cjs/fee-type.js +10 -0
- package/dist/cjs/hyperliquid-execution.d.ts +152 -0
- package/dist/cjs/hyperliquid-execution.js +175 -0
- package/dist/cjs/image-links.d.ts +117 -0
- package/dist/cjs/image-links.js +153 -0
- package/dist/cjs/index.d.ts +23 -0
- package/dist/cjs/index.js +39 -0
- package/dist/cjs/lifi-execution-guard.d.ts +210 -0
- package/dist/cjs/lifi-execution-guard.js +409 -0
- package/dist/cjs/near-intents-conformance.d.ts +85 -0
- package/dist/cjs/near-intents-conformance.js +337 -0
- package/dist/cjs/near-intents-route.d.ts +47 -0
- package/dist/cjs/near-intents-route.js +303 -0
- package/dist/cjs/near-intents.d.ts +524 -0
- package/dist/cjs/near-intents.js +1071 -0
- package/dist/cjs/origin-deposit.d.ts +326 -0
- package/dist/cjs/origin-deposit.js +82 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/pre-quote.d.ts +198 -0
- package/dist/cjs/pre-quote.js +180 -0
- package/dist/cjs/prices.d.ts +107 -0
- package/dist/cjs/prices.js +172 -0
- package/dist/cjs/providers.d.ts +238 -0
- package/dist/cjs/providers.js +171 -0
- package/dist/cjs/quote-fees.d.ts +102 -0
- package/dist/cjs/quote-fees.js +201 -0
- package/dist/cjs/referral.d.ts +85 -0
- package/dist/cjs/referral.js +85 -0
- package/dist/cjs/relay-currencies.d.ts +47 -0
- package/dist/cjs/relay-currencies.js +95 -0
- package/dist/cjs/relay-depository.d.ts +2 -0
- package/dist/cjs/relay-depository.js +85 -0
- package/dist/cjs/relay-quote.d.ts +301 -0
- package/dist/cjs/relay-quote.js +996 -0
- package/dist/cjs/route-steps.d.ts +138 -0
- package/dist/cjs/route-steps.js +310 -0
- package/dist/cjs/routing/amounts.d.ts +80 -0
- package/dist/cjs/routing/amounts.js +126 -0
- package/dist/cjs/routing/candidate-route.d.ts +43 -0
- package/dist/cjs/routing/candidate-route.js +50 -0
- package/dist/cjs/routing/candidate.d.ts +237 -0
- package/dist/cjs/routing/candidate.js +100 -0
- package/dist/cjs/routing/carriers/ask-answer.d.ts +77 -0
- package/dist/cjs/routing/carriers/ask-answer.js +2 -0
- package/dist/cjs/routing/carriers/omnibridge.d.ts +137 -0
- package/dist/cjs/routing/carriers/omnibridge.js +459 -0
- package/dist/cjs/routing/carriers/pulsex-paths.d.ts +80 -0
- package/dist/cjs/routing/carriers/pulsex-paths.js +97 -0
- package/dist/cjs/routing/carriers/pulsex-split.d.ts +175 -0
- package/dist/cjs/routing/carriers/pulsex-split.js +193 -0
- package/dist/cjs/routing/carriers/pulsex.d.ts +159 -0
- package/dist/cjs/routing/carriers/pulsex.js +565 -0
- package/dist/cjs/routing/carriers/wrap.d.ts +25 -0
- package/dist/cjs/routing/carriers/wrap.js +119 -0
- package/dist/cjs/routing/composed-route-quality.d.ts +125 -0
- package/dist/cjs/routing/composed-route-quality.js +144 -0
- package/dist/cjs/routing/entry-chain-anchor.d.ts +88 -0
- package/dist/cjs/routing/entry-chain-anchor.js +59 -0
- package/dist/cjs/routing/format.d.ts +31 -0
- package/dist/cjs/routing/format.js +64 -0
- package/dist/cjs/routing/index.d.ts +38 -0
- package/dist/cjs/routing/index.js +134 -0
- package/dist/cjs/routing/producers.d.ts +770 -0
- package/dist/cjs/routing/producers.js +1617 -0
- package/dist/cjs/routing/providers.d.ts +31 -0
- package/dist/cjs/routing/providers.js +48 -0
- package/dist/cjs/routing/route-data.d.ts +355 -0
- package/dist/cjs/routing/route-data.js +2 -0
- package/dist/cjs/routing/search/compose.d.ts +168 -0
- package/dist/cjs/routing/search/compose.js +104 -0
- package/dist/cjs/routing/search/graph.d.ts +668 -0
- package/dist/cjs/routing/search/graph.js +461 -0
- package/dist/cjs/routing/search/plan-route-data.d.ts +269 -0
- package/dist/cjs/routing/search/plan-route-data.js +848 -0
- package/dist/cjs/routing/search/score.d.ts +356 -0
- package/dist/cjs/routing/search/score.js +445 -0
- package/dist/cjs/routing/swap-transactions.d.ts +91 -0
- package/dist/cjs/routing/swap-transactions.js +131 -0
- package/dist/cjs/routing/usd-value.d.ts +17 -0
- package/dist/cjs/routing/usd-value.js +29 -0
- package/dist/cjs/settings.d.ts +785 -0
- package/dist/cjs/settings.js +1074 -0
- package/dist/cjs/ton-connect.d.ts +98 -0
- package/dist/cjs/ton-connect.js +206 -0
- package/dist/cjs/ton-execution.d.ts +7 -0
- package/dist/cjs/ton-execution.js +23 -0
- package/dist/cjs/ton.d.ts +37 -0
- package/dist/cjs/ton.js +83 -0
- package/dist/cjs/tron-execution.d.ts +146 -0
- package/dist/cjs/tron-execution.js +248 -0
- package/dist/cjs/types.d.ts +51 -0
- package/dist/cjs/types.js +2 -0
- package/dist/claims.d.ts +198 -0
- package/dist/claims.js +140 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.js +39 -5
- package/dist/consolidated-quote.d.ts +109 -15
- package/dist/consolidated-quote.js +310 -52
- package/dist/execution.d.ts +346 -0
- package/dist/execution.js +428 -0
- package/dist/hyperliquid-execution.js +2 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lifi-execution-guard.d.ts +13 -2
- package/dist/lifi-execution-guard.js +4 -0
- package/dist/near-intents.js +2 -3
- package/dist/pre-quote.d.ts +6 -6
- package/dist/pre-quote.js +10 -14
- package/dist/providers.d.ts +17 -0
- package/dist/providers.js +6 -0
- package/dist/referral.d.ts +12 -4
- package/dist/referral.js +12 -4
- package/dist/relay-depository.d.ts +2 -0
- package/dist/relay-depository.js +82 -0
- package/dist/relay-quote.js +2 -3
- package/dist/routing/candidate.d.ts +3 -3
- package/dist/routing/candidate.js +3 -3
- package/dist/routing/carriers/ask-answer.d.ts +19 -0
- package/dist/routing/carriers/omnibridge.js +23 -21
- package/dist/routing/carriers/pulsex-paths.d.ts +80 -0
- package/dist/routing/carriers/pulsex-paths.js +92 -0
- package/dist/routing/carriers/pulsex-split.d.ts +175 -0
- package/dist/routing/carriers/pulsex-split.js +185 -0
- package/dist/routing/carriers/pulsex.d.ts +69 -21
- package/dist/routing/carriers/pulsex.js +184 -65
- package/dist/routing/composed-route-quality.d.ts +28 -6
- package/dist/routing/composed-route-quality.js +36 -5
- package/dist/routing/entry-chain-anchor.d.ts +1 -1
- package/dist/routing/entry-chain-anchor.js +1 -1
- package/dist/routing/index.d.ts +7 -3
- package/dist/routing/index.js +7 -3
- package/dist/routing/producers.js +1 -1
- package/dist/routing/providers.d.ts +5 -0
- package/dist/routing/providers.js +5 -0
- package/dist/routing/search/graph.d.ts +29 -0
- package/dist/routing/search/plan-route-data.d.ts +25 -0
- package/dist/routing/search/plan-route-data.js +43 -7
- package/dist/routing/search/score.d.ts +33 -1
- package/dist/routing/search/score.js +41 -6
- package/dist/routing/swap-transactions.d.ts +91 -0
- package/dist/routing/swap-transactions.js +125 -0
- package/dist/settings.d.ts +94 -1
- package/dist/settings.js +95 -3
- package/dist/ton-connect.d.ts +98 -0
- package/dist/ton-connect.js +200 -0
- package/dist/ton-execution.d.ts +4 -114
- package/dist/ton-execution.js +4 -244
- package/dist/ton.d.ts +37 -0
- package/dist/ton.js +65 -0
- package/docs/examples/example-a-ether-to-pulse.ts +300 -0
- package/docs/examples/example-b-token-pulsechain-to-ethereum.ts +270 -0
- package/docs/examples/shared.ts +261 -0
- package/docs/examples/tsconfig.json +18 -0
- package/docs/integration-guide.md +617 -0
- package/ecosystems/package.json +6 -0
- package/execution/package.json +6 -0
- package/fee-type/package.json +6 -0
- package/hyperliquid-execution/package.json +6 -0
- package/image-links/package.json +6 -0
- package/lifi-execution-guard/package.json +6 -0
- package/llms.txt +234 -0
- package/near-intents/package.json +6 -0
- package/near-intents-route/package.json +6 -0
- package/origin-deposit/package.json +6 -0
- package/package.json +818 -10
- package/pre-quote/package.json +6 -0
- package/prices/package.json +6 -0
- package/providers/package.json +6 -0
- package/quote-fees/package.json +6 -0
- package/referral/package.json +6 -0
- package/relay-currencies/package.json +6 -0
- package/relay-quote/package.json +6 -0
- package/route-steps/package.json +6 -0
- package/routing/package.json +6 -0
- package/settings/package.json +6 -0
- package/ton/package.json +6 -0
- package/ton-connect/package.json +6 -0
- package/ton-execution/package.json +6 -0
- package/tron-execution/package.json +6 -0
- package/types/package.json +6 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { type ConsolidatedQuote, type ConsolidatedQuoteRequest } from './consolidated-quote.js';
|
|
2
|
+
import { type Provider } from './config.js';
|
|
3
|
+
import type { Ecosystem } from './ecosystems.js';
|
|
4
|
+
import { type PreQuoteRequest, type PreQuoteResult } from './pre-quote.js';
|
|
5
|
+
import { type NearIntentsAsset } from './near-intents.js';
|
|
6
|
+
import type { QuoteFeeToken } from './quote-fees.js';
|
|
7
|
+
/**
|
|
8
|
+
* A consolidated-route aggregator. Like {@link Ecosystem}, this is the `id` of a
|
|
9
|
+
* descriptor in {@link providerRegistry}, so adding a provider is one descriptor
|
|
10
|
+
* rather than an edit spread across a union, a capability conditional, and two
|
|
11
|
+
* interface-side arrays.
|
|
12
|
+
*/
|
|
13
|
+
export type ProviderId = 'lifi' | 'relay' | 'near-intents';
|
|
14
|
+
/**
|
|
15
|
+
* Every source a hop or a lookup table can attribute to a name, a logo or a
|
|
16
|
+
* display colour: a consolidated-route aggregator ({@link ProviderId}), an
|
|
17
|
+
* omnibridge crossing ({@link Provider}, from `config.ts` — `'pulsechain'` or
|
|
18
|
+
* `'tokensex'`), or the on-chain PulseChain DEX swap leg, which belongs to
|
|
19
|
+
* neither registry and is named here as its own literal.
|
|
20
|
+
*
|
|
21
|
+
* THE ONE UNION FOR "NAME A CARRIER." Every table a hop's carrier is looked up
|
|
22
|
+
* in — a logo url, a glyph, a display name — must be typed
|
|
23
|
+
* `Record<ProviderKey, X>`, never `Record<string, X>`: a table keyed on
|
|
24
|
+
* `string` accepts a carrier with no entry silently, which is how NEAR
|
|
25
|
+
* Intents shipped with no logo and how a lower-cased `'pulsex'` drew the
|
|
26
|
+
* initials tile "PU" instead of the PulseX mark. Typed on this union, a
|
|
27
|
+
* carrier added to any of its three sources fails to compile until it also
|
|
28
|
+
* has a name and a mark.
|
|
29
|
+
*
|
|
30
|
+
* `'PulseX'` IS SPELLED WITH THAT EXACT CASING, matching `providerKey:
|
|
31
|
+
* 'PulseX'` in `routing/producers.ts` and every lookup table keyed on it.
|
|
32
|
+
* `routing/search/graph.ts`'s `HopEdge.carrier` is a plain `CarrierId`
|
|
33
|
+
* string, not this union — the route-search engine is a plug-in host that
|
|
34
|
+
* does not close its carrier vocabulary over gibs's own three; every member
|
|
35
|
+
* of THIS union is still a valid `CarrierId`, just not the only one.
|
|
36
|
+
*/
|
|
37
|
+
export type ProviderKey = ProviderId | Provider | 'PulseX';
|
|
38
|
+
/**
|
|
39
|
+
* What a provider may need to form a request or read an answer, beyond the
|
|
40
|
+
* route request itself.
|
|
41
|
+
*
|
|
42
|
+
* EVERY FIELD IS OPTIONAL AND MOST PROVIDERS IGNORE ALL OF THEM. LI.FI and Relay
|
|
43
|
+
* name assets by chain and address, and hand back a signable transaction, so
|
|
44
|
+
* their builders and parsers are total over the request alone — and they stay
|
|
45
|
+
* referenced here unchanged, because a function of one argument satisfies a type
|
|
46
|
+
* of two. NEAR Intents needs more in both directions: it names assets by its own
|
|
47
|
+
* identifiers, which can only be looked up in its published list, and it answers
|
|
48
|
+
* with a deposit ADDRESS rather than a transaction, so the chain and token the
|
|
49
|
+
* transfer must be composed from exist only on the request.
|
|
50
|
+
*
|
|
51
|
+
* Kept as one optional record rather than a per-provider generic parameter
|
|
52
|
+
* because the registry's whole purpose is that callers iterate descriptors
|
|
53
|
+
* without knowing which provider they hold.
|
|
54
|
+
*/
|
|
55
|
+
export type ProviderQuoteContext = {
|
|
56
|
+
/**
|
|
57
|
+
* The NEAR Intents asset list. Its identifiers cannot be constructed from a
|
|
58
|
+
* chain and an address — see `findNearIntentsAsset`.
|
|
59
|
+
*/
|
|
60
|
+
nearIntentsAssets?: readonly NearIntentsAsset[];
|
|
61
|
+
/** The clock, for a provider whose request states a deadline. */
|
|
62
|
+
now?: Date;
|
|
63
|
+
/** Distribution-channel tag, for a provider that accepts one. */
|
|
64
|
+
referral?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The request being answered. Needed only by a parser whose response does not
|
|
67
|
+
* carry enough to build the origin deposit on its own.
|
|
68
|
+
*/
|
|
69
|
+
request?: ConsolidatedQuoteRequest;
|
|
70
|
+
/** The paid token, for normalizing a charge denominated in it. */
|
|
71
|
+
originToken?: QuoteFeeToken;
|
|
72
|
+
/** The delivered token, for the same reason. */
|
|
73
|
+
destinationToken?: QuoteFeeToken;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* A self-describing provider: which source ecosystems it can carry, and the
|
|
77
|
+
* existing request-builders and response-parsers for each of the two quoting
|
|
78
|
+
* phases. The builders and parsers are REFERENCED, never re-implemented — they
|
|
79
|
+
* already exist and are tested. Endpoint URLs are intentionally absent: the
|
|
80
|
+
* transport wrappers that own the endpoint, abort signal, and headers live in
|
|
81
|
+
* the interface package.
|
|
82
|
+
*/
|
|
83
|
+
export type ProviderDescriptor = {
|
|
84
|
+
id: ProviderId;
|
|
85
|
+
label: string;
|
|
86
|
+
/** The source ecosystems this provider can originate a route from. */
|
|
87
|
+
supportedSourceEcosystems: readonly Ecosystem[];
|
|
88
|
+
/**
|
|
89
|
+
* Whether this provider's executor performs a call on the destination chain
|
|
90
|
+
* when the funds arrive.
|
|
91
|
+
*
|
|
92
|
+
* THE FIELD THAT DECIDES WHAT SHAPE OF ROUTE A PROVIDER CAN CARRY, and the
|
|
93
|
+
* owner's standing criterion expressed as data rather than as a rule somebody
|
|
94
|
+
* has to remember.
|
|
95
|
+
*
|
|
96
|
+
* True — hand it the omnibridge entry call and the crossing is one signature.
|
|
97
|
+
* False — it delivers tokens to an address and stops, so a crossing through it
|
|
98
|
+
* takes TWO signatures: the provider's leg, then the reader signing the entry
|
|
99
|
+
* call themselves once the funds land.
|
|
100
|
+
*
|
|
101
|
+
* It also gates the entry-anchor pre-quote, and that is the part that bites.
|
|
102
|
+
* That phase takes the LARGEST delivered amount across providers and feeds it
|
|
103
|
+
* to the execution quote as a fixed exact-output target. A provider that
|
|
104
|
+
* cannot execute can still deliver more — so letting one bid there raises a
|
|
105
|
+
* target only it could reach and that nobody can execute, turning a working
|
|
106
|
+
* route into no route at all. See `selectPreQuoteProviderIds`.
|
|
107
|
+
*/
|
|
108
|
+
executesDestinationCalls: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* The origin chains this provider can perform a destination call FROM, or
|
|
111
|
+
* `'any'` when every origin it carries can. Read only when
|
|
112
|
+
* {@link executesDestinationCalls} is true.
|
|
113
|
+
*
|
|
114
|
+
* LI.FI IS ETHEREUM ONLY — the owner's rule: its contract-calls endpoint
|
|
115
|
+
* is what attaches the omnibridge entry call, and from any other origin a
|
|
116
|
+
* LI.FI leg is an ordinary delivery to the reader's own wallet, followed by
|
|
117
|
+
* a crossing the reader signs. The route search reads this list, so it never
|
|
118
|
+
* proposes a fused LI.FI hop it could not have signed.
|
|
119
|
+
*/
|
|
120
|
+
destinationCallOriginChainIds: readonly number[] | 'any';
|
|
121
|
+
/**
|
|
122
|
+
* Whether the destination call this provider performs may carry native
|
|
123
|
+
* value — the omnibridge's native entry (`wrapAndRelayTokens`) is a payable
|
|
124
|
+
* call, where every other entry moves a token.
|
|
125
|
+
*
|
|
126
|
+
* Relay's is verified: a dry `quote/v2` for Base USD Coin into Ethereum
|
|
127
|
+
* ether with a value-bearing `wrapAndRelayTokens` call answered 200 at 0.05
|
|
128
|
+
* ether and refused with `DESTINATION_TX_FAILED` at 0.01 (under the
|
|
129
|
+
* mediator's floor) — so Relay simulates the call with its value attached
|
|
130
|
+
* (measured 2026-09-27). LI.FI's is not verified, and its request builder
|
|
131
|
+
* refuses such a call; this field and that builder must agree (see
|
|
132
|
+
* `providers.test.ts`).
|
|
133
|
+
*/
|
|
134
|
+
destinationCallCarriesNativeValue: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* How this provider takes an Ethereum token from the reader's wallet.
|
|
137
|
+
*
|
|
138
|
+
* - `'allowance'` — the provider's contract pulls the token, so the wallet
|
|
139
|
+
* must first approve that contract as a spender. The execution quote names
|
|
140
|
+
* the spender (`ConsolidatedQuote.approvalAddress`), and the executor
|
|
141
|
+
* raises the allowance before it sends.
|
|
142
|
+
* - `'transfer'` — the reader sends the token to an address the provider
|
|
143
|
+
* gives. A plain transfer needs no approval, and the parser leaves
|
|
144
|
+
* `approvalAddress` null.
|
|
145
|
+
*
|
|
146
|
+
* A DISPLAY FACT, NEVER A SIGNING ONE. The press reads the live quote's own
|
|
147
|
+
* `approvalAddress` and the live allowance. This field lets a route say, BEFORE
|
|
148
|
+
* any live quote exists, that its wallet may ask for an approval first.
|
|
149
|
+
* The native coin never needs one, whatever this says.
|
|
150
|
+
*/
|
|
151
|
+
originTokenSpend: 'allowance' | 'transfer';
|
|
152
|
+
/**
|
|
153
|
+
* Phase one: the plain forward-solving origin-to-anchor swap pre-quote.
|
|
154
|
+
*
|
|
155
|
+
* The `context` argument is ignored by every provider that does not need it,
|
|
156
|
+
* and a builder written to take only the request still satisfies this type.
|
|
157
|
+
*/
|
|
158
|
+
preQuote: {
|
|
159
|
+
method: 'GET' | 'POST';
|
|
160
|
+
build: (request: PreQuoteRequest, context?: ProviderQuoteContext) => string | object | null;
|
|
161
|
+
parse: (payload: unknown, context?: ProviderQuoteContext) => PreQuoteResult | null;
|
|
162
|
+
};
|
|
163
|
+
/** Phase two: the backward-solving execution quote with destination calls. */
|
|
164
|
+
executionQuote: {
|
|
165
|
+
method: 'GET' | 'POST';
|
|
166
|
+
build: (request: ConsolidatedQuoteRequest, context?: ProviderQuoteContext) => object | null;
|
|
167
|
+
parse: (payload: unknown, context?: ProviderQuoteContext) => ConsolidatedQuote | null;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Every integrated provider. LI.FI is first: the interface preserves this order
|
|
172
|
+
* in its active lists, and LI.FI-first is the existing tie-break that prefers
|
|
173
|
+
* the verified provider on an equal-cost quote. NEAR Intents is last, so it
|
|
174
|
+
* wins a tie against neither — appropriate for the one provider whose route
|
|
175
|
+
* costs the reader a second signature.
|
|
176
|
+
*/
|
|
177
|
+
export declare const providerRegistry: readonly ProviderDescriptor[];
|
|
178
|
+
/**
|
|
179
|
+
* Looks up a provider descriptor for ANY carrier id, answering null for an id
|
|
180
|
+
* the registry does not hold. The route-search engine carries hops for
|
|
181
|
+
* carriers that are not providers at all (a local wrap, a pool swap, a
|
|
182
|
+
* host's own plug-in), so a caller holding an open carrier id must ask this,
|
|
183
|
+
* never cast the id to {@link ProviderId} and call {@link providerById}, which
|
|
184
|
+
* throws for such an id.
|
|
185
|
+
*
|
|
186
|
+
* @param id - any carrier id
|
|
187
|
+
* @returns the descriptor, or null when no provider is registered under `id`
|
|
188
|
+
*/
|
|
189
|
+
export declare const findProviderById: (id: string) => ProviderDescriptor | null;
|
|
190
|
+
/**
|
|
191
|
+
* Looks up a provider descriptor. Total over the `ProviderId` union; throws only
|
|
192
|
+
* if the registry is left incomplete.
|
|
193
|
+
*
|
|
194
|
+
* @param id - the provider key
|
|
195
|
+
* @returns the descriptor whose `id` equals `id`
|
|
196
|
+
*/
|
|
197
|
+
export declare const providerById: (id: ProviderId) => ProviderDescriptor;
|
|
198
|
+
/**
|
|
199
|
+
* The providers that can originate a route from `ecosystem`, in registry order.
|
|
200
|
+
* This is the data that used to be the hand-written capability conditional.
|
|
201
|
+
*
|
|
202
|
+
* @param ecosystem - the source ecosystem
|
|
203
|
+
* @returns the descriptors whose `supportedSourceEcosystems` include `ecosystem`
|
|
204
|
+
*/
|
|
205
|
+
export declare const providersForOrigin: (ecosystem: Ecosystem) => readonly ProviderDescriptor[];
|
|
206
|
+
/**
|
|
207
|
+
* The providers that may bid in the entry-anchor pre-quote for an origin.
|
|
208
|
+
*
|
|
209
|
+
* A STRICTER LIST THAN {@link providersForOrigin}, AND THE DIFFERENCE IS NOT
|
|
210
|
+
* COSMETIC. The pre-quote exists for one purpose: to learn, for the reader's
|
|
211
|
+
* fixed input, how much anchor an entry really delivers, so that figure can
|
|
212
|
+
* become the exact-output target of the execution quote. The winner is whoever
|
|
213
|
+
* delivers MOST.
|
|
214
|
+
*
|
|
215
|
+
* A provider that cannot execute the entry call can still win that comparison —
|
|
216
|
+
* it has one less thing to pay for. Its number then becomes a target handed to
|
|
217
|
+
* the providers that must actually fill it, and they cannot, so the whole entry
|
|
218
|
+
* produces no route. The failure is silent and looks like an absent quote.
|
|
219
|
+
*
|
|
220
|
+
* So the pre-quote is restricted to providers that execute. This is not a
|
|
221
|
+
* judgement about quality; it is that a pre-quote and an execution quote have
|
|
222
|
+
* to be answerable by the same provider for the handoff between them to mean
|
|
223
|
+
* anything.
|
|
224
|
+
*
|
|
225
|
+
* @param ecosystem - the source ecosystem
|
|
226
|
+
* @returns the descriptors that may pre-quote this origin, in registry order
|
|
227
|
+
*/
|
|
228
|
+
export declare const preQuoteProvidersForOrigin: (ecosystem: Ecosystem) => readonly ProviderDescriptor[];
|
|
229
|
+
/**
|
|
230
|
+
* Whether a provider can quote a request's origin ecosystem, derived from the
|
|
231
|
+
* registry. Equivalent to `providersForOrigin(...).some(...)`, kept as a named
|
|
232
|
+
* predicate for the call sites that ask about one provider at a time.
|
|
233
|
+
*
|
|
234
|
+
* @param provider - the aggregator under consideration
|
|
235
|
+
* @param request - the request whose origin is being checked
|
|
236
|
+
* @returns true when the provider supports the request's origin ecosystem
|
|
237
|
+
*/
|
|
238
|
+
export declare const providerSupportsOrigin: (provider: ProviderId, request: Pick<ConsolidatedQuoteRequest, "originVmType">) => boolean;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.providerSupportsOrigin = exports.preQuoteProvidersForOrigin = exports.providersForOrigin = exports.providerById = exports.findProviderById = exports.providerRegistry = void 0;
|
|
4
|
+
const consolidated_quote_js_1 = require("./consolidated-quote.js");
|
|
5
|
+
const config_js_1 = require("./config.js");
|
|
6
|
+
const pre_quote_js_1 = require("./pre-quote.js");
|
|
7
|
+
const near_intents_js_1 = require("./near-intents.js");
|
|
8
|
+
const relay_quote_js_1 = require("./relay-quote.js");
|
|
9
|
+
const lifiDescriptor = {
|
|
10
|
+
id: 'lifi',
|
|
11
|
+
label: 'LI.FI',
|
|
12
|
+
supportedSourceEcosystems: ['evm'],
|
|
13
|
+
// Its contract-calls endpoint exists to deliver and then call something.
|
|
14
|
+
executesDestinationCalls: true,
|
|
15
|
+
destinationCallOriginChainIds: [Number(config_js_1.Chains.ETH)],
|
|
16
|
+
destinationCallCarriesNativeValue: false,
|
|
17
|
+
// Its quote names the Diamond as `estimate.approvalAddress`.
|
|
18
|
+
originTokenSpend: 'allowance',
|
|
19
|
+
preQuote: {
|
|
20
|
+
method: 'GET',
|
|
21
|
+
build: pre_quote_js_1.buildLifiPreQuoteRequest,
|
|
22
|
+
parse: pre_quote_js_1.parseLifiPreQuote,
|
|
23
|
+
},
|
|
24
|
+
executionQuote: {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
build: consolidated_quote_js_1.buildLifiContractCallsRequest,
|
|
27
|
+
parse: consolidated_quote_js_1.parseLifiContractCallsQuote,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
const relayDescriptor = {
|
|
31
|
+
id: 'relay',
|
|
32
|
+
label: 'Relay',
|
|
33
|
+
// Relay carries every origin family the registry models. Listed explicitly
|
|
34
|
+
// rather than derived from the registry so that registering a future
|
|
35
|
+
// ecosystem does not silently claim Relay support the integration lacks.
|
|
36
|
+
supportedSourceEcosystems: ['evm', 'svm', 'bvm', 'tvm', 'tonvm', 'hypevm'],
|
|
37
|
+
// Its solver performs the `txs` attached to a quote on arrival.
|
|
38
|
+
executesDestinationCalls: true,
|
|
39
|
+
destinationCallOriginChainIds: 'any',
|
|
40
|
+
destinationCallCarriesNativeValue: true,
|
|
41
|
+
// Its quote carries an approve step; the parser lifts its spender.
|
|
42
|
+
originTokenSpend: 'allowance',
|
|
43
|
+
preQuote: {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
build: pre_quote_js_1.buildRelayPreQuoteRequest,
|
|
46
|
+
parse: pre_quote_js_1.parseRelayPreQuote,
|
|
47
|
+
},
|
|
48
|
+
executionQuote: {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
build: relay_quote_js_1.buildRelayQuoteRequest,
|
|
51
|
+
parse: relay_quote_js_1.parseRelayQuote,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const nearIntentsDescriptor = {
|
|
55
|
+
id: 'near-intents',
|
|
56
|
+
label: 'NEAR Intents',
|
|
57
|
+
// ETHEREUM ORIGINS, AND THE CHAINS A READER PAYS BY HAND. The service
|
|
58
|
+
// carries Solana, Bitcoin, Tron, The Open Network and more, but it returns a
|
|
59
|
+
// deposit ADDRESS and no transaction. For a wallet-connected origin the
|
|
60
|
+
// transfer that funds a route has to be composed on this side, and only the
|
|
61
|
+
// Ethereum one is composed today (`nearIntentsOriginDeposit`); claiming a
|
|
62
|
+
// family whose transfer nothing here can build would offer a route that
|
|
63
|
+
// dead-ends at the signing step. A pay-by-hand chain needs nothing composed:
|
|
64
|
+
// the address and the amount ARE the deposit (`DepositAddressDeposit`).
|
|
65
|
+
supportedSourceEcosystems: ['evm', 'zcash'],
|
|
66
|
+
// The measured answer, and the reason this provider's routes take two
|
|
67
|
+
// signatures. See the head of `near-intents.ts`.
|
|
68
|
+
executesDestinationCalls: false,
|
|
69
|
+
destinationCallOriginChainIds: [],
|
|
70
|
+
destinationCallCarriesNativeValue: false,
|
|
71
|
+
// The reader sends the token to a deposit address.
|
|
72
|
+
originTokenSpend: 'transfer',
|
|
73
|
+
preQuote: {
|
|
74
|
+
method: 'POST',
|
|
75
|
+
build: near_intents_js_1.buildNearIntentsPreQuoteRequest,
|
|
76
|
+
parse: near_intents_js_1.parseNearIntentsPreQuote,
|
|
77
|
+
},
|
|
78
|
+
executionQuote: {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
build: near_intents_js_1.buildNearIntentsQuoteRequest,
|
|
81
|
+
parse: near_intents_js_1.parseNearIntentsQuote,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Every integrated provider. LI.FI is first: the interface preserves this order
|
|
86
|
+
* in its active lists, and LI.FI-first is the existing tie-break that prefers
|
|
87
|
+
* the verified provider on an equal-cost quote. NEAR Intents is last, so it
|
|
88
|
+
* wins a tie against neither — appropriate for the one provider whose route
|
|
89
|
+
* costs the reader a second signature.
|
|
90
|
+
*/
|
|
91
|
+
exports.providerRegistry = [
|
|
92
|
+
lifiDescriptor,
|
|
93
|
+
relayDescriptor,
|
|
94
|
+
nearIntentsDescriptor,
|
|
95
|
+
];
|
|
96
|
+
const byId = new Map(exports.providerRegistry.map((descriptor) => [descriptor.id, descriptor]));
|
|
97
|
+
/**
|
|
98
|
+
* Looks up a provider descriptor for ANY carrier id, answering null for an id
|
|
99
|
+
* the registry does not hold. The route-search engine carries hops for
|
|
100
|
+
* carriers that are not providers at all (a local wrap, a pool swap, a
|
|
101
|
+
* host's own plug-in), so a caller holding an open carrier id must ask this,
|
|
102
|
+
* never cast the id to {@link ProviderId} and call {@link providerById}, which
|
|
103
|
+
* throws for such an id.
|
|
104
|
+
*
|
|
105
|
+
* @param id - any carrier id
|
|
106
|
+
* @returns the descriptor, or null when no provider is registered under `id`
|
|
107
|
+
*/
|
|
108
|
+
const findProviderById = (id) => byId.get(id) ?? null;
|
|
109
|
+
exports.findProviderById = findProviderById;
|
|
110
|
+
/**
|
|
111
|
+
* Looks up a provider descriptor. Total over the `ProviderId` union; throws only
|
|
112
|
+
* if the registry is left incomplete.
|
|
113
|
+
*
|
|
114
|
+
* @param id - the provider key
|
|
115
|
+
* @returns the descriptor whose `id` equals `id`
|
|
116
|
+
*/
|
|
117
|
+
const providerById = (id) => {
|
|
118
|
+
const descriptor = byId.get(id);
|
|
119
|
+
if (descriptor === undefined) {
|
|
120
|
+
throw new Error(`no provider descriptor registered for id "${id}"`);
|
|
121
|
+
}
|
|
122
|
+
return descriptor;
|
|
123
|
+
};
|
|
124
|
+
exports.providerById = providerById;
|
|
125
|
+
/**
|
|
126
|
+
* The providers that can originate a route from `ecosystem`, in registry order.
|
|
127
|
+
* This is the data that used to be the hand-written capability conditional.
|
|
128
|
+
*
|
|
129
|
+
* @param ecosystem - the source ecosystem
|
|
130
|
+
* @returns the descriptors whose `supportedSourceEcosystems` include `ecosystem`
|
|
131
|
+
*/
|
|
132
|
+
const providersForOrigin = (ecosystem) => exports.providerRegistry.filter((descriptor) => descriptor.supportedSourceEcosystems.includes(ecosystem));
|
|
133
|
+
exports.providersForOrigin = providersForOrigin;
|
|
134
|
+
/**
|
|
135
|
+
* The providers that may bid in the entry-anchor pre-quote for an origin.
|
|
136
|
+
*
|
|
137
|
+
* A STRICTER LIST THAN {@link providersForOrigin}, AND THE DIFFERENCE IS NOT
|
|
138
|
+
* COSMETIC. The pre-quote exists for one purpose: to learn, for the reader's
|
|
139
|
+
* fixed input, how much anchor an entry really delivers, so that figure can
|
|
140
|
+
* become the exact-output target of the execution quote. The winner is whoever
|
|
141
|
+
* delivers MOST.
|
|
142
|
+
*
|
|
143
|
+
* A provider that cannot execute the entry call can still win that comparison —
|
|
144
|
+
* it has one less thing to pay for. Its number then becomes a target handed to
|
|
145
|
+
* the providers that must actually fill it, and they cannot, so the whole entry
|
|
146
|
+
* produces no route. The failure is silent and looks like an absent quote.
|
|
147
|
+
*
|
|
148
|
+
* So the pre-quote is restricted to providers that execute. This is not a
|
|
149
|
+
* judgement about quality; it is that a pre-quote and an execution quote have
|
|
150
|
+
* to be answerable by the same provider for the handoff between them to mean
|
|
151
|
+
* anything.
|
|
152
|
+
*
|
|
153
|
+
* @param ecosystem - the source ecosystem
|
|
154
|
+
* @returns the descriptors that may pre-quote this origin, in registry order
|
|
155
|
+
*/
|
|
156
|
+
const preQuoteProvidersForOrigin = (ecosystem) => (0, exports.providersForOrigin)(ecosystem).filter((descriptor) => descriptor.executesDestinationCalls);
|
|
157
|
+
exports.preQuoteProvidersForOrigin = preQuoteProvidersForOrigin;
|
|
158
|
+
// A request with no origin family is the existing-caller shape and is treated as
|
|
159
|
+
// Ethereum, preserving the original single-ecosystem default.
|
|
160
|
+
const ecosystemOf = (request) => request.originVmType ?? 'evm';
|
|
161
|
+
/**
|
|
162
|
+
* Whether a provider can quote a request's origin ecosystem, derived from the
|
|
163
|
+
* registry. Equivalent to `providersForOrigin(...).some(...)`, kept as a named
|
|
164
|
+
* predicate for the call sites that ask about one provider at a time.
|
|
165
|
+
*
|
|
166
|
+
* @param provider - the aggregator under consideration
|
|
167
|
+
* @param request - the request whose origin is being checked
|
|
168
|
+
* @returns true when the provider supports the request's origin ecosystem
|
|
169
|
+
*/
|
|
170
|
+
const providerSupportsOrigin = (provider, request) => (0, exports.providerById)(provider).supportedSourceEcosystems.includes(ecosystemOf(request));
|
|
171
|
+
exports.providerSupportsOrigin = providerSupportsOrigin;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a consolidated route actually charges, normalized across the aggregators.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS. A quote used to carry `fromAmount` and nothing else about
|
|
5
|
+
* cost, so the interface could show the reader only the omnibridge crossing fee
|
|
6
|
+
* — a figure that is real, and on a twenty-five dollar transfer is a rounding
|
|
7
|
+
* error beside what the aggregator takes. Measured on one live route on
|
|
8
|
+
* 2026-09-01: Relay charged 1.466338 USD Coin, or 5.54%, and none of it
|
|
9
|
+
* appeared anywhere on screen.
|
|
10
|
+
*
|
|
11
|
+
* THE FLAG THAT MATTERS IS `includedInFromAmount`. The two providers express
|
|
12
|
+
* cost differently, and the difference is not cosmetic:
|
|
13
|
+
*
|
|
14
|
+
* Relay folds everything into `fromAmount`. You send 26.466338 to receive
|
|
15
|
+
* 25.000000, and the 1.466338 difference IS the fee.
|
|
16
|
+
*
|
|
17
|
+
* LI.FI does not. On the same route it quoted `fromAmount` 25.317074 and a
|
|
18
|
+
* SEPARATE LayerZero fee of 0.000561734871157119 ether — about 1.37 dollars —
|
|
19
|
+
* marked `included: false`, which the sender pays on top in native currency.
|
|
20
|
+
*
|
|
21
|
+
* So comparing the two on `fromAmount` alone reads LI.FI as more than a dollar
|
|
22
|
+
* cheaper when it is in fact slightly dearer. Anything that ranks or displays
|
|
23
|
+
* cost has to add the charges that sit outside `fromAmount`, and that is what
|
|
24
|
+
* this flag is for.
|
|
25
|
+
*/
|
|
26
|
+
/** The token a charge is denominated in, enough to format it. */
|
|
27
|
+
export type QuoteFeeToken = {
|
|
28
|
+
symbol: string;
|
|
29
|
+
decimals: number;
|
|
30
|
+
chainId: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* What a charge IS, independent of the name its provider gives it.
|
|
34
|
+
*
|
|
35
|
+
* Deliberately coarse. The provider's own wording travels in `label`, so this
|
|
36
|
+
* only has to carry the distinction a reader acts on: is this the network's
|
|
37
|
+
* cost, somebody's margin, or our own referral.
|
|
38
|
+
*/
|
|
39
|
+
export type QuoteFeeKind = 'gas' | 'service' | 'integrator';
|
|
40
|
+
/** One charge on a route. */
|
|
41
|
+
export type QuoteFee = {
|
|
42
|
+
kind: QuoteFeeKind;
|
|
43
|
+
/** The provider's own name for it, so a reader can reconcile against them. */
|
|
44
|
+
label: string;
|
|
45
|
+
/** The charge, in the token's base units. */
|
|
46
|
+
amount: bigint;
|
|
47
|
+
token: QuoteFeeToken;
|
|
48
|
+
/** United States dollar value, exactly as the provider reported it. */
|
|
49
|
+
amountUsd: string | null;
|
|
50
|
+
/**
|
|
51
|
+
* FALSE means the sender pays this ON TOP of `fromAmount`.
|
|
52
|
+
*
|
|
53
|
+
* Getting this backwards double-counts a fee or hides one entirely, and in
|
|
54
|
+
* both directions the number on screen is wrong in the direction that
|
|
55
|
+
* flatters the route.
|
|
56
|
+
*/
|
|
57
|
+
includedInFromAmount: boolean;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The charges Relay reports, in the order a reader meets them.
|
|
61
|
+
*
|
|
62
|
+
* `fees.relayer` IS DELIBERATELY SKIPPED. It is the sum of `relayerGas` and
|
|
63
|
+
* `relayerService`, so listing it beside them would count the same money twice
|
|
64
|
+
* and make the breakdown disagree with the amount the sender pays.
|
|
65
|
+
*
|
|
66
|
+
* `fees.gas` is the sender's OWN origin-chain transaction cost. It sits outside
|
|
67
|
+
* `fromAmount` because the wallet pays it directly, which is exactly the case
|
|
68
|
+
* `includedInFromAmount` exists to mark.
|
|
69
|
+
* @param payload - the raw body from Relay's quote endpoint
|
|
70
|
+
* @returns the charges, in display order
|
|
71
|
+
*/
|
|
72
|
+
export declare const relayQuoteFees: (payload: unknown) => QuoteFee[];
|
|
73
|
+
/**
|
|
74
|
+
* The charges LI.FI reports.
|
|
75
|
+
*
|
|
76
|
+
* `feeCosts` CARRIES ITS OWN `included` FLAG and it is the whole point of
|
|
77
|
+
* reading this: a fee marked `included: false` is paid on top of `fromAmount`,
|
|
78
|
+
* in that fee's own token, and on a live route it was worth more than a dollar.
|
|
79
|
+
* `gasCosts` is the sender's own origin transaction and is never included.
|
|
80
|
+
* @param payload - the raw body from LI.FI's quote endpoint
|
|
81
|
+
* @returns the charges, in display order
|
|
82
|
+
*/
|
|
83
|
+
export declare const lifiQuoteFees: (payload: unknown) => QuoteFee[];
|
|
84
|
+
/**
|
|
85
|
+
* What the route costs the sender all in, in United States dollars.
|
|
86
|
+
*
|
|
87
|
+
* `fromAmount` already contains every charge marked included, so only the ones
|
|
88
|
+
* marked otherwise are added. This is the figure two providers must be compared
|
|
89
|
+
* on: ranking them on `fromAmount` alone picked LI.FI over Relay by more than a
|
|
90
|
+
* dollar on a route where LI.FI was in fact the dearer of the two, because its
|
|
91
|
+
* LayerZero fee is charged outside the amount.
|
|
92
|
+
*
|
|
93
|
+
* Returns null when the input's own dollar value is unknown — a partial total
|
|
94
|
+
* would rank routes against each other on different bases.
|
|
95
|
+
* @param quote.fromAmountUsd - the provider's dollar value for the input amount
|
|
96
|
+
* @param quote.fees - the route's charges
|
|
97
|
+
* @returns the all-in dollar cost, or null when it cannot be totalled
|
|
98
|
+
*/
|
|
99
|
+
export declare const totalQuoteCostUsd: ({ fromAmountUsd, fees, }: {
|
|
100
|
+
fromAmountUsd: string | null;
|
|
101
|
+
fees: QuoteFee[];
|
|
102
|
+
}) => number | null;
|