@chainflip/sdk 1.9.5 → 1.10.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.ts CHANGED
@@ -1,16 +1,13 @@
1
- import * as _chainflip_utils_chainflip from '@chainflip/utils/chainflip';
2
1
  import { AssetAndChain, UncheckedAssetAndChain, ChainflipChain, ChainflipAsset, AssetOfChain, AssetSymbol, ChainflipNetwork, ChainAssetMap, ChainMap } from '@chainflip/utils/chainflip';
3
2
  export { AssetSymbol as Asset, ChainflipChain as Chain, ChainflipAsset as ChainflipId, ChainflipNetwork, UncheckedAssetAndChain, getInternalAsset as getChainflipId } from '@chainflip/utils/chainflip';
4
- import * as _trpc_server from '@trpc/server';
5
- import { inferRouterOutputs } from '@trpc/server';
3
+ import { HexString } from '@chainflip/utils/types';
6
4
  import { z } from 'zod';
7
- import superjson from 'superjson';
8
5
 
9
6
  declare const ccmParamsSchema: z.ZodEffects<z.ZodObject<{
10
7
  gasBudget: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, `0x${string}`, string>]>, `0x${string}`, string>;
11
8
  message: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
12
9
  ccmAdditionalData: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>>;
13
- /** @deprecated DEPRECATED(1.8) pass additionalData instead */
10
+ /** @deprecated DEPRECATED(1.10) pass additionalData instead */
14
11
  cfParameters: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>>;
15
12
  }, "strip", z.ZodTypeAny, {
16
13
  message: `0x${string}`;
@@ -25,7 +22,7 @@ declare const ccmParamsSchema: z.ZodEffects<z.ZodObject<{
25
22
  }>, {
26
23
  gasBudget: `0x${string}`;
27
24
  message: `0x${string}`;
28
- ccmAdditionalData: `0x${string}` | undefined;
25
+ ccmAdditionalData: `0x${string}`;
29
26
  }, {
30
27
  message: string;
31
28
  gasBudget: string;
@@ -33,7 +30,7 @@ declare const ccmParamsSchema: z.ZodEffects<z.ZodObject<{
33
30
  cfParameters?: string | undefined;
34
31
  }>;
35
32
  type CcmParams = Omit<z.input<typeof ccmParamsSchema>, 'cfParameters'> & {
36
- /** @deprecated DEPRECATED(1.8) pass additionalData instead */
33
+ /** @deprecated DEPRECATED(1.10) pass additionalData instead */
37
34
  cfParameters?: string;
38
35
  };
39
36
  declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
@@ -120,6 +117,7 @@ interface BaseQuoteDetails {
120
117
  };
121
118
  estimatedPrice: string;
122
119
  recommendedSlippageTolerancePercent: number;
120
+ recommendedRetryDurationMinutes: number;
123
121
  }
124
122
  type WithBoostQuote<T> = Omit<T, 'boostQuote'> & BoostedQuoteDetails;
125
123
  interface RegularQuote extends BaseQuoteDetails {
@@ -135,265 +133,36 @@ type Quote = RegularQuote | DCAQuote;
135
133
  type DCABoostQuote = NonNullable<DCAQuote['boostQuote']>;
136
134
  type RegularBoostQuote = NonNullable<RegularQuote['boostQuote']>;
137
135
  type BoostQuote = RegularBoostQuote | DCABoostQuote;
138
- type FillOrKillParamsWithSlippage$1 = Omit<FillOrKillParamsX128, 'minPriceX128'> & {
136
+ type FillOrKillParamsWithoutRefundAddress = {
137
+ minPrice: string;
138
+ retryDurationBlocks: number;
139
+ } | {
140
+ minPrice: string;
141
+ retryDurationMinutes: number;
142
+ } | {
139
143
  slippageTolerancePercent: string | number;
144
+ retryDurationBlocks: number;
145
+ } | {
146
+ slippageTolerancePercent: string | number;
147
+ retryDurationMinutes: number;
148
+ };
149
+ type FillOrKillParams = {
150
+ refundAddress: string;
151
+ minPrice: string;
152
+ retryDurationBlocks: number;
153
+ } | {
154
+ refundAddress: string;
155
+ minPrice: string;
156
+ retryDurationMinutes: number;
157
+ } | {
158
+ refundAddress: string;
159
+ slippageTolerancePercent: string | number;
160
+ retryDurationBlocks: number;
161
+ } | {
162
+ refundAddress: string;
163
+ slippageTolerancePercent: string | number;
164
+ retryDurationMinutes: number;
140
165
  };
141
-
142
- declare const appRouter: _trpc_server.CreateRouterInner<_trpc_server.RootConfig<{
143
- ctx: object;
144
- meta: object;
145
- errorShape: _trpc_server.DefaultErrorShape;
146
- transformer: typeof superjson;
147
- }>, {
148
- openSwapDepositChannel: _trpc_server.BuildProcedure<"mutation", {
149
- _config: _trpc_server.RootConfig<{
150
- ctx: object;
151
- meta: object;
152
- errorShape: _trpc_server.DefaultErrorShape;
153
- transformer: typeof superjson;
154
- }>;
155
- _meta: object;
156
- _ctx_out: object;
157
- _input_in: {
158
- srcChain: "Ethereum" | "Arbitrum" | "Bitcoin" | "Polkadot" | "Solana" | "Assethub";
159
- srcAsset: "USDC" | "USDT" | "FLIP" | "DOT" | "ETH" | "BTC" | "SOL";
160
- destChain: "Ethereum" | "Arbitrum" | "Bitcoin" | "Polkadot" | "Solana" | "Assethub";
161
- destAsset: "USDC" | "USDT" | "FLIP" | "DOT" | "ETH" | "BTC" | "SOL";
162
- amount: string;
163
- destAddress: string;
164
- fillOrKillParams: {
165
- retryDurationBlocks: number;
166
- refundAddress: string;
167
- minPriceX128: string;
168
- };
169
- ccmParams?: {
170
- message: string;
171
- gasBudget: string;
172
- ccmAdditionalData?: string | undefined;
173
- cfParameters?: string | undefined;
174
- } | undefined;
175
- dcaParams?: {
176
- numberOfChunks: number;
177
- chunkIntervalBlocks: number;
178
- } | undefined;
179
- maxBoostFeeBps?: number | undefined;
180
- srcAddress?: string | undefined;
181
- quote?: {
182
- egressAmount: string;
183
- estimatedPrice: string;
184
- intermediateAmount?: string | undefined;
185
- recommendedSlippageTolerancePercent?: number | undefined;
186
- } | undefined;
187
- takeCommission?: boolean | undefined;
188
- };
189
- _input_out: {
190
- expectedDepositAmount: string;
191
- srcChain: "Ethereum" | "Arbitrum" | "Bitcoin" | "Polkadot" | "Solana" | "Assethub";
192
- srcAsset: "USDC" | "USDT" | "FLIP" | "DOT" | "ETH" | "BTC" | "SOL";
193
- destChain: "Ethereum" | "Arbitrum" | "Bitcoin" | "Polkadot" | "Solana" | "Assethub";
194
- destAsset: "USDC" | "USDT" | "FLIP" | "DOT" | "ETH" | "BTC" | "SOL";
195
- destAddress: string;
196
- fillOrKillParams: {
197
- retryDurationBlocks: number;
198
- refundAddress: string;
199
- minPriceX128: string;
200
- };
201
- ccmParams?: {
202
- gasBudget: `0x${string}`;
203
- message: `0x${string}`;
204
- ccmAdditionalData: `0x${string}` | undefined;
205
- } | undefined;
206
- dcaParams?: {
207
- numberOfChunks: number;
208
- chunkIntervalBlocks: number;
209
- } | undefined;
210
- maxBoostFeeBps?: number | undefined;
211
- srcAddress?: string | undefined;
212
- quote?: {
213
- egressAmount: string;
214
- estimatedPrice: string;
215
- intermediateAmount?: string | undefined;
216
- recommendedSlippageTolerancePercent?: number | undefined;
217
- } | undefined;
218
- takeCommission?: boolean | undefined;
219
- };
220
- _output_in: typeof _trpc_server.unsetMarker;
221
- _output_out: typeof _trpc_server.unsetMarker;
222
- }, {
223
- id: string;
224
- depositAddress: string;
225
- brokerCommissionBps: number;
226
- maxBoostFeeBps: number;
227
- issuedBlock: number;
228
- srcChainExpiryBlock: bigint;
229
- estimatedExpiryTime: number | undefined;
230
- channelOpeningFee: bigint;
231
- }>;
232
- encodeVaultSwapData: _trpc_server.BuildProcedure<"mutation", {
233
- _config: _trpc_server.RootConfig<{
234
- ctx: object;
235
- meta: object;
236
- errorShape: _trpc_server.DefaultErrorShape;
237
- transformer: typeof superjson;
238
- }>;
239
- _meta: object;
240
- _ctx_out: object;
241
- _input_in: {
242
- srcAsset: {
243
- asset: string;
244
- chain: string;
245
- };
246
- destAsset: {
247
- asset: string;
248
- chain: string;
249
- };
250
- amount: string | number;
251
- destAddress: string;
252
- fillOrKillParams: {
253
- retryDurationBlocks: number;
254
- refundAddress: string;
255
- minPriceX128: string;
256
- };
257
- ccmParams?: {
258
- message: string;
259
- gasBudget: string;
260
- ccmAdditionalData?: string | undefined;
261
- cfParameters?: string | undefined;
262
- } | undefined;
263
- commissionBps?: number | undefined;
264
- dcaParams?: {
265
- numberOfChunks: number;
266
- chunkIntervalBlocks: number;
267
- } | undefined;
268
- maxBoostFeeBps?: number | undefined;
269
- affiliates?: {
270
- account: string;
271
- commissionBps: number;
272
- }[] | undefined;
273
- srcAddress?: string | undefined;
274
- extraParams?: {
275
- seed?: string | undefined;
276
- } | undefined;
277
- } & {
278
- brokerCommissionBps?: number | undefined;
279
- brokerAccount?: string | undefined;
280
- };
281
- _input_out: {
282
- extraParams: {
283
- readonly chain: "Bitcoin";
284
- readonly min_output_amount: `0x${string}`;
285
- readonly retry_duration: number;
286
- readonly input_amount?: undefined;
287
- readonly refund_parameters?: undefined;
288
- readonly from?: undefined;
289
- readonly seed?: undefined;
290
- } | {
291
- readonly chain: "Ethereum" | "Arbitrum";
292
- readonly input_amount: `0x${string}`;
293
- readonly refund_parameters: {
294
- retry_duration: number;
295
- refund_address: string;
296
- min_price: `0x${string}`;
297
- };
298
- readonly min_output_amount?: undefined;
299
- readonly retry_duration?: undefined;
300
- readonly from?: undefined;
301
- readonly seed?: undefined;
302
- } | {
303
- readonly chain: "Solana";
304
- readonly from: string;
305
- readonly seed: `0x${string}`;
306
- readonly input_amount: `0x${string}`;
307
- readonly refund_parameters: {
308
- retry_duration: number;
309
- refund_address: string;
310
- min_price: `0x${string}`;
311
- };
312
- readonly min_output_amount?: undefined;
313
- readonly retry_duration?: undefined;
314
- };
315
- srcAsset: _chainflip_utils_chainflip.AssetAndChain;
316
- destAsset: _chainflip_utils_chainflip.AssetAndChain;
317
- amount: bigint;
318
- commissionBps: number;
319
- destAddress: string;
320
- fillOrKillParams: {
321
- retry_duration: number;
322
- refund_address: string;
323
- min_price: `0x${string}`;
324
- };
325
- ccmParams?: {
326
- message: `0x${string}`;
327
- gas_budget: `0x${string}`;
328
- ccm_additional_data: `0x${string}` | undefined;
329
- cf_parameters: `0x${string}` | undefined;
330
- } | undefined;
331
- dcaParams?: {
332
- number_of_chunks: number;
333
- chunk_interval: number;
334
- } | undefined;
335
- maxBoostFeeBps?: number | undefined;
336
- affiliates?: {
337
- account: string;
338
- bps: number;
339
- }[] | undefined;
340
- srcAddress?: string | undefined;
341
- } & {
342
- brokerCommissionBps?: number | undefined;
343
- brokerAccount?: string | undefined;
344
- };
345
- _output_in: typeof _trpc_server.unsetMarker;
346
- _output_out: typeof _trpc_server.unsetMarker;
347
- }, {
348
- chain: "Bitcoin";
349
- nulldataPayload: `0x${string}`;
350
- depositAddress: string;
351
- } | {
352
- value: bigint;
353
- chain: "Ethereum";
354
- to: `0x${string}`;
355
- calldata: `0x${string}`;
356
- sourceTokenAddress?: `0x${string}` | undefined;
357
- } | {
358
- value: bigint;
359
- chain: "Arbitrum";
360
- to: `0x${string}`;
361
- calldata: `0x${string}`;
362
- sourceTokenAddress?: `0x${string}` | undefined;
363
- } | {
364
- chain: "Solana";
365
- programId: string;
366
- data: `0x${string}`;
367
- accounts: {
368
- pubkey: string;
369
- isSigner: boolean;
370
- isWritable: boolean;
371
- }[];
372
- }>;
373
- networkStatus: _trpc_server.BuildProcedure<"query", {
374
- _config: _trpc_server.RootConfig<{
375
- ctx: object;
376
- meta: object;
377
- errorShape: _trpc_server.DefaultErrorShape;
378
- transformer: typeof superjson;
379
- }>;
380
- _ctx_out: object;
381
- _input_in: typeof _trpc_server.unsetMarker;
382
- _input_out: typeof _trpc_server.unsetMarker;
383
- _output_in: typeof _trpc_server.unsetMarker;
384
- _output_out: typeof _trpc_server.unsetMarker;
385
- _meta: object;
386
- }, {
387
- assets: {
388
- deposit: _chainflip_utils_chainflip.ChainflipAsset[];
389
- destination: _chainflip_utils_chainflip.ChainflipAsset[];
390
- all: _chainflip_utils_chainflip.ChainflipAsset[];
391
- };
392
- boostDepositsEnabled: boolean;
393
- cfBrokerCommissionBps: number;
394
- }>;
395
- }>;
396
- type AppRouter = typeof appRouter;
397
166
 
398
167
  interface ChainData {
399
168
  chain: ChainflipChain;
@@ -481,13 +250,13 @@ interface DepositChannelFields {
481
250
  expectedDepositAmount: string | undefined;
482
251
  isExpired: boolean;
483
252
  openedThroughBackend: boolean;
484
- /** @deprecated DEPRECATED(1.8) use SwapStatusResponseV2['brokers'] instead */
253
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['brokers'] instead */
485
254
  brokerCommissionBps: number;
486
- /** @deprecated DEPRECATED(1.8) use SwapStatusResponseV2['brokers'] instead */
255
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['brokers'] instead */
487
256
  affiliateBrokers: AffiliateBroker[];
488
- /** @deprecated DEPRECATED(1.8) use SwapStatusResponseV2['fillOrKillParams'] instead */
257
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['fillOrKillParams'] instead */
489
258
  fillOrKillParams: FillOrKillParamsWithMinPrice | undefined;
490
- /** @deprecated DEPRECATED(1.8) use SwapStatusResponseV2['dcaParams'] instead */
259
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['dcaParams'] instead */
491
260
  dcaParams: DcaParams | undefined;
492
261
  }
493
262
  interface DepositFields {
@@ -622,7 +391,7 @@ interface DepositAddressRequestV2 {
622
391
  quote: Quote | BoostQuote;
623
392
  srcAddress?: string;
624
393
  destAddress: string;
625
- fillOrKillParams: FillOrKillParamsWithMinPrice | FillOrKillParamsWithSlippage$1;
394
+ fillOrKillParams: FillOrKillParams;
626
395
  affiliateBrokers?: {
627
396
  account: `cF${string}` | `0x${string}`;
628
397
  commissionBps: number;
@@ -636,7 +405,7 @@ interface DepositAddressResponseV2 extends Omit<QuoteRequest, 'ccmParams'> {
636
405
  maxBoostFeeBps?: number;
637
406
  srcAddress?: string;
638
407
  dcaParams?: DcaParams;
639
- fillOrKillParams: FillOrKillParamsWithMinPrice | FillOrKillParamsWithSlippage$1;
408
+ fillOrKillParams: FillOrKillParams;
640
409
  depositChannelId: string;
641
410
  depositAddress: string;
642
411
  brokerCommissionBps: number;
@@ -649,7 +418,7 @@ interface VaultSwapRequest {
649
418
  quote: Quote | BoostQuote;
650
419
  srcAddress?: string;
651
420
  destAddress: string;
652
- fillOrKillParams: FillOrKillParamsWithMinPrice | FillOrKillParamsWithSlippage$1;
421
+ fillOrKillParams: FillOrKillParams;
653
422
  affiliateBrokers?: {
654
423
  account: `cF${string}` | `0x${string}`;
655
424
  commissionBps: number;
@@ -681,6 +450,19 @@ type VaultSwapResponse = {
681
450
  }[];
682
451
  data: string;
683
452
  };
453
+ interface EncodeCfParametersRequest {
454
+ quote: Quote | BoostQuote;
455
+ srcAddress?: string;
456
+ destAddress: string;
457
+ fillOrKillParams: FillOrKillParams;
458
+ affiliateBrokers?: {
459
+ account: `cF${string}` | `0x${string}`;
460
+ commissionBps: number;
461
+ }[];
462
+ ccmParams?: CcmParams;
463
+ brokerAccount?: `cF${string}`;
464
+ brokerCommissionBps?: number;
465
+ }
684
466
 
685
467
  type RequestOptions = {
686
468
  signal?: AbortSignal;
@@ -691,7 +473,7 @@ type SwapSDKOptions = {
691
473
  backendUrl?: string;
692
474
  broker?: {
693
475
  url: string;
694
- /** @deprecated DEPRECATED(1.8) set the brokerCommissionBps param of the requestDepositAddress and encodeVaultSwapData method instead */
476
+ /** @deprecated DEPRECATED(1.10) set the brokerCommissionBps param of the requestDepositAddress and encodeVaultSwapData method instead */
695
477
  commissionBps?: number;
696
478
  };
697
479
  rpcUrl?: string;
@@ -699,19 +481,19 @@ type SwapSDKOptions = {
699
481
  dca?: boolean;
700
482
  };
701
483
  };
702
- type NetworkStatus = inferRouterOutputs<AppRouter>['networkStatus'];
484
+ type AssetState = 'all' | 'deposit' | 'destination' | 'depositChannel' | 'vaultSwap';
703
485
  declare class SwapSDK {
704
486
  private readonly options;
705
487
  private readonly rpcConfig;
706
- private readonly trpc;
488
+ private readonly apiClient;
707
489
  private cache;
708
490
  private dcaEnabled;
709
491
  constructor(options?: SwapSDKOptions);
710
- getChains(sourceChain?: ChainflipChain, type?: keyof NetworkStatus['assets']): Promise<ChainData[]>;
492
+ getChains(sourceChain?: ChainflipChain, type?: AssetState): Promise<ChainData[]>;
711
493
  private getStateChainEnvironment;
712
494
  private getSupportedAssets;
713
495
  private getBoostPoolsDepth;
714
- getAssets(chain?: ChainflipChain, type?: keyof NetworkStatus['assets']): Promise<AssetData[]>;
496
+ getAssets(chain?: ChainflipChain, type?: AssetState): Promise<AssetData[]>;
715
497
  protected shouldTakeCommission(): boolean;
716
498
  private getCommissionBps;
717
499
  getQuoteV2(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponseV2>;
@@ -730,9 +512,10 @@ declare class SwapSDK {
730
512
  } & UncheckedAssetAndChain)): Promise<BoostPoolDepth[]>;
731
513
  requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps: brokerCommissionBpsParam, }: DepositAddressRequestV2): Promise<DepositAddressResponseV2>;
732
514
  encodeVaultSwapData({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps: brokerCommissionBpsParam, extraParams, }: VaultSwapRequest): Promise<VaultSwapResponse>;
515
+ encodeCfParameters({ quote, srcAddress, destAddress, fillOrKillParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps, }: EncodeCfParametersRequest): Promise<HexString>;
733
516
  getOnChainSwapExtrinsicArgs({ quote, fillOrKillParams, }: {
734
517
  quote: Quote;
735
- fillOrKillParams: Omit<FillOrKillParamsWithMinPrice, 'refundAddress'> | Omit<FillOrKillParamsWithSlippage, 'refundAddress'>;
518
+ fillOrKillParams: FillOrKillParamsWithoutRefundAddress;
736
519
  }): [
737
520
  amount: string,
738
521
  inputAsset: ChainflipAsset,
@@ -786,4 +569,4 @@ declare const Assets: {
786
569
  SOL: "SOL";
787
570
  };
788
571
 
789
- 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 FillOrKillParamsWithSlippage, type Quote, type QuoteRequest, type QuoteResponseV2, type RegularQuote, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponseV2, type VaultSwapRequest, type VaultSwapResponse };
572
+ 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 };