@sodax/types 2.0.0-rc.10 → 2.0.0-rc.11
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/dist/backend/backendApiV2.d.ts +505 -0
- package/dist/backend/backendApiV2.js +28 -0
- package/dist/backend/index.d.ts +1 -0
- package/dist/backend/index.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
/** Quote direction. Only exact-input quoting is supported. */
|
|
2
|
+
export type QuoteTypeV2 = 'exact_input';
|
|
3
|
+
/**
|
|
4
|
+
* Solver intent status code:
|
|
5
|
+
* -1 NOT_FOUND, 1 NOT_STARTED_YET, 2 STARTED_NOT_FINISHED, 3 SOLVED (terminal), 4 FAILED (terminal).
|
|
6
|
+
*/
|
|
7
|
+
export type SwapIntentStatusCodeV2 = -1 | 1 | 2 | 3 | 4;
|
|
8
|
+
/** A supported swap token descriptor (`XToken` projected to JSON primitives). */
|
|
9
|
+
export interface SwapTokenV2 {
|
|
10
|
+
/** Token symbol (e.g. `USDC`). */
|
|
11
|
+
symbol: string;
|
|
12
|
+
/** Token name (e.g. `USD Coin`). */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Token decimals. */
|
|
15
|
+
decimals: number;
|
|
16
|
+
/** Token address on its spoke chain (or hub address for hub tokens). */
|
|
17
|
+
address: string;
|
|
18
|
+
/** SODAX SpokeChainKey identifier (e.g. `0xa4b1.arbitrum`, `solana`). */
|
|
19
|
+
chainKey: string;
|
|
20
|
+
/** Corresponding hub-side asset address on Sonic. */
|
|
21
|
+
hubAsset: string;
|
|
22
|
+
/** Hub vault address that custodies bridged liquidity for this token. */
|
|
23
|
+
vault: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Intent struct (hub representation) the client SENDS in request bodies
|
|
27
|
+
* (`/swaps/intents/cancel`, `/swaps/intents/hash`, `/swaps/intents/extra-data`,
|
|
28
|
+
* `/swaps/submit-tx`). Mirrors the backend `IntentDto`: the numeric fields are
|
|
29
|
+
* `bigint`; the transport serializes them to decimal strings on the wire.
|
|
30
|
+
*
|
|
31
|
+
* Differs from {@link IntentResponseV2} (the server-returned variant), whose
|
|
32
|
+
* numeric fields are decimal `string` because outbound JSON cannot carry bigint.
|
|
33
|
+
*/
|
|
34
|
+
export interface IntentRequestV2 {
|
|
35
|
+
/** Intent ID. */
|
|
36
|
+
intentId: bigint;
|
|
37
|
+
/** Creator address. */
|
|
38
|
+
creator: string;
|
|
39
|
+
/** Input token address (hub asset). */
|
|
40
|
+
inputToken: string;
|
|
41
|
+
/** Output token address (hub asset). */
|
|
42
|
+
outputToken: string;
|
|
43
|
+
/** Input amount in smallest unit. */
|
|
44
|
+
inputAmount: bigint;
|
|
45
|
+
/** Minimum acceptable output amount in smallest unit. */
|
|
46
|
+
minOutputAmount: bigint;
|
|
47
|
+
/** Unix timestamp (seconds) when the intent expires; `0n` for no expiry. */
|
|
48
|
+
deadline: bigint;
|
|
49
|
+
/** Whether partial fills are allowed. */
|
|
50
|
+
allowPartialFill: boolean;
|
|
51
|
+
/** Source intent-relay chain id (e.g. `146n` for Sonic). */
|
|
52
|
+
srcChain: bigint;
|
|
53
|
+
/** Destination intent-relay chain id. */
|
|
54
|
+
dstChain: bigint;
|
|
55
|
+
/** Source address (hex). */
|
|
56
|
+
srcAddress: string;
|
|
57
|
+
/** Destination address (hex). */
|
|
58
|
+
dstAddress: string;
|
|
59
|
+
/** Solver address; the zero address means "any solver". */
|
|
60
|
+
solver: string;
|
|
61
|
+
/** Arbitrary intent calldata (hex). */
|
|
62
|
+
data: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Intent struct (hub representation) the server RETURNS in responses
|
|
66
|
+
* (`POST /swaps/intents`, `GET /swaps/intents/:txHash`). Pure JSON: all
|
|
67
|
+
* bigint-derived fields are decimal strings (outbound JSON cannot carry bigint).
|
|
68
|
+
*
|
|
69
|
+
* Differs from {@link IntentRequestV2} (the client-sent variant), whose numeric
|
|
70
|
+
* fields are `bigint`.
|
|
71
|
+
*/
|
|
72
|
+
export interface IntentResponseV2 {
|
|
73
|
+
/** Intent ID (decimal string). */
|
|
74
|
+
intentId: string;
|
|
75
|
+
/** Creator address. */
|
|
76
|
+
creator: string;
|
|
77
|
+
/** Input token address (hub asset). */
|
|
78
|
+
inputToken: string;
|
|
79
|
+
/** Output token address (hub asset). */
|
|
80
|
+
outputToken: string;
|
|
81
|
+
/** Input amount in smallest unit (decimal string). */
|
|
82
|
+
inputAmount: string;
|
|
83
|
+
/** Minimum acceptable output amount in smallest unit (decimal string). */
|
|
84
|
+
minOutputAmount: string;
|
|
85
|
+
/** Unix timestamp (seconds) when the intent expires; `"0"` for no expiry (decimal string). */
|
|
86
|
+
deadline: string;
|
|
87
|
+
/** Whether partial fills are allowed. */
|
|
88
|
+
allowPartialFill: boolean;
|
|
89
|
+
/** Source intent-relay chain id (decimal string, e.g. `"146"`). */
|
|
90
|
+
srcChain: string;
|
|
91
|
+
/** Destination intent-relay chain id (decimal string). */
|
|
92
|
+
dstChain: string;
|
|
93
|
+
/** Source address (hex). */
|
|
94
|
+
srcAddress: string;
|
|
95
|
+
/** Destination address (hex). */
|
|
96
|
+
dstAddress: string;
|
|
97
|
+
/** Solver address; the zero address means "any solver". */
|
|
98
|
+
solver: string;
|
|
99
|
+
/** Arbitrary intent calldata (hex). */
|
|
100
|
+
data: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Relay payload the client SENDS to `POST /swaps/intents/submit` (required for
|
|
104
|
+
* Solana / Bitcoin sources). Identical wire shape to {@link RelayExtraDataResponseV2}.
|
|
105
|
+
*/
|
|
106
|
+
export interface RelayExtraDataRequestV2 {
|
|
107
|
+
/** Relay payload address (hex). */
|
|
108
|
+
address: string;
|
|
109
|
+
/** Relay payload (hex). */
|
|
110
|
+
payload: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Relay payload the server RETURNS from `POST /swaps/intents` (`relayData`) and
|
|
114
|
+
* `POST /swaps/intents/extra-data`. Identical wire shape to {@link RelayExtraDataRequestV2}.
|
|
115
|
+
*/
|
|
116
|
+
export interface RelayExtraDataResponseV2 {
|
|
117
|
+
/** Relay payload address (hex). */
|
|
118
|
+
address: string;
|
|
119
|
+
/** Relay payload (hex). */
|
|
120
|
+
payload: string;
|
|
121
|
+
}
|
|
122
|
+
/** GET /swaps/tokens — map of SpokeChainKey → supported swap tokens. */
|
|
123
|
+
export type GetSwapTokensResponseV2 = Record<string, readonly SwapTokenV2[]>;
|
|
124
|
+
/** GET /swaps/tokens/:chainKey — supported swap tokens for a single chain. */
|
|
125
|
+
export type GetSwapTokensByChainResponseV2 = readonly SwapTokenV2[];
|
|
126
|
+
/** POST /swaps/quote — request body. */
|
|
127
|
+
export interface QuoteRequestV2 {
|
|
128
|
+
/** Source token address on the source spoke chain. */
|
|
129
|
+
tokenSrc: string;
|
|
130
|
+
/** Source spoke chain key (SODAX SpokeChainKey). */
|
|
131
|
+
tokenSrcChainKey: string;
|
|
132
|
+
/** Destination token address on the destination spoke chain. */
|
|
133
|
+
tokenDst: string;
|
|
134
|
+
/** Destination spoke chain key (SODAX SpokeChainKey). */
|
|
135
|
+
tokenDstChainKey: string;
|
|
136
|
+
/** Input amount in smallest unit of the source token (decimal string). */
|
|
137
|
+
amount: string;
|
|
138
|
+
/** Quote type (only `exact_input` is supported). */
|
|
139
|
+
quoteType: QuoteTypeV2;
|
|
140
|
+
/** Source address — required only when `includeTxData=true`; ignored otherwise. */
|
|
141
|
+
srcAddress?: string;
|
|
142
|
+
/** Destination address — required only when `includeTxData=true`; ignored otherwise. */
|
|
143
|
+
dstAddress?: string;
|
|
144
|
+
}
|
|
145
|
+
/** POST /swaps/quote — query params. */
|
|
146
|
+
export interface QuoteQueryV2 {
|
|
147
|
+
/** When true, also build and return `{ tx, intent, relayData }` using the quoted amount as `minOutputAmount`. */
|
|
148
|
+
includeTxData?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/** POST /swaps/quote — response body. */
|
|
151
|
+
export interface QuoteResponseV2 {
|
|
152
|
+
/** Quoted output amount in smallest unit of the destination token (decimal string). */
|
|
153
|
+
quotedAmount: string;
|
|
154
|
+
/** Unsigned create-intent transaction; present only when `includeTxData=true`. */
|
|
155
|
+
txData?: CreateIntentResponseV2;
|
|
156
|
+
}
|
|
157
|
+
/** GET /swaps/deadline — query params. */
|
|
158
|
+
export interface DeadlineQueryV2 {
|
|
159
|
+
/** Offset in seconds added to the hub timestamp. Defaults to 300 (5 minutes); minimum 1. */
|
|
160
|
+
offsetSeconds?: number;
|
|
161
|
+
}
|
|
162
|
+
/** GET /swaps/deadline — response body. */
|
|
163
|
+
export interface DeadlineResponseV2 {
|
|
164
|
+
/** Unix timestamp (seconds) at which the swap intent will expire (decimal string). */
|
|
165
|
+
deadline: string;
|
|
166
|
+
}
|
|
167
|
+
/** Shared request body for `/swaps/allowance/check`, `/swaps/approve`, and `/swaps/intents`. */
|
|
168
|
+
export interface CreateIntentParamsV2 {
|
|
169
|
+
/** Source spoke chain key (SODAX SpokeChainKey). */
|
|
170
|
+
srcChainKey: string;
|
|
171
|
+
/** Destination spoke chain key (SODAX SpokeChainKey). */
|
|
172
|
+
dstChainKey: string;
|
|
173
|
+
/** Input token address on the source spoke chain. */
|
|
174
|
+
inputToken: string;
|
|
175
|
+
/** Output token address on the destination spoke chain. */
|
|
176
|
+
outputToken: string;
|
|
177
|
+
/** Input amount in smallest unit of the input token (decimal string). */
|
|
178
|
+
inputAmount: string;
|
|
179
|
+
/** Minimum acceptable output in smallest unit of the output token (decimal string). */
|
|
180
|
+
minOutputAmount: string;
|
|
181
|
+
/** Unix timestamp (seconds) at which the intent expires; `"0"` for limit-order semantics (decimal string). */
|
|
182
|
+
deadline: string;
|
|
183
|
+
/** Whether partial fills are allowed for this intent. */
|
|
184
|
+
allowPartialFill: boolean;
|
|
185
|
+
/** User address on the source spoke chain (chain-specific format). */
|
|
186
|
+
srcAddress: string;
|
|
187
|
+
/** Recipient address on the destination spoke chain (chain-specific format). */
|
|
188
|
+
dstAddress: string;
|
|
189
|
+
/** Solver address (EVM hub address). Defaults to the zero address for "any solver". */
|
|
190
|
+
solver?: string;
|
|
191
|
+
/** Arbitrary calldata hex string. Defaults to `0x`. */
|
|
192
|
+
data?: string;
|
|
193
|
+
}
|
|
194
|
+
/** POST /swaps/allowance/check — response body. */
|
|
195
|
+
export interface AllowanceCheckResponseV2 {
|
|
196
|
+
/** True when the source token allowance is already sufficient for the intent. */
|
|
197
|
+
valid: boolean;
|
|
198
|
+
}
|
|
199
|
+
/** POST /swaps/approve — response body. */
|
|
200
|
+
export interface ApproveResponseV2 {
|
|
201
|
+
/** Unsigned approval transaction (chain-specific shape). For EVM: `{ from, to, value, data }`. */
|
|
202
|
+
tx: unknown;
|
|
203
|
+
}
|
|
204
|
+
/** POST /swaps/intents — response body. */
|
|
205
|
+
export interface CreateIntentResponseV2 {
|
|
206
|
+
/** Unsigned create-intent transaction (chain-specific shape). For EVM: `{ from, to, value, data }`. */
|
|
207
|
+
tx: unknown;
|
|
208
|
+
/** Built intent struct (hub representation). */
|
|
209
|
+
intent: IntentResponseV2;
|
|
210
|
+
/** Extra data required when calling `POST /swaps/intents/submit`. */
|
|
211
|
+
relayData: RelayExtraDataResponseV2;
|
|
212
|
+
}
|
|
213
|
+
/** POST /swaps/intents/submit — request body. */
|
|
214
|
+
export interface SubmitIntentRequestV2 {
|
|
215
|
+
/** Intent-relay chain id of the source chain (decimal string). NOT the SpokeChainKey. */
|
|
216
|
+
chainId: string;
|
|
217
|
+
/** Transaction hash on the source spoke chain after the caller broadcast the intent tx. */
|
|
218
|
+
txHash: string;
|
|
219
|
+
/** Required for Solana / Bitcoin sources — pass the `relayData` returned by `/swaps/intents` verbatim. */
|
|
220
|
+
data?: RelayExtraDataRequestV2;
|
|
221
|
+
}
|
|
222
|
+
/** POST /swaps/intents/submit — response body. */
|
|
223
|
+
export interface SubmitIntentResponseV2 {
|
|
224
|
+
/** Raw response from the intent relay. Shape varies; treat as opaque. */
|
|
225
|
+
result: unknown;
|
|
226
|
+
}
|
|
227
|
+
/** POST /swaps/intents/status — request body. */
|
|
228
|
+
export interface StatusRequestV2 {
|
|
229
|
+
/** Hub-side intent transaction hash (32-byte hex). */
|
|
230
|
+
intentTxHash: string;
|
|
231
|
+
}
|
|
232
|
+
/** POST /swaps/intents/status — response body. */
|
|
233
|
+
export interface StatusResponseV2 {
|
|
234
|
+
/** Solver intent status code. */
|
|
235
|
+
status: SwapIntentStatusCodeV2;
|
|
236
|
+
/** Fill transaction hash on the destination chain. Present only when `status === 3` (SOLVED). */
|
|
237
|
+
fillTxHash?: string;
|
|
238
|
+
}
|
|
239
|
+
/** POST /swaps/intents/cancel — request body. */
|
|
240
|
+
export interface CancelIntentRequestV2 {
|
|
241
|
+
/** Source spoke chain key on which the intent was created. */
|
|
242
|
+
srcChainKey: string;
|
|
243
|
+
/** Intent struct (as returned by `/swaps/intents`). */
|
|
244
|
+
intent: IntentRequestV2;
|
|
245
|
+
}
|
|
246
|
+
/** POST /swaps/intents/cancel — response body. */
|
|
247
|
+
export interface CancelIntentResponseV2 {
|
|
248
|
+
/** Unsigned cancel transaction (chain-specific shape). For EVM: `{ from, to, value, data }`. */
|
|
249
|
+
tx: unknown;
|
|
250
|
+
}
|
|
251
|
+
/** POST /swaps/intents/hash — request body. */
|
|
252
|
+
export interface IntentHashRequestV2 {
|
|
253
|
+
/** Intent struct to hash. */
|
|
254
|
+
intent: IntentRequestV2;
|
|
255
|
+
}
|
|
256
|
+
/** POST /swaps/intents/hash — response body. */
|
|
257
|
+
export interface IntentHashResponseV2 {
|
|
258
|
+
/** keccak256 hash of the intent struct (32-byte hex). */
|
|
259
|
+
hash: string;
|
|
260
|
+
}
|
|
261
|
+
/** POST /swaps/intents/packet — request body. */
|
|
262
|
+
export interface IntentPacketRequestV2 {
|
|
263
|
+
/** Destination spoke chain key on which the intent was filled. */
|
|
264
|
+
chainId: string;
|
|
265
|
+
/** Fill transaction hash on the destination chain (returned by `/swaps/intents/status`). */
|
|
266
|
+
fillTxHash: string;
|
|
267
|
+
/** Polling timeout in milliseconds. Defaults to the SDK default (~60s); minimum 1. */
|
|
268
|
+
timeout?: number;
|
|
269
|
+
}
|
|
270
|
+
/** POST /swaps/intents/packet — response body. */
|
|
271
|
+
export interface IntentPacketResponseV2 {
|
|
272
|
+
/** Source intent-relay chain id (numeric). */
|
|
273
|
+
srcChainId: number;
|
|
274
|
+
/** Source-chain transaction hash that originated the packet. */
|
|
275
|
+
srcTxHash: string;
|
|
276
|
+
/** Encoded source address. */
|
|
277
|
+
srcAddress: string;
|
|
278
|
+
/** Relay status (e.g. `executed`). */
|
|
279
|
+
status: string;
|
|
280
|
+
/** Destination intent-relay chain id (numeric). */
|
|
281
|
+
dstChainId: number;
|
|
282
|
+
/** Connection sequence number assigned by the relay. */
|
|
283
|
+
connSn: number;
|
|
284
|
+
/** Encoded destination address. */
|
|
285
|
+
dstAddress: string;
|
|
286
|
+
/** Destination-chain transaction hash where the fill landed. */
|
|
287
|
+
dstTxHash: string;
|
|
288
|
+
/** Relay signatures collected for this packet. */
|
|
289
|
+
signatures: string[];
|
|
290
|
+
/** Packet payload (hex). */
|
|
291
|
+
payload: string;
|
|
292
|
+
}
|
|
293
|
+
/** POST /swaps/intents/extra-data — request body. Provide EITHER `txHash` OR `intent`, not both. */
|
|
294
|
+
export interface IntentExtraDataRequestV2 {
|
|
295
|
+
/** Source-chain tx hash. Provide either this OR `intent`. */
|
|
296
|
+
txHash?: string;
|
|
297
|
+
/** Intent struct. Provide either this OR `txHash`. */
|
|
298
|
+
intent?: IntentRequestV2;
|
|
299
|
+
}
|
|
300
|
+
/** POST /swaps/intents/extra-data — response body (same shape as relay extra data). */
|
|
301
|
+
export type IntentExtraDataResponseV2 = RelayExtraDataResponseV2;
|
|
302
|
+
/** GET /swaps/intents/:txHash/fill — on-chain fill state for an intent. */
|
|
303
|
+
export interface IntentStateV2 {
|
|
304
|
+
/** Whether the intent exists on the hub chain. */
|
|
305
|
+
exists: boolean;
|
|
306
|
+
/** Remaining input amount left to fill (decimal string). */
|
|
307
|
+
remainingInput: string;
|
|
308
|
+
/** Received output amount so far (decimal string). */
|
|
309
|
+
receivedOutput: string;
|
|
310
|
+
/** Whether a payment is pending. */
|
|
311
|
+
pendingPayment: boolean;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* GET /swaps/intents/:txHash — decoded Intent struct from the hub's IntentCreated
|
|
315
|
+
* event. Bigint fields are serialized as decimal strings.
|
|
316
|
+
*/
|
|
317
|
+
export type GetIntentResponseV2 = IntentResponseV2;
|
|
318
|
+
/** POST /swaps/limit-orders — request body. Same as create-intent but `deadline` is optional. */
|
|
319
|
+
export type CreateLimitOrderParamsV2 = Omit<CreateIntentParamsV2, 'deadline'> & {
|
|
320
|
+
/** Unix timestamp (seconds) at which the limit order expires. Omit (or pass `"0"`) for no expiry. */
|
|
321
|
+
deadline?: string;
|
|
322
|
+
};
|
|
323
|
+
/** POST /swaps/limit-orders — response body (same shape as create-intent). */
|
|
324
|
+
export type CreateLimitOrderResponseV2 = CreateIntentResponseV2;
|
|
325
|
+
/** POST /swaps/gas/estimate — request body. */
|
|
326
|
+
export interface GasEstimateRequestV2 {
|
|
327
|
+
/** Spoke chain key the transaction targets. */
|
|
328
|
+
chainKey: string;
|
|
329
|
+
/** Raw transaction object (chain-specific shape). For EVM: `{ from, to, value, data }` with `value` as decimal string. */
|
|
330
|
+
tx: Record<string, unknown>;
|
|
331
|
+
}
|
|
332
|
+
/** POST /swaps/gas/estimate — response body. */
|
|
333
|
+
export interface GasEstimateResponseV2 {
|
|
334
|
+
/**
|
|
335
|
+
* Gas estimate. Shape varies by chain family: EVM/Bitcoin/Near/Solana →
|
|
336
|
+
* decimal string (bigint); Sui/Stellar/Stacks/Icon/Injective → structured object.
|
|
337
|
+
*/
|
|
338
|
+
gas: unknown;
|
|
339
|
+
}
|
|
340
|
+
/** GET /swaps/fees/partner and GET /swaps/fees/solver — query params. */
|
|
341
|
+
export interface FeeQueryV2 {
|
|
342
|
+
/** Input amount in smallest unit (decimal string). */
|
|
343
|
+
amount: string;
|
|
344
|
+
}
|
|
345
|
+
/** GET /swaps/fees/partner and GET /swaps/fees/solver — response body. */
|
|
346
|
+
export interface FeeResponseV2 {
|
|
347
|
+
/** Fee amount in smallest unit of the input token (decimal string). */
|
|
348
|
+
fee: string;
|
|
349
|
+
}
|
|
350
|
+
/** POST /swaps/submit-tx — request body. */
|
|
351
|
+
export interface SubmitTxRequestV2 {
|
|
352
|
+
/** Transaction hash of the tx that will be submitted (1–127 chars). */
|
|
353
|
+
txHash: string;
|
|
354
|
+
/** Source chain key (spoke chain the tx will be submitted from). */
|
|
355
|
+
srcChainKey: string;
|
|
356
|
+
/** Address of the wallet that will submit the tx (1–127 chars). */
|
|
357
|
+
walletAddress: string;
|
|
358
|
+
/** Intent object received from createIntent. */
|
|
359
|
+
intent: IntentRequestV2;
|
|
360
|
+
/** Relay data received from createIntent, submitted to the intent relay (hex). */
|
|
361
|
+
relayData: string;
|
|
362
|
+
}
|
|
363
|
+
/** POST /swaps/submit-tx — response `data` payload. */
|
|
364
|
+
export interface SubmitTxResponseDataV2 {
|
|
365
|
+
/** Whether the row was newly inserted or matched an existing record. */
|
|
366
|
+
status: 'inserted' | 'duplicate';
|
|
367
|
+
/** Message indicating the result of the submission. */
|
|
368
|
+
message: string;
|
|
369
|
+
}
|
|
370
|
+
/** POST /swaps/submit-tx — response body. */
|
|
371
|
+
export interface SubmitTxResponseV2 {
|
|
372
|
+
/** True when the submission was accepted (or was a duplicate). */
|
|
373
|
+
success: boolean;
|
|
374
|
+
/** Submission result payload. */
|
|
375
|
+
data: SubmitTxResponseDataV2;
|
|
376
|
+
}
|
|
377
|
+
/** GET /swaps/submit-tx/status — query params. */
|
|
378
|
+
export interface SubmitTxStatusQueryV2 {
|
|
379
|
+
/** Transaction hash of the submitted swap tx (1–127 chars). */
|
|
380
|
+
txHash: string;
|
|
381
|
+
/** Source chain key. */
|
|
382
|
+
srcChainKey: string;
|
|
383
|
+
}
|
|
384
|
+
/** Lifecycle status of a submitted swap tx. */
|
|
385
|
+
export type SubmitSwapTxStatusV2 = 'pending' | 'relaying' | 'relayed' | 'posting_execution' | 'executed' | 'failed';
|
|
386
|
+
/** Lifecycle status of a cross-chain relay packet. */
|
|
387
|
+
export type PacketDataStatusV2 = 'pending' | 'validating' | 'executing' | 'executed';
|
|
388
|
+
/** Relay packet data attached to a submit-tx processing result (snake_case as stored). */
|
|
389
|
+
export interface PacketDataV2 {
|
|
390
|
+
/** Source intent-relay chain id (numeric). */
|
|
391
|
+
src_chain_id: number;
|
|
392
|
+
/** Source-chain transaction hash. */
|
|
393
|
+
src_tx_hash: string;
|
|
394
|
+
/** Encoded source address. */
|
|
395
|
+
src_address: string;
|
|
396
|
+
/** Packet lifecycle status. */
|
|
397
|
+
status: PacketDataStatusV2;
|
|
398
|
+
/** Destination intent-relay chain id (numeric). */
|
|
399
|
+
dst_chain_id: number;
|
|
400
|
+
/** Connection sequence number assigned by the relay. */
|
|
401
|
+
conn_sn: number;
|
|
402
|
+
/** Encoded destination address. */
|
|
403
|
+
dst_address: string;
|
|
404
|
+
/** Destination-chain transaction hash. */
|
|
405
|
+
dst_tx_hash: string;
|
|
406
|
+
/** Relay signatures collected for this packet. */
|
|
407
|
+
signatures: string[];
|
|
408
|
+
/** Packet payload (hex). */
|
|
409
|
+
payload: string;
|
|
410
|
+
}
|
|
411
|
+
/** Processing result for a submitted swap tx (present when executed). */
|
|
412
|
+
export interface SubmitTxStatusResultV2 {
|
|
413
|
+
/** Destination intent tx hash. */
|
|
414
|
+
dstIntentTxHash: string;
|
|
415
|
+
/** Packet data from the relay. */
|
|
416
|
+
packetData?: PacketDataV2;
|
|
417
|
+
/** Intent hash from the solver API (populated after post-execution). */
|
|
418
|
+
intent_hash?: string;
|
|
419
|
+
}
|
|
420
|
+
/** Processing state of a submitted swap tx. */
|
|
421
|
+
export interface SubmitTxStatusDataV2 {
|
|
422
|
+
/** Transaction hash. */
|
|
423
|
+
txHash: string;
|
|
424
|
+
/** Source chain key. */
|
|
425
|
+
srcChainKey: string;
|
|
426
|
+
/** Current processing status. */
|
|
427
|
+
status: SubmitSwapTxStatusV2;
|
|
428
|
+
/** Step where processing failed. */
|
|
429
|
+
failedAtStep?: SubmitSwapTxStatusV2;
|
|
430
|
+
/** Failure reason. */
|
|
431
|
+
failureReason?: string;
|
|
432
|
+
/** Number of processing attempts (claim-time counter). */
|
|
433
|
+
processingAttempts: number;
|
|
434
|
+
/** ISO 8601 timestamp set when the swap exhausted its processing budget and was abandoned. */
|
|
435
|
+
abandonedAt?: string;
|
|
436
|
+
/** Processing result (present when executed). */
|
|
437
|
+
result?: SubmitTxStatusResultV2;
|
|
438
|
+
/** User-facing hint when status is failed or the swap was abandoned. */
|
|
439
|
+
userMessage?: string;
|
|
440
|
+
/** True when an on-chain INTENT_CANCELLED event exists for this swap's intent (failed swaps only). */
|
|
441
|
+
intentCancelled?: boolean;
|
|
442
|
+
}
|
|
443
|
+
/** GET /swaps/submit-tx/status — response body. */
|
|
444
|
+
export interface SubmitTxStatusResponseV2 {
|
|
445
|
+
/** True when a record was found. */
|
|
446
|
+
success: boolean;
|
|
447
|
+
/** The submit-tx processing state. */
|
|
448
|
+
data: SubmitTxStatusDataV2;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Client-side surface for the backend Swaps API v2 — for typed HTTP clients
|
|
452
|
+
* (fetch wrappers / SDK adapters). Each method describes one endpoint as the
|
|
453
|
+
* client sees it: all methods are async and all field types are the
|
|
454
|
+
* post-serialization wire shapes above (bigint/Date → decimal/ISO `string`).
|
|
455
|
+
*
|
|
456
|
+
* Do NOT `implements` this on the NestJS `SwapsController`. Handlers return
|
|
457
|
+
* pre-serialization domain types (`bigint`, `Date`, branded `Hex`/`Address`/
|
|
458
|
+
* `SpokeChainKey`) and may be synchronous; the response interceptor serializes
|
|
459
|
+
* them into these wire shapes afterwards. A single class cannot be both the
|
|
460
|
+
* pre-serialization producer and the post-serialization contract.
|
|
461
|
+
*/
|
|
462
|
+
export interface ISwapsApiV2 {
|
|
463
|
+
/** GET /swaps/tokens */
|
|
464
|
+
getTokens(): Promise<GetSwapTokensResponseV2>;
|
|
465
|
+
/** GET /swaps/tokens/:chainKey */
|
|
466
|
+
getTokensByChain(chainKey: string): Promise<GetSwapTokensByChainResponseV2>;
|
|
467
|
+
/** POST /swaps/quote */
|
|
468
|
+
getQuote(body: QuoteRequestV2, query?: QuoteQueryV2): Promise<QuoteResponseV2>;
|
|
469
|
+
/** GET /swaps/deadline */
|
|
470
|
+
getDeadline(query?: DeadlineQueryV2): Promise<DeadlineResponseV2>;
|
|
471
|
+
/** POST /swaps/allowance/check */
|
|
472
|
+
checkAllowance(body: CreateIntentParamsV2): Promise<AllowanceCheckResponseV2>;
|
|
473
|
+
/** POST /swaps/approve */
|
|
474
|
+
approve(body: CreateIntentParamsV2): Promise<ApproveResponseV2>;
|
|
475
|
+
/** POST /swaps/intents */
|
|
476
|
+
createIntent(body: CreateIntentParamsV2): Promise<CreateIntentResponseV2>;
|
|
477
|
+
/** POST /swaps/intents/submit */
|
|
478
|
+
submitIntent(body: SubmitIntentRequestV2): Promise<SubmitIntentResponseV2>;
|
|
479
|
+
/** POST /swaps/intents/status */
|
|
480
|
+
getStatus(body: StatusRequestV2): Promise<StatusResponseV2>;
|
|
481
|
+
/** POST /swaps/intents/cancel */
|
|
482
|
+
cancelIntent(body: CancelIntentRequestV2): Promise<CancelIntentResponseV2>;
|
|
483
|
+
/** POST /swaps/intents/hash */
|
|
484
|
+
getIntentHash(body: IntentHashRequestV2): Promise<IntentHashResponseV2>;
|
|
485
|
+
/** POST /swaps/intents/packet */
|
|
486
|
+
getSolvedIntentPacket(body: IntentPacketRequestV2): Promise<IntentPacketResponseV2>;
|
|
487
|
+
/** POST /swaps/intents/extra-data */
|
|
488
|
+
getIntentSubmitTxExtraData(body: IntentExtraDataRequestV2): Promise<IntentExtraDataResponseV2>;
|
|
489
|
+
/** GET /swaps/intents/:txHash/fill */
|
|
490
|
+
getFilledIntent(txHash: string): Promise<IntentStateV2>;
|
|
491
|
+
/** GET /swaps/intents/:txHash */
|
|
492
|
+
getIntent(txHash: string): Promise<GetIntentResponseV2>;
|
|
493
|
+
/** POST /swaps/limit-orders */
|
|
494
|
+
createLimitOrderIntent(body: CreateLimitOrderParamsV2): Promise<CreateLimitOrderResponseV2>;
|
|
495
|
+
/** POST /swaps/gas/estimate */
|
|
496
|
+
estimateGas(body: GasEstimateRequestV2): Promise<GasEstimateResponseV2>;
|
|
497
|
+
/** GET /swaps/fees/partner */
|
|
498
|
+
getPartnerFee(query: FeeQueryV2): Promise<FeeResponseV2>;
|
|
499
|
+
/** GET /swaps/fees/solver */
|
|
500
|
+
getSolverFee(query: FeeQueryV2): Promise<FeeResponseV2>;
|
|
501
|
+
/** POST /swaps/submit-tx */
|
|
502
|
+
submitTx(body: SubmitTxRequestV2): Promise<SubmitTxResponseV2>;
|
|
503
|
+
/** GET /swaps/submit-tx/status */
|
|
504
|
+
getSubmitTxStatus(query: SubmitTxStatusQueryV2): Promise<SubmitTxStatusResponseV2>;
|
|
505
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Backend Swaps API v2 — request/response contract types.
|
|
2
|
+
//
|
|
3
|
+
// One type per request/response of every endpoint in the backend `swaps-api`
|
|
4
|
+
// controller (`apps/swaps-api/src/api/swaps/swaps.controller.ts`). They favor
|
|
5
|
+
// plain primitives (`string`/`number`/`boolean`/`bigint`/plain objects) over SDK
|
|
6
|
+
// branded types.
|
|
7
|
+
//
|
|
8
|
+
// Inbound (request) and outbound (response) shapes are SEPARATE types because the
|
|
9
|
+
// two directions genuinely differ:
|
|
10
|
+
// - Outbound (response) types are pure JSON: every bigint-derived value (intent
|
|
11
|
+
// ids, amounts, deadlines, fees, relay chain ids) is a decimal `string`, and
|
|
12
|
+
// every `Date` is an ISO 8601 `string` (e.g. `abandonedAt`). A response NEVER
|
|
13
|
+
// contains `bigint` — JSON cannot represent it.
|
|
14
|
+
// - Inbound (request) types mirror the server's parsed request DTOs: the Intent
|
|
15
|
+
// struct (`IntentRequestV2`) carries `bigint` for its numeric fields, matching
|
|
16
|
+
// the backend `IntentDto`. Other request fields (amounts/deadlines on
|
|
17
|
+
// `CreateIntentParamsV2`/`QuoteRequestV2`, fees, relay chain ids, etc.) are
|
|
18
|
+
// decimal `string`, matching their `@IsNumberString` DTO fields.
|
|
19
|
+
// - `Hex` / `Address` / `Hash` / `SpokeChainKey` are plain `string` everywhere.
|
|
20
|
+
// - Chain-specific opaque payloads (unsigned `tx`, gas estimate, raw relay
|
|
21
|
+
// `result`) are `unknown` because their shape varies by chain family.
|
|
22
|
+
//
|
|
23
|
+
// Shapes used in both directions are split into a `*RequestV2` (client → server)
|
|
24
|
+
// and a `*ResponseV2` (server → client) interface. `IntentRequestV2` (bigint
|
|
25
|
+
// numerics) and `IntentResponseV2` (all-string) genuinely differ;
|
|
26
|
+
// `RelayExtraDataRequestV2` / `RelayExtraDataResponseV2` are identical (no bigint
|
|
27
|
+
// fields). This mirrors the backend's request/response DTO pairs.
|
|
28
|
+
export {};
|
package/dist/backend/index.d.ts
CHANGED
package/dist/backend/index.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,4 +17,4 @@ export * from './sui/index.js';
|
|
|
17
17
|
export * from './swap/index.js';
|
|
18
18
|
export * from './utils/index.js';
|
|
19
19
|
export * from './wallet/index.js';
|
|
20
|
-
export const CONFIG_VERSION =
|
|
20
|
+
export const CONFIG_VERSION = 209; // this value should be incremented (inside release/sdk branch) each time @sodax/types package is updated
|
package/package.json
CHANGED