@chainflip/sdk 1.8.1 → 1.8.3
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/swap.d.mts +11 -3
- package/dist/swap.d.ts +11 -3
- package/dist/swap.js +71 -29
- package/dist/swap.mjs +71 -29
- package/package.json +2 -2
package/dist/swap.d.mts
CHANGED
|
@@ -97,6 +97,10 @@ interface BaseQuoteDetails {
|
|
|
97
97
|
srcAsset: AssetAndChain;
|
|
98
98
|
destAsset: AssetAndChain;
|
|
99
99
|
isVaultSwap: boolean;
|
|
100
|
+
ccmParams?: {
|
|
101
|
+
gasBudget: string;
|
|
102
|
+
messageLengthBytes: number;
|
|
103
|
+
};
|
|
100
104
|
depositAmount: string;
|
|
101
105
|
intermediateAmount?: string;
|
|
102
106
|
egressAmount: string;
|
|
@@ -164,17 +168,21 @@ interface QuoteRequest extends ChainsAndAssets {
|
|
|
164
168
|
brokerCommissionBps?: number;
|
|
165
169
|
affiliateBrokers?: AffiliateBroker[];
|
|
166
170
|
isVaultSwap?: boolean;
|
|
171
|
+
ccmParams?: {
|
|
172
|
+
gasBudget: string;
|
|
173
|
+
messageLengthBytes: number;
|
|
174
|
+
};
|
|
167
175
|
}
|
|
168
|
-
interface QuoteResponse extends
|
|
176
|
+
interface QuoteResponse extends QuoteRequest {
|
|
169
177
|
quote: Quote;
|
|
170
178
|
}
|
|
171
|
-
interface QuoteResponseV2 extends
|
|
179
|
+
interface QuoteResponseV2 extends QuoteRequest {
|
|
172
180
|
quotes: Quote[];
|
|
173
181
|
}
|
|
174
182
|
type FillOrKillParamsWithSlippage = Omit<FillOrKillParamsWithMinPrice, 'minPrice'> & {
|
|
175
183
|
slippageTolerancePercent: string | number;
|
|
176
184
|
};
|
|
177
|
-
interface DepositAddressRequest extends QuoteRequest {
|
|
185
|
+
interface DepositAddressRequest extends Omit<QuoteRequest, 'ccmParams'> {
|
|
178
186
|
destAddress: string;
|
|
179
187
|
ccmParams?: CcmParams;
|
|
180
188
|
maxBoostFeeBps?: number;
|
package/dist/swap.d.ts
CHANGED
|
@@ -97,6 +97,10 @@ interface BaseQuoteDetails {
|
|
|
97
97
|
srcAsset: AssetAndChain;
|
|
98
98
|
destAsset: AssetAndChain;
|
|
99
99
|
isVaultSwap: boolean;
|
|
100
|
+
ccmParams?: {
|
|
101
|
+
gasBudget: string;
|
|
102
|
+
messageLengthBytes: number;
|
|
103
|
+
};
|
|
100
104
|
depositAmount: string;
|
|
101
105
|
intermediateAmount?: string;
|
|
102
106
|
egressAmount: string;
|
|
@@ -164,17 +168,21 @@ interface QuoteRequest extends ChainsAndAssets {
|
|
|
164
168
|
brokerCommissionBps?: number;
|
|
165
169
|
affiliateBrokers?: AffiliateBroker[];
|
|
166
170
|
isVaultSwap?: boolean;
|
|
171
|
+
ccmParams?: {
|
|
172
|
+
gasBudget: string;
|
|
173
|
+
messageLengthBytes: number;
|
|
174
|
+
};
|
|
167
175
|
}
|
|
168
|
-
interface QuoteResponse extends
|
|
176
|
+
interface QuoteResponse extends QuoteRequest {
|
|
169
177
|
quote: Quote;
|
|
170
178
|
}
|
|
171
|
-
interface QuoteResponseV2 extends
|
|
179
|
+
interface QuoteResponseV2 extends QuoteRequest {
|
|
172
180
|
quotes: Quote[];
|
|
173
181
|
}
|
|
174
182
|
type FillOrKillParamsWithSlippage = Omit<FillOrKillParamsWithMinPrice, 'minPrice'> & {
|
|
175
183
|
slippageTolerancePercent: string | number;
|
|
176
184
|
};
|
|
177
|
-
interface DepositAddressRequest extends QuoteRequest {
|
|
185
|
+
interface DepositAddressRequest extends Omit<QuoteRequest, 'ccmParams'> {
|
|
178
186
|
destAddress: string;
|
|
179
187
|
ccmParams?: CcmParams;
|
|
180
188
|
maxBoostFeeBps?: number;
|
package/dist/swap.js
CHANGED
|
@@ -397,6 +397,16 @@ zod.z.object({
|
|
|
397
397
|
destAsset: asset,
|
|
398
398
|
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" }),
|
|
399
399
|
brokerCommissionBps: numericOrEmptyString.transform((v) => Number(v)).optional(),
|
|
400
|
+
ccmGasBudget: zod.z.union([
|
|
401
|
+
numericString.transform((v) => BigInt(v)),
|
|
402
|
+
zod.z.literal("undefined").transform(() => void 0)
|
|
403
|
+
// sdk version 1.8.2 sends undefined string if not set
|
|
404
|
+
]).optional(),
|
|
405
|
+
ccmMessageLengthBytes: zod.z.union([
|
|
406
|
+
numericString.transform((v) => Number(v)),
|
|
407
|
+
zod.z.literal("undefined").transform(() => void 0)
|
|
408
|
+
// sdk version 1.8.2 sends undefined string if not set
|
|
409
|
+
]).optional(),
|
|
400
410
|
dcaEnabled: booleanString.default("false"),
|
|
401
411
|
isVaultSwap: booleanString.default("false")
|
|
402
412
|
}).transform((args, ctx) => {
|
|
@@ -415,11 +425,27 @@ zod.z.object({
|
|
|
415
425
|
});
|
|
416
426
|
return zod.z.NEVER;
|
|
417
427
|
}
|
|
428
|
+
if (args.ccmGasBudget !== void 0 && args.ccmMessageLengthBytes === void 0) {
|
|
429
|
+
ctx.addIssue({
|
|
430
|
+
message: `ccmMessageLengthBytes must be set if ccmGasBudget is set`,
|
|
431
|
+
code: zod.z.ZodIssueCode.custom
|
|
432
|
+
});
|
|
433
|
+
return zod.z.NEVER;
|
|
434
|
+
}
|
|
435
|
+
if (args.ccmGasBudget === void 0 && args.ccmMessageLengthBytes !== void 0) {
|
|
436
|
+
ctx.addIssue({
|
|
437
|
+
message: `ccmGasBudget must be set if ccmMessageLengthBytes is set`,
|
|
438
|
+
code: zod.z.ZodIssueCode.custom
|
|
439
|
+
});
|
|
440
|
+
return zod.z.NEVER;
|
|
441
|
+
}
|
|
442
|
+
const ccmParams = args.ccmGasBudget !== void 0 && args.ccmMessageLengthBytes !== void 0 ? { gasBudget: args.ccmGasBudget, messageLengthBytes: args.ccmMessageLengthBytes } : void 0;
|
|
418
443
|
return {
|
|
419
444
|
srcAsset,
|
|
420
445
|
destAsset,
|
|
421
446
|
amount: args.amount,
|
|
422
447
|
brokerCommissionBps: args.brokerCommissionBps,
|
|
448
|
+
ccmParams,
|
|
423
449
|
dcaEnabled: args.dcaEnabled,
|
|
424
450
|
isVaultSwap: args.isVaultSwap
|
|
425
451
|
};
|
|
@@ -866,7 +892,7 @@ var getChainData = (chain2, network, env) => ({
|
|
|
866
892
|
});
|
|
867
893
|
|
|
868
894
|
// package.json
|
|
869
|
-
var version = "1.8.
|
|
895
|
+
var version = "1.8.3";
|
|
870
896
|
|
|
871
897
|
// src/swap/consts.ts
|
|
872
898
|
var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": version };
|
|
@@ -877,16 +903,21 @@ var BACKEND_SERVICE_URLS = {
|
|
|
877
903
|
[ChainflipNetworks.mainnet]: "https://chainflip-swap.chainflip.io/"
|
|
878
904
|
};
|
|
879
905
|
var getQuote = async (baseUrl, quoteRequest, { signal }) => {
|
|
880
|
-
const
|
|
906
|
+
const affiliateCommissionBps = quoteRequest.affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
907
|
+
const totalBrokerCommissionBps = (quoteRequest.brokerCommissionBps ?? 0) + affiliateCommissionBps;
|
|
881
908
|
const params = {
|
|
882
|
-
amount:
|
|
883
|
-
srcChain:
|
|
884
|
-
srcAsset:
|
|
885
|
-
destChain:
|
|
886
|
-
destAsset:
|
|
909
|
+
amount: quoteRequest.amount,
|
|
910
|
+
srcChain: quoteRequest.srcChain,
|
|
911
|
+
srcAsset: quoteRequest.srcAsset,
|
|
912
|
+
destChain: quoteRequest.destChain,
|
|
913
|
+
destAsset: quoteRequest.destAsset,
|
|
887
914
|
isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
|
|
888
|
-
...
|
|
889
|
-
brokerCommissionBps: String(
|
|
915
|
+
...totalBrokerCommissionBps && {
|
|
916
|
+
brokerCommissionBps: String(totalBrokerCommissionBps)
|
|
917
|
+
},
|
|
918
|
+
...quoteRequest.ccmParams && {
|
|
919
|
+
ccmGasBudget: quoteRequest.ccmParams.gasBudget,
|
|
920
|
+
ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
|
|
890
921
|
},
|
|
891
922
|
dcaEnabled: "false"
|
|
892
923
|
};
|
|
@@ -896,19 +927,24 @@ var getQuote = async (baseUrl, quoteRequest, { signal }) => {
|
|
|
896
927
|
signal,
|
|
897
928
|
headers: CF_SDK_VERSION_HEADERS
|
|
898
929
|
});
|
|
899
|
-
return { ...
|
|
930
|
+
return { ...quoteRequest, quote: data };
|
|
900
931
|
};
|
|
901
932
|
var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
|
|
902
|
-
const
|
|
933
|
+
const affiliateCommissionBps = quoteRequest.affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
934
|
+
const totalBrokerCommissionBps = (quoteRequest.brokerCommissionBps ?? 0) + affiliateCommissionBps;
|
|
903
935
|
const params = {
|
|
904
|
-
amount:
|
|
905
|
-
srcChain:
|
|
906
|
-
srcAsset:
|
|
907
|
-
destChain:
|
|
908
|
-
destAsset:
|
|
936
|
+
amount: quoteRequest.amount,
|
|
937
|
+
srcChain: quoteRequest.srcChain,
|
|
938
|
+
srcAsset: quoteRequest.srcAsset,
|
|
939
|
+
destChain: quoteRequest.destChain,
|
|
940
|
+
destAsset: quoteRequest.destAsset,
|
|
909
941
|
isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
|
|
910
|
-
...
|
|
911
|
-
brokerCommissionBps: String(
|
|
942
|
+
...totalBrokerCommissionBps && {
|
|
943
|
+
brokerCommissionBps: String(totalBrokerCommissionBps)
|
|
944
|
+
},
|
|
945
|
+
...quoteRequest.ccmParams && {
|
|
946
|
+
ccmGasBudget: quoteRequest.ccmParams.gasBudget,
|
|
947
|
+
ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
|
|
912
948
|
},
|
|
913
949
|
dcaEnabled: String(Boolean(quoteRequest.dcaEnabled))
|
|
914
950
|
};
|
|
@@ -918,7 +954,7 @@ var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
|
|
|
918
954
|
signal,
|
|
919
955
|
headers: CF_SDK_VERSION_HEADERS
|
|
920
956
|
});
|
|
921
|
-
return { ...
|
|
957
|
+
return { ...quoteRequest, quotes: data };
|
|
922
958
|
};
|
|
923
959
|
var getStatus = async (baseUrl, { id }, { signal }) => {
|
|
924
960
|
const { data } = await axios__default.default.get(`/swaps/${id}`, {
|
|
@@ -1008,27 +1044,23 @@ var SwapSDK = class {
|
|
|
1008
1044
|
console.error(
|
|
1009
1045
|
"[@chainflip/sdk] The getQuote method is deprecated and will be removed in the 1.9 release. Use the getQuoteV2 method instead."
|
|
1010
1046
|
);
|
|
1011
|
-
const
|
|
1012
|
-
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
1013
|
-
const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
1047
|
+
const submitterBrokerCommissionBps = quoteRequest.brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
1014
1048
|
return getQuote(
|
|
1015
1049
|
this.options.backendUrl,
|
|
1016
1050
|
{
|
|
1017
|
-
...
|
|
1018
|
-
brokerCommissionBps: submitterBrokerCommissionBps
|
|
1051
|
+
...quoteRequest,
|
|
1052
|
+
brokerCommissionBps: submitterBrokerCommissionBps
|
|
1019
1053
|
},
|
|
1020
1054
|
options
|
|
1021
1055
|
);
|
|
1022
1056
|
}
|
|
1023
1057
|
getQuoteV2(quoteRequest, options = {}) {
|
|
1024
|
-
const
|
|
1025
|
-
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
1026
|
-
const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
1058
|
+
const submitterBrokerCommissionBps = quoteRequest.brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
1027
1059
|
return getQuoteV2(
|
|
1028
1060
|
this.options.backendUrl,
|
|
1029
1061
|
{
|
|
1030
|
-
...
|
|
1031
|
-
brokerCommissionBps: submitterBrokerCommissionBps
|
|
1062
|
+
...quoteRequest,
|
|
1063
|
+
brokerCommissionBps: submitterBrokerCommissionBps,
|
|
1032
1064
|
dcaEnabled: this.dcaEnabled
|
|
1033
1065
|
},
|
|
1034
1066
|
options
|
|
@@ -1173,6 +1205,11 @@ var SwapSDK = class {
|
|
|
1173
1205
|
await this.validateSwapAmount(quote.srcAsset, BigInt(quote.depositAmount));
|
|
1174
1206
|
assertQuoteValid(quote);
|
|
1175
1207
|
assert(!quote.isVaultSwap, "Cannot open a deposit channel for a vault swap quote");
|
|
1208
|
+
if (ccmParams) {
|
|
1209
|
+
assert(quote.ccmParams, "Cannot open CCM channel for quote without CCM params");
|
|
1210
|
+
} else {
|
|
1211
|
+
assert(!quote.ccmParams, "Cannot open regular channel for quote with CCM params");
|
|
1212
|
+
}
|
|
1176
1213
|
const depositAddressRequest = {
|
|
1177
1214
|
srcAsset: quote.srcAsset.asset,
|
|
1178
1215
|
srcChain: quote.srcAsset.chain,
|
|
@@ -1246,6 +1283,11 @@ var SwapSDK = class {
|
|
|
1246
1283
|
await this.validateSwapAmount(quote.srcAsset, BigInt(quote.depositAmount));
|
|
1247
1284
|
assertQuoteValid(quote);
|
|
1248
1285
|
assert(quote.isVaultSwap, "Cannot encode vault swap data for a deposit channel quote");
|
|
1286
|
+
if (ccmParams) {
|
|
1287
|
+
assert(quote.ccmParams, "Cannot encode CCM swap for quote without CCM params");
|
|
1288
|
+
} else {
|
|
1289
|
+
assert(!quote.ccmParams, "Cannot encode regular swap for quote with CCM params");
|
|
1290
|
+
}
|
|
1249
1291
|
const vaultSwapRequest = {
|
|
1250
1292
|
srcAsset: quote.srcAsset,
|
|
1251
1293
|
destAsset: quote.destAsset,
|
package/dist/swap.mjs
CHANGED
|
@@ -174,6 +174,16 @@ z.object({
|
|
|
174
174
|
destAsset: asset,
|
|
175
175
|
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" }),
|
|
176
176
|
brokerCommissionBps: numericOrEmptyString.transform((v) => Number(v)).optional(),
|
|
177
|
+
ccmGasBudget: z.union([
|
|
178
|
+
numericString.transform((v) => BigInt(v)),
|
|
179
|
+
z.literal("undefined").transform(() => void 0)
|
|
180
|
+
// sdk version 1.8.2 sends undefined string if not set
|
|
181
|
+
]).optional(),
|
|
182
|
+
ccmMessageLengthBytes: z.union([
|
|
183
|
+
numericString.transform((v) => Number(v)),
|
|
184
|
+
z.literal("undefined").transform(() => void 0)
|
|
185
|
+
// sdk version 1.8.2 sends undefined string if not set
|
|
186
|
+
]).optional(),
|
|
177
187
|
dcaEnabled: booleanString.default("false"),
|
|
178
188
|
isVaultSwap: booleanString.default("false")
|
|
179
189
|
}).transform((args, ctx) => {
|
|
@@ -192,11 +202,27 @@ z.object({
|
|
|
192
202
|
});
|
|
193
203
|
return z.NEVER;
|
|
194
204
|
}
|
|
205
|
+
if (args.ccmGasBudget !== void 0 && args.ccmMessageLengthBytes === void 0) {
|
|
206
|
+
ctx.addIssue({
|
|
207
|
+
message: `ccmMessageLengthBytes must be set if ccmGasBudget is set`,
|
|
208
|
+
code: z.ZodIssueCode.custom
|
|
209
|
+
});
|
|
210
|
+
return z.NEVER;
|
|
211
|
+
}
|
|
212
|
+
if (args.ccmGasBudget === void 0 && args.ccmMessageLengthBytes !== void 0) {
|
|
213
|
+
ctx.addIssue({
|
|
214
|
+
message: `ccmGasBudget must be set if ccmMessageLengthBytes is set`,
|
|
215
|
+
code: z.ZodIssueCode.custom
|
|
216
|
+
});
|
|
217
|
+
return z.NEVER;
|
|
218
|
+
}
|
|
219
|
+
const ccmParams = args.ccmGasBudget !== void 0 && args.ccmMessageLengthBytes !== void 0 ? { gasBudget: args.ccmGasBudget, messageLengthBytes: args.ccmMessageLengthBytes } : void 0;
|
|
195
220
|
return {
|
|
196
221
|
srcAsset,
|
|
197
222
|
destAsset,
|
|
198
223
|
amount: args.amount,
|
|
199
224
|
brokerCommissionBps: args.brokerCommissionBps,
|
|
225
|
+
ccmParams,
|
|
200
226
|
dcaEnabled: args.dcaEnabled,
|
|
201
227
|
isVaultSwap: args.isVaultSwap
|
|
202
228
|
};
|
|
@@ -552,7 +578,7 @@ var getChainData = (chain2, network, env) => ({
|
|
|
552
578
|
});
|
|
553
579
|
|
|
554
580
|
// package.json
|
|
555
|
-
var version = "1.8.
|
|
581
|
+
var version = "1.8.3";
|
|
556
582
|
|
|
557
583
|
// src/swap/consts.ts
|
|
558
584
|
var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": version };
|
|
@@ -563,16 +589,21 @@ var BACKEND_SERVICE_URLS = {
|
|
|
563
589
|
[ChainflipNetworks.mainnet]: "https://chainflip-swap.chainflip.io/"
|
|
564
590
|
};
|
|
565
591
|
var getQuote = async (baseUrl, quoteRequest, { signal }) => {
|
|
566
|
-
const
|
|
592
|
+
const affiliateCommissionBps = quoteRequest.affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
593
|
+
const totalBrokerCommissionBps = (quoteRequest.brokerCommissionBps ?? 0) + affiliateCommissionBps;
|
|
567
594
|
const params = {
|
|
568
|
-
amount:
|
|
569
|
-
srcChain:
|
|
570
|
-
srcAsset:
|
|
571
|
-
destChain:
|
|
572
|
-
destAsset:
|
|
595
|
+
amount: quoteRequest.amount,
|
|
596
|
+
srcChain: quoteRequest.srcChain,
|
|
597
|
+
srcAsset: quoteRequest.srcAsset,
|
|
598
|
+
destChain: quoteRequest.destChain,
|
|
599
|
+
destAsset: quoteRequest.destAsset,
|
|
573
600
|
isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
|
|
574
|
-
...
|
|
575
|
-
brokerCommissionBps: String(
|
|
601
|
+
...totalBrokerCommissionBps && {
|
|
602
|
+
brokerCommissionBps: String(totalBrokerCommissionBps)
|
|
603
|
+
},
|
|
604
|
+
...quoteRequest.ccmParams && {
|
|
605
|
+
ccmGasBudget: quoteRequest.ccmParams.gasBudget,
|
|
606
|
+
ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
|
|
576
607
|
},
|
|
577
608
|
dcaEnabled: "false"
|
|
578
609
|
};
|
|
@@ -582,19 +613,24 @@ var getQuote = async (baseUrl, quoteRequest, { signal }) => {
|
|
|
582
613
|
signal,
|
|
583
614
|
headers: CF_SDK_VERSION_HEADERS
|
|
584
615
|
});
|
|
585
|
-
return { ...
|
|
616
|
+
return { ...quoteRequest, quote: data };
|
|
586
617
|
};
|
|
587
618
|
var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
|
|
588
|
-
const
|
|
619
|
+
const affiliateCommissionBps = quoteRequest.affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
620
|
+
const totalBrokerCommissionBps = (quoteRequest.brokerCommissionBps ?? 0) + affiliateCommissionBps;
|
|
589
621
|
const params = {
|
|
590
|
-
amount:
|
|
591
|
-
srcChain:
|
|
592
|
-
srcAsset:
|
|
593
|
-
destChain:
|
|
594
|
-
destAsset:
|
|
622
|
+
amount: quoteRequest.amount,
|
|
623
|
+
srcChain: quoteRequest.srcChain,
|
|
624
|
+
srcAsset: quoteRequest.srcAsset,
|
|
625
|
+
destChain: quoteRequest.destChain,
|
|
626
|
+
destAsset: quoteRequest.destAsset,
|
|
595
627
|
isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
|
|
596
|
-
...
|
|
597
|
-
brokerCommissionBps: String(
|
|
628
|
+
...totalBrokerCommissionBps && {
|
|
629
|
+
brokerCommissionBps: String(totalBrokerCommissionBps)
|
|
630
|
+
},
|
|
631
|
+
...quoteRequest.ccmParams && {
|
|
632
|
+
ccmGasBudget: quoteRequest.ccmParams.gasBudget,
|
|
633
|
+
ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
|
|
598
634
|
},
|
|
599
635
|
dcaEnabled: String(Boolean(quoteRequest.dcaEnabled))
|
|
600
636
|
};
|
|
@@ -604,7 +640,7 @@ var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
|
|
|
604
640
|
signal,
|
|
605
641
|
headers: CF_SDK_VERSION_HEADERS
|
|
606
642
|
});
|
|
607
|
-
return { ...
|
|
643
|
+
return { ...quoteRequest, quotes: data };
|
|
608
644
|
};
|
|
609
645
|
var getStatus = async (baseUrl, { id }, { signal }) => {
|
|
610
646
|
const { data } = await axios.get(`/swaps/${id}`, {
|
|
@@ -694,27 +730,23 @@ var SwapSDK = class {
|
|
|
694
730
|
console.error(
|
|
695
731
|
"[@chainflip/sdk] The getQuote method is deprecated and will be removed in the 1.9 release. Use the getQuoteV2 method instead."
|
|
696
732
|
);
|
|
697
|
-
const
|
|
698
|
-
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
699
|
-
const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
733
|
+
const submitterBrokerCommissionBps = quoteRequest.brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
700
734
|
return getQuote(
|
|
701
735
|
this.options.backendUrl,
|
|
702
736
|
{
|
|
703
|
-
...
|
|
704
|
-
brokerCommissionBps: submitterBrokerCommissionBps
|
|
737
|
+
...quoteRequest,
|
|
738
|
+
brokerCommissionBps: submitterBrokerCommissionBps
|
|
705
739
|
},
|
|
706
740
|
options
|
|
707
741
|
);
|
|
708
742
|
}
|
|
709
743
|
getQuoteV2(quoteRequest, options = {}) {
|
|
710
|
-
const
|
|
711
|
-
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
712
|
-
const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
744
|
+
const submitterBrokerCommissionBps = quoteRequest.brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
713
745
|
return getQuoteV2(
|
|
714
746
|
this.options.backendUrl,
|
|
715
747
|
{
|
|
716
|
-
...
|
|
717
|
-
brokerCommissionBps: submitterBrokerCommissionBps
|
|
748
|
+
...quoteRequest,
|
|
749
|
+
brokerCommissionBps: submitterBrokerCommissionBps,
|
|
718
750
|
dcaEnabled: this.dcaEnabled
|
|
719
751
|
},
|
|
720
752
|
options
|
|
@@ -859,6 +891,11 @@ var SwapSDK = class {
|
|
|
859
891
|
await this.validateSwapAmount(quote.srcAsset, BigInt(quote.depositAmount));
|
|
860
892
|
assertQuoteValid(quote);
|
|
861
893
|
assert(!quote.isVaultSwap, "Cannot open a deposit channel for a vault swap quote");
|
|
894
|
+
if (ccmParams) {
|
|
895
|
+
assert(quote.ccmParams, "Cannot open CCM channel for quote without CCM params");
|
|
896
|
+
} else {
|
|
897
|
+
assert(!quote.ccmParams, "Cannot open regular channel for quote with CCM params");
|
|
898
|
+
}
|
|
862
899
|
const depositAddressRequest = {
|
|
863
900
|
srcAsset: quote.srcAsset.asset,
|
|
864
901
|
srcChain: quote.srcAsset.chain,
|
|
@@ -932,6 +969,11 @@ var SwapSDK = class {
|
|
|
932
969
|
await this.validateSwapAmount(quote.srcAsset, BigInt(quote.depositAmount));
|
|
933
970
|
assertQuoteValid(quote);
|
|
934
971
|
assert(quote.isVaultSwap, "Cannot encode vault swap data for a deposit channel quote");
|
|
972
|
+
if (ccmParams) {
|
|
973
|
+
assert(quote.ccmParams, "Cannot encode CCM swap for quote without CCM params");
|
|
974
|
+
} else {
|
|
975
|
+
assert(!quote.ccmParams, "Cannot encode regular swap for quote with CCM params");
|
|
976
|
+
}
|
|
935
977
|
const vaultSwapRequest = {
|
|
936
978
|
srcAsset: quote.srcAsset,
|
|
937
979
|
destAsset: quote.destAsset,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@chainflip/bitcoin": "^1.2.4",
|
|
45
|
-
"@chainflip/rpc": "^1.8.
|
|
45
|
+
"@chainflip/rpc": "^1.8.9",
|
|
46
46
|
"@chainflip/solana": "^2.1.4",
|
|
47
47
|
"@chainflip/utils": "^0.5.0",
|
|
48
48
|
"@trpc/client": "^10.45.2",
|