@stableflow/core 0.0.0-experimental-5a8afd7389-20260703
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 +21 -0
- package/README.md +78 -0
- package/dist/index.d.mts +854 -0
- package/dist/index.d.ts +854 -0
- package/dist/index.js +1996 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1956 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +39 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
|
|
3
|
+
type ApiRequestOptions = {
|
|
4
|
+
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
5
|
+
readonly url: string;
|
|
6
|
+
readonly path?: Record<string, any>;
|
|
7
|
+
readonly cookies?: Record<string, any>;
|
|
8
|
+
readonly headers?: Record<string, any>;
|
|
9
|
+
readonly query?: Record<string, any>;
|
|
10
|
+
readonly formData?: Record<string, any>;
|
|
11
|
+
readonly body?: any;
|
|
12
|
+
readonly mediaType?: string;
|
|
13
|
+
readonly responseHeader?: string;
|
|
14
|
+
readonly errors?: Record<number, string>;
|
|
15
|
+
readonly timeout?: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type ApiResult = {
|
|
19
|
+
readonly url: string;
|
|
20
|
+
readonly ok: boolean;
|
|
21
|
+
readonly status: number;
|
|
22
|
+
readonly statusText: string;
|
|
23
|
+
readonly body: any;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
declare class ApiError extends Error {
|
|
27
|
+
readonly url: string;
|
|
28
|
+
readonly status: number;
|
|
29
|
+
readonly statusText: string;
|
|
30
|
+
readonly body: any;
|
|
31
|
+
readonly request: ApiRequestOptions;
|
|
32
|
+
constructor(request: ApiRequestOptions, response: ApiResult, message: string);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare class CancelError extends Error {
|
|
36
|
+
constructor(message: string);
|
|
37
|
+
get isCancelled(): boolean;
|
|
38
|
+
}
|
|
39
|
+
interface OnCancel {
|
|
40
|
+
readonly isResolved: boolean;
|
|
41
|
+
readonly isRejected: boolean;
|
|
42
|
+
readonly isCancelled: boolean;
|
|
43
|
+
(cancelHandler: () => void): void;
|
|
44
|
+
}
|
|
45
|
+
declare class CancelablePromise<T> implements Promise<T> {
|
|
46
|
+
#private;
|
|
47
|
+
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
|
|
48
|
+
get [Symbol.toStringTag](): string;
|
|
49
|
+
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
50
|
+
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
51
|
+
finally(onFinally?: (() => void) | null): Promise<T>;
|
|
52
|
+
cancel(): void;
|
|
53
|
+
get isCancelled(): boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
57
|
+
type Headers = Record<string, string>;
|
|
58
|
+
type OpenAPIConfig = {
|
|
59
|
+
BASE: string;
|
|
60
|
+
VERSION: string;
|
|
61
|
+
WITH_CREDENTIALS: boolean;
|
|
62
|
+
CREDENTIALS: 'include' | 'omit' | 'same-origin';
|
|
63
|
+
TOKEN?: string | Resolver<string> | undefined;
|
|
64
|
+
NEARINTENTS_TOKEN?: string | Resolver<string> | undefined;
|
|
65
|
+
USERNAME?: string | Resolver<string> | undefined;
|
|
66
|
+
PASSWORD?: string | Resolver<string> | undefined;
|
|
67
|
+
HEADERS?: Headers | Resolver<Headers> | undefined;
|
|
68
|
+
ENCODE_PATH?: ((path: string) => string) | undefined;
|
|
69
|
+
DEBUG: boolean;
|
|
70
|
+
};
|
|
71
|
+
declare const OpenAPI: OpenAPIConfig;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Request method
|
|
75
|
+
* @param config The OpenAPI configuration object
|
|
76
|
+
* @param options The request options from the service
|
|
77
|
+
* @param axiosClient The axios client instance to use
|
|
78
|
+
* @returns CancelablePromise<T>
|
|
79
|
+
* @throws ApiError
|
|
80
|
+
*/
|
|
81
|
+
declare const request: <T>(config: OpenAPIConfig, options: ApiRequestOptions, axiosClient?: AxiosInstance) => CancelablePromise<T>;
|
|
82
|
+
|
|
83
|
+
declare const getRequest: <T>(url: string, query?: Record<string, any>) => CancelablePromise<T>;
|
|
84
|
+
declare const postRequest: <T>(url: string, data?: any) => CancelablePromise<T>;
|
|
85
|
+
|
|
86
|
+
declare enum SendType {
|
|
87
|
+
SEND = "SEND",
|
|
88
|
+
TRANSFER = "TRANSFER"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Please use Service instead
|
|
93
|
+
*/
|
|
94
|
+
type ServiceType = "oneclick" | "usdt0" | "cctp" | "fraxzero" | "fraxzero-oneclick" | "oneclick-fraxzero" | "usdt0-oneclick" | "oneclick-usdt0" | "native";
|
|
95
|
+
declare const Service: {
|
|
96
|
+
readonly OneClick: "oneclick";
|
|
97
|
+
readonly Usdt0: "usdt0";
|
|
98
|
+
readonly CCTP: "cctp";
|
|
99
|
+
readonly FraxZero: "fraxzero";
|
|
100
|
+
readonly FraxZeroOneClick: "fraxzero-oneclick";
|
|
101
|
+
readonly OneClickFraxZero: "oneclick-fraxzero";
|
|
102
|
+
readonly Usdt0OneClick: "usdt0-oneclick";
|
|
103
|
+
readonly OneClickUsdt0: "oneclick-usdt0";
|
|
104
|
+
readonly Native: "native";
|
|
105
|
+
};
|
|
106
|
+
type Service = (typeof Service)[keyof typeof Service];
|
|
107
|
+
declare const ServiceBackend: Record<Service, string>;
|
|
108
|
+
declare const enum ServiceProject {
|
|
109
|
+
OneClick = 0,
|
|
110
|
+
Usdt0 = 1,
|
|
111
|
+
CCTP = 2,
|
|
112
|
+
FraxZero = 6,
|
|
113
|
+
FraxZeroOneClick = 7,
|
|
114
|
+
OneClickFraxZero = 8,
|
|
115
|
+
Usdt0OneClick = 3,
|
|
116
|
+
OneClickUsdt0 = 4,
|
|
117
|
+
Native = 5
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
type AppFee = {
|
|
121
|
+
/**
|
|
122
|
+
* Account ID within Intents to which this fee will be transferred
|
|
123
|
+
*/
|
|
124
|
+
recipient: string;
|
|
125
|
+
/**
|
|
126
|
+
* Fee for this recipient as part of amountIn in basis points (1/100th of a percent), e.g. 100 for 1% fee
|
|
127
|
+
*/
|
|
128
|
+
fee: number;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
type BadRequestResponse = {
|
|
132
|
+
message: string;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* OneClick Statuses
|
|
137
|
+
* @see https://docs.near-intents.org/integration/distribution-channels/1click-api/quickstart#status-response
|
|
138
|
+
*/
|
|
139
|
+
declare enum OneClickStatus {
|
|
140
|
+
/**
|
|
141
|
+
* Deposit transaction detected
|
|
142
|
+
*/
|
|
143
|
+
KNOWN_DEPOSIT_TX = "KNOWN_DEPOSIT_TX",
|
|
144
|
+
/**
|
|
145
|
+
* Awaiting your token deposit
|
|
146
|
+
*/
|
|
147
|
+
PENDING_DEPOSIT = "PENDING_DEPOSIT",
|
|
148
|
+
/**
|
|
149
|
+
* Deposit below required amount
|
|
150
|
+
*/
|
|
151
|
+
INCOMPLETE_DEPOSIT = "INCOMPLETE_DEPOSIT",
|
|
152
|
+
/**
|
|
153
|
+
* Swap being executed
|
|
154
|
+
*/
|
|
155
|
+
PROCESSING = "PROCESSING",
|
|
156
|
+
/**
|
|
157
|
+
* Tokens delivered to destination address
|
|
158
|
+
*/
|
|
159
|
+
SUCCESS = "SUCCESS",
|
|
160
|
+
/**
|
|
161
|
+
* Swap failed, funds returned to refund address
|
|
162
|
+
*/
|
|
163
|
+
REFUNDED = "REFUNDED",
|
|
164
|
+
/**
|
|
165
|
+
* Swap encountered an error
|
|
166
|
+
*/
|
|
167
|
+
FAILED = "FAILED"
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Transaction Statuses
|
|
171
|
+
* @see https://docs.layerzero.network/v2/developers/evm/tooling/layerzeroscan#transaction-statuses
|
|
172
|
+
*/
|
|
173
|
+
declare enum LayerZeroStatus {
|
|
174
|
+
/**
|
|
175
|
+
* The message has been successfully sent and received by the destination chain.
|
|
176
|
+
*/
|
|
177
|
+
DELIVERED = "DELIVERED",
|
|
178
|
+
/**
|
|
179
|
+
* The message is waiting for source block confirmations, verification, or execution on the destination chain.
|
|
180
|
+
*/
|
|
181
|
+
INFLIGHT = "INFLIGHT",
|
|
182
|
+
/**
|
|
183
|
+
* The message arrived at the destination, but reverted or ran out of gas during execution and needs to be retried.
|
|
184
|
+
*/
|
|
185
|
+
PAYLOAD_STORED = "PAYLOAD_STORED",
|
|
186
|
+
/**
|
|
187
|
+
* The transaction encountered an error and did not complete.
|
|
188
|
+
*/
|
|
189
|
+
FAILED = "FAILED",
|
|
190
|
+
/**
|
|
191
|
+
* A previous message nonce has a stored payload, halting the current transaction.
|
|
192
|
+
*/
|
|
193
|
+
BLOCKED = "BLOCKED",
|
|
194
|
+
/**
|
|
195
|
+
* The destination transaction has been submitted and is waiting to reach finality on the destination chain.
|
|
196
|
+
*/
|
|
197
|
+
CONFIRMING = "CONFIRMING",
|
|
198
|
+
APPLICATION_BURNED = "APPLICATION_BURNED",
|
|
199
|
+
APPLICATION_SKIPPED = "APPLICATION_SKIPPED",
|
|
200
|
+
UNRESOLVABLE_COMMAND = "UNRESOLVABLE_COMMAND",
|
|
201
|
+
MALFORMED_COMMAND = "MALFORMED_COMMAND"
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Stableflow Statuses
|
|
205
|
+
*/
|
|
206
|
+
declare enum StableflowStatus {
|
|
207
|
+
/**
|
|
208
|
+
* Pending
|
|
209
|
+
*/
|
|
210
|
+
PENDING = 0,
|
|
211
|
+
/**
|
|
212
|
+
* Success
|
|
213
|
+
*/
|
|
214
|
+
SUCCESS = 1,
|
|
215
|
+
/**
|
|
216
|
+
* Failed
|
|
217
|
+
*/
|
|
218
|
+
FAILED = 2,
|
|
219
|
+
/**
|
|
220
|
+
* CCTP Confirming
|
|
221
|
+
*/
|
|
222
|
+
CONFIRMING = 3,
|
|
223
|
+
/**
|
|
224
|
+
* Awaiting token deposit
|
|
225
|
+
*/
|
|
226
|
+
CONTINUE = 4,
|
|
227
|
+
/**
|
|
228
|
+
* LayerZero tx submitted
|
|
229
|
+
*/
|
|
230
|
+
LAYERZERO_SUBMITTED = 5
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
interface GetStatusParams {
|
|
234
|
+
/**
|
|
235
|
+
* Required if the source chain transaction was submitted via oneclick; pass the deposit address.
|
|
236
|
+
*/
|
|
237
|
+
depositAddress?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Source chain transaction hash.
|
|
240
|
+
*/
|
|
241
|
+
hash?: string;
|
|
242
|
+
/**
|
|
243
|
+
* Required if the source chain transaction was submitted via oneclick and depositMemo is available; pass depositMemo.
|
|
244
|
+
*/
|
|
245
|
+
depositMemo?: string;
|
|
246
|
+
}
|
|
247
|
+
interface GetStatusStableflowResponse {
|
|
248
|
+
code: number;
|
|
249
|
+
data: {
|
|
250
|
+
address: string;
|
|
251
|
+
create_time: string;
|
|
252
|
+
deposit_address: string;
|
|
253
|
+
fee: string;
|
|
254
|
+
from_chain: string;
|
|
255
|
+
id: number;
|
|
256
|
+
ip: string;
|
|
257
|
+
project: ServiceProject;
|
|
258
|
+
quote_ids: string;
|
|
259
|
+
receive_address: string;
|
|
260
|
+
status: StableflowStatus;
|
|
261
|
+
symbol: string;
|
|
262
|
+
to_chain: string;
|
|
263
|
+
to_symbol: string;
|
|
264
|
+
to_tx_hash: string;
|
|
265
|
+
token_in_amount: string;
|
|
266
|
+
token_out_amount: string;
|
|
267
|
+
trade_status: string;
|
|
268
|
+
tx_hash: string;
|
|
269
|
+
volume: string;
|
|
270
|
+
} | null;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
type Quote = {
|
|
274
|
+
/**
|
|
275
|
+
* The deposit address on the chain of `originAsset` when `depositType` is `ORIGIN_CHAIN`.
|
|
276
|
+
*
|
|
277
|
+
* The deposit address inside NEAR Intents (the verifier smart contract) when `depositType` is `INTENTS`.
|
|
278
|
+
*/
|
|
279
|
+
depositAddress?: string;
|
|
280
|
+
/**
|
|
281
|
+
* Some of the deposit addresses **REQUIRE** to also include the `memo` for the deposit to be processed
|
|
282
|
+
*/
|
|
283
|
+
depositMemo?: string;
|
|
284
|
+
/**
|
|
285
|
+
* Amount of the origin asset
|
|
286
|
+
*/
|
|
287
|
+
amountIn: string;
|
|
288
|
+
/**
|
|
289
|
+
* Amount of the origin asset in readable format
|
|
290
|
+
*/
|
|
291
|
+
amountInFormatted: string;
|
|
292
|
+
/**
|
|
293
|
+
* Amount of the origin assets equivalent in USD
|
|
294
|
+
*/
|
|
295
|
+
amountInUsd: string;
|
|
296
|
+
/**
|
|
297
|
+
* Minimum amount of the origin asset that will be used for the swap
|
|
298
|
+
*/
|
|
299
|
+
minAmountIn: string;
|
|
300
|
+
/**
|
|
301
|
+
* Amount of the destination asset
|
|
302
|
+
*/
|
|
303
|
+
amountOut: string;
|
|
304
|
+
/**
|
|
305
|
+
* Amount of the destination asset in readable format
|
|
306
|
+
*/
|
|
307
|
+
amountOutFormatted: string;
|
|
308
|
+
/**
|
|
309
|
+
* Amount of the destination asset equivalent in USD
|
|
310
|
+
*/
|
|
311
|
+
amountOutUsd: string;
|
|
312
|
+
/**
|
|
313
|
+
* Minimum output amount after slippage is applied
|
|
314
|
+
*/
|
|
315
|
+
minAmountOut: string;
|
|
316
|
+
/**
|
|
317
|
+
* Time when the deposit address becomes inactive and funds may be lost
|
|
318
|
+
*/
|
|
319
|
+
deadline?: string;
|
|
320
|
+
/**
|
|
321
|
+
* Time when the deposit address becomes cold, causing swap processing to take longer
|
|
322
|
+
*/
|
|
323
|
+
timeWhenInactive?: string;
|
|
324
|
+
/**
|
|
325
|
+
* Estimated time in seconds for the swap to be executed after the deposit transaction is confirmed
|
|
326
|
+
*/
|
|
327
|
+
timeEstimate: number;
|
|
328
|
+
/**
|
|
329
|
+
* EVM address of a transfer recipient in a virtual chain
|
|
330
|
+
*/
|
|
331
|
+
virtualChainRecipient?: string;
|
|
332
|
+
/**
|
|
333
|
+
* EVM address of a refund recipient in a virtual chain
|
|
334
|
+
*/
|
|
335
|
+
virtualChainRefundRecipient?: string;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
type QuoteRequest = {
|
|
339
|
+
/**
|
|
340
|
+
* Flag indicating whether this is a dry run request.
|
|
341
|
+
* If `true`, the response will **NOT** contain the following fields:
|
|
342
|
+
* - `depositAddress`
|
|
343
|
+
* - `timeWhenInactive`
|
|
344
|
+
* - `deadline`
|
|
345
|
+
*/
|
|
346
|
+
dry: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* What deposit address mode you will get in the response, most chain supports only `SIMPLE` and some(for example `stellar`) only `MEMO`:
|
|
349
|
+
* - `SIMPLE` - usual deposit with only deposit address.
|
|
350
|
+
* - `MEMO` - some chains will **REQUIRE** the `memo` together with `depositAddress` for swap to work.
|
|
351
|
+
*/
|
|
352
|
+
depositMode?: QuoteRequest.depositMode;
|
|
353
|
+
/**
|
|
354
|
+
* How to interpret `amount` when performing the swap:
|
|
355
|
+
* - `EXACT_INPUT` - requests the output amount for an exact input.
|
|
356
|
+
* - `EXACT_OUTPUT` - requests the input amount for an exact output. The `refundTo` address always receives any excess tokens after the swap is complete.
|
|
357
|
+
* - `FLEX_INPUT` - a flexible input amount that allows for partial deposits and variable amounts.
|
|
358
|
+
*/
|
|
359
|
+
swapType: QuoteRequest.swapType;
|
|
360
|
+
/**
|
|
361
|
+
* Slippage tolerance for the swap. This value is in basis points (1/100th of a percent), e.g. 100 for 1% slippage.
|
|
362
|
+
*/
|
|
363
|
+
slippageTolerance: number;
|
|
364
|
+
/**
|
|
365
|
+
* ID of the origin asset.
|
|
366
|
+
*/
|
|
367
|
+
originAsset: string;
|
|
368
|
+
/**
|
|
369
|
+
* Type of deposit address:
|
|
370
|
+
* - `ORIGIN_CHAIN` - deposit address on the origin chain.
|
|
371
|
+
* - `INTENTS` - the account ID within NEAR Intents to which you should transfer assets.
|
|
372
|
+
*/
|
|
373
|
+
depositType: QuoteRequest.depositType;
|
|
374
|
+
/**
|
|
375
|
+
* ID of the destination asset.
|
|
376
|
+
*/
|
|
377
|
+
destinationAsset: string;
|
|
378
|
+
/**
|
|
379
|
+
* Amount to swap as the base amount. It is interpreted as the input or output amount based on the `swapType` flag and is specified in the smallest unit of the currency (e.g., wei for ETH).
|
|
380
|
+
*/
|
|
381
|
+
amount: string;
|
|
382
|
+
/**
|
|
383
|
+
* Address used for refunds.
|
|
384
|
+
*/
|
|
385
|
+
refundTo: string;
|
|
386
|
+
/**
|
|
387
|
+
* Type of refund address:
|
|
388
|
+
* - `ORIGIN_CHAIN` - assets are refunded to the `refundTo` address on the origin chain.
|
|
389
|
+
* - `INTENTS` - assets are refunded to the `refundTo` Intents account.
|
|
390
|
+
*/
|
|
391
|
+
refundType: QuoteRequest.refundType;
|
|
392
|
+
/**
|
|
393
|
+
* Recipient address. The format must match `recipientType`.
|
|
394
|
+
*/
|
|
395
|
+
recipient: string;
|
|
396
|
+
/**
|
|
397
|
+
* EVM address of a transfer recipient in a virtual chain
|
|
398
|
+
*/
|
|
399
|
+
virtualChainRecipient?: string;
|
|
400
|
+
/**
|
|
401
|
+
* EVM address of a refund recipient in a virtual chain
|
|
402
|
+
*/
|
|
403
|
+
virtualChainRefundRecipient?: string;
|
|
404
|
+
/**
|
|
405
|
+
* Type of recipient address:
|
|
406
|
+
* - `DESTINATION_CHAIN` - assets are transferred to the chain of `destinationAsset`.
|
|
407
|
+
* - `INTENTS` - assets are transferred to an account inside Intents
|
|
408
|
+
*/
|
|
409
|
+
recipientType: QuoteRequest.recipientType;
|
|
410
|
+
/**
|
|
411
|
+
* Timestamp in ISO format that identifies when the user refund begins if the swap isn't completed by then. It must exceed the time required for the deposit transaction to be mined. For example, Bitcoin may require around one hour depending on the fees paid.
|
|
412
|
+
*/
|
|
413
|
+
deadline: string;
|
|
414
|
+
/**
|
|
415
|
+
* Time in milliseconds the user is willing to wait for a quote from the relay.
|
|
416
|
+
* **Defaults to 0ms delay if not specified, if you want to receive the fastest quote**.
|
|
417
|
+
*
|
|
418
|
+
*/
|
|
419
|
+
quoteWaitingTimeMs?: number;
|
|
420
|
+
/**
|
|
421
|
+
* List of recipients and their fees
|
|
422
|
+
*/
|
|
423
|
+
appFees?: Array<AppFee>;
|
|
424
|
+
};
|
|
425
|
+
declare namespace QuoteRequest {
|
|
426
|
+
/**
|
|
427
|
+
* What deposit address mode you will get in the response, most chain supports only `SIMPLE` and some(for example `stellar`) only `MEMO`:
|
|
428
|
+
* - `SIMPLE` - usual deposit with only deposit address.
|
|
429
|
+
* - `MEMO` - some chains will **REQUIRE** the `memo` together with `depositAddress` for swap to work.
|
|
430
|
+
*/
|
|
431
|
+
enum depositMode {
|
|
432
|
+
SIMPLE = "SIMPLE",
|
|
433
|
+
MEMO = "MEMO"
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* How to interpret `amount` when performing the swap:
|
|
437
|
+
* - `EXACT_INPUT` - requests the output amount for an exact input.
|
|
438
|
+
* - `EXACT_OUTPUT` - requests the input amount for an exact output. The `refundTo` address always receives any excess tokens after the swap is complete.
|
|
439
|
+
* - `FLEX_INPUT` - a flexible input amount that allows for partial deposits and variable amounts.
|
|
440
|
+
*/
|
|
441
|
+
enum swapType {
|
|
442
|
+
EXACT_INPUT = "EXACT_INPUT",
|
|
443
|
+
EXACT_OUTPUT = "EXACT_OUTPUT",
|
|
444
|
+
FLEX_INPUT = "FLEX_INPUT"
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Type of deposit address:
|
|
448
|
+
* - `ORIGIN_CHAIN` - deposit address on the origin chain.
|
|
449
|
+
* - `INTENTS` - the account ID within NEAR Intents to which you should transfer assets.
|
|
450
|
+
*/
|
|
451
|
+
enum depositType {
|
|
452
|
+
ORIGIN_CHAIN = "ORIGIN_CHAIN",
|
|
453
|
+
INTENTS = "INTENTS"
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Type of refund address:
|
|
457
|
+
* - `ORIGIN_CHAIN` - assets are refunded to the `refundTo` address on the origin chain.
|
|
458
|
+
* - `INTENTS` - assets are refunded to the `refundTo` Intents account.
|
|
459
|
+
*/
|
|
460
|
+
enum refundType {
|
|
461
|
+
ORIGIN_CHAIN = "ORIGIN_CHAIN",
|
|
462
|
+
INTENTS = "INTENTS"
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Type of recipient address:
|
|
466
|
+
* - `DESTINATION_CHAIN` - assets are transferred to the chain of `destinationAsset`.
|
|
467
|
+
* - `INTENTS` - assets are transferred to an account inside Intents
|
|
468
|
+
*/
|
|
469
|
+
enum recipientType {
|
|
470
|
+
DESTINATION_CHAIN = "DESTINATION_CHAIN",
|
|
471
|
+
INTENTS = "INTENTS"
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
type QuoteResponse = {
|
|
476
|
+
/**
|
|
477
|
+
* Timestamp in ISO format that was used to derive the deposit address
|
|
478
|
+
*/
|
|
479
|
+
timestamp: string;
|
|
480
|
+
/**
|
|
481
|
+
* Signature of the StableFlow service confirming the quote for the specific deposit address. Must be saved on the client side (along with the whole quote) in order to resolve any disputes or mistakes.
|
|
482
|
+
*/
|
|
483
|
+
signature: string;
|
|
484
|
+
/**
|
|
485
|
+
* User request
|
|
486
|
+
*/
|
|
487
|
+
quoteRequest: QuoteRequest;
|
|
488
|
+
/**
|
|
489
|
+
* Response containing the deposit address for sending the `amount` of `originAsset` and the expected output amount.
|
|
490
|
+
*/
|
|
491
|
+
quote: Quote;
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
type TransactionDetails = {
|
|
495
|
+
/**
|
|
496
|
+
* Transaction hash
|
|
497
|
+
*/
|
|
498
|
+
hash: string;
|
|
499
|
+
/**
|
|
500
|
+
* Explorer URL for the transaction
|
|
501
|
+
*/
|
|
502
|
+
explorerUrl: string;
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
type SwapDetails = {
|
|
506
|
+
/**
|
|
507
|
+
* All intent hashes that took part in this swap
|
|
508
|
+
*/
|
|
509
|
+
intentHashes: Array<string>;
|
|
510
|
+
/**
|
|
511
|
+
* All NEAR transactions executed for this swap
|
|
512
|
+
*/
|
|
513
|
+
nearTxHashes: Array<string>;
|
|
514
|
+
/**
|
|
515
|
+
* Exact amount of `originToken` after the trade was settled
|
|
516
|
+
*/
|
|
517
|
+
amountIn?: string;
|
|
518
|
+
/**
|
|
519
|
+
* Exact amount of `originToken` in readable format after the trade was settled
|
|
520
|
+
*/
|
|
521
|
+
amountInFormatted?: string;
|
|
522
|
+
/**
|
|
523
|
+
* Exact amount of `originToken` equivalent in USD
|
|
524
|
+
*/
|
|
525
|
+
amountInUsd?: string;
|
|
526
|
+
/**
|
|
527
|
+
* Exact amount of `destinationToken` after the trade was settled
|
|
528
|
+
*/
|
|
529
|
+
amountOut?: string;
|
|
530
|
+
/**
|
|
531
|
+
* Exact amount of `destinationToken` in readable format after the trade was settled
|
|
532
|
+
*/
|
|
533
|
+
amountOutFormatted?: string;
|
|
534
|
+
/**
|
|
535
|
+
* Exact amount of `destinationToken` equivalent in USD
|
|
536
|
+
*/
|
|
537
|
+
amountOutUsd?: string;
|
|
538
|
+
/**
|
|
539
|
+
* Actual slippage
|
|
540
|
+
*/
|
|
541
|
+
slippage?: number;
|
|
542
|
+
/**
|
|
543
|
+
* Hashes and explorer URLs for all transactions on the origin chain
|
|
544
|
+
*/
|
|
545
|
+
originChainTxHashes: Array<TransactionDetails>;
|
|
546
|
+
/**
|
|
547
|
+
* Hashes and explorer URLs for all transactions on the destination chain
|
|
548
|
+
*/
|
|
549
|
+
destinationChainTxHashes: Array<TransactionDetails>;
|
|
550
|
+
/**
|
|
551
|
+
* Amount of `originAsset` transferred to `refundTo`
|
|
552
|
+
*/
|
|
553
|
+
refundedAmount?: string;
|
|
554
|
+
/**
|
|
555
|
+
* Refunded amount in readable format
|
|
556
|
+
*/
|
|
557
|
+
refundedAmountFormatted?: string;
|
|
558
|
+
/**
|
|
559
|
+
* Refunded amount equivalent in USD
|
|
560
|
+
*/
|
|
561
|
+
refundedAmountUsd?: string;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
type GetExecutionStatusResponse = {
|
|
565
|
+
/**
|
|
566
|
+
* Quote response from the original request
|
|
567
|
+
*/
|
|
568
|
+
quoteResponse: QuoteResponse;
|
|
569
|
+
status: OneClickStatus;
|
|
570
|
+
/**
|
|
571
|
+
* Last time the state was updated
|
|
572
|
+
*/
|
|
573
|
+
updatedAt: string;
|
|
574
|
+
/**
|
|
575
|
+
* Details of actual swaps and withdrawals
|
|
576
|
+
*/
|
|
577
|
+
swapDetails: SwapDetails;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
type SubmitDepositTxRequest = {
|
|
581
|
+
/**
|
|
582
|
+
* Transaction hash of your deposit
|
|
583
|
+
*/
|
|
584
|
+
txHash: string;
|
|
585
|
+
/**
|
|
586
|
+
* Deposit address for the quote
|
|
587
|
+
*/
|
|
588
|
+
depositAddress: string;
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
type SubmitDepositTxResponse = {
|
|
592
|
+
/**
|
|
593
|
+
* Quote response from the original request
|
|
594
|
+
*/
|
|
595
|
+
quoteResponse: QuoteResponse;
|
|
596
|
+
status: OneClickStatus;
|
|
597
|
+
/**
|
|
598
|
+
* Last time the state was updated
|
|
599
|
+
*/
|
|
600
|
+
updatedAt: string;
|
|
601
|
+
/**
|
|
602
|
+
* Details of actual swaps and withdrawals
|
|
603
|
+
*/
|
|
604
|
+
swapDetails: SwapDetails;
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
type TokenResponse = {
|
|
608
|
+
/**
|
|
609
|
+
* Unique asset identifier
|
|
610
|
+
*/
|
|
611
|
+
assetId: string;
|
|
612
|
+
/**
|
|
613
|
+
* Number of decimals for the token
|
|
614
|
+
*/
|
|
615
|
+
decimals: number;
|
|
616
|
+
/**
|
|
617
|
+
* Blockchain associated with the token
|
|
618
|
+
*/
|
|
619
|
+
blockchain: TokenResponse.blockchain;
|
|
620
|
+
/**
|
|
621
|
+
* Token symbol (e.g. BTC, ETH)
|
|
622
|
+
*/
|
|
623
|
+
symbol: string;
|
|
624
|
+
/**
|
|
625
|
+
* Current price of the token in USD
|
|
626
|
+
*/
|
|
627
|
+
price: number;
|
|
628
|
+
/**
|
|
629
|
+
* Date when the token price was last updated
|
|
630
|
+
*/
|
|
631
|
+
priceUpdatedAt: string;
|
|
632
|
+
/**
|
|
633
|
+
* Contract address of the token
|
|
634
|
+
*/
|
|
635
|
+
contractAddress?: string;
|
|
636
|
+
};
|
|
637
|
+
declare namespace TokenResponse {
|
|
638
|
+
/**
|
|
639
|
+
* Blockchain associated with the token
|
|
640
|
+
*/
|
|
641
|
+
enum blockchain {
|
|
642
|
+
NEAR = "near",
|
|
643
|
+
ETH = "eth",
|
|
644
|
+
BASE = "base",
|
|
645
|
+
ARB = "arb",
|
|
646
|
+
BTC = "btc",
|
|
647
|
+
SOL = "sol",
|
|
648
|
+
TON = "ton",
|
|
649
|
+
DOGE = "doge",
|
|
650
|
+
XRP = "xrp",
|
|
651
|
+
ZEC = "zec",
|
|
652
|
+
GNOSIS = "gnosis",
|
|
653
|
+
BERA = "bera",
|
|
654
|
+
BSC = "bsc",
|
|
655
|
+
POL = "pol",
|
|
656
|
+
TRON = "tron",
|
|
657
|
+
SUI = "sui",
|
|
658
|
+
OP = "op",
|
|
659
|
+
AVAX = "avax",
|
|
660
|
+
CARDANO = "cardano"
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
interface ChainConfig {
|
|
665
|
+
chainName: string;
|
|
666
|
+
chainId?: number;
|
|
667
|
+
/**
|
|
668
|
+
* SDA.getTokens() blockchain
|
|
669
|
+
*/
|
|
670
|
+
blockchain: string;
|
|
671
|
+
chainIcon: string;
|
|
672
|
+
chainIconGray: string;
|
|
673
|
+
chainType: string;
|
|
674
|
+
blockExplorerUrl: string;
|
|
675
|
+
blockExplorerUrls: string[];
|
|
676
|
+
primaryColor: string;
|
|
677
|
+
nativeToken: {
|
|
678
|
+
symbol: string;
|
|
679
|
+
decimals: number;
|
|
680
|
+
};
|
|
681
|
+
rpcUrls: string[];
|
|
682
|
+
rpcUrl: string;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
interface TokenConfig extends ChainConfig {
|
|
686
|
+
name: string;
|
|
687
|
+
symbol: string;
|
|
688
|
+
decimals: number;
|
|
689
|
+
icon: string;
|
|
690
|
+
assetId: string;
|
|
691
|
+
contractAddress: string;
|
|
692
|
+
services: Service[];
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
interface WalletConfig {
|
|
696
|
+
transfer(params: {
|
|
697
|
+
originAsset: string;
|
|
698
|
+
depositAddress: string;
|
|
699
|
+
amount: string;
|
|
700
|
+
}): Promise<string>;
|
|
701
|
+
getBalance(token: TokenConfig, account: string): Promise<string>;
|
|
702
|
+
balanceOf(token: TokenConfig, account: string): Promise<string>;
|
|
703
|
+
allowance?(params: {
|
|
704
|
+
contractAddress: string;
|
|
705
|
+
spender: string;
|
|
706
|
+
address: string;
|
|
707
|
+
amountWei: string | number | BigInt;
|
|
708
|
+
}): Promise<{
|
|
709
|
+
allowance: string;
|
|
710
|
+
needApprove: boolean;
|
|
711
|
+
}>;
|
|
712
|
+
approve?(params: {
|
|
713
|
+
contractAddress: string;
|
|
714
|
+
spender: string;
|
|
715
|
+
amountWei: string | number | BigInt;
|
|
716
|
+
isApproveMax?: boolean;
|
|
717
|
+
}): Promise<boolean>;
|
|
718
|
+
quote(type: Service, params: {}): Promise<{
|
|
719
|
+
needApprove?: boolean;
|
|
720
|
+
approveSpender?: string;
|
|
721
|
+
sendParam?: any;
|
|
722
|
+
quoteParam: any;
|
|
723
|
+
fees?: Record<string, string>;
|
|
724
|
+
totalFeesUsd?: string;
|
|
725
|
+
estimateSourceGas?: BigInt;
|
|
726
|
+
estimateSourceGasUsd?: string;
|
|
727
|
+
estimateTime?: number;
|
|
728
|
+
outputAmount?: string;
|
|
729
|
+
}>;
|
|
730
|
+
send(type: SendType, params: any): Promise<string>;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
declare enum TransactionStatus {
|
|
734
|
+
Pending = "pending",
|
|
735
|
+
Success = "success",
|
|
736
|
+
Failed = "failed"
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* StableFlow AI Service — HTTP API helpers.
|
|
741
|
+
*
|
|
742
|
+
* For full cross-chain bridge flows (multi-route quote, send, per-bridge status),
|
|
743
|
+
* install and use `@stableflow/bridges` (`BridgeSFA`).
|
|
744
|
+
*/
|
|
745
|
+
declare class SFA {
|
|
746
|
+
/**
|
|
747
|
+
* Get supported tokens
|
|
748
|
+
* Retrieves a list of tokens currently supported by the StableFlow AI API for asset swaps.
|
|
749
|
+
*/
|
|
750
|
+
static getTokens(): CancelablePromise<Array<TokenResponse>>;
|
|
751
|
+
/**
|
|
752
|
+
* Request a swap quote
|
|
753
|
+
* Generates a swap quote based on input parameters such as the assets, amount, slippage tolerance, and recipient/refund information.
|
|
754
|
+
*/
|
|
755
|
+
static getQuote(requestBody: QuoteRequest): CancelablePromise<QuoteResponse>;
|
|
756
|
+
/**
|
|
757
|
+
* Check swap execution status
|
|
758
|
+
* Retrieves the current status of a swap using the unique deposit address from the quote.
|
|
759
|
+
*/
|
|
760
|
+
static getExecutionStatus(depositAddress: string, depositMemo?: string): CancelablePromise<GetExecutionStatusResponse>;
|
|
761
|
+
/**
|
|
762
|
+
* Submit deposit transaction hash (OneClick)
|
|
763
|
+
* Optionally notifies the service that a deposit has been sent to the specified address.
|
|
764
|
+
*/
|
|
765
|
+
static submitDepositTx: (requestBody: SubmitDepositTxRequest) => CancelablePromise<SubmitDepositTxResponse>;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
declare const tokens: TokenConfig[];
|
|
769
|
+
declare const usdtTokens: TokenConfig[];
|
|
770
|
+
declare const usdcTokens: TokenConfig[];
|
|
771
|
+
declare const frxusdTokens: TokenConfig[];
|
|
772
|
+
|
|
773
|
+
declare const usdtChains: Record<string, TokenConfig>;
|
|
774
|
+
|
|
775
|
+
declare const usdcChains: Record<string, TokenConfig>;
|
|
776
|
+
|
|
777
|
+
declare const frxusdChains: Record<string, TokenConfig>;
|
|
778
|
+
|
|
779
|
+
declare const usdt0Chains: Record<string, TokenConfig>;
|
|
780
|
+
|
|
781
|
+
declare const NetworkRpcUrlsMap: Record<string, string[]>;
|
|
782
|
+
/**
|
|
783
|
+
* @deprecated Please use getChainRpcUrl instead
|
|
784
|
+
* @param blockchain
|
|
785
|
+
* @returns
|
|
786
|
+
*/
|
|
787
|
+
declare const getRpcUrls: (blockchain: string) => string[];
|
|
788
|
+
declare const getChainRpcUrl: (blockchain: string) => {
|
|
789
|
+
rpcUrls: string[];
|
|
790
|
+
rpcUrl: string;
|
|
791
|
+
};
|
|
792
|
+
declare const setRpcUrls: (urls: Record<string, string[]>) => Record<string, string[]>;
|
|
793
|
+
|
|
794
|
+
type ChainType = "near" | "sol" | "evm" | "tron" | "aptos" | "ton" | "sui";
|
|
795
|
+
|
|
796
|
+
declare const DefaultAddresses: Record<ChainType, string>;
|
|
797
|
+
|
|
798
|
+
declare const _default: {
|
|
799
|
+
inputs: {
|
|
800
|
+
internalType: string;
|
|
801
|
+
name: string;
|
|
802
|
+
type: string;
|
|
803
|
+
}[];
|
|
804
|
+
name: string;
|
|
805
|
+
outputs: {
|
|
806
|
+
internalType: string;
|
|
807
|
+
name: string;
|
|
808
|
+
type: string;
|
|
809
|
+
}[];
|
|
810
|
+
stateMutability: string;
|
|
811
|
+
type: string;
|
|
812
|
+
}[];
|
|
813
|
+
|
|
814
|
+
declare function getPrice(prices: Record<string, string>, symbol: string): string;
|
|
815
|
+
|
|
816
|
+
declare const numberRemoveEndZero: (value: string) => string;
|
|
817
|
+
|
|
818
|
+
type StyleScale = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
819
|
+
type StyleColor = "red" | "yellow" | "green" | "blue" | "sky" | "teal" | "purple" | "pink" | "rose" | "gray" | "indigo" | "fuchsia" | "stone" | "lime";
|
|
820
|
+
declare class Csl {
|
|
821
|
+
private isDebug;
|
|
822
|
+
constructor(isDebug: boolean);
|
|
823
|
+
log: (type: string, style: `${StyleColor}-${StyleScale}`, str: string, ...args: any[]) => void;
|
|
824
|
+
info: (type: string, str: string, ...args: any[]) => void;
|
|
825
|
+
error: (type: string, str: string, ...args: any[]) => void;
|
|
826
|
+
success: (type: string, str: string, ...args: any[]) => void;
|
|
827
|
+
simple: (str: string, ...args: any[]) => void;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
declare class ExecTime {
|
|
831
|
+
private isDebug;
|
|
832
|
+
private type;
|
|
833
|
+
private logStyle;
|
|
834
|
+
private startTimestamp;
|
|
835
|
+
private currentTimestamp;
|
|
836
|
+
private isPerformance;
|
|
837
|
+
private readonly performanceThreshold;
|
|
838
|
+
private csl;
|
|
839
|
+
constructor(options: {
|
|
840
|
+
type: string;
|
|
841
|
+
logStyle?: `${StyleColor}-${StyleScale}`;
|
|
842
|
+
isPerformance?: boolean;
|
|
843
|
+
isDebug: boolean;
|
|
844
|
+
});
|
|
845
|
+
breakpoint(): void;
|
|
846
|
+
log(subType: string, str?: string, ...params: any[]): void;
|
|
847
|
+
logTotal(subType: string, str?: string, ...params: any[]): void;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
declare const getRouteStatus: (service: Service, disabledServices?: Service[]) => {
|
|
851
|
+
disabled: boolean;
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
export { ApiError, type AppFee, type BadRequestResponse, CancelError, CancelablePromise, type ChainType, Csl, DefaultAddresses, ExecTime, type GetExecutionStatusResponse, type GetStatusParams, type GetStatusStableflowResponse, LayerZeroStatus, NetworkRpcUrlsMap, OneClickStatus, OpenAPI, type OpenAPIConfig, type Quote, QuoteRequest, type QuoteResponse, SFA, SendType, Service, ServiceBackend, type ServiceType, StableflowStatus, type SubmitDepositTxRequest, type SubmitDepositTxResponse, type SwapDetails, type TokenConfig, TokenResponse, type TransactionDetails, TransactionStatus, type WalletConfig, _default as erc20Abi, frxusdChains, frxusdTokens, getChainRpcUrl, getPrice, getRequest, getRouteStatus, getRpcUrls, numberRemoveEndZero, postRequest, request, setRpcUrls, tokens, usdcChains, usdcTokens, usdt0Chains, usdtChains, usdtTokens };
|