@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,524 @@
|
|
|
1
|
+
import type { ConsolidatedQuote, ConsolidatedQuoteRequest, ConsolidatedStatus } from './consolidated-quote.js';
|
|
2
|
+
import { type Ecosystem } from './ecosystems.js';
|
|
3
|
+
import type { PreQuoteRequest, PreQuoteResult } from './pre-quote.js';
|
|
4
|
+
import type { ProviderQuoteContext } from './providers.js';
|
|
5
|
+
/**
|
|
6
|
+
* NEAR Intents, through its "one click" quoting service.
|
|
7
|
+
*
|
|
8
|
+
* THIS PROVIDER CANNOT EXECUTE ON THE DESTINATION CHAIN, AND IS REGISTERED
|
|
9
|
+
* ANYWAY. Read both halves of that before changing anything here.
|
|
10
|
+
*
|
|
11
|
+
* The service validates its request body against a closed property list and
|
|
12
|
+
* answers `property destinationCall should not exist` for every name a call
|
|
13
|
+
* could travel under — `destinationCall`, `calldata`, `msg`, `txs`, `hook`,
|
|
14
|
+
* `action`, `postSwapAction`. The only thing nameable on the destination side
|
|
15
|
+
* is an address: `recipient`, with a `recipientType` of `DESTINATION_CHAIN`,
|
|
16
|
+
* `INTENTS` or `CONFIDENTIAL_INTENTS`. That is measured, not inferred from
|
|
17
|
+
* silence. `docs/near-intents-capability-survey.md` holds the evidence.
|
|
18
|
+
*
|
|
19
|
+
* DELIVERING TO THE MEDIATOR INSTEAD IS NOT A WAY AROUND IT, and the reason is
|
|
20
|
+
* structural rather than a matter of configuration. The service will happily
|
|
21
|
+
* deliver to a contract — a quote naming a well-known router as `recipient` is
|
|
22
|
+
* accepted. But every omnibridge entry point learns WHO THE READER IS from a
|
|
23
|
+
* data field: `transferAndCall` carries the recipient in its third argument,
|
|
24
|
+
* `relayTokens` in its second, `wrapAndRelayTokens` in its first. A plain
|
|
25
|
+
* token transfer has no data field. So a bare arrival cannot name a recipient,
|
|
26
|
+
* which means it can only ever credit the sender — the solver — or nobody at
|
|
27
|
+
* all. Do not attempt it.
|
|
28
|
+
*
|
|
29
|
+
* SO THE ROUTE TAKES TWO SIGNATURES, and the interface says so on the route
|
|
30
|
+
* strip rather than in a tooltip. The reader signs the origin transfer; NEAR
|
|
31
|
+
* Intents lands the anchor token in THEIR OWN WALLET on the entry chain; then
|
|
32
|
+
* they sign the ordinary bridge leg themselves. `near-intents-route.ts` builds
|
|
33
|
+
* that shape, and `executesDestinationCalls: false` on the descriptor is what
|
|
34
|
+
* keeps this provider out of the single-signature machinery, including the
|
|
35
|
+
* entry-anchor pre-quote — that phase feeds an exact-output target to the
|
|
36
|
+
* providers that DO execute, and a target only a non-executing provider can
|
|
37
|
+
* reach is a target nobody can fill.
|
|
38
|
+
*
|
|
39
|
+
* TWO SIZE FLOORS MAKE THIS A ROUTING RULE, NOT A FOOTNOTE. Binance Smart
|
|
40
|
+
* Chain — one of the two omnibridge entry chains — refuses any transfer worth
|
|
41
|
+
* one thousand United States dollars or less, in either direction, and Polygon
|
|
42
|
+
* and Tron carry floors of their own. The service imposed these on 2026-09-09
|
|
43
|
+
* and calls them temporary. Only asking reveals them, so a route has to be
|
|
44
|
+
* WITHDRAWN on a refusal rather than left to fail: see
|
|
45
|
+
* {@link NearIntentsQuoteRefusal} and `near-intents-route.ts`.
|
|
46
|
+
*/
|
|
47
|
+
/** Base address for the NEAR Intents one-click service. */
|
|
48
|
+
export declare const nearIntentsApiBaseUrl = "https://1click.chaindefuser.com";
|
|
49
|
+
/** Quote endpoint. Verified live: no key required, and a key-less request is answered in full. */
|
|
50
|
+
export declare const nearIntentsQuoteUrl = "https://1click.chaindefuser.com/v0/quote";
|
|
51
|
+
/** The list of assets the service can carry, keyed by its own asset identifiers. */
|
|
52
|
+
export declare const nearIntentsTokensUrl = "https://1click.chaindefuser.com/v0/tokens";
|
|
53
|
+
/**
|
|
54
|
+
* Optional notification that the reader's deposit has been sent. The service
|
|
55
|
+
* detects the deposit on its own; telling it the transaction hash only makes
|
|
56
|
+
* the detection faster. Takes `{ txHash, depositAddress }`.
|
|
57
|
+
*/
|
|
58
|
+
export declare const nearIntentsDepositSubmitUrl = "https://1click.chaindefuser.com/v0/deposit/submit";
|
|
59
|
+
/**
|
|
60
|
+
* What a key-less request costs, in basis points of the input amount.
|
|
61
|
+
*
|
|
62
|
+
* NOT A FEE THIS CODE CHARGES OR CAN DECLINE. The service inserts it into the
|
|
63
|
+
* echoed request as an `appFees` entry payable to its own account whenever no
|
|
64
|
+
* key is presented, so a reader on a key-less route pays a quarter of a percent
|
|
65
|
+
* that no part of this repository asked for. It is named here so the parser can
|
|
66
|
+
* surface it as a charge rather than let it disappear into the delivered
|
|
67
|
+
* amount. A partner key reduces it; obtaining one is an owner decision.
|
|
68
|
+
*/
|
|
69
|
+
export declare const nearIntentsUnauthenticatedFeeBasisPoints = 25;
|
|
70
|
+
/**
|
|
71
|
+
* What a partner-key request costs instead, in basis points of the input
|
|
72
|
+
* amount, for an ordinary (non-stablecoin) pair.
|
|
73
|
+
*
|
|
74
|
+
* Read from the service's own current documentation on 2026-09-18:
|
|
75
|
+
* `docs.near-intents.org/integration/distribution-channels/1click-api/authentication`.
|
|
76
|
+
* See `docs/near-intents-partner-key.md` for the full process of obtaining a
|
|
77
|
+
* key and what else changes once one is configured.
|
|
78
|
+
*/
|
|
79
|
+
export declare const nearIntentsAuthenticatedFeeBasisPoints = 20;
|
|
80
|
+
/**
|
|
81
|
+
* What a partner-key request costs on a stablecoin pair or a same-asset
|
|
82
|
+
* multi-chain route, in basis points of the input amount.
|
|
83
|
+
*
|
|
84
|
+
* Read from the same page as {@link nearIntentsAuthenticatedFeeBasisPoints} on
|
|
85
|
+
* 2026-09-18. Kept as its own constant rather than a special case of the other
|
|
86
|
+
* one because the service documents it as a distinct figure for a distinct
|
|
87
|
+
* class of route, not a discount computed from the ordinary rate.
|
|
88
|
+
*/
|
|
89
|
+
export declare const nearIntentsAuthenticatedStablecoinFeeBasisPoints = 1;
|
|
90
|
+
/**
|
|
91
|
+
* Builds the status-poll address for one quote.
|
|
92
|
+
*
|
|
93
|
+
* The deposit address IS the lookup key here, unlike every other provider in
|
|
94
|
+
* this repository, which key by a request identifier. Each quote is issued its
|
|
95
|
+
* own deposit address, so the two are one and the same fact — see
|
|
96
|
+
* {@link parseNearIntentsQuote}, which puts the deposit address in `quoteId`
|
|
97
|
+
* for exactly this reason.
|
|
98
|
+
*
|
|
99
|
+
* @param options.quoteId - the quote's deposit address
|
|
100
|
+
* @returns the fully-formed status address
|
|
101
|
+
*/
|
|
102
|
+
export declare const nearIntentsStatusUrl: ({ quoteId }: {
|
|
103
|
+
quoteId: string;
|
|
104
|
+
}) => string;
|
|
105
|
+
/**
|
|
106
|
+
* What this repository calls itself when it asks the one-click service.
|
|
107
|
+
*
|
|
108
|
+
* SENT BECAUSE THE SERVICE REFUSES SOME CALLERS BY NAME, and until now the
|
|
109
|
+
* name was whatever the runtime happened to supply. The service sits behind
|
|
110
|
+
* Cloudflare, which answers a refused caller with HTTP 403 and a body reading
|
|
111
|
+
* `error code: 1010` — a page, not a quote, so a parser sees a shape it cannot
|
|
112
|
+
* read and the whole provider looks like an outage.
|
|
113
|
+
*
|
|
114
|
+
* MEASURED against the live quote endpoint on 2026-09-21, one identical body,
|
|
115
|
+
* one header changed:
|
|
116
|
+
*
|
|
117
|
+
* | user agent | answer |
|
|
118
|
+
* | ------------------------- | ------ |
|
|
119
|
+
* | none (Node 26 default) | 201 |
|
|
120
|
+
* | `undici` | 201 |
|
|
121
|
+
* | `node` | 201 |
|
|
122
|
+
* | `curl/8.7.1` | 201 |
|
|
123
|
+
* | `python-requests/2.32` | 201 |
|
|
124
|
+
* | `Python-urllib/3.14` | 403 |
|
|
125
|
+
* | this value | 201 |
|
|
126
|
+
*
|
|
127
|
+
* So nothing is blocked today. The point is that whether we are blocked was
|
|
128
|
+
* being decided by a list we do not control, matched against a string we never
|
|
129
|
+
* chose — and a runtime upgrade could change that string without anyone here
|
|
130
|
+
* touching a line. Naming ourselves fixes the input to that decision.
|
|
131
|
+
*
|
|
132
|
+
* A BROWSER IGNORES THIS, and that is fine. `User-Agent` is a forbidden header
|
|
133
|
+
* name for `fetch`, so the browser drops it silently and sends its own. The
|
|
134
|
+
* value therefore governs Node alone: the live test harness, the deposit
|
|
135
|
+
* poller, and any script written later.
|
|
136
|
+
*/
|
|
137
|
+
export declare const nearIntentsUserAgent = "gibs-bridge/1.0 (+https://gibs.finance)";
|
|
138
|
+
/**
|
|
139
|
+
* Request headers for the one-click service.
|
|
140
|
+
*
|
|
141
|
+
* THE KEY IS A JSON WEB TOKEN, NOT A PLAIN IDENTIFIER LIKE RELAY'S. The
|
|
142
|
+
* service's own documentation accepts it as `Authorization: Bearer` as well as
|
|
143
|
+
* `X-API-Key`, calls it a "JWT token" throughout, and tells an integrator to
|
|
144
|
+
* "store your JWT token securely and never commit it to version control. Use
|
|
145
|
+
* environment variables or secure secret management systems." Relay's
|
|
146
|
+
* documentation says none of that about its key. `X-API-Key` is the form sent
|
|
147
|
+
* here because the service accepts it and it matches the header name Relay
|
|
148
|
+
* already uses, so one code path serves both — but the caller of this
|
|
149
|
+
* function decides where the value comes from, and that decision is where the
|
|
150
|
+
* secrecy question has to be answered. See `packages/ui/src/lib/config.ts`
|
|
151
|
+
* and `docs/near-intents-partner-key.md`.
|
|
152
|
+
*
|
|
153
|
+
* THE DEFAULT `User-Agent` NAMES GIBS FINANCE, AND THAT COSTS A CALLER
|
|
154
|
+
* NOTHING: it carries no key and no rate-limit budget, and a browser drops it.
|
|
155
|
+
* Pass `options.userAgent` to name yourself instead, or `null` to send none and
|
|
156
|
+
* let the runtime use its own.
|
|
157
|
+
*
|
|
158
|
+
* @param apiKey - a partner key, when one is configured
|
|
159
|
+
* @param options - `userAgent`: your own value, or `null` for none (defaults to {@link nearIntentsUserAgent})
|
|
160
|
+
* @returns the headers, carrying the key only when there is one to carry
|
|
161
|
+
*/
|
|
162
|
+
export declare const nearIntentsRequestHeaders: (apiKey?: string, options?: {
|
|
163
|
+
userAgent?: string | null;
|
|
164
|
+
}) => Record<string, string>;
|
|
165
|
+
/**
|
|
166
|
+
* Which side of the trade is fixed.
|
|
167
|
+
*
|
|
168
|
+
* - `EXACT_INPUT` — the reader names what they spend and the delivered amount
|
|
169
|
+
* is whatever the market gives. This is the shape a plain crossing asks for.
|
|
170
|
+
* - `EXACT_OUTPUT` — the delivered amount is fixed and the input is solved
|
|
171
|
+
* backward. The service adds the slippage cushion to `amountIn` and reports
|
|
172
|
+
* the uncushioned figure as `minAmountIn`, so the two differ by roughly the
|
|
173
|
+
* tolerance and neither is price degradation.
|
|
174
|
+
*
|
|
175
|
+
* - `FLEX_INPUT` — the reader is TOLD an amount but may send a slightly
|
|
176
|
+
* different one. The slippage tolerance becomes a band rather than a
|
|
177
|
+
* cushion: the service names `minAmountIn` about one percent below the
|
|
178
|
+
* quote and fills anything at or above it, and it swaps an overpayment
|
|
179
|
+
* instead of bouncing it. This is what a deposit-address origin sends, and
|
|
180
|
+
* it is not a preference — a reader typing a figure into an exchange
|
|
181
|
+
* withdrawal form misses the exact amount routinely, and under
|
|
182
|
+
* `EXACT_INPUT` every one of those payments is refunded three days later
|
|
183
|
+
* instead of filled. Measured on a Zcash origin: one Zcash quoted
|
|
184
|
+
* `amountIn` 100,000,000 and `minAmountIn` 99,000,000.
|
|
185
|
+
*
|
|
186
|
+
* The service also offers `ANY_INPUT`, which is gated to authorized partners
|
|
187
|
+
* and is not modelled. One exclusion applies to the flexible mode:
|
|
188
|
+
* `CONFIDENTIAL_INTENTS` is not supported with it. Nothing here uses that.
|
|
189
|
+
*/
|
|
190
|
+
export type NearIntentsSwapType = 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'FLEX_INPUT';
|
|
191
|
+
/**
|
|
192
|
+
* Where the funds come from, and where a refund goes back to.
|
|
193
|
+
*
|
|
194
|
+
* The deposit is always `ORIGIN_CHAIN`: the reader holds their funds on a real
|
|
195
|
+
* chain. The refund is `ORIGIN_CHAIN` too, except on a chain the reader pays by
|
|
196
|
+
* hand, where it is `INTENTS` — a balance inside NEAR Intents itself, named for
|
|
197
|
+
* the reader's own Ethereum account. `CONFIDENTIAL_INTENTS` is never built.
|
|
198
|
+
*/
|
|
199
|
+
export type NearIntentsAccountKind = 'ORIGIN_CHAIN' | 'INTENTS' | 'CONFIDENTIAL_INTENTS';
|
|
200
|
+
/**
|
|
201
|
+
* Where the delivered funds land.
|
|
202
|
+
*
|
|
203
|
+
* EVERY VALUE IS AN ADDRESS, and that is the whole of the destination-execution
|
|
204
|
+
* finding stated as a type. There is no variant that names a contract call.
|
|
205
|
+
*/
|
|
206
|
+
export type NearIntentsRecipientKind = 'DESTINATION_CHAIN' | 'INTENTS' | 'CONFIDENTIAL_INTENTS';
|
|
207
|
+
/** The JSON body for `POST /v0/quote`. */
|
|
208
|
+
export type NearIntentsQuoteRequestBody = {
|
|
209
|
+
/**
|
|
210
|
+
* Ask for a price without reserving anything. A dry answer omits
|
|
211
|
+
* `depositAddress`, `deadline` and `timeWhenInactive`, so it can price a
|
|
212
|
+
* route but can never execute one.
|
|
213
|
+
*/
|
|
214
|
+
dry: boolean;
|
|
215
|
+
swapType: NearIntentsSwapType;
|
|
216
|
+
/** Maximum slippage in basis points (100 means one percent). */
|
|
217
|
+
slippageTolerance: number;
|
|
218
|
+
/** The service's own identifier for the origin asset, e.g. `nep141:base.omft.near`. */
|
|
219
|
+
originAsset: string;
|
|
220
|
+
depositType: NearIntentsAccountKind;
|
|
221
|
+
/** The service's own identifier for the delivered asset. */
|
|
222
|
+
destinationAsset: string;
|
|
223
|
+
/** The fixed side of the trade, in that asset's base units, as a decimal string. */
|
|
224
|
+
amount: string;
|
|
225
|
+
/**
|
|
226
|
+
* Where a refund goes: the reader's origin-chain address for an
|
|
227
|
+
* `ORIGIN_CHAIN` refund, or a lower-cased Ethereum address naming an account
|
|
228
|
+
* inside NEAR Intents for an `INTENTS` refund.
|
|
229
|
+
*/
|
|
230
|
+
refundTo: string;
|
|
231
|
+
refundType: NearIntentsAccountKind;
|
|
232
|
+
/** Destination-chain address the funds are delivered to. */
|
|
233
|
+
recipient: string;
|
|
234
|
+
recipientType: NearIntentsRecipientKind;
|
|
235
|
+
/**
|
|
236
|
+
* When an unfilled swap starts refunding, as an ISO 8601 instant. It has to
|
|
237
|
+
* outlast the deposit's own confirmation time, which is why a Bitcoin origin
|
|
238
|
+
* needs far longer than an Ethereum one.
|
|
239
|
+
*
|
|
240
|
+
* A REQUEST, NOT A SETTING. The answer carries its own `deadline` three days
|
|
241
|
+
* later — see {@link defaultDeadlineMilliseconds}.
|
|
242
|
+
*/
|
|
243
|
+
deadline: string;
|
|
244
|
+
/** Distribution-channel tag. The service requires lower case. */
|
|
245
|
+
referral?: string;
|
|
246
|
+
};
|
|
247
|
+
/** One asset the service can carry, as `GET /v0/tokens` reports it. */
|
|
248
|
+
export type NearIntentsAsset = {
|
|
249
|
+
/** The identifier a quote request must use for this asset. */
|
|
250
|
+
assetId: string;
|
|
251
|
+
/** The service's own short name for the chain, e.g. `eth`, `base`, `sol`. */
|
|
252
|
+
blockchain: string;
|
|
253
|
+
symbol: string;
|
|
254
|
+
decimals: number;
|
|
255
|
+
/**
|
|
256
|
+
* The asset's address on its own chain, or null for a chain's native coin.
|
|
257
|
+
*
|
|
258
|
+
* ONLY DEPENDABLE FOR AN ETHEREUM-VIRTUAL-MACHINE CHAIN. Solana's USD Coin is
|
|
259
|
+
* reported here as a twenty-byte hexadecimal handle rather than its real
|
|
260
|
+
* base58 mint, so matching a Solana token by its on-chain address against
|
|
261
|
+
* this field finds nothing. That is why {@link findNearIntentsAsset} takes an
|
|
262
|
+
* ecosystem and refuses to guess for the families where the field is not the
|
|
263
|
+
* address it appears to be.
|
|
264
|
+
*/
|
|
265
|
+
contractAddress: string | null;
|
|
266
|
+
/**
|
|
267
|
+
* The service's own United States dollar price for this asset, or null
|
|
268
|
+
* when the response carried none. Verified live against `GET /v0/tokens`,
|
|
269
|
+
* 2026-09-24 — every entry checked carried one (e.g. wrapped NEAR at
|
|
270
|
+
* 3.11), so `null` here means an unpriced or malformed entry, not an
|
|
271
|
+
* absent field this parser failed to read.
|
|
272
|
+
*/
|
|
273
|
+
price: number | null;
|
|
274
|
+
/**
|
|
275
|
+
* When the service last refreshed {@link price}, as the ISO 8601 instant
|
|
276
|
+
* it reports — or null when the response carried none. Kept alongside the
|
|
277
|
+
* price rather than assumed fresh, so a caller pricing a route can tell a
|
|
278
|
+
* live figure from a stale one.
|
|
279
|
+
*/
|
|
280
|
+
priceUpdatedAt: string | null;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* This repository's chain identifiers, keyed by the service's short chain name.
|
|
284
|
+
*
|
|
285
|
+
* The Ethereum-virtual-machine entries are read from viem rather than written
|
|
286
|
+
* down, because a chain identifier typed from memory is a hypothesis that every
|
|
287
|
+
* later reader will trust — and a wrong one here does not fail loudly, it
|
|
288
|
+
* simply quotes a different chain's token.
|
|
289
|
+
*
|
|
290
|
+
* The non-Ethereum entries are this repository's own identifiers for those
|
|
291
|
+
* families, which are Relay's numbers (see {@link relayChainIds}); the service
|
|
292
|
+
* uses short names and has no numeric identifier of its own to reconcile with.
|
|
293
|
+
*
|
|
294
|
+
* DELIBERATELY SHORTER THAN THE SERVICE'S CHAIN LIST. The service names about
|
|
295
|
+
* thirty-five chains. Only the ones this bridge can actually originate from or
|
|
296
|
+
* enter are listed, because an unlisted chain resolves to no asset and
|
|
297
|
+
* therefore to no route, which is the honest outcome, whereas a guessed
|
|
298
|
+
* identifier resolves to a route on the wrong chain.
|
|
299
|
+
*/
|
|
300
|
+
export declare const chainIdByNearIntentsChain: ReadonlyMap<string, number>;
|
|
301
|
+
/**
|
|
302
|
+
* Reads `GET /v0/tokens` into the asset records the identifier lookup needs.
|
|
303
|
+
*
|
|
304
|
+
* An entry missing any field the lookup reads is dropped rather than patched
|
|
305
|
+
* with a default: an asset whose decimals were invented would price every
|
|
306
|
+
* amount wrong by orders of magnitude, and an asset whose identifier is
|
|
307
|
+
* missing cannot be quoted at all.
|
|
308
|
+
*
|
|
309
|
+
* @param payload - the raw JSON body from `GET /v0/tokens`
|
|
310
|
+
* @returns every readable asset, in the order the service listed them
|
|
311
|
+
*/
|
|
312
|
+
export declare const parseNearIntentsTokens: (payload: unknown) => NearIntentsAsset[];
|
|
313
|
+
/**
|
|
314
|
+
* Finds the service's identifier for one token on one chain.
|
|
315
|
+
*
|
|
316
|
+
* THE IDENTIFIER CANNOT BE CONSTRUCTED, ONLY LOOKED UP. It reads like a
|
|
317
|
+
* pattern — a chain name, the token's address, a fixed suffix — and for an
|
|
318
|
+
* Ethereum-virtual-machine token it currently is one. It is not one for the
|
|
319
|
+
* other families: Solana's USD Coin carries a hexadecimal handle that is
|
|
320
|
+
* nothing like its base58 mint. Building the string from its parts therefore
|
|
321
|
+
* produces an identifier that is well-formed and refers to nothing, so the
|
|
322
|
+
* asset list is the only source.
|
|
323
|
+
*
|
|
324
|
+
* @param options.assets - the parsed asset list
|
|
325
|
+
* @param options.chainId - this repository's identifier for the chain
|
|
326
|
+
* @param options.tokenAddress - the token's address on that chain
|
|
327
|
+
* @param options.ecosystem - the chain's virtual-machine family, which decides
|
|
328
|
+
* whether the native-coin test and the address comparison are meaningful
|
|
329
|
+
* @returns the matching asset, or null when the service does not carry it
|
|
330
|
+
*/
|
|
331
|
+
export declare const findNearIntentsAsset: ({ assets, chainId, tokenAddress, ecosystem, }: {
|
|
332
|
+
assets: readonly NearIntentsAsset[];
|
|
333
|
+
chainId: number;
|
|
334
|
+
tokenAddress: string;
|
|
335
|
+
ecosystem: Ecosystem;
|
|
336
|
+
}) => NearIntentsAsset | null;
|
|
337
|
+
/**
|
|
338
|
+
* Converts a slippage fraction into the basis points the service expects.
|
|
339
|
+
*
|
|
340
|
+
* @param slippage - tolerance as a fraction (0.005 means half a percent)
|
|
341
|
+
* @returns basis points (0.005 becomes 50)
|
|
342
|
+
*/
|
|
343
|
+
export declare const slippageToNearIntentsBasisPoints: (slippage: number) => number;
|
|
344
|
+
/**
|
|
345
|
+
* The smallest Zcash deposit that can actually be credited, in base units:
|
|
346
|
+
* 0.01 Zcash.
|
|
347
|
+
*
|
|
348
|
+
* THE LARGER OF TWO FIGURES THAT DISAGREE. The quoting service prices a Zcash
|
|
349
|
+
* input down to about two cents — the smaller floor, read live from its
|
|
350
|
+
* refusal by {@link parseNearIntentsQuoteRefusal}. But Zcash crosses on the
|
|
351
|
+
* Proof of Authority bridge, not the Omni Bridge, and that bridge publishes
|
|
352
|
+
* `min_deposit_amount: 1000000` for native Zcash. A quote between the two is
|
|
353
|
+
* priced by one surface and below the other's floor, so it takes the money and
|
|
354
|
+
* stalls — and the published stuck-deposit recovery flow is written for the
|
|
355
|
+
* Omni Bridge, so it does not cover Zcash. Measured 2026-09-21; see
|
|
356
|
+
* `docs/near-intents-capability-survey.md`.
|
|
357
|
+
*/
|
|
358
|
+
export declare const zcashWorkingFloorBaseUnits = 1000000n;
|
|
359
|
+
/**
|
|
360
|
+
* The working floor for a pay-by-hand chain, in base units, or null when the
|
|
361
|
+
* chain has none registered.
|
|
362
|
+
*
|
|
363
|
+
* EXPORTED SO A SCREEN NEVER KEEPS ITS OWN COPY. {@link isBelowWorkingFloor} is
|
|
364
|
+
* the decision this library enforces when quoting; this is the SAME table,
|
|
365
|
+
* exposed so a payment screen can PRINT the figure it refuses under instead of
|
|
366
|
+
* hand-copying the table — a copy that would silently disagree with quoting
|
|
367
|
+
* the moment a second pay-by-hand chain gets a floor here and not there.
|
|
368
|
+
*
|
|
369
|
+
* @param chainId - the origin chain
|
|
370
|
+
* @returns the floor in base units, or null when the chain has none
|
|
371
|
+
*/
|
|
372
|
+
export declare const workingFloorFor: (chainId: number) => bigint | null;
|
|
373
|
+
/**
|
|
374
|
+
* Whether an amount is below the floor a deposit on this chain can actually
|
|
375
|
+
* be credited at.
|
|
376
|
+
*
|
|
377
|
+
* ASK IT BEFORE ASKING FOR A LIVE QUOTE. The quote request builder already
|
|
378
|
+
* declines such an amount, so no deposit address is ever issued for money that
|
|
379
|
+
* would stall. This predicate lets a surface say WHY there is no route, and
|
|
380
|
+
* what size would work.
|
|
381
|
+
*
|
|
382
|
+
* @param options.chainId - the origin chain
|
|
383
|
+
* @param options.amount - the input, in base units of the origin asset
|
|
384
|
+
* @returns whether the amount is below that chain's working floor
|
|
385
|
+
*/
|
|
386
|
+
export declare const isBelowWorkingFloor: ({ chainId, amount, }: {
|
|
387
|
+
chainId: number;
|
|
388
|
+
amount: bigint;
|
|
389
|
+
}) => boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Builds the forward-solving origin-to-anchor pre-quote body.
|
|
392
|
+
*
|
|
393
|
+
* READ THE HEAD OF THIS MODULE BEFORE CALLING THIS FROM THE ROUTER. The
|
|
394
|
+
* entry-anchor pre-quote takes the largest delivered amount across providers
|
|
395
|
+
* and hands it to the providers that execute, so a pre-quote from a provider
|
|
396
|
+
* that cannot execute raises a target nobody can reach. This builder exists
|
|
397
|
+
* because the request shape is real and testable, not because that wiring is
|
|
398
|
+
* wanted.
|
|
399
|
+
*
|
|
400
|
+
* @param request - the provider-agnostic pre-quote request
|
|
401
|
+
* @param options - the asset list, the clock, and the referral tag
|
|
402
|
+
* @returns the request body, or null when the service carries neither asset or
|
|
403
|
+
* the amount is not positive
|
|
404
|
+
*/
|
|
405
|
+
export declare const buildNearIntentsPreQuoteRequest: (request: PreQuoteRequest, context?: ProviderQuoteContext) => NearIntentsQuoteRequestBody | null;
|
|
406
|
+
/**
|
|
407
|
+
* Builds the execution quote body for a crossing with nothing to run on arrival.
|
|
408
|
+
*
|
|
409
|
+
* REFUSES ANY REQUEST CARRYING A DESTINATION CALL, and that refusal is the
|
|
410
|
+
* whole point of it. The service has no field a call can travel in, so a
|
|
411
|
+
* request built without the call would look like a valid quote for the same
|
|
412
|
+
* route and would deliver the reader's funds to an address instead of into the
|
|
413
|
+
* omnibridge — a silent, funds-affecting difference. Returning null leaves that
|
|
414
|
+
* route to the providers that execute.
|
|
415
|
+
*
|
|
416
|
+
* @param request - the provider-agnostic consolidated request
|
|
417
|
+
* @param context - carries the asset list, the clock and the referral tag
|
|
418
|
+
* @param options.dry - price only, reserving nothing. What a route ON DISPLAY
|
|
419
|
+
* must ask; a live quote reserves a deposit address for three days, so it is
|
|
420
|
+
* asked only when the reader commits. See `UnreservedDeposit`.
|
|
421
|
+
* @returns the request body, or null when the route needs a destination call,
|
|
422
|
+
* names no input amount, or the service carries neither asset
|
|
423
|
+
*/
|
|
424
|
+
export declare const buildNearIntentsQuoteRequest: (request: ConsolidatedQuoteRequest, context?: ProviderQuoteContext, { dry }?: {
|
|
425
|
+
dry?: boolean;
|
|
426
|
+
}) => NearIntentsQuoteRequestBody | null;
|
|
427
|
+
/**
|
|
428
|
+
* Parses a quote response into the delivered amounts a pre-quote reports.
|
|
429
|
+
*
|
|
430
|
+
* `amountOut` is the expected delivery and `minAmountOut` the guaranteed floor
|
|
431
|
+
* after slippage, which is the same pair the other providers' pre-quote parsers
|
|
432
|
+
* produce, so the three rank on like figures.
|
|
433
|
+
*
|
|
434
|
+
* @param payload - the raw JSON body from `POST /v0/quote`
|
|
435
|
+
* @returns the delivered amounts, or null when the payload is an error or
|
|
436
|
+
* otherwise not a quote
|
|
437
|
+
*/
|
|
438
|
+
export declare const parseNearIntentsPreQuote: (payload: unknown) => PreQuoteResult | null;
|
|
439
|
+
/**
|
|
440
|
+
* A normalized NEAR Intents quote.
|
|
441
|
+
*
|
|
442
|
+
* An alias of the shared shape rather than a variant of it: a quote from here
|
|
443
|
+
* ranks, displays and resumes exactly like the others. What differs is the
|
|
444
|
+
* shape of the ROUTE built around it — two signatures rather than one, because
|
|
445
|
+
* this provider delivers to an address and runs nothing on arrival. That
|
|
446
|
+
* difference lives in `near-intents-route.ts`, not in the quote.
|
|
447
|
+
*/
|
|
448
|
+
export type NearIntentsQuote = ConsolidatedQuote;
|
|
449
|
+
/**
|
|
450
|
+
* Normalizes a DRY answer into a quote that can be drawn and not paid.
|
|
451
|
+
*
|
|
452
|
+
* Same figures, fees and timing as a live quote; its deposit is
|
|
453
|
+
* {@link UnreservedDeposit} and its `quoteId` is empty, because a dry answer
|
|
454
|
+
* reserves no address and the address is a quote's identity. A caller that
|
|
455
|
+
* reaches the commit asks live with `buildNearIntentsQuoteRequest(…, { dry:
|
|
456
|
+
* false })` and pays that answer instead.
|
|
457
|
+
*
|
|
458
|
+
* @param payload - the raw JSON body of a `dry: true` quote
|
|
459
|
+
* @param context - the same context the live parser reads
|
|
460
|
+
* @returns the priced quote, or null when the body is not a quote
|
|
461
|
+
*/
|
|
462
|
+
export declare const parseNearIntentsPriceQuote: (payload: unknown, context?: ProviderQuoteContext) => NearIntentsQuote | null;
|
|
463
|
+
export declare const parseNearIntentsQuote: (payload: unknown, context?: ProviderQuoteContext) => NearIntentsQuote | null;
|
|
464
|
+
/**
|
|
465
|
+
* Why the service declined to quote a route.
|
|
466
|
+
*
|
|
467
|
+
* TWO DIFFERENT FLOORS, AND THEY ARE NOT THE SAME KIND OF THING. One is
|
|
468
|
+
* economics and one is policy, they are measured in different units, and a
|
|
469
|
+
* caller that treats them alike will tell a reader the wrong number.
|
|
470
|
+
*
|
|
471
|
+
* - `belowChainMinimum` is an administrative floor on a whole chain, stated in
|
|
472
|
+
* United States dollars. On 2026-09-17 it stood at one thousand dollars for
|
|
473
|
+
* Binance Smart Chain and Polygon and one hundred for Tron, with no floor on
|
|
474
|
+
* the other chains measured. The service's own wording calls it TEMPORARY, so
|
|
475
|
+
* it is a figure to read from an answer, never one to write into this
|
|
476
|
+
* repository — and it has already moved once, on 2026-09-09, when it was
|
|
477
|
+
* introduced on nine chains of which only two still enforce it.
|
|
478
|
+
*
|
|
479
|
+
* IT IS CHECKED AGAINST THE AMOUNT ASKED FOR, WHICHEVER SIDE THAT IS, not
|
|
480
|
+
* against what the reader spends. Measured: a backward-solved request for
|
|
481
|
+
* 999 USD Coin on Binance Smart Chain is refused even though it would take
|
|
482
|
+
* about 1,011 dollars of input to fill. So a route cannot be slipped under
|
|
483
|
+
* the floor by asking the other way round, and a caller estimating whether
|
|
484
|
+
* this provider will bid must compare the floor to the side it is asking for.
|
|
485
|
+
* - `belowBridgeMinimum` is the economic floor: a transfer so small the
|
|
486
|
+
* withdrawal fee would consume it. The service quotes the figure live, in the
|
|
487
|
+
* ORIGIN asset's base units, and it moves between requests because it tracks
|
|
488
|
+
* that fee.
|
|
489
|
+
*
|
|
490
|
+
* Both arrive as HTTP 400 with a `message`, which is why they have to be read
|
|
491
|
+
* out of the body rather than inferred from the status.
|
|
492
|
+
*/
|
|
493
|
+
export type NearIntentsQuoteRefusal = {
|
|
494
|
+
reason: 'belowChainMinimum';
|
|
495
|
+
minimumUsd: number;
|
|
496
|
+
} | {
|
|
497
|
+
reason: 'belowBridgeMinimum';
|
|
498
|
+
minimumAmount: bigint;
|
|
499
|
+
} | {
|
|
500
|
+
reason: 'noLiquidity';
|
|
501
|
+
} | {
|
|
502
|
+
reason: 'other';
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* Reads why a quote request was declined.
|
|
506
|
+
*
|
|
507
|
+
* WORTH READING RATHER THAN TREATING AS A FAILURE. A route below one of these
|
|
508
|
+
* floors is not a fault to retry — it is a route this provider will never
|
|
509
|
+
* carry at that size, so a router can drop the provider from the competition
|
|
510
|
+
* and a surface can say what size would work. Left as a bare rejection, the
|
|
511
|
+
* same route simply produces a slower answer with one fewer bidder and nothing
|
|
512
|
+
* on screen to explain it.
|
|
513
|
+
*
|
|
514
|
+
* @param payload - the raw JSON body of a declined `POST /v0/quote`
|
|
515
|
+
* @returns the refusal, or null when the body carries no message to read
|
|
516
|
+
*/
|
|
517
|
+
export declare const parseNearIntentsQuoteRefusal: (payload: unknown) => NearIntentsQuoteRefusal | null;
|
|
518
|
+
/**
|
|
519
|
+
* Normalizes a `GET /v0/status` response.
|
|
520
|
+
*
|
|
521
|
+
* @param payload - the raw JSON body
|
|
522
|
+
* @returns the normalized status, or null when the payload names no status
|
|
523
|
+
*/
|
|
524
|
+
export declare const parseNearIntentsStatus: (payload: unknown) => ConsolidatedStatus | null;
|