@lifi/types 0.0.0-preview-97f0520
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.md +201 -0
- package/README.md +59 -0
- package/package.json +46 -0
- package/src/_cjs/api.js +99 -0
- package/src/_cjs/api.js.map +1 -0
- package/src/_cjs/balance/index.js +18 -0
- package/src/_cjs/balance/index.js.map +1 -0
- package/src/_cjs/balance/wallet.js +3 -0
- package/src/_cjs/balance/wallet.js.map +1 -0
- package/src/_cjs/bridges.js +3 -0
- package/src/_cjs/bridges.js.map +1 -0
- package/src/_cjs/chains/Chain.js +13 -0
- package/src/_cjs/chains/Chain.js.map +1 -0
- package/src/_cjs/chains/EVMChain.js +3 -0
- package/src/_cjs/chains/EVMChain.js.map +1 -0
- package/src/_cjs/chains/MVMChain.js +3 -0
- package/src/_cjs/chains/MVMChain.js.map +1 -0
- package/src/_cjs/chains/STLChain.js +3 -0
- package/src/_cjs/chains/STLChain.js.map +1 -0
- package/src/_cjs/chains/SVMChain.js +3 -0
- package/src/_cjs/chains/SVMChain.js.map +1 -0
- package/src/_cjs/chains/TVMChain.js +3 -0
- package/src/_cjs/chains/TVMChain.js.map +1 -0
- package/src/_cjs/chains/UTXOChain.js +3 -0
- package/src/_cjs/chains/UTXOChain.js.map +1 -0
- package/src/_cjs/chains/base.js +196 -0
- package/src/_cjs/chains/base.js.map +1 -0
- package/src/_cjs/chains/index.js +25 -0
- package/src/_cjs/chains/index.js.map +1 -0
- package/src/_cjs/earn.js +3 -0
- package/src/_cjs/earn.js.map +1 -0
- package/src/_cjs/errors.js +21 -0
- package/src/_cjs/errors.js.map +1 -0
- package/src/_cjs/exchanges.js +3 -0
- package/src/_cjs/exchanges.js.map +1 -0
- package/src/_cjs/index.js +28 -0
- package/src/_cjs/index.js.map +1 -0
- package/src/_cjs/package.json +1 -0
- package/src/_cjs/routeSlippage.js +13 -0
- package/src/_cjs/routeSlippage.js.map +1 -0
- package/src/_cjs/step.js +28 -0
- package/src/_cjs/step.js.map +1 -0
- package/src/_cjs/tokens/base.js +137 -0
- package/src/_cjs/tokens/base.js.map +1 -0
- package/src/_cjs/tokens/index.js +19 -0
- package/src/_cjs/tokens/index.js.map +1 -0
- package/src/_cjs/tokens/token.js +12 -0
- package/src/_cjs/tokens/token.js.map +1 -0
- package/src/_cjs/typed-data.js +3 -0
- package/src/_cjs/typed-data.js.map +1 -0
- package/src/_esm/api.js +126 -0
- package/src/_esm/api.js.map +1 -0
- package/src/_esm/balance/index.js +2 -0
- package/src/_esm/balance/index.js.map +1 -0
- package/src/_esm/balance/wallet.js +2 -0
- package/src/_esm/balance/wallet.js.map +1 -0
- package/src/_esm/bridges.js +2 -0
- package/src/_esm/bridges.js.map +1 -0
- package/src/_esm/chains/Chain.js +15 -0
- package/src/_esm/chains/Chain.js.map +1 -0
- package/src/_esm/chains/EVMChain.js +2 -0
- package/src/_esm/chains/EVMChain.js.map +1 -0
- package/src/_esm/chains/MVMChain.js +2 -0
- package/src/_esm/chains/MVMChain.js.map +1 -0
- package/src/_esm/chains/STLChain.js +2 -0
- package/src/_esm/chains/STLChain.js.map +1 -0
- package/src/_esm/chains/SVMChain.js +2 -0
- package/src/_esm/chains/SVMChain.js.map +1 -0
- package/src/_esm/chains/TVMChain.js +2 -0
- package/src/_esm/chains/TVMChain.js.map +1 -0
- package/src/_esm/chains/UTXOChain.js +2 -0
- package/src/_esm/chains/UTXOChain.js.map +1 -0
- package/src/_esm/chains/base.js +209 -0
- package/src/_esm/chains/base.js.map +1 -0
- package/src/_esm/chains/index.js +9 -0
- package/src/_esm/chains/index.js.map +1 -0
- package/src/_esm/earn.js +9 -0
- package/src/_esm/earn.js.map +1 -0
- package/src/_esm/errors.js +19 -0
- package/src/_esm/errors.js.map +1 -0
- package/src/_esm/exchanges.js +2 -0
- package/src/_esm/exchanges.js.map +1 -0
- package/src/_esm/index.js +12 -0
- package/src/_esm/index.js.map +1 -0
- package/src/_esm/package.json +1 -0
- package/src/_esm/routeSlippage.js +54 -0
- package/src/_esm/routeSlippage.js.map +1 -0
- package/src/_esm/step.js +25 -0
- package/src/_esm/step.js.map +1 -0
- package/src/_esm/tokens/base.js +144 -0
- package/src/_esm/tokens/base.js.map +1 -0
- package/src/_esm/tokens/index.js +3 -0
- package/src/_esm/tokens/index.js.map +1 -0
- package/src/_esm/tokens/token.js +10 -0
- package/src/_esm/tokens/token.js.map +1 -0
- package/src/_esm/typed-data.js +2 -0
- package/src/_esm/typed-data.js.map +1 -0
- package/src/_types/api.d.ts +891 -0
- package/src/_types/api.d.ts.map +1 -0
- package/src/_types/balance/index.d.ts +2 -0
- package/src/_types/balance/index.d.ts.map +1 -0
- package/src/_types/balance/wallet.d.ts +97 -0
- package/src/_types/balance/wallet.d.ts.map +1 -0
- package/src/_types/bridges.d.ts +29 -0
- package/src/_types/bridges.d.ts.map +1 -0
- package/src/_types/chains/Chain.d.ts +21 -0
- package/src/_types/chains/Chain.d.ts.map +1 -0
- package/src/_types/chains/EVMChain.d.ts +23 -0
- package/src/_types/chains/EVMChain.d.ts.map +1 -0
- package/src/_types/chains/MVMChain.d.ts +6 -0
- package/src/_types/chains/MVMChain.d.ts.map +1 -0
- package/src/_types/chains/STLChain.d.ts +6 -0
- package/src/_types/chains/STLChain.d.ts.map +1 -0
- package/src/_types/chains/SVMChain.d.ts +10 -0
- package/src/_types/chains/SVMChain.d.ts.map +1 -0
- package/src/_types/chains/TVMChain.d.ts +7 -0
- package/src/_types/chains/TVMChain.d.ts.map +1 -0
- package/src/_types/chains/UTXOChain.d.ts +6 -0
- package/src/_types/chains/UTXOChain.d.ts.map +1 -0
- package/src/_types/chains/base.d.ts +191 -0
- package/src/_types/chains/base.d.ts.map +1 -0
- package/src/_types/chains/index.d.ts +9 -0
- package/src/_types/chains/index.d.ts.map +1 -0
- package/src/_types/earn.d.ts +137 -0
- package/src/_types/earn.d.ts.map +1 -0
- package/src/_types/errors.d.ts +17 -0
- package/src/_types/errors.d.ts.map +1 -0
- package/src/_types/exchanges.d.ts +25 -0
- package/src/_types/exchanges.d.ts.map +1 -0
- package/src/_types/index.d.ts +12 -0
- package/src/_types/index.d.ts.map +1 -0
- package/src/_types/routeSlippage.d.ts +85 -0
- package/src/_types/routeSlippage.d.ts.map +1 -0
- package/src/_types/step.d.ts +218 -0
- package/src/_types/step.d.ts.map +1 -0
- package/src/_types/tokens/base.d.ts +133 -0
- package/src/_types/tokens/base.d.ts.map +1 -0
- package/src/_types/tokens/index.d.ts +3 -0
- package/src/_types/tokens/index.d.ts.map +1 -0
- package/src/_types/tokens/token.d.ts +54 -0
- package/src/_types/tokens/token.d.ts.map +1 -0
- package/src/_types/typed-data.d.ts +31 -0
- package/src/_types/typed-data.d.ts.map +1 -0
- package/src/api.ts +1185 -0
- package/src/balance/index.ts +1 -0
- package/src/balance/wallet.ts +102 -0
- package/src/bridges.ts +30 -0
- package/src/chains/Chain.ts +28 -0
- package/src/chains/EVMChain.ts +28 -0
- package/src/chains/MVMChain.ts +6 -0
- package/src/chains/STLChain.ts +6 -0
- package/src/chains/SVMChain.ts +11 -0
- package/src/chains/TVMChain.ts +7 -0
- package/src/chains/UTXOChain.ts +6 -0
- package/src/chains/base.ts +221 -0
- package/src/chains/index.ts +8 -0
- package/src/earn.ts +158 -0
- package/src/errors.ts +17 -0
- package/src/exchanges.ts +27 -0
- package/src/index.ts +11 -0
- package/src/routeSlippage.ts +97 -0
- package/src/step.ts +281 -0
- package/src/tokens/base.ts +152 -0
- package/src/tokens/index.ts +2 -0
- package/src/tokens/token.ts +63 -0
- package/src/typed-data.ts +34 -0
package/src/api.ts
ADDED
|
@@ -0,0 +1,1185 @@
|
|
|
1
|
+
import type { BridgeDefinition } from './bridges.js'
|
|
2
|
+
import type { Chain, ChainId, ChainKey, ChainType } from './chains/index.js'
|
|
3
|
+
import type { ExchangeDefinition } from './exchanges.js'
|
|
4
|
+
import type {
|
|
5
|
+
Action,
|
|
6
|
+
DestinationAction,
|
|
7
|
+
DestinationActionKind,
|
|
8
|
+
FeeCost,
|
|
9
|
+
LiFiStep,
|
|
10
|
+
SignedLiFiStep,
|
|
11
|
+
StepToolDetails,
|
|
12
|
+
} from './step.js'
|
|
13
|
+
import type {
|
|
14
|
+
BaseToken,
|
|
15
|
+
Token,
|
|
16
|
+
TokenExtended,
|
|
17
|
+
TokenTag,
|
|
18
|
+
} from './tokens/index.js'
|
|
19
|
+
import type { RouteSlippageCommitment, SlippageScope } from './routeSlippage.js'
|
|
20
|
+
import type {
|
|
21
|
+
Address,
|
|
22
|
+
Hash,
|
|
23
|
+
Hex,
|
|
24
|
+
TypedDataDomain,
|
|
25
|
+
TypedDataParameter,
|
|
26
|
+
} from './typed-data.js'
|
|
27
|
+
|
|
28
|
+
export enum SVMPriorityFeeLevel {
|
|
29
|
+
NORMAL = 'NORMAL',
|
|
30
|
+
FAST = 'FAST',
|
|
31
|
+
ULTRA = 'ULTRA',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Used as a bigint replacement for TransactionRequest because bigint is not serializable
|
|
36
|
+
*/
|
|
37
|
+
export type BigIntish = string
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Pagination options for the API
|
|
41
|
+
*/
|
|
42
|
+
export interface PaginationQuery {
|
|
43
|
+
limit?: number
|
|
44
|
+
next?: string
|
|
45
|
+
previous?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* API response for paginated requests
|
|
50
|
+
*/
|
|
51
|
+
export interface PaginatedResponse<T> {
|
|
52
|
+
hasNext?: boolean
|
|
53
|
+
hasPrevious?: boolean
|
|
54
|
+
next?: string
|
|
55
|
+
previous?: string
|
|
56
|
+
total?: number
|
|
57
|
+
data: T[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type TransactionRequest = {
|
|
61
|
+
to?: string
|
|
62
|
+
from?: string
|
|
63
|
+
nonce?: number
|
|
64
|
+
|
|
65
|
+
gasLimit?: BigIntish
|
|
66
|
+
gasPrice?: BigIntish
|
|
67
|
+
|
|
68
|
+
data?: string
|
|
69
|
+
value?: BigIntish
|
|
70
|
+
chainId?: number
|
|
71
|
+
|
|
72
|
+
type?: number
|
|
73
|
+
accessList?: { address: string; storageKeys: string[] }[]
|
|
74
|
+
|
|
75
|
+
maxPriorityFeePerGas?: BigIntish
|
|
76
|
+
maxFeePerGas?: BigIntish
|
|
77
|
+
|
|
78
|
+
// oxlint-disable-next-line typescript/no-explicit-any -- public API type; narrowing it is a breaking change
|
|
79
|
+
customData?: Record<string, any>
|
|
80
|
+
ccipReadEnabled?: boolean
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Timing options
|
|
85
|
+
*/
|
|
86
|
+
export interface TimingStrategyMinWaitTime {
|
|
87
|
+
strategy: 'minWaitTime'
|
|
88
|
+
minWaitTimeMs: number
|
|
89
|
+
startingExpectedResults: number
|
|
90
|
+
reduceEveryMs: number
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type TimingStrategyMinWaitTimeString =
|
|
94
|
+
`minWaitTime-${number}-${number}-${number}`
|
|
95
|
+
|
|
96
|
+
export type TimingStrategy = TimingStrategyMinWaitTime
|
|
97
|
+
export type TimingStrategyString = TimingStrategyMinWaitTimeString
|
|
98
|
+
|
|
99
|
+
export interface Timing {
|
|
100
|
+
swapStepTimingStrategies?: TimingStrategy[]
|
|
101
|
+
routeTimingStrategies?: TimingStrategy[]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface TimingStrings {
|
|
105
|
+
swapStepTimingStrategies?: TimingStrategyString[]
|
|
106
|
+
routeTimingStrategies?: TimingStrategyString[]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* RECOMMENDED and SAFEST are deprecated as of 28.06.24
|
|
111
|
+
* https://lifi.atlassian.net/browse/LF-8826
|
|
112
|
+
*/
|
|
113
|
+
export const Orders = ['RECOMMENDED', 'FASTEST', 'CHEAPEST', 'SAFEST'] as const
|
|
114
|
+
export type Order = (typeof Orders)[number]
|
|
115
|
+
|
|
116
|
+
export interface RoutesRequest {
|
|
117
|
+
fromChainId: number
|
|
118
|
+
fromAmount: string
|
|
119
|
+
|
|
120
|
+
fromTokenAddress: string
|
|
121
|
+
fromAddress?: string
|
|
122
|
+
|
|
123
|
+
toChainId: number
|
|
124
|
+
toTokenAddress: string
|
|
125
|
+
toAddress?: string
|
|
126
|
+
|
|
127
|
+
options?: RouteOptions
|
|
128
|
+
fromAmountForGas?: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface RouteOptionsBase {
|
|
132
|
+
/** 0.03 = take 3% integrator fee (requires verified integrator to be set) */
|
|
133
|
+
fee?: number
|
|
134
|
+
|
|
135
|
+
/** Hide routes with price impact greater than or equal to this value */
|
|
136
|
+
maxPriceImpact?: number
|
|
137
|
+
|
|
138
|
+
/** (default: CHEAPEST) 'FASTEST' | 'CHEAPEST' */
|
|
139
|
+
order?: Order
|
|
140
|
+
|
|
141
|
+
/** (default: 0.03) Expressed as decimal proportion, 0.03 represents 3%.
|
|
142
|
+
* With `slippageScope: 'route'` this is the total budget `S` for the whole
|
|
143
|
+
* route instead (explicit value in `[0, 1)` required; no default applies). */
|
|
144
|
+
slippage?: number
|
|
145
|
+
|
|
146
|
+
/** Scope of `slippage`. Omitted and `'step'` are identical (per-step
|
|
147
|
+
* slippage, today's behaviour). `'route'` opts into route-wide protection:
|
|
148
|
+
* the response carries a {@link RouteSlippageCommitment} and unsupported
|
|
149
|
+
* paths are rejected instead of downgraded. @default 'step' */
|
|
150
|
+
slippageScope?: SlippageScope
|
|
151
|
+
|
|
152
|
+
/** (default: false) Whether chain switches should be allowed in the routes */
|
|
153
|
+
allowSwitchChain?: boolean
|
|
154
|
+
|
|
155
|
+
/** (default: true) destination calls are enabled by default */
|
|
156
|
+
allowDestinationCall?: boolean
|
|
157
|
+
|
|
158
|
+
/** Bridges that should or should not be taken into consideration for the possibilities */
|
|
159
|
+
bridges?: AllowDenyPrefer
|
|
160
|
+
|
|
161
|
+
/** Exchanges that should or should not be taken into consideration for the possibilities */
|
|
162
|
+
exchanges?: AllowDenyPrefer
|
|
163
|
+
|
|
164
|
+
/** Protocols that should or should not be taken into consideration for the possibilities */
|
|
165
|
+
protocols?: AllowDenyPrefer
|
|
166
|
+
|
|
167
|
+
/** Pools that should not be taken into consideration for the possibilities.
|
|
168
|
+
* Only supported by the `fly` exchange — see {@link PoolDeny}. */
|
|
169
|
+
pools?: PoolDeny
|
|
170
|
+
|
|
171
|
+
/** Liquidity venues each swap leg may execute against, per side.
|
|
172
|
+
* Only supported by the `fly` exchange — see {@link LiquiditySources}. */
|
|
173
|
+
liquiditySources?: LiquiditySources
|
|
174
|
+
|
|
175
|
+
/** Timing strategies for the routes */
|
|
176
|
+
timing?: Timing
|
|
177
|
+
|
|
178
|
+
/** Whether to include routes that require a transaction or a message, or both
|
|
179
|
+
* @default 'transaction' */
|
|
180
|
+
executionType?: ExecutionType
|
|
181
|
+
|
|
182
|
+
/** Opt the request into gasless execution. The returned steps carry signable
|
|
183
|
+
* typed data instead of a `transactionRequest`, and a relay fee is deducted
|
|
184
|
+
* from the input amount as a `feeCosts` entry named `LIFI Gasless Relay Fee`.
|
|
185
|
+
* @default false */
|
|
186
|
+
gasless?: boolean
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* A single entry in the `distributionFees` request parameter.
|
|
191
|
+
*
|
|
192
|
+
* `distributionFees` lets a verified integrator carve additional on-chain
|
|
193
|
+
* recipients out of their integrator-fee pool, in parallel with the
|
|
194
|
+
* optional `intermediary` carve. Each entry produces an extra fee transfer
|
|
195
|
+
* to `receiver` proportional to `percentage` of the source amount, executed
|
|
196
|
+
* via the LI.FI FeeForwarder contract. Partner-provided receivers are
|
|
197
|
+
* sanction-screened at quote time (warn-log on failure, see backend logs).
|
|
198
|
+
*
|
|
199
|
+
* Constraints (enforced server-side, subject to change without a types
|
|
200
|
+
* major bump — read the current values from the API error responses if
|
|
201
|
+
* you need them programmatically):
|
|
202
|
+
* - `percentage` is a decimal proportion ( `0.001` = 0.1% ), exclusive of 0
|
|
203
|
+
* and bounded by a per-request cap. The aggregate fee (integrator `fee`
|
|
204
|
+
* plus all `distributionFees[].percentage`) is also capped by the
|
|
205
|
+
* backend; exceeding either limit yields a `ValidationError`.
|
|
206
|
+
* - At most ~10 entries per request.
|
|
207
|
+
* - `receiver` must be a non-zero EVM address (`0x` followed by 40 hex
|
|
208
|
+
* characters). Non-EVM receivers are not yet supported.
|
|
209
|
+
*
|
|
210
|
+
* Only meaningful when `integrator` is set and has an active fee agreement.
|
|
211
|
+
*/
|
|
212
|
+
export interface DistributionFee {
|
|
213
|
+
/** Fraction of the swap input taken as a distribution fee (e.g. `0.001` = 0.1%). */
|
|
214
|
+
percentage: number
|
|
215
|
+
/** On-chain EVM recipient address; must be a non-zero `0x`-prefixed hex address. */
|
|
216
|
+
receiver: string
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface RouteOptions extends RouteOptionsBase {
|
|
220
|
+
/** Should contain the identifier of the integrator. Usually, it's dApp/company name. */
|
|
221
|
+
integrator?: string
|
|
222
|
+
|
|
223
|
+
/** Optional intermediary identifier for multi-party fee splitting.
|
|
224
|
+
* Requires a registered integrator with a `fee` and a configured intermediary share on the backend. */
|
|
225
|
+
intermediary?: string
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Partner-provided fee distribution recipients. Each entry adds an
|
|
229
|
+
* independent on-chain transfer to `receiver` in proportion to
|
|
230
|
+
* `percentage` of the swap input, in parallel with the integrator and
|
|
231
|
+
* (optional) intermediary carves. Requires a verified `integrator` with
|
|
232
|
+
* an active fee agreement.
|
|
233
|
+
* @see {@link DistributionFee} for per-entry constraints.
|
|
234
|
+
*/
|
|
235
|
+
distributionFees?: DistributionFee[]
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Disable the backend integrator fee for this request.
|
|
239
|
+
*
|
|
240
|
+
* Permissioned: honoured only for allowlisted integrations (authenticated via
|
|
241
|
+
* their API key). Non-allowlisted callers that set it are ignored and charged
|
|
242
|
+
* normally. Attribution and integrator-specific config still resolve from
|
|
243
|
+
* `integrator` — only the fee is suppressed.
|
|
244
|
+
*/
|
|
245
|
+
disableFees?: boolean
|
|
246
|
+
|
|
247
|
+
/** Integrators can set a wallet address as a referrer to track them */
|
|
248
|
+
referrer?: string
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Recipient of source-chain bridge principal refunds, independent of the
|
|
252
|
+
* funding sender and successful recipient. Must be valid on the source chain.
|
|
253
|
+
* When supplied, bridges and quote variants that cannot honor it are excluded
|
|
254
|
+
* or rejected rather than falling back to the sender. Does not redirect
|
|
255
|
+
* destination swap/call recovery. Omission preserves the bridge's default.
|
|
256
|
+
*/
|
|
257
|
+
refundAddress?: string
|
|
258
|
+
|
|
259
|
+
/** SVM specific option, without it implicit source swaps routes are discarded */
|
|
260
|
+
jitoBundle?: boolean
|
|
261
|
+
|
|
262
|
+
/** SVM specific option, wallet to sponsor tx costs */
|
|
263
|
+
svmSponsor?: string
|
|
264
|
+
|
|
265
|
+
/** SVM specific option, priority fee level */
|
|
266
|
+
svmPriorityFeeLevel?: SVMPriorityFeeLevel
|
|
267
|
+
|
|
268
|
+
/** Mayan specific option to bridge from non-EVM chain to Hyperliquid */
|
|
269
|
+
mayanNonEvmPermitSignature?: boolean
|
|
270
|
+
|
|
271
|
+
/** Preset configuration for stablecoin routing optimization.
|
|
272
|
+
* When provided, this preset will override other route options with optimized settings */
|
|
273
|
+
preset?: string
|
|
274
|
+
|
|
275
|
+
/** Opt into amount-flexible routing where the underlying tool supports it.
|
|
276
|
+
* Instead of a fixed minimum output, an amount-flexible route carries a signed
|
|
277
|
+
* rate floor, a minimum deposit and a rate expiry alongside a deposit address:
|
|
278
|
+
* any amount at or above the minimum, funded within the window, executes at
|
|
279
|
+
* the live price no worse than the floor. Currently honored only by
|
|
280
|
+
* cross-chain Smart Deposit Address routes; ignored by tools that do not
|
|
281
|
+
* support it.
|
|
282
|
+
* @default false */
|
|
283
|
+
amountFlexible?: boolean
|
|
284
|
+
|
|
285
|
+
/** Requests a destination-side action executed after the bridge leg
|
|
286
|
+
* (cross-chain EVM Smart Deposits routes only). The returned route's Smart
|
|
287
|
+
* Deposits step carries the action — post that step unchanged to
|
|
288
|
+
* `/v1/advanced/stepTransaction`. Routes that cannot execute the action are
|
|
289
|
+
* rejected or excluded rather than silently served without it. */
|
|
290
|
+
destinationAction?: DestinationAction
|
|
291
|
+
|
|
292
|
+
/** Whether the user wants to insure their tx
|
|
293
|
+
* @deprecated This property is deprecated and will be removed in future versions. */
|
|
294
|
+
insurance?: boolean
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export const ExecutionTypes = ['transaction', 'message', 'all'] as const
|
|
298
|
+
export type ExecutionType = (typeof ExecutionTypes)[number]
|
|
299
|
+
|
|
300
|
+
export type ToolsResponse = {
|
|
301
|
+
exchanges: {
|
|
302
|
+
key: string
|
|
303
|
+
name: string
|
|
304
|
+
logoURI: string
|
|
305
|
+
supportedChains: ChainId[]
|
|
306
|
+
}[]
|
|
307
|
+
bridges: {
|
|
308
|
+
key: string
|
|
309
|
+
name: string
|
|
310
|
+
logoURI: string
|
|
311
|
+
supportedChains: {
|
|
312
|
+
fromChainId: ChainId
|
|
313
|
+
toChainId: ChainId
|
|
314
|
+
}[]
|
|
315
|
+
}[]
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface AllowDenyPrefer {
|
|
319
|
+
allow?: string[] // (default: [all])
|
|
320
|
+
deny?: string[] // (default: [])
|
|
321
|
+
prefer?: string[] // (default: []) // eg. ['1inch'] to use 1inch if available and fall back to others if not
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export interface PoolDeny {
|
|
325
|
+
/**
|
|
326
|
+
* AMM pool identifiers to exclude from swap quoting. Accepts either:
|
|
327
|
+
* - Uniswap V2 / V3: a plain EVM pool address (`0x` + 40 hex, non-zero).
|
|
328
|
+
* - Uniswap V4: `${poolManagerAddress}-${poolId}` where `poolId` is a
|
|
329
|
+
* 32-byte hex string.
|
|
330
|
+
* Pool-level exclusion is only supported by the `fly` exchange aggregator, so
|
|
331
|
+
* setting this restricts every swap in the route to `fly`.
|
|
332
|
+
*/
|
|
333
|
+
deny?: string[]
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Liquidity venues a swap leg is allowed to execute against, scoped per side of
|
|
338
|
+
* the route. Names come from Fly's liquidity-source list and are chain-specific
|
|
339
|
+
* (e.g. `aerodrome-stable` on Base); a name valid on another chain simply yields
|
|
340
|
+
* no route. Venue-level filtering is only supported by the `fly` exchange
|
|
341
|
+
* aggregator, so a side with a list set is restricted to `fly`.
|
|
342
|
+
*
|
|
343
|
+
* On a same-chain route the single swap counts as the source leg, so `source`
|
|
344
|
+
* applies and `destination` is ignored.
|
|
345
|
+
*/
|
|
346
|
+
export interface LiquiditySources {
|
|
347
|
+
/** Venues allowed for the swap on the source chain. */
|
|
348
|
+
source?: string[]
|
|
349
|
+
/** Venues allowed for the swap on the destination chain. */
|
|
350
|
+
destination?: string[]
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* @deprecated _InsuranceState is deprecated and will be removed in future versions.
|
|
355
|
+
*/
|
|
356
|
+
export const _InsuranceState = [
|
|
357
|
+
'INSURED',
|
|
358
|
+
'INSURABLE',
|
|
359
|
+
'NOT_INSURABLE',
|
|
360
|
+
] as const
|
|
361
|
+
/**
|
|
362
|
+
* @deprecated InsuranceState is deprecated and will be removed in future versions.
|
|
363
|
+
*/
|
|
364
|
+
export type InsuranceState = (typeof _InsuranceState)[number]
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* @deprecated InsuranceState is deprecated and will be removed in future versions.
|
|
368
|
+
*/
|
|
369
|
+
export interface Insurance {
|
|
370
|
+
state: InsuranceState
|
|
371
|
+
feeAmountUsd: string
|
|
372
|
+
}
|
|
373
|
+
export interface Route {
|
|
374
|
+
id: string
|
|
375
|
+
insurance: Insurance
|
|
376
|
+
fromChainId: number
|
|
377
|
+
fromAmountUSD: string
|
|
378
|
+
fromAmount: string
|
|
379
|
+
fromToken: Token
|
|
380
|
+
fromAddress?: string
|
|
381
|
+
|
|
382
|
+
toChainId: number
|
|
383
|
+
toAmountUSD: string
|
|
384
|
+
toAmount: string
|
|
385
|
+
toAmountMin: string
|
|
386
|
+
toToken: Token
|
|
387
|
+
toAddress?: string
|
|
388
|
+
|
|
389
|
+
/** Present iff the route was admitted with `slippageScope: 'route'`; also
|
|
390
|
+
* mirrored onto every participating root step. Absent on step-scope routes. */
|
|
391
|
+
routeSlippage?: RouteSlippageCommitment
|
|
392
|
+
|
|
393
|
+
gasCostUSD?: string // Aggregation of underlying gas costs in usd
|
|
394
|
+
|
|
395
|
+
containsSwitchChain?: boolean // Features required for route execution
|
|
396
|
+
|
|
397
|
+
steps: LiFiStep[]
|
|
398
|
+
|
|
399
|
+
tags?: Order[]
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export type ToolErrorType = 'NO_QUOTE'
|
|
403
|
+
|
|
404
|
+
export interface ToolError {
|
|
405
|
+
errorType: ToolErrorType
|
|
406
|
+
code: string
|
|
407
|
+
action: Action
|
|
408
|
+
tool: string
|
|
409
|
+
message: string
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export type ErroredPaths = { [subpath: string]: ToolError[] }
|
|
413
|
+
|
|
414
|
+
export type ErroredRoute = {
|
|
415
|
+
overallPath: string
|
|
416
|
+
subpaths: ErroredPaths
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export type FilteredResult = {
|
|
420
|
+
overallPath: string
|
|
421
|
+
reason: string
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export type UnavailableRoutes = {
|
|
425
|
+
filteredOut: FilteredResult[]
|
|
426
|
+
failed: ErroredRoute[]
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export interface RoutesResponse {
|
|
430
|
+
routes: Route[]
|
|
431
|
+
unavailableRoutes: UnavailableRoutes
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export type PossibilityTopic = 'chains' | 'tokens' | 'bridges' | 'exchanges'
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
|
|
438
|
+
* @deprecated
|
|
439
|
+
*/
|
|
440
|
+
export interface PossibilitiesRequest {
|
|
441
|
+
chains?: number[] // (default: [all]) // eg. [1, 56, 100]
|
|
442
|
+
bridges?: AllowDenyPrefer
|
|
443
|
+
exchanges?: AllowDenyPrefer
|
|
444
|
+
include?: PossibilityTopic[]
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Should not be accessed via the types package anymore
|
|
449
|
+
* @deprecated
|
|
450
|
+
*/
|
|
451
|
+
export interface PossibilitiesResponse {
|
|
452
|
+
chains?: Chain[]
|
|
453
|
+
tokens?: Token[]
|
|
454
|
+
bridges?: BridgeDefinition[]
|
|
455
|
+
exchanges?: ExchangeDefinition[]
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export interface GetTokenRequest {
|
|
459
|
+
chain: number | string
|
|
460
|
+
token: string
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export enum TokenHistoricGranularity {
|
|
464
|
+
THIRTY_MIN = '30min',
|
|
465
|
+
HOUR = 'hour',
|
|
466
|
+
DAY = 'day',
|
|
467
|
+
OVER_DAY = '>day',
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export interface GetTokenHistoricRequest {
|
|
471
|
+
chain: number | string
|
|
472
|
+
token: string
|
|
473
|
+
timestamp: number
|
|
474
|
+
granularity?: TokenHistoricGranularity
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
export interface TokenPriceHistoricResponse {
|
|
478
|
+
chainId: number
|
|
479
|
+
tokenAddress: string
|
|
480
|
+
isNativeToken: boolean
|
|
481
|
+
priceUSD: string
|
|
482
|
+
timestamp: number
|
|
483
|
+
granularity: TokenHistoricGranularity
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export interface ToolConfiguration {
|
|
487
|
+
allowBridges?: string[]
|
|
488
|
+
denyBridges?: string[]
|
|
489
|
+
preferBridges?: string[]
|
|
490
|
+
allowExchanges?: string[]
|
|
491
|
+
denyExchanges?: string[]
|
|
492
|
+
preferExchanges?: string[]
|
|
493
|
+
allowProtocols?: string[]
|
|
494
|
+
denyProtocols?: string[]
|
|
495
|
+
denyPools?: string[]
|
|
496
|
+
liquiditySourcesSource?: string[]
|
|
497
|
+
liquiditySourcesDestination?: string[]
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
export interface QuoteRequest extends ToolConfiguration, TimingStrings {
|
|
501
|
+
fromChain: number | string
|
|
502
|
+
fromToken: string
|
|
503
|
+
fromAddress: string
|
|
504
|
+
fromAmount: string
|
|
505
|
+
|
|
506
|
+
toChain: number | string
|
|
507
|
+
toToken: string
|
|
508
|
+
toAddress?: string
|
|
509
|
+
/** @see {@link RouteOptions.refundAddress} */
|
|
510
|
+
refundAddress?: string
|
|
511
|
+
|
|
512
|
+
order?: Order
|
|
513
|
+
slippage?: number | string
|
|
514
|
+
/** Scope of `slippage` — see {@link RouteOptionsBase.slippageScope}.
|
|
515
|
+
* Exact-input quotes only; other surfaces reject `'route'`. @default 'step' */
|
|
516
|
+
slippageScope?: SlippageScope
|
|
517
|
+
integrator?: string
|
|
518
|
+
/** Optional intermediary identifier for multi-party fee splitting.
|
|
519
|
+
* Requires a registered integrator with a `fee` and a configured intermediary share on the backend. */
|
|
520
|
+
intermediary?: string
|
|
521
|
+
/** @see {@link RouteOptions.distributionFees} and {@link DistributionFee} */
|
|
522
|
+
distributionFees?: DistributionFee[]
|
|
523
|
+
referrer?: string
|
|
524
|
+
fee?: number | string
|
|
525
|
+
/** @see {@link RouteOptions.disableFees} */
|
|
526
|
+
disableFees?: boolean
|
|
527
|
+
|
|
528
|
+
/** Whether destination calls are enabled by default
|
|
529
|
+
* @default true */
|
|
530
|
+
allowDestinationCall?: boolean
|
|
531
|
+
|
|
532
|
+
/** Requests a destination-side action executed after the bridge leg (Smart Deposits routes only).
|
|
533
|
+
* Must be sent together with `destinationActionVault`; cross-chain EVM routes only. */
|
|
534
|
+
destinationActionKind?: DestinationActionKind
|
|
535
|
+
|
|
536
|
+
/** The ERC-4626 vault the bridged funds are deposited into. Must be on the curated allowlist
|
|
537
|
+
* and its underlying asset must equal `toToken`. Must be sent together with `destinationActionKind`. */
|
|
538
|
+
destinationActionVault?: string
|
|
539
|
+
|
|
540
|
+
/** The amount of token to convert to gas */
|
|
541
|
+
fromAmountForGas?: string
|
|
542
|
+
|
|
543
|
+
/** Hide routes with price impact greater than or equal to this value */
|
|
544
|
+
maxPriceImpact?: number
|
|
545
|
+
|
|
546
|
+
/** Whether to skip simulation of the quote */
|
|
547
|
+
skipSimulation?: boolean
|
|
548
|
+
|
|
549
|
+
/** The execution type of the quote
|
|
550
|
+
* @default 'transaction' */
|
|
551
|
+
executionType?: ExecutionType
|
|
552
|
+
|
|
553
|
+
/** Opt the request into gasless execution. The response returns signable
|
|
554
|
+
* typed data instead of a `transactionRequest`, and a relay fee is deducted
|
|
555
|
+
* from the input amount as a `feeCosts` entry named `LIFI Gasless Relay Fee`.
|
|
556
|
+
* @default false */
|
|
557
|
+
gasless?: boolean
|
|
558
|
+
|
|
559
|
+
/** SVM specific option, without it implicit source swaps routes are discarded */
|
|
560
|
+
jitoBundle?: boolean
|
|
561
|
+
|
|
562
|
+
/** SVM specific option, wallet to sponsor tx costs */
|
|
563
|
+
svmSponsor?: string
|
|
564
|
+
|
|
565
|
+
/** SVM specific option, priority fee level */
|
|
566
|
+
svmPriorityFeeLevel?: SVMPriorityFeeLevel
|
|
567
|
+
|
|
568
|
+
/** Preset configuration for stablecoin routing optimization
|
|
569
|
+
* When provided, this preset will override other route options with optimized settings */
|
|
570
|
+
preset?: string
|
|
571
|
+
|
|
572
|
+
/** Indicates whether the user wants a quote with bridge insurance
|
|
573
|
+
* @deprecated This property is deprecated and will be removed in future versions. */
|
|
574
|
+
insurance?: boolean
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export interface QuoteToAmountRequest extends Omit<
|
|
578
|
+
QuoteRequest,
|
|
579
|
+
// Destination actions are excluded: a target output amount cannot be
|
|
580
|
+
// inverted across the action leg, and the endpoint rejects the params.
|
|
581
|
+
| 'fromAmount'
|
|
582
|
+
| 'fromAmountForGas'
|
|
583
|
+
| 'insurance'
|
|
584
|
+
| 'destinationActionKind'
|
|
585
|
+
| 'destinationActionVault'
|
|
586
|
+
// Route-wide protection is exact-input only: exact-output stays on step
|
|
587
|
+
// scope and rejects `'route'` instead of downgrading.
|
|
588
|
+
| 'slippageScope'
|
|
589
|
+
> {
|
|
590
|
+
toAmount: string
|
|
591
|
+
slippageScope?: 'step'
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export interface ContractCall {
|
|
595
|
+
fromAmount: string
|
|
596
|
+
fromTokenAddress: string
|
|
597
|
+
toContractAddress: string
|
|
598
|
+
toContractCallData: string
|
|
599
|
+
toContractGasLimit: string
|
|
600
|
+
toApprovalAddress?: string
|
|
601
|
+
toTokenAddress?: string
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
type PartialContractCallsQuoteRequest = ToolConfiguration & {
|
|
605
|
+
fromChain: number | string
|
|
606
|
+
fromToken: string
|
|
607
|
+
fromAddress: string
|
|
608
|
+
/** @see {@link RouteOptions.refundAddress} */
|
|
609
|
+
refundAddress?: string
|
|
610
|
+
|
|
611
|
+
toChain: number | string
|
|
612
|
+
toToken: string
|
|
613
|
+
|
|
614
|
+
toFallbackAddress?: string
|
|
615
|
+
contractOutputsToken?: string
|
|
616
|
+
contractCalls: ContractCall[]
|
|
617
|
+
|
|
618
|
+
slippage?: number | string
|
|
619
|
+
/** Contract-call quotes stay on step scope; `'route'` is rejected. */
|
|
620
|
+
slippageScope?: 'step'
|
|
621
|
+
integrator?: string
|
|
622
|
+
referrer?: string
|
|
623
|
+
fee?: number | string
|
|
624
|
+
/** @see {@link RouteOptions.disableFees} */
|
|
625
|
+
disableFees?: boolean
|
|
626
|
+
allowDestinationCall?: boolean // (default : true) // destination calls are enabled by default
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
export type ContractCallsQuoteRequestToAmount =
|
|
630
|
+
PartialContractCallsQuoteRequest & {
|
|
631
|
+
toAmount: string
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export type ContractCallsQuoteRequestFromAmount =
|
|
635
|
+
PartialContractCallsQuoteRequest & {
|
|
636
|
+
fromAmount: string
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export type ContractCallsQuoteRequest =
|
|
640
|
+
| ContractCallsQuoteRequestFromAmount
|
|
641
|
+
| ContractCallsQuoteRequestToAmount
|
|
642
|
+
export const isContractCallsRequestWithFromAmount = (
|
|
643
|
+
r: ContractCallsQuoteRequestFromAmount | ContractCallsQuoteRequestToAmount
|
|
644
|
+
): r is ContractCallsQuoteRequestFromAmount => 'fromAmount' in r
|
|
645
|
+
|
|
646
|
+
export const isContractCallsRequestWithToAmount = (
|
|
647
|
+
r: ContractCallsQuoteRequestFromAmount | ContractCallsQuoteRequestToAmount
|
|
648
|
+
): r is ContractCallsQuoteRequestToAmount => 'toAmount' in r
|
|
649
|
+
|
|
650
|
+
/* @deprecated */
|
|
651
|
+
export interface ContractCallQuoteRequest extends ToolConfiguration {
|
|
652
|
+
fromChain: number | string
|
|
653
|
+
fromToken: string
|
|
654
|
+
fromAddress: string
|
|
655
|
+
/** @see {@link RouteOptions.refundAddress} */
|
|
656
|
+
refundAddress?: string
|
|
657
|
+
toChain: number | string
|
|
658
|
+
toToken: string
|
|
659
|
+
toAmount: string
|
|
660
|
+
toContractAddress: string
|
|
661
|
+
toContractCallData: string
|
|
662
|
+
toContractGasLimit: string
|
|
663
|
+
toApprovalAddress?: string
|
|
664
|
+
toFallbackAddress?: string
|
|
665
|
+
contractOutputsToken?: string
|
|
666
|
+
slippage?: number | string
|
|
667
|
+
integrator?: string
|
|
668
|
+
referrer?: string
|
|
669
|
+
fee?: number | string
|
|
670
|
+
allowDestinationCall?: boolean
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export interface ConnectionsRequest extends ToolConfiguration {
|
|
674
|
+
fromChain: number | string
|
|
675
|
+
fromToken?: string
|
|
676
|
+
toChain: number | string
|
|
677
|
+
toToken?: string
|
|
678
|
+
allowSwitchChain?: boolean // (default: true) the connections that require chain switch (multiple signatures) are included by default
|
|
679
|
+
allowDestinationCall?: boolean // (default: true) the connections that includes destination calls are included by default
|
|
680
|
+
chainTypes?: ChainType[]
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
export interface Connection {
|
|
684
|
+
fromChainId: number
|
|
685
|
+
toChainId: number
|
|
686
|
+
fromTokens: Token[]
|
|
687
|
+
toTokens: Token[]
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
export type BasicConnection = Omit<Connection, 'fromTokens' | 'toTokens'> & {
|
|
691
|
+
fromTokens: BaseToken[]
|
|
692
|
+
toTokens: BaseToken[]
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
export interface ConnectionsResponse {
|
|
696
|
+
connections: BasicConnection[]
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
export type GetStatusRequest = {
|
|
700
|
+
bridge?: string
|
|
701
|
+
fromChain?: number | string
|
|
702
|
+
toChain?: number | string
|
|
703
|
+
transactionId?: string
|
|
704
|
+
depositAddress?: string
|
|
705
|
+
} & ({ txHash: string } | { taskId: string })
|
|
706
|
+
|
|
707
|
+
export interface BaseTransactionInfo {
|
|
708
|
+
txHash: string
|
|
709
|
+
chainId: ChainId
|
|
710
|
+
txLink: string
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
export interface ExtendedTransactionInfo extends BaseTransactionInfo {
|
|
714
|
+
amount?: string
|
|
715
|
+
amountUSD?: string
|
|
716
|
+
token?: Token
|
|
717
|
+
gasPrice: string
|
|
718
|
+
gasUsed: string
|
|
719
|
+
gasToken: Token
|
|
720
|
+
gasAmount: string
|
|
721
|
+
gasAmountUSD: string
|
|
722
|
+
timestamp?: number
|
|
723
|
+
value?: string
|
|
724
|
+
includedSteps?: IncludedStep[]
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
export interface PendingReceivingInfo {
|
|
728
|
+
chainId: ChainId
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
const _StatusMessage = [
|
|
732
|
+
// The transaction was not found -- likely not mined yet
|
|
733
|
+
'NOT_FOUND',
|
|
734
|
+
// A third party service is not available
|
|
735
|
+
'INVALID',
|
|
736
|
+
// The transfer is pending
|
|
737
|
+
'PENDING',
|
|
738
|
+
// The transfer is done
|
|
739
|
+
'DONE',
|
|
740
|
+
// The transfer failed
|
|
741
|
+
'FAILED',
|
|
742
|
+
] as const
|
|
743
|
+
export type StatusMessage = (typeof _StatusMessage)[number]
|
|
744
|
+
|
|
745
|
+
const _SubstatusPending = [
|
|
746
|
+
// The bridge is waiting for additional confirmations
|
|
747
|
+
'WAIT_SOURCE_CONFIRMATIONS',
|
|
748
|
+
// The off-chain logic is in progress, waiting for the destination tx to be mined
|
|
749
|
+
'WAIT_DESTINATION_TRANSACTION',
|
|
750
|
+
// The bridge API / subgraph is temporarily unavailable
|
|
751
|
+
'BRIDGE_NOT_AVAILABLE',
|
|
752
|
+
// The RPC for source/destination chain is temporarily unavailable
|
|
753
|
+
'CHAIN_NOT_AVAILABLE',
|
|
754
|
+
// A refund has been requested and is in progress
|
|
755
|
+
'REFUND_IN_PROGRESS',
|
|
756
|
+
// We cannot determine the status of the transfer
|
|
757
|
+
'UNKNOWN_ERROR',
|
|
758
|
+
// Intent is waiting for funds to arrive at the smart contract account
|
|
759
|
+
'INTENT_AWAITING_FUNDS',
|
|
760
|
+
// Intent funds detected, preparing execution
|
|
761
|
+
'INTENT_READY',
|
|
762
|
+
// Intent is being executed by solver
|
|
763
|
+
'INTENT_EXECUTING',
|
|
764
|
+
// Intent execution failed, solver retrying
|
|
765
|
+
'INTENT_FAILED_RETRYABLE',
|
|
766
|
+
// Intent simulation failed, solver retrying
|
|
767
|
+
'INTENT_SIMULATION_FAILURE',
|
|
768
|
+
] as const
|
|
769
|
+
export type SubstatusPending = (typeof _SubstatusPending)[number]
|
|
770
|
+
|
|
771
|
+
const _SubstatusDone = [
|
|
772
|
+
// The transfer was successful
|
|
773
|
+
'COMPLETED',
|
|
774
|
+
// The transfer was partially successful
|
|
775
|
+
// This can happen for specific bridges like Across
|
|
776
|
+
// which may provide alternative tokens in case of low liquidity
|
|
777
|
+
'PARTIAL',
|
|
778
|
+
// The transfer was not successful but it has been refunded
|
|
779
|
+
'REFUNDED',
|
|
780
|
+
] as const
|
|
781
|
+
export type SubstatusDone = (typeof _SubstatusDone)[number]
|
|
782
|
+
|
|
783
|
+
const _SubstatusFailed = [
|
|
784
|
+
// The amount in the request exceeds the allowance
|
|
785
|
+
'INSUFFICIENT_ALLOWANCE',
|
|
786
|
+
// The token amount is not enough to execute the transfer
|
|
787
|
+
'INSUFFICIENT_BALANCE',
|
|
788
|
+
// The gas limit is lower than tx would consume
|
|
789
|
+
'OUT_OF_GAS',
|
|
790
|
+
// The requested quote is expired and can’t be processed anymore
|
|
791
|
+
'EXPIRED',
|
|
792
|
+
// Slippage conditions were not met
|
|
793
|
+
'SLIPPAGE_EXCEEDED',
|
|
794
|
+
// We cannot determine the cause of the failure
|
|
795
|
+
'UNKNOWN_FAILED_ERROR',
|
|
796
|
+
// A Smart Deposits refund attempt failed
|
|
797
|
+
'INTENT_REFUND_FAILED',
|
|
798
|
+
] as const
|
|
799
|
+
export type SubstatusFailed = (typeof _SubstatusFailed)[number]
|
|
800
|
+
|
|
801
|
+
export type Substatus = SubstatusPending | SubstatusDone | SubstatusFailed
|
|
802
|
+
|
|
803
|
+
export const isSubstatusPending = (
|
|
804
|
+
substatus: Substatus
|
|
805
|
+
): substatus is SubstatusPending =>
|
|
806
|
+
_SubstatusPending.includes(substatus as SubstatusPending)
|
|
807
|
+
export const isSubstatusDone = (
|
|
808
|
+
substatus: Substatus
|
|
809
|
+
): substatus is SubstatusDone =>
|
|
810
|
+
_SubstatusDone.includes(substatus as SubstatusDone)
|
|
811
|
+
export const isSubstatusFailed = (
|
|
812
|
+
substatus: Substatus
|
|
813
|
+
): substatus is SubstatusFailed =>
|
|
814
|
+
_SubstatusFailed.includes(substatus as SubstatusFailed)
|
|
815
|
+
|
|
816
|
+
export interface BaseStatusData {
|
|
817
|
+
status: StatusMessage
|
|
818
|
+
substatus?: Substatus
|
|
819
|
+
substatusMessage?: string
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export interface StatusData extends BaseStatusData {
|
|
823
|
+
tool: string
|
|
824
|
+
sending: BaseTransactionInfo
|
|
825
|
+
receiving: PendingReceivingInfo
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
export interface FailedStatusData extends BaseStatusData {
|
|
829
|
+
status: 'FAILED'
|
|
830
|
+
sending: BaseTransactionInfo
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
export type StatusResponse = FullStatusData | StatusData | FailedStatusData
|
|
834
|
+
interface TransferMetadata {
|
|
835
|
+
integrator: string
|
|
836
|
+
referrer?: string
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
export type IncludedStep = {
|
|
840
|
+
fromAmount: string
|
|
841
|
+
fromToken: Token
|
|
842
|
+
toAmount: string
|
|
843
|
+
toToken: Token
|
|
844
|
+
bridgedAmount?: string
|
|
845
|
+
tool: string
|
|
846
|
+
toolDetails: StepToolDetails
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
export interface FullStatusData extends StatusData {
|
|
850
|
+
transactionId: string
|
|
851
|
+
sending: ExtendedTransactionInfo
|
|
852
|
+
receiving: PendingReceivingInfo | ExtendedTransactionInfo
|
|
853
|
+
feeCosts: FeeCost[]
|
|
854
|
+
lifiExplorerLink: string
|
|
855
|
+
fromAddress: string
|
|
856
|
+
toAddress: string
|
|
857
|
+
metadata: TransferMetadata
|
|
858
|
+
bridgeExplorerLink?: string
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
export interface ExtendedChain extends Chain {
|
|
862
|
+
nativeToken: Token
|
|
863
|
+
diamondAddress?: string
|
|
864
|
+
permit2?: string
|
|
865
|
+
permit2Proxy?: string
|
|
866
|
+
/**
|
|
867
|
+
* Whether the chain has a non-standard native decimals handling like Tempo or Stable
|
|
868
|
+
* @default false
|
|
869
|
+
*/
|
|
870
|
+
nonStandardNativeDecimals?: boolean
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
export interface ChainsResponse {
|
|
874
|
+
chains: ExtendedChain[]
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
export interface ChainsRequest {
|
|
878
|
+
chainTypes?: ChainType[]
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
export interface ToolsRequest {
|
|
882
|
+
chains?: (ChainKey | ChainId)[]
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export const TokensSortOrders = [
|
|
886
|
+
'marketCapUSD',
|
|
887
|
+
'priceUSD',
|
|
888
|
+
'volumeUSD24H',
|
|
889
|
+
'fdvUSD',
|
|
890
|
+
] as const
|
|
891
|
+
export type TokensSortOrder = (typeof TokensSortOrders)[number]
|
|
892
|
+
|
|
893
|
+
export type TokensRequest = {
|
|
894
|
+
chains?: (ChainId | ChainKey)[]
|
|
895
|
+
chainTypes?: ChainType[]
|
|
896
|
+
minPriceUSD?: number
|
|
897
|
+
orderBy?: TokensSortOrder
|
|
898
|
+
limit?: number
|
|
899
|
+
extended?: boolean
|
|
900
|
+
search?: string
|
|
901
|
+
tags?: TokenTag[]
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
export type TokensResponse = {
|
|
905
|
+
tokens: { [chainId: number]: Token[] }
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
export type TokensExtendedResponse = {
|
|
909
|
+
tokens: { [chainId: number]: TokenExtended[] }
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
export type RequestOptions = {
|
|
913
|
+
signal?: AbortSignal
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
export interface Integrator {
|
|
917
|
+
integratorId: string
|
|
918
|
+
feeBalances: FeeBalance[]
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
export type FeeBalance = {
|
|
922
|
+
chainId: ChainId
|
|
923
|
+
tokenBalances: TokenBalance[]
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
export type TokenBalance = {
|
|
927
|
+
token: Token
|
|
928
|
+
amount: string
|
|
929
|
+
amountUsd: string
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
export interface IntegratorWithdrawalRequest {
|
|
933
|
+
integratorId: string
|
|
934
|
+
chainId: ChainId
|
|
935
|
+
tokens?: string[]
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
export interface IntegratorWithdrawalTransactionResponse {
|
|
939
|
+
transactionRequest: TransactionRequest
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
const _LIFuelState = ['PENDING', 'DONE', 'NOT_FOUND'] as const
|
|
943
|
+
type LIFuelState = (typeof _LIFuelState)[number]
|
|
944
|
+
// Response to the status API for trusted gas
|
|
945
|
+
export type LIFuelStatusResponse = {
|
|
946
|
+
status: LIFuelState
|
|
947
|
+
sending?: ExtendedTransactionInfo
|
|
948
|
+
receiving?: PendingReceivingInfo | ExtendedTransactionInfo
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
export type GasRecommendationRequest = {
|
|
952
|
+
chainId: ChainId
|
|
953
|
+
fromChain?: ChainId
|
|
954
|
+
fromToken?: string
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
export type RefetchSourceLIFuelRequest = {
|
|
958
|
+
txHash: string
|
|
959
|
+
chainId: ChainId
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
export type LIFuelStatusRequest = {
|
|
963
|
+
txHash: string
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
export type RefetchLIFuelRequest = {
|
|
967
|
+
txHash: string
|
|
968
|
+
chainId: ChainId
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
export type GasRecommendationResponse = {
|
|
972
|
+
// whether we can support that
|
|
973
|
+
available: boolean
|
|
974
|
+
// reason why the gas feature is not available (e.g. missing liquidity)
|
|
975
|
+
message?: string
|
|
976
|
+
recommended?: TokenBalance
|
|
977
|
+
limit?: TokenBalance // Maximum of gas the user can transfer
|
|
978
|
+
serviceFee?: TokenBalance // LI.FI fee for providing the service
|
|
979
|
+
|
|
980
|
+
// information about what the user has to pay to get the recommended gas amount
|
|
981
|
+
fromToken?: Token
|
|
982
|
+
fromAmount?: string
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
export interface TransactionAnalyticsResponse {
|
|
986
|
+
transfers: StatusResponse[]
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
export type TransactionAnalyticsStatus =
|
|
990
|
+
| Exclude<StatusMessage, 'NOT_FOUND' | 'INVALID'>
|
|
991
|
+
| 'ALL'
|
|
992
|
+
|
|
993
|
+
export interface TransactionAnalyticsRequest {
|
|
994
|
+
wallet: string
|
|
995
|
+
fromTimestamp?: number
|
|
996
|
+
toTimestamp?: number
|
|
997
|
+
status?: TransactionAnalyticsStatus
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
export interface CreateIntegratorRequest {
|
|
1001
|
+
name: string
|
|
1002
|
+
integratorId: string
|
|
1003
|
+
fee?: number
|
|
1004
|
+
feeType?: IntegratorFeeType
|
|
1005
|
+
defaultWallet?: string
|
|
1006
|
+
chainWallets?: ChainWalletConfiguration
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
export interface UpdateIntegratorRequest {
|
|
1010
|
+
name?: string
|
|
1011
|
+
fee?: number
|
|
1012
|
+
feeType?: IntegratorFeeType
|
|
1013
|
+
defaultWallet?: string
|
|
1014
|
+
chainWallets?: ChainWalletConfiguration
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
export type IntegratorResult = {
|
|
1018
|
+
name: string
|
|
1019
|
+
integratorId: string
|
|
1020
|
+
fee: number
|
|
1021
|
+
feeType: IntegratorFeeType
|
|
1022
|
+
defaultWallet?: string
|
|
1023
|
+
chainWallets?: ChainWalletConfiguration
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
export type ChainWalletConfiguration = {
|
|
1027
|
+
[key in ChainId]?: string
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
export enum IntegratorFeeType {
|
|
1031
|
+
FIXED = 'FIXED',
|
|
1032
|
+
SHARED = 'SHARED',
|
|
1033
|
+
DYNAMIC = 'DYNAMIC',
|
|
1034
|
+
INTERMEDIARY = 'INTERMEDIARY',
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
export type TransferSummary = {
|
|
1038
|
+
id: {
|
|
1039
|
+
toAddress: string
|
|
1040
|
+
sendingChainId?: number
|
|
1041
|
+
}
|
|
1042
|
+
totalReceivedAmount: number
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
export type TransferSummariesResponse = PaginatedResponse<TransferSummary>
|
|
1046
|
+
|
|
1047
|
+
export interface GetStepRequest {
|
|
1048
|
+
stepId: string
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
export interface GetTokenApprovalRequest {
|
|
1052
|
+
tokenContractAddress: string
|
|
1053
|
+
chainId: string
|
|
1054
|
+
userWalletAddress: string
|
|
1055
|
+
requiredAmount: string
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
export interface GetTokenApprovalResponse {
|
|
1059
|
+
isApproved: boolean
|
|
1060
|
+
approvedAmount: string
|
|
1061
|
+
approvalTransaction: {
|
|
1062
|
+
to?: string
|
|
1063
|
+
from?: string
|
|
1064
|
+
nonce?: string
|
|
1065
|
+
gasLimit?: string
|
|
1066
|
+
gasPrice?: string
|
|
1067
|
+
data?: string
|
|
1068
|
+
value?: string
|
|
1069
|
+
chainId?: number
|
|
1070
|
+
type?: number
|
|
1071
|
+
accessList?: { address: string; storageKeys: string[] }[]
|
|
1072
|
+
maxPriorityFeePerGas?: string
|
|
1073
|
+
maxFeePerGas?: string
|
|
1074
|
+
customData?: string
|
|
1075
|
+
ccipReadEnabled?: boolean
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
export type PermitBase<T extends bigint | string> = {
|
|
1080
|
+
spender: Address
|
|
1081
|
+
nonce: T
|
|
1082
|
+
deadline: T
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
export type PermitMessage<T extends bigint | string> = PermitBase<T> & {
|
|
1086
|
+
owner: Address
|
|
1087
|
+
value: T
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
export type TokenPermissions<T extends bigint | string> = {
|
|
1091
|
+
token: Address
|
|
1092
|
+
amount: T
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
export type PermitWitnessTransferFromMessage<T extends bigint | string> =
|
|
1096
|
+
PermitBase<T> & {
|
|
1097
|
+
permitted: TokenPermissions<T>
|
|
1098
|
+
}
|
|
1099
|
+
export const TypedDataPrimaryTypes = [
|
|
1100
|
+
'Permit',
|
|
1101
|
+
'PermitTransferFrom',
|
|
1102
|
+
'PermitBatchTransferFrom',
|
|
1103
|
+
'PermitWitnessTransferFrom',
|
|
1104
|
+
'PermitBatchWitnessTransferFrom',
|
|
1105
|
+
'Order',
|
|
1106
|
+
'HyperliquidTransaction:UsdSend',
|
|
1107
|
+
'HyperliquidTransaction:SpotSend',
|
|
1108
|
+
'HyperliquidTransaction:SendAsset',
|
|
1109
|
+
'HyperliquidTransaction:Withdraw',
|
|
1110
|
+
'HyperliquidTransaction:ApproveAgent',
|
|
1111
|
+
'Agent',
|
|
1112
|
+
'NonceMapping',
|
|
1113
|
+
'HyperliquidTransaction:ApproveBuilderFee',
|
|
1114
|
+
'PermitSingle',
|
|
1115
|
+
] as const
|
|
1116
|
+
export type TypedDataPrimaryType = (typeof TypedDataPrimaryTypes)[number]
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* EIP-712 Typed Data
|
|
1120
|
+
* @link https://eips.ethereum.org/EIPS/eip-712
|
|
1121
|
+
*/
|
|
1122
|
+
export type TypedData = {
|
|
1123
|
+
primaryType: TypedDataPrimaryType
|
|
1124
|
+
domain: TypedDataDomain
|
|
1125
|
+
types: Record<string, readonly TypedDataParameter[]>
|
|
1126
|
+
// oxlint-disable-next-line typescript/no-explicit-any -- public API type; narrowing it is a breaking change
|
|
1127
|
+
message: Record<string, any>
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* EIP-712 Typed Data with signature
|
|
1132
|
+
*/
|
|
1133
|
+
export interface SignedTypedData extends TypedData {
|
|
1134
|
+
signature: Hex
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
export type RelayerErrorResponse = {
|
|
1138
|
+
status: 'error'
|
|
1139
|
+
data: {
|
|
1140
|
+
code: number
|
|
1141
|
+
message: string
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
export type RelayerResponse<T> =
|
|
1146
|
+
| { status: 'ok'; data: T }
|
|
1147
|
+
| RelayerErrorResponse
|
|
1148
|
+
|
|
1149
|
+
export type RelayerQuoteResponse = RelayerResponse<LiFiStep>
|
|
1150
|
+
|
|
1151
|
+
export type RelayRequest = SignedLiFiStep
|
|
1152
|
+
|
|
1153
|
+
export type RelayResponseData = {
|
|
1154
|
+
taskId: string
|
|
1155
|
+
txLink?: string
|
|
1156
|
+
}
|
|
1157
|
+
export type RelayResponse = RelayerResponse<RelayResponseData>
|
|
1158
|
+
|
|
1159
|
+
export type RelayStatusRequest = {
|
|
1160
|
+
taskId: Hash
|
|
1161
|
+
bridge?: string
|
|
1162
|
+
fromChain?: number
|
|
1163
|
+
toChain?: number
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
export type RelayStatusResponseData = {
|
|
1167
|
+
status: 'DONE' | 'PENDING' | 'FAILED'
|
|
1168
|
+
message?: string
|
|
1169
|
+
metadata: { chainId: number; txHash?: Hash }
|
|
1170
|
+
transactionStatus?: StatusResponse
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
export type RelayStatusResponse = RelayerResponse<RelayStatusResponseData>
|
|
1174
|
+
|
|
1175
|
+
export type PatchCallDataRequest = {
|
|
1176
|
+
chainId: ChainId
|
|
1177
|
+
fromTokenAddress: string
|
|
1178
|
+
targetContractAddress: string
|
|
1179
|
+
callDataToPatch: string
|
|
1180
|
+
patches: {
|
|
1181
|
+
amountToReplace: string
|
|
1182
|
+
}[]
|
|
1183
|
+
value?: string
|
|
1184
|
+
delegateCall?: boolean
|
|
1185
|
+
}[]
|