@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,326 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* An Ethereum-Virtual-Machine origin deposit: the transaction the user signs on
|
|
4
|
+
* the source chain.
|
|
5
|
+
*
|
|
6
|
+
* Every variant in {@link OriginDeposit} is produced by the Relay parser, but
|
|
7
|
+
* being produced is not the same as being signable: a variant can only be
|
|
8
|
+
* executed where the interface has a wallet adapter for its ecosystem. This
|
|
9
|
+
* repository's interface now has one for every variant below, including Tron and
|
|
10
|
+
* The Open Network. An interface that does not must reject the variant
|
|
11
|
+
* explicitly rather than let it reach a signer meant for another ecosystem.
|
|
12
|
+
*/
|
|
13
|
+
export type EvmDeposit = {
|
|
14
|
+
ecosystem: 'evm';
|
|
15
|
+
to: Hex;
|
|
16
|
+
data: Hex;
|
|
17
|
+
value: bigint;
|
|
18
|
+
chainId: number;
|
|
19
|
+
gasLimit: bigint | null;
|
|
20
|
+
};
|
|
21
|
+
/** One Solana instruction: the account metas, the program, and hex-encoded instruction data. */
|
|
22
|
+
export type SolanaInstruction = {
|
|
23
|
+
keys: Array<{
|
|
24
|
+
pubkey: string;
|
|
25
|
+
isSigner: boolean;
|
|
26
|
+
isWritable: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
programId: string;
|
|
29
|
+
data: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A Solana origin deposit expressed as the raw instruction set plus the
|
|
33
|
+
* address-lookup-table addresses, which the execution layer compiles into a
|
|
34
|
+
* versioned transaction with the Solana web3 library. There is no separate
|
|
35
|
+
* fee-payer field — the fee payer is the signer account inside an
|
|
36
|
+
* instruction's keys. This is the shape Relay returns.
|
|
37
|
+
*
|
|
38
|
+
* Because the transaction is compiled at signing time, its recent blockhash is
|
|
39
|
+
* stamped then too, so this form does not go stale while the user deliberates.
|
|
40
|
+
*/
|
|
41
|
+
export type SolanaInstructionsDeposit = {
|
|
42
|
+
ecosystem: 'svm';
|
|
43
|
+
form: 'instructions';
|
|
44
|
+
instructions: SolanaInstruction[];
|
|
45
|
+
addressLookupTableAddresses: string[];
|
|
46
|
+
chainId: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* A Solana origin deposit that arrives ALREADY COMPILED: a base64 versioned
|
|
50
|
+
* (v0) transaction the wallet deserializes, signs and sends unchanged. This is
|
|
51
|
+
* the shape LI.FI's plain `/v1/quote` returns for a Solana origin, where the
|
|
52
|
+
* whole payload is a single `transactionRequest.data` string with no `to`,
|
|
53
|
+
* `value` or `chainId` beside it.
|
|
54
|
+
*
|
|
55
|
+
* The two forms are kept as separate members of a discriminated union rather
|
|
56
|
+
* than one type with optional fields, because they are not interchangeable at
|
|
57
|
+
* the signer: this one must NOT be recompiled or re-stamped, and the
|
|
58
|
+
* instruction form cannot be signed without being compiled first.
|
|
59
|
+
*
|
|
60
|
+
* GOTCHA: the quote bakes a recent blockhash into the serialized bytes, so this
|
|
61
|
+
* form EXPIRES (Solana retains roughly 150 blocks, on the order of a minute).
|
|
62
|
+
* A quote the user sits on will be rejected as an expired blockhash rather than
|
|
63
|
+
* silently re-priced, so treat a stale-transaction failure as "re-quote", not
|
|
64
|
+
* as a wallet fault.
|
|
65
|
+
*/
|
|
66
|
+
export type SolanaSerializedDeposit = {
|
|
67
|
+
ecosystem: 'svm';
|
|
68
|
+
form: 'serialized';
|
|
69
|
+
/** The compiled v0 transaction, base64, exactly as the provider returned it. */
|
|
70
|
+
transaction: string;
|
|
71
|
+
chainId: number;
|
|
72
|
+
};
|
|
73
|
+
/** A Solana origin deposit in either of the two forms providers return. */
|
|
74
|
+
export type SolanaDeposit = SolanaInstructionsDeposit | SolanaSerializedDeposit;
|
|
75
|
+
/** A Bitcoin origin deposit: either a partially-signed transaction, or a deposit address plus an amount in satoshis. */
|
|
76
|
+
export type BitcoinDeposit = {
|
|
77
|
+
ecosystem: 'bvm';
|
|
78
|
+
psbt: string | null;
|
|
79
|
+
depositAddress: string;
|
|
80
|
+
amountSats: bigint;
|
|
81
|
+
chainId: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* A Tron origin deposit: one contract call for the user's wallet to sign and
|
|
85
|
+
* broadcast. Relay returns Tron's own wire shape, whose field names are
|
|
86
|
+
* snake_case and whose addresses are hex with Tron's `41` prefix byte rather
|
|
87
|
+
* than `0x`; the fields are renamed here to the codebase's conventions and the
|
|
88
|
+
* wire name of each is recorded so a signer can map back without guessing.
|
|
89
|
+
*/
|
|
90
|
+
export type TronDeposit = {
|
|
91
|
+
ecosystem: 'tvm';
|
|
92
|
+
/** Tron contract type; `TriggerSmartContract` is the only shape Relay returns. Wire name `type`. */
|
|
93
|
+
contractType: string;
|
|
94
|
+
/** The signer's account, hex with Tron's `41` prefix. Wire name `parameter.owner_address`. */
|
|
95
|
+
ownerAddress: string;
|
|
96
|
+
/** The contract being called, hex with Tron's `41` prefix. Wire name `parameter.contract_address`. */
|
|
97
|
+
contractAddress: string;
|
|
98
|
+
/** Native TRX sent with the call, in sun. Wire name `parameter.call_value`. */
|
|
99
|
+
callValue: bigint;
|
|
100
|
+
/** Call data as bare hex with NO `0x` prefix, unlike every Ethereum payload. Wire name `parameter.data`. */
|
|
101
|
+
data: string;
|
|
102
|
+
chainId: number;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* One message in a TON deposit. TON wallets send a list of messages rather than
|
|
106
|
+
* a single transaction, and the payload (`body`) is a base64 bag-of-cells, not
|
|
107
|
+
* hex.
|
|
108
|
+
*/
|
|
109
|
+
export type TonMessage = {
|
|
110
|
+
/** Destination account. */
|
|
111
|
+
to: string;
|
|
112
|
+
/** Amount attached to the message, in nanotons. */
|
|
113
|
+
value: bigint;
|
|
114
|
+
/** Base64 bag-of-cells payload. */
|
|
115
|
+
body: string;
|
|
116
|
+
/** TON send mode flags. */
|
|
117
|
+
mode: number;
|
|
118
|
+
/** Whether the message bounces back if the destination cannot accept it. */
|
|
119
|
+
bounce: boolean;
|
|
120
|
+
/** Sending account; absent when the wallet is left to fill it in. */
|
|
121
|
+
from: string | null;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* A TON origin deposit: the message list the user's wallet signs and sends.
|
|
125
|
+
*/
|
|
126
|
+
export type TonDeposit = {
|
|
127
|
+
ecosystem: 'tonvm';
|
|
128
|
+
messages: TonMessage[];
|
|
129
|
+
chainId: number;
|
|
130
|
+
};
|
|
131
|
+
/** One field of an typed-data structure: its name and its solidity-style type. */
|
|
132
|
+
export type TypedDataField = {
|
|
133
|
+
name: string;
|
|
134
|
+
type: string;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* The authorization a Hyperliquid deposit must complete BEFORE its action is
|
|
138
|
+
* submitted: the user signs `sign` as typed data, then the signature and `post`
|
|
139
|
+
* are sent to Relay. Skipping it makes the action unusable, which is why it
|
|
140
|
+
* travels with the deposit rather than being dropped as a separate step.
|
|
141
|
+
*/
|
|
142
|
+
export type HyperliquidAuthorization = {
|
|
143
|
+
/** The typed-data structure the user signs. */
|
|
144
|
+
sign: {
|
|
145
|
+
/** Signing scheme; `eip712` is the only value observed. */
|
|
146
|
+
signatureKind: string;
|
|
147
|
+
domain: Record<string, unknown>;
|
|
148
|
+
types: Record<string, TypedDataField[]>;
|
|
149
|
+
value: Record<string, unknown>;
|
|
150
|
+
primaryType: string;
|
|
151
|
+
};
|
|
152
|
+
/** Where the resulting signature is submitted. */
|
|
153
|
+
post: {
|
|
154
|
+
endpoint: string;
|
|
155
|
+
method: string;
|
|
156
|
+
body: Record<string, unknown>;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* A Hyperliquid origin deposit. Unlike every other ecosystem, nothing here is
|
|
161
|
+
* broadcast to a chain: the user signs a typed-data ACTION and it is posted to
|
|
162
|
+
* Hyperliquid's API. There is therefore no transaction, no gas, and no calldata
|
|
163
|
+
* — and two signatures are required, the {@link HyperliquidAuthorization} first
|
|
164
|
+
* and this action second.
|
|
165
|
+
*/
|
|
166
|
+
export type HyperliquidDeposit = {
|
|
167
|
+
ecosystem: 'hypevm';
|
|
168
|
+
/** The action to sign, e.g. `sendAsset`, with its parameters. */
|
|
169
|
+
action: {
|
|
170
|
+
type: string;
|
|
171
|
+
parameters: Record<string, unknown>;
|
|
172
|
+
};
|
|
173
|
+
/** Typed-data structures for the action. */
|
|
174
|
+
eip712Types: Record<string, TypedDataField[]>;
|
|
175
|
+
/** Which structure in `eip712Types` the action signs. */
|
|
176
|
+
eip712PrimaryType: string;
|
|
177
|
+
/** Replay-protection nonce, shared with the authorization. */
|
|
178
|
+
nonce: bigint;
|
|
179
|
+
/** The authorization to complete first; null when Relay omits that step. */
|
|
180
|
+
authorization: HyperliquidAuthorization | null;
|
|
181
|
+
chainId: number;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* An origin deposit that is an ADDRESS AND AN AMOUNT, with no transaction of
|
|
185
|
+
* any kind — not a signed one, not an unsigned one, not a partially-signed one.
|
|
186
|
+
* The reader pays it by hand, from any wallet or any exchange, on a chain this
|
|
187
|
+
* interface has no wallet connector for.
|
|
188
|
+
*
|
|
189
|
+
* DISCRIMINATED BY `kind`, NOT BY `ecosystem`, AND THAT IS DELIBERATE. Every
|
|
190
|
+
* other variant here is tagged with the ecosystem whose signer it needs. This
|
|
191
|
+
* one needs no signer, and the SAME shape serves Zcash, Dogecoin, Litecoin and the
|
|
192
|
+
* XRP Ledger alike — the chain is `chainId`, not the type. Tagging it with an
|
|
193
|
+
* ecosystem would force one variant per chain for no difference in handling,
|
|
194
|
+
* and would let an ecosystem guard such as {@link isBitcoinDeposit} claim a
|
|
195
|
+
* deposit that has nothing to sign.
|
|
196
|
+
*
|
|
197
|
+
* NOT A VARIANT OF {@link BitcoinDeposit}, AND THE DIFFERENCE IS THE POINT.
|
|
198
|
+
* `BitcoinDeposit.psbt` is nullable, so it can already carry an address and no
|
|
199
|
+
* partially-signed transaction. But a name is a claim: `psbt` says a
|
|
200
|
+
* partially-signed Bitcoin transaction is the thing that might be missing, and
|
|
201
|
+
* here there is no such thing even in principle. A reader who found
|
|
202
|
+
* `psbt: null` on a Zcash deposit would reach for the signer that fills it in.
|
|
203
|
+
* There is no signer.
|
|
204
|
+
*
|
|
205
|
+
* WHERE EVERY FIELD COMES FROM, because this is the whole safety argument: the
|
|
206
|
+
* address is read off the provider's LIVE answer and nowhere else. It is never
|
|
207
|
+
* typed, never seeded from a link, never derived on this side. A provider
|
|
208
|
+
* answer with no address produces no deposit, and therefore no screen.
|
|
209
|
+
*
|
|
210
|
+
* HOW IT MOVES FORWARD. Nothing here is signed or broadcast. The reader sends
|
|
211
|
+
* an ordinary transfer, the provider's own watcher sees it arrive at the
|
|
212
|
+
* address it issued, and the existing status poll — keyed by this same
|
|
213
|
+
* address — reports the fill.
|
|
214
|
+
*/
|
|
215
|
+
export type DepositAddressDeposit = {
|
|
216
|
+
kind: 'deposit-address';
|
|
217
|
+
/** The origin chain. */
|
|
218
|
+
chainId: number;
|
|
219
|
+
/**
|
|
220
|
+
* The address the provider reserved for this one quote, exactly as it
|
|
221
|
+
* answered. Single-use: a second quote for the same route gets a different
|
|
222
|
+
* address.
|
|
223
|
+
*/
|
|
224
|
+
depositAddress: string;
|
|
225
|
+
/**
|
|
226
|
+
* What the reader is asked to send, in base units of the origin asset. The
|
|
227
|
+
* amount the quote was priced at.
|
|
228
|
+
*/
|
|
229
|
+
amount: bigint;
|
|
230
|
+
/**
|
|
231
|
+
* The smallest payment the provider will still fill, in the same base units.
|
|
232
|
+
*
|
|
233
|
+
* NOT A RESTATEMENT OF `amount`. The request asks for a flexible input, so
|
|
234
|
+
* the provider names a floor about one percent under the quote and fills
|
|
235
|
+
* anything at or above it. A reader typing a figure into an exchange
|
|
236
|
+
* withdrawal form misses the exact amount routinely, and this tolerance is
|
|
237
|
+
* what turns those payments into fills rather than refunds.
|
|
238
|
+
*/
|
|
239
|
+
minimumAmount: bigint;
|
|
240
|
+
/** Decimal places of the origin asset, so a screen can print the amounts without a second lookup. */
|
|
241
|
+
decimals: number;
|
|
242
|
+
/**
|
|
243
|
+
* When the address goes cold, in milliseconds since the epoch.
|
|
244
|
+
*
|
|
245
|
+
* READ OFF THE ANSWER, NEVER OFF THE ECHOED REQUEST. The provider discards
|
|
246
|
+
* the deadline a caller asks for and substitutes one three days out. A screen
|
|
247
|
+
* built on the echoed request would run a thirty-minute countdown against an
|
|
248
|
+
* address that is live for three days.
|
|
249
|
+
*/
|
|
250
|
+
expiresAtMs: number;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* A route that has been PRICED BUT NOT RESERVED: there is nothing to pay yet.
|
|
254
|
+
*
|
|
255
|
+
* WHY IT EXISTS. NEAR Intents reserves a real deposit address, with a
|
|
256
|
+
* three-day clock, for every live quote it answers. Asking live merely to draw
|
|
257
|
+
* a route on screen reserved one per keystroke, per route, for readers who
|
|
258
|
+
* mostly never paid, and registered their recipient and refund accounts with
|
|
259
|
+
* the provider on every glance. So a route on display is priced with a dry
|
|
260
|
+
* quote, which carries figures and no address, and its deposit says so here.
|
|
261
|
+
*
|
|
262
|
+
* WHAT A SURFACE MUST DO WITH ONE. Nothing that pays: it has no address, no
|
|
263
|
+
* calldata and no amount to send. The moment the reader commits — the press
|
|
264
|
+
* before a signature, or "Show payment address" on a route paid by hand — the
|
|
265
|
+
* surface asks for a live quote and pays that one instead, having checked its
|
|
266
|
+
* terms against what the reader was shown.
|
|
267
|
+
*/
|
|
268
|
+
export type UnreservedDeposit = {
|
|
269
|
+
kind: 'unreserved';
|
|
270
|
+
/** The origin chain the route was priced from. */
|
|
271
|
+
chainId: number;
|
|
272
|
+
};
|
|
273
|
+
/** The origin deposit for any supported source ecosystem. */
|
|
274
|
+
export type OriginDeposit = EvmDeposit | SolanaDeposit | BitcoinDeposit | TronDeposit | TonDeposit | HyperliquidDeposit | DepositAddressDeposit | UnreservedDeposit;
|
|
275
|
+
export declare const isEvmDeposit: (deposit: OriginDeposit) => deposit is EvmDeposit;
|
|
276
|
+
export declare const isSolanaDeposit: (deposit: OriginDeposit) => deposit is SolanaDeposit;
|
|
277
|
+
/**
|
|
278
|
+
* Narrows a Solana deposit to the instruction form, which must be compiled
|
|
279
|
+
* before it can be signed.
|
|
280
|
+
*/
|
|
281
|
+
export declare const isSolanaInstructionsDeposit: (deposit: SolanaDeposit) => deposit is SolanaInstructionsDeposit;
|
|
282
|
+
/**
|
|
283
|
+
* Narrows a Solana deposit to the pre-compiled form, which must be signed
|
|
284
|
+
* as-is.
|
|
285
|
+
*/
|
|
286
|
+
export declare const isSolanaSerializedDeposit: (deposit: SolanaDeposit) => deposit is SolanaSerializedDeposit;
|
|
287
|
+
export declare const isBitcoinDeposit: (deposit: OriginDeposit) => deposit is BitcoinDeposit;
|
|
288
|
+
export declare const isTronDeposit: (deposit: OriginDeposit) => deposit is TronDeposit;
|
|
289
|
+
export declare const isTonDeposit: (deposit: OriginDeposit) => deposit is TonDeposit;
|
|
290
|
+
export declare const isHyperliquidDeposit: (deposit: OriginDeposit) => deposit is HyperliquidDeposit;
|
|
291
|
+
/**
|
|
292
|
+
* Narrows a deposit to the pay-by-hand shape: an address, an amount, and
|
|
293
|
+
* nothing to sign.
|
|
294
|
+
*
|
|
295
|
+
* THE GUARD EVERY EXECUTION PATH MUST ASK FIRST. A surface that falls through
|
|
296
|
+
* to a signer with one of these has no transaction to give it, and a surface
|
|
297
|
+
* that asks the reader to connect a wallet is asking for one that does not
|
|
298
|
+
* exist for this chain.
|
|
299
|
+
*
|
|
300
|
+
* @param deposit - any origin deposit
|
|
301
|
+
* @returns whether the reader pays this one by hand
|
|
302
|
+
*/
|
|
303
|
+
export declare const isDepositAddressDeposit: (deposit: OriginDeposit) => deposit is DepositAddressDeposit;
|
|
304
|
+
/**
|
|
305
|
+
* Narrows a deposit to the priced-but-not-reserved shape: a route on display,
|
|
306
|
+
* with nothing to pay until a live quote replaces it.
|
|
307
|
+
*
|
|
308
|
+
* @param deposit - any origin deposit
|
|
309
|
+
* @returns whether the route must be quoted live before anything is paid
|
|
310
|
+
*/
|
|
311
|
+
export declare const isUnreservedDeposit: (deposit: OriginDeposit) => deposit is UnreservedDeposit;
|
|
312
|
+
/**
|
|
313
|
+
* Names a deposit's family for a message shown to someone: its ecosystem, or
|
|
314
|
+
* its `kind` for a deposit that has none — a {@link DepositAddressDeposit}
|
|
315
|
+
* reads as `"deposit-address"`, an {@link UnreservedDeposit} as `"unreserved"`.
|
|
316
|
+
*
|
|
317
|
+
* THE ONE COPY. The same `'ecosystem' in deposit ? deposit.ecosystem :
|
|
318
|
+
* deposit.kind` expression used to be written out separately in
|
|
319
|
+
* `consolidated-quote.ts` and in the interface's `consolidated-execute.ts`;
|
|
320
|
+
* each copy was a chance for the two to describe the same deposit
|
|
321
|
+
* differently. Import this instead of restating the expression.
|
|
322
|
+
*
|
|
323
|
+
* @param deposit - any origin deposit
|
|
324
|
+
* @returns the ecosystem name, or the deposit's `kind` when it has none
|
|
325
|
+
*/
|
|
326
|
+
export declare const depositFamilyOf: (deposit: OriginDeposit) => string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.depositFamilyOf = exports.isUnreservedDeposit = exports.isDepositAddressDeposit = exports.isHyperliquidDeposit = exports.isTonDeposit = exports.isTronDeposit = exports.isBitcoinDeposit = exports.isSolanaSerializedDeposit = exports.isSolanaInstructionsDeposit = exports.isSolanaDeposit = exports.isEvmDeposit = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The ecosystem whose signer a deposit needs, or null for a deposit that needs
|
|
6
|
+
* no signer at all.
|
|
7
|
+
*
|
|
8
|
+
* THE ONE PLACE THE ECOSYSTEM TAG IS READ. A {@link DepositAddressDeposit} has
|
|
9
|
+
* no `ecosystem`, so every guard below asks through this instead of reading the
|
|
10
|
+
* field directly — which also means no ecosystem guard can ever answer true for
|
|
11
|
+
* a deposit the reader pays by hand.
|
|
12
|
+
*
|
|
13
|
+
* TYPED `Ecosystem | null`, NOT `string | null`. A `string` return let a typo
|
|
14
|
+
* such as `signerEcosystemOf(deposit) === 'hypvm'` compile silently — the
|
|
15
|
+
* comparison is just false forever, so `isHyperliquidDeposit` would always
|
|
16
|
+
* answer false and every Hyperliquid deposit would fall through to the
|
|
17
|
+
* Ethereum branch. Typed on the union, the same typo fails to compile instead.
|
|
18
|
+
*/
|
|
19
|
+
const signerEcosystemOf = (deposit) => 'ecosystem' in deposit ? deposit.ecosystem : null;
|
|
20
|
+
const isEvmDeposit = (deposit) => signerEcosystemOf(deposit) === 'evm';
|
|
21
|
+
exports.isEvmDeposit = isEvmDeposit;
|
|
22
|
+
const isSolanaDeposit = (deposit) => signerEcosystemOf(deposit) === 'svm';
|
|
23
|
+
exports.isSolanaDeposit = isSolanaDeposit;
|
|
24
|
+
/**
|
|
25
|
+
* Narrows a Solana deposit to the instruction form, which must be compiled
|
|
26
|
+
* before it can be signed.
|
|
27
|
+
*/
|
|
28
|
+
const isSolanaInstructionsDeposit = (deposit) => deposit.form === 'instructions';
|
|
29
|
+
exports.isSolanaInstructionsDeposit = isSolanaInstructionsDeposit;
|
|
30
|
+
/**
|
|
31
|
+
* Narrows a Solana deposit to the pre-compiled form, which must be signed
|
|
32
|
+
* as-is.
|
|
33
|
+
*/
|
|
34
|
+
const isSolanaSerializedDeposit = (deposit) => deposit.form === 'serialized';
|
|
35
|
+
exports.isSolanaSerializedDeposit = isSolanaSerializedDeposit;
|
|
36
|
+
const isBitcoinDeposit = (deposit) => signerEcosystemOf(deposit) === 'bvm';
|
|
37
|
+
exports.isBitcoinDeposit = isBitcoinDeposit;
|
|
38
|
+
const isTronDeposit = (deposit) => signerEcosystemOf(deposit) === 'tvm';
|
|
39
|
+
exports.isTronDeposit = isTronDeposit;
|
|
40
|
+
const isTonDeposit = (deposit) => signerEcosystemOf(deposit) === 'tonvm';
|
|
41
|
+
exports.isTonDeposit = isTonDeposit;
|
|
42
|
+
const isHyperliquidDeposit = (deposit) => signerEcosystemOf(deposit) === 'hypevm';
|
|
43
|
+
exports.isHyperliquidDeposit = isHyperliquidDeposit;
|
|
44
|
+
/**
|
|
45
|
+
* Narrows a deposit to the pay-by-hand shape: an address, an amount, and
|
|
46
|
+
* nothing to sign.
|
|
47
|
+
*
|
|
48
|
+
* THE GUARD EVERY EXECUTION PATH MUST ASK FIRST. A surface that falls through
|
|
49
|
+
* to a signer with one of these has no transaction to give it, and a surface
|
|
50
|
+
* that asks the reader to connect a wallet is asking for one that does not
|
|
51
|
+
* exist for this chain.
|
|
52
|
+
*
|
|
53
|
+
* @param deposit - any origin deposit
|
|
54
|
+
* @returns whether the reader pays this one by hand
|
|
55
|
+
*/
|
|
56
|
+
const isDepositAddressDeposit = (deposit) => 'kind' in deposit && deposit.kind === 'deposit-address';
|
|
57
|
+
exports.isDepositAddressDeposit = isDepositAddressDeposit;
|
|
58
|
+
/**
|
|
59
|
+
* Narrows a deposit to the priced-but-not-reserved shape: a route on display,
|
|
60
|
+
* with nothing to pay until a live quote replaces it.
|
|
61
|
+
*
|
|
62
|
+
* @param deposit - any origin deposit
|
|
63
|
+
* @returns whether the route must be quoted live before anything is paid
|
|
64
|
+
*/
|
|
65
|
+
const isUnreservedDeposit = (deposit) => 'kind' in deposit && deposit.kind === 'unreserved';
|
|
66
|
+
exports.isUnreservedDeposit = isUnreservedDeposit;
|
|
67
|
+
/**
|
|
68
|
+
* Names a deposit's family for a message shown to someone: its ecosystem, or
|
|
69
|
+
* its `kind` for a deposit that has none — a {@link DepositAddressDeposit}
|
|
70
|
+
* reads as `"deposit-address"`, an {@link UnreservedDeposit} as `"unreserved"`.
|
|
71
|
+
*
|
|
72
|
+
* THE ONE COPY. The same `'ecosystem' in deposit ? deposit.ecosystem :
|
|
73
|
+
* deposit.kind` expression used to be written out separately in
|
|
74
|
+
* `consolidated-quote.ts` and in the interface's `consolidated-execute.ts`;
|
|
75
|
+
* each copy was a chance for the two to describe the same deposit
|
|
76
|
+
* differently. Import this instead of restating the expression.
|
|
77
|
+
*
|
|
78
|
+
* @param deposit - any origin deposit
|
|
79
|
+
* @returns the ecosystem name, or the deposit's `kind` when it has none
|
|
80
|
+
*/
|
|
81
|
+
const depositFamilyOf = (deposit) => 'ecosystem' in deposit ? deposit.ecosystem : deposit.kind;
|
|
82
|
+
exports.depositFamilyOf = depositFamilyOf;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
import { type OriginVmType } from './consolidated-quote.js';
|
|
3
|
+
import { type RelayTradeType } from './relay-quote.js';
|
|
4
|
+
/**
|
|
5
|
+
* Phase one of the two-phase consolidated-route quoting model ("option 2").
|
|
6
|
+
*
|
|
7
|
+
* The consolidated route swaps the user's origin token into an ANCHOR token on
|
|
8
|
+
* an omnibridge entry chain (Ethereum or Binance Smart Chain), then the
|
|
9
|
+
* omnibridge crosses that anchor onto PulseChain. The execution quote
|
|
10
|
+
* (consolidated-quote / relay-quote) is EXACT_OUTPUT: it solves BACKWARD to a
|
|
11
|
+
* FIXED anchor amount, because the omnibridge entry call encodes that exact
|
|
12
|
+
* amount and it must arrive exactly.
|
|
13
|
+
*
|
|
14
|
+
* The problem the EXACT_OUTPUT path cannot answer on its own is "for the user's
|
|
15
|
+
* fixed input, how much anchor does this entry actually deliver?". Previously
|
|
16
|
+
* that target was estimated from PRICES, which is fragile (garbage when a price
|
|
17
|
+
* is missing) and makes every entry target the same value-equivalent amount, so
|
|
18
|
+
* the routes deliver alike and cannot be ranked by who delivers most.
|
|
19
|
+
*
|
|
20
|
+
* The PRE-QUOTE solves that: a plain EXACT_INPUT swap of origin token -> anchor
|
|
21
|
+
* for the FIXED input, with NO destination transactions. Its delivered amount
|
|
22
|
+
* is provider-accurate and decimals-correct, with no price dependency. The
|
|
23
|
+
* caller feeds that delivered amount as the EXACT_OUTPUT `toAmount`, so each
|
|
24
|
+
* entry now targets its OWN real delivered amount and ranking-by-delivered
|
|
25
|
+
* becomes meaningful.
|
|
26
|
+
*
|
|
27
|
+
* These builders/parsers are deliberately SEPARATE from the EXACT_OUTPUT
|
|
28
|
+
* consolidated builders so the execution path is never disturbed.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Provider-agnostic input for an EXACT_INPUT origin -> anchor pre-quote. A plain
|
|
32
|
+
* swap: no destination calls, no recipient on PulseChain, no omnibridge entry
|
|
33
|
+
* call. Carries only what a forward-solving swap needs.
|
|
34
|
+
*/
|
|
35
|
+
export type PreQuoteRequest = {
|
|
36
|
+
/** Chain the user's funds start on. */
|
|
37
|
+
fromChainId: number;
|
|
38
|
+
/**
|
|
39
|
+
* Origin token address. Typed `string` (not `Hex`) so a non-Ethereum native
|
|
40
|
+
* currency address (Solana base58 mint, Bitcoin native string) flows through
|
|
41
|
+
* unchanged; an Ethereum Virtual Machine address is a subset of `string`.
|
|
42
|
+
*/
|
|
43
|
+
fromTokenAddress: string;
|
|
44
|
+
/**
|
|
45
|
+
* The user's origin-chain address. Typed `string` for the same reason as
|
|
46
|
+
* `fromTokenAddress`: a non-Ethereum origin carries a base58/bech32 address.
|
|
47
|
+
*/
|
|
48
|
+
fromAddress: string;
|
|
49
|
+
/** The omnibridge entry chain whose anchor token is the swap target. */
|
|
50
|
+
toChainId: number;
|
|
51
|
+
/** The anchor token on the entry chain; always an Ethereum Virtual Machine address. */
|
|
52
|
+
toTokenAddress: Hex;
|
|
53
|
+
/** The user's FIXED input amount, in origin-token base units. */
|
|
54
|
+
amount: bigint;
|
|
55
|
+
/** Maximum slippage as a fraction (e.g. 0.005); provider default when omitted. */
|
|
56
|
+
slippage?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Virtual-machine family of the ORIGIN chain. Defaults to Ethereum Virtual
|
|
59
|
+
* Machine when absent. A non-Ethereum origin (`svm`/`bvm`) excludes LI.FI (it
|
|
60
|
+
* cannot cross ecosystems) and routes the Relay refund to the user's own
|
|
61
|
+
* origin address.
|
|
62
|
+
*/
|
|
63
|
+
originVmType?: OriginVmType;
|
|
64
|
+
/**
|
|
65
|
+
* Where the swapped anchor conceptually lands on the entry chain (an
|
|
66
|
+
* Ethereum Virtual Machine address). REQUIRED for a non-Ethereum origin:
|
|
67
|
+
* Relay validates this address's FORMAT against `toChainId` even though the
|
|
68
|
+
* pre-quote never executes (no `txs` are attached), so a non-Ethereum
|
|
69
|
+
* origin's own base58/bech32 `fromAddress` is rejected outright — it is not
|
|
70
|
+
* an Ethereum-format address. Omitted (and defaulted to `fromAddress`) for
|
|
71
|
+
* an Ethereum origin, preserving the pre-quote's original behavior there.
|
|
72
|
+
*/
|
|
73
|
+
recipient?: Hex;
|
|
74
|
+
/**
|
|
75
|
+
* The `referrer` sent to Relay. Left out or `null`, the field is OMITTED —
|
|
76
|
+
* never sent as `''`. Relay's live behavior (verified 2026-09-23) answers a
|
|
77
|
+
* keyless request with NO `referrer` field 200, but treats ANY `referrer` —
|
|
78
|
+
* including `''` — as "a referrer was supplied", which requires an API key
|
|
79
|
+
* and gets 401 without one. A package default would therefore break every
|
|
80
|
+
* caller without a key, so there is none. A string is sent as-is; Gibs
|
|
81
|
+
* Finance's own value is `relayReferrer` from `relay-quote.ts`.
|
|
82
|
+
*/
|
|
83
|
+
relayReferrer?: string | null;
|
|
84
|
+
/**
|
|
85
|
+
* The `integrator` sent to LI.FI. Left out or `null`, the query parameter is
|
|
86
|
+
* OMITTED entirely (it is optional per LI.FI's own `/v1/quote` schema —
|
|
87
|
+
* verified 2026-09-23 — and an empty string would be a literal empty
|
|
88
|
+
* integrator, not an absent one). A string is sent as-is. Gibs Finance's own
|
|
89
|
+
* label is `lifiIntegrator` in `consolidated-quote.ts`; it is never sent
|
|
90
|
+
* unless you pass it.
|
|
91
|
+
*/
|
|
92
|
+
lifiIntegrator?: string | null;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* The two delivered anchor amounts a pre-quote yields.
|
|
96
|
+
*
|
|
97
|
+
* Both come from the provider's own forward solve for the fixed input, so they
|
|
98
|
+
* are decimals-correct and free of any price dependency.
|
|
99
|
+
*/
|
|
100
|
+
export type PreQuoteResult = {
|
|
101
|
+
/** The EXPECTED delivered anchor amount, for display and ranking. */
|
|
102
|
+
expectedAmount: bigint;
|
|
103
|
+
/**
|
|
104
|
+
* The GUARANTEED delivered anchor amount after slippage. This is the
|
|
105
|
+
* conservative figure the caller uses as the EXACT_OUTPUT `toAmount`, so the
|
|
106
|
+
* fixed input can actually achieve the execution target.
|
|
107
|
+
*/
|
|
108
|
+
minimumAmount: bigint;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Plain LI.FI swap quote endpoint (forward-solving), re-exported from
|
|
112
|
+
* `consolidated-quote.js` rather than redeclared here — both modules must
|
|
113
|
+
* agree on the same address, and a second literal would be free to drift from
|
|
114
|
+
* it.
|
|
115
|
+
*/
|
|
116
|
+
export { lifiQuoteUrl, lifiRequestHeaders } from './consolidated-quote.js';
|
|
117
|
+
/**
|
|
118
|
+
* The JSON body for a Relay EXACT_INPUT swap pre-quote. Mirrors
|
|
119
|
+
* `RelayQuoteRequestBody` but carries NO `txs` (it is a plain swap) and adds a
|
|
120
|
+
* `recipient` because, without destination calls, Relay needs an explicit
|
|
121
|
+
* delivery address on the entry chain.
|
|
122
|
+
*/
|
|
123
|
+
export type RelayPreQuoteRequestBody = {
|
|
124
|
+
user: string;
|
|
125
|
+
originChainId: number;
|
|
126
|
+
originCurrency: string;
|
|
127
|
+
destinationChainId: number;
|
|
128
|
+
destinationCurrency: Hex;
|
|
129
|
+
amount: string;
|
|
130
|
+
tradeType: RelayTradeType;
|
|
131
|
+
/** Where the swapped anchor lands on the entry chain (the user, for a pre-quote). */
|
|
132
|
+
recipient: string;
|
|
133
|
+
/** Origin-chain refund target; required for Relay to enable automatic refunds. */
|
|
134
|
+
refundTo: string;
|
|
135
|
+
/**
|
|
136
|
+
* OPTIONAL — omitted entirely (not `''`) for an unconfigured host. See
|
|
137
|
+
* {@link PreQuoteRequest.relayReferrer}'s doc for why `null` and `''` are
|
|
138
|
+
* two different requests to Relay.
|
|
139
|
+
*/
|
|
140
|
+
referrer?: string;
|
|
141
|
+
/** Maximum slippage in basis points; omitted when the caller defers to Relay. */
|
|
142
|
+
slippageTolerance?: string;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Builds the Relay EXACT_INPUT swap pre-quote body for a fixed input. NO `txs`
|
|
146
|
+
* are attached: Relay solves FORWARD and reports the delivered anchor amount.
|
|
147
|
+
*
|
|
148
|
+
* `recipient` and `refundTo` name TWO DIFFERENT chains and must never be
|
|
149
|
+
* conflated. `refundTo` is always the user's OWN origin-chain address — Relay
|
|
150
|
+
* refunds a failed (or, here, never-run) swap on the origin chain, and an
|
|
151
|
+
* Ethereum fallback address could not receive one there. `recipient` names
|
|
152
|
+
* where the swap lands on the ENTRY chain (`toChainId`), which is always
|
|
153
|
+
* Ethereum Virtual Machine — for an Ethereum origin the user's own address
|
|
154
|
+
* already satisfies that and is the default; for a non-Ethereum origin
|
|
155
|
+
* (Solana base58, Bitcoin bech32, ...) it does NOT, and Relay's `/quote/v2`
|
|
156
|
+
* validates the recipient's FORMAT against `toChainId` even though this
|
|
157
|
+
* pre-quote never executes. Sending the origin account there — as an earlier
|
|
158
|
+
* version of this builder did, reasoning that an unexecuted quote's recipient
|
|
159
|
+
* is "informational" — gets Relay's `400 INVALID_ADDRESS` on every
|
|
160
|
+
* non-Ethereum-origin pre-quote, which starves `fetchBestEntryAnchorPreQuote`
|
|
161
|
+
* of its only capable provider and surfaces as "No route available" for the
|
|
162
|
+
* whole non-Ethereum-origin flow. `request.recipient` (an explicit
|
|
163
|
+
* Ethereum-format address the caller supplies) is therefore REQUIRED for a
|
|
164
|
+
* non-Ethereum origin; without it this returns null.
|
|
165
|
+
*
|
|
166
|
+
* @param request - the provider-agnostic pre-quote request
|
|
167
|
+
* @returns the request body, or null when the input amount is non-positive or
|
|
168
|
+
* a non-Ethereum origin has no explicit Ethereum-format `recipient`
|
|
169
|
+
*/
|
|
170
|
+
export declare const buildRelayPreQuoteRequest: (request: PreQuoteRequest) => RelayPreQuoteRequestBody | null;
|
|
171
|
+
/**
|
|
172
|
+
* Builds the plain LI.FI swap pre-quote as a query string for `GET /v1/quote`.
|
|
173
|
+
* LI.FI's plain `/quote` is forward-solving by construction (`fromAmount` in,
|
|
174
|
+
* `estimate.toAmount` out), so no trade-type flag is needed.
|
|
175
|
+
*
|
|
176
|
+
* Returns null for a non-Ethereum origin (LI.FI cannot bridge across
|
|
177
|
+
* virtual-machine ecosystems) and for a non-positive input amount.
|
|
178
|
+
*
|
|
179
|
+
* @param request - the provider-agnostic pre-quote request
|
|
180
|
+
* @returns the URL query string (without a leading `?`), or null
|
|
181
|
+
*/
|
|
182
|
+
export declare const buildLifiPreQuoteRequest: (request: PreQuoteRequest) => string | null;
|
|
183
|
+
/**
|
|
184
|
+
* Parses a Relay EXACT_INPUT pre-quote response. The delivered anchor figures
|
|
185
|
+
* live under `details.currencyOut`: `amount` (expected) and `minimumAmount`
|
|
186
|
+
* (guaranteed slippage floor). Verified live against `api.relay.link/quote/v2`.
|
|
187
|
+
*
|
|
188
|
+
* @returns the delivered amounts, or null when the payload shape is unexpected
|
|
189
|
+
*/
|
|
190
|
+
export declare const parseRelayPreQuote: (payload: unknown) => PreQuoteResult | null;
|
|
191
|
+
/**
|
|
192
|
+
* Parses a plain LI.FI `/quote` response. The delivered anchor figures live
|
|
193
|
+
* under `estimate`: `toAmount` (expected) and `toAmountMin` (guaranteed minimum
|
|
194
|
+
* after slippage) — the same estimate shape the route-step normalizer reads.
|
|
195
|
+
*
|
|
196
|
+
* @returns the delivered amounts, or null when the payload shape is unexpected
|
|
197
|
+
*/
|
|
198
|
+
export declare const parseLifiPreQuote: (payload: unknown) => PreQuoteResult | null;
|