@gibs/bridge-sdk 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +234 -432
- package/dist/abis.d.ts +1 -0
- package/dist/bridge-limits.d.ts +103 -0
- package/dist/bridge-limits.js +84 -0
- package/dist/chain-info.d.ts +169 -0
- package/dist/chain-info.js +410 -0
- package/dist/chain-names.d.ts +160 -0
- package/dist/chain-names.js +200 -0
- package/dist/chains.d.ts +65 -0
- package/dist/chains.js +284 -0
- package/dist/config.d.ts +216 -0
- package/dist/config.js +493 -0
- package/dist/consolidated-quote.d.ts +554 -0
- package/dist/consolidated-quote.js +773 -0
- package/dist/destination-calldata.d.ts +118 -0
- package/dist/destination-calldata.js +152 -0
- package/dist/ecosystems.d.ts +217 -0
- package/dist/ecosystems.js +288 -0
- package/dist/fee-type.d.ts +10 -0
- package/dist/fee-type.js +9 -0
- package/dist/hyperliquid-execution.d.ts +152 -0
- package/dist/hyperliquid-execution.js +168 -0
- package/dist/image-links.d.ts +117 -0
- package/dist/image-links.js +142 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/lifi-execution-guard.d.ts +199 -0
- package/dist/lifi-execution-guard.js +400 -0
- package/dist/near-intents-conformance.d.ts +85 -0
- package/dist/near-intents-conformance.js +329 -0
- package/dist/near-intents-route.d.ts +47 -0
- package/dist/near-intents-route.js +265 -0
- package/dist/near-intents.d.ts +524 -0
- package/dist/near-intents.js +1055 -0
- package/dist/origin-deposit.d.ts +326 -0
- package/dist/origin-deposit.js +68 -0
- package/dist/pre-quote.d.ts +198 -0
- package/dist/pre-quote.js +175 -0
- package/dist/prices.d.ts +107 -0
- package/dist/prices.js +162 -0
- package/dist/providers.d.ts +221 -0
- package/dist/providers.js +157 -0
- package/dist/quote-fees.d.ts +102 -0
- package/dist/quote-fees.js +195 -0
- package/dist/referral.d.ts +77 -0
- package/dist/referral.js +72 -0
- package/dist/relay-currencies.d.ts +47 -0
- package/dist/relay-currencies.js +89 -0
- package/dist/relay-quote.d.ts +301 -0
- package/dist/relay-quote.js +983 -0
- package/dist/route-steps.d.ts +138 -0
- package/dist/route-steps.js +305 -0
- package/dist/routing/amounts.d.ts +80 -0
- package/dist/routing/amounts.js +120 -0
- package/dist/routing/candidate-route.d.ts +43 -0
- package/dist/routing/candidate-route.js +45 -0
- package/dist/routing/candidate.d.ts +237 -0
- package/dist/routing/candidate.js +96 -0
- package/dist/routing/carriers/ask-answer.d.ts +58 -0
- package/dist/routing/carriers/ask-answer.js +1 -0
- package/dist/routing/carriers/omnibridge.d.ts +137 -0
- package/dist/routing/carriers/omnibridge.js +419 -0
- package/dist/routing/carriers/pulsex.d.ts +111 -0
- package/dist/routing/carriers/pulsex.js +404 -0
- package/dist/routing/carriers/wrap.d.ts +25 -0
- package/dist/routing/carriers/wrap.js +115 -0
- package/dist/routing/composed-route-quality.d.ts +103 -0
- package/dist/routing/composed-route-quality.js +108 -0
- package/dist/routing/entry-chain-anchor.d.ts +88 -0
- package/dist/routing/entry-chain-anchor.js +55 -0
- package/dist/routing/format.d.ts +31 -0
- package/dist/routing/format.js +58 -0
- package/dist/routing/index.d.ts +34 -0
- package/dist/routing/index.js +42 -0
- package/dist/routing/producers.d.ts +770 -0
- package/dist/routing/producers.js +1564 -0
- package/dist/routing/providers.d.ts +26 -0
- package/dist/routing/providers.js +38 -0
- package/dist/routing/route-data.d.ts +355 -0
- package/dist/routing/route-data.js +1 -0
- package/dist/routing/search/compose.d.ts +168 -0
- package/dist/routing/search/compose.js +98 -0
- package/dist/routing/search/graph.d.ts +639 -0
- package/dist/routing/search/graph.js +445 -0
- package/dist/routing/search/plan-route-data.d.ts +244 -0
- package/dist/routing/search/plan-route-data.js +767 -0
- package/dist/routing/search/score.d.ts +324 -0
- package/dist/routing/search/score.js +400 -0
- package/dist/routing/usd-value.d.ts +17 -0
- package/dist/routing/usd-value.js +25 -0
- package/dist/settings.d.ts +692 -0
- package/dist/settings.js +909 -0
- package/dist/ton-execution.d.ts +117 -0
- package/dist/ton-execution.js +247 -0
- package/dist/tron-execution.d.ts +146 -0
- package/dist/tron-execution.js +239 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.js +1 -0
- package/package.json +203 -23
- package/src/chain-info.test.ts +0 -968
- package/src/chain-info.ts +0 -498
- package/src/chains.test.ts +0 -123
- package/src/chains.ts +0 -88
- package/src/config.test.ts +0 -679
- package/src/config.ts +0 -500
- package/src/fee-type.test.ts +0 -45
- package/src/fee-type.ts +0 -14
- package/src/image-links.test.ts +0 -160
- package/src/image-links.ts +0 -65
- package/src/index.ts +0 -8
- package/src/settings.test.ts +0 -2754
- package/src/settings.ts +0 -875
- package/src/types.ts +0 -48
- package/tsconfig.json +0 -17
- package/vitest.config.ts +0 -13
- /package/{src/abis.ts → dist/abis.js} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay currencies endpoint. Anonymous access works at the same 50-requests-per-
|
|
3
|
+
* minute tier as the quote endpoint; used to discover the source tokens a
|
|
4
|
+
* non-Ethereum origin chain (Solana, Bitcoin) can bridge from.
|
|
5
|
+
*/
|
|
6
|
+
export const relayCurrenciesUrl = 'https://api.relay.link/currencies/v2';
|
|
7
|
+
/**
|
|
8
|
+
* Builds the Relay currencies request body.
|
|
9
|
+
*
|
|
10
|
+
* @returns the request body, or null when no chain ids are supplied
|
|
11
|
+
*/
|
|
12
|
+
export const buildRelayCurrenciesRequest = ({ chainIds, limit, }) => {
|
|
13
|
+
if (chainIds.length === 0) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return { chainIds, ...(limit === undefined ? {} : { limit }) };
|
|
17
|
+
};
|
|
18
|
+
const asRecord = (value) => {
|
|
19
|
+
if (typeof value !== 'object' || value === null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Relay's own chain registry — the provider's word on which chains it
|
|
26
|
+
* supports AT ALL, distinct from `/currencies/v2` (which chains currently
|
|
27
|
+
* have priced currencies). A chain absent here can never be asked about, on
|
|
28
|
+
* `/currencies/v2` or `/quote` alike; see `parseRelayChains`.
|
|
29
|
+
*/
|
|
30
|
+
export const relayChainsUrl = 'https://api.relay.link/chains';
|
|
31
|
+
/**
|
|
32
|
+
* Normalizes a `GET /chains` response body to the chain ids Relay lists.
|
|
33
|
+
* Mirrors `parseLifiChains` (`consolidated-quote.ts`) for LI.FI's own chain
|
|
34
|
+
* list: read the provider's own registry, never a hand-written exclusion.
|
|
35
|
+
*
|
|
36
|
+
* @returns the chain ids Relay lists, or null when the payload shape is unexpected
|
|
37
|
+
*/
|
|
38
|
+
export const parseRelayChains = (payload) => {
|
|
39
|
+
const body = asRecord(payload);
|
|
40
|
+
if (body === null || !Array.isArray(body.chains)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const ids = [];
|
|
44
|
+
for (const chain of body.chains) {
|
|
45
|
+
const record = asRecord(chain);
|
|
46
|
+
if (record !== null && typeof record.id === 'number') {
|
|
47
|
+
ids.push(record.id);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return ids;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Maps Relay's flat `/currencies/v2` array onto the shared `Token` shape. A
|
|
54
|
+
* Relay currency's `address` is already a string (a Solana mint or a Bitcoin
|
|
55
|
+
* native address), so no widening is needed. Malformed entries are skipped
|
|
56
|
+
* rather than failing the whole list.
|
|
57
|
+
*
|
|
58
|
+
* @returns the tokens, or an empty list when the payload is not an array
|
|
59
|
+
*/
|
|
60
|
+
export const parseRelayCurrencies = (payload) => {
|
|
61
|
+
if (!Array.isArray(payload)) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
const tokens = [];
|
|
65
|
+
for (const entry of payload) {
|
|
66
|
+
const record = asRecord(entry);
|
|
67
|
+
if (!record) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const { chainId, address, symbol, name, decimals } = record;
|
|
71
|
+
if (typeof chainId !== 'number' ||
|
|
72
|
+
typeof address !== 'string' ||
|
|
73
|
+
typeof symbol !== 'string' ||
|
|
74
|
+
typeof name !== 'string' ||
|
|
75
|
+
typeof decimals !== 'number') {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const metadata = asRecord(record.metadata);
|
|
79
|
+
tokens.push({
|
|
80
|
+
chainId,
|
|
81
|
+
address,
|
|
82
|
+
symbol,
|
|
83
|
+
name,
|
|
84
|
+
decimals,
|
|
85
|
+
logoURI: typeof metadata?.logoURI === 'string' ? metadata.logoURI : null,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return tokens;
|
|
89
|
+
};
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { type Hex } from 'viem';
|
|
2
|
+
import { type ConsolidatedQuote, type ConsolidatedQuoteRequest, type ConsolidatedStatus } from './consolidated-quote.js';
|
|
3
|
+
import type { Ecosystem } from './ecosystems.js';
|
|
4
|
+
/**
|
|
5
|
+
* Relay (relay.link) as a second consolidated-route quote provider, competing
|
|
6
|
+
* with LI.FI on price. Relay quotes the same backwards-from-destination route:
|
|
7
|
+
* deliver exactly `toAmount` of the Ethereum-side token, then run our omnibridge
|
|
8
|
+
* entry call against it.
|
|
9
|
+
*
|
|
10
|
+
* One semantic differs from LI.FI and the difference is load-bearing. Relay has
|
|
11
|
+
* NO destination-chain fallback address. When the destination call cannot fill,
|
|
12
|
+
* Relay refunds on the ORIGIN chain to `refundTo`, in the origin currency — the
|
|
13
|
+
* user ends up back where they started, not holding the Ethereum-side token at
|
|
14
|
+
* a fallback. We therefore map our `fallbackAddress` onto `refundTo`; a failed
|
|
15
|
+
* Relay route is recovered on the origin chain, never stranded on Ethereum.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Relay's API root. Steps carry RELATIVE post endpoints (`/authorize`), so a
|
|
19
|
+
* caller completing one has to resolve it against this.
|
|
20
|
+
*/
|
|
21
|
+
export declare const relayApiBaseUrl = "https://api.relay.link";
|
|
22
|
+
/** Relay quote endpoint. Anonymous access works at a 50-requests-per-minute tier. */
|
|
23
|
+
export declare const relayQuoteUrl = "https://api.relay.link/quote/v2";
|
|
24
|
+
/** Relay requests endpoint; filters by origin or destination transaction hash. */
|
|
25
|
+
/**
|
|
26
|
+
* The request-lookup endpoint, used to poll a route's progress.
|
|
27
|
+
*
|
|
28
|
+
* v3 RATHER THAN v2 BECAUSE v2 IS GOING AWAY. Relay began staged rate limiting
|
|
29
|
+
* of `/requests/v2` on 2026-09-01 and retires it on 2026-11-24, saying so in a
|
|
30
|
+
* `deprecation` block on every v2 response. v3 REQUIRES `x-api-key` - it
|
|
31
|
+
* answers 400 without one, where v2 served anonymous callers from a shared
|
|
32
|
+
* pool - so a caller must send `relayRequestHeaders(yourRelayApiKey)`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const relayRequestsUrl = "https://api.relay.link/requests/v3";
|
|
35
|
+
/**
|
|
36
|
+
* Builds the headers for a Relay request. `apiKey` is Relay's `x-api-key`
|
|
37
|
+
* value. This package ships no key: the caller supplies its own (the Gibs
|
|
38
|
+
* interface keeps its key in `packages/ui/src/lib/config.ts`).
|
|
39
|
+
* Relay raises the account's rate limit and attributes traffic to it when the
|
|
40
|
+
* header is present.
|
|
41
|
+
*
|
|
42
|
+
* When `apiKey` is absent or an empty string, the returned headers carry NO
|
|
43
|
+
* `x-api-key` entry at all — not an empty one.
|
|
44
|
+
*
|
|
45
|
+
* WHETHER THAT IS SURVIVABLE DEPENDS ENTIRELY ON WHICH ENDPOINT IS BEING CALLED,
|
|
46
|
+
* and this note used to say only the reassuring half. Measured against the live
|
|
47
|
+
* service:
|
|
48
|
+
*
|
|
49
|
+
* POST /quote no key -> 200 routing works anonymously
|
|
50
|
+
* GET /requests/v3 no key -> 400 "headers must have required
|
|
51
|
+
* property 'x-api-key'"
|
|
52
|
+
*
|
|
53
|
+
* So a missing key is a normal operating state for ROUTING — a reader on a
|
|
54
|
+
* local build or the anonymous InterPlanetary File System deployment still gets
|
|
55
|
+
* real quotes, and clearing the key disables attribution rather than the
|
|
56
|
+
* product. It is NOT survivable for STATUS. Every status poll from a keyless
|
|
57
|
+
* build fails, which means a consolidated record never learns its provider
|
|
58
|
+
* finished, never records the entry-chain transaction, and never releases from
|
|
59
|
+
* the pending list. That is not a degraded rate limit; it is the feature not
|
|
60
|
+
* working at all, silently.
|
|
61
|
+
*/
|
|
62
|
+
export declare const relayRequestHeaders: (apiKey?: string) => Record<string, string>;
|
|
63
|
+
/**
|
|
64
|
+
* Gibs Finance's own Relay `referrer`, for callers that want to attribute to
|
|
65
|
+
* Gibs Finance. The request builders do NOT default to it: pass it, or your
|
|
66
|
+
* own, as `relayReferrer` on the request. Relay reads any `referrer` as "a
|
|
67
|
+
* referrer was supplied" and then requires an API key, so a default would
|
|
68
|
+
* break every caller without one.
|
|
69
|
+
*/
|
|
70
|
+
export declare const relayReferrer = "gibs.finance";
|
|
71
|
+
/**
|
|
72
|
+
* Application fee in basis points charged on Relay routes. Ten basis points is
|
|
73
|
+
* one tenth of a percent. Sent as `appFees[0].fee` when a payout recipient is
|
|
74
|
+
* configured; absent entirely when the recipient is missing.
|
|
75
|
+
*/
|
|
76
|
+
export declare const relayReferralFeeBasisPoints = 10n;
|
|
77
|
+
export { relayReferralRecipient } from './referral.js';
|
|
78
|
+
/** Extra gas added to the destination budget to cover a prepended approval call. */
|
|
79
|
+
export declare const relayApprovalGasBuffer = 60000n;
|
|
80
|
+
/**
|
|
81
|
+
* Relay's chain identifiers and their display names live in `chain-names.ts`
|
|
82
|
+
* so the route-step normalizer can name a Relay chain without importing this
|
|
83
|
+
* module, which imports it. Re-exported here because callers reach for them
|
|
84
|
+
* alongside the rest of the Relay surface.
|
|
85
|
+
*/
|
|
86
|
+
export { relayChainIds, relayChainNames } from './chain-names.js';
|
|
87
|
+
/**
|
|
88
|
+
* Maps a chain identifier to its virtual-machine ecosystem. Relay's non-Ethereum
|
|
89
|
+
* pseudo chain identifiers map to their own ecosystem; every other identifier
|
|
90
|
+
* (every Ethereum Virtual Machine chain) maps to `evm`. Total — never throws.
|
|
91
|
+
*
|
|
92
|
+
* Lives here rather than in `ecosystems.ts` because it depends on
|
|
93
|
+
* `relayChainIds` (defined in this file); the `Ecosystem` import is type-only,
|
|
94
|
+
* so `ecosystems.ts` stays a dependency-free leaf and no import cycle is formed.
|
|
95
|
+
*
|
|
96
|
+
* @param chainId - a chain identifier (an Ethereum chain id, or a Relay pseudo id)
|
|
97
|
+
* @returns the ecosystem that chain belongs to
|
|
98
|
+
*/
|
|
99
|
+
export declare const ecosystemByChainId: (chainId: number) => Ecosystem;
|
|
100
|
+
/**
|
|
101
|
+
* Relay's native-currency address strings, used verbatim as `originCurrency`
|
|
102
|
+
* when the origin pays in the chain's native asset.
|
|
103
|
+
*
|
|
104
|
+
* Source: https://api.relay.link/chains.
|
|
105
|
+
*/
|
|
106
|
+
export declare const relayNativeCurrencyAddresses: {
|
|
107
|
+
/**
|
|
108
|
+
* Ethereum Virtual Machine native currency (Ether, native gas tokens). The
|
|
109
|
+
* all-zero address Relay uses across every Ethereum Virtual Machine chain.
|
|
110
|
+
*/
|
|
111
|
+
readonly ethereumVirtualMachine: "0x0000000000000000000000000000000000000000";
|
|
112
|
+
/**
|
|
113
|
+
* Solana native currency (SOL), addressed by the System Program. Nine
|
|
114
|
+
* decimals.
|
|
115
|
+
*/
|
|
116
|
+
readonly solana: "11111111111111111111111111111111";
|
|
117
|
+
/** Bitcoin native currency (BTC). Eight decimals. */
|
|
118
|
+
readonly bitcoin: "bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8";
|
|
119
|
+
/** Tron native currency (TRX). Six decimals. */
|
|
120
|
+
readonly tron: "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb";
|
|
121
|
+
/**
|
|
122
|
+
* The Open Network's native currency as Relay reports it: Gram, NOT the
|
|
123
|
+
* Toncoin gas asset. Nine decimals.
|
|
124
|
+
*/
|
|
125
|
+
readonly ton: "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
|
|
126
|
+
/**
|
|
127
|
+
* Hyperliquid's native currency as Relay reports it: USD Coin, NOT the Hype
|
|
128
|
+
* gas asset, addressed by a sixteen-byte HyperCore token identifier. Eight
|
|
129
|
+
* decimals. Deliberately NOT the twenty-byte all-zero Ethereum address.
|
|
130
|
+
*/
|
|
131
|
+
readonly hyperliquid: "0x00000000000000000000000000000000";
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Relay's solving direction for a quote.
|
|
135
|
+
*
|
|
136
|
+
* - `EXACT_OUTPUT` — solve BACKWARD to a fixed delivered amount; this is what
|
|
137
|
+
* the consolidated route uses, because the omnibridge entry call encodes a
|
|
138
|
+
* fixed anchor amount that must arrive exactly.
|
|
139
|
+
* - `EXACT_INPUT` — solve FORWARD from a fixed input amount; this is what the
|
|
140
|
+
* two-phase pre-quote uses to LEARN the delivered anchor amount for a fixed
|
|
141
|
+
* user input before building the EXACT_OUTPUT execution quote.
|
|
142
|
+
*/
|
|
143
|
+
export type RelayTradeType = 'EXACT_OUTPUT' | 'EXACT_INPUT';
|
|
144
|
+
/** One destination transaction in a Relay quote request. */
|
|
145
|
+
export type RelayTransaction = {
|
|
146
|
+
to: Hex;
|
|
147
|
+
value: string;
|
|
148
|
+
data: Hex;
|
|
149
|
+
};
|
|
150
|
+
/** The JSON body for `POST /quote/v2` with attached destination calls. */
|
|
151
|
+
export type RelayQuoteRequestBody = {
|
|
152
|
+
/**
|
|
153
|
+
* The user's origin-chain address. Typed as `string` because a non-Ethereum
|
|
154
|
+
* origin (Solana base58, Bitcoin bech32) supplies a non-`Hex` address here.
|
|
155
|
+
*/
|
|
156
|
+
user: string;
|
|
157
|
+
originChainId: number;
|
|
158
|
+
/**
|
|
159
|
+
* The origin currency address. Typed as `string` because a non-Ethereum
|
|
160
|
+
* origin's native currency address (Solana System Program, Bitcoin native) is
|
|
161
|
+
* not `Hex`.
|
|
162
|
+
*/
|
|
163
|
+
originCurrency: string;
|
|
164
|
+
destinationChainId: number;
|
|
165
|
+
/** The Ethereum-side entry-chain token; always an Ethereum Virtual Machine address. */
|
|
166
|
+
destinationCurrency: Hex;
|
|
167
|
+
amount: string;
|
|
168
|
+
tradeType: RelayTradeType;
|
|
169
|
+
/**
|
|
170
|
+
* Origin-chain refund address; without it Relay disables automatic refunds.
|
|
171
|
+
* Typed as `string` because for a non-Ethereum origin the refund lands on the
|
|
172
|
+
* origin chain and so carries that chain's (non-`Hex`) address.
|
|
173
|
+
*/
|
|
174
|
+
refundTo: string;
|
|
175
|
+
/** Omitted unless the request names a `relayReferrer`. */
|
|
176
|
+
referrer?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Where the funds land, for a route that names no transaction to run.
|
|
179
|
+
*
|
|
180
|
+
* A route into the omnibridge carries its recipient INSIDE the entry call's
|
|
181
|
+
* calldata, so this is absent there and Relay delivers to the executor that
|
|
182
|
+
* performs the call. A direct route has no call, so the recipient has to be
|
|
183
|
+
* said out loud.
|
|
184
|
+
*/
|
|
185
|
+
recipient?: Hex;
|
|
186
|
+
/**
|
|
187
|
+
* The calls the executor performs on arrival, in order.
|
|
188
|
+
*
|
|
189
|
+
* Absent on a direct route. Its presence is what tells Relay this is a
|
|
190
|
+
* deliver-and-call rather than a plain transfer, so an empty array would be a
|
|
191
|
+
* different request from an omitted field and must not be sent instead.
|
|
192
|
+
*/
|
|
193
|
+
txs?: RelayTransaction[];
|
|
194
|
+
/** Aggregate gas budget across every entry in `txs`. Absent when `txs` is. */
|
|
195
|
+
txsGasLimit?: number;
|
|
196
|
+
/** Maximum slippage in basis points (50 means half a percent). */
|
|
197
|
+
slippageTolerance?: string;
|
|
198
|
+
/**
|
|
199
|
+
* Solana fee-payer address that sponsors the deposit transaction's fee. Only
|
|
200
|
+
* present for a Solana origin; omitted entirely for every other origin.
|
|
201
|
+
*/
|
|
202
|
+
depositFeePayer?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Extra data Relay needs for non-Ethereum deposits. Only the Bitcoin
|
|
205
|
+
* pay-to-script-hash public key is carried today, and only for a Bitcoin
|
|
206
|
+
* origin; omitted entirely otherwise.
|
|
207
|
+
*/
|
|
208
|
+
additionalData?: {
|
|
209
|
+
/** The Bitcoin pay-to-script-hash public key. */
|
|
210
|
+
userPublicKey?: string;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Application fees collected by the integrator. Each entry names a payout
|
|
214
|
+
* recipient and a rate in basis points (as a string). Omitted entirely when
|
|
215
|
+
* no recipient is configured — Relay rejects a recipient-less fee entry.
|
|
216
|
+
*/
|
|
217
|
+
appFees?: Array<{
|
|
218
|
+
recipient: string;
|
|
219
|
+
fee: string;
|
|
220
|
+
}>;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Converts a slippage fraction into the basis-point string Relay expects.
|
|
224
|
+
*
|
|
225
|
+
* @param slippage - tolerance as a fraction (0.005 means half a percent)
|
|
226
|
+
* @returns basis points as a string (0.005 becomes "50")
|
|
227
|
+
*/
|
|
228
|
+
export declare const slippageToBasisPoints: (slippage: number) => string;
|
|
229
|
+
/**
|
|
230
|
+
* The `referrer` field of a Relay request body, present only when the caller
|
|
231
|
+
* named one. Relay reads any `referrer`, an empty one included, as "a referrer
|
|
232
|
+
* was supplied" and then requires an API key, so absence is the safe default.
|
|
233
|
+
*
|
|
234
|
+
* @param request - carries the caller's `relayReferrer`, if any
|
|
235
|
+
* @returns `{ referrer }`, or an empty object
|
|
236
|
+
*/
|
|
237
|
+
export declare const relayReferrerField: (request: {
|
|
238
|
+
relayReferrer?: string | null;
|
|
239
|
+
}) => {
|
|
240
|
+
referrer?: string;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Builds the Relay contract-call quote request from a provider-agnostic
|
|
244
|
+
* consolidated request. The omnibridge entry call becomes the final `txs`
|
|
245
|
+
* entry; when it needs an ERC20 allowance (the relayTokens shape, where
|
|
246
|
+
* `approvalTarget` is set) an `approve` call is prepended so Relay's executor
|
|
247
|
+
* grants it before relaying.
|
|
248
|
+
*
|
|
249
|
+
* @returns the request body, or null when the inputs cannot form a valid call
|
|
250
|
+
*/
|
|
251
|
+
export declare const buildRelayQuoteRequest: (request: ConsolidatedQuoteRequest) => RelayQuoteRequestBody | null;
|
|
252
|
+
/**
|
|
253
|
+
* Normalizes a Relay `/quote/v2` response into the shared consolidated quote
|
|
254
|
+
* shape. The origin approval Relay returns as its own step is folded back into
|
|
255
|
+
* `approvalAddress` so the executor raises it through the same path as LI.FI;
|
|
256
|
+
* the deposit step becomes the single `originDeposit`.
|
|
257
|
+
*
|
|
258
|
+
* @returns the normalized quote, or null when the payload shape is unexpected
|
|
259
|
+
*/
|
|
260
|
+
export declare const parseRelayQuote: (payload: unknown) => ConsolidatedQuote | null;
|
|
261
|
+
/**
|
|
262
|
+
* Builds the requests-lookup address for a Relay route BY ITS QUOTE
|
|
263
|
+
* IDENTIFIER.
|
|
264
|
+
*
|
|
265
|
+
* IT USED TO ASK BY ORIGIN TRANSACTION HASH, AND THAT RETURNED OTHER PEOPLE'S
|
|
266
|
+
* TRANSFERS. `/requests/v3` does not accept a `hash` filter: it ignores the
|
|
267
|
+
* parameter entirely and answers with the twenty most recent requests ACROSS
|
|
268
|
+
* ALL USERS. Measured, with two different origin hashes a minute apart:
|
|
269
|
+
*
|
|
270
|
+
* ?hash=0x447149ed… -> 20 requests, first is 8453:0x7d7c3de2… -> 4663:…
|
|
271
|
+
* ?hash=0xa650d2d7… -> the SAME 20 requests, same first entry
|
|
272
|
+
*
|
|
273
|
+
* `parseRelayStatus` reads `requests[0]`, so both of this account's transfers
|
|
274
|
+
* were updated from a stranger's — they took the same entry-chain transaction
|
|
275
|
+
* hash, and neither was their own. A transfer was reported finished because
|
|
276
|
+
* somebody else's had finished.
|
|
277
|
+
*
|
|
278
|
+
* `id` is the filter v3 actually honours. The same lookup by quote identifier
|
|
279
|
+
* returns exactly ONE request, and its `inTxs` name the origin transaction the
|
|
280
|
+
* reader really signed. The caller should assert that correspondence rather
|
|
281
|
+
* than trust it — see `checkConsolidatedRecord`.
|
|
282
|
+
*/
|
|
283
|
+
export declare const relayStatusUrl: ({ quoteId }: {
|
|
284
|
+
quoteId: string;
|
|
285
|
+
}) => string;
|
|
286
|
+
/**
|
|
287
|
+
* Maps a Relay request status onto the provider-agnostic consolidated status.
|
|
288
|
+
* `success` reports `DONE`/`COMPLETED` because for this route the destination
|
|
289
|
+
* fill IS our omnibridge entry call; `refund` reports `DONE`/`REFUNDED` because
|
|
290
|
+
* the user was made whole on the origin chain. Relay never strands funds on
|
|
291
|
+
* Ethereum, so the partial/stranded status LI.FI can return has no analogue.
|
|
292
|
+
*
|
|
293
|
+
* @param payload - a `/requests/v2?hash=` response body
|
|
294
|
+
* @param options.destinationChainId - the omnibridge entry chain the route
|
|
295
|
+
* targeted (Ethereum or Binance Smart Chain); defaults to Ethereum,
|
|
296
|
+
* preserving the original single-entry behavior
|
|
297
|
+
* @returns the normalized status, or null when no matching request is present
|
|
298
|
+
*/
|
|
299
|
+
export declare const parseRelayStatus: (payload: unknown, { destinationChainId }?: {
|
|
300
|
+
destinationChainId?: number;
|
|
301
|
+
}) => ConsolidatedStatus | null;
|