@swapkit/helpers 3.0.0-beta.0 → 3.0.0-beta.1
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/api/index.cjs +2 -2
- package/dist/api/index.cjs.map +6 -6
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +6 -6
- package/dist/chunk-1gwdyyeh.js +4 -0
- package/dist/chunk-1gwdyyeh.js.map +10 -0
- package/dist/chunk-2bhvezjh.js +4 -0
- package/dist/chunk-2bhvezjh.js.map +10 -0
- package/dist/chunk-3ptwhtpd.js +3 -0
- package/dist/chunk-3ptwhtpd.js.map +10 -0
- package/dist/{chunk-nm00d52v.js → chunk-3wnfcm30.js} +2 -2
- package/dist/{chunk-nm00d52v.js.map → chunk-3wnfcm30.js.map} +1 -1
- package/dist/chunk-40epvqbm.js +3 -0
- package/dist/chunk-40epvqbm.js.map +10 -0
- package/dist/chunk-49nsjaay.js +3 -0
- package/dist/chunk-49nsjaay.js.map +10 -0
- package/dist/chunk-4b66tryh.js +4 -0
- package/dist/chunk-4b66tryh.js.map +10 -0
- package/dist/chunk-4kzjrrjv.js +3 -0
- package/dist/chunk-4kzjrrjv.js.map +10 -0
- package/dist/chunk-5m49s8z8.js +4 -0
- package/dist/chunk-5m49s8z8.js.map +10 -0
- package/dist/chunk-9b6y7r75.js +4 -0
- package/dist/chunk-9b6y7r75.js.map +10 -0
- package/dist/chunk-9zcbvqq2.js +3 -0
- package/dist/chunk-9zcbvqq2.js.map +10 -0
- package/dist/chunk-a0bpx1q3.js +4 -0
- package/dist/chunk-a0bpx1q3.js.map +10 -0
- package/dist/chunk-a0fxkkfh.js +4 -0
- package/dist/chunk-a0fxkkfh.js.map +10 -0
- package/dist/chunk-a6bjd9ar.js +3 -0
- package/dist/chunk-a6bjd9ar.js.map +10 -0
- package/dist/chunk-bg6pz5qh.js +3 -0
- package/dist/chunk-bg6pz5qh.js.map +10 -0
- package/dist/chunk-cpdcnp2x.js +4 -0
- package/dist/chunk-cpdcnp2x.js.map +10 -0
- package/dist/chunk-fr86y3rx.js +4 -0
- package/dist/chunk-fr86y3rx.js.map +10 -0
- package/dist/chunk-ftdtdkhk.js +3 -0
- package/dist/chunk-ftdtdkhk.js.map +10 -0
- package/dist/chunk-gjeaw024.js +4 -0
- package/dist/chunk-gjeaw024.js.map +10 -0
- package/dist/chunk-hdcdd2cf.js +4 -0
- package/dist/chunk-hdcdd2cf.js.map +10 -0
- package/dist/chunk-q2pb6ggs.js +3 -0
- package/dist/chunk-q2pb6ggs.js.map +10 -0
- package/dist/chunk-t9s9811k.js +3 -0
- package/dist/chunk-t9s9811k.js.map +10 -0
- package/dist/chunk-v4dvhh90.js +4 -0
- package/dist/chunk-v4dvhh90.js.map +10 -0
- package/dist/chunk-vzptz52h.js +4 -0
- package/dist/chunk-vzptz52h.js.map +10 -0
- package/dist/chunk-wyr5d8ad.js +3 -0
- package/dist/chunk-wyr5d8ad.js.map +10 -0
- package/dist/chunk-x0jsq6ag.js +3 -0
- package/dist/chunk-x0jsq6ag.js.map +10 -0
- package/dist/chunk-x2fe9scs.js +3 -0
- package/dist/chunk-x2fe9scs.js.map +10 -0
- package/dist/chunk-xm5jkehh.js +4 -0
- package/dist/chunk-xm5jkehh.js.map +10 -0
- package/dist/chunk-xzb1nshn.js +3 -0
- package/dist/chunk-xzb1nshn.js.map +10 -0
- package/dist/contracts/index.cjs.map +2 -2
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/index.js.map +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +19 -18
- package/dist/index.js +3 -3
- package/dist/index.js.map +19 -18
- package/dist/tokens/index.cjs +2 -2
- package/dist/tokens/index.cjs.map +3 -16
- package/dist/tokens/index.js +2 -2
- package/dist/tokens/index.js.map +3 -16
- package/package.json +8 -5
- package/src/api/midgard/endpoints.ts +120 -132
- package/src/api/swapkitApi/endpoints.ts +53 -158
- package/src/api/swapkitApi/types.ts +318 -514
- package/src/api/thorswapStatic/endpoints.ts +18 -2
- package/src/contracts/index.ts +1 -1
- package/src/index.ts +15 -10
- package/src/modules/__tests__/assetValue.test.ts +50 -22
- package/src/modules/__tests__/swapKitConfig.test.ts +3 -3
- package/src/modules/assetValue.ts +77 -67
- package/src/modules/requestClient.ts +52 -55
- package/src/modules/swapKitConfig.ts +8 -5
- package/src/modules/swapKitError.ts +18 -11
- package/src/tokens/lists/index.ts +1 -0
- package/src/types/chains.ts +22 -5
- package/src/types/commonTypes.ts +1 -1
- package/src/types/derivationPath.ts +11 -24
- package/src/types/radix.ts +2 -2
- package/src/types/sdk.ts +0 -7
- package/src/types/tokens.ts +13 -16
- package/src/types/wallet.ts +42 -21
- package/src/utils/asset.ts +118 -217
- package/src/utils/derivationPath.ts +24 -7
- package/src/utils/plugin.ts +1 -1
- package/src/utils/tokens.ts +73 -0
- package/src/utils/validators.ts +3 -2
- package/src/utils/wallets.ts +19 -10
|
@@ -7,7 +7,19 @@ import {
|
|
|
7
7
|
ProviderName,
|
|
8
8
|
WarningCodeEnum,
|
|
9
9
|
} from "@swapkit/helpers";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
type ZodType,
|
|
12
|
+
array,
|
|
13
|
+
boolean,
|
|
14
|
+
nativeEnum,
|
|
15
|
+
number,
|
|
16
|
+
object,
|
|
17
|
+
optional,
|
|
18
|
+
string,
|
|
19
|
+
union,
|
|
20
|
+
unknown,
|
|
21
|
+
type z,
|
|
22
|
+
} from "zod";
|
|
11
23
|
|
|
12
24
|
export enum PriorityLabel {
|
|
13
25
|
CHEAPEST = "CHEAPEST",
|
|
@@ -23,39 +35,38 @@ export enum RouteQuoteTxType {
|
|
|
23
35
|
}
|
|
24
36
|
|
|
25
37
|
export enum TxnType {
|
|
26
|
-
native_send = "native_send",
|
|
27
|
-
token_transfer = "token_transfer",
|
|
28
|
-
native_contract_call = "native_contract_call",
|
|
29
|
-
token_contract_call = "token_contract_call",
|
|
30
|
-
approve = "approve",
|
|
31
|
-
deposit = "deposit",
|
|
32
|
-
thorname_action = "thorname_action",
|
|
33
|
-
lp_action = "lp_action",
|
|
34
|
-
swap = "swap",
|
|
35
|
-
streaming_swap = "streaming_swap",
|
|
36
|
-
stake = "stake",
|
|
37
|
-
claim = "claim",
|
|
38
|
-
lending = "lending",
|
|
38
|
+
native_send = "native_send",
|
|
39
|
+
token_transfer = "token_transfer",
|
|
40
|
+
native_contract_call = "native_contract_call",
|
|
41
|
+
token_contract_call = "token_contract_call",
|
|
42
|
+
approve = "approve",
|
|
43
|
+
deposit = "deposit",
|
|
44
|
+
thorname_action = "thorname_action",
|
|
45
|
+
lp_action = "lp_action",
|
|
46
|
+
swap = "swap",
|
|
47
|
+
streaming_swap = "streaming_swap",
|
|
48
|
+
stake = "stake",
|
|
49
|
+
claim = "claim",
|
|
50
|
+
lending = "lending",
|
|
39
51
|
unknown = "unknown",
|
|
40
52
|
}
|
|
41
53
|
|
|
42
|
-
// transaction status devoid of any business logic
|
|
43
54
|
export enum TxnStatus {
|
|
44
55
|
unknown = "unknown",
|
|
45
56
|
not_started = "not_started",
|
|
46
57
|
pending = "pending",
|
|
47
|
-
|
|
58
|
+
swapping = "swapping",
|
|
48
59
|
completed = "completed",
|
|
49
60
|
}
|
|
50
61
|
|
|
51
62
|
export enum TrackingStatus {
|
|
52
63
|
not_started = "not_started",
|
|
53
|
-
starting = "starting",
|
|
64
|
+
starting = "starting",
|
|
54
65
|
broadcasted = "broadcasted",
|
|
55
|
-
mempool = "mempool",
|
|
66
|
+
mempool = "mempool",
|
|
56
67
|
inbound = "inbound",
|
|
57
68
|
outbound = "outbound",
|
|
58
|
-
swapping = "swapping",
|
|
69
|
+
swapping = "swapping",
|
|
59
70
|
completed = "completed",
|
|
60
71
|
refunded = "refunded",
|
|
61
72
|
partially_refunded = "partially_refunded",
|
|
@@ -134,465 +145,321 @@ export type TrackerResponse = TransactionProps & {
|
|
|
134
145
|
transient?: TxnTransient;
|
|
135
146
|
};
|
|
136
147
|
|
|
137
|
-
export const ApiV2ErrorSchema =
|
|
138
|
-
error:
|
|
139
|
-
message:
|
|
148
|
+
export const ApiV2ErrorSchema = object({
|
|
149
|
+
error: string(),
|
|
150
|
+
message: string(),
|
|
140
151
|
});
|
|
141
152
|
|
|
142
|
-
export const AssetValueSchema =
|
|
143
|
-
chain:
|
|
144
|
-
symbol:
|
|
145
|
-
ticker:
|
|
146
|
-
decimal:
|
|
147
|
-
address:
|
|
148
|
-
isGasAsset:
|
|
149
|
-
isSynthetic:
|
|
150
|
-
tax:
|
|
151
|
-
z.object({
|
|
152
|
-
buy: z.number(),
|
|
153
|
-
sell: z.number(),
|
|
154
|
-
}),
|
|
155
|
-
),
|
|
153
|
+
export const AssetValueSchema = object({
|
|
154
|
+
chain: nativeEnum(Chain),
|
|
155
|
+
symbol: string(),
|
|
156
|
+
ticker: string(),
|
|
157
|
+
decimal: optional(number()),
|
|
158
|
+
address: optional(string()),
|
|
159
|
+
isGasAsset: boolean(),
|
|
160
|
+
isSynthetic: boolean(),
|
|
161
|
+
tax: optional(object({ buy: number(), sell: number() })),
|
|
156
162
|
});
|
|
157
163
|
|
|
158
|
-
export const TokenDetailsMetadataSchema =
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
timestamp:
|
|
166
|
-
|
|
164
|
+
export const TokenDetailsMetadataSchema = object({
|
|
165
|
+
id: string(),
|
|
166
|
+
market_cap: number(),
|
|
167
|
+
name: string(),
|
|
168
|
+
price_change_24h_usd: number(),
|
|
169
|
+
price_change_percentage_24h_usd: number(),
|
|
170
|
+
sparkline_in_7d: array(number()),
|
|
171
|
+
timestamp: string(),
|
|
172
|
+
total_volume: number(),
|
|
167
173
|
});
|
|
168
174
|
|
|
169
|
-
export const PriceResponseSchema =
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
})
|
|
178
|
-
.partial(),
|
|
175
|
+
export const PriceResponseSchema = array(
|
|
176
|
+
object({
|
|
177
|
+
identifier: string(),
|
|
178
|
+
provider: string(),
|
|
179
|
+
cg: TokenDetailsMetadataSchema.optional(),
|
|
180
|
+
price_usd: number(),
|
|
181
|
+
timestamp: number(),
|
|
182
|
+
}).partial(),
|
|
179
183
|
);
|
|
180
184
|
|
|
181
185
|
export type PriceResponse = z.infer<typeof PriceResponseSchema>;
|
|
182
186
|
|
|
183
|
-
export const QuoteRequestSchema =
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
.refine((amount) => +amount > 0, {
|
|
196
|
-
message: "sellAmount must be greater than 0",
|
|
197
|
-
path: ["sellAmount"],
|
|
198
|
-
}),
|
|
199
|
-
providers: z.optional(
|
|
200
|
-
z.array(
|
|
201
|
-
z
|
|
202
|
-
.string({
|
|
203
|
-
description: "List of providers to use",
|
|
204
|
-
})
|
|
205
|
-
.refine(
|
|
206
|
-
(provider) => {
|
|
207
|
-
return ProviderName[provider as ProviderName] !== undefined;
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
message: "Invalid provider",
|
|
211
|
-
path: ["providers"],
|
|
212
|
-
},
|
|
213
|
-
),
|
|
187
|
+
export const QuoteRequestSchema = object({
|
|
188
|
+
sellAsset: string({ description: "Asset to sell" }),
|
|
189
|
+
buyAsset: string({ description: "Asset to buy" }),
|
|
190
|
+
sellAmount: string({ description: "Amount of asset to sell" }).refine((amount) => +amount > 0, {
|
|
191
|
+
message: "sellAmount must be greater than 0",
|
|
192
|
+
path: ["sellAmount"],
|
|
193
|
+
}),
|
|
194
|
+
providers: optional(
|
|
195
|
+
array(
|
|
196
|
+
string({ description: "List of providers to use" }).refine(
|
|
197
|
+
(provider) => ProviderName[provider as ProviderName] !== undefined,
|
|
198
|
+
{ message: "Invalid provider", path: ["providers"] },
|
|
214
199
|
),
|
|
215
200
|
),
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
),
|
|
226
|
-
slippage: z.optional(
|
|
227
|
-
z.number({
|
|
228
|
-
description: "Slippage tolerance as a percentage. Default is 3%.",
|
|
229
|
-
}),
|
|
230
|
-
),
|
|
231
|
-
affiliate: z.optional(
|
|
232
|
-
z.string({
|
|
233
|
-
description: "Affiliate thorname",
|
|
234
|
-
}),
|
|
235
|
-
),
|
|
236
|
-
affiliateFee: z.optional(
|
|
237
|
-
z
|
|
238
|
-
.number({
|
|
239
|
-
description: "Affiliate fee in basis points",
|
|
240
|
-
})
|
|
241
|
-
.refine(
|
|
242
|
-
(fee) => {
|
|
243
|
-
return fee === Math.floor(fee) && fee >= 0;
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
message: "affiliateFee must be a positive integer",
|
|
247
|
-
path: ["affiliateFee"],
|
|
248
|
-
},
|
|
249
|
-
),
|
|
250
|
-
),
|
|
251
|
-
allowSmartContractSender: z.optional(
|
|
252
|
-
z.boolean({
|
|
253
|
-
description: "Allow smart contract as sender",
|
|
254
|
-
}),
|
|
255
|
-
),
|
|
256
|
-
allowSmartContractReceiver: z.optional(
|
|
257
|
-
z.boolean({
|
|
258
|
-
description: "Allow smart contract as recipient",
|
|
259
|
-
}),
|
|
260
|
-
),
|
|
261
|
-
disableSecurityChecks: z.optional(
|
|
262
|
-
z.boolean({
|
|
263
|
-
description: "Disable security checks",
|
|
264
|
-
}),
|
|
265
|
-
),
|
|
266
|
-
includeTx: z.optional(
|
|
267
|
-
z.boolean({
|
|
268
|
-
description: "Set to true to include an transaction object (EVM only)",
|
|
269
|
-
}),
|
|
270
|
-
),
|
|
271
|
-
cfBoost: z.optional(
|
|
272
|
-
z.boolean({
|
|
273
|
-
description: "Set to true to enable CF boost to speed up Chainflip swaps. BTC only.",
|
|
274
|
-
}),
|
|
275
|
-
),
|
|
276
|
-
referrer: z.optional(
|
|
277
|
-
z.string({
|
|
278
|
-
description: "Referrer address (referral program)",
|
|
279
|
-
}),
|
|
201
|
+
),
|
|
202
|
+
sourceAddress: optional(string({ description: "Address to send asset from" })),
|
|
203
|
+
destinationAddress: optional(string({ description: "Address to send asset to" })),
|
|
204
|
+
slippage: optional(number({ description: "Slippage tolerance as a percentage. Default is 3%." })),
|
|
205
|
+
affiliate: optional(string({ description: "Affiliate thorname" })),
|
|
206
|
+
affiliateFee: optional(
|
|
207
|
+
number({ description: "Affiliate fee in basis points" }).refine(
|
|
208
|
+
(fee) => fee === Math.floor(fee) && fee >= 0,
|
|
209
|
+
{ message: "affiliateFee must be a positive integer", path: ["affiliateFee"] },
|
|
280
210
|
),
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
211
|
+
),
|
|
212
|
+
allowSmartContractSender: optional(boolean({ description: "Allow smart contract as sender" })),
|
|
213
|
+
allowSmartContractReceiver: optional(
|
|
214
|
+
boolean({ description: "Allow smart contract as recipient" }),
|
|
215
|
+
),
|
|
216
|
+
disableSecurityChecks: optional(boolean({ description: "Disable security checks" })),
|
|
217
|
+
includeTx: optional(
|
|
218
|
+
boolean({ description: "Set to true to include an transaction object (EVM only)" }),
|
|
219
|
+
),
|
|
220
|
+
cfBoost: optional(
|
|
221
|
+
boolean({
|
|
222
|
+
description: "Set to true to enable CF boost to speed up Chainflip swaps. BTC only.",
|
|
223
|
+
}),
|
|
224
|
+
),
|
|
225
|
+
referrer: optional(string({ description: "Referrer address (referral program)" })),
|
|
226
|
+
}).refine((data) => data.sellAsset !== data.buyAsset, {
|
|
227
|
+
message: "Must be different",
|
|
228
|
+
path: ["sellAsset", "buyAsset"],
|
|
229
|
+
});
|
|
286
230
|
|
|
287
231
|
export type QuoteRequest = z.infer<typeof QuoteRequestSchema>;
|
|
288
232
|
|
|
289
|
-
export const PriceRequestSchema =
|
|
290
|
-
tokens:
|
|
291
|
-
|
|
292
|
-
identifier:
|
|
233
|
+
export const PriceRequestSchema = object({
|
|
234
|
+
tokens: array(
|
|
235
|
+
object({
|
|
236
|
+
identifier: string(),
|
|
293
237
|
}),
|
|
294
238
|
),
|
|
295
|
-
metadata:
|
|
239
|
+
metadata: boolean(),
|
|
296
240
|
});
|
|
297
241
|
|
|
298
242
|
export type PriceRequest = z.infer<typeof PriceRequestSchema>;
|
|
299
243
|
|
|
300
|
-
export const BrokerDepositChannelParamsSchema =
|
|
301
|
-
sellAsset:
|
|
302
|
-
chain:
|
|
303
|
-
asset:
|
|
304
|
-
}),
|
|
305
|
-
buyAsset:
|
|
306
|
-
chain:
|
|
307
|
-
asset:
|
|
308
|
-
}),
|
|
309
|
-
destinationAddress:
|
|
310
|
-
channelMetadata:
|
|
311
|
-
.
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
)
|
|
324
|
-
.optional(),
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
dcaParameters: z
|
|
333
|
-
.object({
|
|
334
|
-
chunkInterval: z.number().optional(),
|
|
335
|
-
numberOfChunks: z.number().optional(),
|
|
336
|
-
})
|
|
337
|
-
.optional(),
|
|
338
|
-
brokerCommissionBps: z.number().optional(),
|
|
339
|
-
maxBoostFeeBps: z.number().optional(),
|
|
244
|
+
export const BrokerDepositChannelParamsSchema = object({
|
|
245
|
+
sellAsset: object({
|
|
246
|
+
chain: string(),
|
|
247
|
+
asset: string(),
|
|
248
|
+
}),
|
|
249
|
+
buyAsset: object({
|
|
250
|
+
chain: string(),
|
|
251
|
+
asset: string(), // identifier of the asset
|
|
252
|
+
}),
|
|
253
|
+
destinationAddress: string(),
|
|
254
|
+
channelMetadata: object({
|
|
255
|
+
cfParameters: string().optional(),
|
|
256
|
+
gasBudget: string().optional(),
|
|
257
|
+
message: string().optional(),
|
|
258
|
+
}).optional(),
|
|
259
|
+
affiliateFees: array(
|
|
260
|
+
object({
|
|
261
|
+
brokerAddress: string(),
|
|
262
|
+
feeBps: number(),
|
|
263
|
+
}),
|
|
264
|
+
).optional(),
|
|
265
|
+
refundParameters: object({
|
|
266
|
+
minPrice: string().optional(),
|
|
267
|
+
refundAddress: string().optional(),
|
|
268
|
+
retryDuration: number().optional(),
|
|
269
|
+
}).optional(),
|
|
270
|
+
dcaParameters: object({
|
|
271
|
+
chunkInterval: number().optional(),
|
|
272
|
+
numberOfChunks: number().optional(),
|
|
273
|
+
}).optional(),
|
|
274
|
+
brokerCommissionBps: number().optional(),
|
|
275
|
+
maxBoostFeeBps: number().optional(),
|
|
340
276
|
});
|
|
341
277
|
|
|
342
278
|
export type BrokerDepositChannelParams = z.infer<typeof BrokerDepositChannelParamsSchema>;
|
|
343
279
|
|
|
344
|
-
export const DepositChannelResponseSchema =
|
|
345
|
-
channelId:
|
|
346
|
-
depositAddress:
|
|
280
|
+
export const DepositChannelResponseSchema = object({
|
|
281
|
+
channelId: string(),
|
|
282
|
+
depositAddress: string(),
|
|
347
283
|
});
|
|
348
284
|
|
|
349
285
|
export type DepositChannelResponse = z.infer<typeof DepositChannelResponseSchema>;
|
|
350
286
|
|
|
351
|
-
const TxnPayloadSchema =
|
|
352
|
-
evmCalldata:
|
|
353
|
-
logs:
|
|
354
|
-
memo:
|
|
355
|
-
spender:
|
|
287
|
+
const TxnPayloadSchema = object({
|
|
288
|
+
evmCalldata: optional(string()),
|
|
289
|
+
logs: optional(unknown()),
|
|
290
|
+
memo: optional(string()),
|
|
291
|
+
spender: optional(string()), // used in evm approve transactions
|
|
356
292
|
});
|
|
357
293
|
|
|
358
294
|
export type TxnPayload = z.infer<typeof TxnPayloadSchema>;
|
|
359
295
|
|
|
360
296
|
// props that are most important while the transaction is live
|
|
361
|
-
const TxnTransientSchema =
|
|
362
|
-
|
|
363
|
-
estimatedTimeToComplete:
|
|
364
|
-
updatedAt:
|
|
365
|
-
currentLegIndex:
|
|
366
|
-
providerDetails:
|
|
297
|
+
const TxnTransientSchema = object({
|
|
298
|
+
estimatedFinalisedAt: number(),
|
|
299
|
+
estimatedTimeToComplete: number(),
|
|
300
|
+
updatedAt: number(),
|
|
301
|
+
currentLegIndex: optional(number()),
|
|
302
|
+
providerDetails: optional(unknown()), // see ProviderTransientDetails
|
|
367
303
|
});
|
|
368
304
|
|
|
369
305
|
export type TxnTransient = z.infer<typeof TxnTransientSchema>;
|
|
370
306
|
|
|
371
|
-
const TransactionFeesSchema =
|
|
372
|
-
network:
|
|
373
|
-
affiliate:
|
|
374
|
-
liquidity:
|
|
375
|
-
protocol:
|
|
376
|
-
tax:
|
|
307
|
+
const TransactionFeesSchema = object({
|
|
308
|
+
network: optional(AssetValueSchema), // gas on ethereum, network fee on thorchain, etc.
|
|
309
|
+
affiliate: optional(AssetValueSchema), // e.g. affiliate in memo, other affiliate mechanisms
|
|
310
|
+
liquidity: optional(AssetValueSchema), // fee paid to pool
|
|
311
|
+
protocol: optional(AssetValueSchema), // extra protocol fees (TS dex aggregation contracts, stargate fees, etc.)
|
|
312
|
+
tax: optional(AssetValueSchema), // taxed tokens
|
|
377
313
|
});
|
|
378
314
|
|
|
379
315
|
export type TransactionFees = z.infer<typeof TransactionFeesSchema>;
|
|
380
316
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
chain: z.optional(z.string()),
|
|
317
|
+
const TxnMetaSchema = object({
|
|
318
|
+
broadcastedAt: optional(number()),
|
|
319
|
+
wallet: optional(string()),
|
|
320
|
+
quoteId: optional(string()),
|
|
321
|
+
explorerUrl: optional(string()),
|
|
322
|
+
affiliate: optional(string()),
|
|
323
|
+
fees: optional(TransactionFeesSchema),
|
|
324
|
+
provider: optional(nativeEnum(ProviderName)),
|
|
325
|
+
images: optional(
|
|
326
|
+
object({
|
|
327
|
+
from: optional(string()),
|
|
328
|
+
to: optional(string()),
|
|
329
|
+
provider: optional(string()),
|
|
330
|
+
chain: optional(string()),
|
|
396
331
|
}),
|
|
397
332
|
),
|
|
398
333
|
});
|
|
399
334
|
|
|
400
335
|
export type TxnMeta = z.infer<typeof TxnMetaSchema>;
|
|
401
336
|
|
|
402
|
-
const TransactionLegDTOSchema =
|
|
403
|
-
chainId:
|
|
404
|
-
hash:
|
|
405
|
-
block:
|
|
406
|
-
type:
|
|
407
|
-
status:
|
|
408
|
-
trackingStatus:
|
|
409
|
-
|
|
410
|
-
fromAsset:
|
|
411
|
-
fromAmount:
|
|
412
|
-
fromAddress:
|
|
413
|
-
toAsset:
|
|
414
|
-
toAmount:
|
|
415
|
-
toAddress:
|
|
416
|
-
finalAsset:
|
|
417
|
-
finalAddress:
|
|
418
|
-
|
|
419
|
-
finalisedAt:
|
|
420
|
-
|
|
421
|
-
transient:
|
|
422
|
-
meta:
|
|
423
|
-
payload:
|
|
337
|
+
const TransactionLegDTOSchema = object({
|
|
338
|
+
chainId: nativeEnum(ChainId),
|
|
339
|
+
hash: string(),
|
|
340
|
+
block: number(),
|
|
341
|
+
type: nativeEnum(TxnType),
|
|
342
|
+
status: nativeEnum(TxnStatus),
|
|
343
|
+
trackingStatus: optional(nativeEnum(TrackingStatus)),
|
|
344
|
+
|
|
345
|
+
fromAsset: string(),
|
|
346
|
+
fromAmount: string(),
|
|
347
|
+
fromAddress: string(),
|
|
348
|
+
toAsset: string(),
|
|
349
|
+
toAmount: string(),
|
|
350
|
+
toAddress: string(),
|
|
351
|
+
finalAsset: optional(AssetValueSchema),
|
|
352
|
+
finalAddress: optional(string()),
|
|
353
|
+
|
|
354
|
+
finalisedAt: number(),
|
|
355
|
+
|
|
356
|
+
transient: optional(TxnTransientSchema),
|
|
357
|
+
meta: optional(TxnMetaSchema),
|
|
358
|
+
payload: optional(TxnPayloadSchema),
|
|
424
359
|
});
|
|
425
360
|
|
|
426
361
|
export type TransactionLegDTO = z.infer<typeof TransactionLegDTOSchema>;
|
|
427
362
|
|
|
428
363
|
export const TransactionSchema = TransactionLegDTOSchema.extend({
|
|
429
|
-
legs:
|
|
364
|
+
legs: array(TransactionLegDTOSchema),
|
|
430
365
|
});
|
|
431
366
|
|
|
432
367
|
export type TransactionDTO = z.infer<typeof TransactionLegDTOSchema> & {
|
|
433
368
|
legs: TransactionLegDTO[];
|
|
434
369
|
};
|
|
435
370
|
|
|
436
|
-
export const TransactionDTOSchema:
|
|
437
|
-
legs:
|
|
371
|
+
export const TransactionDTOSchema: ZodType<TransactionDTO> = TransactionLegDTOSchema.extend({
|
|
372
|
+
legs: array(TransactionLegDTOSchema),
|
|
438
373
|
});
|
|
439
374
|
|
|
440
|
-
export const FeesSchema =
|
|
441
|
-
|
|
442
|
-
type:
|
|
443
|
-
amount:
|
|
444
|
-
asset:
|
|
445
|
-
chain:
|
|
446
|
-
protocol:
|
|
375
|
+
export const FeesSchema = array(
|
|
376
|
+
object({
|
|
377
|
+
type: nativeEnum(FeeTypeEnum),
|
|
378
|
+
amount: string(),
|
|
379
|
+
asset: string(),
|
|
380
|
+
chain: string(),
|
|
381
|
+
protocol: nativeEnum(ProviderName),
|
|
447
382
|
}),
|
|
448
383
|
);
|
|
449
384
|
|
|
450
385
|
export type Fees = z.infer<typeof FeesSchema>;
|
|
451
386
|
|
|
452
|
-
export const EstimatedTimeSchema =
|
|
453
|
-
inbound:
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
),
|
|
458
|
-
swap: z.optional(
|
|
459
|
-
z.number({
|
|
460
|
-
description: "Time to swap assets in seconds",
|
|
461
|
-
}),
|
|
462
|
-
),
|
|
463
|
-
outbound: z.optional(
|
|
464
|
-
z.number({
|
|
465
|
-
description: "Time to receive outbound asset in seconds",
|
|
466
|
-
}),
|
|
467
|
-
),
|
|
468
|
-
total: z.number({
|
|
469
|
-
description: "Total time in seconds",
|
|
470
|
-
}),
|
|
387
|
+
export const EstimatedTimeSchema = object({
|
|
388
|
+
inbound: optional(number({ description: "Time to receive inbound asset in seconds" })),
|
|
389
|
+
swap: optional(number({ description: "Time to swap assets in seconds" })),
|
|
390
|
+
outbound: optional(number({ description: "Time to receive outbound asset in seconds" })),
|
|
391
|
+
total: number({ description: "Total time in seconds" }),
|
|
471
392
|
});
|
|
472
393
|
|
|
473
394
|
export type EstimatedTime = z.infer<typeof EstimatedTimeSchema>;
|
|
474
395
|
|
|
475
|
-
export const EVMTransactionSchema =
|
|
476
|
-
to:
|
|
477
|
-
|
|
478
|
-
}),
|
|
479
|
-
|
|
480
|
-
description: "Address of the sender",
|
|
481
|
-
}),
|
|
482
|
-
value: z.string({
|
|
483
|
-
description: "Value to send",
|
|
484
|
-
}),
|
|
485
|
-
data: z.string({
|
|
486
|
-
description: "Data to send",
|
|
487
|
-
}),
|
|
396
|
+
export const EVMTransactionSchema = object({
|
|
397
|
+
to: string({ description: "Address of the recipient" }),
|
|
398
|
+
from: string({ description: "Address of the sender" }),
|
|
399
|
+
value: string({ description: "Value to send" }),
|
|
400
|
+
data: string({ description: "Data to send" }),
|
|
488
401
|
});
|
|
489
402
|
|
|
490
403
|
export type EVMTransaction = z.infer<typeof EVMTransactionSchema>;
|
|
491
404
|
|
|
492
|
-
export const EVMTransactionDetailsParamsSchema =
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
})
|
|
502
|
-
.describe("Parameters to pass to the contract method"),
|
|
405
|
+
export const EVMTransactionDetailsParamsSchema = array(
|
|
406
|
+
union([
|
|
407
|
+
string(),
|
|
408
|
+
number(),
|
|
409
|
+
array(string()),
|
|
410
|
+
|
|
411
|
+
object({ from: string(), value: string() }).describe(
|
|
412
|
+
"Parameters to pass to the contract method",
|
|
413
|
+
),
|
|
503
414
|
]),
|
|
504
415
|
);
|
|
505
416
|
|
|
506
417
|
export type EVMTransactionDetailsParams = z.infer<typeof EVMTransactionDetailsParamsSchema>;
|
|
507
418
|
|
|
508
|
-
export const EVMTransactionDetailsSchema =
|
|
509
|
-
contractAddress:
|
|
510
|
-
|
|
511
|
-
}),
|
|
512
|
-
contractMethod: z.string({
|
|
513
|
-
description: "Name of the method to call",
|
|
514
|
-
}),
|
|
419
|
+
export const EVMTransactionDetailsSchema = object({
|
|
420
|
+
contractAddress: string({ description: "Address of the contract to interact with" }),
|
|
421
|
+
contractMethod: string({ description: "Name of the method to call" }),
|
|
515
422
|
contractParams: EVMTransactionDetailsParamsSchema,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
// description:
|
|
519
|
-
// "If making a streaming swap through THORChain, parameters to pass to the contract method",
|
|
520
|
-
// }),
|
|
521
|
-
// ),
|
|
522
|
-
contractParamNames: z.array(
|
|
523
|
-
z.string({
|
|
524
|
-
description: "Names of the parameters to pass to the contract method",
|
|
525
|
-
}),
|
|
526
|
-
),
|
|
527
|
-
approvalToken: z.optional(
|
|
528
|
-
z.string({
|
|
529
|
-
description: "Address of the token to approve spending of",
|
|
530
|
-
}),
|
|
531
|
-
),
|
|
532
|
-
approvalSpender: z.optional(
|
|
533
|
-
z.string({
|
|
534
|
-
description: "Address of the spender to approve",
|
|
535
|
-
}),
|
|
423
|
+
contractParamNames: array(
|
|
424
|
+
string({ description: "Names of the parameters to pass to the contract method" }),
|
|
536
425
|
),
|
|
426
|
+
approvalToken: optional(string({ description: "Address of the token to approve spending of" })),
|
|
427
|
+
approvalSpender: optional(string({ description: "Address of the spender to approve" })),
|
|
537
428
|
});
|
|
538
429
|
|
|
539
430
|
export type EVMTransactionDetails = z.infer<typeof EVMTransactionDetailsSchema>;
|
|
540
431
|
|
|
541
|
-
const EncodeObjectSchema =
|
|
542
|
-
typeUrl:
|
|
543
|
-
value:
|
|
432
|
+
const EncodeObjectSchema = object({
|
|
433
|
+
typeUrl: string(),
|
|
434
|
+
value: unknown(),
|
|
544
435
|
});
|
|
545
436
|
|
|
546
|
-
const FeeSchema =
|
|
547
|
-
amount:
|
|
548
|
-
|
|
549
|
-
denom: z.string(),
|
|
550
|
-
amount: z.string(),
|
|
551
|
-
}),
|
|
552
|
-
),
|
|
553
|
-
gas: z.string(),
|
|
437
|
+
const FeeSchema = object({
|
|
438
|
+
amount: array(object({ denom: string(), amount: string() })),
|
|
439
|
+
gas: string(),
|
|
554
440
|
});
|
|
555
441
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
msgs: z.array(EncodeObjectSchema),
|
|
442
|
+
export const CosmosTransactionSchema = object({
|
|
443
|
+
memo: string(),
|
|
444
|
+
accountNumber: number(),
|
|
445
|
+
sequence: number(),
|
|
446
|
+
chainId: nativeEnum(ChainId),
|
|
447
|
+
msgs: array(EncodeObjectSchema),
|
|
563
448
|
fee: FeeSchema,
|
|
564
449
|
});
|
|
565
450
|
|
|
566
451
|
export type CosmosTransaction = z.infer<typeof CosmosTransactionSchema>;
|
|
567
452
|
|
|
568
|
-
export const RouteLegSchema =
|
|
569
|
-
sellAsset:
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
}),
|
|
575
|
-
provider: z.nativeEnum(ProviderName),
|
|
576
|
-
sourceAddress: z.string({
|
|
577
|
-
description: "Source address",
|
|
578
|
-
}),
|
|
579
|
-
destinationAddress: z.string({
|
|
580
|
-
description: "Destination address",
|
|
581
|
-
}),
|
|
453
|
+
export const RouteLegSchema = object({
|
|
454
|
+
sellAsset: string({ description: "Asset to sell" }),
|
|
455
|
+
buyAsset: string({ description: "Asset to buy" }),
|
|
456
|
+
provider: nativeEnum(ProviderName),
|
|
457
|
+
sourceAddress: string({ description: "Source address" }),
|
|
458
|
+
destinationAddress: string({ description: "Destination address" }),
|
|
582
459
|
estimatedTime: EstimatedTimeSchema.optional(),
|
|
583
|
-
affiliate:
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
})
|
|
587
|
-
.optional(),
|
|
588
|
-
affiliateFee: z
|
|
589
|
-
.number({
|
|
590
|
-
description: "Affiliate fee",
|
|
591
|
-
})
|
|
592
|
-
.optional(),
|
|
593
|
-
slipPercentage: z.number({
|
|
594
|
-
description: "Slippage as a percentage",
|
|
595
|
-
}),
|
|
460
|
+
affiliate: string({ description: "Affiliate address" }).optional(),
|
|
461
|
+
affiliateFee: number({ description: "Affiliate fee" }).optional(),
|
|
462
|
+
slipPercentage: number({ description: "Slippage as a percentage" }),
|
|
596
463
|
});
|
|
597
464
|
|
|
598
465
|
export type RouteLeg = z.infer<typeof RouteLegSchema>;
|
|
@@ -605,16 +472,10 @@ export const RouteLegWithoutAddressesSchema = RouteLegSchema.omit({
|
|
|
605
472
|
|
|
606
473
|
export type RouteLegWithoutAddresses = z.infer<typeof RouteLegWithoutAddressesSchema>;
|
|
607
474
|
|
|
608
|
-
export const RouteQuoteMetadataAssetSchema =
|
|
609
|
-
asset:
|
|
610
|
-
|
|
611
|
-
}),
|
|
612
|
-
price: z.number({
|
|
613
|
-
description: "Price in USD",
|
|
614
|
-
}),
|
|
615
|
-
image: z.string({
|
|
616
|
-
description: "Asset image",
|
|
617
|
-
}),
|
|
475
|
+
export const RouteQuoteMetadataAssetSchema = object({
|
|
476
|
+
asset: string({ description: "Asset name" }),
|
|
477
|
+
price: number({ description: "Price in USD" }),
|
|
478
|
+
image: string({ description: "Asset image" }),
|
|
618
479
|
});
|
|
619
480
|
|
|
620
481
|
export type RouteQuoteMetadataAsset = z.infer<typeof RouteQuoteMetadataAssetSchema>;
|
|
@@ -623,133 +484,69 @@ export const ChainflipMetadataSchema = BrokerDepositChannelParamsSchema;
|
|
|
623
484
|
|
|
624
485
|
export type ChainflipMetadata = z.infer<typeof ChainflipMetadataSchema>;
|
|
625
486
|
|
|
626
|
-
export const RouteQuoteMetadataSchema =
|
|
627
|
-
priceImpact:
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
),
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
),
|
|
638
|
-
streamingInterval: z.number().optional(),
|
|
639
|
-
maxStreamingQuantity: z.number().optional(),
|
|
640
|
-
tags: z.array(z.nativeEnum(PriorityLabel)),
|
|
641
|
-
|
|
642
|
-
affiliate: z.optional(z.string()),
|
|
643
|
-
affiliateFee: z.optional(z.string()),
|
|
644
|
-
|
|
645
|
-
txType: z.optional(z.nativeEnum(RouteQuoteTxType)),
|
|
646
|
-
chainflip: z.optional(ChainflipMetadataSchema),
|
|
647
|
-
referrer: z.optional(z.string()),
|
|
487
|
+
export const RouteQuoteMetadataSchema = object({
|
|
488
|
+
priceImpact: optional(number({ description: "Price impact" })),
|
|
489
|
+
assets: optional(array(RouteQuoteMetadataAssetSchema)),
|
|
490
|
+
approvalAddress: optional(string({ description: "Approval address for swap" })),
|
|
491
|
+
streamingInterval: number().optional(),
|
|
492
|
+
maxStreamingQuantity: number().optional(),
|
|
493
|
+
tags: array(nativeEnum(PriorityLabel)),
|
|
494
|
+
affiliate: optional(string()),
|
|
495
|
+
affiliateFee: optional(string()),
|
|
496
|
+
txType: optional(nativeEnum(RouteQuoteTxType)),
|
|
497
|
+
chainflip: optional(ChainflipMetadataSchema),
|
|
498
|
+
referrer: optional(string()),
|
|
648
499
|
});
|
|
649
500
|
|
|
650
|
-
export const RouteQuoteWarningSchema =
|
|
651
|
-
|
|
652
|
-
code: z.nativeEnum(WarningCodeEnum),
|
|
653
|
-
display: z.string(),
|
|
654
|
-
tooltip: z.string().optional(),
|
|
655
|
-
}),
|
|
501
|
+
export const RouteQuoteWarningSchema = array(
|
|
502
|
+
object({ code: nativeEnum(WarningCodeEnum), display: string(), tooltip: string().optional() }),
|
|
656
503
|
);
|
|
657
504
|
|
|
658
505
|
export type RouteQuoteWarning = z.infer<typeof RouteQuoteWarningSchema>;
|
|
659
506
|
|
|
660
|
-
const QuoteResponseRouteLegItem =
|
|
661
|
-
provider:
|
|
662
|
-
sellAsset:
|
|
663
|
-
|
|
664
|
-
}),
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
buyAsset: z.string({
|
|
669
|
-
description: "Asset to buy",
|
|
670
|
-
}),
|
|
671
|
-
buyAmount: z.string({
|
|
672
|
-
description: "Buy amount",
|
|
673
|
-
}),
|
|
674
|
-
buyAmountMaxSlippage: z.string({
|
|
675
|
-
description: "Buy amount max slippage",
|
|
676
|
-
}),
|
|
677
|
-
fees: z.optional(FeesSchema), // TODO remove optionality
|
|
507
|
+
const QuoteResponseRouteLegItem = object({
|
|
508
|
+
provider: nativeEnum(ProviderName),
|
|
509
|
+
sellAsset: string({ description: "Asset to sell" }),
|
|
510
|
+
sellAmount: string({ description: "Sell amount" }),
|
|
511
|
+
buyAsset: string({ description: "Asset to buy" }),
|
|
512
|
+
buyAmount: string({ description: "Buy amount" }),
|
|
513
|
+
buyAmountMaxSlippage: string({ description: "Buy amount max slippage" }),
|
|
514
|
+
fees: optional(FeesSchema),
|
|
678
515
|
});
|
|
679
516
|
|
|
680
|
-
const QuoteResponseRouteItem =
|
|
681
|
-
providers:
|
|
682
|
-
sellAsset:
|
|
683
|
-
|
|
684
|
-
}),
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}),
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}),
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}),
|
|
694
|
-
expectedBuyAmountMaxSlippage: z.string({
|
|
695
|
-
description: "Expected Buy amount max slippage",
|
|
696
|
-
}),
|
|
697
|
-
sourceAddress: z.string({
|
|
698
|
-
description: "Source address",
|
|
699
|
-
}),
|
|
700
|
-
destinationAddress: z.string({
|
|
701
|
-
description: "Destination address",
|
|
702
|
-
}),
|
|
703
|
-
targetAddress: z.optional(
|
|
704
|
-
z.string({
|
|
705
|
-
description: "Target address",
|
|
706
|
-
}),
|
|
707
|
-
),
|
|
708
|
-
inboundAddress: z.optional(
|
|
709
|
-
z.string({
|
|
710
|
-
description: "Inbound address",
|
|
711
|
-
}),
|
|
712
|
-
),
|
|
713
|
-
expiration: z.optional(
|
|
714
|
-
z.string({
|
|
715
|
-
description: "Expiration",
|
|
716
|
-
}),
|
|
717
|
-
),
|
|
718
|
-
memo: z.optional(
|
|
719
|
-
z.string({
|
|
720
|
-
description: "Memo",
|
|
721
|
-
}),
|
|
722
|
-
),
|
|
517
|
+
const QuoteResponseRouteItem = object({
|
|
518
|
+
providers: array(nativeEnum(ProviderName)),
|
|
519
|
+
sellAsset: string({ description: "Asset to sell" }),
|
|
520
|
+
sellAmount: string({ description: "Sell amount" }),
|
|
521
|
+
buyAsset: string({ description: "Asset to buy" }),
|
|
522
|
+
expectedBuyAmount: string({ description: "Expected Buy amount" }),
|
|
523
|
+
expectedBuyAmountMaxSlippage: string({ description: "Expected Buy amount max slippage" }),
|
|
524
|
+
sourceAddress: string({ description: "Source address" }),
|
|
525
|
+
destinationAddress: string({ description: "Destination address" }),
|
|
526
|
+
targetAddress: optional(string({ description: "Target address" })),
|
|
527
|
+
inboundAddress: optional(string({ description: "Inbound address" })),
|
|
528
|
+
expiration: optional(string({ description: "Expiration" })),
|
|
529
|
+
memo: optional(string({ description: "Memo" })),
|
|
723
530
|
fees: FeesSchema,
|
|
724
|
-
txType:
|
|
725
|
-
tx:
|
|
726
|
-
estimatedTime:
|
|
727
|
-
totalSlippageBps:
|
|
728
|
-
|
|
729
|
-
}),
|
|
730
|
-
legs: z.array(QuoteResponseRouteLegItem),
|
|
531
|
+
txType: optional(nativeEnum(RouteQuoteTxType)),
|
|
532
|
+
tx: optional(union([EVMTransactionSchema, CosmosTransactionSchema, string()])),
|
|
533
|
+
estimatedTime: optional(EstimatedTimeSchema),
|
|
534
|
+
totalSlippageBps: number({ description: "Total slippage in bps" }),
|
|
535
|
+
legs: array(QuoteResponseRouteLegItem),
|
|
731
536
|
warnings: RouteQuoteWarningSchema,
|
|
732
537
|
meta: RouteQuoteMetadataSchema,
|
|
733
538
|
});
|
|
734
539
|
|
|
735
|
-
export const QuoteResponseSchema =
|
|
736
|
-
quoteId:
|
|
737
|
-
|
|
738
|
-
}),
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
),
|
|
746
|
-
// errors from providers
|
|
747
|
-
providerErrors: z.optional(
|
|
748
|
-
z.array(
|
|
749
|
-
z.object({
|
|
750
|
-
provider: z.nativeEnum(ProviderName).optional(),
|
|
751
|
-
errorCode: z.optional(z.nativeEnum(ErrorCode)),
|
|
752
|
-
message: z.optional(z.string()),
|
|
540
|
+
export const QuoteResponseSchema = object({
|
|
541
|
+
quoteId: string({ description: "Quote ID" }),
|
|
542
|
+
routes: array(QuoteResponseRouteItem),
|
|
543
|
+
error: optional(string({ description: "Error message" })),
|
|
544
|
+
providerErrors: optional(
|
|
545
|
+
array(
|
|
546
|
+
object({
|
|
547
|
+
provider: nativeEnum(ProviderName).optional(),
|
|
548
|
+
errorCode: optional(nativeEnum(ErrorCode)),
|
|
549
|
+
message: optional(string()),
|
|
753
550
|
}),
|
|
754
551
|
),
|
|
755
552
|
),
|
|
@@ -759,14 +556,21 @@ export type QuoteResponse = z.infer<typeof QuoteResponseSchema>;
|
|
|
759
556
|
export type QuoteResponseRoute = z.infer<typeof QuoteResponseRouteItem>;
|
|
760
557
|
export type QuoteResponseRouteLeg = z.infer<typeof QuoteResponseRouteLegItem>;
|
|
761
558
|
|
|
762
|
-
export const GasResponseSchema =
|
|
763
|
-
|
|
764
|
-
id: z.number(),
|
|
765
|
-
chainId: z.string(),
|
|
766
|
-
value: z.string(),
|
|
767
|
-
unit: z.string(),
|
|
768
|
-
createdAt: z.string(),
|
|
769
|
-
}),
|
|
559
|
+
export const GasResponseSchema = array(
|
|
560
|
+
object({ id: number(), chainId: string(), value: string(), unit: string(), createdAt: string() }),
|
|
770
561
|
);
|
|
771
562
|
|
|
772
563
|
export type GasResponse = z.infer<typeof GasResponseSchema>;
|
|
564
|
+
|
|
565
|
+
const BalanceResponseSchema = array(
|
|
566
|
+
object({
|
|
567
|
+
chain: nativeEnum(Chain),
|
|
568
|
+
decimal: number(),
|
|
569
|
+
ticker: string(),
|
|
570
|
+
symbol: string(),
|
|
571
|
+
value: string(),
|
|
572
|
+
identifier: string(),
|
|
573
|
+
}),
|
|
574
|
+
);
|
|
575
|
+
|
|
576
|
+
export type BalanceResponse = z.infer<typeof BalanceResponseSchema>;
|