@chainflip/sdk 1.4.3 → 1.5.0-alpha.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.
@@ -1,4 +1,4 @@
1
- import { z, assetAndChain, numericString, hexString, btcAddress, ccmMetadataSchema, affiliateBroker, dotAddress, ethereumAddress } from './chunk-JHVSTX24.mjs';
1
+ import { z, assetAndChain, numericString, hexString, btcAddress, ccmParamsSchema, affiliateBroker, fillOrKillParams, dotAddress, ethereumAddress } from './chunk-7ENWS5RM.mjs';
2
2
  import { __name, Chains } from './chunk-3V7QJANN.mjs';
3
3
  import { HttpClient } from '@chainflip/rpc';
4
4
  import { bytesToHex } from '@chainflip/utils/bytes';
@@ -19,7 +19,7 @@ var validateRequest = /* @__PURE__ */ __name((network, params) => z.tuple([
19
19
  btcAddress(network)
20
20
  ]),
21
21
  z.number(),
22
- ccmMetadataSchema.merge(z.object({
22
+ ccmParamsSchema.merge(z.object({
23
23
  cfParameters: z.union([
24
24
  hexString,
25
25
  z.string()
@@ -30,7 +30,12 @@ var validateRequest = /* @__PURE__ */ __name((network, params) => z.tuple([
30
30
  gas_budget: `0x${BigInt(rest.gasBudget).toString(16)}`
31
31
  })).optional(),
32
32
  z.number().optional(),
33
- z.array(affiliateBroker).optional()
33
+ z.array(affiliateBroker).optional(),
34
+ fillOrKillParams.transform(({ retryDurationBlocks, refundAddress, minPrice }) => ({
35
+ retry_duration: retryDurationBlocks,
36
+ refund_address: refundAddress,
37
+ min_price: `0x${BigInt(minPrice).toString(16)}`
38
+ })).optional()
34
39
  ]).parse(params), "validateRequest");
35
40
  var validateResponse = /* @__PURE__ */ __name((network, response) => z.object({
36
41
  address: z.union([
@@ -63,12 +68,13 @@ async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork) {
63
68
  },
64
69
  submitAddress(destChain, destAddress),
65
70
  swapRequest.commissionBps ?? 0,
66
- swapRequest.ccmMetadata && {
67
- ...swapRequest.ccmMetadata,
71
+ swapRequest.ccmParams && {
72
+ ...swapRequest.ccmParams,
68
73
  cfParameters: void 0
69
74
  },
70
75
  maxBoostFeeBps,
71
- swapRequest.affiliates
76
+ swapRequest.affiliates,
77
+ swapRequest.fillOrKillParams
72
78
  ]);
73
79
  const response = await client.sendRequest("broker_requestSwapDepositAddress", ...params);
74
80
  return validateResponse(chainflipNetwork, response);
@@ -4442,7 +4442,7 @@ z.object({
4442
4442
  brokerCommissionBps: args.brokerCommissionBps
4443
4443
  };
4444
4444
  });
4445
- var ccmMetadataSchema = z.object({
4445
+ var ccmParamsSchema = z.object({
4446
4446
  gasBudget: numericString,
4447
4447
  message: hexStringWithMaxByteSize(1024 * 10)
4448
4448
  });
@@ -4453,6 +4453,11 @@ var affiliateBroker = z.object({
4453
4453
  account,
4454
4454
  bps
4455
4455
  }));
4456
+ var fillOrKillParams = z.object({
4457
+ retryDurationBlocks: number,
4458
+ refundAddress: z.string(),
4459
+ minPrice: numericString
4460
+ });
4456
4461
  z.object({
4457
4462
  srcAsset: asset,
4458
4463
  destAsset: asset,
@@ -4460,12 +4465,14 @@ z.object({
4460
4465
  destChain: chain,
4461
4466
  destAddress: z.string(),
4462
4467
  amount: numericString,
4463
- ccmMetadata: ccmMetadataSchema.optional(),
4468
+ ccmMetadata: ccmParamsSchema.optional(),
4469
+ ccmParams: ccmParamsSchema.optional(),
4464
4470
  maxBoostFeeBps: z.number().optional(),
4465
- srcAddress: z.string().optional()
4471
+ srcAddress: z.string().optional(),
4472
+ fillOrKillParams: fillOrKillParams.optional()
4466
4473
  }).transform(({ amount, ...rest }) => ({
4467
4474
  ...rest,
4468
4475
  expectedDepositAmount: amount
4469
4476
  }));
4470
4477
 
4471
- export { affiliateBroker, assertValidAddress, assetAndChain, btcAddress, ccmMetadataSchema, dotAddress, ethereumAddress, hexString, numericString, z };
4478
+ export { affiliateBroker, assertValidAddress, assetAndChain, btcAddress, ccmParamsSchema, dotAddress, ethereumAddress, fillOrKillParams, hexString, numericString, z };
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { c as ChainflipNetwork, T as TransactionOptions } from './contracts-Maix4eRX.mjs';
2
+ import { c as ChainflipNetwork, T as TransactionOptions } from './contracts-Cb-5VdIi.mjs';
3
3
 
4
4
  type PendingRedemption = {
5
5
  amount: bigint;
package/dist/funding.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { c as ChainflipNetwork, T as TransactionOptions } from './contracts-Maix4eRX.js';
2
+ import { c as ChainflipNetwork, T as TransactionOptions } from './contracts-Cb-5VdIi.js';
3
3
 
4
4
  type PendingRedemption = {
5
5
  amount: bigint;
package/dist/swap.d.mts CHANGED
@@ -1,9 +1,9 @@
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-Cb-5VdIi.mjs';
3
+ export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-Cb-5VdIi.mjs';
4
4
  import { z } from 'zod';
5
5
 
6
- declare const ccmMetadataSchema: z.ZodObject<{
6
+ declare const ccmParamsSchema: z.ZodObject<{
7
7
  gasBudget: z.ZodString;
8
8
  message: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
9
9
  }, "strip", z.ZodTypeAny, {
@@ -13,7 +13,7 @@ declare const ccmMetadataSchema: z.ZodObject<{
13
13
  message: string;
14
14
  gasBudget: string;
15
15
  }>;
16
- type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
16
+ type CcmParams = z.infer<typeof ccmParamsSchema>;
17
17
  declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
18
18
  account: z.ZodEffects<z.ZodString, string, string>;
19
19
  commissionBps: z.ZodNumber;
@@ -31,6 +31,20 @@ declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
31
31
  commissionBps: number;
32
32
  }>;
33
33
  type AffiliateBroker = z.input<typeof affiliateBroker>;
34
+ declare const fillOrKillParams: z.ZodObject<{
35
+ retryDurationBlocks: z.ZodNumber;
36
+ refundAddress: z.ZodString;
37
+ minPrice: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ retryDurationBlocks: number;
40
+ refundAddress: string;
41
+ minPrice: string;
42
+ }, {
43
+ retryDurationBlocks: number;
44
+ refundAddress: string;
45
+ minPrice: string;
46
+ }>;
47
+ type FillOrKillParams = z.input<typeof fillOrKillParams>;
34
48
  type Fee<T> = {
35
49
  type: T;
36
50
  chain: Chain;
@@ -51,6 +65,7 @@ type QuoteDetails = {
51
65
  poolInfo: PoolInfo[];
52
66
  lowLiquidityWarning: boolean | undefined;
53
67
  estimatedDurationSeconds: number;
68
+ estimatedPrice: string;
54
69
  };
55
70
  type BoostedQuoteDetails = QuoteDetails & {
56
71
  estimatedBoostFeeBps: number;
@@ -66,7 +81,8 @@ interface ExecuteSwapParams {
66
81
  destAsset: Asset;
67
82
  amount: string;
68
83
  destAddress: string;
69
- ccmMetadata?: CcmMetadata;
84
+ ccmParams?: CcmParams;
85
+ ccmMetadata?: CcmParams;
70
86
  }
71
87
 
72
88
  interface ChainData {
@@ -107,9 +123,11 @@ interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affi
107
123
  }
108
124
  interface DepositAddressRequest extends QuoteRequest {
109
125
  destAddress: string;
110
- ccmMetadata?: CcmMetadata;
126
+ ccmParams?: CcmParams;
111
127
  maxBoostFeeBps?: number;
112
128
  srcAddress?: string;
129
+ fillOrKillParams?: FillOrKillParams;
130
+ ccmMetadata?: CcmParams;
113
131
  }
114
132
  interface DepositAddressResponse extends DepositAddressRequest {
115
133
  depositChannelId: string;
@@ -126,9 +144,13 @@ interface SwapStatusRequest {
126
144
  interface SwapStatusResponseCommonFields extends ChainsAndAssets {
127
145
  destAddress: string;
128
146
  ccmDepositReceivedBlockIndex: string | undefined;
129
- ccmMetadata: CcmMetadata | undefined;
147
+ ccmParams: CcmParams | undefined;
130
148
  feesPaid: SwapFee[];
131
149
  estimatedDefaultDurationSeconds: number | undefined;
150
+ srcChainRequiredBlockConfirmations: number | undefined;
151
+ depositTransactionRef: string | undefined;
152
+ depositTransactionHash: string | undefined;
153
+ ccmMetadata?: CcmParams;
132
154
  }
133
155
  interface DepositAddressFields extends SwapStatusResponseCommonFields {
134
156
  depositAddress: string;
@@ -147,6 +169,7 @@ interface DepositAddressFields extends SwapStatusResponseCommonFields {
147
169
  effectiveBoostFeeBps?: number;
148
170
  boostSkippedAt?: number;
149
171
  boostSkippedBlockIndex?: string;
172
+ fillOrKillParams: FillOrKillParams;
150
173
  }
151
174
  type BroadcastRequested = {
152
175
  swapId: string;
@@ -168,8 +191,6 @@ type CopyFields<T, U> = {
168
191
  type VaultSwapFields = CopyFields<DepositAddressFields, SwapStatusResponseCommonFields>;
169
192
  type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
170
193
  depositAmount: string;
171
- depositTransactionHash: string | undefined;
172
- depositTransactionRef: string | undefined;
173
194
  destAddress: string;
174
195
  error: {
175
196
  message: string;
@@ -187,8 +208,6 @@ type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
187
208
  type SwapState = {
188
209
  state: 'AWAITING_DEPOSIT';
189
210
  depositAmount: string | undefined;
190
- depositTransactionHash: string | undefined;
191
- depositTransactionRef: string | undefined;
192
211
  depositTransactionConfirmations: number | undefined;
193
212
  } | {
194
213
  state: 'DEPOSIT_RECEIVED';
@@ -241,8 +260,6 @@ type SwapState = {
241
260
  message: string;
242
261
  };
243
262
  depositAmount: string;
244
- depositTransactionHash: string | undefined;
245
- depositTransactionRef: string | undefined;
246
263
  failedAt: number;
247
264
  failedBlockIndex: string;
248
265
  } | {
@@ -316,10 +333,13 @@ declare class SwapSDK {
316
333
  }>;
317
334
  getRequiredBlockConfirmations(): Promise<ChainMap<number | null>>;
318
335
  getChannelOpeningFees(): Promise<ChainMap<bigint>>;
319
- getBoostLiquidity({ chainAsset, feeTierBps, }?: {
320
- chainAsset?: UncheckedAssetAndChain;
336
+ getBoostLiquidity(params?: {
337
+ feeTierBps?: number;
338
+ } | {
321
339
  feeTierBps?: number;
340
+ asset: Asset;
341
+ chain: Chain;
322
342
  }): Promise<BoostPoolDepth[]>;
323
343
  }
324
344
 
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 };
345
+ 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,9 +1,9 @@
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-Cb-5VdIi.js';
3
+ export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-Cb-5VdIi.js';
4
4
  import { z } from 'zod';
5
5
 
6
- declare const ccmMetadataSchema: z.ZodObject<{
6
+ declare const ccmParamsSchema: z.ZodObject<{
7
7
  gasBudget: z.ZodString;
8
8
  message: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
9
9
  }, "strip", z.ZodTypeAny, {
@@ -13,7 +13,7 @@ declare const ccmMetadataSchema: z.ZodObject<{
13
13
  message: string;
14
14
  gasBudget: string;
15
15
  }>;
16
- type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
16
+ type CcmParams = z.infer<typeof ccmParamsSchema>;
17
17
  declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
18
18
  account: z.ZodEffects<z.ZodString, string, string>;
19
19
  commissionBps: z.ZodNumber;
@@ -31,6 +31,20 @@ declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
31
31
  commissionBps: number;
32
32
  }>;
33
33
  type AffiliateBroker = z.input<typeof affiliateBroker>;
34
+ declare const fillOrKillParams: z.ZodObject<{
35
+ retryDurationBlocks: z.ZodNumber;
36
+ refundAddress: z.ZodString;
37
+ minPrice: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ retryDurationBlocks: number;
40
+ refundAddress: string;
41
+ minPrice: string;
42
+ }, {
43
+ retryDurationBlocks: number;
44
+ refundAddress: string;
45
+ minPrice: string;
46
+ }>;
47
+ type FillOrKillParams = z.input<typeof fillOrKillParams>;
34
48
  type Fee<T> = {
35
49
  type: T;
36
50
  chain: Chain;
@@ -51,6 +65,7 @@ type QuoteDetails = {
51
65
  poolInfo: PoolInfo[];
52
66
  lowLiquidityWarning: boolean | undefined;
53
67
  estimatedDurationSeconds: number;
68
+ estimatedPrice: string;
54
69
  };
55
70
  type BoostedQuoteDetails = QuoteDetails & {
56
71
  estimatedBoostFeeBps: number;
@@ -66,7 +81,8 @@ interface ExecuteSwapParams {
66
81
  destAsset: Asset;
67
82
  amount: string;
68
83
  destAddress: string;
69
- ccmMetadata?: CcmMetadata;
84
+ ccmParams?: CcmParams;
85
+ ccmMetadata?: CcmParams;
70
86
  }
71
87
 
72
88
  interface ChainData {
@@ -107,9 +123,11 @@ interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affi
107
123
  }
108
124
  interface DepositAddressRequest extends QuoteRequest {
109
125
  destAddress: string;
110
- ccmMetadata?: CcmMetadata;
126
+ ccmParams?: CcmParams;
111
127
  maxBoostFeeBps?: number;
112
128
  srcAddress?: string;
129
+ fillOrKillParams?: FillOrKillParams;
130
+ ccmMetadata?: CcmParams;
113
131
  }
114
132
  interface DepositAddressResponse extends DepositAddressRequest {
115
133
  depositChannelId: string;
@@ -126,9 +144,13 @@ interface SwapStatusRequest {
126
144
  interface SwapStatusResponseCommonFields extends ChainsAndAssets {
127
145
  destAddress: string;
128
146
  ccmDepositReceivedBlockIndex: string | undefined;
129
- ccmMetadata: CcmMetadata | undefined;
147
+ ccmParams: CcmParams | undefined;
130
148
  feesPaid: SwapFee[];
131
149
  estimatedDefaultDurationSeconds: number | undefined;
150
+ srcChainRequiredBlockConfirmations: number | undefined;
151
+ depositTransactionRef: string | undefined;
152
+ depositTransactionHash: string | undefined;
153
+ ccmMetadata?: CcmParams;
132
154
  }
133
155
  interface DepositAddressFields extends SwapStatusResponseCommonFields {
134
156
  depositAddress: string;
@@ -147,6 +169,7 @@ interface DepositAddressFields extends SwapStatusResponseCommonFields {
147
169
  effectiveBoostFeeBps?: number;
148
170
  boostSkippedAt?: number;
149
171
  boostSkippedBlockIndex?: string;
172
+ fillOrKillParams: FillOrKillParams;
150
173
  }
151
174
  type BroadcastRequested = {
152
175
  swapId: string;
@@ -168,8 +191,6 @@ type CopyFields<T, U> = {
168
191
  type VaultSwapFields = CopyFields<DepositAddressFields, SwapStatusResponseCommonFields>;
169
192
  type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
170
193
  depositAmount: string;
171
- depositTransactionHash: string | undefined;
172
- depositTransactionRef: string | undefined;
173
194
  destAddress: string;
174
195
  error: {
175
196
  message: string;
@@ -187,8 +208,6 @@ type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
187
208
  type SwapState = {
188
209
  state: 'AWAITING_DEPOSIT';
189
210
  depositAmount: string | undefined;
190
- depositTransactionHash: string | undefined;
191
- depositTransactionRef: string | undefined;
192
211
  depositTransactionConfirmations: number | undefined;
193
212
  } | {
194
213
  state: 'DEPOSIT_RECEIVED';
@@ -241,8 +260,6 @@ type SwapState = {
241
260
  message: string;
242
261
  };
243
262
  depositAmount: string;
244
- depositTransactionHash: string | undefined;
245
- depositTransactionRef: string | undefined;
246
263
  failedAt: number;
247
264
  failedBlockIndex: string;
248
265
  } | {
@@ -316,10 +333,13 @@ declare class SwapSDK {
316
333
  }>;
317
334
  getRequiredBlockConfirmations(): Promise<ChainMap<number | null>>;
318
335
  getChannelOpeningFees(): Promise<ChainMap<bigint>>;
319
- getBoostLiquidity({ chainAsset, feeTierBps, }?: {
320
- chainAsset?: UncheckedAssetAndChain;
336
+ getBoostLiquidity(params?: {
337
+ feeTierBps?: number;
338
+ } | {
321
339
  feeTierBps?: number;
340
+ asset: Asset;
341
+ chain: Chain;
322
342
  }): Promise<BoostPoolDepth[]>;
323
343
  }
324
344
 
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 };
345
+ 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;
@@ -4689,7 +4689,7 @@ var init_parsers = __esm({
4689
4689
  });
4690
4690
 
4691
4691
  // ../shared/src/schemas.ts
4692
- var ccmMetadataSchema, affiliateBroker;
4692
+ var ccmParamsSchema, affiliateBroker, fillOrKillParams;
4693
4693
  var init_schemas = __esm({
4694
4694
  "../shared/src/schemas.ts"() {
4695
4695
  init_lib();
@@ -4731,7 +4731,7 @@ var init_schemas = __esm({
4731
4731
  brokerCommissionBps: args.brokerCommissionBps
4732
4732
  };
4733
4733
  });
4734
- ccmMetadataSchema = z.object({
4734
+ ccmParamsSchema = z.object({
4735
4735
  gasBudget: numericString,
4736
4736
  message: hexStringWithMaxByteSize(1024 * 10)
4737
4737
  });
@@ -4742,6 +4742,11 @@ var init_schemas = __esm({
4742
4742
  account,
4743
4743
  bps
4744
4744
  }));
4745
+ fillOrKillParams = z.object({
4746
+ retryDurationBlocks: number,
4747
+ refundAddress: z.string(),
4748
+ minPrice: numericString
4749
+ });
4745
4750
  z.object({
4746
4751
  srcAsset: asset,
4747
4752
  destAsset: asset,
@@ -4749,9 +4754,11 @@ var init_schemas = __esm({
4749
4754
  destChain: chain,
4750
4755
  destAddress: z.string(),
4751
4756
  amount: numericString,
4752
- ccmMetadata: ccmMetadataSchema.optional(),
4757
+ ccmMetadata: ccmParamsSchema.optional(),
4758
+ ccmParams: ccmParamsSchema.optional(),
4753
4759
  maxBoostFeeBps: z.number().optional(),
4754
- srcAddress: z.string().optional()
4760
+ srcAddress: z.string().optional(),
4761
+ fillOrKillParams: fillOrKillParams.optional()
4755
4762
  }).transform(({ amount, ...rest }) => ({
4756
4763
  ...rest,
4757
4764
  expectedDepositAmount: amount
@@ -4778,12 +4785,13 @@ async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork2) {
4778
4785
  },
4779
4786
  submitAddress(destChain, destAddress),
4780
4787
  swapRequest.commissionBps ?? 0,
4781
- swapRequest.ccmMetadata && {
4782
- ...swapRequest.ccmMetadata,
4788
+ swapRequest.ccmParams && {
4789
+ ...swapRequest.ccmParams,
4783
4790
  cfParameters: void 0
4784
4791
  },
4785
4792
  maxBoostFeeBps,
4786
- swapRequest.affiliates
4793
+ swapRequest.affiliates,
4794
+ swapRequest.fillOrKillParams
4787
4795
  ]);
4788
4796
  const response = await client.sendRequest("broker_requestSwapDepositAddress", ...params);
4789
4797
  return validateResponse(chainflipNetwork2, response);
@@ -4810,7 +4818,7 @@ var init_broker = __esm({
4810
4818
  btcAddress(network)
4811
4819
  ]),
4812
4820
  z.number(),
4813
- ccmMetadataSchema.merge(z.object({
4821
+ ccmParamsSchema.merge(z.object({
4814
4822
  cfParameters: z.union([
4815
4823
  hexString,
4816
4824
  z.string()
@@ -4821,7 +4829,12 @@ var init_broker = __esm({
4821
4829
  gas_budget: `0x${BigInt(rest.gasBudget).toString(16)}`
4822
4830
  })).optional(),
4823
4831
  z.number().optional(),
4824
- z.array(affiliateBroker).optional()
4832
+ z.array(affiliateBroker).optional(),
4833
+ fillOrKillParams.transform(({ retryDurationBlocks, refundAddress, minPrice }) => ({
4834
+ retry_duration: retryDurationBlocks,
4835
+ refund_address: refundAddress,
4836
+ min_price: `0x${BigInt(minPrice).toString(16)}`
4837
+ })).optional()
4825
4838
  ]).parse(params), "validateRequest");
4826
4839
  validateResponse = /* @__PURE__ */ __name((network, response) => z.object({
4827
4840
  address: z.union([
@@ -8560,7 +8573,7 @@ var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
8560
8573
  asset: params.destAsset
8561
8574
  });
8562
8575
  const { vaultContract: vault } = getVaultContract(params.srcChain, networkOpts);
8563
- const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmMetadata.message, params.ccmMetadata.gasBudget, "0x", {
8576
+ const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, "0x", {
8564
8577
  value: params.amount,
8565
8578
  ...extractOverrides(txOpts)
8566
8579
  });
@@ -8573,24 +8586,24 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
8573
8586
  const erc20Address = getErc20Address(srcAsset, networkOpts);
8574
8587
  const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultAddress, erc20Address, networkOpts.signer);
8575
8588
  assert(hasSufficientAllowance, "Swap amount exceeds allowance");
8576
- const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
8589
+ const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
8577
8590
  await transaction.wait(txOpts.wait);
8578
8591
  return transaction;
8579
8592
  }, "callToken");
8580
- var executeSwap = /* @__PURE__ */ __name(async ({ ccmMetadata: unvalidatedCcmMetadata, ...params }, networkOpts, txOpts) => {
8593
+ var executeSwap = /* @__PURE__ */ __name(async ({ ccmParams: unvalidatedCcmParams, ...params }, networkOpts, txOpts) => {
8581
8594
  assertIsValidSwap(params);
8582
8595
  assertIsEvmChain(params.srcChain);
8583
8596
  assertValidAddress(params.destChain, params.destAddress, networkOpts.network);
8584
8597
  await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
8585
- if (unvalidatedCcmMetadata) {
8598
+ if (unvalidatedCcmParams) {
8586
8599
  assertIsEvmChain(params.destChain);
8587
- const ccmMetadata = ccmMetadataSchema.parse(unvalidatedCcmMetadata);
8600
+ const ccmParams = ccmParamsSchema.parse(unvalidatedCcmParams);
8588
8601
  return params.srcAsset === chainConstants[params.srcChain].gasAsset ? callNative({
8589
8602
  ...params,
8590
- ccmMetadata
8603
+ ccmParams
8591
8604
  }, networkOpts, txOpts) : callToken({
8592
8605
  ...params,
8593
- ccmMetadata
8606
+ ccmParams
8594
8607
  }, networkOpts, txOpts);
8595
8608
  }
8596
8609
  return params.srcAsset === chainConstants[params.srcChain].gasAsset ? swapNative(params, networkOpts, txOpts) : swapToken(params, networkOpts, txOpts);
@@ -8653,6 +8666,14 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
8653
8666
 
8654
8667
  // src/swap/consts.ts
8655
8668
  init_enums();
8669
+
8670
+ // package.json
8671
+ var version = "1.5.0-alpha.0";
8672
+
8673
+ // src/swap/consts.ts
8674
+ var CF_SDK_VERSION_HEADERS = {
8675
+ "Cf-Sdk-Version": version
8676
+ };
8656
8677
  var BACKEND_SERVICE_URLS = {
8657
8678
  [exports.ChainflipNetworks.backspin]: "https://chainflip-swap-backspin.staging/",
8658
8679
  [exports.ChainflipNetworks.sisyphos]: "https://chainflip-swap.staging/",
@@ -8671,10 +8692,11 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
8671
8692
  brokerCommissionBps: String(brokerCommissionBps)
8672
8693
  }
8673
8694
  };
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
8695
+ const { data } = await axios__default.default.get("/quote", {
8696
+ baseURL: baseUrl,
8697
+ params,
8698
+ signal,
8699
+ headers: CF_SDK_VERSION_HEADERS
8678
8700
  });
8679
8701
  return {
8680
8702
  ...returnedRequestData,
@@ -8682,9 +8704,10 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
8682
8704
  };
8683
8705
  }, "getQuote");
8684
8706
  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
8707
+ const { data } = await axios__default.default.get(`/swaps/${id}`, {
8708
+ baseURL: baseUrl,
8709
+ signal,
8710
+ headers: CF_SDK_VERSION_HEADERS
8688
8711
  });
8689
8712
  return data;
8690
8713
  }, "getStatus");
@@ -8712,7 +8735,8 @@ var _SwapSDK = class _SwapSDK {
8712
8735
  transformer: esm_default,
8713
8736
  links: [
8714
8737
  httpBatchLink({
8715
- url: new URL("/trpc", this.options.backendUrl)
8738
+ url: new URL("/trpc", this.options.backendUrl),
8739
+ headers: CF_SDK_VERSION_HEADERS
8716
8740
  })
8717
8741
  ]
8718
8742
  });
@@ -8762,6 +8786,7 @@ var _SwapSDK = class _SwapSDK {
8762
8786
  chain: srcChain,
8763
8787
  asset: srcAsset
8764
8788
  }, BigInt(amount));
8789
+ depositAddressRequest.ccmParams ?? (depositAddressRequest.ccmParams = depositAddressRequest.ccmMetadata);
8765
8790
  let response;
8766
8791
  if (this.options.broker !== void 0) {
8767
8792
  const { requestSwapDepositAddress: requestSwapDepositAddress2 } = await Promise.resolve().then(() => (init_broker(), broker_exports));
@@ -8809,6 +8834,7 @@ var _SwapSDK = class _SwapSDK {
8809
8834
  chain: srcChain,
8810
8835
  asset: srcAsset
8811
8836
  }, BigInt(amount));
8837
+ params.ccmParams ?? (params.ccmParams = params.ccmMetadata);
8812
8838
  const tx = await executeSwap_default(params, {
8813
8839
  network: this.options.network,
8814
8840
  signer
@@ -8849,14 +8875,18 @@ var _SwapSDK = class _SwapSDK {
8849
8875
  const { ingressEgress: { channelOpeningFees } } = await this.getStateChainEnvironment();
8850
8876
  return channelOpeningFees;
8851
8877
  }
8852
- async getBoostLiquidity({ chainAsset, feeTierBps } = {}) {
8878
+ async getBoostLiquidity(params = {}) {
8853
8879
  let poolsDepth = await this.getBoostPoolsDepth();
8854
- if (chainAsset) {
8855
- const internalAsset = getInternalAsset(chainAsset);
8880
+ if ("chain" in params && "asset" in params) {
8881
+ const { chain: chain2, asset: asset2 } = params;
8882
+ const internalAsset = getInternalAsset({
8883
+ chain: chain2,
8884
+ asset: asset2
8885
+ });
8856
8886
  poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.asset === internalAsset).sort((a, b) => b.tier - a.tier);
8857
8887
  }
8858
- if (feeTierBps) {
8859
- poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === feeTierBps);
8888
+ if ("feeTierBps" in params && params.feeTierBps !== void 0) {
8889
+ poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === params.feeTierBps);
8860
8890
  }
8861
8891
  return poolsDepth.map((depth) => ({
8862
8892
  availableAmount: depth.availableAmount,
package/dist/swap.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getEnvironment, getSupportedAssets, getAllBoostPoolsDepth, getVaultContractAddress, approve, getTokenContractAddress, getEvmChainId, checkAllowance, extractOverrides, Vault__factory } from './chunk-M32JHS3U.mjs';
2
- import { assertValidAddress, ccmMetadataSchema, dotAddress } from './chunk-JHVSTX24.mjs';
2
+ import { assertValidAddress, ccmParamsSchema, dotAddress } from './chunk-7ENWS5RM.mjs';
3
3
  import { __name, ChainflipNetworks, __publicField, Chains, assetConstants, getInternalAsset, isNotNullish, assert, getAssetAndChain, readChainAssetValue, isTestnet, chainConstants, getInternalAssets } from './chunk-3V7QJANN.mjs';
4
4
  export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-3V7QJANN.mjs';
5
5
  import { bytesToHex } from '@chainflip/utils/bytes';
@@ -2262,7 +2262,7 @@ var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
2262
2262
  asset: params.destAsset
2263
2263
  });
2264
2264
  const { vaultContract: vault } = getVaultContract(params.srcChain, networkOpts);
2265
- const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmMetadata.message, params.ccmMetadata.gasBudget, "0x", {
2265
+ const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, "0x", {
2266
2266
  value: params.amount,
2267
2267
  ...extractOverrides(txOpts)
2268
2268
  });
@@ -2275,24 +2275,24 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
2275
2275
  const erc20Address = getErc20Address(srcAsset, networkOpts);
2276
2276
  const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultAddress, erc20Address, networkOpts.signer);
2277
2277
  assert(hasSufficientAllowance, "Swap amount exceeds allowance");
2278
- const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
2278
+ const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
2279
2279
  await transaction.wait(txOpts.wait);
2280
2280
  return transaction;
2281
2281
  }, "callToken");
2282
- var executeSwap = /* @__PURE__ */ __name(async ({ ccmMetadata: unvalidatedCcmMetadata, ...params }, networkOpts, txOpts) => {
2282
+ var executeSwap = /* @__PURE__ */ __name(async ({ ccmParams: unvalidatedCcmParams, ...params }, networkOpts, txOpts) => {
2283
2283
  assertIsValidSwap(params);
2284
2284
  assertIsEvmChain(params.srcChain);
2285
2285
  assertValidAddress(params.destChain, params.destAddress, networkOpts.network);
2286
2286
  await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
2287
- if (unvalidatedCcmMetadata) {
2287
+ if (unvalidatedCcmParams) {
2288
2288
  assertIsEvmChain(params.destChain);
2289
- const ccmMetadata = ccmMetadataSchema.parse(unvalidatedCcmMetadata);
2289
+ const ccmParams = ccmParamsSchema.parse(unvalidatedCcmParams);
2290
2290
  return params.srcAsset === chainConstants[params.srcChain].gasAsset ? callNative({
2291
2291
  ...params,
2292
- ccmMetadata
2292
+ ccmParams
2293
2293
  }, networkOpts, txOpts) : callToken({
2294
2294
  ...params,
2295
- ccmMetadata
2295
+ ccmParams
2296
2296
  }, networkOpts, txOpts);
2297
2297
  }
2298
2298
  return params.srcAsset === chainConstants[params.srcChain].gasAsset ? swapNative(params, networkOpts, txOpts) : swapToken(params, networkOpts, txOpts);
@@ -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.5.0-alpha.0";
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
  });
@@ -2458,9 +2467,10 @@ var _SwapSDK = class _SwapSDK {
2458
2467
  chain: srcChain,
2459
2468
  asset: srcAsset
2460
2469
  }, BigInt(amount));
2470
+ depositAddressRequest.ccmParams ?? (depositAddressRequest.ccmParams = depositAddressRequest.ccmMetadata);
2461
2471
  let response;
2462
2472
  if (this.options.broker !== void 0) {
2463
- const { requestSwapDepositAddress } = await import('./broker-PBJJVRH4.mjs');
2473
+ const { requestSwapDepositAddress } = await import('./broker-QFRN2UBT.mjs');
2464
2474
  const result = await requestSwapDepositAddress({
2465
2475
  ...depositAddressRequest,
2466
2476
  commissionBps: brokerCommissionBps ?? this.options.broker.commissionBps,
@@ -2505,6 +2515,7 @@ var _SwapSDK = class _SwapSDK {
2505
2515
  chain: srcChain,
2506
2516
  asset: srcAsset
2507
2517
  }, BigInt(amount));
2518
+ params.ccmParams ?? (params.ccmParams = params.ccmMetadata);
2508
2519
  const tx = await executeSwap_default(params, {
2509
2520
  network: this.options.network,
2510
2521
  signer
@@ -2545,14 +2556,18 @@ var _SwapSDK = class _SwapSDK {
2545
2556
  const { ingressEgress: { channelOpeningFees } } = await this.getStateChainEnvironment();
2546
2557
  return channelOpeningFees;
2547
2558
  }
2548
- async getBoostLiquidity({ chainAsset, feeTierBps } = {}) {
2559
+ async getBoostLiquidity(params = {}) {
2549
2560
  let poolsDepth = await this.getBoostPoolsDepth();
2550
- if (chainAsset) {
2551
- const internalAsset = getInternalAsset(chainAsset);
2561
+ if ("chain" in params && "asset" in params) {
2562
+ const { chain, asset } = params;
2563
+ const internalAsset = getInternalAsset({
2564
+ chain,
2565
+ asset
2566
+ });
2552
2567
  poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.asset === internalAsset).sort((a, b) => b.tier - a.tier);
2553
2568
  }
2554
- if (feeTierBps) {
2555
- poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === feeTierBps);
2569
+ if ("feeTierBps" in params && params.feeTierBps !== void 0) {
2570
+ poolsDepth = poolsDepth.filter((boostPoolDepth) => boostPoolDepth.tier === params.feeTierBps);
2556
2571
  }
2557
2572
  return poolsDepth.map((depth) => ({
2558
2573
  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.5.0-alpha.0",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {
@@ -44,10 +44,10 @@
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
- "tsup": "^8.1.0"
50
+ "tsup": "^8.2.4"
51
51
  },
52
52
  "scripts": {
53
53
  "test": "jest --forceExit",