@chainflip/sdk 2.3.2 → 2.3.4-dev.1

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.cts CHANGED
@@ -5,238 +5,95 @@ import { HexString } from '@chainflip/utils/types';
5
5
  import { z } from 'zod';
6
6
 
7
7
  type AccountCreationDepositChannelParams = z.input<ReturnType<typeof getAccountCreationDepositChannelSchema>>;
8
- declare const getAccountCreationDepositChannelSchema: (network: ChainflipNetwork) => z.ZodEffects<z.ZodObject<{
8
+ declare const getAccountCreationDepositChannelSchema: (network: ChainflipNetwork) => z.ZodObject<{
9
9
  signatureData: z.ZodObject<{
10
- Ethereum: z.ZodEffects<z.ZodObject<{
11
- signature: z.ZodEffects<z.ZodString, `0x${string}`, string>;
12
- signer: z.ZodEffects<z.ZodString, `0x${string}`, string>;
10
+ Ethereum: z.ZodPipe<z.ZodObject<{
11
+ signature: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
12
+ signer: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
13
13
  sigType: z.ZodLiteral<"Eip712">;
14
- }, "strip", z.ZodTypeAny, {
15
- signature: `0x${string}`;
16
- signer: `0x${string}`;
17
- sigType: "Eip712";
18
- }, {
19
- signature: string;
20
- signer: string;
21
- sigType: "Eip712";
22
- }>, {
14
+ }, z.core.$strip>, z.ZodTransform<{
23
15
  signature: `0x${string}`;
24
16
  signer: `0x${string}`;
25
17
  sig_type: "Eip712";
26
18
  }, {
27
- signature: string;
28
- signer: string;
29
- sigType: "Eip712";
30
- }>;
31
- }, "strip", z.ZodTypeAny, {
32
- Ethereum: {
33
19
  signature: `0x${string}`;
34
20
  signer: `0x${string}`;
35
- sig_type: "Eip712";
36
- };
37
- }, {
38
- Ethereum: {
39
- signature: string;
40
- signer: string;
41
21
  sigType: "Eip712";
42
- };
43
- }>;
44
- transactionMetadata: z.ZodEffects<z.ZodObject<{
22
+ }>>;
23
+ }, z.core.$strip>;
24
+ transactionMetadata: z.ZodPipe<z.ZodObject<{
45
25
  nonce: z.ZodNumber;
46
26
  expiryBlock: z.ZodNumber;
47
- }, "strip", z.ZodTypeAny, {
48
- nonce: number;
49
- expiryBlock: number;
50
- }, {
51
- nonce: number;
52
- expiryBlock: number;
53
- }>, {
27
+ }, z.core.$strip>, z.ZodTransform<{
54
28
  nonce: number;
55
29
  expiry_block: number;
56
30
  }, {
57
31
  nonce: number;
58
32
  expiryBlock: number;
59
- }>;
60
- asset: z.ZodEffects<z.ZodObject<{
33
+ }>>;
34
+ asset: z.ZodObject<{
61
35
  asset: z.ZodString;
62
36
  chain: z.ZodString;
63
- }, "strip", z.ZodTypeAny, {
64
- asset: string;
65
- chain: string;
66
- }, {
37
+ }, z.core.$strip> & z.ZodType<_chainflip_utils_chainflip.AssetAndChain, {
67
38
  asset: string;
68
39
  chain: string;
69
- }>, _chainflip_utils_chainflip.AssetAndChain, {
40
+ }, z.core.$ZodTypeInternals<_chainflip_utils_chainflip.AssetAndChain, {
70
41
  asset: string;
71
42
  chain: string;
72
- }>;
43
+ }>>;
73
44
  refundAddress: z.ZodString;
74
45
  boostFeeBps: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
75
- }, "strip", z.ZodTypeAny, {
76
- asset: _chainflip_utils_chainflip.AssetAndChain;
77
- signatureData: {
78
- Ethereum: {
79
- signature: `0x${string}`;
80
- signer: `0x${string}`;
81
- sig_type: "Eip712";
82
- };
83
- };
84
- transactionMetadata: {
85
- nonce: number;
86
- expiry_block: number;
87
- };
88
- refundAddress: string;
89
- boostFeeBps: number;
90
- }, {
91
- asset: {
92
- asset: string;
93
- chain: string;
94
- };
95
- signatureData: {
96
- Ethereum: {
97
- signature: string;
98
- signer: string;
99
- sigType: "Eip712";
100
- };
101
- };
102
- transactionMetadata: {
103
- nonce: number;
104
- expiryBlock: number;
105
- };
106
- refundAddress: string;
107
- boostFeeBps?: number | undefined;
108
- }>, {
109
- asset: _chainflip_utils_chainflip.AssetAndChain;
110
- signatureData: {
111
- Ethereum: {
112
- signature: `0x${string}`;
113
- signer: `0x${string}`;
114
- sig_type: "Eip712";
115
- };
116
- };
117
- transactionMetadata: {
118
- nonce: number;
119
- expiry_block: number;
120
- };
121
- refundAddress: string;
122
- boostFeeBps: number;
123
- }, {
124
- asset: {
125
- asset: string;
126
- chain: string;
127
- };
128
- signatureData: {
129
- Ethereum: {
130
- signature: string;
131
- signer: string;
132
- sigType: "Eip712";
133
- };
134
- };
135
- transactionMetadata: {
136
- nonce: number;
137
- expiryBlock: number;
138
- };
139
- refundAddress: string;
140
- boostFeeBps?: number | undefined;
141
- }>;
46
+ }, z.core.$strip>;
142
47
 
143
- declare const ccmParamsSchema: z.ZodEffects<z.ZodObject<{
144
- gasBudget: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, `0x${string}`, string>]>, bigint, string>, bigint, string>, `0x${string}`, string>;
145
- message: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
146
- ccmAdditionalData: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>>;
147
- }, "strip", z.ZodTypeAny, {
148
- message: `0x${string}`;
149
- gasBudget: `0x${string}`;
150
- ccmAdditionalData?: `0x${string}` | undefined;
151
- }, {
152
- message: string;
153
- gasBudget: string;
154
- ccmAdditionalData?: string | undefined;
155
- }>, {
48
+ declare const ccmParamsSchema: z.ZodPipe<z.ZodObject<{
49
+ gasBudget: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>]>, z.ZodTransform<bigint, string>>, z.ZodTransform<`0x${string}`, bigint>>;
50
+ message: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
51
+ ccmAdditionalData: z.ZodOptional<z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>>;
52
+ }, z.core.$strip>, z.ZodTransform<{
156
53
  gasBudget: `0x${string}`;
157
54
  message: `0x${string}`;
158
55
  ccmAdditionalData: `0x${string}`;
159
56
  }, {
160
- message: string;
161
- gasBudget: string;
162
- ccmAdditionalData?: string | undefined;
163
- }>;
57
+ gasBudget: `0x${string}`;
58
+ message: `0x${string}`;
59
+ ccmAdditionalData?: `0x${string}` | undefined;
60
+ }>>;
164
61
  type CcmParams = z.input<typeof ccmParamsSchema>;
165
- declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
166
- account: z.ZodEffects<z.ZodString, string, string>;
62
+ declare const affiliateBroker: z.ZodPipe<z.ZodObject<{
63
+ account: z.ZodString;
167
64
  commissionBps: z.ZodNumber;
168
- }, "strip", z.ZodTypeAny, {
169
- account: string;
170
- commissionBps: number;
171
- }, {
172
- account: string;
173
- commissionBps: number;
174
- }>, {
65
+ }, z.core.$strip>, z.ZodTransform<{
175
66
  account: string;
176
67
  bps: number;
177
68
  }, {
178
69
  account: string;
179
70
  commissionBps: number;
180
- }>;
71
+ }>>;
181
72
  type AffiliateBroker = z.input<typeof affiliateBroker>;
182
73
  declare const dcaParams: z.ZodObject<{
183
74
  numberOfChunks: z.ZodNumber;
184
75
  chunkIntervalBlocks: z.ZodNumber;
185
- }, "strip", z.ZodTypeAny, {
186
- numberOfChunks: number;
187
- chunkIntervalBlocks: number;
188
- }, {
189
- numberOfChunks: number;
190
- chunkIntervalBlocks: number;
191
- }>;
76
+ }, z.core.$strip>;
192
77
  type DcaParams = z.input<typeof dcaParams>;
193
78
  declare const fillOrKillParams: z.ZodObject<{
194
79
  retryDurationBlocks: z.ZodNumber;
195
80
  refundAddress: z.ZodString;
196
81
  minPriceX128: z.ZodString;
197
- maxOraclePriceSlippage: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, number | null, number | null | undefined>;
198
- refundCcmMetadata: z.ZodDefault<z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodObject<{
199
- gasBudget: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, `0x${string}`, string>]>, bigint, string>, bigint, string>, `0x${string}`, string>;
200
- message: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
201
- ccmAdditionalData: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>>;
202
- }, "strip", z.ZodTypeAny, {
203
- message: `0x${string}`;
204
- gasBudget: `0x${string}`;
205
- ccmAdditionalData?: `0x${string}` | undefined;
206
- }, {
207
- message: string;
208
- gasBudget: string;
209
- ccmAdditionalData?: string | undefined;
210
- }>, {
82
+ maxOraclePriceSlippage: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, z.ZodTransform<number | null, number | null | undefined>>;
83
+ refundCcmMetadata: z.ZodDefault<z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodObject<{
84
+ gasBudget: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>]>, z.ZodTransform<bigint, string>>, z.ZodTransform<`0x${string}`, bigint>>;
85
+ message: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
86
+ ccmAdditionalData: z.ZodOptional<z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>>;
87
+ }, z.core.$strip>, z.ZodTransform<{
211
88
  gasBudget: `0x${string}`;
212
89
  message: `0x${string}`;
213
90
  ccmAdditionalData: `0x${string}`;
214
91
  }, {
215
- message: string;
216
- gasBudget: string;
217
- ccmAdditionalData?: string | undefined;
218
- }>>>>>;
219
- }, "strip", z.ZodTypeAny, {
220
- refundAddress: string;
221
- retryDurationBlocks: number;
222
- minPriceX128: string;
223
- maxOraclePriceSlippage: number | null;
224
- refundCcmMetadata: {
225
92
  gasBudget: `0x${string}`;
226
93
  message: `0x${string}`;
227
- ccmAdditionalData: `0x${string}`;
228
- } | null;
229
- }, {
230
- refundAddress: string;
231
- retryDurationBlocks: number;
232
- minPriceX128: string;
233
- maxOraclePriceSlippage?: number | null | undefined;
234
- refundCcmMetadata?: {
235
- message: string;
236
- gasBudget: string;
237
- ccmAdditionalData?: string | undefined;
238
- } | null | undefined;
239
- }>;
94
+ ccmAdditionalData?: `0x${string}` | undefined;
95
+ }>>>>>>;
96
+ }, z.core.$strip>;
240
97
  type FillOrKillParamsX128 = z.input<typeof fillOrKillParams>;
241
98
  type FillOrKillParamsWithMinPrice = Omit<FillOrKillParamsX128, 'minPriceX128'> & {
242
99
  minPrice: string;
@@ -589,6 +446,10 @@ interface VaultSwapRequest {
589
446
  commissionBps: number;
590
447
  }[];
591
448
  ccmParams?: CcmParams;
449
+ /**
450
+ * @deprecated DEPRECATED(2.3): Initialize the SDK with `broker: { url }` for your own broker instead.
451
+ * When the SDK is initialized with a broker, that broker takes precedence here.
452
+ */
592
453
  brokerAccount?: `cF${string}`;
593
454
  brokerCommissionBps?: number;
594
455
  extraParams?: {
@@ -632,6 +493,10 @@ interface EncodeCfParametersRequest {
632
493
  commissionBps: number;
633
494
  }[];
634
495
  ccmParams?: CcmParams;
496
+ /**
497
+ * @deprecated DEPRECATED(2.3): Initialize the SDK with `broker: { url }` for your own broker instead.
498
+ * When the SDK is initialized with a broker, that broker takes precedence here.
499
+ */
635
500
  brokerAccount?: `cF${string}`;
636
501
  brokerCommissionBps?: number;
637
502
  }
@@ -640,12 +505,19 @@ type RequestOptions = {
640
505
  signal?: AbortSignal;
641
506
  };
642
507
 
508
+ declare const BrokerName: {
509
+ readonly ChainflipSwap: "swap.chainflip.io";
510
+ };
511
+ type BrokerName = (typeof BrokerName)[keyof typeof BrokerName];
512
+ type BrokerOption = {
513
+ url: string;
514
+ } | {
515
+ name: BrokerName;
516
+ };
643
517
  type SwapSDKOptions = {
644
518
  network?: ChainflipNetwork;
645
519
  backendUrl?: string;
646
- broker?: {
647
- url: string;
648
- };
520
+ broker?: BrokerOption;
649
521
  rpcUrl?: string;
650
522
  enabledFeatures?: {
651
523
  dcaV2?: boolean;
@@ -660,7 +532,6 @@ type AssetState = 'all' | 'deposit' | 'destination' | 'depositChannel' | 'vaultS
660
532
  declare class SwapSDK {
661
533
  private readonly options;
662
534
  private readonly rpcConfig;
663
- private readonly apiClient;
664
535
  private cache;
665
536
  private dcaV2Enabled;
666
537
  constructor(options?: SwapSDKOptions);
@@ -670,8 +541,12 @@ declare class SwapSDK {
670
541
  private getBtcSupplyPoolDepth;
671
542
  private getBoostPoolsDepth;
672
543
  getAssets(chain?: ChainflipChain, type?: AssetState): Promise<AssetData[]>;
673
- protected shouldTakeCommission(): boolean;
544
+ private resolveBroker;
545
+ private requireBroker;
546
+ private resolveEncodingBroker;
547
+ private estimateExpiryTime;
674
548
  private getCommissionBps;
549
+ private getQuotedBrokerCommissionBps;
675
550
  getQuoteV2(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponseV2>;
676
551
  getStatusV2(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponseV2>;
677
552
  private validateSwapAmount;
@@ -688,14 +563,14 @@ declare class SwapSDK {
688
563
  /** @deprecated DEPRECATED(2.2): Only value supported moving forward is 5 bps */
689
564
  feeTierBps?: number;
690
565
  } & UncheckedAssetAndChain)): Promise<BoostPoolDepth[]>;
691
- requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps: brokerCommissionBpsParam, }: DepositAddressRequestV2): Promise<DepositAddressResponseV2>;
692
- encodeVaultSwapData({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps: brokerCommissionBpsParam, extraParams, }: VaultSwapRequest): Promise<VaultSwapResponse>;
566
+ requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps, }: DepositAddressRequestV2): Promise<DepositAddressResponseV2>;
567
+ encodeVaultSwapData({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps, extraParams, }: VaultSwapRequest): Promise<VaultSwapResponse>;
693
568
  encodeCfParameters({ quote, srcAddress, destAddress, fillOrKillParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps, }: EncodeCfParametersRequest): Promise<HexString>;
694
569
  checkBoostEnabled(): Promise<boolean>;
695
570
  requestAccountCreationDepositAddress(asset: ChainflipAsset, refundAddress: string, signatureData: AccountCreationDepositChannelParams['signatureData'], transactionMetadata: AccountCreationDepositChannelParams['transactionMetadata'], boostFeeBps?: number): Promise<{
571
+ id: string;
696
572
  depositAddress: string;
697
573
  brokerCommissionBps: number;
698
- id: string;
699
574
  maxBoostFeeBps: number;
700
575
  issuedBlock: number;
701
576
  srcChainExpiryBlock: string;
@@ -762,4 +637,4 @@ declare const Assets: {
762
637
  type Chain = ChainflipChain;
763
638
  type InternalAsset = ChainflipAsset;
764
639
 
765
- export { type AssetData, Assets, type BoostPoolDepth, type BoostQuote, type Chain, type ChainData, type InternalAsset as ChainflipId, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, type ChainsAndAssets, type DCABoostQuote, type DCAQuote, type DepositAddressRequestV2, type DepositAddressResponseV2, type EncodeCfParametersRequest, type FillOrKillParamsWithSlippage, type Quote, type QuoteRequest, type QuoteResponseV2, type RegularQuote, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponseV2, type VaultSwapRequest, type VaultSwapResponse };
640
+ export { type AssetData, Assets, type BoostPoolDepth, type BoostQuote, BrokerName, type BrokerOption, type Chain, type ChainData, type InternalAsset as ChainflipId, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, type ChainsAndAssets, type DCABoostQuote, type DCAQuote, type DepositAddressRequestV2, type DepositAddressResponseV2, type EncodeCfParametersRequest, type FillOrKillParamsWithSlippage, type Quote, type QuoteRequest, type QuoteResponseV2, type RegularQuote, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponseV2, type VaultSwapRequest, type VaultSwapResponse };