@rhea-finance/cross-chain-aggregation-dex 1.0.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +277 -270
- package/dist/executors/aptos.d.mts +19 -0
- package/dist/executors/aptos.d.ts +19 -0
- package/dist/executors/aptos.js +140 -0
- package/dist/executors/aptos.js.map +1 -0
- package/dist/executors/aptos.mjs +138 -0
- package/dist/executors/aptos.mjs.map +1 -0
- package/dist/executors/bitcoin.d.mts +22 -0
- package/dist/executors/bitcoin.d.ts +22 -0
- package/dist/executors/bitcoin.js +153 -0
- package/dist/executors/bitcoin.js.map +1 -0
- package/dist/executors/bitcoin.mjs +151 -0
- package/dist/executors/bitcoin.mjs.map +1 -0
- package/dist/executors/evm.d.mts +18 -0
- package/dist/executors/evm.d.ts +18 -0
- package/dist/executors/evm.js +233 -0
- package/dist/executors/evm.js.map +1 -0
- package/dist/executors/evm.mjs +231 -0
- package/dist/executors/evm.mjs.map +1 -0
- package/dist/executors/near.d.mts +18 -0
- package/dist/executors/near.d.ts +18 -0
- package/dist/executors/near.js +162 -0
- package/dist/executors/near.js.map +1 -0
- package/dist/executors/near.mjs +160 -0
- package/dist/executors/near.mjs.map +1 -0
- package/dist/executors/solana.d.mts +20 -0
- package/dist/executors/solana.d.ts +20 -0
- package/dist/executors/solana.js +151 -0
- package/dist/executors/solana.js.map +1 -0
- package/dist/executors/solana.mjs +149 -0
- package/dist/executors/solana.mjs.map +1 -0
- package/dist/executors/sui.d.mts +19 -0
- package/dist/executors/sui.d.ts +19 -0
- package/dist/executors/sui.js +154 -0
- package/dist/executors/sui.js.map +1 -0
- package/dist/executors/sui.mjs +152 -0
- package/dist/executors/sui.mjs.map +1 -0
- package/dist/executors/tron.d.mts +24 -0
- package/dist/executors/tron.d.ts +24 -0
- package/dist/executors/tron.js +161 -0
- package/dist/executors/tron.js.map +1 -0
- package/dist/executors/tron.mjs +159 -0
- package/dist/executors/tron.mjs.map +1 -0
- package/dist/executors/zcash.d.mts +19 -0
- package/dist/executors/zcash.d.ts +19 -0
- package/dist/executors/zcash.js +158 -0
- package/dist/executors/zcash.js.map +1 -0
- package/dist/executors/zcash.mjs +156 -0
- package/dist/executors/zcash.mjs.map +1 -0
- package/dist/index.d.mts +278 -250
- package/dist/index.d.ts +278 -250
- package/dist/index.js +2369 -573
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2340 -560
- package/dist/index.mjs.map +1 -1
- package/dist/registry-DRYUqs7T.d.mts +532 -0
- package/dist/registry-DRYUqs7T.d.ts +532 -0
- package/dist/shared-BdH3hWuP.d.ts +23 -0
- package/dist/shared-BqpFeosz.d.mts +23 -0
- package/package.json +51 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,278 +1,306 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { S as SwapQuoteRequestRaw, a as SwapQuoteDataRaw, b as SwapBuildRequestRaw, c as SwapBuildDataRaw, d as SwapOrderSubmitRequestRaw, e as SwapOrderSubmitDataRaw, f as SwapOrderStatusParamsRaw, g as SwapOrderStatusDataRaw, h as SwapReportRequestRaw, i as SwapReportDataRaw, j as SwapHistoryParamsRaw, k as SwapHistoryDataRaw, Q as QuoteRequest, l as Quote, m as SwapMcaPayloadRaw, W as WaitMode, n as SwapLifecycleEvent, o as SwapExecutionResult, C as ChainRef, A as AssetRef, B as BaseUnitAmount, p as SwapHistoryRecordRaw, q as ChainExecutor, E as ExecutorRegistry, r as SwapBuild, s as ExecuteSwapInput, t as SwapInput, O as OrderStatusResult, u as WaitForOrderInput, N as NearTransaction, v as SwapMcaRelayerRequestRaw } from './registry-DRYUqs7T.js';
|
|
2
|
+
export { a1 as BuildContext, J as ChainExecutionResult, Z as DepositInfo, U as EvmApproval, V as EvmSigningRequest, T as EvmTx, K as ExecutionContext, L as ExecutorIdentityProvider, P as ExecutorMessageSigner, M as MessageSignOptions, Y as OrderReference, H as OrderStatus, a0 as RouteSummary, G as SignRequestPreview, X as SolanaMetadata, w as SwapApiResponse, x as SwapApiTokenMetaRaw, D as SwapBuildApproveRaw, $ as SwapExecution, y as SwapMcaSignerPayloadRaw, _ as SwapReportContext, z as SwapSigningRequestRaw, F as SwapWarning, R as assertBaseUnitAmount, I as normalizeOrderStatus } from './registry-DRYUqs7T.js';
|
|
3
|
+
|
|
4
|
+
type SwapErrorCode = "HTTP_ERROR" | "API_ERROR" | "RATE_LIMITED" | "AUTH_FAILED" | "REQUEST_ABORTED" | "REQUEST_TIMEOUT" | "INVALID_REQUEST" | "INVALID_API_RESPONSE" | "QUOTE_EXPIRED" | "ROUTE_NOT_FOUND" | "EXECUTOR_NOT_FOUND" | "UNSUPPORTED_CHAIN" | "CHAIN_MISMATCH" | "INVALID_TRANSACTION" | "USER_REJECTED" | "INSUFFICIENT_BALANCE" | "APPROVAL_FAILED" | "SIGNING_FAILED" | "BROADCAST_FAILED" | "ORDER_SUBMIT_FAILED" | "ORDER_TIMEOUT" | "REPORT_FAILED";
|
|
5
|
+
type SwapErrorStage = "quote" | "build" | "approve" | "sign" | "broadcast" | "submit" | "report" | "status" | "history";
|
|
6
|
+
interface SwapSdkErrorOptions {
|
|
7
|
+
retryable?: boolean;
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
details?: Record<string, unknown>;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
declare class SwapSdkError extends Error {
|
|
12
|
+
readonly code: SwapErrorCode;
|
|
13
|
+
readonly stage: SwapErrorStage;
|
|
14
|
+
readonly options: SwapSdkErrorOptions;
|
|
15
|
+
readonly name = "SwapSdkError";
|
|
16
|
+
constructor(code: SwapErrorCode, stage: SwapErrorStage, message: string, options?: SwapSdkErrorOptions);
|
|
17
|
+
get retryable(): boolean;
|
|
18
|
+
get cause(): unknown;
|
|
19
|
+
get details(): Record<string, unknown> | undefined;
|
|
14
20
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
declare function asSwapSdkError(error: unknown, stage: SwapErrorStage): SwapSdkError;
|
|
22
|
+
|
|
23
|
+
type SdkLogLevel = "debug" | "warn";
|
|
24
|
+
interface SdkLogEntry {
|
|
25
|
+
level: SdkLogLevel;
|
|
26
|
+
event: "api.request" | "api.response" | "api.retry";
|
|
27
|
+
path: string;
|
|
28
|
+
stage: SwapErrorStage;
|
|
29
|
+
attempt: number;
|
|
30
|
+
status?: number;
|
|
31
|
+
durationMs?: number;
|
|
32
|
+
code?: SwapErrorCode;
|
|
22
33
|
}
|
|
23
|
-
interface
|
|
24
|
-
|
|
25
|
-
tokenOut: TokenInfo;
|
|
26
|
-
amountIn: string;
|
|
27
|
-
/** Slippage tolerance in bps (e.g. 50 = 0.5%). */
|
|
28
|
-
slippage: number;
|
|
29
|
-
swapType?: "EXACT_INPUT" | "EXACT_OUTPUT";
|
|
30
|
-
recipient?: string;
|
|
34
|
+
interface SdkLogger {
|
|
35
|
+
log(entry: SdkLogEntry): void;
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* - Used for scenarios where aggregator-specific fields need to be passed through in executeSwap
|
|
43
|
-
* - Kept optional to avoid tightly coupling implementation details into core logic
|
|
44
|
-
*/
|
|
45
|
-
rawRoutes?: any[];
|
|
46
|
-
priceImpact?: number;
|
|
47
|
-
avgFee?: number;
|
|
48
|
-
estimatedGas?: string;
|
|
49
|
-
error?: string;
|
|
37
|
+
|
|
38
|
+
interface ApiClientConfig {
|
|
39
|
+
baseUrl: string;
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
getAccessToken?: () => string | Promise<string>;
|
|
42
|
+
fetch?: typeof globalThis.fetch;
|
|
43
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
retry?: Partial<RetryConfig>;
|
|
46
|
+
logger?: SdkLogger;
|
|
50
47
|
}
|
|
51
|
-
interface
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
interface ApiRequestOptions {
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
idempotencyKey?: string;
|
|
51
|
+
}
|
|
52
|
+
interface RetryConfig {
|
|
53
|
+
maxRetries: number;
|
|
54
|
+
baseDelayMs: number;
|
|
55
|
+
maxDelayMs: number;
|
|
56
|
+
jitter: boolean;
|
|
57
|
+
}
|
|
58
|
+
declare class ApiClient {
|
|
59
|
+
private readonly config;
|
|
60
|
+
private readonly baseUrl;
|
|
61
|
+
private readonly fetchImpl;
|
|
62
|
+
constructor(config: ApiClientConfig);
|
|
63
|
+
quote(body: SwapQuoteRequestRaw, options?: ApiRequestOptions): Promise<SwapQuoteDataRaw>;
|
|
64
|
+
build(body: SwapBuildRequestRaw, options?: ApiRequestOptions): Promise<SwapBuildDataRaw>;
|
|
65
|
+
submitOrder(body: SwapOrderSubmitRequestRaw, options?: ApiRequestOptions): Promise<SwapOrderSubmitDataRaw>;
|
|
66
|
+
getOrderStatus(params: SwapOrderStatusParamsRaw, options?: ApiRequestOptions): Promise<SwapOrderStatusDataRaw>;
|
|
67
|
+
report(body: SwapReportRequestRaw, options?: ApiRequestOptions): Promise<SwapReportDataRaw>;
|
|
68
|
+
getHistory(params: SwapHistoryParamsRaw, options?: ApiRequestOptions): Promise<SwapHistoryDataRaw>;
|
|
69
|
+
private request;
|
|
70
|
+
private requestOnce;
|
|
71
|
+
private buildUrl;
|
|
72
|
+
private buildHeaders;
|
|
73
|
+
private retryConfig;
|
|
74
|
+
private retryDelay;
|
|
75
|
+
private log;
|
|
76
|
+
private parseResponse;
|
|
77
|
+
private isEnvelope;
|
|
78
|
+
private readMessage;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type McaFlow = "deposit" | "withdraw";
|
|
82
|
+
type McaSignerChain = "evm" | "solana" | "btc" | "near" | "aptos" | "sui" | "zcash" | "tron";
|
|
83
|
+
interface McaSignerIdentity {
|
|
84
|
+
chain: McaSignerChain;
|
|
85
|
+
identityKey: string;
|
|
86
|
+
accountId?: string;
|
|
87
|
+
}
|
|
88
|
+
interface McaDepositCollateral {
|
|
89
|
+
useAsCollateral: boolean;
|
|
90
|
+
}
|
|
91
|
+
interface McaWithdrawCollateral {
|
|
92
|
+
needDecrease: boolean;
|
|
93
|
+
decreaseAmountBurrow: string;
|
|
94
|
+
withdrawAll?: boolean;
|
|
95
|
+
}
|
|
96
|
+
interface McaQuoteRequestBase extends QuoteRequest {
|
|
97
|
+
mcaAccountId: string;
|
|
98
|
+
signerChain: McaSignerChain;
|
|
99
|
+
recipientMsgSignatures?: string[];
|
|
100
|
+
depositSignerProofSignatures?: string[];
|
|
56
101
|
}
|
|
57
|
-
interface
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
txHashArray?: string[];
|
|
61
|
-
error?: string;
|
|
102
|
+
interface McaDepositQuoteRequest extends McaQuoteRequestBase {
|
|
103
|
+
flow: "deposit";
|
|
104
|
+
collateral: McaDepositCollateral;
|
|
62
105
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
interface DexRouter {
|
|
69
|
-
/** Router's chain (near/evm/solana...) */
|
|
70
|
-
getSupportedChain(): SupportedChain | string;
|
|
71
|
-
quote(params: QuoteParams): Promise<QuoteResult>;
|
|
72
|
-
executeSwap(params: ExecuteParams): Promise<ExecuteResult>;
|
|
106
|
+
interface McaWithdrawQuoteRequest extends McaQuoteRequestBase {
|
|
107
|
+
flow: "withdraw";
|
|
108
|
+
collateral: McaWithdrawCollateral;
|
|
109
|
+
executionPreference?: "auto" | "near" | "relayer";
|
|
110
|
+
boundNearAccountId?: string;
|
|
73
111
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
112
|
+
type McaQuoteRequest = McaDepositQuoteRequest | McaWithdrawQuoteRequest;
|
|
113
|
+
interface McaQuoteBase extends Quote {
|
|
114
|
+
flow: McaFlow;
|
|
115
|
+
mcaAccountId: string;
|
|
116
|
+
signer: Readonly<McaSignerIdentity>;
|
|
117
|
+
request: McaQuoteRequest;
|
|
118
|
+
mca: Readonly<SwapMcaPayloadRaw>;
|
|
119
|
+
raw: SwapQuoteDataRaw;
|
|
82
120
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
USDC?: BluechipTokenConfig;
|
|
89
|
-
NEAR?: BluechipTokenConfig;
|
|
90
|
-
[key: string]: BluechipTokenConfig | undefined;
|
|
121
|
+
interface McaDepositQuote extends McaQuoteBase {
|
|
122
|
+
flow: "deposit";
|
|
123
|
+
executionMode: "deposit";
|
|
124
|
+
request: McaDepositQuoteRequest;
|
|
125
|
+
nearDepositTx?: unknown;
|
|
91
126
|
}
|
|
127
|
+
interface McaWithdrawNearQuote extends McaQuoteBase {
|
|
128
|
+
flow: "withdraw";
|
|
129
|
+
executionMode: "withdraw-near";
|
|
130
|
+
request: McaWithdrawQuoteRequest;
|
|
131
|
+
preview: Record<string, unknown>;
|
|
132
|
+
}
|
|
133
|
+
interface McaWithdrawRelayerQuote extends McaQuoteBase {
|
|
134
|
+
flow: "withdraw";
|
|
135
|
+
executionMode: "withdraw-relayer";
|
|
136
|
+
request: McaWithdrawQuoteRequest;
|
|
137
|
+
preview: Record<string, unknown>;
|
|
138
|
+
}
|
|
139
|
+
type McaQuote = McaDepositQuote | McaWithdrawNearQuote | McaWithdrawRelayerQuote;
|
|
140
|
+
interface McaSwapInput {
|
|
141
|
+
quote: McaQuote;
|
|
142
|
+
waitFor?: WaitMode;
|
|
143
|
+
signal?: AbortSignal;
|
|
144
|
+
idempotencyKey?: string;
|
|
145
|
+
onEvent?: (event: SwapLifecycleEvent) => void;
|
|
146
|
+
beforeSign?: (preview: {
|
|
147
|
+
chain: McaSignerChain;
|
|
148
|
+
identityKey: string;
|
|
149
|
+
message: string;
|
|
150
|
+
business: Readonly<Record<string, unknown>>;
|
|
151
|
+
}) => void | Promise<void>;
|
|
152
|
+
}
|
|
153
|
+
type McaSwapResult = SwapExecutionResult;
|
|
92
154
|
|
|
93
|
-
|
|
94
|
-
interface
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
routes: any[];
|
|
100
|
-
amount_out: string;
|
|
101
|
-
} | null;
|
|
155
|
+
type HistoryStatus = "pending" | "processing" | "completed" | "failed" | "refunded" | "expired" | "unknown";
|
|
156
|
+
interface HistoryRequest {
|
|
157
|
+
sender: string;
|
|
158
|
+
page?: number;
|
|
159
|
+
pageSize?: number;
|
|
160
|
+
status?: HistoryStatus[];
|
|
102
161
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
supportLedger?: boolean;
|
|
111
|
-
}): Promise<FindPathResponse>;
|
|
162
|
+
interface SwapHistoryPage {
|
|
163
|
+
items: SwapHistoryItem[];
|
|
164
|
+
page: number;
|
|
165
|
+
pageSize: number;
|
|
166
|
+
totalPages: number;
|
|
167
|
+
totalItems: number;
|
|
168
|
+
filteredLocally?: boolean;
|
|
112
169
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
170
|
+
interface SwapHistoryItem {
|
|
171
|
+
id: string;
|
|
172
|
+
sender: string;
|
|
173
|
+
recipient?: string;
|
|
174
|
+
fromChain: ChainRef;
|
|
175
|
+
toChain: ChainRef;
|
|
176
|
+
tokenIn: AssetRef;
|
|
177
|
+
tokenOut: AssetRef;
|
|
178
|
+
amountIn?: BaseUnitAmount;
|
|
179
|
+
estimatedOut?: BaseUnitAmount;
|
|
180
|
+
actualOut?: BaseUnitAmount;
|
|
181
|
+
sourceTxHash?: string;
|
|
182
|
+
destinationTxHash?: string;
|
|
183
|
+
orderId?: string;
|
|
184
|
+
depositAddress?: string;
|
|
185
|
+
router?: string;
|
|
186
|
+
status: HistoryStatus;
|
|
187
|
+
createdAt?: string;
|
|
188
|
+
updatedAt?: string;
|
|
189
|
+
statusResponse?: Record<string, unknown>;
|
|
190
|
+
raw: SwapHistoryRecordRaw;
|
|
126
191
|
}
|
|
127
|
-
|
|
128
|
-
interface
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
recipient: string;
|
|
135
|
-
slippageTolerance: number;
|
|
136
|
-
swapType?: "EXACT_INPUT" | "EXACT_OUTPUT" | "FLEX_INPUT";
|
|
137
|
-
[key: string]: any;
|
|
138
|
-
}): Promise<IntentsQuoteResult>;
|
|
192
|
+
|
|
193
|
+
interface SwapClientConfig extends ApiClientConfig {
|
|
194
|
+
maxQuoteAgeMs?: number | null;
|
|
195
|
+
reportMode?: "auto" | "manual" | "disabled";
|
|
196
|
+
executors?: readonly ChainExecutor[];
|
|
197
|
+
onEvent?: (event: SwapLifecycleEvent) => void;
|
|
198
|
+
now?: () => number;
|
|
139
199
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
contractId: string;
|
|
145
|
-
methodName: string;
|
|
146
|
-
args: any;
|
|
147
|
-
gas?: string;
|
|
148
|
-
expandDeposit?: string;
|
|
149
|
-
}>;
|
|
150
|
-
}): Promise<{
|
|
151
|
-
status: "success" | "error";
|
|
152
|
-
txHash?: string;
|
|
153
|
-
txHashArr?: string[];
|
|
154
|
-
message?: string;
|
|
155
|
-
}>;
|
|
156
|
-
view(params: {
|
|
157
|
-
contractId: string;
|
|
158
|
-
methodName: string;
|
|
159
|
-
args?: any;
|
|
160
|
-
}): Promise<any>;
|
|
200
|
+
interface BuildSwapInput {
|
|
201
|
+
quote: Quote;
|
|
202
|
+
signal?: AbortSignal;
|
|
203
|
+
idempotencyKey?: string;
|
|
161
204
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
205
|
+
declare class SwapClient {
|
|
206
|
+
private readonly managedSwapFlow;
|
|
207
|
+
protected readonly api: ApiClient;
|
|
208
|
+
protected readonly registry: ExecutorRegistry;
|
|
209
|
+
protected readonly reportMode: "auto" | "manual" | "disabled";
|
|
210
|
+
protected readonly config: SwapClientConfig;
|
|
211
|
+
private readonly now;
|
|
212
|
+
private readonly inFlight;
|
|
213
|
+
private readonly reportRequests;
|
|
214
|
+
constructor(config: SwapClientConfig);
|
|
215
|
+
quoteRaw(request: SwapQuoteRequestRaw, options?: ApiRequestOptions): Promise<SwapQuoteDataRaw>;
|
|
216
|
+
quote(request: McaQuoteRequest, options?: ApiRequestOptions): Promise<McaQuote>;
|
|
217
|
+
quote(request: QuoteRequest, options?: ApiRequestOptions): Promise<Quote>;
|
|
218
|
+
private quoteStandard;
|
|
219
|
+
buildRaw(request: SwapBuildRequestRaw, options?: ApiRequestOptions): Promise<SwapBuildDataRaw>;
|
|
220
|
+
buildSwap(input: BuildSwapInput): Promise<SwapBuild>;
|
|
221
|
+
private buildStandardSwap;
|
|
222
|
+
executeSwap(input: ExecuteSwapInput): Promise<SwapExecutionResult>;
|
|
223
|
+
swap(input: McaSwapInput): Promise<McaSwapResult>;
|
|
224
|
+
swap(input: SwapInput): Promise<SwapExecutionResult>;
|
|
225
|
+
getOrderStatus(input: {
|
|
226
|
+
orderId: string;
|
|
227
|
+
router: string;
|
|
228
|
+
chainId?: string;
|
|
229
|
+
signal?: AbortSignal;
|
|
230
|
+
}): Promise<OrderStatusResult>;
|
|
231
|
+
waitForOrder(input: WaitForOrderInput): Promise<OrderStatusResult>;
|
|
232
|
+
submitOrderRaw(request: Parameters<ApiClient["submitOrder"]>[0], options?: ApiRequestOptions): Promise<SwapOrderSubmitDataRaw>;
|
|
233
|
+
getOrderStatusRaw(request: Parameters<ApiClient["getOrderStatus"]>[0], options?: ApiRequestOptions): Promise<SwapOrderStatusDataRaw>;
|
|
234
|
+
reportRaw(request: SwapReportRequestRaw, options?: ApiRequestOptions): Promise<SwapReportDataRaw>;
|
|
235
|
+
report(result: SwapExecutionResult): Promise<SwapReportDataRaw>;
|
|
236
|
+
retryReport(result: SwapExecutionResult): Promise<SwapReportDataRaw>;
|
|
237
|
+
getHistoryRaw(params: SwapHistoryParamsRaw, options?: ApiRequestOptions): Promise<SwapHistoryDataRaw>;
|
|
238
|
+
getHistory(request: HistoryRequest, options?: ApiRequestOptions): Promise<SwapHistoryPage>;
|
|
239
|
+
protected emit(event: SwapLifecycleEvent): void;
|
|
240
|
+
private assertQuoteFresh;
|
|
241
|
+
private createReportRequest;
|
|
169
242
|
}
|
|
170
243
|
|
|
171
|
-
declare
|
|
172
|
-
|
|
173
|
-
info: (...args: any[]) => void;
|
|
174
|
-
warn: (...args: any[]) => void;
|
|
175
|
-
error: (...args: any[]) => void;
|
|
176
|
-
};
|
|
244
|
+
declare function normalizeBuild(raw: SwapBuildDataRaw, executionId?: string, request?: SwapBuildRequestRaw): SwapBuild;
|
|
245
|
+
declare function createExecutionId(): string;
|
|
177
246
|
|
|
178
|
-
|
|
179
|
-
declare function
|
|
180
|
-
|
|
181
|
-
declare function getBluechipTokensConfig(): BluechipTokensConfig;
|
|
182
|
-
/**
|
|
183
|
-
* Normalize a NEAR asset id:
|
|
184
|
-
* - strip `nep141:` prefix (if present)
|
|
185
|
-
* - map `near` -> `wrap.near` (overridable via `wrapNearContractId`)
|
|
186
|
-
*/
|
|
187
|
-
declare function normalizeTokenId(tokenId: string | undefined | null, wrapNearContractId?: string): string;
|
|
188
|
-
/** True if the token matches a NearIntents-supported bluechip token (by symbol + address/assetId). */
|
|
189
|
-
declare function isNearIntentsSupportedToken(token: TokenInfo, bluechipTokens?: BluechipTokensConfig): boolean;
|
|
190
|
-
/** Pick an intermediate bluechip token (priority: USDT > USDC > wNEAR; fallback to `wrapNearContractId`). */
|
|
191
|
-
declare function findBestBluechipToken(bluechipTokens: BluechipTokensConfig, wrapNearContractId?: string): TokenInfo;
|
|
192
|
-
/**
|
|
193
|
-
* Convert slippage input into bps (1 bps = 0.01%).
|
|
194
|
-
* - `>= 1`: bps (e.g. 50 = 0.5%)
|
|
195
|
-
* - `[0.01, 1)`: percent (e.g. 0.5 = 0.5%)
|
|
196
|
-
* - `(0, 0.01)`: decimal (e.g. 0.005 = 0.5%)
|
|
197
|
-
*/
|
|
198
|
-
declare function convertSlippageToBasisPoints(slippage: number): number;
|
|
199
|
-
/** Normalize NearIntents `destinationAsset` (prefix + `near` -> `wrap.near`). */
|
|
200
|
-
declare function normalizeDestinationAsset(assetId: string, wrapNearContractId?: string): string;
|
|
247
|
+
declare function toApiChain(chain: ChainRef): string;
|
|
248
|
+
declare function fromApiChain(chain: string): ChainRef;
|
|
249
|
+
declare function toApiAssetAddress(asset: AssetRef): string;
|
|
201
250
|
|
|
202
|
-
|
|
251
|
+
declare function normalizeHistory(raw: SwapHistoryDataRaw): SwapHistoryPage;
|
|
252
|
+
declare function normalizeHistoryStatus(status: unknown): HistoryStatus;
|
|
203
253
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
private configAdapter;
|
|
213
|
-
private wrapNearContractId;
|
|
214
|
-
private refExchangeId;
|
|
215
|
-
private tokenStorageDepositRead;
|
|
216
|
-
constructor(config: NearSmartRouterConfig);
|
|
217
|
-
/**
|
|
218
|
-
* Get a swap quote (normalizes token ids and queries FindPath for routes).
|
|
219
|
-
*/
|
|
220
|
-
quote(params: QuoteParams): Promise<QuoteResult>;
|
|
221
|
-
/**
|
|
222
|
-
* Execute a swap: optionally adds `storage_deposit` for the recipient, then calls REF via `ft_transfer_call`.
|
|
223
|
-
*/
|
|
224
|
-
executeSwap(params: ExecuteParams): Promise<ExecuteResult>;
|
|
225
|
-
/**
|
|
226
|
-
* Get supported chain
|
|
227
|
-
*/
|
|
228
|
-
getSupportedChain(): "near";
|
|
254
|
+
declare function serializeQuoteRequest(request: QuoteRequest): SwapQuoteRequestRaw;
|
|
255
|
+
declare function normalizeQuote(request: QuoteRequest, raw: SwapQuoteDataRaw, receivedAt?: number): Quote;
|
|
256
|
+
|
|
257
|
+
interface ResolveMcaWithdrawPolicyInput {
|
|
258
|
+
collateralBalance: string;
|
|
259
|
+
availableBalance: string;
|
|
260
|
+
amountIn: string;
|
|
261
|
+
isMax: boolean;
|
|
229
262
|
}
|
|
263
|
+
declare function resolveMcaWithdrawPolicy(input: ResolveMcaWithdrawPolicyInput): McaWithdrawCollateral & {
|
|
264
|
+
withdrawAll: boolean;
|
|
265
|
+
};
|
|
230
266
|
|
|
231
|
-
|
|
267
|
+
declare function serializeMcaQuoteRequest(request: McaQuoteRequest, signer: McaSignerIdentity): SwapQuoteRequestRaw;
|
|
268
|
+
declare function normalizeMcaQuote(request: McaQuoteRequest, signer: McaSignerIdentity, quote: Quote): McaQuote;
|
|
232
269
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
270
|
+
type McaWalletKey = "EVM" | "Solana" | "Bitcoin" | "Near" | "Aptos" | "Sui" | "Zcash" | "Tron";
|
|
271
|
+
type McaWalletDescriptor = Partial<Record<McaWalletKey, string>>;
|
|
272
|
+
declare const DEFAULT_MCA_SIGNER_PRIORITY: readonly ["evm", "solana", "btc", "aptos", "near", "zcash", "sui", "tron"];
|
|
273
|
+
declare function formatMcaWallet(chain: McaSignerChain, identityKey: string): McaWalletDescriptor;
|
|
274
|
+
declare function selectMcaSigner(boundWallets: ReadonlyArray<Readonly<Record<string, unknown>>>, connectedSigners: readonly McaSignerIdentity[], priority?: readonly McaSignerChain[]): McaSignerIdentity | undefined;
|
|
275
|
+
declare function isSameMcaSignerIdentity(a: Pick<McaSignerIdentity, "chain" | "identityKey">, b: Pick<McaSignerIdentity, "chain" | "identityKey">): boolean;
|
|
276
|
+
|
|
277
|
+
declare function extractMcaWithdrawBusiness(preview: unknown): Record<string, unknown> | undefined;
|
|
278
|
+
declare function extractMcaWithdrawSignerWallet(preview: unknown): Record<string, unknown> | undefined;
|
|
279
|
+
interface ExtractMcaWithdrawDepositAddressInput {
|
|
280
|
+
bestQuote?: unknown;
|
|
281
|
+
preview?: unknown;
|
|
282
|
+
snapshotDepositAddress?: string | null;
|
|
283
|
+
storeDepositAddress?: string | null;
|
|
242
284
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
preSwap?: {
|
|
250
|
-
quote: QuoteResult;
|
|
251
|
-
tokenIn: TokenInfo;
|
|
252
|
-
tokenOut: TokenInfo;
|
|
253
|
-
executor: DexRouter;
|
|
254
|
-
};
|
|
255
|
-
finalAmountOut: string;
|
|
256
|
-
totalPriceImpact?: number;
|
|
257
|
-
totalFee?: number;
|
|
285
|
+
declare function extractMcaWithdrawDepositAddress(input: ExtractMcaWithdrawDepositAddressInput): string;
|
|
286
|
+
interface BuildNearMcaWithdrawTransactionsInput {
|
|
287
|
+
business: Record<string, unknown>;
|
|
288
|
+
signerWallet: Record<string, unknown>;
|
|
289
|
+
signature?: string;
|
|
290
|
+
mcaAccountId: string;
|
|
258
291
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
292
|
+
declare function buildNearMcaWithdrawTransactions(preview: unknown, input: BuildNearMcaWithdrawTransactionsInput): NearTransaction[];
|
|
293
|
+
interface BuildMcaWithdrawRelayerRequestInput {
|
|
294
|
+
quoteBuild: SwapBuildRequestRaw;
|
|
295
|
+
mcaRelayer: SwapMcaRelayerRequestRaw;
|
|
296
|
+
isCrossChain: boolean;
|
|
297
|
+
depositAddress: string;
|
|
298
|
+
mcaAccountId: string;
|
|
299
|
+
recipientFallback?: string | null;
|
|
266
300
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
*
|
|
272
|
-
* Notes:
|
|
273
|
-
* - Prefer `slippage` in bps (e.g. 50 = 0.5%); we also accept percent/decimal inputs.
|
|
274
|
-
* - `targetChain` is currently reserved for future use.
|
|
275
|
-
*/
|
|
276
|
-
declare function completeQuote(params: CompleteQuoteParams, config: CompleteQuoteConfig): Promise<CompleteQuoteResult>;
|
|
301
|
+
declare function buildMcaWithdrawRelayerRequest(input: BuildMcaWithdrawRelayerRequestInput): SwapBuildRequestRaw;
|
|
302
|
+
|
|
303
|
+
declare function parseUnits(value: string, decimals: number): BaseUnitAmount;
|
|
304
|
+
declare function formatUnits(value: BaseUnitAmount, decimals: number): string;
|
|
277
305
|
|
|
278
|
-
export { type
|
|
306
|
+
export { ApiClient, type ApiClientConfig, type ApiRequestOptions, AssetRef, BaseUnitAmount, type BuildMcaWithdrawRelayerRequestInput, type BuildNearMcaWithdrawTransactionsInput, type BuildSwapInput, ChainExecutor, ChainRef, DEFAULT_MCA_SIGNER_PRIORITY, ExecuteSwapInput, ExecutorRegistry, type ExtractMcaWithdrawDepositAddressInput, type HistoryRequest, type HistoryStatus, type McaDepositCollateral, type McaDepositQuote, type McaDepositQuoteRequest, type McaFlow, type McaQuote, type McaQuoteRequest, type McaSignerChain, type McaSignerIdentity, type McaSwapInput, type McaSwapResult, type McaWalletDescriptor, type McaWalletKey, type McaWithdrawCollateral, type McaWithdrawNearQuote, type McaWithdrawQuoteRequest, type McaWithdrawRelayerQuote, NearTransaction, OrderStatusResult, Quote, QuoteRequest, type ResolveMcaWithdrawPolicyInput, type RetryConfig, type SdkLogEntry, type SdkLogLevel, type SdkLogger, SwapBuild, SwapBuildDataRaw, SwapBuildRequestRaw, SwapClient, type SwapClientConfig, type SwapErrorCode, type SwapErrorStage, SwapExecutionResult, SwapHistoryDataRaw, type SwapHistoryItem, type SwapHistoryPage, SwapHistoryParamsRaw, SwapHistoryRecordRaw, SwapInput, SwapLifecycleEvent, SwapMcaPayloadRaw, SwapMcaRelayerRequestRaw, SwapOrderStatusDataRaw, SwapOrderStatusParamsRaw, SwapOrderSubmitDataRaw, SwapOrderSubmitRequestRaw, SwapQuoteDataRaw, SwapQuoteRequestRaw, SwapReportDataRaw, SwapReportRequestRaw, SwapSdkError, type SwapSdkErrorOptions, WaitForOrderInput, WaitMode, asSwapSdkError, buildMcaWithdrawRelayerRequest, buildNearMcaWithdrawTransactions, createExecutionId, extractMcaWithdrawBusiness, extractMcaWithdrawDepositAddress, extractMcaWithdrawSignerWallet, formatMcaWallet, formatUnits, fromApiChain, isSameMcaSignerIdentity, normalizeBuild, normalizeHistory, normalizeHistoryStatus, normalizeMcaQuote, normalizeQuote, parseUnits, resolveMcaWithdrawPolicy, selectMcaSigner, serializeMcaQuoteRequest, serializeQuoteRequest, toApiAssetAddress, toApiChain };
|