@chainflip/sdk 1.8.2 → 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 CHANGED
@@ -173,10 +173,10 @@ interface QuoteRequest extends ChainsAndAssets {
173
173
  messageLengthBytes: number;
174
174
  };
175
175
  }
176
- interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers' | 'ccmParams'> {
176
+ interface QuoteResponse extends QuoteRequest {
177
177
  quote: Quote;
178
178
  }
179
- interface QuoteResponseV2 extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers' | 'ccmParams'> {
179
+ interface QuoteResponseV2 extends QuoteRequest {
180
180
  quotes: Quote[];
181
181
  }
182
182
  type FillOrKillParamsWithSlippage = Omit<FillOrKillParamsWithMinPrice, 'minPrice'> & {
package/dist/swap.d.ts CHANGED
@@ -173,10 +173,10 @@ interface QuoteRequest extends ChainsAndAssets {
173
173
  messageLengthBytes: number;
174
174
  };
175
175
  }
176
- interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers' | 'ccmParams'> {
176
+ interface QuoteResponse extends QuoteRequest {
177
177
  quote: Quote;
178
178
  }
179
- interface QuoteResponseV2 extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers' | 'ccmParams'> {
179
+ interface QuoteResponseV2 extends QuoteRequest {
180
180
  quotes: Quote[];
181
181
  }
182
182
  type FillOrKillParamsWithSlippage = Omit<FillOrKillParamsWithMinPrice, 'minPrice'> & {
package/dist/swap.js CHANGED
@@ -397,8 +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: numericString.transform((v) => BigInt(v)).optional(),
401
- ccmMessageLengthBytes: numericString.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(),
402
410
  dcaEnabled: booleanString.default("false"),
403
411
  isVaultSwap: booleanString.default("false")
404
412
  }).transform((args, ctx) => {
@@ -884,7 +892,7 @@ var getChainData = (chain2, network, env) => ({
884
892
  });
885
893
 
886
894
  // package.json
887
- var version = "1.8.2";
895
+ var version = "1.8.3";
888
896
 
889
897
  // src/swap/consts.ts
890
898
  var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": version };
@@ -895,18 +903,21 @@ var BACKEND_SERVICE_URLS = {
895
903
  [ChainflipNetworks.mainnet]: "https://chainflip-swap.chainflip.io/"
896
904
  };
897
905
  var getQuote = async (baseUrl, quoteRequest, { signal }) => {
898
- const { brokerCommissionBps, ccmGasBudget, ccmMessageLengthBytes, ...returnedRequestData } = quoteRequest;
906
+ const affiliateCommissionBps = quoteRequest.affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
907
+ const totalBrokerCommissionBps = (quoteRequest.brokerCommissionBps ?? 0) + affiliateCommissionBps;
899
908
  const params = {
900
- amount: returnedRequestData.amount,
901
- srcChain: returnedRequestData.srcChain,
902
- srcAsset: returnedRequestData.srcAsset,
903
- destChain: returnedRequestData.destChain,
904
- destAsset: returnedRequestData.destAsset,
909
+ amount: quoteRequest.amount,
910
+ srcChain: quoteRequest.srcChain,
911
+ srcAsset: quoteRequest.srcAsset,
912
+ destChain: quoteRequest.destChain,
913
+ destAsset: quoteRequest.destAsset,
905
914
  isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
906
- ccmGasBudget: String(ccmGasBudget),
907
- ccmMessageLengthBytes: String(ccmMessageLengthBytes),
908
- ...brokerCommissionBps && {
909
- brokerCommissionBps: String(brokerCommissionBps)
915
+ ...totalBrokerCommissionBps && {
916
+ brokerCommissionBps: String(totalBrokerCommissionBps)
917
+ },
918
+ ...quoteRequest.ccmParams && {
919
+ ccmGasBudget: quoteRequest.ccmParams.gasBudget,
920
+ ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
910
921
  },
911
922
  dcaEnabled: "false"
912
923
  };
@@ -916,21 +927,24 @@ var getQuote = async (baseUrl, quoteRequest, { signal }) => {
916
927
  signal,
917
928
  headers: CF_SDK_VERSION_HEADERS
918
929
  });
919
- return { ...returnedRequestData, quote: data };
930
+ return { ...quoteRequest, quote: data };
920
931
  };
921
932
  var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
922
- const { brokerCommissionBps, ccmGasBudget, ccmMessageLengthBytes, ...returnedRequestData } = quoteRequest;
933
+ const affiliateCommissionBps = quoteRequest.affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
934
+ const totalBrokerCommissionBps = (quoteRequest.brokerCommissionBps ?? 0) + affiliateCommissionBps;
923
935
  const params = {
924
- amount: returnedRequestData.amount,
925
- srcChain: returnedRequestData.srcChain,
926
- srcAsset: returnedRequestData.srcAsset,
927
- destChain: returnedRequestData.destChain,
928
- destAsset: returnedRequestData.destAsset,
936
+ amount: quoteRequest.amount,
937
+ srcChain: quoteRequest.srcChain,
938
+ srcAsset: quoteRequest.srcAsset,
939
+ destChain: quoteRequest.destChain,
940
+ destAsset: quoteRequest.destAsset,
929
941
  isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
930
- ccmGasBudget: String(ccmGasBudget),
931
- ccmMessageLengthBytes: String(ccmMessageLengthBytes),
932
- ...brokerCommissionBps && {
933
- brokerCommissionBps: String(brokerCommissionBps)
942
+ ...totalBrokerCommissionBps && {
943
+ brokerCommissionBps: String(totalBrokerCommissionBps)
944
+ },
945
+ ...quoteRequest.ccmParams && {
946
+ ccmGasBudget: quoteRequest.ccmParams.gasBudget,
947
+ ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
934
948
  },
935
949
  dcaEnabled: String(Boolean(quoteRequest.dcaEnabled))
936
950
  };
@@ -940,7 +954,7 @@ var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
940
954
  signal,
941
955
  headers: CF_SDK_VERSION_HEADERS
942
956
  });
943
- return { ...returnedRequestData, quotes: data };
957
+ return { ...quoteRequest, quotes: data };
944
958
  };
945
959
  var getStatus = async (baseUrl, { id }, { signal }) => {
946
960
  const { data } = await axios__default.default.get(`/swaps/${id}`, {
@@ -1030,31 +1044,23 @@ var SwapSDK = class {
1030
1044
  console.error(
1031
1045
  "[@chainflip/sdk] The getQuote method is deprecated and will be removed in the 1.9 release. Use the getQuoteV2 method instead."
1032
1046
  );
1033
- const { brokerCommissionBps, affiliateBrokers, ccmParams, ...remainingRequest } = quoteRequest;
1034
- const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
1035
- const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
1047
+ const submitterBrokerCommissionBps = quoteRequest.brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
1036
1048
  return getQuote(
1037
1049
  this.options.backendUrl,
1038
1050
  {
1039
- ...remainingRequest,
1040
- ccmGasBudget: ccmParams?.gasBudget,
1041
- ccmMessageLengthBytes: ccmParams?.messageLengthBytes,
1042
- brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
1051
+ ...quoteRequest,
1052
+ brokerCommissionBps: submitterBrokerCommissionBps
1043
1053
  },
1044
1054
  options
1045
1055
  );
1046
1056
  }
1047
1057
  getQuoteV2(quoteRequest, options = {}) {
1048
- const { brokerCommissionBps, affiliateBrokers, ccmParams, ...remainingRequest } = quoteRequest;
1049
- const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
1050
- const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
1058
+ const submitterBrokerCommissionBps = quoteRequest.brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
1051
1059
  return getQuoteV2(
1052
1060
  this.options.backendUrl,
1053
1061
  {
1054
- ...remainingRequest,
1055
- brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps,
1056
- ccmGasBudget: ccmParams?.gasBudget,
1057
- ccmMessageLengthBytes: ccmParams?.messageLengthBytes,
1062
+ ...quoteRequest,
1063
+ brokerCommissionBps: submitterBrokerCommissionBps,
1058
1064
  dcaEnabled: this.dcaEnabled
1059
1065
  },
1060
1066
  options
package/dist/swap.mjs CHANGED
@@ -174,8 +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: numericString.transform((v) => BigInt(v)).optional(),
178
- ccmMessageLengthBytes: numericString.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(),
179
187
  dcaEnabled: booleanString.default("false"),
180
188
  isVaultSwap: booleanString.default("false")
181
189
  }).transform((args, ctx) => {
@@ -570,7 +578,7 @@ var getChainData = (chain2, network, env) => ({
570
578
  });
571
579
 
572
580
  // package.json
573
- var version = "1.8.2";
581
+ var version = "1.8.3";
574
582
 
575
583
  // src/swap/consts.ts
576
584
  var CF_SDK_VERSION_HEADERS = { "X-Chainflip-Sdk-Version": version };
@@ -581,18 +589,21 @@ var BACKEND_SERVICE_URLS = {
581
589
  [ChainflipNetworks.mainnet]: "https://chainflip-swap.chainflip.io/"
582
590
  };
583
591
  var getQuote = async (baseUrl, quoteRequest, { signal }) => {
584
- const { brokerCommissionBps, ccmGasBudget, ccmMessageLengthBytes, ...returnedRequestData } = quoteRequest;
592
+ const affiliateCommissionBps = quoteRequest.affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
593
+ const totalBrokerCommissionBps = (quoteRequest.brokerCommissionBps ?? 0) + affiliateCommissionBps;
585
594
  const params = {
586
- amount: returnedRequestData.amount,
587
- srcChain: returnedRequestData.srcChain,
588
- srcAsset: returnedRequestData.srcAsset,
589
- destChain: returnedRequestData.destChain,
590
- destAsset: returnedRequestData.destAsset,
595
+ amount: quoteRequest.amount,
596
+ srcChain: quoteRequest.srcChain,
597
+ srcAsset: quoteRequest.srcAsset,
598
+ destChain: quoteRequest.destChain,
599
+ destAsset: quoteRequest.destAsset,
591
600
  isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
592
- ccmGasBudget: String(ccmGasBudget),
593
- ccmMessageLengthBytes: String(ccmMessageLengthBytes),
594
- ...brokerCommissionBps && {
595
- brokerCommissionBps: String(brokerCommissionBps)
601
+ ...totalBrokerCommissionBps && {
602
+ brokerCommissionBps: String(totalBrokerCommissionBps)
603
+ },
604
+ ...quoteRequest.ccmParams && {
605
+ ccmGasBudget: quoteRequest.ccmParams.gasBudget,
606
+ ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
596
607
  },
597
608
  dcaEnabled: "false"
598
609
  };
@@ -602,21 +613,24 @@ var getQuote = async (baseUrl, quoteRequest, { signal }) => {
602
613
  signal,
603
614
  headers: CF_SDK_VERSION_HEADERS
604
615
  });
605
- return { ...returnedRequestData, quote: data };
616
+ return { ...quoteRequest, quote: data };
606
617
  };
607
618
  var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
608
- const { brokerCommissionBps, ccmGasBudget, ccmMessageLengthBytes, ...returnedRequestData } = quoteRequest;
619
+ const affiliateCommissionBps = quoteRequest.affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
620
+ const totalBrokerCommissionBps = (quoteRequest.brokerCommissionBps ?? 0) + affiliateCommissionBps;
609
621
  const params = {
610
- amount: returnedRequestData.amount,
611
- srcChain: returnedRequestData.srcChain,
612
- srcAsset: returnedRequestData.srcAsset,
613
- destChain: returnedRequestData.destChain,
614
- destAsset: returnedRequestData.destAsset,
622
+ amount: quoteRequest.amount,
623
+ srcChain: quoteRequest.srcChain,
624
+ srcAsset: quoteRequest.srcAsset,
625
+ destChain: quoteRequest.destChain,
626
+ destAsset: quoteRequest.destAsset,
615
627
  isVaultSwap: String(Boolean(quoteRequest.isVaultSwap)),
616
- ccmGasBudget: String(ccmGasBudget),
617
- ccmMessageLengthBytes: String(ccmMessageLengthBytes),
618
- ...brokerCommissionBps && {
619
- brokerCommissionBps: String(brokerCommissionBps)
628
+ ...totalBrokerCommissionBps && {
629
+ brokerCommissionBps: String(totalBrokerCommissionBps)
630
+ },
631
+ ...quoteRequest.ccmParams && {
632
+ ccmGasBudget: quoteRequest.ccmParams.gasBudget,
633
+ ccmMessageLengthBytes: String(quoteRequest.ccmParams.messageLengthBytes)
620
634
  },
621
635
  dcaEnabled: String(Boolean(quoteRequest.dcaEnabled))
622
636
  };
@@ -626,7 +640,7 @@ var getQuoteV2 = async (baseUrl, quoteRequest, { signal }) => {
626
640
  signal,
627
641
  headers: CF_SDK_VERSION_HEADERS
628
642
  });
629
- return { ...returnedRequestData, quotes: data };
643
+ return { ...quoteRequest, quotes: data };
630
644
  };
631
645
  var getStatus = async (baseUrl, { id }, { signal }) => {
632
646
  const { data } = await axios.get(`/swaps/${id}`, {
@@ -716,31 +730,23 @@ var SwapSDK = class {
716
730
  console.error(
717
731
  "[@chainflip/sdk] The getQuote method is deprecated and will be removed in the 1.9 release. Use the getQuoteV2 method instead."
718
732
  );
719
- const { brokerCommissionBps, affiliateBrokers, ccmParams, ...remainingRequest } = quoteRequest;
720
- const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
721
- const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
733
+ const submitterBrokerCommissionBps = quoteRequest.brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
722
734
  return getQuote(
723
735
  this.options.backendUrl,
724
736
  {
725
- ...remainingRequest,
726
- ccmGasBudget: ccmParams?.gasBudget,
727
- ccmMessageLengthBytes: ccmParams?.messageLengthBytes,
728
- brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
737
+ ...quoteRequest,
738
+ brokerCommissionBps: submitterBrokerCommissionBps
729
739
  },
730
740
  options
731
741
  );
732
742
  }
733
743
  getQuoteV2(quoteRequest, options = {}) {
734
- const { brokerCommissionBps, affiliateBrokers, ccmParams, ...remainingRequest } = quoteRequest;
735
- const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
736
- const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
744
+ const submitterBrokerCommissionBps = quoteRequest.brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
737
745
  return getQuoteV2(
738
746
  this.options.backendUrl,
739
747
  {
740
- ...remainingRequest,
741
- brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps,
742
- ccmGasBudget: ccmParams?.gasBudget,
743
- ccmMessageLengthBytes: ccmParams?.messageLengthBytes,
748
+ ...quoteRequest,
749
+ brokerCommissionBps: submitterBrokerCommissionBps,
744
750
  dcaEnabled: this.dcaEnabled
745
751
  },
746
752
  options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "1.8.2",
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.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",