@chainflip/sdk 1.4.3 → 1.4.4

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,6 +1,6 @@
1
1
  import { Signer } from 'ethers';
2
- 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, U as UncheckedAssetAndChain } from './contracts-Maix4eRX.mjs';
3
- export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, j as getChainflipId } from './contracts-Maix4eRX.mjs';
2
+ 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-Maix4eRX.mjs';
3
+ export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-Maix4eRX.mjs';
4
4
  import { z } from 'zod';
5
5
 
6
6
  declare const ccmMetadataSchema: z.ZodObject<{
@@ -129,6 +129,7 @@ interface SwapStatusResponseCommonFields extends ChainsAndAssets {
129
129
  ccmMetadata: CcmMetadata | undefined;
130
130
  feesPaid: SwapFee[];
131
131
  estimatedDefaultDurationSeconds: number | undefined;
132
+ srcChainRequiredBlockConfirmations: number | undefined;
132
133
  }
133
134
  interface DepositAddressFields extends SwapStatusResponseCommonFields {
134
135
  depositAddress: string;
@@ -316,10 +317,13 @@ declare class SwapSDK {
316
317
  }>;
317
318
  getRequiredBlockConfirmations(): Promise<ChainMap<number | null>>;
318
319
  getChannelOpeningFees(): Promise<ChainMap<bigint>>;
319
- getBoostLiquidity({ chainAsset, feeTierBps, }?: {
320
- chainAsset?: UncheckedAssetAndChain;
320
+ getBoostLiquidity(params?: {
321
321
  feeTierBps?: number;
322
+ } | {
323
+ feeTierBps?: number;
324
+ asset: Asset;
325
+ chain: Chain;
322
326
  }): Promise<BoostPoolDepth[]>;
323
327
  }
324
328
 
325
- export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, UncheckedAssetAndChain, type VaultSwapStatusResponse };
329
+ export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse };
package/dist/swap.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Signer } from 'ethers';
2
- 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, U as UncheckedAssetAndChain } from './contracts-Maix4eRX.js';
3
- export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, j as getChainflipId } from './contracts-Maix4eRX.js';
2
+ 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-Maix4eRX.js';
3
+ export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-Maix4eRX.js';
4
4
  import { z } from 'zod';
5
5
 
6
6
  declare const ccmMetadataSchema: z.ZodObject<{
@@ -129,6 +129,7 @@ interface SwapStatusResponseCommonFields extends ChainsAndAssets {
129
129
  ccmMetadata: CcmMetadata | undefined;
130
130
  feesPaid: SwapFee[];
131
131
  estimatedDefaultDurationSeconds: number | undefined;
132
+ srcChainRequiredBlockConfirmations: number | undefined;
132
133
  }
133
134
  interface DepositAddressFields extends SwapStatusResponseCommonFields {
134
135
  depositAddress: string;
@@ -316,10 +317,13 @@ declare class SwapSDK {
316
317
  }>;
317
318
  getRequiredBlockConfirmations(): Promise<ChainMap<number | null>>;
318
319
  getChannelOpeningFees(): Promise<ChainMap<bigint>>;
319
- getBoostLiquidity({ chainAsset, feeTierBps, }?: {
320
- chainAsset?: UncheckedAssetAndChain;
320
+ getBoostLiquidity(params?: {
321
321
  feeTierBps?: number;
322
+ } | {
323
+ feeTierBps?: number;
324
+ asset: Asset;
325
+ chain: Chain;
322
326
  }): Promise<BoostPoolDepth[]>;
323
327
  }
324
328
 
325
- export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, UncheckedAssetAndChain, type VaultSwapStatusResponse };
329
+ export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse };
package/dist/swap.js CHANGED
@@ -557,11 +557,11 @@ function datetimeRegex(args) {
557
557
  regex = `${regex}(${opts.join("|")})`;
558
558
  return new RegExp(`^${regex}$`);
559
559
  }
560
- function isValidIP(ip, version) {
561
- if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
560
+ function isValidIP(ip, version2) {
561
+ if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
562
562
  return true;
563
563
  }
564
- if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
564
+ if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) {
565
565
  return true;
566
566
  }
567
567
  return false;
@@ -8653,6 +8653,14 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
8653
8653
 
8654
8654
  // src/swap/consts.ts
8655
8655
  init_enums();
8656
+
8657
+ // package.json
8658
+ var version = "1.4.4";
8659
+
8660
+ // src/swap/consts.ts
8661
+ var CF_SDK_VERSION_HEADERS = {
8662
+ "Cf-Sdk-Version": version
8663
+ };
8656
8664
  var BACKEND_SERVICE_URLS = {
8657
8665
  [exports.ChainflipNetworks.backspin]: "https://chainflip-swap-backspin.staging/",
8658
8666
  [exports.ChainflipNetworks.sisyphos]: "https://chainflip-swap.staging/",
@@ -8671,10 +8679,11 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
8671
8679
  brokerCommissionBps: String(brokerCommissionBps)
8672
8680
  }
8673
8681
  };
8674
- const queryParams = new URLSearchParams(params);
8675
- const url = new URL(`/quote?${queryParams.toString()}`, baseUrl).toString();
8676
- const { data } = await axios__default.default.get(url, {
8677
- signal
8682
+ const { data } = await axios__default.default.get("/quote", {
8683
+ baseURL: baseUrl,
8684
+ params,
8685
+ signal,
8686
+ headers: CF_SDK_VERSION_HEADERS
8678
8687
  });
8679
8688
  return {
8680
8689
  ...returnedRequestData,
@@ -8682,9 +8691,10 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
8682
8691
  };
8683
8692
  }, "getQuote");
8684
8693
  var getStatus = /* @__PURE__ */ __name(async (baseUrl, { id }, { signal }) => {
8685
- const url = new URL(`/swaps/${id}`, baseUrl).toString();
8686
- const { data } = await axios__default.default.get(url, {
8687
- signal
8694
+ const { data } = await axios__default.default.get(`/swaps/${id}`, {
8695
+ baseURL: baseUrl,
8696
+ signal,
8697
+ headers: CF_SDK_VERSION_HEADERS
8688
8698
  });
8689
8699
  return data;
8690
8700
  }, "getStatus");
@@ -8712,7 +8722,8 @@ var _SwapSDK = class _SwapSDK {
8712
8722
  transformer: esm_default,
8713
8723
  links: [
8714
8724
  httpBatchLink({
8715
- url: new URL("/trpc", this.options.backendUrl)
8725
+ url: new URL("/trpc", this.options.backendUrl),
8726
+ headers: CF_SDK_VERSION_HEADERS
8716
8727
  })
8717
8728
  ]
8718
8729
  });
@@ -8849,14 +8860,18 @@ var _SwapSDK = class _SwapSDK {
8849
8860
  const { ingressEgress: { channelOpeningFees } } = await this.getStateChainEnvironment();
8850
8861
  return channelOpeningFees;
8851
8862
  }
8852
- async getBoostLiquidity({ chainAsset, feeTierBps } = {}) {
8863
+ async getBoostLiquidity(params = {}) {
8853
8864
  let poolsDepth = await this.getBoostPoolsDepth();
8854
- if (chainAsset) {
8855
- const internalAsset = getInternalAsset(chainAsset);
8865
+ if ("chain" in params && "asset" in params) {
8866
+ const { chain: chain2, asset: asset2 } = params;
8867
+ const internalAsset = getInternalAsset({
8868
+ chain: chain2,
8869
+ asset: asset2
8870
+ });
8856
8871
  poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.asset === internalAsset).sort((a, b) => b.tier - a.tier);
8857
8872
  }
8858
- if (feeTierBps) {
8859
- poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === feeTierBps);
8873
+ if ("feeTierBps" in params && params.feeTierBps !== void 0) {
8874
+ poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === params.feeTierBps);
8860
8875
  }
8861
8876
  return poolsDepth.map((depth) => ({
8862
8877
  availableAmount: depth.availableAmount,
package/dist/swap.mjs CHANGED
@@ -2348,7 +2348,13 @@ var getChainData = /* @__PURE__ */ __name((chain, network, env) => ({
2348
2348
  requiredBlockConfirmations: isNotNullish(env.ingressEgress.witnessSafetyMargins[chain]) ? Number(env.ingressEgress.witnessSafetyMargins[chain]) + 1 : void 0
2349
2349
  }), "getChainData");
2350
2350
 
2351
+ // package.json
2352
+ var version = "1.4.4";
2353
+
2351
2354
  // src/swap/consts.ts
2355
+ var CF_SDK_VERSION_HEADERS = {
2356
+ "Cf-Sdk-Version": version
2357
+ };
2352
2358
  var BACKEND_SERVICE_URLS = {
2353
2359
  [ChainflipNetworks.backspin]: "https://chainflip-swap-backspin.staging/",
2354
2360
  [ChainflipNetworks.sisyphos]: "https://chainflip-swap.staging/",
@@ -2367,10 +2373,11 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
2367
2373
  brokerCommissionBps: String(brokerCommissionBps)
2368
2374
  }
2369
2375
  };
2370
- const queryParams = new URLSearchParams(params);
2371
- const url = new URL(`/quote?${queryParams.toString()}`, baseUrl).toString();
2372
- const { data } = await axios.get(url, {
2373
- signal
2376
+ const { data } = await axios.get("/quote", {
2377
+ baseURL: baseUrl,
2378
+ params,
2379
+ signal,
2380
+ headers: CF_SDK_VERSION_HEADERS
2374
2381
  });
2375
2382
  return {
2376
2383
  ...returnedRequestData,
@@ -2378,9 +2385,10 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
2378
2385
  };
2379
2386
  }, "getQuote");
2380
2387
  var getStatus = /* @__PURE__ */ __name(async (baseUrl, { id }, { signal }) => {
2381
- const url = new URL(`/swaps/${id}`, baseUrl).toString();
2382
- const { data } = await axios.get(url, {
2383
- signal
2388
+ const { data } = await axios.get(`/swaps/${id}`, {
2389
+ baseURL: baseUrl,
2390
+ signal,
2391
+ headers: CF_SDK_VERSION_HEADERS
2384
2392
  });
2385
2393
  return data;
2386
2394
  }, "getStatus");
@@ -2408,7 +2416,8 @@ var _SwapSDK = class _SwapSDK {
2408
2416
  transformer: esm_default,
2409
2417
  links: [
2410
2418
  httpBatchLink({
2411
- url: new URL("/trpc", this.options.backendUrl)
2419
+ url: new URL("/trpc", this.options.backendUrl),
2420
+ headers: CF_SDK_VERSION_HEADERS
2412
2421
  })
2413
2422
  ]
2414
2423
  });
@@ -2545,14 +2554,18 @@ var _SwapSDK = class _SwapSDK {
2545
2554
  const { ingressEgress: { channelOpeningFees } } = await this.getStateChainEnvironment();
2546
2555
  return channelOpeningFees;
2547
2556
  }
2548
- async getBoostLiquidity({ chainAsset, feeTierBps } = {}) {
2557
+ async getBoostLiquidity(params = {}) {
2549
2558
  let poolsDepth = await this.getBoostPoolsDepth();
2550
- if (chainAsset) {
2551
- const internalAsset = getInternalAsset(chainAsset);
2559
+ if ("chain" in params && "asset" in params) {
2560
+ const { chain, asset } = params;
2561
+ const internalAsset = getInternalAsset({
2562
+ chain,
2563
+ asset
2564
+ });
2552
2565
  poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.asset === internalAsset).sort((a, b) => b.tier - a.tier);
2553
2566
  }
2554
- if (feeTierBps) {
2555
- poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === feeTierBps);
2567
+ if ("feeTierBps" in params && params.feeTierBps !== void 0) {
2568
+ poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === params.feeTierBps);
2556
2569
  }
2557
2570
  return poolsDepth.map((depth) => ({
2558
2571
  availableAmount: depth.availableAmount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {
@@ -44,7 +44,7 @@
44
44
  "@chainflip/rpc": "^1.4.10",
45
45
  "@chainflip/utils": "^0.4.0",
46
46
  "axios": "^1.6.8",
47
- "ethers": "^6.13.1"
47
+ "ethers": "^6.13.2"
48
48
  },
49
49
  "devDependencies": {
50
50
  "tsup": "^8.1.0"