@chainflip/sdk 1.7.0 → 1.8.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/chunk-HBQFFIRA.mjs +292 -0
- package/dist/{contracts-Bgib7w_h.d.mts → enums-_AFEOA70.d.mts} +1 -10
- package/dist/{contracts-Bgib7w_h.d.ts → enums-_AFEOA70.d.ts} +1 -10
- package/dist/funding.d.mts +10 -1
- package/dist/funding.d.ts +10 -1
- package/dist/funding.js +89 -233
- package/dist/funding.mjs +832 -43
- package/dist/swap.d.mts +86 -65
- package/dist/swap.d.ts +86 -65
- package/dist/swap.js +628 -2127
- package/dist/swap.mjs +474 -568
- package/package.json +11 -11
- package/dist/chunk-KLBPIDTY.mjs +0 -2373
package/dist/swap.js
CHANGED
|
@@ -4,16 +4,17 @@ var client = require('@trpc/client');
|
|
|
4
4
|
var superjson = require('superjson');
|
|
5
5
|
var rpc = require('@chainflip/rpc');
|
|
6
6
|
var ss582 = require('@chainflip/utils/ss58');
|
|
7
|
+
var string$1 = require('@chainflip/utils/string');
|
|
8
|
+
var tickMath = require('@chainflip/utils/tickMath');
|
|
9
|
+
var BigNumber2 = require('bignumber.js');
|
|
7
10
|
var zod = require('zod');
|
|
8
11
|
var bitcoin = require('@chainflip/bitcoin');
|
|
9
12
|
var solana = require('@chainflip/solana');
|
|
10
13
|
var base58 = require('@chainflip/utils/base58');
|
|
11
14
|
var bytes = require('@chainflip/utils/bytes');
|
|
12
|
-
var string$1 = require('@chainflip/utils/string');
|
|
13
15
|
var ethers = require('ethers');
|
|
14
16
|
var address = require('@chainflip/solana/address');
|
|
15
17
|
var number$1 = require('@chainflip/utils/number');
|
|
16
|
-
var BigNumber = require('bignumber.js');
|
|
17
18
|
var axios = require('axios');
|
|
18
19
|
|
|
19
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -38,22 +39,47 @@ function _interopNamespace(e) {
|
|
|
38
39
|
|
|
39
40
|
var superjson__default = /*#__PURE__*/_interopDefault(superjson);
|
|
40
41
|
var ss582__namespace = /*#__PURE__*/_interopNamespace(ss582);
|
|
42
|
+
var BigNumber2__default = /*#__PURE__*/_interopDefault(BigNumber2);
|
|
41
43
|
var bitcoin__namespace = /*#__PURE__*/_interopNamespace(bitcoin);
|
|
42
44
|
var base58__namespace = /*#__PURE__*/_interopNamespace(base58);
|
|
43
45
|
var ethers__namespace = /*#__PURE__*/_interopNamespace(ethers);
|
|
44
|
-
var BigNumber__default = /*#__PURE__*/_interopDefault(BigNumber);
|
|
45
46
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var
|
|
48
|
+
// src/swap/sdk.ts
|
|
49
|
+
|
|
50
|
+
// ../shared/src/guards.ts
|
|
51
|
+
var isString = (value) => typeof value === "string";
|
|
52
|
+
var isNotNullish = (value) => value !== null && value !== void 0;
|
|
53
|
+
function assert(condition, message, Constructor = Error) {
|
|
54
|
+
if (condition) return;
|
|
55
|
+
const error = new Constructor(message);
|
|
56
|
+
if (error.stack) {
|
|
57
|
+
error.stack = error.stack.replace(/\n.+/, "\n");
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ../shared/src/strings.ts
|
|
63
|
+
var toCamelCase = (str) => str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
64
|
+
|
|
65
|
+
// ../shared/src/objects.ts
|
|
66
|
+
var transformKeysToCamelCase = (obj) => {
|
|
67
|
+
if (Array.isArray(obj)) {
|
|
68
|
+
return obj.map(transformKeysToCamelCase);
|
|
69
|
+
}
|
|
70
|
+
if (obj !== null && typeof obj === "object") {
|
|
71
|
+
return Object.fromEntries(
|
|
72
|
+
Object.entries(obj).map(([key, value]) => [
|
|
73
|
+
toCamelCase(key),
|
|
74
|
+
transformKeysToCamelCase(value)
|
|
75
|
+
])
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return obj;
|
|
79
|
+
};
|
|
51
80
|
|
|
52
81
|
// ../shared/src/enums.ts
|
|
53
|
-
var arrayToMap =
|
|
54
|
-
key,
|
|
55
|
-
key
|
|
56
|
-
])), "arrayToMap");
|
|
82
|
+
var arrayToMap = (array) => Object.fromEntries(array.map((key) => [key, key]));
|
|
57
83
|
var InternalAssets = arrayToMap([
|
|
58
84
|
"Flip",
|
|
59
85
|
"Usdc",
|
|
@@ -66,29 +92,10 @@ var InternalAssets = arrayToMap([
|
|
|
66
92
|
"Sol",
|
|
67
93
|
"SolUsdc"
|
|
68
94
|
]);
|
|
69
|
-
var Chains = arrayToMap([
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"Arbitrum",
|
|
74
|
-
"Solana"
|
|
75
|
-
]);
|
|
76
|
-
var Assets = arrayToMap([
|
|
77
|
-
"FLIP",
|
|
78
|
-
"USDC",
|
|
79
|
-
"DOT",
|
|
80
|
-
"ETH",
|
|
81
|
-
"BTC",
|
|
82
|
-
"USDT",
|
|
83
|
-
"SOL"
|
|
84
|
-
]);
|
|
85
|
-
var ChainflipNetworks = arrayToMap([
|
|
86
|
-
"backspin",
|
|
87
|
-
"sisyphos",
|
|
88
|
-
"perseverance",
|
|
89
|
-
"mainnet"
|
|
90
|
-
]);
|
|
91
|
-
var isTestnet = /* @__PURE__ */ __name((network) => network !== ChainflipNetworks.mainnet, "isTestnet");
|
|
95
|
+
var Chains = arrayToMap(["Bitcoin", "Ethereum", "Polkadot", "Arbitrum", "Solana"]);
|
|
96
|
+
var Assets = arrayToMap(["FLIP", "USDC", "DOT", "ETH", "BTC", "USDT", "SOL"]);
|
|
97
|
+
var ChainflipNetworks = arrayToMap(["backspin", "sisyphos", "perseverance", "mainnet"]);
|
|
98
|
+
var isTestnet = (network) => network !== ChainflipNetworks.mainnet;
|
|
92
99
|
var assetConstants = {
|
|
93
100
|
[InternalAssets.Eth]: {
|
|
94
101
|
chain: Chains.Ethereum,
|
|
@@ -163,46 +170,31 @@ var assetConstants = {
|
|
|
163
170
|
};
|
|
164
171
|
var chainConstants = {
|
|
165
172
|
[Chains.Ethereum]: {
|
|
166
|
-
assets: [
|
|
167
|
-
Assets.ETH,
|
|
168
|
-
Assets.FLIP,
|
|
169
|
-
Assets.USDC,
|
|
170
|
-
Assets.USDT
|
|
171
|
-
],
|
|
173
|
+
assets: [Assets.ETH, Assets.FLIP, Assets.USDC, Assets.USDT],
|
|
172
174
|
gasAsset: InternalAssets.Eth,
|
|
173
175
|
contractId: 1,
|
|
174
176
|
blockTimeSeconds: 12
|
|
175
177
|
},
|
|
176
178
|
[Chains.Polkadot]: {
|
|
177
|
-
assets: [
|
|
178
|
-
Assets.DOT
|
|
179
|
-
],
|
|
179
|
+
assets: [Assets.DOT],
|
|
180
180
|
gasAsset: InternalAssets.Dot,
|
|
181
181
|
contractId: 2,
|
|
182
182
|
blockTimeSeconds: 6
|
|
183
183
|
},
|
|
184
184
|
[Chains.Bitcoin]: {
|
|
185
|
-
assets: [
|
|
186
|
-
Assets.BTC
|
|
187
|
-
],
|
|
185
|
+
assets: [Assets.BTC],
|
|
188
186
|
gasAsset: InternalAssets.Btc,
|
|
189
187
|
contractId: 3,
|
|
190
188
|
blockTimeSeconds: 10 * 60
|
|
191
189
|
},
|
|
192
190
|
[Chains.Arbitrum]: {
|
|
193
|
-
assets: [
|
|
194
|
-
Assets.ETH,
|
|
195
|
-
Assets.USDC
|
|
196
|
-
],
|
|
191
|
+
assets: [Assets.ETH, Assets.USDC],
|
|
197
192
|
gasAsset: InternalAssets.ArbEth,
|
|
198
193
|
contractId: 4,
|
|
199
194
|
blockTimeSeconds: 0.26
|
|
200
195
|
},
|
|
201
196
|
[Chains.Solana]: {
|
|
202
|
-
assets: [
|
|
203
|
-
Assets.SOL,
|
|
204
|
-
Assets.USDC
|
|
205
|
-
],
|
|
197
|
+
assets: [Assets.SOL, Assets.USDC],
|
|
206
198
|
gasAsset: InternalAssets.Sol,
|
|
207
199
|
contractId: 5,
|
|
208
200
|
blockTimeSeconds: (400 + 800) / 2 / 1e3
|
|
@@ -214,12 +206,11 @@ function isValidAssetAndChain(assetAndChain2) {
|
|
|
214
206
|
const validAssets = chainConstants[chain2].assets;
|
|
215
207
|
return validAssets.includes(asset2);
|
|
216
208
|
}
|
|
217
|
-
|
|
218
|
-
var readChainAssetValue = /* @__PURE__ */ __name((map, asset2) => {
|
|
209
|
+
var readChainAssetValue = (map, asset2) => {
|
|
219
210
|
const { chain: chain2, asset: symbol } = assetConstants[asset2];
|
|
220
211
|
const chainValues = map[chain2];
|
|
221
212
|
return chainValues[symbol];
|
|
222
|
-
}
|
|
213
|
+
};
|
|
223
214
|
function getInternalAsset(asset2, assert3 = true) {
|
|
224
215
|
if (!isValidAssetAndChain(asset2)) {
|
|
225
216
|
if (assert3) {
|
|
@@ -252,59 +243,34 @@ function getInternalAsset(asset2, assert3 = true) {
|
|
|
252
243
|
const chain2 = map[asset2.chain];
|
|
253
244
|
return chain2[asset2.asset];
|
|
254
245
|
}
|
|
255
|
-
|
|
256
|
-
|
|
246
|
+
function getInternalAssets({
|
|
247
|
+
srcAsset,
|
|
248
|
+
srcChain,
|
|
249
|
+
destAsset,
|
|
250
|
+
destChain
|
|
251
|
+
}, assert3 = true) {
|
|
257
252
|
return {
|
|
258
|
-
srcAsset: getInternalAsset({
|
|
259
|
-
|
|
260
|
-
chain: srcChain
|
|
261
|
-
}, assert3),
|
|
262
|
-
destAsset: getInternalAsset({
|
|
263
|
-
asset: destAsset,
|
|
264
|
-
chain: destChain
|
|
265
|
-
}, assert3)
|
|
253
|
+
srcAsset: getInternalAsset({ asset: srcAsset, chain: srcChain }, assert3),
|
|
254
|
+
destAsset: getInternalAsset({ asset: destAsset, chain: destChain }, assert3)
|
|
266
255
|
};
|
|
267
256
|
}
|
|
268
|
-
__name(getInternalAssets, "getInternalAssets");
|
|
269
257
|
function getAssetAndChain(internalAsset, prefix) {
|
|
270
258
|
const { chain: chain2, asset: asset2 } = assetConstants[internalAsset];
|
|
271
|
-
|
|
272
|
-
return {
|
|
273
|
-
[`${prefix}Asset`]: asset2,
|
|
274
|
-
[`${prefix}Chain`]: chain2
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
return {
|
|
278
|
-
chain: chain2,
|
|
279
|
-
asset: asset2
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
__name(getAssetAndChain, "getAssetAndChain");
|
|
283
|
-
|
|
284
|
-
// ../shared/src/guards.ts
|
|
285
|
-
var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
|
|
286
|
-
var isNotNullish = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isNotNullish");
|
|
287
|
-
function assert(condition, message, Constructor = Error) {
|
|
288
|
-
if (condition) return;
|
|
289
|
-
const error = new Constructor(message);
|
|
290
|
-
if (error.stack) {
|
|
291
|
-
error.stack = error.stack.replace(/\n.+/, "\n");
|
|
292
|
-
}
|
|
293
|
-
throw error;
|
|
259
|
+
return { chain: chain2, asset: asset2 };
|
|
294
260
|
}
|
|
295
|
-
|
|
296
|
-
|
|
261
|
+
var validatePolkadotAddress = (address) => {
|
|
262
|
+
if (string$1.isHex(address)) return address.length === 66;
|
|
297
263
|
try {
|
|
298
264
|
ss582__namespace.decode(address);
|
|
299
265
|
return true;
|
|
300
266
|
} catch {
|
|
301
267
|
return false;
|
|
302
268
|
}
|
|
303
|
-
}
|
|
304
|
-
var validateEvmAddress =
|
|
305
|
-
var validateBitcoinMainnetAddress =
|
|
306
|
-
var validateBitcoinTestnetAddress =
|
|
307
|
-
var validateBitcoinRegtestAddress =
|
|
269
|
+
};
|
|
270
|
+
var validateEvmAddress = (address) => ethers__namespace.isAddress(address);
|
|
271
|
+
var validateBitcoinMainnetAddress = (address) => bitcoin__namespace.isValidAddressForNetwork(address, "mainnet");
|
|
272
|
+
var validateBitcoinTestnetAddress = (address) => bitcoin__namespace.isValidAddressForNetwork(address, "testnet");
|
|
273
|
+
var validateBitcoinRegtestAddress = (address) => bitcoin__namespace.isValidAddressForNetwork(address, "regtest");
|
|
308
274
|
var validateSolanaAddress = address.isValidSolanaAddress;
|
|
309
275
|
var validators = {
|
|
310
276
|
mainnet: {
|
|
@@ -343,90 +309,52 @@ var validators = {
|
|
|
343
309
|
Solana: validateSolanaAddress
|
|
344
310
|
}
|
|
345
311
|
};
|
|
346
|
-
var
|
|
312
|
+
var validateAddress = (chain2, address, network) => validators[network][chain2](address);
|
|
347
313
|
|
|
348
314
|
// ../shared/src/parsers.ts
|
|
349
315
|
var chainflipSS58Prefix = 2112;
|
|
350
316
|
var enumValues = Object.values;
|
|
351
|
-
var safeStringify =
|
|
352
|
-
var errorMap =
|
|
317
|
+
var safeStringify = (obj) => JSON.stringify(obj, (key, value) => typeof value === "bigint" ? value.toString() : value);
|
|
318
|
+
var errorMap = (_issue, context) => ({
|
|
353
319
|
message: `received: ${safeStringify(context.data)}`
|
|
354
|
-
}), "errorMap");
|
|
355
|
-
var string = zod.z.string({
|
|
356
|
-
errorMap
|
|
357
|
-
});
|
|
358
|
-
var number = zod.z.number({
|
|
359
|
-
errorMap
|
|
360
320
|
});
|
|
321
|
+
var string = zod.z.string({ errorMap });
|
|
322
|
+
var number = zod.z.number({ errorMap });
|
|
361
323
|
var booleanString = string.regex(/^(true|false)$/i).transform((v) => v.toLowerCase() === "true");
|
|
362
324
|
var numericString = string.regex(/^[0-9]+$/);
|
|
363
325
|
var numericOrEmptyString = string.regex(/^[0-9]*$/);
|
|
364
326
|
var hexString = string.refine((v) => /^0x[0-9a-f]*$/i.test(v));
|
|
365
|
-
var hexStringWithMaxByteSize =
|
|
327
|
+
var hexStringWithMaxByteSize = (maxByteSize) => hexString.refine((val) => val.length / 2 <= maxByteSize + 1, {
|
|
366
328
|
message: `String must be less than or equal to ${maxByteSize} bytes`
|
|
367
|
-
})
|
|
368
|
-
var btcAddress = /* @__PURE__ */ __name((network) => {
|
|
369
|
-
if (network === "mainnet") {
|
|
370
|
-
return string.regex(/^(1|3|bc1)/).refine(validateBitcoinMainnetAddress, (address) => ({
|
|
371
|
-
message: `"${address}" is not a valid Bitcoin mainnet address`
|
|
372
|
-
}));
|
|
373
|
-
}
|
|
374
|
-
return zod.z.union([
|
|
375
|
-
string.regex(/^(m|n|2|tb1)/).refine(validateBitcoinTestnetAddress, (address) => ({
|
|
376
|
-
message: `"${address}" is not a valid Bitcoin testnet address`
|
|
377
|
-
})),
|
|
378
|
-
string.regex(/^bcrt1/).refine(validateBitcoinRegtestAddress, (address) => ({
|
|
379
|
-
message: `"${address}" is not a valid Bitcoin regtest address`
|
|
380
|
-
}))
|
|
381
|
-
]);
|
|
382
|
-
}, "btcAddress");
|
|
329
|
+
});
|
|
383
330
|
var DOT_PREFIX = 0;
|
|
384
|
-
|
|
385
|
-
string,
|
|
386
|
-
hexString
|
|
387
|
-
]).transform((arg) => {
|
|
331
|
+
zod.z.union([string, hexString]).transform((arg) => {
|
|
388
332
|
try {
|
|
389
333
|
if (arg.startsWith("0x")) {
|
|
390
|
-
return ss582__namespace.encode({
|
|
391
|
-
data: arg,
|
|
392
|
-
ss58Format: DOT_PREFIX
|
|
393
|
-
});
|
|
334
|
+
return ss582__namespace.encode({ data: arg, ss58Format: DOT_PREFIX });
|
|
394
335
|
}
|
|
395
|
-
return ss582__namespace.encode({
|
|
396
|
-
data: ss582__namespace.decode(arg).data,
|
|
397
|
-
ss58Format: DOT_PREFIX
|
|
398
|
-
});
|
|
336
|
+
return ss582__namespace.encode({ data: ss582__namespace.decode(arg).data, ss58Format: DOT_PREFIX });
|
|
399
337
|
} catch {
|
|
400
338
|
return null;
|
|
401
339
|
}
|
|
402
340
|
}).refine(isString, {
|
|
403
341
|
message: `address is not a valid polkadot address`
|
|
404
342
|
});
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
})
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
343
|
+
hexString.refine(
|
|
344
|
+
(address) => ethers__namespace.isAddress(address),
|
|
345
|
+
(address) => ({ message: `${address} is not a valid Ethereum address` })
|
|
346
|
+
);
|
|
347
|
+
var chainflipAddress = string.refine(
|
|
348
|
+
(address) => address.startsWith("cF") && ss582__namespace.decode(address),
|
|
349
|
+
(address) => ({ message: `${address} is not a valid Chainflip address` })
|
|
350
|
+
);
|
|
411
351
|
var solanaAddress = string.refine(solana.isValidSolanaAddress, (address) => ({
|
|
412
352
|
message: `${address} is not a valid Solana address`
|
|
413
353
|
}));
|
|
414
|
-
var polkadotAddress = string.refine((address) => ss582__namespace.decode(address), (address) => ({
|
|
415
|
-
message: `${address} is not a valid polkadot address`
|
|
416
|
-
}));
|
|
417
354
|
numericString.transform((arg) => BigInt(arg));
|
|
418
|
-
var u128 = zod.z.union([
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
hexString
|
|
422
|
-
]).transform((arg) => BigInt(arg));
|
|
423
|
-
var unsignedInteger = zod.z.union([
|
|
424
|
-
u128,
|
|
425
|
-
zod.z.number().transform((n) => BigInt(n))
|
|
426
|
-
]);
|
|
427
|
-
var rustEnum = /* @__PURE__ */ __name((values) => zod.z.object({
|
|
428
|
-
__kind: zod.z.enum(values)
|
|
429
|
-
}).transform(({ __kind }) => __kind), "rustEnum");
|
|
355
|
+
var u128 = zod.z.union([number, numericString, hexString]).transform((arg) => BigInt(arg));
|
|
356
|
+
var unsignedInteger = zod.z.union([u128, zod.z.number().transform((n) => BigInt(n))]);
|
|
357
|
+
var rustEnum = (values) => zod.z.object({ __kind: zod.z.enum(values) }).transform(({ __kind }) => __kind);
|
|
430
358
|
rustEnum(enumValues(InternalAssets));
|
|
431
359
|
rustEnum(enumValues(Chains));
|
|
432
360
|
var chain = zod.z.nativeEnum(Chains);
|
|
@@ -436,44 +364,19 @@ var uncheckedAssetAndChain = zod.z.object({
|
|
|
436
364
|
asset: zod.z.string(),
|
|
437
365
|
chain: zod.z.string()
|
|
438
366
|
});
|
|
439
|
-
var assetAndChain = uncheckedAssetAndChain.refine(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
__kind: zod.z.literal("CcmPrincipal"),
|
|
443
|
-
value: unsignedInteger
|
|
444
|
-
}).transform(({ value: ccmId }) => ({
|
|
445
|
-
type: "PRINCIPAL",
|
|
446
|
-
ccmId
|
|
447
|
-
})),
|
|
448
|
-
zod.z.object({
|
|
449
|
-
__kind: zod.z.literal("CcmGas"),
|
|
450
|
-
value: unsignedInteger
|
|
451
|
-
}).transform(({ value: ccmId }) => ({
|
|
452
|
-
type: "GAS",
|
|
453
|
-
ccmId
|
|
454
|
-
})),
|
|
455
|
-
zod.z.object({
|
|
456
|
-
__kind: zod.z.literal("Swap")
|
|
457
|
-
}).transform(() => ({
|
|
458
|
-
type: "SWAP"
|
|
459
|
-
}))
|
|
460
|
-
]);
|
|
367
|
+
var assetAndChain = uncheckedAssetAndChain.refine(
|
|
368
|
+
(value) => isValidAssetAndChain(value)
|
|
369
|
+
);
|
|
461
370
|
zod.z.union([
|
|
462
371
|
hexString,
|
|
372
|
+
//
|
|
463
373
|
string.regex(/^[a-f\d]$/i).transform((value) => `0x${value}`)
|
|
464
|
-
]).transform(
|
|
465
|
-
data: value,
|
|
466
|
-
|
|
467
|
-
}));
|
|
374
|
+
]).transform(
|
|
375
|
+
(value) => ss582__namespace.encode({ data: value, ss58Format: chainflipSS58Prefix })
|
|
376
|
+
);
|
|
468
377
|
zod.z.union([
|
|
469
|
-
zod.z.object({
|
|
470
|
-
|
|
471
|
-
swapId: u128
|
|
472
|
-
}),
|
|
473
|
-
zod.z.object({
|
|
474
|
-
__kind: zod.z.literal("LiquidityProvision"),
|
|
475
|
-
lpAccount: hexString
|
|
476
|
-
}),
|
|
378
|
+
zod.z.object({ __kind: zod.z.literal("Swap"), swapId: u128 }),
|
|
379
|
+
zod.z.object({ __kind: zod.z.literal("LiquidityProvision"), lpAccount: hexString }),
|
|
477
380
|
zod.z.object({
|
|
478
381
|
__kind: zod.z.literal("CcmTransfer"),
|
|
479
382
|
principalSwapId: u128.nullable().optional(),
|
|
@@ -493,27 +396,22 @@ zod.z.object({
|
|
|
493
396
|
srcAsset: asset,
|
|
494
397
|
destChain: chain,
|
|
495
398
|
destAsset: asset,
|
|
496
|
-
amount: numericString.transform((
|
|
399
|
+
amount: numericString.transform((v) => BigInt(v)).refine((v) => v > 0n, { message: "swap input amount must be greater than 0" }).refine((v) => v < 2n ** 128n, { message: "swap input amount must be less than 2^128" }),
|
|
497
400
|
brokerCommissionBps: numericOrEmptyString.transform((v) => Number(v)).optional(),
|
|
498
|
-
dcaEnabled: booleanString
|
|
401
|
+
dcaEnabled: booleanString.default("false"),
|
|
402
|
+
isVaultSwap: booleanString.default("false")
|
|
499
403
|
}).transform((args, ctx) => {
|
|
500
404
|
const { srcAsset, destAsset } = getInternalAssets(args, false);
|
|
501
405
|
if (srcAsset === null) {
|
|
502
406
|
ctx.addIssue({
|
|
503
|
-
message: `invalid asset and chain combination: ${JSON.stringify({
|
|
504
|
-
asset: args.srcAsset,
|
|
505
|
-
chain: args.srcChain
|
|
506
|
-
})}`,
|
|
407
|
+
message: `invalid asset and chain combination: ${JSON.stringify({ asset: args.srcAsset, chain: args.srcChain })}`,
|
|
507
408
|
code: zod.z.ZodIssueCode.custom
|
|
508
409
|
});
|
|
509
410
|
return zod.z.NEVER;
|
|
510
411
|
}
|
|
511
412
|
if (destAsset === null) {
|
|
512
413
|
ctx.addIssue({
|
|
513
|
-
message: `invalid asset and chain combination: ${JSON.stringify({
|
|
514
|
-
asset: args.destAsset,
|
|
515
|
-
chain: args.destChain
|
|
516
|
-
})}`,
|
|
414
|
+
message: `invalid asset and chain combination: ${JSON.stringify({ asset: args.destAsset, chain: args.destChain })}`,
|
|
517
415
|
code: zod.z.ZodIssueCode.custom
|
|
518
416
|
});
|
|
519
417
|
return zod.z.NEVER;
|
|
@@ -523,35 +421,37 @@ zod.z.object({
|
|
|
523
421
|
destAsset,
|
|
524
422
|
amount: args.amount,
|
|
525
423
|
brokerCommissionBps: args.brokerCommissionBps,
|
|
526
|
-
dcaEnabled: args.dcaEnabled
|
|
424
|
+
dcaEnabled: args.dcaEnabled,
|
|
425
|
+
isVaultSwap: args.isVaultSwap
|
|
527
426
|
};
|
|
528
427
|
});
|
|
529
428
|
var ccmParamsSchema = zod.z.object({
|
|
530
|
-
gasBudget: zod.z.union([
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
cfParameters: hexStringWithMaxByteSize(
|
|
537
|
-
})
|
|
429
|
+
gasBudget: zod.z.union([numericString, hexString]).transform((n) => number$1.hexEncodeNumber(BigInt(n))),
|
|
430
|
+
// https://github.com/chainflip-io/chainflip-backend/blob/415aa9e20ec4046c68892cd34798e5d831c5b83f/state-chain/chains/src/lib.rs#L709
|
|
431
|
+
message: hexStringWithMaxByteSize(15e3),
|
|
432
|
+
// https://github.com/chainflip-io/chainflip-backend/blob/415aa9e20ec4046c68892cd34798e5d831c5b83f/state-chain/chains/src/lib.rs#L710
|
|
433
|
+
additionalData: hexStringWithMaxByteSize(3e3).optional(),
|
|
434
|
+
/** @deprecated DEPRECATED(1.8) pass additionalData instead */
|
|
435
|
+
cfParameters: hexStringWithMaxByteSize(3e3).optional()
|
|
436
|
+
}).transform(({ gasBudget, message, additionalData, cfParameters }) => ({
|
|
437
|
+
gasBudget,
|
|
438
|
+
message,
|
|
439
|
+
additionalData: additionalData ?? cfParameters
|
|
440
|
+
}));
|
|
538
441
|
var affiliateBroker = zod.z.object({
|
|
539
442
|
account: chainflipAddress,
|
|
540
443
|
commissionBps: number
|
|
541
|
-
}).transform(({ account, commissionBps: bps }) => ({
|
|
542
|
-
account,
|
|
543
|
-
bps
|
|
544
|
-
}));
|
|
444
|
+
}).transform(({ account, commissionBps: bps }) => ({ account, bps }));
|
|
545
445
|
var dcaParams = zod.z.object({
|
|
546
446
|
numberOfChunks: number,
|
|
547
447
|
chunkIntervalBlocks: number
|
|
548
448
|
});
|
|
549
|
-
|
|
449
|
+
zod.z.object({
|
|
550
450
|
retryDurationBlocks: number,
|
|
551
451
|
refundAddress: zod.z.string(),
|
|
552
452
|
minPriceX128: numericString
|
|
553
453
|
});
|
|
554
|
-
var ensureDcaWithFok =
|
|
454
|
+
var ensureDcaWithFok = (args, ctx) => {
|
|
555
455
|
if (args.dcaParams && !args.fillOrKillParams) {
|
|
556
456
|
ctx.addIssue({
|
|
557
457
|
code: "custom",
|
|
@@ -559,144 +459,188 @@ var ensureDcaWithFok = /* @__PURE__ */ __name((args, ctx) => {
|
|
|
559
459
|
});
|
|
560
460
|
return zod.z.NEVER;
|
|
561
461
|
}
|
|
562
|
-
}
|
|
563
|
-
zod.z.object({
|
|
564
|
-
srcAsset: asset,
|
|
565
|
-
destAsset: asset,
|
|
566
|
-
srcChain: chain,
|
|
567
|
-
destChain: chain,
|
|
568
|
-
destAddress: zod.z.string(),
|
|
569
|
-
amount: numericString,
|
|
570
|
-
ccmParams: ccmParamsSchema.optional(),
|
|
571
|
-
maxBoostFeeBps: zod.z.number().optional(),
|
|
572
|
-
srcAddress: zod.z.string().optional(),
|
|
573
|
-
fillOrKillParams,
|
|
574
|
-
dcaParams: dcaParams.optional(),
|
|
575
|
-
quote: zod.z.object({
|
|
576
|
-
intermediateAmount: zod.z.string().optional(),
|
|
577
|
-
egressAmount: zod.z.string(),
|
|
578
|
-
estimatedPrice: zod.z.string(),
|
|
579
|
-
recommendedSlippageTolerancePercent: zod.z.number().optional()
|
|
580
|
-
}).optional()
|
|
581
|
-
}).superRefine(ensureDcaWithFok).transform(({ amount, ...rest }) => ({
|
|
582
|
-
...rest,
|
|
583
|
-
expectedDepositAmount: amount
|
|
584
|
-
}));
|
|
462
|
+
};
|
|
585
463
|
|
|
586
464
|
// ../shared/src/broker.ts
|
|
587
|
-
var
|
|
588
|
-
"srcAsset",
|
|
589
|
-
"destAsset",
|
|
590
|
-
"destAddress",
|
|
591
|
-
"commissionBps",
|
|
592
|
-
"ccmParams",
|
|
593
|
-
"maxBoostFeeBps",
|
|
594
|
-
"affiliates",
|
|
595
|
-
"fillOrKillParams",
|
|
596
|
-
"dcaParams"
|
|
597
|
-
];
|
|
598
|
-
var getTransformedFokSchema = /* @__PURE__ */ __name((addressSchema) => zod.z.object({
|
|
465
|
+
var transformedFokSchema = zod.z.object({
|
|
599
466
|
retryDurationBlocks: number,
|
|
600
|
-
refundAddress:
|
|
467
|
+
refundAddress: zod.z.string(),
|
|
601
468
|
minPriceX128: numericString
|
|
602
469
|
}).transform(({ retryDurationBlocks, refundAddress, minPriceX128 }) => ({
|
|
603
470
|
retry_duration: retryDurationBlocks,
|
|
604
471
|
refund_address: refundAddress,
|
|
605
472
|
min_price: `0x${BigInt(minPriceX128).toString(16)}`
|
|
606
|
-
})), "getTransformedFokSchema");
|
|
607
|
-
var transformedDcaParamsSchema = dcaParams.transform(({ numberOfChunks, chunkIntervalBlocks }) => ({
|
|
608
|
-
number_of_chunks: numberOfChunks,
|
|
609
|
-
chunk_interval: chunkIntervalBlocks
|
|
610
473
|
}));
|
|
611
|
-
var
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
})
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
474
|
+
var transformedDcaParamsSchema = dcaParams.transform(
|
|
475
|
+
({ numberOfChunks, chunkIntervalBlocks }) => ({
|
|
476
|
+
number_of_chunks: numberOfChunks,
|
|
477
|
+
chunk_interval: chunkIntervalBlocks
|
|
478
|
+
})
|
|
479
|
+
);
|
|
480
|
+
var transformedCcmParamsSchema = ccmParamsSchema.transform(
|
|
481
|
+
({ message, gasBudget, additionalData }) => ({
|
|
482
|
+
message,
|
|
483
|
+
gas_budget: gasBudget,
|
|
484
|
+
ccm_additional_data: additionalData,
|
|
485
|
+
/** @deprecated DEPRECATED(1.8) we still need to pass cf_parameters until 1.8 is deployed to all networks */
|
|
486
|
+
cf_parameters: additionalData
|
|
487
|
+
})
|
|
488
|
+
);
|
|
489
|
+
var getDepositAddressRequestSchema = (network) => zod.z.object({
|
|
490
|
+
srcAsset: assetAndChain,
|
|
491
|
+
destAsset: assetAndChain,
|
|
492
|
+
destAddress: zod.z.string(),
|
|
493
|
+
commissionBps: zod.z.number().optional().default(0),
|
|
494
|
+
ccmParams: transformedCcmParamsSchema.optional(),
|
|
495
|
+
maxBoostFeeBps: zod.z.number().optional(),
|
|
496
|
+
affiliates: zod.z.array(affiliateBroker).optional(),
|
|
497
|
+
fillOrKillParams: transformedFokSchema.optional(),
|
|
498
|
+
dcaParams: transformedDcaParamsSchema.optional()
|
|
499
|
+
}).superRefine((val, ctx) => {
|
|
500
|
+
if (!validateAddress(val.destAsset.chain, val.destAddress, network)) {
|
|
501
|
+
ctx.addIssue({
|
|
502
|
+
message: `Address "${val.destAddress}" is not a valid "${val.destAsset.chain}" address for "${network}"`,
|
|
503
|
+
code: zod.z.ZodIssueCode.custom
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}).superRefine((val, ctx) => {
|
|
507
|
+
if (val.fillOrKillParams && !validateAddress(val.srcAsset.chain, val.fillOrKillParams.refund_address, network)) {
|
|
508
|
+
ctx.addIssue({
|
|
509
|
+
message: `Address "${val.fillOrKillParams.refund_address}" is not a valid "${val.srcAsset.chain}" address for "${network}"`,
|
|
510
|
+
code: zod.z.ZodIssueCode.custom
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}).superRefine(ensureDcaWithFok);
|
|
514
|
+
var getParameterEncodingRequestSchema = (network) => zod.z.object({
|
|
515
|
+
srcAsset: assetAndChain,
|
|
516
|
+
srcAddress: zod.z.string().optional(),
|
|
517
|
+
destAsset: assetAndChain,
|
|
518
|
+
destAddress: zod.z.string(),
|
|
519
|
+
amount: unsignedInteger,
|
|
520
|
+
commissionBps: zod.z.number().optional().default(0),
|
|
521
|
+
ccmParams: transformedCcmParamsSchema.optional(),
|
|
522
|
+
maxBoostFeeBps: zod.z.number().optional(),
|
|
523
|
+
affiliates: zod.z.array(affiliateBroker).optional(),
|
|
524
|
+
fillOrKillParams: transformedFokSchema,
|
|
525
|
+
dcaParams: transformedDcaParamsSchema.optional(),
|
|
526
|
+
extraParams: zod.z.object({ solanaDataAccount: solanaAddress.optional() }).optional()
|
|
527
|
+
}).superRefine((val, ctx) => {
|
|
528
|
+
if (val.srcAddress && !validateAddress(val.srcAsset.chain, val.srcAddress, network)) {
|
|
529
|
+
ctx.addIssue({
|
|
530
|
+
message: `Address "${val.srcAddress}" is not a valid "${val.srcAsset.chain}" address for "${network}"`,
|
|
531
|
+
code: zod.z.ZodIssueCode.custom
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}).superRefine((val, ctx) => {
|
|
535
|
+
if (!validateAddress(val.destAsset.chain, val.destAddress, network)) {
|
|
536
|
+
ctx.addIssue({
|
|
537
|
+
message: `Address "${val.destAddress}" is not a valid "${val.destAsset.chain}" address for "${network}"`,
|
|
538
|
+
code: zod.z.ZodIssueCode.custom
|
|
539
|
+
});
|
|
619
540
|
}
|
|
620
|
-
|
|
621
|
-
|
|
541
|
+
}).superRefine((val, ctx) => {
|
|
542
|
+
if (val.fillOrKillParams && !validateAddress(val.srcAsset.chain, val.fillOrKillParams.refund_address, network)) {
|
|
543
|
+
ctx.addIssue({
|
|
544
|
+
message: `Address "${val.fillOrKillParams.refund_address}" is not a valid "${val.srcAsset.chain}" address for "${network}"`,
|
|
545
|
+
code: zod.z.ZodIssueCode.custom
|
|
546
|
+
});
|
|
622
547
|
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
548
|
+
}).transform((data) => {
|
|
549
|
+
let extraParams;
|
|
550
|
+
if (data.srcAsset.chain === "Bitcoin") {
|
|
551
|
+
const minOutputAmount = BigNumber2__default.default(data.amount.toString()).multipliedBy(tickMath.priceX128ToPrice(data.fillOrKillParams.min_price)).toFixed(0);
|
|
552
|
+
extraParams = {
|
|
553
|
+
chain: "Bitcoin",
|
|
554
|
+
min_output_amount: `0x${BigInt(minOutputAmount).toString(16)}`,
|
|
555
|
+
retry_duration: data.fillOrKillParams.retry_duration
|
|
556
|
+
};
|
|
557
|
+
} else if (data.srcAsset.chain === "Ethereum" || data.srcAsset.chain === "Arbitrum") {
|
|
558
|
+
extraParams = {
|
|
559
|
+
chain: data.srcAsset.chain,
|
|
560
|
+
input_amount: `0x${BigInt(data.amount).toString(16)}`,
|
|
561
|
+
refund_parameters: data.fillOrKillParams
|
|
562
|
+
};
|
|
563
|
+
} else if (data.srcAsset.chain === "Solana") {
|
|
564
|
+
assert(data.srcAddress, "srcAddress is required for Solana");
|
|
565
|
+
assert(data.extraParams?.solanaDataAccount, "solanaDataAccount is required for Solana");
|
|
566
|
+
extraParams = {
|
|
567
|
+
chain: "Solana",
|
|
568
|
+
from: data.srcAddress,
|
|
569
|
+
event_data_account: data.extraParams.solanaDataAccount,
|
|
570
|
+
input_amount: `0x${BigInt(data.amount).toString(16)}`,
|
|
571
|
+
refund_parameters: data.fillOrKillParams
|
|
572
|
+
};
|
|
573
|
+
} else {
|
|
574
|
+
throw new Error(`parameter encoding is not supported for ${data.srcAsset.chain}`);
|
|
646
575
|
}
|
|
647
|
-
return
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
address: zod.z.union([
|
|
651
|
-
dotAddress,
|
|
652
|
-
ethereumAddress,
|
|
653
|
-
btcAddress(network),
|
|
654
|
-
solanaAddress
|
|
655
|
-
]),
|
|
656
|
-
issued_block: zod.z.number(),
|
|
657
|
-
channel_id: zod.z.number(),
|
|
658
|
-
source_chain_expiry_block: zod.z.bigint(),
|
|
659
|
-
channel_opening_fee: zod.z.bigint()
|
|
660
|
-
}).transform(({ address, issued_block, channel_id, source_chain_expiry_block, channel_opening_fee }) => ({
|
|
661
|
-
address,
|
|
662
|
-
issuedBlock: issued_block,
|
|
663
|
-
channelId: BigInt(channel_id),
|
|
664
|
-
sourceChainExpiryBlock: source_chain_expiry_block,
|
|
665
|
-
channelOpeningFee: channel_opening_fee
|
|
666
|
-
})).parse(response), "validateResponse");
|
|
667
|
-
async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork2) {
|
|
576
|
+
return { ...data, extraParams };
|
|
577
|
+
});
|
|
578
|
+
async function requestSwapDepositAddress(request, opts, chainflipNetwork2) {
|
|
668
579
|
const client = new rpc.HttpClient(opts.url);
|
|
669
|
-
|
|
670
|
-
...
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
580
|
+
if (request.srcChain && typeof request.srcAsset === "string") {
|
|
581
|
+
request = { ...request, srcAsset: { asset: request.srcAsset, chain: request.srcChain } };
|
|
582
|
+
}
|
|
583
|
+
if (request.destChain && typeof request.destAsset === "string") {
|
|
584
|
+
request = { ...request, destAsset: { asset: request.destAsset, chain: request.destChain } };
|
|
585
|
+
}
|
|
586
|
+
const params = getDepositAddressRequestSchema(chainflipNetwork2).parse(request);
|
|
587
|
+
const response = await client.sendRequest(
|
|
588
|
+
"broker_requestSwapDepositAddress",
|
|
589
|
+
params.srcAsset,
|
|
590
|
+
params.destAsset,
|
|
591
|
+
params.destAddress,
|
|
592
|
+
params.commissionBps,
|
|
593
|
+
params.ccmParams,
|
|
594
|
+
params.maxBoostFeeBps,
|
|
595
|
+
params.affiliates,
|
|
596
|
+
params.fillOrKillParams,
|
|
597
|
+
params.dcaParams
|
|
598
|
+
);
|
|
599
|
+
if (params.srcAsset.chain === "Polkadot" && string$1.isHex(response.address)) {
|
|
600
|
+
response.address = ss582__namespace.encode({ data: response.address, ss58Format: DOT_PREFIX });
|
|
601
|
+
}
|
|
602
|
+
return transformKeysToCamelCase(response);
|
|
682
603
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
604
|
+
async function requestSwapParameterEncoding(request, opts, chainflipNetwork2) {
|
|
605
|
+
const client = new rpc.HttpClient(opts.url);
|
|
606
|
+
const params = getParameterEncodingRequestSchema(chainflipNetwork2).parse(request);
|
|
607
|
+
const response = await client.sendRequest(
|
|
608
|
+
"broker_request_swap_parameter_encoding",
|
|
609
|
+
params.srcAsset,
|
|
610
|
+
params.destAsset,
|
|
611
|
+
params.destAddress,
|
|
612
|
+
params.commissionBps,
|
|
613
|
+
params.extraParams,
|
|
614
|
+
params.ccmParams,
|
|
615
|
+
params.maxBoostFeeBps,
|
|
616
|
+
params.affiliates,
|
|
617
|
+
params.dcaParams
|
|
618
|
+
);
|
|
619
|
+
return transformKeysToCamelCase(response);
|
|
620
|
+
}
|
|
621
|
+
var getPriceX128FromPrice = (price, srcAsset, destAsset) => BigNumber2__default.default(price).multipliedBy(new BigNumber2__default.default(2).pow(128)).shiftedBy(assetConstants[destAsset].decimals - assetConstants[srcAsset].decimals).toFixed(0);
|
|
622
|
+
var parseFoKParams = (params, quote) => {
|
|
686
623
|
if (!params) return void 0;
|
|
687
624
|
const srcAsset = getInternalAsset(quote.srcAsset);
|
|
688
625
|
const destAsset = getInternalAsset(quote.destAsset);
|
|
689
626
|
let minPrice;
|
|
690
627
|
if ("minPrice" in params) {
|
|
691
|
-
assert(
|
|
628
|
+
assert(
|
|
629
|
+
!("slippageTolerancePercent" in params),
|
|
630
|
+
"Cannot have both minPrice and slippageTolerancePercent"
|
|
631
|
+
);
|
|
692
632
|
minPrice = params.minPrice;
|
|
693
633
|
} else if ("slippageTolerancePercent" in params) {
|
|
694
|
-
const tolerance = new
|
|
634
|
+
const tolerance = new BigNumber2__default.default(params.slippageTolerancePercent);
|
|
695
635
|
assert(!tolerance.isNaN(), "Invalid slippage tolerance");
|
|
696
|
-
assert(
|
|
697
|
-
|
|
636
|
+
assert(
|
|
637
|
+
tolerance.gte(0) && tolerance.lte(100),
|
|
638
|
+
"Slippage tolerance must be between 0 and 100 inclusive",
|
|
639
|
+
RangeError
|
|
640
|
+
);
|
|
641
|
+
const estimatedPrice = new BigNumber2__default.default(quote.estimatedPrice);
|
|
698
642
|
assert(!estimatedPrice.isNaN(), "Invalid estimated price");
|
|
699
|
-
minPrice = estimatedPrice.times(new
|
|
643
|
+
minPrice = estimatedPrice.times(new BigNumber2__default.default(100).minus(tolerance).dividedBy(100)).toFixed(assetConstants[destAsset].decimals);
|
|
700
644
|
} else {
|
|
701
645
|
throw new Error("Either minPrice or slippageTolerancePercent must be provided");
|
|
702
646
|
}
|
|
@@ -705,46 +649,34 @@ var parseFoKParams = /* @__PURE__ */ __name((params, quote) => {
|
|
|
705
649
|
retryDurationBlocks: params.retryDurationBlocks,
|
|
706
650
|
minPriceX128: getPriceX128FromPrice(minPrice, srcAsset, destAsset)
|
|
707
651
|
};
|
|
708
|
-
}
|
|
709
|
-
var camelCase =
|
|
710
|
-
var camelCaseKeys =
|
|
652
|
+
};
|
|
653
|
+
var camelCase = (str) => str.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
|
|
654
|
+
var camelCaseKeys = (obj) => {
|
|
711
655
|
if (typeof obj !== "object" || obj === null) return obj;
|
|
712
656
|
if (Array.isArray(obj)) return obj.map((item) => camelCaseKeys(item));
|
|
713
|
-
return Object.fromEntries(
|
|
714
|
-
camelCase(key),
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
var createRequest = /* @__PURE__ */ __name((method) => async (urlOrNetwork, ...params) => {
|
|
657
|
+
return Object.fromEntries(
|
|
658
|
+
Object.entries(obj).map(([key, value]) => [camelCase(key), camelCaseKeys(value)])
|
|
659
|
+
);
|
|
660
|
+
};
|
|
661
|
+
var createRequest = (method) => async (urlOrNetwork, ...params) => {
|
|
719
662
|
const url = "network" in urlOrNetwork ? rpc.constants.PUBLIC_RPC_ENDPOINTS[urlOrNetwork.network] : urlOrNetwork.rpcUrl;
|
|
720
663
|
const result = await new rpc.HttpClient(url).sendRequest(method, ...params);
|
|
721
664
|
return camelCaseKeys(result);
|
|
722
|
-
}
|
|
723
|
-
var transform =
|
|
724
|
-
createRequest("cf_funding_environment");
|
|
725
|
-
createRequest("cf_swapping_environment");
|
|
726
|
-
createRequest("cf_ingress_egress_environment");
|
|
665
|
+
};
|
|
666
|
+
var transform = (fn, cb) => (...args) => fn(...args).then(cb);
|
|
727
667
|
var getEnvironment = createRequest("cf_environment");
|
|
728
|
-
createRequest("cf_swap_rate");
|
|
729
|
-
createRequest("state_getMetadata");
|
|
730
668
|
var getSupportedAssets = createRequest("cf_supported_assets");
|
|
731
|
-
|
|
732
|
-
createRequest("
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
chain: chain2,
|
|
739
|
-
asset: asset2
|
|
740
|
-
}),
|
|
741
|
-
...rest
|
|
742
|
-
})));
|
|
743
|
-
createRequest("cf_swap_rate_v2");
|
|
669
|
+
var getAllBoostPoolsDepth = transform(
|
|
670
|
+
createRequest("cf_boost_pools_depth"),
|
|
671
|
+
(result) => result.map(({ chain: chain2, asset: asset2, ...rest }) => ({
|
|
672
|
+
asset: getInternalAsset({ chain: chain2, asset: asset2 }),
|
|
673
|
+
...rest
|
|
674
|
+
}))
|
|
675
|
+
);
|
|
744
676
|
|
|
745
677
|
// ../shared/src/rpc/utils.ts
|
|
746
678
|
var MAX_SWAP_AMOUNT = 2n ** 128n - 1n;
|
|
747
|
-
var validateSwapAmount =
|
|
679
|
+
var validateSwapAmount = (env, asset2, amount) => {
|
|
748
680
|
const minimumAmount = readChainAssetValue(env.ingressEgress.minimumDepositAmounts, asset2);
|
|
749
681
|
if (amount < minimumAmount) {
|
|
750
682
|
return {
|
|
@@ -759,1673 +691,203 @@ var validateSwapAmount = /* @__PURE__ */ __name((env, asset2, amount) => {
|
|
|
759
691
|
reason: `expected amount is above maximum swap amount (${maxAmount})`
|
|
760
692
|
};
|
|
761
693
|
}
|
|
762
|
-
return {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
var
|
|
767
|
-
{
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
],
|
|
780
|
-
name: "allowance",
|
|
781
|
-
outputs: [
|
|
782
|
-
{
|
|
783
|
-
internalType: "uint256",
|
|
784
|
-
name: "",
|
|
785
|
-
type: "uint256"
|
|
786
|
-
}
|
|
787
|
-
],
|
|
788
|
-
stateMutability: "view",
|
|
789
|
-
type: "function"
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
inputs: [
|
|
793
|
-
{
|
|
794
|
-
internalType: "address",
|
|
795
|
-
name: "spender",
|
|
796
|
-
type: "address"
|
|
797
|
-
},
|
|
798
|
-
{
|
|
799
|
-
internalType: "uint256",
|
|
800
|
-
name: "amount",
|
|
801
|
-
type: "uint256"
|
|
802
|
-
}
|
|
803
|
-
],
|
|
804
|
-
name: "approve",
|
|
805
|
-
outputs: [
|
|
806
|
-
{
|
|
807
|
-
internalType: "bool",
|
|
808
|
-
name: "",
|
|
809
|
-
type: "bool"
|
|
810
|
-
}
|
|
811
|
-
],
|
|
812
|
-
stateMutability: "nonpayable",
|
|
813
|
-
type: "function"
|
|
814
|
-
},
|
|
815
|
-
{
|
|
816
|
-
inputs: [
|
|
817
|
-
{
|
|
818
|
-
internalType: "address",
|
|
819
|
-
name: "account",
|
|
820
|
-
type: "address"
|
|
821
|
-
}
|
|
822
|
-
],
|
|
823
|
-
name: "balanceOf",
|
|
824
|
-
outputs: [
|
|
825
|
-
{
|
|
826
|
-
internalType: "uint256",
|
|
827
|
-
name: "",
|
|
828
|
-
type: "uint256"
|
|
829
|
-
}
|
|
830
|
-
],
|
|
831
|
-
stateMutability: "view",
|
|
832
|
-
type: "function"
|
|
694
|
+
return { success: true };
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
// ../swap/src/utils/dataStructures.ts
|
|
698
|
+
var Timer = class {
|
|
699
|
+
constructor(value, cb, ms) {
|
|
700
|
+
this.value = value;
|
|
701
|
+
this.cb = cb;
|
|
702
|
+
this.ms = ms;
|
|
703
|
+
this.reset(true);
|
|
704
|
+
}
|
|
705
|
+
reset(resetExpiryOnLookup) {
|
|
706
|
+
if (resetExpiryOnLookup) {
|
|
707
|
+
this.clear();
|
|
708
|
+
this.timeout = setTimeout(this.cb, this.ms);
|
|
709
|
+
}
|
|
710
|
+
return this;
|
|
833
711
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
static createInterface() {
|
|
837
|
-
return new ethers.Interface(_abi);
|
|
712
|
+
getValue(resetExpiryOnLookup) {
|
|
713
|
+
return this.reset(resetExpiryOnLookup).value;
|
|
838
714
|
}
|
|
839
|
-
|
|
840
|
-
|
|
715
|
+
clear() {
|
|
716
|
+
if (this.timeout) clearTimeout(this.timeout);
|
|
841
717
|
}
|
|
842
718
|
};
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
858
|
-
{
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
719
|
+
var CacheMap = class {
|
|
720
|
+
constructor(ttl, resetExpiryOnLookup = true) {
|
|
721
|
+
this.ttl = ttl;
|
|
722
|
+
this.resetExpiryOnLookup = resetExpiryOnLookup;
|
|
723
|
+
this.store = /* @__PURE__ */ new Map();
|
|
724
|
+
}
|
|
725
|
+
set(key, value) {
|
|
726
|
+
this.delete(key);
|
|
727
|
+
const timer = new Timer(value, () => this.store.delete(key), this.ttl);
|
|
728
|
+
this.store.set(key, timer);
|
|
729
|
+
return this;
|
|
730
|
+
}
|
|
731
|
+
get(key) {
|
|
732
|
+
return this.store.get(key)?.getValue(this.resetExpiryOnLookup);
|
|
733
|
+
}
|
|
734
|
+
delete(key) {
|
|
735
|
+
this.store.get(key)?.clear();
|
|
736
|
+
return this.store.delete(key);
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
var AsyncCacheMap = class extends CacheMap {
|
|
740
|
+
constructor({
|
|
741
|
+
fetch,
|
|
742
|
+
ttl,
|
|
743
|
+
resetExpiryOnLookup = true
|
|
744
|
+
}) {
|
|
745
|
+
super(ttl, resetExpiryOnLookup);
|
|
746
|
+
this.fetch = fetch;
|
|
747
|
+
}
|
|
748
|
+
get(key) {
|
|
749
|
+
let promise = super.get(key);
|
|
750
|
+
if (!promise) {
|
|
751
|
+
promise = this.fetch(key).catch((err) => {
|
|
752
|
+
this.delete(key);
|
|
753
|
+
throw err;
|
|
754
|
+
});
|
|
755
|
+
this.set(key, promise);
|
|
756
|
+
}
|
|
757
|
+
return promise;
|
|
758
|
+
}
|
|
759
|
+
load(key) {
|
|
760
|
+
return this.get(key).then(
|
|
761
|
+
() => true,
|
|
762
|
+
() => false
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
var ETHEREUM_EVM_CHAIN_ID = {
|
|
767
|
+
[ChainflipNetworks.backspin]: 10997,
|
|
768
|
+
// backspin ethereum
|
|
769
|
+
[ChainflipNetworks.sisyphos]: 11155111,
|
|
770
|
+
// sepolia
|
|
771
|
+
[ChainflipNetworks.perseverance]: 11155111,
|
|
772
|
+
// sepolia
|
|
773
|
+
[ChainflipNetworks.mainnet]: 1
|
|
774
|
+
// mainnet
|
|
775
|
+
};
|
|
776
|
+
var ARBITRUM_EVM_CHAIN_ID = {
|
|
777
|
+
[ChainflipNetworks.backspin]: 412346,
|
|
778
|
+
// backspin arbitrum
|
|
779
|
+
[ChainflipNetworks.sisyphos]: 421614,
|
|
780
|
+
// arb-sepolia
|
|
781
|
+
[ChainflipNetworks.perseverance]: 421614,
|
|
782
|
+
// arb-sepolia
|
|
783
|
+
[ChainflipNetworks.mainnet]: 42161
|
|
784
|
+
// mainnet
|
|
785
|
+
};
|
|
786
|
+
var getEvmChainId = (chain2, network) => {
|
|
787
|
+
switch (chain2) {
|
|
788
|
+
case Chains.Ethereum:
|
|
789
|
+
return ETHEREUM_EVM_CHAIN_ID[network];
|
|
790
|
+
case Chains.Arbitrum:
|
|
791
|
+
return ARBITRUM_EVM_CHAIN_ID[network];
|
|
792
|
+
default:
|
|
793
|
+
return void 0;
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
var SEPOLIA_USDC_CONTRACT_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
|
|
797
|
+
var SEPOLIA_USDT_CONTRACT_ADDRESS = "0x27CEA6Eb8a21Aae05Eb29C91c5CA10592892F584";
|
|
798
|
+
var ADDRESSES = {
|
|
799
|
+
[ChainflipNetworks.backspin]: {
|
|
800
|
+
FLIP_CONTRACT_ADDRESS: "0x10C6E9530F1C1AF873a391030a1D9E8ed0630D26",
|
|
801
|
+
USDC_CONTRACT_ADDRESS: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
|
|
802
|
+
USDT_CONTRACT_ADDRESS: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
803
|
+
ARBUSDC_CONTRACT_ADDRESS: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
804
|
+
STATE_CHAIN_GATEWAY_ADDRESS: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883",
|
|
805
|
+
SOLUSDC_CONTRACT_ADDRESS: "24PNhTaNtomHhoy3fTRaMhAFCRj4uHqhZEEoWrKDbR5p"
|
|
876
806
|
},
|
|
877
|
-
{
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
type: "bytes32"
|
|
885
|
-
},
|
|
886
|
-
{
|
|
887
|
-
indexed: false,
|
|
888
|
-
internalType: "uint256",
|
|
889
|
-
name: "amount",
|
|
890
|
-
type: "uint256"
|
|
891
|
-
},
|
|
892
|
-
{
|
|
893
|
-
indexed: false,
|
|
894
|
-
internalType: "address",
|
|
895
|
-
name: "token",
|
|
896
|
-
type: "address"
|
|
897
|
-
}
|
|
898
|
-
],
|
|
899
|
-
name: "AddGasToken",
|
|
900
|
-
type: "event"
|
|
807
|
+
[ChainflipNetworks.sisyphos]: {
|
|
808
|
+
FLIP_CONTRACT_ADDRESS: "0xcD079EAB6B5443b545788Fd210C8800FEADd87fa",
|
|
809
|
+
USDC_CONTRACT_ADDRESS: SEPOLIA_USDC_CONTRACT_ADDRESS,
|
|
810
|
+
USDT_CONTRACT_ADDRESS: SEPOLIA_USDT_CONTRACT_ADDRESS,
|
|
811
|
+
ARBUSDC_CONTRACT_ADDRESS: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
812
|
+
STATE_CHAIN_GATEWAY_ADDRESS: "0x1F7fE41C798cc7b1D34BdC8de2dDDA4a4bE744D9",
|
|
813
|
+
SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
|
|
901
814
|
},
|
|
902
|
-
{
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
type: "bool"
|
|
910
|
-
}
|
|
911
|
-
],
|
|
912
|
-
name: "CommunityGuardDisabled",
|
|
913
|
-
type: "event"
|
|
914
|
-
},
|
|
915
|
-
{
|
|
916
|
-
anonymous: false,
|
|
917
|
-
inputs: [
|
|
918
|
-
{
|
|
919
|
-
indexed: true,
|
|
920
|
-
internalType: "address payable",
|
|
921
|
-
name: "multicallAddress",
|
|
922
|
-
type: "address"
|
|
923
|
-
},
|
|
924
|
-
{
|
|
925
|
-
indexed: false,
|
|
926
|
-
internalType: "uint256",
|
|
927
|
-
name: "amount",
|
|
928
|
-
type: "uint256"
|
|
929
|
-
},
|
|
930
|
-
{
|
|
931
|
-
indexed: true,
|
|
932
|
-
internalType: "address",
|
|
933
|
-
name: "token",
|
|
934
|
-
type: "address"
|
|
935
|
-
},
|
|
936
|
-
{
|
|
937
|
-
indexed: false,
|
|
938
|
-
internalType: "bytes",
|
|
939
|
-
name: "reason",
|
|
940
|
-
type: "bytes"
|
|
941
|
-
}
|
|
942
|
-
],
|
|
943
|
-
name: "ExecuteActionsFailed",
|
|
944
|
-
type: "event"
|
|
945
|
-
},
|
|
946
|
-
{
|
|
947
|
-
anonymous: false,
|
|
948
|
-
inputs: [
|
|
949
|
-
{
|
|
950
|
-
indexed: false,
|
|
951
|
-
internalType: "bool",
|
|
952
|
-
name: "suspended",
|
|
953
|
-
type: "bool"
|
|
954
|
-
}
|
|
955
|
-
],
|
|
956
|
-
name: "Suspended",
|
|
957
|
-
type: "event"
|
|
958
|
-
},
|
|
959
|
-
{
|
|
960
|
-
anonymous: false,
|
|
961
|
-
inputs: [
|
|
962
|
-
{
|
|
963
|
-
indexed: false,
|
|
964
|
-
internalType: "uint32",
|
|
965
|
-
name: "dstChain",
|
|
966
|
-
type: "uint32"
|
|
967
|
-
},
|
|
968
|
-
{
|
|
969
|
-
indexed: false,
|
|
970
|
-
internalType: "bytes",
|
|
971
|
-
name: "dstAddress",
|
|
972
|
-
type: "bytes"
|
|
973
|
-
},
|
|
974
|
-
{
|
|
975
|
-
indexed: false,
|
|
976
|
-
internalType: "uint32",
|
|
977
|
-
name: "dstToken",
|
|
978
|
-
type: "uint32"
|
|
979
|
-
},
|
|
980
|
-
{
|
|
981
|
-
indexed: false,
|
|
982
|
-
internalType: "uint256",
|
|
983
|
-
name: "amount",
|
|
984
|
-
type: "uint256"
|
|
985
|
-
},
|
|
986
|
-
{
|
|
987
|
-
indexed: true,
|
|
988
|
-
internalType: "address",
|
|
989
|
-
name: "sender",
|
|
990
|
-
type: "address"
|
|
991
|
-
},
|
|
992
|
-
{
|
|
993
|
-
indexed: false,
|
|
994
|
-
internalType: "bytes",
|
|
995
|
-
name: "cfParameters",
|
|
996
|
-
type: "bytes"
|
|
997
|
-
}
|
|
998
|
-
],
|
|
999
|
-
name: "SwapNative",
|
|
1000
|
-
type: "event"
|
|
1001
|
-
},
|
|
1002
|
-
{
|
|
1003
|
-
anonymous: false,
|
|
1004
|
-
inputs: [
|
|
1005
|
-
{
|
|
1006
|
-
indexed: false,
|
|
1007
|
-
internalType: "uint32",
|
|
1008
|
-
name: "dstChain",
|
|
1009
|
-
type: "uint32"
|
|
1010
|
-
},
|
|
1011
|
-
{
|
|
1012
|
-
indexed: false,
|
|
1013
|
-
internalType: "bytes",
|
|
1014
|
-
name: "dstAddress",
|
|
1015
|
-
type: "bytes"
|
|
1016
|
-
},
|
|
1017
|
-
{
|
|
1018
|
-
indexed: false,
|
|
1019
|
-
internalType: "uint32",
|
|
1020
|
-
name: "dstToken",
|
|
1021
|
-
type: "uint32"
|
|
1022
|
-
},
|
|
1023
|
-
{
|
|
1024
|
-
indexed: false,
|
|
1025
|
-
internalType: "address",
|
|
1026
|
-
name: "srcToken",
|
|
1027
|
-
type: "address"
|
|
1028
|
-
},
|
|
1029
|
-
{
|
|
1030
|
-
indexed: false,
|
|
1031
|
-
internalType: "uint256",
|
|
1032
|
-
name: "amount",
|
|
1033
|
-
type: "uint256"
|
|
1034
|
-
},
|
|
1035
|
-
{
|
|
1036
|
-
indexed: true,
|
|
1037
|
-
internalType: "address",
|
|
1038
|
-
name: "sender",
|
|
1039
|
-
type: "address"
|
|
1040
|
-
},
|
|
1041
|
-
{
|
|
1042
|
-
indexed: false,
|
|
1043
|
-
internalType: "bytes",
|
|
1044
|
-
name: "cfParameters",
|
|
1045
|
-
type: "bytes"
|
|
1046
|
-
}
|
|
1047
|
-
],
|
|
1048
|
-
name: "SwapToken",
|
|
1049
|
-
type: "event"
|
|
1050
|
-
},
|
|
1051
|
-
{
|
|
1052
|
-
anonymous: false,
|
|
1053
|
-
inputs: [
|
|
1054
|
-
{
|
|
1055
|
-
indexed: true,
|
|
1056
|
-
internalType: "address payable",
|
|
1057
|
-
name: "recipient",
|
|
1058
|
-
type: "address"
|
|
1059
|
-
},
|
|
1060
|
-
{
|
|
1061
|
-
indexed: false,
|
|
1062
|
-
internalType: "uint256",
|
|
1063
|
-
name: "amount",
|
|
1064
|
-
type: "uint256"
|
|
1065
|
-
}
|
|
1066
|
-
],
|
|
1067
|
-
name: "TransferNativeFailed",
|
|
1068
|
-
type: "event"
|
|
1069
|
-
},
|
|
1070
|
-
{
|
|
1071
|
-
anonymous: false,
|
|
1072
|
-
inputs: [
|
|
1073
|
-
{
|
|
1074
|
-
indexed: true,
|
|
1075
|
-
internalType: "address payable",
|
|
1076
|
-
name: "recipient",
|
|
1077
|
-
type: "address"
|
|
1078
|
-
},
|
|
1079
|
-
{
|
|
1080
|
-
indexed: false,
|
|
1081
|
-
internalType: "uint256",
|
|
1082
|
-
name: "amount",
|
|
1083
|
-
type: "uint256"
|
|
1084
|
-
},
|
|
1085
|
-
{
|
|
1086
|
-
indexed: true,
|
|
1087
|
-
internalType: "address",
|
|
1088
|
-
name: "token",
|
|
1089
|
-
type: "address"
|
|
1090
|
-
},
|
|
1091
|
-
{
|
|
1092
|
-
indexed: false,
|
|
1093
|
-
internalType: "bytes",
|
|
1094
|
-
name: "reason",
|
|
1095
|
-
type: "bytes"
|
|
1096
|
-
}
|
|
1097
|
-
],
|
|
1098
|
-
name: "TransferTokenFailed",
|
|
1099
|
-
type: "event"
|
|
1100
|
-
},
|
|
1101
|
-
{
|
|
1102
|
-
anonymous: false,
|
|
1103
|
-
inputs: [
|
|
1104
|
-
{
|
|
1105
|
-
indexed: false,
|
|
1106
|
-
internalType: "address",
|
|
1107
|
-
name: "keyManager",
|
|
1108
|
-
type: "address"
|
|
1109
|
-
}
|
|
1110
|
-
],
|
|
1111
|
-
name: "UpdatedKeyManager",
|
|
1112
|
-
type: "event"
|
|
1113
|
-
},
|
|
1114
|
-
{
|
|
1115
|
-
anonymous: false,
|
|
1116
|
-
inputs: [
|
|
1117
|
-
{
|
|
1118
|
-
indexed: false,
|
|
1119
|
-
internalType: "uint32",
|
|
1120
|
-
name: "dstChain",
|
|
1121
|
-
type: "uint32"
|
|
1122
|
-
},
|
|
1123
|
-
{
|
|
1124
|
-
indexed: false,
|
|
1125
|
-
internalType: "bytes",
|
|
1126
|
-
name: "dstAddress",
|
|
1127
|
-
type: "bytes"
|
|
1128
|
-
},
|
|
1129
|
-
{
|
|
1130
|
-
indexed: false,
|
|
1131
|
-
internalType: "uint32",
|
|
1132
|
-
name: "dstToken",
|
|
1133
|
-
type: "uint32"
|
|
1134
|
-
},
|
|
1135
|
-
{
|
|
1136
|
-
indexed: false,
|
|
1137
|
-
internalType: "uint256",
|
|
1138
|
-
name: "amount",
|
|
1139
|
-
type: "uint256"
|
|
1140
|
-
},
|
|
1141
|
-
{
|
|
1142
|
-
indexed: true,
|
|
1143
|
-
internalType: "address",
|
|
1144
|
-
name: "sender",
|
|
1145
|
-
type: "address"
|
|
1146
|
-
},
|
|
1147
|
-
{
|
|
1148
|
-
indexed: false,
|
|
1149
|
-
internalType: "bytes",
|
|
1150
|
-
name: "message",
|
|
1151
|
-
type: "bytes"
|
|
1152
|
-
},
|
|
1153
|
-
{
|
|
1154
|
-
indexed: false,
|
|
1155
|
-
internalType: "uint256",
|
|
1156
|
-
name: "gasAmount",
|
|
1157
|
-
type: "uint256"
|
|
1158
|
-
},
|
|
1159
|
-
{
|
|
1160
|
-
indexed: false,
|
|
1161
|
-
internalType: "bytes",
|
|
1162
|
-
name: "cfParameters",
|
|
1163
|
-
type: "bytes"
|
|
1164
|
-
}
|
|
1165
|
-
],
|
|
1166
|
-
name: "XCallNative",
|
|
1167
|
-
type: "event"
|
|
1168
|
-
},
|
|
1169
|
-
{
|
|
1170
|
-
anonymous: false,
|
|
1171
|
-
inputs: [
|
|
1172
|
-
{
|
|
1173
|
-
indexed: false,
|
|
1174
|
-
internalType: "uint32",
|
|
1175
|
-
name: "dstChain",
|
|
1176
|
-
type: "uint32"
|
|
1177
|
-
},
|
|
1178
|
-
{
|
|
1179
|
-
indexed: false,
|
|
1180
|
-
internalType: "bytes",
|
|
1181
|
-
name: "dstAddress",
|
|
1182
|
-
type: "bytes"
|
|
1183
|
-
},
|
|
1184
|
-
{
|
|
1185
|
-
indexed: false,
|
|
1186
|
-
internalType: "uint32",
|
|
1187
|
-
name: "dstToken",
|
|
1188
|
-
type: "uint32"
|
|
1189
|
-
},
|
|
1190
|
-
{
|
|
1191
|
-
indexed: false,
|
|
1192
|
-
internalType: "address",
|
|
1193
|
-
name: "srcToken",
|
|
1194
|
-
type: "address"
|
|
1195
|
-
},
|
|
1196
|
-
{
|
|
1197
|
-
indexed: false,
|
|
1198
|
-
internalType: "uint256",
|
|
1199
|
-
name: "amount",
|
|
1200
|
-
type: "uint256"
|
|
1201
|
-
},
|
|
1202
|
-
{
|
|
1203
|
-
indexed: true,
|
|
1204
|
-
internalType: "address",
|
|
1205
|
-
name: "sender",
|
|
1206
|
-
type: "address"
|
|
1207
|
-
},
|
|
1208
|
-
{
|
|
1209
|
-
indexed: false,
|
|
1210
|
-
internalType: "bytes",
|
|
1211
|
-
name: "message",
|
|
1212
|
-
type: "bytes"
|
|
1213
|
-
},
|
|
1214
|
-
{
|
|
1215
|
-
indexed: false,
|
|
1216
|
-
internalType: "uint256",
|
|
1217
|
-
name: "gasAmount",
|
|
1218
|
-
type: "uint256"
|
|
1219
|
-
},
|
|
1220
|
-
{
|
|
1221
|
-
indexed: false,
|
|
1222
|
-
internalType: "bytes",
|
|
1223
|
-
name: "cfParameters",
|
|
1224
|
-
type: "bytes"
|
|
1225
|
-
}
|
|
1226
|
-
],
|
|
1227
|
-
name: "XCallToken",
|
|
1228
|
-
type: "event"
|
|
1229
|
-
},
|
|
1230
|
-
{
|
|
1231
|
-
inputs: [
|
|
1232
|
-
{
|
|
1233
|
-
internalType: "bytes32",
|
|
1234
|
-
name: "swapID",
|
|
1235
|
-
type: "bytes32"
|
|
1236
|
-
}
|
|
1237
|
-
],
|
|
1238
|
-
name: "addGasNative",
|
|
1239
|
-
outputs: [],
|
|
1240
|
-
stateMutability: "payable",
|
|
1241
|
-
type: "function"
|
|
1242
|
-
},
|
|
1243
|
-
{
|
|
1244
|
-
inputs: [
|
|
1245
|
-
{
|
|
1246
|
-
internalType: "bytes32",
|
|
1247
|
-
name: "swapID",
|
|
1248
|
-
type: "bytes32"
|
|
1249
|
-
},
|
|
1250
|
-
{
|
|
1251
|
-
internalType: "uint256",
|
|
1252
|
-
name: "amount",
|
|
1253
|
-
type: "uint256"
|
|
1254
|
-
},
|
|
1255
|
-
{
|
|
1256
|
-
internalType: "contract IERC20",
|
|
1257
|
-
name: "token",
|
|
1258
|
-
type: "address"
|
|
1259
|
-
}
|
|
1260
|
-
],
|
|
1261
|
-
name: "addGasToken",
|
|
1262
|
-
outputs: [],
|
|
1263
|
-
stateMutability: "nonpayable",
|
|
1264
|
-
type: "function"
|
|
1265
|
-
},
|
|
1266
|
-
{
|
|
1267
|
-
inputs: [
|
|
1268
|
-
{
|
|
1269
|
-
components: [
|
|
1270
|
-
{
|
|
1271
|
-
internalType: "uint256",
|
|
1272
|
-
name: "sig",
|
|
1273
|
-
type: "uint256"
|
|
1274
|
-
},
|
|
1275
|
-
{
|
|
1276
|
-
internalType: "uint256",
|
|
1277
|
-
name: "nonce",
|
|
1278
|
-
type: "uint256"
|
|
1279
|
-
},
|
|
1280
|
-
{
|
|
1281
|
-
internalType: "address",
|
|
1282
|
-
name: "kTimesGAddress",
|
|
1283
|
-
type: "address"
|
|
1284
|
-
}
|
|
1285
|
-
],
|
|
1286
|
-
internalType: "struct IShared.SigData",
|
|
1287
|
-
name: "sigData",
|
|
1288
|
-
type: "tuple"
|
|
1289
|
-
},
|
|
1290
|
-
{
|
|
1291
|
-
components: [
|
|
1292
|
-
{
|
|
1293
|
-
internalType: "bytes32",
|
|
1294
|
-
name: "swapID",
|
|
1295
|
-
type: "bytes32"
|
|
1296
|
-
},
|
|
1297
|
-
{
|
|
1298
|
-
internalType: "address",
|
|
1299
|
-
name: "token",
|
|
1300
|
-
type: "address"
|
|
1301
|
-
}
|
|
1302
|
-
],
|
|
1303
|
-
internalType: "struct IShared.DeployFetchParams[]",
|
|
1304
|
-
name: "deployFetchParamsArray",
|
|
1305
|
-
type: "tuple[]"
|
|
1306
|
-
},
|
|
1307
|
-
{
|
|
1308
|
-
components: [
|
|
1309
|
-
{
|
|
1310
|
-
internalType: "address payable",
|
|
1311
|
-
name: "fetchContract",
|
|
1312
|
-
type: "address"
|
|
1313
|
-
},
|
|
1314
|
-
{
|
|
1315
|
-
internalType: "address",
|
|
1316
|
-
name: "token",
|
|
1317
|
-
type: "address"
|
|
1318
|
-
}
|
|
1319
|
-
],
|
|
1320
|
-
internalType: "struct IShared.FetchParams[]",
|
|
1321
|
-
name: "fetchParamsArray",
|
|
1322
|
-
type: "tuple[]"
|
|
1323
|
-
},
|
|
1324
|
-
{
|
|
1325
|
-
components: [
|
|
1326
|
-
{
|
|
1327
|
-
internalType: "address",
|
|
1328
|
-
name: "token",
|
|
1329
|
-
type: "address"
|
|
1330
|
-
},
|
|
1331
|
-
{
|
|
1332
|
-
internalType: "address payable",
|
|
1333
|
-
name: "recipient",
|
|
1334
|
-
type: "address"
|
|
1335
|
-
},
|
|
1336
|
-
{
|
|
1337
|
-
internalType: "uint256",
|
|
1338
|
-
name: "amount",
|
|
1339
|
-
type: "uint256"
|
|
1340
|
-
}
|
|
1341
|
-
],
|
|
1342
|
-
internalType: "struct IShared.TransferParams[]",
|
|
1343
|
-
name: "transferParamsArray",
|
|
1344
|
-
type: "tuple[]"
|
|
1345
|
-
}
|
|
1346
|
-
],
|
|
1347
|
-
name: "allBatch",
|
|
1348
|
-
outputs: [],
|
|
1349
|
-
stateMutability: "nonpayable",
|
|
1350
|
-
type: "function"
|
|
1351
|
-
},
|
|
1352
|
-
{
|
|
1353
|
-
inputs: [
|
|
1354
|
-
{
|
|
1355
|
-
components: [
|
|
1356
|
-
{
|
|
1357
|
-
internalType: "uint256",
|
|
1358
|
-
name: "sig",
|
|
1359
|
-
type: "uint256"
|
|
1360
|
-
},
|
|
1361
|
-
{
|
|
1362
|
-
internalType: "uint256",
|
|
1363
|
-
name: "nonce",
|
|
1364
|
-
type: "uint256"
|
|
1365
|
-
},
|
|
1366
|
-
{
|
|
1367
|
-
internalType: "address",
|
|
1368
|
-
name: "kTimesGAddress",
|
|
1369
|
-
type: "address"
|
|
1370
|
-
}
|
|
1371
|
-
],
|
|
1372
|
-
internalType: "struct IShared.SigData",
|
|
1373
|
-
name: "sigData",
|
|
1374
|
-
type: "tuple"
|
|
1375
|
-
},
|
|
1376
|
-
{
|
|
1377
|
-
components: [
|
|
1378
|
-
{
|
|
1379
|
-
internalType: "bytes32",
|
|
1380
|
-
name: "swapID",
|
|
1381
|
-
type: "bytes32"
|
|
1382
|
-
},
|
|
1383
|
-
{
|
|
1384
|
-
internalType: "address",
|
|
1385
|
-
name: "token",
|
|
1386
|
-
type: "address"
|
|
1387
|
-
}
|
|
1388
|
-
],
|
|
1389
|
-
internalType: "struct IShared.DeployFetchParams[]",
|
|
1390
|
-
name: "deployFetchParamsArray",
|
|
1391
|
-
type: "tuple[]"
|
|
1392
|
-
}
|
|
1393
|
-
],
|
|
1394
|
-
name: "deployAndFetchBatch",
|
|
1395
|
-
outputs: [],
|
|
1396
|
-
stateMutability: "nonpayable",
|
|
1397
|
-
type: "function"
|
|
1398
|
-
},
|
|
1399
|
-
{
|
|
1400
|
-
inputs: [],
|
|
1401
|
-
name: "disableCommunityGuard",
|
|
1402
|
-
outputs: [],
|
|
1403
|
-
stateMutability: "nonpayable",
|
|
1404
|
-
type: "function"
|
|
1405
|
-
},
|
|
1406
|
-
{
|
|
1407
|
-
inputs: [],
|
|
1408
|
-
name: "enableCommunityGuard",
|
|
1409
|
-
outputs: [],
|
|
1410
|
-
stateMutability: "nonpayable",
|
|
1411
|
-
type: "function"
|
|
1412
|
-
},
|
|
1413
|
-
{
|
|
1414
|
-
inputs: [
|
|
1415
|
-
{
|
|
1416
|
-
components: [
|
|
1417
|
-
{
|
|
1418
|
-
internalType: "uint256",
|
|
1419
|
-
name: "sig",
|
|
1420
|
-
type: "uint256"
|
|
1421
|
-
},
|
|
1422
|
-
{
|
|
1423
|
-
internalType: "uint256",
|
|
1424
|
-
name: "nonce",
|
|
1425
|
-
type: "uint256"
|
|
1426
|
-
},
|
|
1427
|
-
{
|
|
1428
|
-
internalType: "address",
|
|
1429
|
-
name: "kTimesGAddress",
|
|
1430
|
-
type: "address"
|
|
1431
|
-
}
|
|
1432
|
-
],
|
|
1433
|
-
internalType: "struct IShared.SigData",
|
|
1434
|
-
name: "sigData",
|
|
1435
|
-
type: "tuple"
|
|
1436
|
-
},
|
|
1437
|
-
{
|
|
1438
|
-
components: [
|
|
1439
|
-
{
|
|
1440
|
-
internalType: "address",
|
|
1441
|
-
name: "token",
|
|
1442
|
-
type: "address"
|
|
1443
|
-
},
|
|
1444
|
-
{
|
|
1445
|
-
internalType: "address payable",
|
|
1446
|
-
name: "recipient",
|
|
1447
|
-
type: "address"
|
|
1448
|
-
},
|
|
1449
|
-
{
|
|
1450
|
-
internalType: "uint256",
|
|
1451
|
-
name: "amount",
|
|
1452
|
-
type: "uint256"
|
|
1453
|
-
}
|
|
1454
|
-
],
|
|
1455
|
-
internalType: "struct IShared.TransferParams",
|
|
1456
|
-
name: "transferParams",
|
|
1457
|
-
type: "tuple"
|
|
1458
|
-
},
|
|
1459
|
-
{
|
|
1460
|
-
components: [
|
|
1461
|
-
{
|
|
1462
|
-
internalType: "enum IMulticall.CallType",
|
|
1463
|
-
name: "callType",
|
|
1464
|
-
type: "uint8"
|
|
1465
|
-
},
|
|
1466
|
-
{
|
|
1467
|
-
internalType: "address",
|
|
1468
|
-
name: "target",
|
|
1469
|
-
type: "address"
|
|
1470
|
-
},
|
|
1471
|
-
{
|
|
1472
|
-
internalType: "uint256",
|
|
1473
|
-
name: "value",
|
|
1474
|
-
type: "uint256"
|
|
1475
|
-
},
|
|
1476
|
-
{
|
|
1477
|
-
internalType: "bytes",
|
|
1478
|
-
name: "callData",
|
|
1479
|
-
type: "bytes"
|
|
1480
|
-
},
|
|
1481
|
-
{
|
|
1482
|
-
internalType: "bytes",
|
|
1483
|
-
name: "payload",
|
|
1484
|
-
type: "bytes"
|
|
1485
|
-
}
|
|
1486
|
-
],
|
|
1487
|
-
internalType: "struct IMulticall.Call[]",
|
|
1488
|
-
name: "calls",
|
|
1489
|
-
type: "tuple[]"
|
|
1490
|
-
},
|
|
1491
|
-
{
|
|
1492
|
-
internalType: "uint256",
|
|
1493
|
-
name: "gasMulticall",
|
|
1494
|
-
type: "uint256"
|
|
1495
|
-
}
|
|
1496
|
-
],
|
|
1497
|
-
name: "executeActions",
|
|
1498
|
-
outputs: [],
|
|
1499
|
-
stateMutability: "nonpayable",
|
|
1500
|
-
type: "function"
|
|
1501
|
-
},
|
|
1502
|
-
{
|
|
1503
|
-
inputs: [
|
|
1504
|
-
{
|
|
1505
|
-
components: [
|
|
1506
|
-
{
|
|
1507
|
-
internalType: "uint256",
|
|
1508
|
-
name: "sig",
|
|
1509
|
-
type: "uint256"
|
|
1510
|
-
},
|
|
1511
|
-
{
|
|
1512
|
-
internalType: "uint256",
|
|
1513
|
-
name: "nonce",
|
|
1514
|
-
type: "uint256"
|
|
1515
|
-
},
|
|
1516
|
-
{
|
|
1517
|
-
internalType: "address",
|
|
1518
|
-
name: "kTimesGAddress",
|
|
1519
|
-
type: "address"
|
|
1520
|
-
}
|
|
1521
|
-
],
|
|
1522
|
-
internalType: "struct IShared.SigData",
|
|
1523
|
-
name: "sigData",
|
|
1524
|
-
type: "tuple"
|
|
1525
|
-
},
|
|
1526
|
-
{
|
|
1527
|
-
internalType: "address",
|
|
1528
|
-
name: "recipient",
|
|
1529
|
-
type: "address"
|
|
1530
|
-
},
|
|
1531
|
-
{
|
|
1532
|
-
internalType: "uint32",
|
|
1533
|
-
name: "srcChain",
|
|
1534
|
-
type: "uint32"
|
|
1535
|
-
},
|
|
1536
|
-
{
|
|
1537
|
-
internalType: "bytes",
|
|
1538
|
-
name: "srcAddress",
|
|
1539
|
-
type: "bytes"
|
|
1540
|
-
},
|
|
1541
|
-
{
|
|
1542
|
-
internalType: "bytes",
|
|
1543
|
-
name: "message",
|
|
1544
|
-
type: "bytes"
|
|
1545
|
-
}
|
|
1546
|
-
],
|
|
1547
|
-
name: "executexCall",
|
|
1548
|
-
outputs: [],
|
|
1549
|
-
stateMutability: "nonpayable",
|
|
1550
|
-
type: "function"
|
|
1551
|
-
},
|
|
1552
|
-
{
|
|
1553
|
-
inputs: [
|
|
1554
|
-
{
|
|
1555
|
-
components: [
|
|
1556
|
-
{
|
|
1557
|
-
internalType: "uint256",
|
|
1558
|
-
name: "sig",
|
|
1559
|
-
type: "uint256"
|
|
1560
|
-
},
|
|
1561
|
-
{
|
|
1562
|
-
internalType: "uint256",
|
|
1563
|
-
name: "nonce",
|
|
1564
|
-
type: "uint256"
|
|
1565
|
-
},
|
|
1566
|
-
{
|
|
1567
|
-
internalType: "address",
|
|
1568
|
-
name: "kTimesGAddress",
|
|
1569
|
-
type: "address"
|
|
1570
|
-
}
|
|
1571
|
-
],
|
|
1572
|
-
internalType: "struct IShared.SigData",
|
|
1573
|
-
name: "sigData",
|
|
1574
|
-
type: "tuple"
|
|
1575
|
-
},
|
|
1576
|
-
{
|
|
1577
|
-
components: [
|
|
1578
|
-
{
|
|
1579
|
-
internalType: "address",
|
|
1580
|
-
name: "token",
|
|
1581
|
-
type: "address"
|
|
1582
|
-
},
|
|
1583
|
-
{
|
|
1584
|
-
internalType: "address payable",
|
|
1585
|
-
name: "recipient",
|
|
1586
|
-
type: "address"
|
|
1587
|
-
},
|
|
1588
|
-
{
|
|
1589
|
-
internalType: "uint256",
|
|
1590
|
-
name: "amount",
|
|
1591
|
-
type: "uint256"
|
|
1592
|
-
}
|
|
1593
|
-
],
|
|
1594
|
-
internalType: "struct IShared.TransferParams",
|
|
1595
|
-
name: "transferParams",
|
|
1596
|
-
type: "tuple"
|
|
1597
|
-
},
|
|
1598
|
-
{
|
|
1599
|
-
internalType: "uint32",
|
|
1600
|
-
name: "srcChain",
|
|
1601
|
-
type: "uint32"
|
|
1602
|
-
},
|
|
1603
|
-
{
|
|
1604
|
-
internalType: "bytes",
|
|
1605
|
-
name: "srcAddress",
|
|
1606
|
-
type: "bytes"
|
|
1607
|
-
},
|
|
1608
|
-
{
|
|
1609
|
-
internalType: "bytes",
|
|
1610
|
-
name: "message",
|
|
1611
|
-
type: "bytes"
|
|
1612
|
-
}
|
|
1613
|
-
],
|
|
1614
|
-
name: "executexSwapAndCall",
|
|
1615
|
-
outputs: [],
|
|
1616
|
-
stateMutability: "nonpayable",
|
|
1617
|
-
type: "function"
|
|
1618
|
-
},
|
|
1619
|
-
{
|
|
1620
|
-
inputs: [
|
|
1621
|
-
{
|
|
1622
|
-
components: [
|
|
1623
|
-
{
|
|
1624
|
-
internalType: "uint256",
|
|
1625
|
-
name: "sig",
|
|
1626
|
-
type: "uint256"
|
|
1627
|
-
},
|
|
1628
|
-
{
|
|
1629
|
-
internalType: "uint256",
|
|
1630
|
-
name: "nonce",
|
|
1631
|
-
type: "uint256"
|
|
1632
|
-
},
|
|
1633
|
-
{
|
|
1634
|
-
internalType: "address",
|
|
1635
|
-
name: "kTimesGAddress",
|
|
1636
|
-
type: "address"
|
|
1637
|
-
}
|
|
1638
|
-
],
|
|
1639
|
-
internalType: "struct IShared.SigData",
|
|
1640
|
-
name: "sigData",
|
|
1641
|
-
type: "tuple"
|
|
1642
|
-
},
|
|
1643
|
-
{
|
|
1644
|
-
components: [
|
|
1645
|
-
{
|
|
1646
|
-
internalType: "address payable",
|
|
1647
|
-
name: "fetchContract",
|
|
1648
|
-
type: "address"
|
|
1649
|
-
},
|
|
1650
|
-
{
|
|
1651
|
-
internalType: "address",
|
|
1652
|
-
name: "token",
|
|
1653
|
-
type: "address"
|
|
1654
|
-
}
|
|
1655
|
-
],
|
|
1656
|
-
internalType: "struct IShared.FetchParams[]",
|
|
1657
|
-
name: "fetchParamsArray",
|
|
1658
|
-
type: "tuple[]"
|
|
1659
|
-
}
|
|
1660
|
-
],
|
|
1661
|
-
name: "fetchBatch",
|
|
1662
|
-
outputs: [],
|
|
1663
|
-
stateMutability: "nonpayable",
|
|
1664
|
-
type: "function"
|
|
1665
|
-
},
|
|
1666
|
-
{
|
|
1667
|
-
inputs: [],
|
|
1668
|
-
name: "getCommunityGuardDisabled",
|
|
1669
|
-
outputs: [
|
|
1670
|
-
{
|
|
1671
|
-
internalType: "bool",
|
|
1672
|
-
name: "",
|
|
1673
|
-
type: "bool"
|
|
1674
|
-
}
|
|
1675
|
-
],
|
|
1676
|
-
stateMutability: "view",
|
|
1677
|
-
type: "function"
|
|
1678
|
-
},
|
|
1679
|
-
{
|
|
1680
|
-
inputs: [],
|
|
1681
|
-
name: "getCommunityKey",
|
|
1682
|
-
outputs: [
|
|
1683
|
-
{
|
|
1684
|
-
internalType: "address",
|
|
1685
|
-
name: "",
|
|
1686
|
-
type: "address"
|
|
1687
|
-
}
|
|
1688
|
-
],
|
|
1689
|
-
stateMutability: "view",
|
|
1690
|
-
type: "function"
|
|
1691
|
-
},
|
|
1692
|
-
{
|
|
1693
|
-
inputs: [],
|
|
1694
|
-
name: "getGovernor",
|
|
1695
|
-
outputs: [
|
|
1696
|
-
{
|
|
1697
|
-
internalType: "address",
|
|
1698
|
-
name: "",
|
|
1699
|
-
type: "address"
|
|
1700
|
-
}
|
|
1701
|
-
],
|
|
1702
|
-
stateMutability: "view",
|
|
1703
|
-
type: "function"
|
|
1704
|
-
},
|
|
1705
|
-
{
|
|
1706
|
-
inputs: [],
|
|
1707
|
-
name: "getKeyManager",
|
|
1708
|
-
outputs: [
|
|
1709
|
-
{
|
|
1710
|
-
internalType: "contract IKeyManager",
|
|
1711
|
-
name: "",
|
|
1712
|
-
type: "address"
|
|
1713
|
-
}
|
|
1714
|
-
],
|
|
1715
|
-
stateMutability: "view",
|
|
1716
|
-
type: "function"
|
|
1717
|
-
},
|
|
1718
|
-
{
|
|
1719
|
-
inputs: [],
|
|
1720
|
-
name: "getSuspendedState",
|
|
1721
|
-
outputs: [
|
|
1722
|
-
{
|
|
1723
|
-
internalType: "bool",
|
|
1724
|
-
name: "",
|
|
1725
|
-
type: "bool"
|
|
1726
|
-
}
|
|
1727
|
-
],
|
|
1728
|
-
stateMutability: "view",
|
|
1729
|
-
type: "function"
|
|
1730
|
-
},
|
|
1731
|
-
{
|
|
1732
|
-
inputs: [
|
|
1733
|
-
{
|
|
1734
|
-
internalType: "address[]",
|
|
1735
|
-
name: "tokens",
|
|
1736
|
-
type: "address[]"
|
|
1737
|
-
}
|
|
1738
|
-
],
|
|
1739
|
-
name: "govWithdraw",
|
|
1740
|
-
outputs: [],
|
|
1741
|
-
stateMutability: "nonpayable",
|
|
1742
|
-
type: "function"
|
|
1743
|
-
},
|
|
1744
|
-
{
|
|
1745
|
-
inputs: [],
|
|
1746
|
-
name: "resume",
|
|
1747
|
-
outputs: [],
|
|
1748
|
-
stateMutability: "nonpayable",
|
|
1749
|
-
type: "function"
|
|
1750
|
-
},
|
|
1751
|
-
{
|
|
1752
|
-
inputs: [],
|
|
1753
|
-
name: "suspend",
|
|
1754
|
-
outputs: [],
|
|
1755
|
-
stateMutability: "nonpayable",
|
|
1756
|
-
type: "function"
|
|
1757
|
-
},
|
|
1758
|
-
{
|
|
1759
|
-
inputs: [
|
|
1760
|
-
{
|
|
1761
|
-
components: [
|
|
1762
|
-
{
|
|
1763
|
-
internalType: "uint256",
|
|
1764
|
-
name: "sig",
|
|
1765
|
-
type: "uint256"
|
|
1766
|
-
},
|
|
1767
|
-
{
|
|
1768
|
-
internalType: "uint256",
|
|
1769
|
-
name: "nonce",
|
|
1770
|
-
type: "uint256"
|
|
1771
|
-
},
|
|
1772
|
-
{
|
|
1773
|
-
internalType: "address",
|
|
1774
|
-
name: "kTimesGAddress",
|
|
1775
|
-
type: "address"
|
|
1776
|
-
}
|
|
1777
|
-
],
|
|
1778
|
-
internalType: "struct IShared.SigData",
|
|
1779
|
-
name: "sigData",
|
|
1780
|
-
type: "tuple"
|
|
1781
|
-
},
|
|
1782
|
-
{
|
|
1783
|
-
components: [
|
|
1784
|
-
{
|
|
1785
|
-
internalType: "address",
|
|
1786
|
-
name: "token",
|
|
1787
|
-
type: "address"
|
|
1788
|
-
},
|
|
1789
|
-
{
|
|
1790
|
-
internalType: "address payable",
|
|
1791
|
-
name: "recipient",
|
|
1792
|
-
type: "address"
|
|
1793
|
-
},
|
|
1794
|
-
{
|
|
1795
|
-
internalType: "uint256",
|
|
1796
|
-
name: "amount",
|
|
1797
|
-
type: "uint256"
|
|
1798
|
-
}
|
|
1799
|
-
],
|
|
1800
|
-
internalType: "struct IShared.TransferParams",
|
|
1801
|
-
name: "transferParams",
|
|
1802
|
-
type: "tuple"
|
|
1803
|
-
}
|
|
1804
|
-
],
|
|
1805
|
-
name: "transfer",
|
|
1806
|
-
outputs: [],
|
|
1807
|
-
stateMutability: "nonpayable",
|
|
1808
|
-
type: "function"
|
|
1809
|
-
},
|
|
1810
|
-
{
|
|
1811
|
-
inputs: [
|
|
1812
|
-
{
|
|
1813
|
-
components: [
|
|
1814
|
-
{
|
|
1815
|
-
internalType: "uint256",
|
|
1816
|
-
name: "sig",
|
|
1817
|
-
type: "uint256"
|
|
1818
|
-
},
|
|
1819
|
-
{
|
|
1820
|
-
internalType: "uint256",
|
|
1821
|
-
name: "nonce",
|
|
1822
|
-
type: "uint256"
|
|
1823
|
-
},
|
|
1824
|
-
{
|
|
1825
|
-
internalType: "address",
|
|
1826
|
-
name: "kTimesGAddress",
|
|
1827
|
-
type: "address"
|
|
1828
|
-
}
|
|
1829
|
-
],
|
|
1830
|
-
internalType: "struct IShared.SigData",
|
|
1831
|
-
name: "sigData",
|
|
1832
|
-
type: "tuple"
|
|
1833
|
-
},
|
|
1834
|
-
{
|
|
1835
|
-
components: [
|
|
1836
|
-
{
|
|
1837
|
-
internalType: "address",
|
|
1838
|
-
name: "token",
|
|
1839
|
-
type: "address"
|
|
1840
|
-
},
|
|
1841
|
-
{
|
|
1842
|
-
internalType: "address payable",
|
|
1843
|
-
name: "recipient",
|
|
1844
|
-
type: "address"
|
|
1845
|
-
},
|
|
1846
|
-
{
|
|
1847
|
-
internalType: "uint256",
|
|
1848
|
-
name: "amount",
|
|
1849
|
-
type: "uint256"
|
|
1850
|
-
}
|
|
1851
|
-
],
|
|
1852
|
-
internalType: "struct IShared.TransferParams[]",
|
|
1853
|
-
name: "transferParamsArray",
|
|
1854
|
-
type: "tuple[]"
|
|
1855
|
-
}
|
|
1856
|
-
],
|
|
1857
|
-
name: "transferBatch",
|
|
1858
|
-
outputs: [],
|
|
1859
|
-
stateMutability: "nonpayable",
|
|
1860
|
-
type: "function"
|
|
1861
|
-
},
|
|
1862
|
-
{
|
|
1863
|
-
inputs: [
|
|
1864
|
-
{
|
|
1865
|
-
components: [
|
|
1866
|
-
{
|
|
1867
|
-
internalType: "uint256",
|
|
1868
|
-
name: "sig",
|
|
1869
|
-
type: "uint256"
|
|
1870
|
-
},
|
|
1871
|
-
{
|
|
1872
|
-
internalType: "uint256",
|
|
1873
|
-
name: "nonce",
|
|
1874
|
-
type: "uint256"
|
|
1875
|
-
},
|
|
1876
|
-
{
|
|
1877
|
-
internalType: "address",
|
|
1878
|
-
name: "kTimesGAddress",
|
|
1879
|
-
type: "address"
|
|
1880
|
-
}
|
|
1881
|
-
],
|
|
1882
|
-
internalType: "struct IShared.SigData",
|
|
1883
|
-
name: "sigData",
|
|
1884
|
-
type: "tuple"
|
|
1885
|
-
},
|
|
1886
|
-
{
|
|
1887
|
-
internalType: "contract IKeyManager",
|
|
1888
|
-
name: "keyManager",
|
|
1889
|
-
type: "address"
|
|
1890
|
-
},
|
|
1891
|
-
{
|
|
1892
|
-
internalType: "bool",
|
|
1893
|
-
name: "omitChecks",
|
|
1894
|
-
type: "bool"
|
|
1895
|
-
}
|
|
1896
|
-
],
|
|
1897
|
-
name: "updateKeyManager",
|
|
1898
|
-
outputs: [],
|
|
1899
|
-
stateMutability: "nonpayable",
|
|
1900
|
-
type: "function"
|
|
1901
|
-
},
|
|
1902
|
-
{
|
|
1903
|
-
inputs: [
|
|
1904
|
-
{
|
|
1905
|
-
internalType: "uint32",
|
|
1906
|
-
name: "dstChain",
|
|
1907
|
-
type: "uint32"
|
|
1908
|
-
},
|
|
1909
|
-
{
|
|
1910
|
-
internalType: "bytes",
|
|
1911
|
-
name: "dstAddress",
|
|
1912
|
-
type: "bytes"
|
|
1913
|
-
},
|
|
1914
|
-
{
|
|
1915
|
-
internalType: "uint32",
|
|
1916
|
-
name: "dstToken",
|
|
1917
|
-
type: "uint32"
|
|
1918
|
-
},
|
|
1919
|
-
{
|
|
1920
|
-
internalType: "bytes",
|
|
1921
|
-
name: "message",
|
|
1922
|
-
type: "bytes"
|
|
1923
|
-
},
|
|
1924
|
-
{
|
|
1925
|
-
internalType: "uint256",
|
|
1926
|
-
name: "gasAmount",
|
|
1927
|
-
type: "uint256"
|
|
1928
|
-
},
|
|
1929
|
-
{
|
|
1930
|
-
internalType: "bytes",
|
|
1931
|
-
name: "cfParameters",
|
|
1932
|
-
type: "bytes"
|
|
1933
|
-
}
|
|
1934
|
-
],
|
|
1935
|
-
name: "xCallNative",
|
|
1936
|
-
outputs: [],
|
|
1937
|
-
stateMutability: "payable",
|
|
1938
|
-
type: "function"
|
|
1939
|
-
},
|
|
1940
|
-
{
|
|
1941
|
-
inputs: [
|
|
1942
|
-
{
|
|
1943
|
-
internalType: "uint32",
|
|
1944
|
-
name: "dstChain",
|
|
1945
|
-
type: "uint32"
|
|
1946
|
-
},
|
|
1947
|
-
{
|
|
1948
|
-
internalType: "bytes",
|
|
1949
|
-
name: "dstAddress",
|
|
1950
|
-
type: "bytes"
|
|
1951
|
-
},
|
|
1952
|
-
{
|
|
1953
|
-
internalType: "uint32",
|
|
1954
|
-
name: "dstToken",
|
|
1955
|
-
type: "uint32"
|
|
1956
|
-
},
|
|
1957
|
-
{
|
|
1958
|
-
internalType: "bytes",
|
|
1959
|
-
name: "message",
|
|
1960
|
-
type: "bytes"
|
|
1961
|
-
},
|
|
1962
|
-
{
|
|
1963
|
-
internalType: "uint256",
|
|
1964
|
-
name: "gasAmount",
|
|
1965
|
-
type: "uint256"
|
|
1966
|
-
},
|
|
1967
|
-
{
|
|
1968
|
-
internalType: "contract IERC20",
|
|
1969
|
-
name: "srcToken",
|
|
1970
|
-
type: "address"
|
|
1971
|
-
},
|
|
1972
|
-
{
|
|
1973
|
-
internalType: "uint256",
|
|
1974
|
-
name: "amount",
|
|
1975
|
-
type: "uint256"
|
|
1976
|
-
},
|
|
1977
|
-
{
|
|
1978
|
-
internalType: "bytes",
|
|
1979
|
-
name: "cfParameters",
|
|
1980
|
-
type: "bytes"
|
|
1981
|
-
}
|
|
1982
|
-
],
|
|
1983
|
-
name: "xCallToken",
|
|
1984
|
-
outputs: [],
|
|
1985
|
-
stateMutability: "nonpayable",
|
|
1986
|
-
type: "function"
|
|
1987
|
-
},
|
|
1988
|
-
{
|
|
1989
|
-
inputs: [
|
|
1990
|
-
{
|
|
1991
|
-
internalType: "uint32",
|
|
1992
|
-
name: "dstChain",
|
|
1993
|
-
type: "uint32"
|
|
1994
|
-
},
|
|
1995
|
-
{
|
|
1996
|
-
internalType: "bytes",
|
|
1997
|
-
name: "dstAddress",
|
|
1998
|
-
type: "bytes"
|
|
1999
|
-
},
|
|
2000
|
-
{
|
|
2001
|
-
internalType: "uint32",
|
|
2002
|
-
name: "dstToken",
|
|
2003
|
-
type: "uint32"
|
|
2004
|
-
},
|
|
2005
|
-
{
|
|
2006
|
-
internalType: "bytes",
|
|
2007
|
-
name: "cfParameters",
|
|
2008
|
-
type: "bytes"
|
|
2009
|
-
}
|
|
2010
|
-
],
|
|
2011
|
-
name: "xSwapNative",
|
|
2012
|
-
outputs: [],
|
|
2013
|
-
stateMutability: "payable",
|
|
2014
|
-
type: "function"
|
|
2015
|
-
},
|
|
2016
|
-
{
|
|
2017
|
-
inputs: [
|
|
2018
|
-
{
|
|
2019
|
-
internalType: "uint32",
|
|
2020
|
-
name: "dstChain",
|
|
2021
|
-
type: "uint32"
|
|
2022
|
-
},
|
|
2023
|
-
{
|
|
2024
|
-
internalType: "bytes",
|
|
2025
|
-
name: "dstAddress",
|
|
2026
|
-
type: "bytes"
|
|
2027
|
-
},
|
|
2028
|
-
{
|
|
2029
|
-
internalType: "uint32",
|
|
2030
|
-
name: "dstToken",
|
|
2031
|
-
type: "uint32"
|
|
2032
|
-
},
|
|
2033
|
-
{
|
|
2034
|
-
internalType: "contract IERC20",
|
|
2035
|
-
name: "srcToken",
|
|
2036
|
-
type: "address"
|
|
2037
|
-
},
|
|
2038
|
-
{
|
|
2039
|
-
internalType: "uint256",
|
|
2040
|
-
name: "amount",
|
|
2041
|
-
type: "uint256"
|
|
2042
|
-
},
|
|
2043
|
-
{
|
|
2044
|
-
internalType: "bytes",
|
|
2045
|
-
name: "cfParameters",
|
|
2046
|
-
type: "bytes"
|
|
2047
|
-
}
|
|
2048
|
-
],
|
|
2049
|
-
name: "xSwapToken",
|
|
2050
|
-
outputs: [],
|
|
2051
|
-
stateMutability: "nonpayable",
|
|
2052
|
-
type: "function"
|
|
2053
|
-
},
|
|
2054
|
-
{
|
|
2055
|
-
stateMutability: "payable",
|
|
2056
|
-
type: "receive"
|
|
2057
|
-
}
|
|
2058
|
-
];
|
|
2059
|
-
var _Vault__factory = class _Vault__factory {
|
|
2060
|
-
static createInterface() {
|
|
2061
|
-
return new ethers.Interface(_abi2);
|
|
2062
|
-
}
|
|
2063
|
-
static connect(address, runner) {
|
|
2064
|
-
return new ethers.Contract(address, _abi2, runner);
|
|
2065
|
-
}
|
|
2066
|
-
};
|
|
2067
|
-
__name(_Vault__factory, "Vault__factory");
|
|
2068
|
-
__publicField(_Vault__factory, "abi", _abi2);
|
|
2069
|
-
var Vault__factory = _Vault__factory;
|
|
2070
|
-
var ETHEREUM_EVM_CHAIN_ID = {
|
|
2071
|
-
[ChainflipNetworks.backspin]: 10997,
|
|
2072
|
-
[ChainflipNetworks.sisyphos]: 11155111,
|
|
2073
|
-
[ChainflipNetworks.perseverance]: 11155111,
|
|
2074
|
-
[ChainflipNetworks.mainnet]: 1
|
|
2075
|
-
};
|
|
2076
|
-
var ARBITRUM_EVM_CHAIN_ID = {
|
|
2077
|
-
[ChainflipNetworks.backspin]: 412346,
|
|
2078
|
-
[ChainflipNetworks.sisyphos]: 421614,
|
|
2079
|
-
[ChainflipNetworks.perseverance]: 421614,
|
|
2080
|
-
[ChainflipNetworks.mainnet]: 42161
|
|
2081
|
-
};
|
|
2082
|
-
var getEvmChainId = /* @__PURE__ */ __name((chain2, network) => {
|
|
2083
|
-
switch (chain2) {
|
|
2084
|
-
case Chains.Ethereum:
|
|
2085
|
-
return ETHEREUM_EVM_CHAIN_ID[network];
|
|
2086
|
-
case Chains.Arbitrum:
|
|
2087
|
-
return ARBITRUM_EVM_CHAIN_ID[network];
|
|
2088
|
-
default:
|
|
2089
|
-
return void 0;
|
|
2090
|
-
}
|
|
2091
|
-
}, "getEvmChainId");
|
|
2092
|
-
var SEPOLIA_USDC_CONTRACT_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
|
|
2093
|
-
var SEPOLIA_USDT_CONTRACT_ADDRESS = "0x27CEA6Eb8a21Aae05Eb29C91c5CA10592892F584";
|
|
2094
|
-
var ADDRESSES = {
|
|
2095
|
-
[ChainflipNetworks.backspin]: {
|
|
2096
|
-
FLIP_CONTRACT_ADDRESS: "0x10C6E9530F1C1AF873a391030a1D9E8ed0630D26",
|
|
2097
|
-
USDC_CONTRACT_ADDRESS: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
|
|
2098
|
-
USDT_CONTRACT_ADDRESS: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
2099
|
-
ARBUSDC_CONTRACT_ADDRESS: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
|
|
2100
|
-
VAULT_CONTRACT_ADDRESS: "0xB7A5bd0345EF1Cc5E66bf61BdeC17D2461fBd968",
|
|
2101
|
-
STATE_CHAIN_GATEWAY_ADDRESS: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883",
|
|
2102
|
-
ARB_VAULT_CONTRACT_ADDRESS: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
2103
|
-
// TODO(solana)
|
|
2104
|
-
SOLUSDC_CONTRACT_ADDRESS: ""
|
|
2105
|
-
},
|
|
2106
|
-
[ChainflipNetworks.sisyphos]: {
|
|
2107
|
-
FLIP_CONTRACT_ADDRESS: "0xcD079EAB6B5443b545788Fd210C8800FEADd87fa",
|
|
2108
|
-
USDC_CONTRACT_ADDRESS: SEPOLIA_USDC_CONTRACT_ADDRESS,
|
|
2109
|
-
USDT_CONTRACT_ADDRESS: SEPOLIA_USDT_CONTRACT_ADDRESS,
|
|
2110
|
-
ARBUSDC_CONTRACT_ADDRESS: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
2111
|
-
VAULT_CONTRACT_ADDRESS: "0xa94d6b1853F3cb611Ed3cCb701b4fdA5a9DACe85",
|
|
2112
|
-
STATE_CHAIN_GATEWAY_ADDRESS: "0x1F7fE41C798cc7b1D34BdC8de2dDDA4a4bE744D9",
|
|
2113
|
-
ARB_VAULT_CONTRACT_ADDRESS: "0x8155BdD48CD011e1118b51A1C82be020A3E5c2f2",
|
|
2114
|
-
SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
|
|
2115
|
-
},
|
|
2116
|
-
[ChainflipNetworks.perseverance]: {
|
|
2117
|
-
FLIP_CONTRACT_ADDRESS: "0xdC27c60956cB065D19F08bb69a707E37b36d8086",
|
|
2118
|
-
USDC_CONTRACT_ADDRESS: SEPOLIA_USDC_CONTRACT_ADDRESS,
|
|
2119
|
-
USDT_CONTRACT_ADDRESS: SEPOLIA_USDT_CONTRACT_ADDRESS,
|
|
2120
|
-
ARBUSDC_CONTRACT_ADDRESS: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
2121
|
-
VAULT_CONTRACT_ADDRESS: "0x36eaD71325604DC15d35FAE584D7b50646D81753",
|
|
2122
|
-
STATE_CHAIN_GATEWAY_ADDRESS: "0xA34a967197Ee90BB7fb28e928388a573c5CFd099",
|
|
2123
|
-
ARB_VAULT_CONTRACT_ADDRESS: "0x2bb150e6d4366A1BDBC4275D1F35892CD63F27e3",
|
|
2124
|
-
SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
|
|
815
|
+
[ChainflipNetworks.perseverance]: {
|
|
816
|
+
FLIP_CONTRACT_ADDRESS: "0xdC27c60956cB065D19F08bb69a707E37b36d8086",
|
|
817
|
+
USDC_CONTRACT_ADDRESS: SEPOLIA_USDC_CONTRACT_ADDRESS,
|
|
818
|
+
USDT_CONTRACT_ADDRESS: SEPOLIA_USDT_CONTRACT_ADDRESS,
|
|
819
|
+
ARBUSDC_CONTRACT_ADDRESS: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
820
|
+
STATE_CHAIN_GATEWAY_ADDRESS: "0xA34a967197Ee90BB7fb28e928388a573c5CFd099",
|
|
821
|
+
SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
|
|
2125
822
|
},
|
|
2126
823
|
[ChainflipNetworks.mainnet]: {
|
|
2127
824
|
FLIP_CONTRACT_ADDRESS: "0x826180541412D574cf1336d22c0C0a287822678A",
|
|
2128
825
|
USDC_CONTRACT_ADDRESS: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
2129
826
|
USDT_CONTRACT_ADDRESS: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
2130
827
|
ARBUSDC_CONTRACT_ADDRESS: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
2131
|
-
VAULT_CONTRACT_ADDRESS: "0xF5e10380213880111522dd0efD3dbb45b9f62Bcc",
|
|
2132
828
|
STATE_CHAIN_GATEWAY_ADDRESS: "0x6995Ab7c4D7F4B03f467Cf4c8E920427d9621DBd",
|
|
2133
|
-
ARB_VAULT_CONTRACT_ADDRESS: "0x79001a5e762f3bEFC8e5871b42F6734e00498920",
|
|
2134
829
|
SOLUSDC_CONTRACT_ADDRESS: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
2135
830
|
}
|
|
2136
831
|
};
|
|
2137
832
|
|
|
2138
|
-
//
|
|
2139
|
-
var
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
throw new Error(`No contract address for ${asset2} on ${network}`);
|
|
2150
|
-
}
|
|
2151
|
-
__name(getTokenContractAddress, "getTokenContractAddress");
|
|
2152
|
-
var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20Address, signer) => {
|
|
2153
|
-
const erc20 = ERC20__factory.connect(erc20Address, signer);
|
|
2154
|
-
const signerAddress = await signer.getAddress();
|
|
2155
|
-
const allowance = await erc20.allowance(signerAddress, spenderAddress);
|
|
2156
|
-
return {
|
|
2157
|
-
allowance,
|
|
2158
|
-
hasSufficientAllowance: allowance >= amount,
|
|
2159
|
-
erc20
|
|
2160
|
-
};
|
|
2161
|
-
}, "checkAllowance");
|
|
2162
|
-
var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20, allowance, txOpts) => {
|
|
2163
|
-
if (allowance >= amount) return null;
|
|
2164
|
-
const transaction = await erc20.approve(spenderAddress, amount - allowance, extractOverrides(txOpts));
|
|
2165
|
-
await transaction.wait(txOpts.wait);
|
|
2166
|
-
return transaction;
|
|
2167
|
-
}, "approve");
|
|
2168
|
-
var getVaultContractAddress = /* @__PURE__ */ __name((chain2, network) => {
|
|
2169
|
-
if (chain2 === Chains.Ethereum) return ADDRESSES[network].VAULT_CONTRACT_ADDRESS;
|
|
2170
|
-
if (chain2 === Chains.Arbitrum) return ADDRESSES[network].ARB_VAULT_CONTRACT_ADDRESS;
|
|
2171
|
-
throw new Error(`No vault contract address for ${chain2} on ${network}`);
|
|
2172
|
-
}, "getVaultContractAddress");
|
|
2173
|
-
|
|
2174
|
-
// ../shared/src/evm.ts
|
|
2175
|
-
var assertIsEvmChain = /* @__PURE__ */ __name((chain2) => {
|
|
2176
|
-
const evmChainId = getEvmChainId(chain2, ChainflipNetworks.backspin);
|
|
2177
|
-
assert(evmChainId, `Chain ${chain2} is not an evm chain`);
|
|
2178
|
-
}, "assertIsEvmChain");
|
|
2179
|
-
var assertIsCCMDestination = /* @__PURE__ */ __name((chain2) => {
|
|
2180
|
-
if (chain2 === "Solana") return;
|
|
2181
|
-
assertIsEvmChain(chain2);
|
|
2182
|
-
}, "assertIsCCMDestination");
|
|
2183
|
-
var assertSignerIsConnectedToChain = /* @__PURE__ */ __name(async (opts, chain2) => {
|
|
2184
|
-
if (opts.network === "localnet") return;
|
|
2185
|
-
assert(opts.signer.provider, "Signer has no provider");
|
|
2186
|
-
const sourceChainId = getEvmChainId(chain2, opts.network);
|
|
2187
|
-
assert(sourceChainId, `Chain ${chain2} has no evm chain id`);
|
|
2188
|
-
const { chainId: signerChainId } = await opts.signer.provider.getNetwork();
|
|
2189
|
-
assert(BigInt(signerChainId) === BigInt(sourceChainId), `Signer is connected to unexpected evm chain (expected: ${sourceChainId}, got: ${signerChainId})`);
|
|
2190
|
-
}, "assertSignerIsConnectedToChain");
|
|
2191
|
-
|
|
2192
|
-
// ../shared/src/vault/executeSwap.ts
|
|
2193
|
-
var encodeAddress2 = /* @__PURE__ */ __name((chain2, address) => {
|
|
2194
|
-
if (chain2 === Chains.Polkadot) return bytes.bytesToHex(ss582__namespace.decode(dotAddress.parse(address)).data);
|
|
2195
|
-
if (chain2 === Chains.Bitcoin) return `0x${Buffer.from(address).toString("hex")}`;
|
|
2196
|
-
if (chain2 === Chains.Ethereum || chain2 === Chains.Arbitrum) return address;
|
|
2197
|
-
if (chain2 === Chains.Solana) {
|
|
2198
|
-
if (string$1.isHex(address)) return address;
|
|
2199
|
-
return bytes.bytesToHex(base58__namespace.decode(address));
|
|
2200
|
-
}
|
|
2201
|
-
throw new Error(`cannot encode address for chain ${chain2}`);
|
|
2202
|
-
}, "encodeAddress");
|
|
2203
|
-
var assertIsValidSwap = /* @__PURE__ */ __name((params) => {
|
|
2204
|
-
const { srcAsset, destAsset } = getInternalAssets(params);
|
|
2205
|
-
assert(srcAsset !== destAsset, "source asset and destination asset cannot be the same");
|
|
2206
|
-
}, "assertIsValidSwap");
|
|
2207
|
-
var getVaultContract = /* @__PURE__ */ __name((chain2, networkOpts) => {
|
|
2208
|
-
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultContractAddress(chain2, networkOpts.network);
|
|
2209
|
-
return {
|
|
2210
|
-
vaultContract: Vault__factory.connect(vaultContractAddress, networkOpts.signer),
|
|
2211
|
-
vaultAddress: vaultContractAddress
|
|
2212
|
-
};
|
|
2213
|
-
}, "getVaultContract");
|
|
2214
|
-
var getErc20Address = /* @__PURE__ */ __name((asset2, networkOpts) => {
|
|
2215
|
-
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(asset2, networkOpts.network);
|
|
2216
|
-
assert(erc20Address !== void 0, `Missing ERC20 contract address for ${asset2}`);
|
|
2217
|
-
return erc20Address;
|
|
2218
|
-
}, "getErc20Address");
|
|
2219
|
-
var swapNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2220
|
-
const destAsset = getInternalAsset({
|
|
2221
|
-
chain: params.destChain,
|
|
2222
|
-
asset: params.destAsset
|
|
2223
|
-
});
|
|
2224
|
-
const { vaultContract: vault } = getVaultContract(params.srcChain, networkOpts);
|
|
2225
|
-
const transaction = await vault.xSwapNative(chainConstants[params.destChain].contractId, encodeAddress2(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams?.cfParameters ?? "0x", {
|
|
2226
|
-
value: params.amount,
|
|
2227
|
-
...extractOverrides(txOpts)
|
|
2228
|
-
});
|
|
2229
|
-
await transaction.wait(txOpts.wait);
|
|
2230
|
-
return transaction;
|
|
2231
|
-
}, "swapNative");
|
|
2232
|
-
var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2233
|
-
const { srcAsset, destAsset } = getInternalAssets(params);
|
|
2234
|
-
const { vaultContract: vault, vaultAddress } = getVaultContract(params.srcChain, networkOpts);
|
|
2235
|
-
const erc20Address = getErc20Address(srcAsset, networkOpts);
|
|
2236
|
-
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultAddress, erc20Address, networkOpts.signer);
|
|
2237
|
-
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
2238
|
-
const transaction = await vault.xSwapToken(chainConstants[params.destChain].contractId, encodeAddress2(params.destChain, params.destAddress), assetConstants[destAsset].contractId, erc20Address, params.amount, params.ccmParams?.cfParameters ?? "0x", extractOverrides(txOpts));
|
|
2239
|
-
await transaction.wait(txOpts.wait);
|
|
2240
|
-
return transaction;
|
|
2241
|
-
}, "swapToken");
|
|
2242
|
-
var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2243
|
-
const destAsset = getInternalAsset({
|
|
2244
|
-
chain: params.destChain,
|
|
2245
|
-
asset: params.destAsset
|
|
2246
|
-
});
|
|
2247
|
-
const { vaultContract: vault } = getVaultContract(params.srcChain, networkOpts);
|
|
2248
|
-
const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress2(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, params.ccmParams?.cfParameters ?? "0x", {
|
|
2249
|
-
value: params.amount,
|
|
2250
|
-
...extractOverrides(txOpts)
|
|
2251
|
-
});
|
|
2252
|
-
await transaction.wait(txOpts.wait);
|
|
2253
|
-
return transaction;
|
|
2254
|
-
}, "callNative");
|
|
2255
|
-
var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2256
|
-
const { srcAsset, destAsset } = getInternalAssets(params);
|
|
2257
|
-
const { vaultContract: vault, vaultAddress } = getVaultContract(params.srcChain, networkOpts);
|
|
2258
|
-
const erc20Address = getErc20Address(srcAsset, networkOpts);
|
|
2259
|
-
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultAddress, erc20Address, networkOpts.signer);
|
|
2260
|
-
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
2261
|
-
const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress2(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, erc20Address, params.amount, params.ccmParams?.cfParameters ?? "0x", extractOverrides(txOpts));
|
|
2262
|
-
await transaction.wait(txOpts.wait);
|
|
2263
|
-
return transaction;
|
|
2264
|
-
}, "callToken");
|
|
2265
|
-
var executeSwap = /* @__PURE__ */ __name(async ({ ccmParams: unvalidatedCcmParams, ...params }, networkOpts, txOpts) => {
|
|
2266
|
-
assertIsValidSwap(params);
|
|
2267
|
-
assertIsEvmChain(params.srcChain);
|
|
2268
|
-
assertValidAddress(params.destChain, params.destAddress, networkOpts.network);
|
|
2269
|
-
await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
|
|
2270
|
-
const internalSrcAsset = getInternalAsset({
|
|
2271
|
-
asset: params.srcAsset,
|
|
2272
|
-
chain: params.srcChain
|
|
2273
|
-
});
|
|
2274
|
-
if (unvalidatedCcmParams) {
|
|
2275
|
-
assertIsCCMDestination(params.destChain);
|
|
2276
|
-
const validatedCcmParams = ccmParamsSchema.parse(unvalidatedCcmParams);
|
|
2277
|
-
return internalSrcAsset === chainConstants[params.srcChain].gasAsset ? callNative({
|
|
2278
|
-
...params,
|
|
2279
|
-
ccmParams: validatedCcmParams
|
|
2280
|
-
}, networkOpts, txOpts) : callToken({
|
|
2281
|
-
...params,
|
|
2282
|
-
ccmParams: validatedCcmParams
|
|
2283
|
-
}, networkOpts, txOpts);
|
|
2284
|
-
}
|
|
2285
|
-
return internalSrcAsset === chainConstants[params.srcChain].gasAsset ? swapNative(params, networkOpts, txOpts) : swapToken(params, networkOpts, txOpts);
|
|
2286
|
-
}, "executeSwap");
|
|
2287
|
-
var executeSwap_default = executeSwap;
|
|
2288
|
-
|
|
2289
|
-
// ../shared/src/vault/approval.ts
|
|
2290
|
-
var checkVaultAllowance = /* @__PURE__ */ __name((params, networkOpts) => {
|
|
2291
|
-
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(getInternalAsset({
|
|
2292
|
-
chain: params.srcChain,
|
|
2293
|
-
asset: params.srcAsset
|
|
2294
|
-
}), networkOpts.network);
|
|
2295
|
-
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
2296
|
-
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultContractAddress(params.srcChain, networkOpts.network);
|
|
2297
|
-
return checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
2298
|
-
}, "checkVaultAllowance");
|
|
2299
|
-
var approveVault = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2300
|
-
await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
|
|
2301
|
-
const { hasSufficientAllowance, erc20, allowance } = await checkVaultAllowance(params, networkOpts);
|
|
2302
|
-
if (hasSufficientAllowance) return null;
|
|
2303
|
-
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultContractAddress(params.srcChain, networkOpts.network);
|
|
2304
|
-
return approve(BigInt(params.amount), vaultContractAddress, erc20, allowance, txOpts);
|
|
2305
|
-
}, "approveVault");
|
|
2306
|
-
|
|
2307
|
-
// ../swap/src/utils/dataStructures.ts
|
|
2308
|
-
var _a;
|
|
2309
|
-
var Timer = (_a = class {
|
|
2310
|
-
constructor(value, cb, ms) {
|
|
2311
|
-
__publicField(this, "value");
|
|
2312
|
-
__publicField(this, "cb");
|
|
2313
|
-
__publicField(this, "ms");
|
|
2314
|
-
__publicField(this, "timeout");
|
|
2315
|
-
this.value = value;
|
|
2316
|
-
this.cb = cb;
|
|
2317
|
-
this.ms = ms;
|
|
2318
|
-
this.reset(true);
|
|
2319
|
-
}
|
|
2320
|
-
reset(resetExpiryOnLookup) {
|
|
2321
|
-
if (resetExpiryOnLookup) {
|
|
2322
|
-
this.clear();
|
|
2323
|
-
this.timeout = setTimeout(this.cb, this.ms);
|
|
2324
|
-
}
|
|
2325
|
-
return this;
|
|
2326
|
-
}
|
|
2327
|
-
getValue(resetExpiryOnLookup) {
|
|
2328
|
-
return this.reset(resetExpiryOnLookup).value;
|
|
2329
|
-
}
|
|
2330
|
-
clear() {
|
|
2331
|
-
if (this.timeout) clearTimeout(this.timeout);
|
|
2332
|
-
}
|
|
2333
|
-
}, __name(_a, "Timer"), _a);
|
|
2334
|
-
var _CacheMap = class _CacheMap {
|
|
2335
|
-
constructor(ttl, resetExpiryOnLookup = true) {
|
|
2336
|
-
__publicField(this, "ttl");
|
|
2337
|
-
__publicField(this, "resetExpiryOnLookup");
|
|
2338
|
-
__publicField(this, "store");
|
|
2339
|
-
this.ttl = ttl;
|
|
2340
|
-
this.resetExpiryOnLookup = resetExpiryOnLookup;
|
|
2341
|
-
this.store = /* @__PURE__ */ new Map();
|
|
2342
|
-
}
|
|
2343
|
-
set(key, value) {
|
|
2344
|
-
this.delete(key);
|
|
2345
|
-
const timer = new Timer(value, () => this.store.delete(key), this.ttl);
|
|
2346
|
-
this.store.set(key, timer);
|
|
2347
|
-
return this;
|
|
2348
|
-
}
|
|
2349
|
-
get(key) {
|
|
2350
|
-
return this.store.get(key)?.getValue(this.resetExpiryOnLookup);
|
|
2351
|
-
}
|
|
2352
|
-
delete(key) {
|
|
2353
|
-
this.store.get(key)?.clear();
|
|
2354
|
-
return this.store.delete(key);
|
|
2355
|
-
}
|
|
2356
|
-
};
|
|
2357
|
-
__name(_CacheMap, "CacheMap");
|
|
2358
|
-
var CacheMap = _CacheMap;
|
|
2359
|
-
var _AsyncCacheMap = class _AsyncCacheMap extends CacheMap {
|
|
2360
|
-
constructor({ fetch, ttl, resetExpiryOnLookup = true }) {
|
|
2361
|
-
super(ttl, resetExpiryOnLookup);
|
|
2362
|
-
__publicField(this, "fetch");
|
|
2363
|
-
this.fetch = fetch;
|
|
2364
|
-
}
|
|
2365
|
-
get(key) {
|
|
2366
|
-
let promise = super.get(key);
|
|
2367
|
-
if (!promise) {
|
|
2368
|
-
promise = this.fetch(key).catch((err) => {
|
|
2369
|
-
this.delete(key);
|
|
2370
|
-
throw err;
|
|
2371
|
-
});
|
|
2372
|
-
this.set(key, promise);
|
|
2373
|
-
}
|
|
2374
|
-
return promise;
|
|
2375
|
-
}
|
|
2376
|
-
load(key) {
|
|
2377
|
-
return this.get(key).then(() => true, () => false);
|
|
833
|
+
// src/swap/assets.ts
|
|
834
|
+
var getTokenContractAddress = (asset2, network) => {
|
|
835
|
+
switch (asset2) {
|
|
836
|
+
case "Btc":
|
|
837
|
+
case "Dot":
|
|
838
|
+
case "Eth":
|
|
839
|
+
case "ArbEth":
|
|
840
|
+
case "Sol":
|
|
841
|
+
return void 0;
|
|
842
|
+
default:
|
|
843
|
+
return ADDRESSES[network][`${string$1.toUpperCase(asset2)}_CONTRACT_ADDRESS`];
|
|
2378
844
|
}
|
|
2379
845
|
};
|
|
2380
|
-
|
|
2381
|
-
var AsyncCacheMap = _AsyncCacheMap;
|
|
2382
|
-
|
|
2383
|
-
// src/swap/assets.ts
|
|
2384
|
-
var isGasAsset = /* @__PURE__ */ __name((asset2) => {
|
|
2385
|
-
const { chain: chain2 } = assetConstants[asset2];
|
|
2386
|
-
return asset2 === chainConstants[chain2].gasAsset;
|
|
2387
|
-
}, "isGasAsset");
|
|
2388
|
-
var getAssetData = /* @__PURE__ */ __name((asset2, network, env) => {
|
|
846
|
+
var getAssetData = (asset2, network, env) => {
|
|
2389
847
|
const assetConstant = assetConstants[asset2];
|
|
2390
848
|
return {
|
|
2391
849
|
chainflipId: asset2,
|
|
2392
850
|
asset: assetConstant.asset,
|
|
2393
851
|
chain: assetConstant.chain,
|
|
2394
|
-
contractAddress:
|
|
852
|
+
contractAddress: getTokenContractAddress(asset2, network),
|
|
2395
853
|
decimals: assetConstant.decimals,
|
|
2396
854
|
name: assetConstant.name,
|
|
2397
855
|
symbol: assetConstant.asset,
|
|
2398
856
|
isMainnet: !isTestnet(network),
|
|
2399
|
-
minimumSwapAmount: readChainAssetValue(
|
|
857
|
+
minimumSwapAmount: readChainAssetValue(
|
|
858
|
+
env.ingressEgress.minimumDepositAmounts,
|
|
859
|
+
asset2
|
|
860
|
+
).toString(),
|
|
2400
861
|
maximumSwapAmount: readChainAssetValue(env.swapping.maximumSwapAmounts, asset2)?.toString() ?? null,
|
|
2401
|
-
minimumEgressAmount: readChainAssetValue(
|
|
862
|
+
minimumEgressAmount: readChainAssetValue(
|
|
863
|
+
env.ingressEgress.minimumEgressAmounts,
|
|
864
|
+
asset2
|
|
865
|
+
).toString()
|
|
2402
866
|
};
|
|
2403
|
-
}
|
|
867
|
+
};
|
|
2404
868
|
|
|
2405
869
|
// src/swap/chains.ts
|
|
2406
|
-
var getChainData =
|
|
870
|
+
var getChainData = (chain2, network, env) => ({
|
|
2407
871
|
chain: chain2,
|
|
2408
872
|
name: chain2,
|
|
2409
873
|
evmChainId: getEvmChainId(chain2, network),
|
|
2410
874
|
isMainnet: !isTestnet(network),
|
|
2411
875
|
requiredBlockConfirmations: isNotNullish(env.ingressEgress.witnessSafetyMargins[chain2]) ? Number(env.ingressEgress.witnessSafetyMargins[chain2]) + 1 : void 0,
|
|
2412
876
|
maxRetryDurationBlocks: env.ingressEgress.maxSwapRetryDurationBlocks[chain2]
|
|
2413
|
-
})
|
|
877
|
+
});
|
|
2414
878
|
|
|
2415
879
|
// package.json
|
|
2416
|
-
var version = "1.
|
|
880
|
+
var version = "1.8.0-beta.1";
|
|
2417
881
|
|
|
2418
882
|
// src/swap/consts.ts
|
|
2419
|
-
var CF_SDK_VERSION_HEADERS = {
|
|
2420
|
-
"X-Chainflip-Sdk-Version": version
|
|
2421
|
-
};
|
|
883
|
+
var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": version };
|
|
2422
884
|
var BACKEND_SERVICE_URLS = {
|
|
2423
885
|
[ChainflipNetworks.backspin]: "https://chainflip-swap-backspin.staging/",
|
|
2424
886
|
[ChainflipNetworks.sisyphos]: "https://chainflip-swap.staging/",
|
|
2425
887
|
[ChainflipNetworks.perseverance]: "https://chainflip-swap-perseverance.chainflip.io/",
|
|
2426
888
|
[ChainflipNetworks.mainnet]: "https://chainflip-swap.chainflip.io/"
|
|
2427
889
|
};
|
|
2428
|
-
var getQuote =
|
|
890
|
+
var getQuote = async (baseUrl, quoteRequest, { signal }) => {
|
|
2429
891
|
const { brokerCommissionBps, ...returnedRequestData } = quoteRequest;
|
|
2430
892
|
const params = {
|
|
2431
893
|
amount: returnedRequestData.amount,
|
|
@@ -2433,6 +895,7 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
|
|
|
2433
895
|
srcAsset: returnedRequestData.srcAsset,
|
|
2434
896
|
destChain: returnedRequestData.destChain,
|
|
2435
897
|
destAsset: returnedRequestData.destAsset,
|
|
898
|
+
isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
|
|
2436
899
|
...brokerCommissionBps && {
|
|
2437
900
|
brokerCommissionBps: String(brokerCommissionBps)
|
|
2438
901
|
},
|
|
@@ -2444,12 +907,9 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
|
|
|
2444
907
|
signal,
|
|
2445
908
|
headers: CF_SDK_VERSION_HEADERS
|
|
2446
909
|
});
|
|
2447
|
-
return {
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
};
|
|
2451
|
-
}, "getQuote");
|
|
2452
|
-
var getQuoteV2 = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
|
|
910
|
+
return { ...returnedRequestData, quote: data };
|
|
911
|
+
};
|
|
912
|
+
var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
|
|
2453
913
|
const { brokerCommissionBps, ...returnedRequestData } = quoteRequest;
|
|
2454
914
|
const params = {
|
|
2455
915
|
amount: returnedRequestData.amount,
|
|
@@ -2457,10 +917,11 @@ var getQuoteV2 = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }
|
|
|
2457
917
|
srcAsset: returnedRequestData.srcAsset,
|
|
2458
918
|
destChain: returnedRequestData.destChain,
|
|
2459
919
|
destAsset: returnedRequestData.destAsset,
|
|
920
|
+
isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
|
|
2460
921
|
...brokerCommissionBps && {
|
|
2461
922
|
brokerCommissionBps: String(brokerCommissionBps)
|
|
2462
923
|
},
|
|
2463
|
-
dcaEnabled: String(quoteRequest.dcaEnabled)
|
|
924
|
+
dcaEnabled: String(Boolean(quoteRequest.dcaEnabled))
|
|
2464
925
|
};
|
|
2465
926
|
const { data } = await axios__default.default.get("/v2/quote", {
|
|
2466
927
|
baseURL: baseUrl,
|
|
@@ -2468,30 +929,27 @@ var getQuoteV2 = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }
|
|
|
2468
929
|
signal,
|
|
2469
930
|
headers: CF_SDK_VERSION_HEADERS
|
|
2470
931
|
});
|
|
2471
|
-
return {
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
};
|
|
2475
|
-
}, "getQuoteV2");
|
|
2476
|
-
var getStatus = /* @__PURE__ */ __name(async (baseUrl, { id }, { signal }) => {
|
|
932
|
+
return { ...returnedRequestData, quotes: data };
|
|
933
|
+
};
|
|
934
|
+
var getStatus = async (baseUrl, { id }, { signal }) => {
|
|
2477
935
|
const { data } = await axios__default.default.get(`/swaps/${id}`, {
|
|
2478
936
|
baseURL: baseUrl,
|
|
2479
937
|
signal,
|
|
2480
938
|
headers: CF_SDK_VERSION_HEADERS
|
|
2481
939
|
});
|
|
2482
940
|
return data;
|
|
2483
|
-
}
|
|
2484
|
-
var getStatusV2 =
|
|
941
|
+
};
|
|
942
|
+
var getStatusV2 = async (baseUrl, { id }, { signal }) => {
|
|
2485
943
|
const { data } = await axios__default.default.get(`/v2/swaps/${id}`, {
|
|
2486
944
|
baseURL: baseUrl,
|
|
2487
945
|
signal,
|
|
2488
946
|
headers: CF_SDK_VERSION_HEADERS
|
|
2489
947
|
});
|
|
2490
948
|
return data;
|
|
2491
|
-
}
|
|
949
|
+
};
|
|
2492
950
|
|
|
2493
951
|
// src/swap/sdk.ts
|
|
2494
|
-
var assertQuoteValid =
|
|
952
|
+
var assertQuoteValid = (quote) => {
|
|
2495
953
|
switch (quote.type) {
|
|
2496
954
|
case "REGULAR":
|
|
2497
955
|
break;
|
|
@@ -2501,26 +959,17 @@ var assertQuoteValid = /* @__PURE__ */ __name((quote) => {
|
|
|
2501
959
|
default:
|
|
2502
960
|
throw new Error("Invalid quote type");
|
|
2503
961
|
}
|
|
2504
|
-
}
|
|
2505
|
-
var
|
|
962
|
+
};
|
|
963
|
+
var SwapSDK = class {
|
|
2506
964
|
constructor(options = {}) {
|
|
2507
|
-
|
|
2508
|
-
__publicField(this, "rpcConfig");
|
|
2509
|
-
__publicField(this, "trpc");
|
|
2510
|
-
__publicField(this, "stateChainEnvironmentCache");
|
|
2511
|
-
__publicField(this, "supportedAssets");
|
|
2512
|
-
__publicField(this, "dcaEnabled", false);
|
|
965
|
+
this.dcaEnabled = false;
|
|
2513
966
|
const network = options.network ?? ChainflipNetworks.perseverance;
|
|
2514
967
|
this.options = {
|
|
2515
968
|
...options,
|
|
2516
969
|
network,
|
|
2517
970
|
backendUrl: options.backendUrl ?? BACKEND_SERVICE_URLS[network]
|
|
2518
971
|
};
|
|
2519
|
-
this.rpcConfig = options.rpcUrl ? {
|
|
2520
|
-
rpcUrl: options.rpcUrl
|
|
2521
|
-
} : {
|
|
2522
|
-
network
|
|
2523
|
-
};
|
|
972
|
+
this.rpcConfig = options.rpcUrl ? { rpcUrl: options.rpcUrl } : { network };
|
|
2524
973
|
this.trpc = client.createTRPCProxyClient({
|
|
2525
974
|
transformer: superjson__default.default,
|
|
2526
975
|
links: [
|
|
@@ -2532,20 +981,19 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2532
981
|
});
|
|
2533
982
|
this.dcaEnabled = options.enabledFeatures?.dca ?? false;
|
|
2534
983
|
this.stateChainEnvironmentCache = new AsyncCacheMap({
|
|
2535
|
-
fetch:
|
|
984
|
+
fetch: (_key) => getEnvironment(this.rpcConfig),
|
|
2536
985
|
ttl: 6e4 * 10,
|
|
2537
986
|
resetExpiryOnLookup: false
|
|
2538
987
|
});
|
|
2539
988
|
}
|
|
2540
989
|
async getChains(sourceChain) {
|
|
2541
|
-
if (sourceChain && !(sourceChain in Chains))
|
|
990
|
+
if (sourceChain && !(sourceChain in Chains))
|
|
991
|
+
throw new Error(`unsupported source chain "${sourceChain}"`);
|
|
2542
992
|
const [env, supportedAssets] = await Promise.all([
|
|
2543
993
|
this.getStateChainEnvironment(),
|
|
2544
994
|
this.getSupportedAssets()
|
|
2545
995
|
]);
|
|
2546
|
-
const supportedChains = [
|
|
2547
|
-
...new Set(supportedAssets.map((a) => assetConstants[a].chain))
|
|
2548
|
-
];
|
|
996
|
+
const supportedChains = [...new Set(supportedAssets.map((a) => assetConstants[a].chain))];
|
|
2549
997
|
return supportedChains.map((chain2) => getChainData(chain2, this.options.network, env)).filter((chain2) => chain2.chain !== sourceChain);
|
|
2550
998
|
}
|
|
2551
999
|
async getStateChainEnvironment() {
|
|
@@ -2566,64 +1014,89 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2566
1014
|
]);
|
|
2567
1015
|
return supportedAssets.map((asset2) => getAssetData(asset2, this.options.network, env)).filter((asset2) => !chain2 || asset2.chain === chain2);
|
|
2568
1016
|
}
|
|
2569
|
-
/** @deprecated DEPRECATED(1.
|
|
1017
|
+
/** @deprecated DEPRECATED(1.7) use getQuoteV2() */
|
|
2570
1018
|
getQuote(quoteRequest, options = {}) {
|
|
1019
|
+
console.error(
|
|
1020
|
+
"[@chainflip/sdk] The getQuote method is deprecated and will be removed in the 1.9 release. Use the getQuoteV2 method instead."
|
|
1021
|
+
);
|
|
2571
1022
|
const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
|
|
2572
1023
|
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
2573
1024
|
const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
2574
|
-
return getQuote(
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
1025
|
+
return getQuote(
|
|
1026
|
+
this.options.backendUrl,
|
|
1027
|
+
{
|
|
1028
|
+
...remainingRequest,
|
|
1029
|
+
brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
|
|
1030
|
+
},
|
|
1031
|
+
options
|
|
1032
|
+
);
|
|
2578
1033
|
}
|
|
2579
1034
|
getQuoteV2(quoteRequest, options = {}) {
|
|
2580
1035
|
const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
|
|
2581
1036
|
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
2582
1037
|
const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
2583
|
-
return getQuoteV2(
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
1038
|
+
return getQuoteV2(
|
|
1039
|
+
this.options.backendUrl,
|
|
1040
|
+
{
|
|
1041
|
+
...remainingRequest,
|
|
1042
|
+
brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps,
|
|
1043
|
+
dcaEnabled: this.dcaEnabled
|
|
1044
|
+
},
|
|
1045
|
+
options
|
|
1046
|
+
);
|
|
2588
1047
|
}
|
|
2589
|
-
/** @deprecated DEPRECATED(1.
|
|
1048
|
+
/** @deprecated DEPRECATED(1.7) use requestDepositAddressV2() */
|
|
2590
1049
|
async requestDepositAddress(depositAddressRequest) {
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
1050
|
+
console.error(
|
|
1051
|
+
"[@chainflip/sdk] The requestDepositAddress method is deprecated and will be removed in the 1.9 release. Use the requestDepositAddressV2 method instead."
|
|
1052
|
+
);
|
|
1053
|
+
const {
|
|
1054
|
+
srcChain,
|
|
1055
|
+
srcAsset,
|
|
1056
|
+
amount,
|
|
1057
|
+
destChain,
|
|
1058
|
+
destAsset,
|
|
1059
|
+
brokerCommissionBps,
|
|
1060
|
+
affiliateBrokers
|
|
1061
|
+
} = depositAddressRequest;
|
|
1062
|
+
await this.validateSwapAmount({ chain: srcChain, asset: srcAsset }, BigInt(amount));
|
|
2596
1063
|
const fillOrKillParams2 = depositAddressRequest.fillOrKillParams ? {
|
|
2597
1064
|
...depositAddressRequest.fillOrKillParams,
|
|
2598
|
-
minPriceX128: getPriceX128FromPrice(
|
|
2599
|
-
|
|
2600
|
-
asset: srcAsset
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
asset: destAsset
|
|
2604
|
-
}))
|
|
1065
|
+
minPriceX128: getPriceX128FromPrice(
|
|
1066
|
+
depositAddressRequest.fillOrKillParams.minPrice,
|
|
1067
|
+
getInternalAsset({ chain: srcChain, asset: srcAsset }),
|
|
1068
|
+
getInternalAsset({ chain: destChain, asset: destAsset })
|
|
1069
|
+
)
|
|
2605
1070
|
} : void 0;
|
|
2606
1071
|
let response;
|
|
2607
|
-
if (this.options.broker
|
|
2608
|
-
const result = await requestSwapDepositAddress(
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
1072
|
+
if (this.options.broker) {
|
|
1073
|
+
const result = await requestSwapDepositAddress(
|
|
1074
|
+
{
|
|
1075
|
+
...depositAddressRequest,
|
|
1076
|
+
commissionBps: brokerCommissionBps ?? this.options.broker.commissionBps,
|
|
1077
|
+
affiliates: affiliateBrokers,
|
|
1078
|
+
fillOrKillParams: fillOrKillParams2
|
|
1079
|
+
},
|
|
1080
|
+
{ url: this.options.broker.url },
|
|
1081
|
+
this.options.network
|
|
1082
|
+
);
|
|
2616
1083
|
response = {
|
|
2617
1084
|
id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
|
|
2618
1085
|
depositAddress: result.address,
|
|
2619
|
-
brokerCommissionBps: this.options.broker.commissionBps,
|
|
1086
|
+
brokerCommissionBps: brokerCommissionBps ?? this.options.broker.commissionBps ?? 0,
|
|
2620
1087
|
srcChainExpiryBlock: result.sourceChainExpiryBlock,
|
|
2621
1088
|
maxBoostFeeBps: depositAddressRequest.maxBoostFeeBps,
|
|
2622
1089
|
channelOpeningFee: result.channelOpeningFee
|
|
2623
1090
|
};
|
|
2624
1091
|
} else {
|
|
2625
|
-
assert(
|
|
2626
|
-
|
|
1092
|
+
assert(
|
|
1093
|
+
!depositAddressRequest.brokerCommissionBps,
|
|
1094
|
+
"Broker commission is supported only when initializing the SDK with a brokerUrl"
|
|
1095
|
+
);
|
|
1096
|
+
assert(
|
|
1097
|
+
!depositAddressRequest.affiliateBrokers?.length,
|
|
1098
|
+
"Affiliate brokers are supported only when initializing the SDK with a brokerUrl"
|
|
1099
|
+
);
|
|
2627
1100
|
assert(fillOrKillParams2, "Fill or kill parameters are required");
|
|
2628
1101
|
response = await this.trpc.openSwapDepositChannel.mutate({
|
|
2629
1102
|
...depositAddressRequest,
|
|
@@ -2642,94 +1115,52 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2642
1115
|
channelOpeningFee: response.channelOpeningFee
|
|
2643
1116
|
};
|
|
2644
1117
|
}
|
|
2645
|
-
/** @deprecated DEPRECATED(1.
|
|
1118
|
+
/** @deprecated DEPRECATED(1.7) use getStatusV2() */
|
|
2646
1119
|
getStatus(swapStatusRequest, options = {}) {
|
|
1120
|
+
console.error(
|
|
1121
|
+
"[@chainflip/sdk] The getStatus method is deprecated and will be removed in the 1.9 release. Use the getStatusV2 method instead."
|
|
1122
|
+
);
|
|
2647
1123
|
return getStatus(this.options.backendUrl, swapStatusRequest, options);
|
|
2648
1124
|
}
|
|
2649
1125
|
getStatusV2(swapStatusRequest, options = {}) {
|
|
2650
1126
|
return getStatusV2(this.options.backendUrl, swapStatusRequest, options);
|
|
2651
1127
|
}
|
|
2652
|
-
async executeSwap(params, txOpts = {}) {
|
|
2653
|
-
const { srcChain, srcAsset, amount } = params;
|
|
2654
|
-
const { signer: optsSigner, ...remainingTxOpts } = txOpts;
|
|
2655
|
-
const signer = optsSigner ?? this.options.signer;
|
|
2656
|
-
assert(signer, "No signer provided");
|
|
2657
|
-
await this.validateSwapAmount({
|
|
2658
|
-
chain: srcChain,
|
|
2659
|
-
asset: srcAsset
|
|
2660
|
-
}, BigInt(amount));
|
|
2661
|
-
const tx = await executeSwap_default(params, {
|
|
2662
|
-
network: this.options.network,
|
|
2663
|
-
signer
|
|
2664
|
-
}, remainingTxOpts);
|
|
2665
|
-
return tx.hash;
|
|
2666
|
-
}
|
|
2667
|
-
async approveVault(params, txOpts = {}) {
|
|
2668
|
-
const { signer: optsSigner, ...remainingTxOpts } = txOpts;
|
|
2669
|
-
const signer = optsSigner ?? this.options.signer;
|
|
2670
|
-
assert(signer, "No signer provided");
|
|
2671
|
-
const tx = await approveVault(params, {
|
|
2672
|
-
signer,
|
|
2673
|
-
network: this.options.network
|
|
2674
|
-
}, remainingTxOpts);
|
|
2675
|
-
return tx ? tx.hash : null;
|
|
2676
|
-
}
|
|
2677
1128
|
async validateSwapAmount(asset2, amount) {
|
|
2678
1129
|
const stateChainEnv = await this.getStateChainEnvironment();
|
|
2679
1130
|
const internalAsset = getInternalAsset(asset2);
|
|
2680
1131
|
const result = validateSwapAmount(stateChainEnv, internalAsset, amount);
|
|
2681
1132
|
if (!result.success) throw new Error(result.reason);
|
|
2682
1133
|
}
|
|
2683
|
-
async approveAndExecuteSwap(params, txOpts = {}) {
|
|
2684
|
-
const { srcChain, srcAsset } = params;
|
|
2685
|
-
const signer = txOpts.signer ?? this.options.signer;
|
|
2686
|
-
assert(signer, "No signer provided");
|
|
2687
|
-
const internalAsset = getInternalAsset({
|
|
2688
|
-
chain: srcChain,
|
|
2689
|
-
asset: srcAsset
|
|
2690
|
-
});
|
|
2691
|
-
let approveTxRef = null;
|
|
2692
|
-
if (!isGasAsset(internalAsset)) {
|
|
2693
|
-
approveTxRef = await this.approveVault(params, {
|
|
2694
|
-
...txOpts,
|
|
2695
|
-
nonce: void 0
|
|
2696
|
-
});
|
|
2697
|
-
}
|
|
2698
|
-
const swapTxRef = await this.executeSwap(params, {
|
|
2699
|
-
...txOpts,
|
|
2700
|
-
nonce: void 0
|
|
2701
|
-
});
|
|
2702
|
-
return {
|
|
2703
|
-
approveTxRef,
|
|
2704
|
-
swapTxRef
|
|
2705
|
-
};
|
|
2706
|
-
}
|
|
2707
1134
|
async getSwapLimits() {
|
|
2708
|
-
const {
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
};
|
|
1135
|
+
const {
|
|
1136
|
+
swapping: { maximumSwapAmounts },
|
|
1137
|
+
ingressEgress: { minimumDepositAmounts }
|
|
1138
|
+
} = await this.getStateChainEnvironment();
|
|
1139
|
+
return { minimumSwapAmounts: minimumDepositAmounts, maximumSwapAmounts };
|
|
2713
1140
|
}
|
|
2714
1141
|
async getRequiredBlockConfirmations() {
|
|
2715
|
-
const {
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
1142
|
+
const {
|
|
1143
|
+
ingressEgress: { witnessSafetyMargins }
|
|
1144
|
+
} = await this.getStateChainEnvironment();
|
|
1145
|
+
return Object.keys(Chains).reduce(
|
|
1146
|
+
(acc, chain2) => {
|
|
1147
|
+
acc[chain2] = witnessSafetyMargins[chain2] ? Number(witnessSafetyMargins[chain2]) + 1 : null;
|
|
1148
|
+
return acc;
|
|
1149
|
+
},
|
|
1150
|
+
{}
|
|
1151
|
+
);
|
|
2720
1152
|
}
|
|
2721
1153
|
async getChannelOpeningFees() {
|
|
2722
|
-
const {
|
|
1154
|
+
const {
|
|
1155
|
+
ingressEgress: { channelOpeningFees }
|
|
1156
|
+
} = await this.getStateChainEnvironment();
|
|
2723
1157
|
return channelOpeningFees;
|
|
2724
1158
|
}
|
|
2725
1159
|
async getBoostLiquidity(params = {}) {
|
|
2726
1160
|
let poolsDepth = await this.getBoostPoolsDepth();
|
|
2727
1161
|
if ("chain" in params && "asset" in params) {
|
|
2728
1162
|
const { chain: chain2, asset: asset2 } = params;
|
|
2729
|
-
const internalAsset = getInternalAsset({
|
|
2730
|
-
chain: chain2,
|
|
2731
|
-
asset: asset2
|
|
2732
|
-
});
|
|
1163
|
+
const internalAsset = getInternalAsset({ chain: chain2, asset: asset2 });
|
|
2733
1164
|
poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.asset === internalAsset).sort((a, b) => b.tier - a.tier);
|
|
2734
1165
|
}
|
|
2735
1166
|
if ("feeTierBps" in params && params.feeTierBps !== void 0) {
|
|
@@ -2741,9 +1172,18 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2741
1172
|
...getAssetAndChain(depth.asset)
|
|
2742
1173
|
}));
|
|
2743
1174
|
}
|
|
2744
|
-
async requestDepositAddressV2({
|
|
1175
|
+
async requestDepositAddressV2({
|
|
1176
|
+
quote,
|
|
1177
|
+
srcAddress,
|
|
1178
|
+
destAddress,
|
|
1179
|
+
fillOrKillParams: inputFoKParams,
|
|
1180
|
+
affiliateBrokers: affiliates,
|
|
1181
|
+
ccmParams,
|
|
1182
|
+
brokerCommissionBps
|
|
1183
|
+
}) {
|
|
2745
1184
|
await this.validateSwapAmount(quote.srcAsset, BigInt(quote.depositAmount));
|
|
2746
1185
|
assertQuoteValid(quote);
|
|
1186
|
+
assert(!quote.isVaultSwap, "Cannot open a deposit channel for a vault swap quote");
|
|
2747
1187
|
const depositAddressRequest = {
|
|
2748
1188
|
srcAsset: quote.srcAsset.asset,
|
|
2749
1189
|
srcChain: quote.srcAsset.chain,
|
|
@@ -2758,24 +1198,34 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2758
1198
|
amount: quote.depositAmount
|
|
2759
1199
|
};
|
|
2760
1200
|
let response;
|
|
2761
|
-
if (this.options.broker
|
|
2762
|
-
const result = await requestSwapDepositAddress(
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
1201
|
+
if (this.options.broker) {
|
|
1202
|
+
const result = await requestSwapDepositAddress(
|
|
1203
|
+
{
|
|
1204
|
+
...depositAddressRequest,
|
|
1205
|
+
commissionBps: brokerCommissionBps ?? this.options.broker.commissionBps,
|
|
1206
|
+
affiliates
|
|
1207
|
+
},
|
|
1208
|
+
{ url: this.options.broker.url },
|
|
1209
|
+
this.options.network
|
|
1210
|
+
);
|
|
2769
1211
|
response = {
|
|
2770
1212
|
id: `${result.issuedBlock}-${quote.srcAsset.chain}-${result.channelId}`,
|
|
2771
1213
|
depositAddress: result.address,
|
|
2772
|
-
brokerCommissionBps: this.options.broker.commissionBps,
|
|
1214
|
+
brokerCommissionBps: brokerCommissionBps ?? this.options.broker.commissionBps ?? 0,
|
|
2773
1215
|
srcChainExpiryBlock: result.sourceChainExpiryBlock,
|
|
2774
1216
|
maxBoostFeeBps: depositAddressRequest.maxBoostFeeBps,
|
|
2775
1217
|
channelOpeningFee: result.channelOpeningFee
|
|
2776
1218
|
};
|
|
2777
1219
|
} else {
|
|
2778
1220
|
assert(depositAddressRequest.fillOrKillParams, "fill or kill params are required");
|
|
1221
|
+
assert(
|
|
1222
|
+
!brokerCommissionBps,
|
|
1223
|
+
"Broker commission is supported only when initializing the SDK with a brokerUrl"
|
|
1224
|
+
);
|
|
1225
|
+
assert(
|
|
1226
|
+
!affiliates?.length,
|
|
1227
|
+
"Affiliate brokers are supported only when initializing the SDK with a brokerUrl"
|
|
1228
|
+
);
|
|
2779
1229
|
response = await this.trpc.openSwapDepositChannel.mutate({
|
|
2780
1230
|
...depositAddressRequest,
|
|
2781
1231
|
fillOrKillParams: depositAddressRequest.fillOrKillParams,
|
|
@@ -2795,9 +1245,60 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2795
1245
|
fillOrKillParams: inputFoKParams
|
|
2796
1246
|
};
|
|
2797
1247
|
}
|
|
1248
|
+
async encodeVaultSwapData({
|
|
1249
|
+
quote,
|
|
1250
|
+
srcAddress,
|
|
1251
|
+
destAddress,
|
|
1252
|
+
fillOrKillParams: inputFoKParams,
|
|
1253
|
+
affiliateBrokers: affiliates,
|
|
1254
|
+
ccmParams,
|
|
1255
|
+
brokerAccount,
|
|
1256
|
+
brokerCommissionBps,
|
|
1257
|
+
extraParams
|
|
1258
|
+
}) {
|
|
1259
|
+
await this.validateSwapAmount(quote.srcAsset, BigInt(quote.depositAmount));
|
|
1260
|
+
assertQuoteValid(quote);
|
|
1261
|
+
assert(quote.isVaultSwap, "Cannot encode vault swap data for a deposit channel quote");
|
|
1262
|
+
const vaultSwapRequest = {
|
|
1263
|
+
srcAsset: quote.srcAsset,
|
|
1264
|
+
destAsset: quote.destAsset,
|
|
1265
|
+
srcAddress,
|
|
1266
|
+
destAddress,
|
|
1267
|
+
amount: quote.depositAmount,
|
|
1268
|
+
ccmParams,
|
|
1269
|
+
maxBoostFeeBps: "maxBoostFeeBps" in quote ? quote.maxBoostFeeBps : void 0,
|
|
1270
|
+
fillOrKillParams: parseFoKParams(inputFoKParams, quote),
|
|
1271
|
+
dcaParams: quote.type === "DCA" ? quote.dcaParams : void 0,
|
|
1272
|
+
extraParams,
|
|
1273
|
+
brokerAccount,
|
|
1274
|
+
brokerCommissionBps,
|
|
1275
|
+
affiliates
|
|
1276
|
+
};
|
|
1277
|
+
if (this.options.broker) {
|
|
1278
|
+
assert(
|
|
1279
|
+
!vaultSwapRequest.brokerAccount,
|
|
1280
|
+
"Cannot overwrite broker account when initializing the SDK with a brokerUrl"
|
|
1281
|
+
);
|
|
1282
|
+
return requestSwapParameterEncoding(
|
|
1283
|
+
{
|
|
1284
|
+
...vaultSwapRequest,
|
|
1285
|
+
commissionBps: vaultSwapRequest.brokerCommissionBps ?? this.options.broker.commissionBps
|
|
1286
|
+
},
|
|
1287
|
+
{ url: this.options.broker.url },
|
|
1288
|
+
this.options.network
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
assert(
|
|
1292
|
+
!vaultSwapRequest.brokerCommissionBps || vaultSwapRequest.brokerAccount,
|
|
1293
|
+
"Broker commission is supported only when setting a broker account"
|
|
1294
|
+
);
|
|
1295
|
+
assert(
|
|
1296
|
+
!vaultSwapRequest.affiliates?.length || vaultSwapRequest.brokerAccount,
|
|
1297
|
+
"Affiliate brokers are supported only when setting a broker account"
|
|
1298
|
+
);
|
|
1299
|
+
return this.trpc.encodeVaultSwapData.mutate(vaultSwapRequest);
|
|
1300
|
+
}
|
|
2798
1301
|
};
|
|
2799
|
-
__name(_SwapSDK, "SwapSDK");
|
|
2800
|
-
var SwapSDK = _SwapSDK;
|
|
2801
1302
|
|
|
2802
1303
|
exports.Assets = Assets;
|
|
2803
1304
|
exports.ChainflipIds = InternalAssets;
|