@chainflip/sdk 1.9.5 → 1.10.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.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}`;
@@ -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<{
@@ -139,262 +136,6 @@ type FillOrKillParamsWithSlippage$1 = Omit<FillOrKillParamsX128, 'minPriceX128'>
139
136
  slippageTolerancePercent: string | number;
140
137
  };
141
138
 
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
-
398
139
  interface ChainData {
399
140
  chain: ChainflipChain;
400
141
  name: string;
@@ -481,13 +222,13 @@ interface DepositChannelFields {
481
222
  expectedDepositAmount: string | undefined;
482
223
  isExpired: boolean;
483
224
  openedThroughBackend: boolean;
484
- /** @deprecated DEPRECATED(1.8) use SwapStatusResponseV2['brokers'] instead */
225
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['brokers'] instead */
485
226
  brokerCommissionBps: number;
486
- /** @deprecated DEPRECATED(1.8) use SwapStatusResponseV2['brokers'] instead */
227
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['brokers'] instead */
487
228
  affiliateBrokers: AffiliateBroker[];
488
- /** @deprecated DEPRECATED(1.8) use SwapStatusResponseV2['fillOrKillParams'] instead */
229
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['fillOrKillParams'] instead */
489
230
  fillOrKillParams: FillOrKillParamsWithMinPrice | undefined;
490
- /** @deprecated DEPRECATED(1.8) use SwapStatusResponseV2['dcaParams'] instead */
231
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['dcaParams'] instead */
491
232
  dcaParams: DcaParams | undefined;
492
233
  }
493
234
  interface DepositFields {
@@ -681,6 +422,19 @@ type VaultSwapResponse = {
681
422
  }[];
682
423
  data: string;
683
424
  };
425
+ interface EncodeCfParametersRequest {
426
+ quote: Quote | BoostQuote;
427
+ srcAddress?: string;
428
+ destAddress: string;
429
+ fillOrKillParams: FillOrKillParamsWithMinPrice | FillOrKillParamsWithSlippage$1;
430
+ affiliateBrokers?: {
431
+ account: `cF${string}` | `0x${string}`;
432
+ commissionBps: number;
433
+ }[];
434
+ ccmParams?: CcmParams;
435
+ brokerAccount?: `cF${string}`;
436
+ brokerCommissionBps?: number;
437
+ }
684
438
 
685
439
  type RequestOptions = {
686
440
  signal?: AbortSignal;
@@ -691,7 +445,7 @@ type SwapSDKOptions = {
691
445
  backendUrl?: string;
692
446
  broker?: {
693
447
  url: string;
694
- /** @deprecated DEPRECATED(1.8) set the brokerCommissionBps param of the requestDepositAddress and encodeVaultSwapData method instead */
448
+ /** @deprecated DEPRECATED(1.10) set the brokerCommissionBps param of the requestDepositAddress and encodeVaultSwapData method instead */
695
449
  commissionBps?: number;
696
450
  };
697
451
  rpcUrl?: string;
@@ -699,19 +453,19 @@ type SwapSDKOptions = {
699
453
  dca?: boolean;
700
454
  };
701
455
  };
702
- type NetworkStatus = inferRouterOutputs<AppRouter>['networkStatus'];
456
+ type AssetState = 'all' | 'deposit' | 'destination' | 'depositChannel' | 'vaultSwap';
703
457
  declare class SwapSDK {
704
458
  private readonly options;
705
459
  private readonly rpcConfig;
706
- private readonly trpc;
460
+ private readonly apiClient;
707
461
  private cache;
708
462
  private dcaEnabled;
709
463
  constructor(options?: SwapSDKOptions);
710
- getChains(sourceChain?: ChainflipChain, type?: keyof NetworkStatus['assets']): Promise<ChainData[]>;
464
+ getChains(sourceChain?: ChainflipChain, type?: AssetState): Promise<ChainData[]>;
711
465
  private getStateChainEnvironment;
712
466
  private getSupportedAssets;
713
467
  private getBoostPoolsDepth;
714
- getAssets(chain?: ChainflipChain, type?: keyof NetworkStatus['assets']): Promise<AssetData[]>;
468
+ getAssets(chain?: ChainflipChain, type?: AssetState): Promise<AssetData[]>;
715
469
  protected shouldTakeCommission(): boolean;
716
470
  private getCommissionBps;
717
471
  getQuoteV2(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponseV2>;
@@ -730,6 +484,7 @@ declare class SwapSDK {
730
484
  } & UncheckedAssetAndChain)): Promise<BoostPoolDepth[]>;
731
485
  requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps: brokerCommissionBpsParam, }: DepositAddressRequestV2): Promise<DepositAddressResponseV2>;
732
486
  encodeVaultSwapData({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps: brokerCommissionBpsParam, extraParams, }: VaultSwapRequest): Promise<VaultSwapResponse>;
487
+ encodeCfParameters({ quote, srcAddress, destAddress, fillOrKillParams, affiliateBrokers: affiliates, ccmParams, brokerAccount, brokerCommissionBps, }: EncodeCfParametersRequest): Promise<HexString>;
733
488
  getOnChainSwapExtrinsicArgs({ quote, fillOrKillParams, }: {
734
489
  quote: Quote;
735
490
  fillOrKillParams: Omit<FillOrKillParamsWithMinPrice, 'refundAddress'> | Omit<FillOrKillParamsWithSlippage, 'refundAddress'>;
@@ -786,4 +541,4 @@ declare const Assets: {
786
541
  SOL: "SOL";
787
542
  };
788
543
 
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 };
544
+ 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 };