@chainflip/sdk 1.7.0-rc.0 → 1.7.0

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
@@ -1,7 +1,6 @@
1
1
  import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-Bgib7w_h.mjs';
2
2
  export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-Bgib7w_h.mjs';
3
3
  import { z } from 'zod';
4
- import { SwappingRequestSwapDepositAddressWithAffiliates } from '@chainflip/extrinsics/160/swapping/requestSwapDepositAddressWithAffiliates';
5
4
  import { Signer } from 'ethers';
6
5
 
7
6
  declare const ccmParamsSchema: z.ZodObject<{
@@ -592,7 +591,6 @@ declare class SwapSDK {
592
591
  } | undefined;
593
592
  amount: string;
594
593
  }>;
595
- buildRequestSwapDepositAddressWithAffiliatesParams({ quote, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers, ccmParams, brokerCommissionBps, }: DepositAddressRequestV2): SwappingRequestSwapDepositAddressWithAffiliates;
596
594
  }
597
595
 
598
596
  export { Asset, type AssetData, type BoostPoolDepth, type BoostQuote, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DCABoostQuote, type DCAQuote, type DepositAddressRequest, type DepositAddressRequestV2, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type FillOrKillParamsWithSlippage, type Quote, type QuoteRequest, type QuoteResponse, type QuoteResponseV2, type RegularQuote, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse };
package/dist/swap.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-Bgib7w_h.js';
2
2
  export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-Bgib7w_h.js';
3
3
  import { z } from 'zod';
4
- import { SwappingRequestSwapDepositAddressWithAffiliates } from '@chainflip/extrinsics/160/swapping/requestSwapDepositAddressWithAffiliates';
5
4
  import { Signer } from 'ethers';
6
5
 
7
6
  declare const ccmParamsSchema: z.ZodObject<{
@@ -592,7 +591,6 @@ declare class SwapSDK {
592
591
  } | undefined;
593
592
  amount: string;
594
593
  }>;
595
- buildRequestSwapDepositAddressWithAffiliatesParams({ quote, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers, ccmParams, brokerCommissionBps, }: DepositAddressRequestV2): SwappingRequestSwapDepositAddressWithAffiliates;
596
594
  }
597
595
 
598
596
  export { Asset, type AssetData, type BoostPoolDepth, type BoostQuote, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DCABoostQuote, type DCAQuote, type DepositAddressRequest, type DepositAddressRequestV2, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type FillOrKillParamsWithSlippage, type Quote, type QuoteRequest, type QuoteResponse, type QuoteResponseV2, type RegularQuote, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse };
package/dist/swap.js CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  var client = require('@trpc/client');
4
4
  var superjson = require('superjson');
5
- var bitcoin = require('@chainflip/bitcoin');
6
5
  var rpc = require('@chainflip/rpc');
7
- var base58 = require('@chainflip/utils/base58');
8
- var bytes = require('@chainflip/utils/bytes');
9
6
  var ss582 = require('@chainflip/utils/ss58');
10
- var string$1 = require('@chainflip/utils/string');
11
7
  var zod = require('zod');
8
+ var bitcoin = require('@chainflip/bitcoin');
12
9
  var solana = require('@chainflip/solana');
10
+ var base58 = require('@chainflip/utils/base58');
11
+ var bytes = require('@chainflip/utils/bytes');
12
+ var string$1 = require('@chainflip/utils/string');
13
13
  var ethers = require('ethers');
14
14
  var address = require('@chainflip/solana/address');
15
15
  var number$1 = require('@chainflip/utils/number');
@@ -37,9 +37,9 @@ function _interopNamespace(e) {
37
37
  }
38
38
 
39
39
  var superjson__default = /*#__PURE__*/_interopDefault(superjson);
40
+ var ss582__namespace = /*#__PURE__*/_interopNamespace(ss582);
40
41
  var bitcoin__namespace = /*#__PURE__*/_interopNamespace(bitcoin);
41
42
  var base58__namespace = /*#__PURE__*/_interopNamespace(base58);
42
- var ss582__namespace = /*#__PURE__*/_interopNamespace(ss582);
43
43
  var ethers__namespace = /*#__PURE__*/_interopNamespace(ethers);
44
44
  var BigNumber__default = /*#__PURE__*/_interopDefault(BigNumber);
45
45
  var axios__default = /*#__PURE__*/_interopDefault(axios);
@@ -681,82 +681,6 @@ async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork2) {
681
681
  return validateResponse(chainflipNetwork2, response);
682
682
  }
683
683
  __name(requestSwapDepositAddress, "requestSwapDepositAddress");
684
- function toEncodedAddress(chain2, address) {
685
- switch (chain2) {
686
- case "Arbitrum":
687
- assert(string$1.isHex(address), "Expected hex-encoded EVM address");
688
- return {
689
- Arb: bytes.hexToBytes(address)
690
- };
691
- case "Ethereum":
692
- assert(string$1.isHex(address), "Expected hex-encoded EVM address");
693
- return {
694
- Eth: bytes.hexToBytes(address)
695
- };
696
- case "Polkadot":
697
- return {
698
- Dot: string$1.isHex(address) ? bytes.hexToBytes(address) : ss582__namespace.decode(address).data
699
- };
700
- case "Solana":
701
- return {
702
- Sol: string$1.isHex(address) ? bytes.hexToBytes(address) : base58__namespace.decode(address)
703
- };
704
- case "Bitcoin":
705
- return {
706
- Btc: bytes.bytesToHex(new TextEncoder().encode(address))
707
- };
708
- default:
709
- throw new Error(`Unsupported chain: ${chain2}`);
710
- }
711
- }
712
- __name(toEncodedAddress, "toEncodedAddress");
713
- var toForeignChainAddress = /* @__PURE__ */ __name((chain2, address, network) => {
714
- switch (chain2) {
715
- case "Arbitrum":
716
- case "Ethereum":
717
- case "Polkadot":
718
- case "Solana":
719
- return toEncodedAddress(chain2, address);
720
- case "Bitcoin": {
721
- const { type, data } = bitcoin__namespace.decodeAddress(address, network);
722
- return {
723
- Btc: {
724
- [type]: data
725
- }
726
- };
727
- }
728
- default:
729
- throw new Error(`Unsupported chain: ${chain2}`);
730
- }
731
- }, "toForeignChainAddress");
732
- var buildExtrinsicPayload = /* @__PURE__ */ __name((swapRequest, chainflipNetwork2) => {
733
- const srcAsset = getInternalAsset({
734
- asset: swapRequest.srcAsset,
735
- chain: swapRequest.srcChain
736
- });
737
- const destAsset = getInternalAsset({
738
- asset: swapRequest.destAsset,
739
- chain: swapRequest.destChain
740
- });
741
- const ccmParams = transformedCcmParamsSchema("0x").nullable().parse(swapRequest.ccmParams ?? null);
742
- const fokParams = getTransformedFokSchema(zod.z.string().transform((address) => toForeignChainAddress(swapRequest.srcChain, address, chainflipNetwork2))).nullable().parse(swapRequest.fillOrKillParams ?? null);
743
- const dcaParams2 = transformedDcaParamsSchema.nullable().parse(swapRequest.dcaParams ?? null);
744
- assert(!dcaParams2 || fokParams, "Fill or kill parameters are required for DCA");
745
- return [
746
- srcAsset,
747
- destAsset,
748
- toEncodedAddress(swapRequest.destChain, swapRequest.destAddress),
749
- swapRequest.commissionBps ?? 0,
750
- ccmParams,
751
- srcAsset === "Btc" ? swapRequest.maxBoostFeeBps ?? 0 : 0,
752
- (swapRequest.affiliates ?? []).map(({ account, commissionBps }) => ({
753
- account: string$1.isHex(account) ? account : bytes.bytesToHex(ss582__namespace.decode(account).data),
754
- bps: commissionBps
755
- })),
756
- fokParams,
757
- dcaParams2
758
- ];
759
- }, "buildExtrinsicPayload");
760
684
  var getPriceX128FromPrice = /* @__PURE__ */ __name((price, srcAsset, destAsset) => BigNumber__default.default(price).multipliedBy(new BigNumber__default.default(2).pow(128)).shiftedBy(assetConstants[destAsset].decimals - assetConstants[srcAsset].decimals).toFixed(0), "getPriceX128FromPrice");
761
685
  var parseFoKParams = /* @__PURE__ */ __name((params, quote) => {
762
686
  if (!params) return void 0;
@@ -2489,7 +2413,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
2489
2413
  }), "getChainData");
2490
2414
 
2491
2415
  // package.json
2492
- var version = "1.7.0-rc.0";
2416
+ var version = "1.7.0";
2493
2417
 
2494
2418
  // src/swap/consts.ts
2495
2419
  var CF_SDK_VERSION_HEADERS = {
@@ -2871,24 +2795,6 @@ var _SwapSDK = class _SwapSDK {
2871
2795
  fillOrKillParams: inputFoKParams
2872
2796
  };
2873
2797
  }
2874
- buildRequestSwapDepositAddressWithAffiliatesParams({ quote, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers, ccmParams, brokerCommissionBps }) {
2875
- assertQuoteValid(quote);
2876
- let dcaParams2 = null;
2877
- if (quote.type === "DCA") dcaParams2 = quote.dcaParams;
2878
- return buildExtrinsicPayload({
2879
- srcAsset: quote.srcAsset.asset,
2880
- srcChain: quote.srcAsset.chain,
2881
- destAsset: quote.destAsset.asset,
2882
- destChain: quote.destAsset.chain,
2883
- destAddress,
2884
- dcaParams: dcaParams2,
2885
- fillOrKillParams: parseFoKParams(inputFoKParams, quote) ?? null,
2886
- maxBoostFeeBps: "maxBoostFeeBps" in quote ? quote.maxBoostFeeBps : null,
2887
- commissionBps: brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0,
2888
- ccmParams: ccmParams ?? null,
2889
- affiliates: affiliateBrokers ?? []
2890
- }, this.options.network);
2891
- }
2892
2798
  };
2893
2799
  __name(_SwapSDK, "SwapSDK");
2894
2800
  var SwapSDK = _SwapSDK;
package/dist/swap.mjs CHANGED
@@ -1,15 +1,15 @@
1
- import { isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __name, assert, __publicField, getEnvironment, assetConstants, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, chainConstants, getTokenContractAddress, isTestnet, getEvmChainId, checkAllowance, extractOverrides, Vault__factory } from './chunk-KLBPIDTY.mjs';
1
+ import { isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __name, __publicField, getEnvironment, assetConstants, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, assert, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, chainConstants, getTokenContractAddress, isTestnet, getEvmChainId, checkAllowance, extractOverrides, Vault__factory } from './chunk-KLBPIDTY.mjs';
2
2
  export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-KLBPIDTY.mjs';
3
3
  import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
4
4
  import superjson from 'superjson';
5
- import * as bitcoin from '@chainflip/bitcoin';
6
5
  import { HttpClient } from '@chainflip/rpc';
7
- import * as base58 from '@chainflip/utils/base58';
8
- import { hexToBytes, bytesToHex } from '@chainflip/utils/bytes';
9
6
  import * as ss582 from '@chainflip/utils/ss58';
10
- import { isHex } from '@chainflip/utils/string';
11
7
  import { z } from 'zod';
8
+ import * as bitcoin from '@chainflip/bitcoin';
12
9
  import { isValidSolanaAddress } from '@chainflip/solana';
10
+ import * as base58 from '@chainflip/utils/base58';
11
+ import { hexToBytes, bytesToHex } from '@chainflip/utils/bytes';
12
+ import { isHex } from '@chainflip/utils/string';
13
13
  import * as ethers from 'ethers';
14
14
  import { isValidSolanaAddress as isValidSolanaAddress$1 } from '@chainflip/solana/address';
15
15
  import { hexEncodeNumber } from '@chainflip/utils/number';
@@ -404,82 +404,6 @@ async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork2) {
404
404
  return validateResponse(chainflipNetwork2, response);
405
405
  }
406
406
  __name(requestSwapDepositAddress, "requestSwapDepositAddress");
407
- function toEncodedAddress(chain2, address) {
408
- switch (chain2) {
409
- case "Arbitrum":
410
- assert(isHex(address), "Expected hex-encoded EVM address");
411
- return {
412
- Arb: hexToBytes(address)
413
- };
414
- case "Ethereum":
415
- assert(isHex(address), "Expected hex-encoded EVM address");
416
- return {
417
- Eth: hexToBytes(address)
418
- };
419
- case "Polkadot":
420
- return {
421
- Dot: isHex(address) ? hexToBytes(address) : ss582.decode(address).data
422
- };
423
- case "Solana":
424
- return {
425
- Sol: isHex(address) ? hexToBytes(address) : base58.decode(address)
426
- };
427
- case "Bitcoin":
428
- return {
429
- Btc: bytesToHex(new TextEncoder().encode(address))
430
- };
431
- default:
432
- throw new Error(`Unsupported chain: ${chain2}`);
433
- }
434
- }
435
- __name(toEncodedAddress, "toEncodedAddress");
436
- var toForeignChainAddress = /* @__PURE__ */ __name((chain2, address, network) => {
437
- switch (chain2) {
438
- case "Arbitrum":
439
- case "Ethereum":
440
- case "Polkadot":
441
- case "Solana":
442
- return toEncodedAddress(chain2, address);
443
- case "Bitcoin": {
444
- const { type, data } = bitcoin.decodeAddress(address, network);
445
- return {
446
- Btc: {
447
- [type]: data
448
- }
449
- };
450
- }
451
- default:
452
- throw new Error(`Unsupported chain: ${chain2}`);
453
- }
454
- }, "toForeignChainAddress");
455
- var buildExtrinsicPayload = /* @__PURE__ */ __name((swapRequest, chainflipNetwork2) => {
456
- const srcAsset = getInternalAsset({
457
- asset: swapRequest.srcAsset,
458
- chain: swapRequest.srcChain
459
- });
460
- const destAsset = getInternalAsset({
461
- asset: swapRequest.destAsset,
462
- chain: swapRequest.destChain
463
- });
464
- const ccmParams = transformedCcmParamsSchema("0x").nullable().parse(swapRequest.ccmParams ?? null);
465
- const fokParams = getTransformedFokSchema(z.string().transform((address) => toForeignChainAddress(swapRequest.srcChain, address, chainflipNetwork2))).nullable().parse(swapRequest.fillOrKillParams ?? null);
466
- const dcaParams2 = transformedDcaParamsSchema.nullable().parse(swapRequest.dcaParams ?? null);
467
- assert(!dcaParams2 || fokParams, "Fill or kill parameters are required for DCA");
468
- return [
469
- srcAsset,
470
- destAsset,
471
- toEncodedAddress(swapRequest.destChain, swapRequest.destAddress),
472
- swapRequest.commissionBps ?? 0,
473
- ccmParams,
474
- srcAsset === "Btc" ? swapRequest.maxBoostFeeBps ?? 0 : 0,
475
- (swapRequest.affiliates ?? []).map(({ account, commissionBps }) => ({
476
- account: isHex(account) ? account : bytesToHex(ss582.decode(account).data),
477
- bps: commissionBps
478
- })),
479
- fokParams,
480
- dcaParams2
481
- ];
482
- }, "buildExtrinsicPayload");
483
407
  var getPriceX128FromPrice = /* @__PURE__ */ __name((price, srcAsset, destAsset) => BigNumber(price).multipliedBy(new BigNumber(2).pow(128)).shiftedBy(assetConstants[destAsset].decimals - assetConstants[srcAsset].decimals).toFixed(0), "getPriceX128FromPrice");
484
408
  var parseFoKParams = /* @__PURE__ */ __name((params, quote) => {
485
409
  if (!params) return void 0;
@@ -770,7 +694,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
770
694
  }), "getChainData");
771
695
 
772
696
  // package.json
773
- var version = "1.7.0-rc.0";
697
+ var version = "1.7.0";
774
698
 
775
699
  // src/swap/consts.ts
776
700
  var CF_SDK_VERSION_HEADERS = {
@@ -1152,24 +1076,6 @@ var _SwapSDK = class _SwapSDK {
1152
1076
  fillOrKillParams: inputFoKParams
1153
1077
  };
1154
1078
  }
1155
- buildRequestSwapDepositAddressWithAffiliatesParams({ quote, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers, ccmParams, brokerCommissionBps }) {
1156
- assertQuoteValid(quote);
1157
- let dcaParams2 = null;
1158
- if (quote.type === "DCA") dcaParams2 = quote.dcaParams;
1159
- return buildExtrinsicPayload({
1160
- srcAsset: quote.srcAsset.asset,
1161
- srcChain: quote.srcAsset.chain,
1162
- destAsset: quote.destAsset.asset,
1163
- destChain: quote.destAsset.chain,
1164
- destAddress,
1165
- dcaParams: dcaParams2,
1166
- fillOrKillParams: parseFoKParams(inputFoKParams, quote) ?? null,
1167
- maxBoostFeeBps: "maxBoostFeeBps" in quote ? quote.maxBoostFeeBps : null,
1168
- commissionBps: brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0,
1169
- ccmParams: ccmParams ?? null,
1170
- affiliates: affiliateBrokers ?? []
1171
- }, this.options.network);
1172
- }
1173
1079
  };
1174
1080
  __name(_SwapSDK, "SwapSDK");
1175
1081
  var SwapSDK = _SwapSDK;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "1.7.0-rc.0",
3
+ "version": "1.7.0",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {
@@ -42,7 +42,6 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@chainflip/bitcoin": "^1.1.1",
45
- "@chainflip/extrinsics": "^1.6.1",
46
45
  "@chainflip/rpc": "^1.6.11",
47
46
  "@chainflip/solana": "^1.0.2",
48
47
  "@chainflip/utils": "^0.4.0",