@chainflip/sdk 1.11.1 → 2.0.0-beta.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.cts CHANGED
@@ -1,24 +1,161 @@
1
- import { AssetAndChain, UncheckedAssetAndChain, ChainflipChain, ChainflipAsset, AssetOfChain, AssetSymbol, ChainflipNetwork, ChainAssetMap, ChainMap } from '@chainflip/utils/chainflip';
2
- export { AssetSymbol as Asset, ChainflipChain as Chain, ChainflipAsset as ChainflipId, ChainflipNetwork, UncheckedAssetAndChain, getInternalAsset as getChainflipId } from '@chainflip/utils/chainflip';
1
+ import * as _chainflip_utils_chainflip from '@chainflip/utils/chainflip';
2
+ import { ChainflipNetwork, AssetAndChain, UncheckedAssetAndChain, ChainflipChain, ChainflipAsset, AssetOfChain, AssetSymbol, ChainAssetMap, ChainMap } from '@chainflip/utils/chainflip';
3
+ export { AssetSymbol as Asset, ChainflipNetwork, UncheckedAssetAndChain, getInternalAsset as getChainflipId } from '@chainflip/utils/chainflip';
3
4
  import { HexString } from '@chainflip/utils/types';
4
5
  import { z } from 'zod';
5
6
 
7
+ type AccountCreationDepositChannelParams = z.input<ReturnType<typeof getAccountCreationDepositChannelSchema>>;
8
+ declare const getAccountCreationDepositChannelSchema: (network: ChainflipNetwork) => z.ZodEffects<z.ZodObject<{
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>;
13
+ sigType: z.ZodLiteral<"Eip712">;
14
+ }, "strip", z.ZodTypeAny, {
15
+ signer: `0x${string}`;
16
+ signature: `0x${string}`;
17
+ sigType: "Eip712";
18
+ }, {
19
+ signer: string;
20
+ signature: string;
21
+ sigType: "Eip712";
22
+ }>, {
23
+ signer: `0x${string}`;
24
+ signature: `0x${string}`;
25
+ sig_type: "Eip712";
26
+ }, {
27
+ signer: string;
28
+ signature: string;
29
+ sigType: "Eip712";
30
+ }>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ Ethereum: {
33
+ signer: `0x${string}`;
34
+ signature: `0x${string}`;
35
+ sig_type: "Eip712";
36
+ };
37
+ }, {
38
+ Ethereum: {
39
+ signer: string;
40
+ signature: string;
41
+ sigType: "Eip712";
42
+ };
43
+ }>;
44
+ transactionMetadata: z.ZodEffects<z.ZodObject<{
45
+ nonce: z.ZodNumber;
46
+ expiryBlock: z.ZodNumber;
47
+ }, "strip", z.ZodTypeAny, {
48
+ expiryBlock: number;
49
+ nonce: number;
50
+ }, {
51
+ expiryBlock: number;
52
+ nonce: number;
53
+ }>, {
54
+ nonce: number;
55
+ expiry_block: number;
56
+ }, {
57
+ expiryBlock: number;
58
+ nonce: number;
59
+ }>;
60
+ asset: z.ZodEffects<z.ZodObject<{
61
+ asset: z.ZodString;
62
+ chain: z.ZodString;
63
+ }, "strip", z.ZodTypeAny, {
64
+ asset: string;
65
+ chain: string;
66
+ }, {
67
+ asset: string;
68
+ chain: string;
69
+ }>, _chainflip_utils_chainflip.AssetAndChain, {
70
+ asset: string;
71
+ chain: string;
72
+ }>;
73
+ refundAddress: z.ZodString;
74
+ boostFeeBps: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ asset: _chainflip_utils_chainflip.AssetAndChain;
77
+ refundAddress: string;
78
+ signatureData: {
79
+ Ethereum: {
80
+ signer: `0x${string}`;
81
+ signature: `0x${string}`;
82
+ sig_type: "Eip712";
83
+ };
84
+ };
85
+ transactionMetadata: {
86
+ nonce: number;
87
+ expiry_block: number;
88
+ };
89
+ boostFeeBps: number;
90
+ }, {
91
+ asset: {
92
+ asset: string;
93
+ chain: string;
94
+ };
95
+ refundAddress: string;
96
+ signatureData: {
97
+ Ethereum: {
98
+ signer: string;
99
+ signature: string;
100
+ sigType: "Eip712";
101
+ };
102
+ };
103
+ transactionMetadata: {
104
+ expiryBlock: number;
105
+ nonce: number;
106
+ };
107
+ boostFeeBps?: number | undefined;
108
+ }>, {
109
+ asset: _chainflip_utils_chainflip.AssetAndChain;
110
+ refundAddress: string;
111
+ signatureData: {
112
+ Ethereum: {
113
+ signer: `0x${string}`;
114
+ signature: `0x${string}`;
115
+ sig_type: "Eip712";
116
+ };
117
+ };
118
+ transactionMetadata: {
119
+ nonce: number;
120
+ expiry_block: number;
121
+ };
122
+ boostFeeBps: number;
123
+ }, {
124
+ asset: {
125
+ asset: string;
126
+ chain: string;
127
+ };
128
+ refundAddress: string;
129
+ signatureData: {
130
+ Ethereum: {
131
+ signer: string;
132
+ signature: string;
133
+ sigType: "Eip712";
134
+ };
135
+ };
136
+ transactionMetadata: {
137
+ expiryBlock: number;
138
+ nonce: number;
139
+ };
140
+ boostFeeBps?: number | undefined;
141
+ }>;
142
+
6
143
  declare const ccmParamsSchema: z.ZodEffects<z.ZodObject<{
7
144
  gasBudget: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, `0x${string}`, string>]>, `0x${string}`, string>;
8
145
  message: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
9
146
  ccmAdditionalData: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>>;
10
- /** @deprecated DEPRECATED(1.10) pass additionalData instead */
11
- cfParameters: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>>;
147
+ /** @deprecated DEPRECATED(1.12) pass additionalData instead */
148
+ cfParameters: z.ZodOptional<z.ZodNever>;
12
149
  }, "strip", z.ZodTypeAny, {
13
150
  message: `0x${string}`;
14
151
  gasBudget: `0x${string}`;
15
152
  ccmAdditionalData?: `0x${string}` | undefined;
16
- cfParameters?: `0x${string}` | undefined;
153
+ cfParameters?: undefined;
17
154
  }, {
18
155
  message: string;
19
156
  gasBudget: string;
20
157
  ccmAdditionalData?: string | undefined;
21
- cfParameters?: string | undefined;
158
+ cfParameters?: undefined;
22
159
  }>, {
23
160
  gasBudget: `0x${string}`;
24
161
  message: `0x${string}`;
@@ -27,12 +164,9 @@ declare const ccmParamsSchema: z.ZodEffects<z.ZodObject<{
27
164
  message: string;
28
165
  gasBudget: string;
29
166
  ccmAdditionalData?: string | undefined;
30
- cfParameters?: string | undefined;
167
+ cfParameters?: undefined;
31
168
  }>;
32
- type CcmParams = Omit<z.input<typeof ccmParamsSchema>, 'cfParameters'> & {
33
- /** @deprecated DEPRECATED(1.10) pass additionalData instead */
34
- cfParameters?: string;
35
- };
169
+ type CcmParams = Omit<z.input<typeof ccmParamsSchema>, 'cfParameters'>;
36
170
  declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
37
171
  account: z.ZodEffects<z.ZodString, string, string>;
38
172
  commissionBps: z.ZodNumber;
@@ -66,22 +200,22 @@ declare const fillOrKillParams: z.ZodObject<{
66
200
  refundAddress: z.ZodString;
67
201
  minPriceX128: z.ZodString;
68
202
  maxOraclePriceSlippage: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodNumber>>, number | null, number | null | undefined>;
69
- refundCcmMetadata: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodObject<{
203
+ refundCcmMetadata: z.ZodDefault<z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodObject<{
70
204
  gasBudget: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, `0x${string}`, string>]>, `0x${string}`, string>;
71
205
  message: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
72
206
  ccmAdditionalData: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>>;
73
- /** @deprecated DEPRECATED(1.10) pass additionalData instead */
74
- cfParameters: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>>;
207
+ /** @deprecated DEPRECATED(1.12) pass additionalData instead */
208
+ cfParameters: z.ZodOptional<z.ZodNever>;
75
209
  }, "strip", z.ZodTypeAny, {
76
210
  message: `0x${string}`;
77
211
  gasBudget: `0x${string}`;
78
212
  ccmAdditionalData?: `0x${string}` | undefined;
79
- cfParameters?: `0x${string}` | undefined;
213
+ cfParameters?: undefined;
80
214
  }, {
81
215
  message: string;
82
216
  gasBudget: string;
83
217
  ccmAdditionalData?: string | undefined;
84
- cfParameters?: string | undefined;
218
+ cfParameters?: undefined;
85
219
  }>, {
86
220
  gasBudget: `0x${string}`;
87
221
  message: `0x${string}`;
@@ -90,25 +224,14 @@ declare const fillOrKillParams: z.ZodObject<{
90
224
  message: string;
91
225
  gasBudget: string;
92
226
  ccmAdditionalData?: string | undefined;
93
- cfParameters?: string | undefined;
94
- }>>>>>, {
95
- cfParameters: `0x${string}`;
96
- gasBudget: `0x${string}`;
97
- message: `0x${string}`;
98
- ccmAdditionalData: `0x${string}`;
99
- } | null, {
100
- message: string;
101
- gasBudget: string;
102
- ccmAdditionalData?: string | undefined;
103
- cfParameters?: string | undefined;
104
- } | null | undefined>;
227
+ cfParameters?: undefined;
228
+ }>>>>>;
105
229
  }, "strip", z.ZodTypeAny, {
106
230
  retryDurationBlocks: number;
107
231
  refundAddress: string;
108
232
  minPriceX128: string;
109
233
  maxOraclePriceSlippage: number | null;
110
234
  refundCcmMetadata: {
111
- cfParameters: `0x${string}`;
112
235
  gasBudget: `0x${string}`;
113
236
  message: `0x${string}`;
114
237
  ccmAdditionalData: `0x${string}`;
@@ -122,7 +245,7 @@ declare const fillOrKillParams: z.ZodObject<{
122
245
  message: string;
123
246
  gasBudget: string;
124
247
  ccmAdditionalData?: string | undefined;
125
- cfParameters?: string | undefined;
248
+ cfParameters?: undefined;
126
249
  } | null | undefined;
127
250
  }>;
128
251
  type FillOrKillParamsX128 = z.input<typeof fillOrKillParams>;
@@ -137,8 +260,12 @@ type SwapFee = Fee<'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER' | 'BOOST' | 'REFU
137
260
  type PoolFee = Fee<'LIQUIDITY'>;
138
261
  type PaidFee = SwapFee | PoolFee;
139
262
  type PoolInfo = {
140
- baseAsset: AssetAndChain;
141
- quoteAsset: AssetAndChain;
263
+ baseAsset: Exclude<AssetAndChain, {
264
+ chain: 'Polkadot';
265
+ }>;
266
+ quoteAsset: Exclude<AssetAndChain, {
267
+ chain: 'Polkadot';
268
+ }>;
142
269
  fee: Omit<PoolFee, 'type'>;
143
270
  };
144
271
  type BoostedQuoteDetails = {
@@ -146,8 +273,12 @@ type BoostedQuoteDetails = {
146
273
  maxBoostFeeBps: number;
147
274
  };
148
275
  interface BaseQuoteDetails {
149
- srcAsset: AssetAndChain;
150
- destAsset: AssetAndChain;
276
+ srcAsset: Exclude<AssetAndChain, {
277
+ chain: 'Polkadot';
278
+ }>;
279
+ destAsset: Exclude<AssetAndChain, {
280
+ chain: 'Polkadot';
281
+ }>;
151
282
  isVaultSwap: boolean;
152
283
  isOnChain: boolean;
153
284
  ccmParams?: {
@@ -185,22 +316,6 @@ type Quote = RegularQuote | DCAQuote;
185
316
  type DCABoostQuote = NonNullable<DCAQuote['boostQuote']>;
186
317
  type RegularBoostQuote = NonNullable<RegularQuote['boostQuote']>;
187
318
  type BoostQuote = RegularBoostQuote | DCABoostQuote;
188
- type FillOrKillParamsWithoutRefundAddress = {
189
- livePriceSlippageTolerancePercent?: string | number | false;
190
- refundCcmMetadata?: CcmParams | null;
191
- } & ({
192
- minPrice: string;
193
- retryDurationBlocks: number;
194
- } | {
195
- minPrice: string;
196
- retryDurationMinutes: number;
197
- } | {
198
- slippageTolerancePercent: string | number;
199
- retryDurationBlocks: number;
200
- } | {
201
- slippageTolerancePercent: string | number;
202
- retryDurationMinutes: number;
203
- });
204
319
  type FillOrKillParams = {
205
320
  livePriceSlippageTolerancePercent?: string | number | false;
206
321
  refundAddress: string;
@@ -306,13 +421,6 @@ interface DepositChannelFields {
306
421
  expectedDepositAmount: string | undefined;
307
422
  isExpired: boolean;
308
423
  openedThroughBackend: boolean;
309
- /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['brokers'] instead */
310
- brokerCommissionBps: number;
311
- /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['brokers'] instead */
312
- affiliateBrokers: AffiliateBroker[];
313
- /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['fillOrKillParams'] instead */
314
- fillOrKillParams: FillOrKillParamsWithMinPrice | undefined;
315
- /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['dcaParams'] instead */
316
424
  dcaParams: DcaParams | undefined;
317
425
  }
318
426
  interface DepositFields {
@@ -538,8 +646,8 @@ type SwapSDKOptions = {
538
646
  backendUrl?: string;
539
647
  broker?: {
540
648
  url: string;
541
- /** @deprecated DEPRECATED(1.10) set the brokerCommissionBps param of the requestDepositAddress and encodeVaultSwapData method instead */
542
- commissionBps?: number;
649
+ /** @deprecated DEPRECATED(1.12) set the brokerCommissionBps param of the requestDepositAddress and encodeVaultSwapData method instead */
650
+ commissionBps?: never;
543
651
  };
544
652
  rpcUrl?: string;
545
653
  enabledFeatures?: {
@@ -579,24 +687,24 @@ declare class SwapSDK {
579
687
  requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps: brokerCommissionBpsParam, }: DepositAddressRequestV2): Promise<DepositAddressResponseV2>;
580
688
  encodeVaultSwapData({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps: brokerCommissionBpsParam, extraParams, }: VaultSwapRequest): Promise<VaultSwapResponse>;
581
689
  encodeCfParameters({ quote, srcAddress, destAddress, fillOrKillParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps, }: EncodeCfParametersRequest): Promise<HexString>;
582
- /** @deprecated DEPRECATED(1.11) removing this method as it appears to not be used */
583
- getOnChainSwapExtrinsicArgs({ quote, fillOrKillParams, }: {
584
- quote: Quote;
585
- fillOrKillParams: FillOrKillParamsWithoutRefundAddress;
586
- }): [
587
- amount: string,
588
- inputAsset: ChainflipAsset,
589
- outputAsset: ChainflipAsset,
590
- retryDuration: number,
591
- minPrice: string,
592
- dcaParams: {
593
- number_of_chunks: number;
594
- chunk_interval: number;
595
- } | null
596
- ];
597
690
  checkBoostEnabled(): Promise<boolean>;
691
+ requestAccountCreationDepositAddress(asset: ChainflipAsset, refundAddress: string, signatureData: AccountCreationDepositChannelParams['signatureData'], transactionMetadata: AccountCreationDepositChannelParams['transactionMetadata'], boostFeeBps?: number): Promise<{
692
+ depositAddress: string;
693
+ brokerCommissionBps: number;
694
+ id: string;
695
+ maxBoostFeeBps: number;
696
+ issuedBlock: number;
697
+ srcChainExpiryBlock: string;
698
+ channelOpeningFee: string;
699
+ estimatedExpiryTime?: number | undefined;
700
+ }>;
598
701
  }
599
702
 
703
+ /**
704
+ * This file provides backwards compatibility for exports from before we started
705
+ * moving common stuff to the toolkit
706
+ */
707
+
600
708
  declare const ChainflipNetworks: {
601
709
  mainnet: "mainnet";
602
710
  backspin: "backspin";
@@ -633,5 +741,7 @@ declare const Assets: {
633
741
  BTC: "BTC";
634
742
  SOL: "SOL";
635
743
  };
744
+ type Chain = Exclude<ChainflipChain, 'Polkadot'>;
745
+ type InternalAsset = Exclude<ChainflipAsset, 'Dot'>;
636
746
 
637
- export { type AssetData, Assets, type BoostPoolDepth, type BoostQuote, type ChainData, 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 };
747
+ 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 };