@rhea-finance/cross-chain-aggregation-dex 1.0.5 → 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 +277 -306
- package/dist/index.d.ts +277 -306
- package/dist/index.js +2359 -631
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2332 -620
- 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.mts
CHANGED
|
@@ -1,335 +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.mjs';
|
|
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.mjs';
|
|
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;
|
|
31
|
-
/** Fallback account for SmartX user/receiveUser when recipient is absent. */
|
|
32
|
-
refundTo?: string;
|
|
33
|
-
/** Optional: Deposit address from intents. If provided, will be used for SmartX second call. */
|
|
34
|
-
depositAddress?: string;
|
|
34
|
+
interface SdkLogger {
|
|
35
|
+
log(entry: SdkLogEntry): void;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* - Used for scenarios where aggregator-specific fields need to be passed through in executeSwap
|
|
47
|
-
* - Kept optional to avoid tightly coupling implementation details into core logic
|
|
48
|
-
*/
|
|
49
|
-
rawRoutes?: any[];
|
|
50
|
-
/** Quote source identifier (used when multiple quote backends are supported). */
|
|
51
|
-
quoteSource?: "findPath" | "smartx";
|
|
52
|
-
/** SmartX quote payload (present when quoteSource === "smartx"). */
|
|
53
|
-
smartxResult?: {
|
|
54
|
-
amountIn: string;
|
|
55
|
-
amountOut: string;
|
|
56
|
-
minAmountOut: string;
|
|
57
|
-
dexs?: string[];
|
|
58
|
-
msg?: string;
|
|
59
|
-
signature?: string;
|
|
60
|
-
tokens?: string[];
|
|
61
|
-
};
|
|
62
|
-
priceImpact?: number;
|
|
63
|
-
avgFee?: number;
|
|
64
|
-
estimatedGas?: string;
|
|
65
|
-
error?: string;
|
|
66
|
-
/** Optional: Deposit address for cross-chain swaps (e.g., from Intents). Passed from quote to executeSwap. */
|
|
67
|
-
depositAddress?: 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;
|
|
68
47
|
}
|
|
69
|
-
interface
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
depositAddress?: string;
|
|
73
|
-
deadline?: number;
|
|
48
|
+
interface ApiRequestOptions {
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
idempotencyKey?: string;
|
|
74
51
|
}
|
|
75
|
-
interface
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
52
|
+
interface RetryConfig {
|
|
53
|
+
maxRetries: number;
|
|
54
|
+
baseDelayMs: number;
|
|
55
|
+
maxDelayMs: number;
|
|
56
|
+
jitter: boolean;
|
|
80
57
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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;
|
|
91
79
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
interface
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
assetId?: string;
|
|
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;
|
|
100
87
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*/
|
|
104
|
-
interface BluechipTokensConfig {
|
|
105
|
-
USDT?: BluechipTokenConfig;
|
|
106
|
-
USDC?: BluechipTokenConfig;
|
|
107
|
-
NEAR?: BluechipTokenConfig;
|
|
108
|
-
[key: string]: BluechipTokenConfig | undefined;
|
|
88
|
+
interface McaDepositCollateral {
|
|
89
|
+
useAsCollateral: boolean;
|
|
109
90
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
result_msg?: string;
|
|
115
|
-
result_message?: string;
|
|
116
|
-
result_data: {
|
|
117
|
-
routes: any[];
|
|
118
|
-
amount_out: string;
|
|
119
|
-
} | null;
|
|
91
|
+
interface McaWithdrawCollateral {
|
|
92
|
+
needDecrease: boolean;
|
|
93
|
+
decreaseAmountBurrow: string;
|
|
94
|
+
withdrawAll?: boolean;
|
|
120
95
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
amountIn: string;
|
|
127
|
-
slippage: number;
|
|
128
|
-
supportLedger?: boolean;
|
|
129
|
-
}): Promise<FindPathResponse>;
|
|
96
|
+
interface McaQuoteRequestBase extends QuoteRequest {
|
|
97
|
+
mcaAccountId: string;
|
|
98
|
+
signerChain: McaSignerChain;
|
|
99
|
+
recipientMsgSignatures?: string[];
|
|
100
|
+
depositSignerProofSignatures?: string[];
|
|
130
101
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
result_message?: string;
|
|
135
|
-
result_data: {
|
|
136
|
-
amount_in: string;
|
|
137
|
-
amount_out: string;
|
|
138
|
-
min_amount_out: string;
|
|
139
|
-
dexs?: string[];
|
|
140
|
-
msg?: string;
|
|
141
|
-
signature?: string;
|
|
142
|
-
tokens?: string[];
|
|
143
|
-
[key: string]: any;
|
|
144
|
-
} | null;
|
|
102
|
+
interface McaDepositQuoteRequest extends McaQuoteRequestBase {
|
|
103
|
+
flow: "deposit";
|
|
104
|
+
collateral: McaDepositCollateral;
|
|
145
105
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
tokenOut: string;
|
|
152
|
-
slippage: number;
|
|
153
|
-
pathDeep: number;
|
|
154
|
-
chainId: number;
|
|
155
|
-
routerCount: number;
|
|
156
|
-
skipUnwrapNativeToken: boolean;
|
|
157
|
-
user: string;
|
|
158
|
-
receiveUser: string;
|
|
159
|
-
[key: string]: any;
|
|
160
|
-
}): Promise<SwapMultiDexPathResponse>;
|
|
106
|
+
interface McaWithdrawQuoteRequest extends McaQuoteRequestBase {
|
|
107
|
+
flow: "withdraw";
|
|
108
|
+
collateral: McaWithdrawCollateral;
|
|
109
|
+
executionPreference?: "auto" | "near" | "relayer";
|
|
110
|
+
boundNearAccountId?: string;
|
|
161
111
|
}
|
|
162
|
-
|
|
163
|
-
interface
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
[key: string]: any;
|
|
171
|
-
};
|
|
172
|
-
[key: string]: any;
|
|
173
|
-
};
|
|
174
|
-
[key: string]: any;
|
|
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;
|
|
175
120
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
amount: string;
|
|
182
|
-
refundTo: string;
|
|
183
|
-
recipient: string;
|
|
184
|
-
slippageTolerance: number;
|
|
185
|
-
swapType?: "EXACT_INPUT" | "EXACT_OUTPUT" | "FLEX_INPUT";
|
|
186
|
-
[key: string]: any;
|
|
187
|
-
}): Promise<IntentsQuoteResult>;
|
|
121
|
+
interface McaDepositQuote extends McaQuoteBase {
|
|
122
|
+
flow: "deposit";
|
|
123
|
+
executionMode: "deposit";
|
|
124
|
+
request: McaDepositQuoteRequest;
|
|
125
|
+
nearDepositTx?: unknown;
|
|
188
126
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
methodName: string;
|
|
195
|
-
args: any;
|
|
196
|
-
gas?: string;
|
|
197
|
-
expandDeposit?: string;
|
|
198
|
-
}>;
|
|
199
|
-
}): Promise<{
|
|
200
|
-
status: "success" | "error";
|
|
201
|
-
txHash?: string;
|
|
202
|
-
txHashArr?: string[];
|
|
203
|
-
message?: string;
|
|
204
|
-
}>;
|
|
205
|
-
view(params: {
|
|
206
|
-
contractId: string;
|
|
207
|
-
methodName: string;
|
|
208
|
-
args?: any;
|
|
209
|
-
}): Promise<any>;
|
|
127
|
+
interface McaWithdrawNearQuote extends McaQuoteBase {
|
|
128
|
+
flow: "withdraw";
|
|
129
|
+
executionMode: "withdraw-near";
|
|
130
|
+
request: McaWithdrawQuoteRequest;
|
|
131
|
+
preview: Record<string, unknown>;
|
|
210
132
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
/** Storage deposit amount (yoctoNEAR) for `storage_deposit` when needed. */
|
|
217
|
-
getTokenStorageDepositRead?(): string;
|
|
218
|
-
/** Aggregate DEX contract id for SmartX execution. */
|
|
219
|
-
getAggregateDexContractId?(): string;
|
|
133
|
+
interface McaWithdrawRelayerQuote extends McaQuoteBase {
|
|
134
|
+
flow: "withdraw";
|
|
135
|
+
executionMode: "withdraw-relayer";
|
|
136
|
+
request: McaWithdrawQuoteRequest;
|
|
137
|
+
preview: Record<string, unknown>;
|
|
220
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;
|
|
221
154
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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[];
|
|
161
|
+
}
|
|
162
|
+
interface SwapHistoryPage {
|
|
163
|
+
items: SwapHistoryItem[];
|
|
164
|
+
page: number;
|
|
165
|
+
pageSize: number;
|
|
166
|
+
totalPages: number;
|
|
167
|
+
totalItems: number;
|
|
168
|
+
filteredLocally?: boolean;
|
|
169
|
+
}
|
|
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;
|
|
191
|
+
}
|
|
252
192
|
|
|
253
|
-
interface
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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;
|
|
259
199
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
private configAdapter;
|
|
265
|
-
private intentsQuotationAdapter?;
|
|
266
|
-
private wrapNearContractId;
|
|
267
|
-
private refExchangeId;
|
|
268
|
-
private tokenStorageDepositRead;
|
|
269
|
-
private aggregateDexContractId?;
|
|
270
|
-
constructor(config: NearSmartRouterConfig);
|
|
271
|
-
/**
|
|
272
|
-
* 核心报价逻辑:并行比价 -> 获取 Intent 地址 -> SmartX 二次修正
|
|
273
|
-
*/
|
|
274
|
-
quote(params: QuoteParams): Promise<QuoteResult>;
|
|
275
|
-
/**
|
|
276
|
-
* 执行逻辑:基于 quote 准备好的数据进行分发
|
|
277
|
-
*/
|
|
278
|
-
executeSwap(params: ExecuteParams): Promise<ExecuteResult>;
|
|
279
|
-
private executeSmartX;
|
|
280
|
-
private executeRef;
|
|
281
|
-
private checkRegistration;
|
|
282
|
-
private handleCallResult;
|
|
283
|
-
getSupportedChain(): "near";
|
|
200
|
+
interface BuildSwapInput {
|
|
201
|
+
quote: Quote;
|
|
202
|
+
signal?: AbortSignal;
|
|
203
|
+
idempotencyKey?: string;
|
|
284
204
|
}
|
|
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;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare function normalizeBuild(raw: SwapBuildDataRaw, executionId?: string, request?: SwapBuildRequestRaw): SwapBuild;
|
|
245
|
+
declare function createExecutionId(): string;
|
|
246
|
+
|
|
247
|
+
declare function toApiChain(chain: ChainRef): string;
|
|
248
|
+
declare function fromApiChain(chain: string): ChainRef;
|
|
249
|
+
declare function toApiAssetAddress(asset: AssetRef): string;
|
|
250
|
+
|
|
251
|
+
declare function normalizeHistory(raw: SwapHistoryDataRaw): SwapHistoryPage;
|
|
252
|
+
declare function normalizeHistoryStatus(status: unknown): HistoryStatus;
|
|
285
253
|
|
|
286
|
-
|
|
254
|
+
declare function serializeQuoteRequest(request: QuoteRequest): SwapQuoteRequestRaw;
|
|
255
|
+
declare function normalizeQuote(request: QuoteRequest, raw: SwapQuoteDataRaw, receivedAt?: number): Quote;
|
|
287
256
|
|
|
288
|
-
interface
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
sourceChain: string;
|
|
292
|
-
targetChain: string;
|
|
257
|
+
interface ResolveMcaWithdrawPolicyInput {
|
|
258
|
+
collateralBalance: string;
|
|
259
|
+
availableBalance: string;
|
|
293
260
|
amountIn: string;
|
|
294
|
-
|
|
295
|
-
recipient: string;
|
|
296
|
-
refundTo?: string;
|
|
297
|
-
/** Optional: Deposit address from intents. If provided, will be passed to dexRouter.quote() for SmartX second call. */
|
|
298
|
-
depositAddress?: string;
|
|
261
|
+
isMax: boolean;
|
|
299
262
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
263
|
+
declare function resolveMcaWithdrawPolicy(input: ResolveMcaWithdrawPolicyInput): McaWithdrawCollateral & {
|
|
264
|
+
withdrawAll: boolean;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
declare function serializeMcaQuoteRequest(request: McaQuoteRequest, signer: McaSignerIdentity): SwapQuoteRequestRaw;
|
|
268
|
+
declare function normalizeMcaQuote(request: McaQuoteRequest, signer: McaSignerIdentity, quote: Quote): McaQuote;
|
|
269
|
+
|
|
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;
|
|
284
|
+
}
|
|
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;
|
|
315
291
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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;
|
|
323
300
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
*
|
|
329
|
-
* Notes:
|
|
330
|
-
* - Prefer `slippage` in bps (e.g. 50 = 0.5%); we also accept percent/decimal inputs.
|
|
331
|
-
* - `targetChain` is currently reserved for future use.
|
|
332
|
-
*/
|
|
333
|
-
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;
|
|
334
305
|
|
|
335
|
-
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 };
|