@lifi/types 10.0.0 → 11.0.0-alpha.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.
Files changed (161) hide show
  1. package/README.md +27 -5
  2. package/package.json +22 -74
  3. package/{dist/cjs → src/_cjs}/api.js +1 -17
  4. package/src/_cjs/api.js.map +1 -0
  5. package/src/_cjs/bridges.js +3 -0
  6. package/src/_cjs/bridges.js.map +1 -0
  7. package/{dist/cjs → src/_cjs}/chains/Chain.js +3 -2
  8. package/src/_cjs/chains/Chain.js.map +1 -0
  9. package/src/_cjs/chains/EVMChain.js +3 -0
  10. package/src/_cjs/chains/EVMChain.js.map +1 -0
  11. package/src/_cjs/chains/SolanaChain.js +3 -0
  12. package/src/_cjs/chains/SolanaChain.js.map +1 -0
  13. package/src/_cjs/chains/UTXOChain.js +3 -0
  14. package/src/_cjs/chains/UTXOChain.js.map +1 -0
  15. package/{dist/cjs → src/_cjs/chains}/base.js +21 -77
  16. package/src/_cjs/chains/base.js.map +1 -0
  17. package/src/_cjs/chains/index.js +9 -0
  18. package/src/_cjs/chains/index.js.map +1 -0
  19. package/{dist/cjs/apiErrors.js → src/_cjs/errors.js} +2 -2
  20. package/src/_cjs/errors.js.map +1 -0
  21. package/src/_cjs/exchanges.js +3 -0
  22. package/src/_cjs/exchanges.js.map +1 -0
  23. package/src/_cjs/index.js +12 -0
  24. package/src/_cjs/index.js.map +1 -0
  25. package/src/_cjs/package.json +1 -0
  26. package/{dist/cjs → src/_cjs}/quests.js +1 -0
  27. package/src/_cjs/quests.js.map +1 -0
  28. package/{dist/cjs → src/_cjs}/step.js +1 -1
  29. package/src/_cjs/step.js.map +1 -0
  30. package/src/_cjs/tokens/base.js +68 -0
  31. package/src/_cjs/tokens/base.js.map +1 -0
  32. package/src/_cjs/tokens/index.js +6 -0
  33. package/src/_cjs/tokens/index.js.map +1 -0
  34. package/{dist/cjs/chains/SolanaChain.js → src/_cjs/tokens/token.js} +1 -0
  35. package/src/_cjs/tokens/token.js.map +1 -0
  36. package/{dist → src/_esm}/api.js +1 -0
  37. package/src/_esm/api.js.map +1 -0
  38. package/src/_esm/bridges.js +2 -0
  39. package/src/_esm/bridges.js.map +1 -0
  40. package/src/_esm/chains/Chain.js +11 -0
  41. package/src/_esm/chains/Chain.js.map +1 -0
  42. package/src/_esm/chains/EVMChain.js +2 -0
  43. package/src/_esm/chains/EVMChain.js.map +1 -0
  44. package/src/_esm/chains/SolanaChain.js +2 -0
  45. package/src/_esm/chains/SolanaChain.js.map +1 -0
  46. package/src/_esm/chains/UTXOChain.js +2 -0
  47. package/src/_esm/chains/UTXOChain.js.map +1 -0
  48. package/{dist → src/_esm/chains}/base.js +24 -72
  49. package/src/_esm/chains/base.js.map +1 -0
  50. package/src/_esm/chains/index.js +6 -0
  51. package/src/_esm/chains/index.js.map +1 -0
  52. package/{dist/apiErrors.js → src/_esm/errors.js} +1 -0
  53. package/src/_esm/errors.js.map +1 -0
  54. package/src/_esm/exchanges.js +2 -0
  55. package/src/_esm/exchanges.js.map +1 -0
  56. package/src/_esm/index.js +9 -0
  57. package/src/_esm/index.js.map +1 -0
  58. package/src/_esm/package.json +1 -0
  59. package/src/_esm/quests.js +2 -0
  60. package/src/_esm/quests.js.map +1 -0
  61. package/{dist → src/_esm}/step.js +1 -0
  62. package/src/_esm/step.js.map +1 -0
  63. package/src/_esm/tokens/base.js +71 -0
  64. package/src/_esm/tokens/base.js.map +1 -0
  65. package/src/_esm/tokens/index.js +3 -0
  66. package/src/_esm/tokens/index.js.map +1 -0
  67. package/src/_esm/tokens/token.js +3 -0
  68. package/src/_esm/tokens/token.js.map +1 -0
  69. package/{dist → src/_types}/api.d.ts +53 -19
  70. package/src/_types/api.d.ts.map +1 -0
  71. package/src/_types/bridges.d.ts +29 -0
  72. package/src/_types/bridges.d.ts.map +1 -0
  73. package/{dist → src/_types}/chains/Chain.d.ts +5 -2
  74. package/src/_types/chains/Chain.d.ts.map +1 -0
  75. package/{dist/cjs → src/_types}/chains/EVMChain.d.ts +2 -2
  76. package/src/_types/chains/EVMChain.d.ts.map +1 -0
  77. package/{dist/cjs → src/_types}/chains/SolanaChain.d.ts +3 -2
  78. package/src/_types/chains/SolanaChain.d.ts.map +1 -0
  79. package/src/_types/chains/UTXOChain.d.ts +6 -0
  80. package/src/_types/chains/UTXOChain.d.ts.map +1 -0
  81. package/src/_types/chains/base.d.ts +133 -0
  82. package/src/_types/chains/base.d.ts.map +1 -0
  83. package/src/_types/chains/index.d.ts +6 -0
  84. package/src/_types/chains/index.d.ts.map +1 -0
  85. package/{dist/apiErrors.d.ts → src/_types/errors.d.ts} +1 -9
  86. package/src/_types/errors.d.ts.map +1 -0
  87. package/src/_types/exchanges.d.ts +25 -0
  88. package/src/_types/exchanges.d.ts.map +1 -0
  89. package/src/_types/index.d.ts +9 -0
  90. package/src/_types/index.d.ts.map +1 -0
  91. package/{dist/cjs → src/_types}/quests.d.ts +1 -0
  92. package/src/_types/quests.d.ts.map +1 -0
  93. package/{dist → src/_types}/step.d.ts +13 -14
  94. package/src/_types/step.d.ts.map +1 -0
  95. package/src/_types/tokens/base.d.ts +64 -0
  96. package/src/_types/tokens/base.d.ts.map +1 -0
  97. package/src/_types/tokens/index.d.ts +3 -0
  98. package/src/_types/tokens/index.d.ts.map +1 -0
  99. package/src/_types/tokens/token.d.ts +30 -0
  100. package/src/_types/tokens/token.d.ts.map +1 -0
  101. package/src/api.ts +515 -0
  102. package/src/bridges.ts +30 -0
  103. package/src/chains/Chain.ts +22 -0
  104. package/src/chains/EVMChain.ts +25 -0
  105. package/src/chains/SolanaChain.ts +8 -0
  106. package/src/chains/UTXOChain.ts +6 -0
  107. package/src/chains/base.ts +148 -0
  108. package/src/chains/index.ts +5 -0
  109. package/src/errors.ts +15 -0
  110. package/src/exchanges.ts +27 -0
  111. package/src/index.ts +8 -0
  112. package/{dist/quests.d.ts → src/quests.ts} +21 -15
  113. package/src/step.ts +192 -0
  114. package/src/tokens/base.ts +75 -0
  115. package/src/tokens/index.ts +2 -0
  116. package/src/tokens/token.ts +34 -0
  117. package/dist/base.d.ts +0 -231
  118. package/dist/bridges.d.ts +0 -34
  119. package/dist/bridges.js +0 -167
  120. package/dist/chains/Chain.js +0 -6
  121. package/dist/chains/EVMChain.d.ts +0 -19
  122. package/dist/chains/EVMChain.js +0 -4
  123. package/dist/chains/SolanaChain.d.ts +0 -7
  124. package/dist/chains/SolanaChain.js +0 -1
  125. package/dist/chains/chain.utils.d.ts +0 -4
  126. package/dist/chains/chain.utils.js +0 -21
  127. package/dist/chains/index.d.ts +0 -5
  128. package/dist/chains/index.js +0 -5
  129. package/dist/chains/supported.chains.d.ts +0 -5
  130. package/dist/chains/supported.chains.js +0 -1208
  131. package/dist/cjs/api.d.ts +0 -355
  132. package/dist/cjs/apiErrors.d.ts +0 -23
  133. package/dist/cjs/base.d.ts +0 -231
  134. package/dist/cjs/bridges.d.ts +0 -34
  135. package/dist/cjs/bridges.js +0 -170
  136. package/dist/cjs/chains/Chain.d.ts +0 -15
  137. package/dist/cjs/chains/EVMChain.js +0 -8
  138. package/dist/cjs/chains/chain.utils.d.ts +0 -4
  139. package/dist/cjs/chains/chain.utils.js +0 -26
  140. package/dist/cjs/chains/index.d.ts +0 -5
  141. package/dist/cjs/chains/index.js +0 -21
  142. package/dist/cjs/chains/supported.chains.d.ts +0 -5
  143. package/dist/cjs/chains/supported.chains.js +0 -1211
  144. package/dist/cjs/coins.d.ts +0 -9
  145. package/dist/cjs/coins.js +0 -1898
  146. package/dist/cjs/exchanges.d.ts +0 -50
  147. package/dist/cjs/exchanges.js +0 -1104
  148. package/dist/cjs/index.d.ts +0 -10
  149. package/dist/cjs/index.js +0 -26
  150. package/dist/cjs/multicall.d.ts +0 -3
  151. package/dist/cjs/multicall.js +0 -80
  152. package/dist/cjs/step.d.ts +0 -129
  153. package/dist/coins.d.ts +0 -9
  154. package/dist/coins.js +0 -1891
  155. package/dist/exchanges.d.ts +0 -50
  156. package/dist/exchanges.js +0 -1100
  157. package/dist/index.d.ts +0 -10
  158. package/dist/index.js +0 -10
  159. package/dist/multicall.d.ts +0 -3
  160. package/dist/multicall.js +0 -77
  161. package/dist/quests.js +0 -1
package/src/api.ts ADDED
@@ -0,0 +1,515 @@
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 { Action, LiFiStep } from './step.js'
5
+ import type { Token } from './tokens/index.js'
6
+
7
+ /**
8
+ * Used as a bigint replacement for TransactionRequest because bigint is not serializable
9
+ */
10
+ export type BigIntish = string
11
+
12
+ export type TransactionRequest = {
13
+ to?: string
14
+ from?: string
15
+ nonce?: number
16
+
17
+ gasLimit?: BigIntish
18
+ gasPrice?: BigIntish
19
+
20
+ data?: string
21
+ value?: BigIntish
22
+ chainId?: number
23
+
24
+ type?: number
25
+ accessList?: { address: string; storageKeys: string[] }[]
26
+
27
+ maxPriorityFeePerGas?: BigIntish
28
+ maxFeePerGas?: BigIntish
29
+
30
+ customData?: Record<string, any>
31
+ ccipReadEnabled?: boolean
32
+ }
33
+
34
+ export const Orders = ['RECOMMENDED', 'FASTEST', 'CHEAPEST', 'SAFEST'] as const
35
+ export type Order = (typeof Orders)[number]
36
+
37
+ export interface RoutesRequest {
38
+ fromChainId: number
39
+ fromAmount: string
40
+
41
+ fromTokenAddress: string
42
+ fromAddress?: string
43
+
44
+ toChainId: number
45
+ toTokenAddress: string
46
+ toAddress?: string
47
+
48
+ options?: RouteOptions
49
+ fromAmountForGas?: string
50
+ }
51
+
52
+ export interface RouteOptions {
53
+ integrator?: string // Should contain the identifier of the integrator. Usually, it's dApp/company name.
54
+ fee?: number // 0.03 = take 3% integrator fee (requires verified integrator to be set)
55
+ insurance?: boolean // Whether the user wants to insure their tx
56
+ maxPriceImpact?: number // Hide routes with price impact greater than or equal to this value
57
+ order?: Order // (default: RECOMMENDED) 'RECOMMENDED' | 'FASTEST' | 'CHEAPEST' | 'SAFEST'
58
+ slippage?: number // (default: 0.03) Expressed as decimal proportion, 0.03 represents 3%
59
+ referrer?: string // Integrators can set a wallet address as a referrer to track them
60
+ allowSwitchChain?: boolean // (default: false) Whether chain switches should be allowed in the routes
61
+ allowDestinationCall?: boolean // (default: true) destination calls are enabled by default
62
+ bridges?: AllowDenyPrefer
63
+ exchanges?: AllowDenyPrefer
64
+ }
65
+
66
+ export type ToolsResponse = {
67
+ exchanges: {
68
+ key: string
69
+ name: string
70
+ logoURI: string
71
+ supportedChains: ChainId[]
72
+ }[]
73
+ bridges: {
74
+ key: string
75
+ name: string
76
+ logoURI: string
77
+ supportedChains: {
78
+ fromChainId: ChainId
79
+ toChainId: ChainId
80
+ }[]
81
+ }[]
82
+ }
83
+
84
+ export interface AllowDenyPrefer {
85
+ allow?: string[] // (default: [all])
86
+ deny?: string[] // (default: [])
87
+ prefer?: string[] // (default: []) // eg. ['1inch'] to use 1inch if available and fall back to others if not
88
+ }
89
+
90
+ export const _InsuranceState = [
91
+ 'INSURED',
92
+ 'INSURABLE',
93
+ 'NOT_INSURABLE',
94
+ ] as const
95
+ export type InsuranceState = (typeof _InsuranceState)[number]
96
+
97
+ export interface Insurance {
98
+ state: InsuranceState
99
+ feeAmountUsd: string
100
+ }
101
+ export interface Route {
102
+ id: string
103
+ insurance: Insurance
104
+ fromChainId: number
105
+ fromAmountUSD: string
106
+ fromAmount: string
107
+ fromToken: Token
108
+ fromAddress?: string
109
+
110
+ toChainId: number
111
+ toAmountUSD: string
112
+ toAmount: string
113
+ toAmountMin: string
114
+ toToken: Token
115
+ toAddress?: string
116
+
117
+ gasCostUSD?: string // Aggregation of underlying gas costs in usd
118
+
119
+ containsSwitchChain?: boolean // Features required for route execution
120
+
121
+ steps: LiFiStep[]
122
+
123
+ tags?: Order[]
124
+ }
125
+
126
+ export type ToolErrorType = 'NO_QUOTE'
127
+
128
+ export interface ToolError {
129
+ errorType: ToolErrorType
130
+ code: string
131
+ action: Action
132
+ tool: string
133
+ message: string
134
+ }
135
+
136
+ export type ErroredPaths = { [subpath: string]: ToolError[] }
137
+
138
+ export type ErroredRoute = {
139
+ overallPath: string
140
+ subpaths: ErroredPaths
141
+ }
142
+
143
+ export type FilteredResult = {
144
+ overallPath: string
145
+ reason: string
146
+ }
147
+
148
+ export type UnavailableRoutes = {
149
+ filteredOut: FilteredResult[]
150
+ failed: ErroredRoute[]
151
+ }
152
+
153
+ export interface RoutesResponse {
154
+ routes: Route[]
155
+ unavailableRoutes: UnavailableRoutes
156
+ }
157
+
158
+ export type PossibilityTopic = 'chains' | 'tokens' | 'bridges' | 'exchanges'
159
+
160
+ /**
161
+ * We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
162
+ * @deprecated
163
+ */
164
+ export interface PossibilitiesRequest {
165
+ chains?: number[] // (default: [all]) // eg. [1, 56, 100]
166
+ bridges?: AllowDenyPrefer
167
+ exchanges?: AllowDenyPrefer
168
+ include?: PossibilityTopic[]
169
+ }
170
+
171
+ /**
172
+ * Should not be accessed via the types package anymore
173
+ * @deprecated
174
+ */
175
+ export interface PossibilitiesResponse {
176
+ chains?: Chain[]
177
+ tokens?: Token[]
178
+ bridges?: BridgeDefinition[]
179
+ exchanges?: ExchangeDefinition[]
180
+ }
181
+
182
+ export interface GetTokenRequest {
183
+ chain: number | string
184
+ token: string
185
+ }
186
+
187
+ export interface ToolConfiguration {
188
+ allowBridges?: string[]
189
+ denyBridges?: string[]
190
+ preferBridges?: string[]
191
+ allowExchanges?: string[]
192
+ denyExchanges?: string[]
193
+ preferExchanges?: string[]
194
+ }
195
+
196
+ export interface QuoteRequest extends ToolConfiguration {
197
+ fromChain: number | string
198
+ fromToken: string
199
+ fromAddress: string
200
+ fromAmount: string
201
+
202
+ toChain: number | string
203
+ toToken: string
204
+ toAddress?: string
205
+
206
+ order?: Order
207
+ slippage?: number | string
208
+ integrator?: string
209
+ referrer?: string
210
+ fee?: number | string
211
+ insurance?: boolean // indicates whether the user wants a quote with bridge insurance
212
+ allowDestinationCall?: boolean // (default : true) // destination calls are enabled by default
213
+ fromAmountForGas?: string // the amount of token to convert to gas
214
+ maxPriceImpact?: number // hide routes with price impact greater than or equal to this value
215
+ }
216
+
217
+ export interface ContractCall {
218
+ fromAmount: string
219
+ fromTokenAddress: string
220
+ toContractAddress: string
221
+ toContractCallData: string
222
+ toContractGasLimit: string
223
+ toApprovalAddress?: string
224
+ toTokenAddress?: string
225
+ }
226
+
227
+ export interface ContractCallsQuoteRequest extends ToolConfiguration {
228
+ fromChain: number | string
229
+ fromToken: string
230
+ fromAddress: string
231
+
232
+ toChain: number | string
233
+ toToken: string
234
+ toAmount: string
235
+
236
+ toFallbackAddress?: string
237
+ contractOutputsToken?: string
238
+ contractCalls: ContractCall[]
239
+
240
+ slippage?: number | string
241
+ integrator?: string
242
+ referrer?: string
243
+ fee?: number | string
244
+ allowDestinationCall?: boolean // (default : true) // destination calls are enabled by default
245
+ }
246
+
247
+ /* @deprecated */
248
+ export interface ContractCallQuoteRequest extends ToolConfiguration {
249
+ fromChain: number | string
250
+ fromToken: string
251
+ fromAddress: string
252
+ toChain: number | string
253
+ toToken: string
254
+ toAmount: string
255
+ toContractAddress: string
256
+ toContractCallData: string
257
+ toContractGasLimit: string
258
+ toApprovalAddress?: string
259
+ toFallbackAddress?: string
260
+ contractOutputsToken?: string
261
+ slippage?: number | string
262
+ integrator?: string
263
+ referrer?: string
264
+ fee?: number | string
265
+ allowDestinationCall?: boolean
266
+ }
267
+
268
+ export interface ConnectionsRequest extends ToolConfiguration {
269
+ fromChain?: number | string
270
+ fromToken?: string
271
+ toChain?: number | string
272
+ toToken?: string
273
+ chainTypes?: ChainType[]
274
+ }
275
+
276
+ export interface Connection {
277
+ fromChainId: number
278
+ toChainId: number
279
+ fromTokens: Token[]
280
+ toTokens: Token[]
281
+ }
282
+
283
+ export interface ConnectionsResponse {
284
+ connections: Connection[]
285
+ }
286
+
287
+ export interface GetStatusRequest {
288
+ txHash: string
289
+ bridge?: string
290
+ fromChain?: number | string
291
+ toChain?: number | string
292
+ }
293
+
294
+ export interface BaseTransactionInfo {
295
+ txHash: string
296
+ chainId: ChainId
297
+ txLink: string
298
+ }
299
+
300
+ export interface ExtendedTransactionInfo extends BaseTransactionInfo {
301
+ amount?: string
302
+ amountUSD?: string
303
+ token?: Token
304
+ gasPrice: string
305
+ gasUsed: string
306
+ gasToken: Token
307
+ gasAmount: string
308
+ gasAmountUSD: string
309
+ timestamp?: number
310
+ value?: string
311
+ }
312
+
313
+ export interface PendingReceivingInfo {
314
+ chainId: ChainId
315
+ }
316
+
317
+ const _StatusMessage = [
318
+ // The transaction was not found -- likely not mined yet
319
+ 'NOT_FOUND',
320
+ // A third party service is not available
321
+ 'INVALID',
322
+ // The transfer is pending
323
+ 'PENDING',
324
+ // The transfer is done
325
+ 'DONE',
326
+ // The transfer failed
327
+ 'FAILED',
328
+ ] as const
329
+ export type StatusMessage = (typeof _StatusMessage)[number]
330
+
331
+ const _SubstatusPending = [
332
+ // The bridge is waiting for additional confirmations
333
+ 'WAIT_SOURCE_CONFIRMATIONS',
334
+ // The off-chain logic is in progress, waiting for the destination tx to be mined
335
+ 'WAIT_DESTINATION_TRANSACTION',
336
+ // The bridge API / subgraph is temporarily unavailable
337
+ 'BRIDGE_NOT_AVAILABLE',
338
+ // The RPC for source/destination chain is temporarily unavailable
339
+ 'CHAIN_NOT_AVAILABLE',
340
+ // The transfer cannot be completed, a refund is required
341
+ 'NOT_PROCESSABLE_REFUND_NEEDED',
342
+ // A refund has been requested and is in progress
343
+ 'REFUND_IN_PROGRESS',
344
+ // We cannot determine the status of the transfer
345
+ 'UNKNOWN_ERROR',
346
+ ] as const
347
+ export type SubstatusPending = (typeof _SubstatusPending)[number]
348
+
349
+ const _SubstatusDone = [
350
+ // The transfer was successful
351
+ 'COMPLETED',
352
+ // The transfer was partially successful
353
+ // This can happen for specific bridges like Across
354
+ // which may provide alternative tokens in case of low liquidity
355
+ 'PARTIAL',
356
+ // The transfer was not successful but it has been refunded
357
+ 'REFUNDED',
358
+ ] as const
359
+ export type SubstatusDone = (typeof _SubstatusDone)[number]
360
+
361
+ export type Substatus = SubstatusPending | SubstatusDone
362
+
363
+ export const isSubstatusPending = (
364
+ substatus: Substatus
365
+ ): substatus is SubstatusPending =>
366
+ _SubstatusPending.includes(substatus as SubstatusPending)
367
+ export const isSubstatusDone = (
368
+ substatus: Substatus
369
+ ): substatus is SubstatusDone =>
370
+ _SubstatusDone.includes(substatus as SubstatusDone)
371
+
372
+ export interface BaseStatusData {
373
+ status: StatusMessage
374
+ substatus?: Substatus
375
+ substatusMessage?: string
376
+ }
377
+
378
+ export interface StatusData extends BaseStatusData {
379
+ tool: string
380
+ sending: BaseTransactionInfo
381
+ receiving: PendingReceivingInfo
382
+ }
383
+
384
+ export type StatusResponse = FullStatusData | StatusData
385
+ interface TransferMetadata {
386
+ integrator: string
387
+ }
388
+
389
+ export interface FullStatusData extends StatusData {
390
+ transactionId: string
391
+ sending: ExtendedTransactionInfo
392
+ receiving: PendingReceivingInfo | ExtendedTransactionInfo
393
+ lifiExplorerLink: string
394
+ fromAddress: string
395
+ toAddress: string
396
+ metadata: TransferMetadata
397
+ bridgeExplorerLink?: string
398
+ }
399
+
400
+ export interface ExtendedChain extends Chain {
401
+ nativeToken: Token
402
+ }
403
+
404
+ export interface ChainsResponse {
405
+ chains: ExtendedChain[]
406
+ }
407
+
408
+ export interface ChainsRequest {
409
+ chainTypes?: ChainType[]
410
+ }
411
+
412
+ export interface ToolsRequest {
413
+ chains?: (ChainKey | ChainId)[]
414
+ }
415
+
416
+ export type TokensRequest = {
417
+ chains?: (ChainId | ChainKey)[]
418
+ chainTypes?: ChainType[]
419
+ }
420
+
421
+ export type TokensResponse = {
422
+ tokens: { [chainId: number]: Token[] }
423
+ }
424
+
425
+ export type RequestOptions = {
426
+ signal?: AbortSignal
427
+ }
428
+
429
+ export interface Integrator {
430
+ integratorId: string
431
+ feeBalances: FeeBalance[]
432
+ }
433
+
434
+ export type FeeBalance = {
435
+ chainId: ChainId
436
+ tokenBalances: TokenBalance[]
437
+ }
438
+
439
+ export type TokenBalance = {
440
+ token: Token
441
+ amount: string
442
+ amountUsd: string
443
+ }
444
+
445
+ export interface IntegratorWithdrawalRequest {
446
+ integratorId: string
447
+ chainId: ChainId
448
+ tokens?: string[]
449
+ }
450
+
451
+ export interface IntegratorWithdrawalTransactionResponse {
452
+ transactionRequest: TransactionRequest
453
+ }
454
+
455
+ const _LIFuelState = ['PENDING', 'DONE', 'NOT_FOUND'] as const
456
+ type LIFuelState = (typeof _LIFuelState)[number]
457
+ // Response to the status API for trusted gas
458
+ export type LIFuelStatusResponse = {
459
+ status: LIFuelState
460
+ sending?: ExtendedTransactionInfo
461
+ receiving?: PendingReceivingInfo | ExtendedTransactionInfo
462
+ }
463
+
464
+ export type GasRecommendationRequest = {
465
+ chainId: ChainId
466
+ fromChain?: ChainId
467
+ fromToken?: string
468
+ }
469
+
470
+ export type RefetchSourceLIFuelRequest = {
471
+ txHash: string
472
+ chainId: ChainId
473
+ }
474
+
475
+ export type LIFuelStatusRequest = {
476
+ txHash: string
477
+ }
478
+
479
+ export type RefetchLIFuelRequest = {
480
+ txHash: string
481
+ chainId: ChainId
482
+ }
483
+
484
+ export type GasRecommendationResponse =
485
+ | {
486
+ // whether we can support that
487
+ available: false
488
+ // reason why the gas feature is not available (e.g. missing liquidity)
489
+ message: string
490
+ }
491
+ | {
492
+ available: true
493
+ recommended: TokenBalance
494
+ limit: TokenBalance // Maximum of gas the user can transfer
495
+ serviceFee: TokenBalance // LI.FI fee for providing the service
496
+
497
+ // information about what the user has to pay to get the recommended gas amount
498
+ fromToken?: Token
499
+ fromAmount?: string
500
+ }
501
+
502
+ export interface TransactionAnalyticsResponse {
503
+ transfers: StatusResponse[]
504
+ }
505
+
506
+ export type TransactionAnalyticsStatus =
507
+ | Exclude<StatusMessage, 'NOT_FOUND' | 'INVALID'>
508
+ | 'ALL'
509
+
510
+ export interface TransactionAnalyticsRequest {
511
+ wallet: string
512
+ fromTimestamp?: number
513
+ toTimestamp?: number
514
+ status?: TransactionAnalyticsStatus
515
+ }
package/src/bridges.ts ADDED
@@ -0,0 +1,30 @@
1
+ import type { BaseToken } from './tokens/token.js'
2
+
3
+ export interface Bridge {
4
+ key: string
5
+ name: string
6
+ logoURI: string
7
+ bridgeUrl?: string
8
+ discordUrl?: string
9
+ supportUrl?: string
10
+ docsUrl?: string
11
+ explorerUrl?: string
12
+ analyticsUrl?: string
13
+ }
14
+
15
+ /**
16
+ * Should not be accessed via the types package anymore
17
+ * @deprecated
18
+ */
19
+ export interface BridgeDefinition {
20
+ tool: string
21
+ fromChainId: number
22
+ fromToken: BaseToken
23
+ toChainId: number
24
+ toToken: BaseToken
25
+ maximumTransfer: string
26
+ minimumTransfer: string
27
+ swapFeeRate: string
28
+ swapFeeMinimum: string
29
+ swapFeeMaximum: string
30
+ }
@@ -0,0 +1,22 @@
1
+ import { CoinKey } from '../tokens/base.js'
2
+ import { ChainKey } from './base.js'
3
+
4
+ export enum ChainType {
5
+ EVM = 'EVM',
6
+ // Solana virtual machine
7
+ SVM = 'SVM',
8
+ // Bitcoin based chains
9
+ UTXO = 'UTXO',
10
+ }
11
+
12
+ export interface _Chain {
13
+ key: ChainKey
14
+ chainType: ChainType
15
+ name: string
16
+ coin: CoinKey
17
+ id: number
18
+ mainnet: boolean
19
+ logoURI?: string
20
+ // faucetUrls is DEPRECATED - will be removed in the next breaking release
21
+ faucetUrls?: string[]
22
+ }
@@ -0,0 +1,25 @@
1
+ import type { _Chain } from './Chain.js'
2
+
3
+ export interface EVMChain extends _Chain {
4
+ // tokenlistUrl is DEPRECATED - will be removed in the next breaking release
5
+ tokenlistUrl?: string
6
+ metamask: AddEthereumChainParameter
7
+ multicallAddress?: string
8
+ }
9
+
10
+ export interface AddEthereumChainParameter {
11
+ chainId: string
12
+ blockExplorerUrls: string[]
13
+ chainName: string
14
+ nativeCurrency: {
15
+ name: string
16
+ symbol: string
17
+ decimals: number
18
+ }
19
+ rpcUrls: string[]
20
+ }
21
+
22
+ // This type alias is required to avoid breaking
23
+ // changes with the new non EVM support types release
24
+ // This will be removed in the future in favour of _Chain
25
+ export type Chain = EVMChain
@@ -0,0 +1,8 @@
1
+ import type { _Chain } from './Chain.js'
2
+ import type { AddEthereumChainParameter } from './EVMChain.js'
3
+
4
+ export interface SolanaChain extends _Chain {
5
+ tokenlistUrl?: string
6
+ metamask: AddEthereumChainParameter
7
+ multicallAddress?: string
8
+ }
@@ -0,0 +1,6 @@
1
+ import type { _Chain } from './Chain.js'
2
+ import type { AddEthereumChainParameter } from './EVMChain.js'
3
+
4
+ export interface UTXOChain extends _Chain {
5
+ metamask: AddEthereumChainParameter
6
+ }