@chainflip/sdk 1.9.4 → 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,15 +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>>;
10
+ /** @deprecated DEPRECATED(1.10) pass additionalData instead */
13
11
  cfParameters: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>>;
14
12
  }, "strip", z.ZodTypeAny, {
15
13
  message: `0x${string}`;
@@ -32,6 +30,7 @@ declare const ccmParamsSchema: z.ZodEffects<z.ZodObject<{
32
30
  cfParameters?: string | undefined;
33
31
  }>;
34
32
  type CcmParams = Omit<z.input<typeof ccmParamsSchema>, 'cfParameters'> & {
33
+ /** @deprecated DEPRECATED(1.10) pass additionalData instead */
35
34
  cfParameters?: string;
36
35
  };
37
36
  declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
@@ -137,262 +136,6 @@ type FillOrKillParamsWithSlippage$1 = Omit<FillOrKillParamsX128, 'minPriceX128'>
137
136
  slippageTolerancePercent: string | number;
138
137
  };
139
138
 
140
- declare const appRouter: _trpc_server.CreateRouterInner<_trpc_server.RootConfig<{
141
- ctx: object;
142
- meta: object;
143
- errorShape: _trpc_server.DefaultErrorShape;
144
- transformer: typeof superjson;
145
- }>, {
146
- openSwapDepositChannel: _trpc_server.BuildProcedure<"mutation", {
147
- _config: _trpc_server.RootConfig<{
148
- ctx: object;
149
- meta: object;
150
- errorShape: _trpc_server.DefaultErrorShape;
151
- transformer: typeof superjson;
152
- }>;
153
- _meta: object;
154
- _ctx_out: object;
155
- _input_in: {
156
- srcChain: "Ethereum" | "Arbitrum" | "Bitcoin" | "Polkadot" | "Solana" | "Assethub";
157
- srcAsset: "USDC" | "USDT" | "FLIP" | "DOT" | "ETH" | "BTC" | "SOL";
158
- destChain: "Ethereum" | "Arbitrum" | "Bitcoin" | "Polkadot" | "Solana" | "Assethub";
159
- destAsset: "USDC" | "USDT" | "FLIP" | "DOT" | "ETH" | "BTC" | "SOL";
160
- amount: string;
161
- destAddress: string;
162
- fillOrKillParams: {
163
- retryDurationBlocks: number;
164
- refundAddress: string;
165
- minPriceX128: string;
166
- };
167
- ccmParams?: {
168
- message: string;
169
- gasBudget: string;
170
- ccmAdditionalData?: string | undefined;
171
- cfParameters?: string | undefined;
172
- } | undefined;
173
- dcaParams?: {
174
- numberOfChunks: number;
175
- chunkIntervalBlocks: number;
176
- } | undefined;
177
- maxBoostFeeBps?: number | undefined;
178
- srcAddress?: string | undefined;
179
- quote?: {
180
- egressAmount: string;
181
- estimatedPrice: string;
182
- intermediateAmount?: string | undefined;
183
- recommendedSlippageTolerancePercent?: number | undefined;
184
- } | undefined;
185
- takeCommission?: boolean | undefined;
186
- };
187
- _input_out: {
188
- expectedDepositAmount: string;
189
- srcChain: "Ethereum" | "Arbitrum" | "Bitcoin" | "Polkadot" | "Solana" | "Assethub";
190
- srcAsset: "USDC" | "USDT" | "FLIP" | "DOT" | "ETH" | "BTC" | "SOL";
191
- destChain: "Ethereum" | "Arbitrum" | "Bitcoin" | "Polkadot" | "Solana" | "Assethub";
192
- destAsset: "USDC" | "USDT" | "FLIP" | "DOT" | "ETH" | "BTC" | "SOL";
193
- destAddress: string;
194
- fillOrKillParams: {
195
- retryDurationBlocks: number;
196
- refundAddress: string;
197
- minPriceX128: string;
198
- };
199
- ccmParams?: {
200
- gasBudget: `0x${string}`;
201
- message: `0x${string}`;
202
- ccmAdditionalData: `0x${string}` | undefined;
203
- } | undefined;
204
- dcaParams?: {
205
- numberOfChunks: number;
206
- chunkIntervalBlocks: number;
207
- } | undefined;
208
- maxBoostFeeBps?: number | undefined;
209
- srcAddress?: string | undefined;
210
- quote?: {
211
- egressAmount: string;
212
- estimatedPrice: string;
213
- intermediateAmount?: string | undefined;
214
- recommendedSlippageTolerancePercent?: number | undefined;
215
- } | undefined;
216
- takeCommission?: boolean | undefined;
217
- };
218
- _output_in: typeof _trpc_server.unsetMarker;
219
- _output_out: typeof _trpc_server.unsetMarker;
220
- }, {
221
- id: string;
222
- depositAddress: string;
223
- brokerCommissionBps: number;
224
- maxBoostFeeBps: number;
225
- issuedBlock: number;
226
- srcChainExpiryBlock: bigint;
227
- estimatedExpiryTime: number | undefined;
228
- channelOpeningFee: bigint;
229
- }>;
230
- encodeVaultSwapData: _trpc_server.BuildProcedure<"mutation", {
231
- _config: _trpc_server.RootConfig<{
232
- ctx: object;
233
- meta: object;
234
- errorShape: _trpc_server.DefaultErrorShape;
235
- transformer: typeof superjson;
236
- }>;
237
- _meta: object;
238
- _ctx_out: object;
239
- _input_in: {
240
- srcAsset: {
241
- asset: string;
242
- chain: string;
243
- };
244
- destAsset: {
245
- asset: string;
246
- chain: string;
247
- };
248
- amount: string | number;
249
- destAddress: string;
250
- fillOrKillParams: {
251
- retryDurationBlocks: number;
252
- refundAddress: string;
253
- minPriceX128: string;
254
- };
255
- ccmParams?: {
256
- message: string;
257
- gasBudget: string;
258
- ccmAdditionalData?: string | undefined;
259
- cfParameters?: string | undefined;
260
- } | undefined;
261
- commissionBps?: number | undefined;
262
- dcaParams?: {
263
- numberOfChunks: number;
264
- chunkIntervalBlocks: number;
265
- } | undefined;
266
- maxBoostFeeBps?: number | undefined;
267
- affiliates?: {
268
- account: string;
269
- commissionBps: number;
270
- }[] | undefined;
271
- srcAddress?: string | undefined;
272
- extraParams?: {
273
- seed?: string | undefined;
274
- } | undefined;
275
- } & {
276
- brokerCommissionBps?: number | undefined;
277
- brokerAccount?: string | undefined;
278
- };
279
- _input_out: {
280
- extraParams: {
281
- readonly chain: "Bitcoin";
282
- readonly min_output_amount: `0x${string}`;
283
- readonly retry_duration: number;
284
- readonly input_amount?: undefined;
285
- readonly refund_parameters?: undefined;
286
- readonly from?: undefined;
287
- readonly seed?: undefined;
288
- } | {
289
- readonly chain: "Ethereum" | "Arbitrum";
290
- readonly input_amount: `0x${string}`;
291
- readonly refund_parameters: {
292
- retry_duration: number;
293
- refund_address: string;
294
- min_price: `0x${string}`;
295
- };
296
- readonly min_output_amount?: undefined;
297
- readonly retry_duration?: undefined;
298
- readonly from?: undefined;
299
- readonly seed?: undefined;
300
- } | {
301
- readonly chain: "Solana";
302
- readonly from: string;
303
- readonly seed: `0x${string}`;
304
- readonly input_amount: `0x${string}`;
305
- readonly refund_parameters: {
306
- retry_duration: number;
307
- refund_address: string;
308
- min_price: `0x${string}`;
309
- };
310
- readonly min_output_amount?: undefined;
311
- readonly retry_duration?: undefined;
312
- };
313
- srcAsset: _chainflip_utils_chainflip.AssetAndChain;
314
- destAsset: _chainflip_utils_chainflip.AssetAndChain;
315
- amount: bigint;
316
- commissionBps: number;
317
- destAddress: string;
318
- fillOrKillParams: {
319
- retry_duration: number;
320
- refund_address: string;
321
- min_price: `0x${string}`;
322
- };
323
- ccmParams?: {
324
- message: `0x${string}`;
325
- gas_budget: `0x${string}`;
326
- ccm_additional_data: `0x${string}` | undefined;
327
- cf_parameters: `0x${string}` | undefined;
328
- } | undefined;
329
- dcaParams?: {
330
- number_of_chunks: number;
331
- chunk_interval: number;
332
- } | undefined;
333
- maxBoostFeeBps?: number | undefined;
334
- affiliates?: {
335
- account: string;
336
- bps: number;
337
- }[] | undefined;
338
- srcAddress?: string | undefined;
339
- } & {
340
- brokerCommissionBps?: number | undefined;
341
- brokerAccount?: string | undefined;
342
- };
343
- _output_in: typeof _trpc_server.unsetMarker;
344
- _output_out: typeof _trpc_server.unsetMarker;
345
- }, {
346
- chain: "Bitcoin";
347
- nulldataPayload: `0x${string}`;
348
- depositAddress: string;
349
- } | {
350
- value: bigint;
351
- chain: "Ethereum";
352
- to: `0x${string}`;
353
- calldata: `0x${string}`;
354
- sourceTokenAddress?: `0x${string}` | undefined;
355
- } | {
356
- value: bigint;
357
- chain: "Arbitrum";
358
- to: `0x${string}`;
359
- calldata: `0x${string}`;
360
- sourceTokenAddress?: `0x${string}` | undefined;
361
- } | {
362
- chain: "Solana";
363
- programId: string;
364
- data: `0x${string}`;
365
- accounts: {
366
- pubkey: string;
367
- isSigner: boolean;
368
- isWritable: boolean;
369
- }[];
370
- }>;
371
- networkStatus: _trpc_server.BuildProcedure<"query", {
372
- _config: _trpc_server.RootConfig<{
373
- ctx: object;
374
- meta: object;
375
- errorShape: _trpc_server.DefaultErrorShape;
376
- transformer: typeof superjson;
377
- }>;
378
- _ctx_out: object;
379
- _input_in: typeof _trpc_server.unsetMarker;
380
- _input_out: typeof _trpc_server.unsetMarker;
381
- _output_in: typeof _trpc_server.unsetMarker;
382
- _output_out: typeof _trpc_server.unsetMarker;
383
- _meta: object;
384
- }, {
385
- assets: {
386
- deposit: _chainflip_utils_chainflip.ChainflipAsset[];
387
- destination: _chainflip_utils_chainflip.ChainflipAsset[];
388
- all: _chainflip_utils_chainflip.ChainflipAsset[];
389
- };
390
- boostDepositsEnabled: boolean;
391
- cfBrokerCommissionBps: number;
392
- }>;
393
- }>;
394
- type AppRouter = typeof appRouter;
395
-
396
139
  interface ChainData {
397
140
  chain: ChainflipChain;
398
141
  name: string;
@@ -479,9 +222,13 @@ interface DepositChannelFields {
479
222
  expectedDepositAmount: string | undefined;
480
223
  isExpired: boolean;
481
224
  openedThroughBackend: boolean;
225
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['brokers'] instead */
482
226
  brokerCommissionBps: number;
227
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['brokers'] instead */
483
228
  affiliateBrokers: AffiliateBroker[];
229
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['fillOrKillParams'] instead */
484
230
  fillOrKillParams: FillOrKillParamsWithMinPrice | undefined;
231
+ /** @deprecated DEPRECATED(1.10) use SwapStatusResponseV2['dcaParams'] instead */
485
232
  dcaParams: DcaParams | undefined;
486
233
  }
487
234
  interface DepositFields {
@@ -520,9 +267,28 @@ interface SwapFields {
520
267
  executedChunks: number;
521
268
  remainingChunks: number;
522
269
  } | undefined;
270
+ /**
271
+ * Represents details of an on-chain transaction associated with the swap.
272
+ * - `accountId`: The account identifier of the LP for the on-chain swap.
273
+ * - `outputAmount`: The amount of output tokens received from the swap.
274
+ * This is `undefined` if the swap has not been executed or it was fully
275
+ * refunded.
276
+ * - `refundAmount`: The amount of input tokens refunded due to a fully or
277
+ * partially refunded swap. This is `undefined` if no refund occurred.
278
+ */
523
279
  onChain: {
280
+ /** The account identifier of the LP for the on-chain swap */
524
281
  accountId: string;
282
+ /**
283
+ * The amount of output tokens received from the swap. This is
284
+ * `undefined` if the swap has not been executed or it was fully
285
+ * refunded.
286
+ */
525
287
  outputAmount: string | undefined;
288
+ /**
289
+ * The amount of input tokens refunded due to a fully or partially
290
+ * refunded swap. This is `undefined` if no refund occurred.
291
+ */
526
292
  refundAmount: string | undefined;
527
293
  } | undefined;
528
294
  }
@@ -656,6 +422,19 @@ type VaultSwapResponse = {
656
422
  }[];
657
423
  data: string;
658
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
+ }
659
438
 
660
439
  type RequestOptions = {
661
440
  signal?: AbortSignal;
@@ -666,6 +445,7 @@ type SwapSDKOptions = {
666
445
  backendUrl?: string;
667
446
  broker?: {
668
447
  url: string;
448
+ /** @deprecated DEPRECATED(1.10) set the brokerCommissionBps param of the requestDepositAddress and encodeVaultSwapData method instead */
669
449
  commissionBps?: number;
670
450
  };
671
451
  rpcUrl?: string;
@@ -673,19 +453,19 @@ type SwapSDKOptions = {
673
453
  dca?: boolean;
674
454
  };
675
455
  };
676
- type NetworkStatus = inferRouterOutputs<AppRouter>['networkStatus'];
456
+ type AssetState = 'all' | 'deposit' | 'destination' | 'depositChannel' | 'vaultSwap';
677
457
  declare class SwapSDK {
678
458
  private readonly options;
679
459
  private readonly rpcConfig;
680
- private readonly trpc;
460
+ private readonly apiClient;
681
461
  private cache;
682
462
  private dcaEnabled;
683
463
  constructor(options?: SwapSDKOptions);
684
- getChains(sourceChain?: ChainflipChain, type?: keyof NetworkStatus['assets']): Promise<ChainData[]>;
464
+ getChains(sourceChain?: ChainflipChain, type?: AssetState): Promise<ChainData[]>;
685
465
  private getStateChainEnvironment;
686
466
  private getSupportedAssets;
687
467
  private getBoostPoolsDepth;
688
- getAssets(chain?: ChainflipChain, type?: keyof NetworkStatus['assets']): Promise<AssetData[]>;
468
+ getAssets(chain?: ChainflipChain, type?: AssetState): Promise<AssetData[]>;
689
469
  protected shouldTakeCommission(): boolean;
690
470
  private getCommissionBps;
691
471
  getQuoteV2(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponseV2>;
@@ -704,6 +484,7 @@ declare class SwapSDK {
704
484
  } & UncheckedAssetAndChain)): Promise<BoostPoolDepth[]>;
705
485
  requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps: brokerCommissionBpsParam, }: DepositAddressRequestV2): Promise<DepositAddressResponseV2>;
706
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>;
707
488
  getOnChainSwapExtrinsicArgs({ quote, fillOrKillParams, }: {
708
489
  quote: Quote;
709
490
  fillOrKillParams: Omit<FillOrKillParamsWithMinPrice, 'refundAddress'> | Omit<FillOrKillParamsWithSlippage, 'refundAddress'>;
@@ -760,4 +541,4 @@ declare const Assets: {
760
541
  SOL: "SOL";
761
542
  };
762
543
 
763
- 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 };