@chainflip/sdk 1.6.0-alpha.6 → 1.6.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.
@@ -274,6 +274,9 @@ createRequest("state_getMetadata");
274
274
  var getSupportedAssets = createRequest("cf_supported_assets");
275
275
  createRequest("state_getRuntimeVersion");
276
276
  createRequest("chain_getBlockHash");
277
+ createRequest("cf_pool_depth");
278
+ createRequest("cf_accounts");
279
+ createRequest("cf_account_info");
277
280
  var getAllBoostPoolsDepth = transform(createRequest("cf_boost_pools_depth"), (result) => result.map(({ chain, asset, ...rest }) => ({
278
281
  asset: getInternalAsset({
279
282
  chain,
package/dist/funding.js CHANGED
@@ -1083,6 +1083,9 @@ createRequest("state_getMetadata");
1083
1083
  createRequest("cf_supported_assets");
1084
1084
  createRequest("state_getRuntimeVersion");
1085
1085
  createRequest("chain_getBlockHash");
1086
+ createRequest("cf_pool_depth");
1087
+ createRequest("cf_accounts");
1088
+ createRequest("cf_account_info");
1086
1089
  transform(createRequest("cf_boost_pools_depth"), (result) => result.map(({ chain, asset, ...rest }) => ({
1087
1090
  asset: getInternalAsset({
1088
1091
  chain,
package/dist/funding.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { __name, __publicField, ChainflipNetworks, getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, InternalAssets, checkAllowance, assert, extractOverrides, StateChainGateway__factory } from './chunk-EHDVKR7F.mjs';
1
+ import { __name, __publicField, ChainflipNetworks, getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, InternalAssets, checkAllowance, assert, extractOverrides, StateChainGateway__factory } from './chunk-35BXEUA4.mjs';
2
2
 
3
3
  // ../shared/src/stateChainGateway/utils.ts
4
4
  var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
package/dist/swap.d.mts CHANGED
@@ -2,7 +2,6 @@ import { Signer } from 'ethers';
2
2
  import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-DmShvHR7.mjs';
3
3
  export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-DmShvHR7.mjs';
4
4
  import { z } from 'zod';
5
- import { SwapType } from '.prisma/client';
6
5
 
7
6
  declare const ccmParamsSchema: z.ZodObject<{
8
7
  gasBudget: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, `0x${string}`, string>]>, `0x${string}`, string>;
@@ -35,6 +34,17 @@ declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
35
34
  commissionBps: number;
36
35
  }>;
37
36
  type AffiliateBroker = z.input<typeof affiliateBroker>;
37
+ declare const dcaParams: z.ZodObject<{
38
+ numberOfChunks: z.ZodNumber;
39
+ chunkIntervalBlocks: z.ZodNumber;
40
+ }, "strip", z.ZodTypeAny, {
41
+ numberOfChunks: number;
42
+ chunkIntervalBlocks: number;
43
+ }, {
44
+ numberOfChunks: number;
45
+ chunkIntervalBlocks: number;
46
+ }>;
47
+ type DcaParams = z.input<typeof dcaParams>;
38
48
  declare const fillOrKillParams: z.ZodObject<{
39
49
  retryDurationBlocks: z.ZodNumber;
40
50
  refundAddress: z.ZodString;
@@ -52,10 +62,6 @@ type FillOrKillParamsX128 = z.input<typeof fillOrKillParams>;
52
62
  type FillOrKillParams = Omit<FillOrKillParamsX128, 'minPriceX128'> & {
53
63
  minPrice: string;
54
64
  };
55
- type DcaParams = {
56
- numberOfChunks: number;
57
- chunkInterval: number;
58
- };
59
65
  type Fee<T> = {
60
66
  type: T;
61
67
  chain: Chain;
@@ -84,6 +90,10 @@ type BoostedQuoteDetails = QuoteDetails & {
84
90
  };
85
91
  type QuoteQueryResponse = QuoteDetails & {
86
92
  boostQuote?: BoostedQuoteDetails;
93
+ dcaParams?: {
94
+ numberOfChunks: number;
95
+ chunkIntervalBlocks: number;
96
+ };
87
97
  };
88
98
 
89
99
  interface ExecuteSwapParams {
@@ -134,6 +144,9 @@ interface QuoteRequest extends ChainsAndAssets {
134
144
  interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
135
145
  quote: QuoteQueryResponse;
136
146
  }
147
+ interface QuoteResponseV2 extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
148
+ quotes: QuoteQueryResponse[];
149
+ }
137
150
  interface DepositAddressRequest extends QuoteRequest {
138
151
  destAddress: string;
139
152
  ccmParams?: CcmParams;
@@ -223,7 +236,7 @@ type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
223
236
  state: 'FAILED';
224
237
  depositAddress: undefined;
225
238
  }>;
226
- type SwapState$1 = {
239
+ type SwapState = {
227
240
  state: 'AWAITING_DEPOSIT';
228
241
  depositAmount: string | undefined;
229
242
  depositTransactionConfirmations: number | undefined;
@@ -310,8 +323,8 @@ type SwapState$1 = {
310
323
  egressIgnoredAt: number;
311
324
  egressIgnoredBlockIndex: string;
312
325
  };
313
- type DepositAddressStatusResponse = DepositAddressFields & SwapState$1;
314
- type VaultSwapStatusResponse = VaultSwapFields & SwapState$1;
326
+ type DepositAddressStatusResponse = DepositAddressFields & SwapState;
327
+ type VaultSwapStatusResponse = VaultSwapFields & SwapState;
315
328
  type SwapStatusResponse = DepositAddressStatusResponse | VaultSwapStatusResponse | FailedVaultSwapStatusResponse;
316
329
  type BoostPoolDepth = {
317
330
  feeTierBps: number;
@@ -327,16 +340,6 @@ declare enum FailureMode {
327
340
  BroadcastAborted = "SENDING_FAILED"
328
341
  }
329
342
 
330
- interface DcaParameters {
331
- numberOfChunks: number;
332
- chunkIntervalBlocks: string;
333
- }
334
- interface Ccm {
335
- message: string;
336
- gasBudget: string;
337
- cfParameters: string | undefined;
338
- ccmDepositReceivedBlockIndex: string | undefined;
339
- }
340
343
  interface Failure {
341
344
  failedAt: number;
342
345
  failedBlockIndex: string;
@@ -366,39 +369,51 @@ interface DepositChannelFields {
366
369
  openedThroughBackend: boolean;
367
370
  affiliateBrokers: AffiliateBroker[];
368
371
  fillOrKillParams: FillOrKillParams | undefined;
369
- dcaParams: DcaParameters | undefined;
372
+ dcaParams: DcaParams | undefined;
370
373
  }
371
374
  interface DepositFields {
372
375
  amount: string;
373
376
  txRef: string | undefined;
374
377
  txConfirmations: number | undefined;
375
- receivedAt: number | undefined;
376
- receivedBlockIndex: string | undefined;
378
+ witnessedAt: number | undefined;
379
+ witnessedBlockIndex: string | undefined;
377
380
  failure: Failure | undefined;
378
381
  failedAt: number | undefined;
379
382
  failedBlockIndex: string | undefined;
380
383
  }
381
- interface SwapChunk {
382
- swapInputAmount: string;
383
- swapOutputAmount: string | undefined;
384
- scheduledAt: number;
385
- scheduledBlockIndex: string;
386
- executedAt: number | undefined;
387
- executedBlockIndex: string | undefined;
388
- retryCount: number;
389
- latestSwapRescheduledAt: number | undefined;
390
- latestSwapRescheduledBlockIndex: number | undefined;
391
- fees: PaidFee[];
392
- isDca: false;
393
- }
394
384
  interface SwapFields {
395
- totalInputAmountSwapped: string | undefined;
396
- totalOutputAmountSwapped: string | undefined;
397
- totalChunksExecuted: number;
398
- isDca: true;
399
- lastExecutedChunk: SwapChunk | undefined;
400
- currentChunk: SwapChunk;
401
- type: SwapType;
385
+ originalInputAmount: string;
386
+ remainingInputAmount: string;
387
+ swappedInputAmount: string;
388
+ swappedOutputAmount: string;
389
+ regular?: {
390
+ inputAmount: string;
391
+ outputAmount: string;
392
+ scheduledAt: number;
393
+ scheduledBlockIndex: string;
394
+ executedAt?: number;
395
+ executedBlockIndex?: string;
396
+ retryCount: 0;
397
+ };
398
+ dca?: {
399
+ lastExecutedChunk: {
400
+ inputAmount: string;
401
+ outputAmount: string;
402
+ scheduledAt: number;
403
+ scheduledBlockIndex: string;
404
+ executedAt: number;
405
+ executedBlockIndex: string;
406
+ retryCount: number;
407
+ } | null;
408
+ currentChunk: {
409
+ inputAmount: string;
410
+ scheduledAt: number;
411
+ scheduledBlockIndex: string;
412
+ retryCount: number;
413
+ } | null;
414
+ executedChunks: number;
415
+ remainingChunks: number;
416
+ };
402
417
  fees: PaidFee[];
403
418
  }
404
419
  interface EgressFields {
@@ -406,9 +421,8 @@ interface EgressFields {
406
421
  scheduledAt: number;
407
422
  scheduledBlockIndex: string;
408
423
  txRef: string | undefined;
409
- confirmedAt: number | undefined;
410
- confirmedBlockIndex: string | undefined;
411
- ignoredAmount: string | undefined;
424
+ witnessedAt: number | undefined;
425
+ witnessedBlockIndex: string | undefined;
412
426
  failure: Failure | undefined;
413
427
  failedAt: number | undefined;
414
428
  failedBlockIndex: string | undefined;
@@ -416,27 +430,16 @@ interface EgressFields {
416
430
  interface SwapStatusResponseCommonFields extends ChainsAndAssets {
417
431
  swapId: string;
418
432
  destAddress: string;
419
- ccm: Ccm | undefined;
433
+ depositChannel: DepositChannelFields | undefined;
434
+ ccmParams: CcmParams | undefined;
420
435
  boost: Boost | undefined;
421
436
  estimatedDurationSeconds: number | null | undefined;
422
437
  srcChainRequiredBlockConfirmations: number | null;
423
438
  }
424
- interface VaultSwapCommonFields extends Exclude<SwapStatusResponseCommonFields, 'boost'> {
425
- }
426
- interface ReceivingVaultSwap extends VaultSwapCommonFields {
427
- deposit: DepositFields;
428
- }
429
- interface SwappingVaultSwap extends ReceivingVaultSwap {
430
- swap: Exclude<SwapChunk, 'latestSwapRescheduledAt' | 'latestSwapRescheduledBlockIndex'> | undefined;
431
- swapEgress: EgressFields | undefined;
432
- }
433
- interface SendingVaultSwap extends SwappingVaultSwap {
434
- swapEgress: EgressFields | undefined;
435
- }
436
- interface DepositChannel extends SwapStatusResponseCommonFields {
439
+ interface Waiting extends SwapStatusResponseCommonFields {
437
440
  depositChannel: DepositChannelFields;
438
441
  }
439
- interface Receiving extends DepositChannel {
442
+ interface Receiving extends SwapStatusResponseCommonFields {
440
443
  deposit: DepositFields;
441
444
  }
442
445
  interface Swapping extends Receiving {
@@ -447,9 +450,9 @@ interface Sending extends Receiving {
447
450
  swapEgress: EgressFields | undefined;
448
451
  refundEgress: EgressFields | undefined;
449
452
  }
450
- type SwapState = ({
453
+ type SwapStatusResponseV2 = ({
451
454
  state: 'WAITING';
452
- } & DepositChannel) | ({
455
+ } & Waiting) | ({
453
456
  state: 'RECEIVING';
454
457
  } & Receiving) | ({
455
458
  state: 'SWAPPING';
@@ -462,9 +465,6 @@ type SwapState = ({
462
465
  } & Sending) | ({
463
466
  state: 'FAILED';
464
467
  } & Sending);
465
- type DepositAddressStatusResponseV2 = SwapState;
466
- type VaultSwapStatusResponseV2 = SwapState & SendingVaultSwap;
467
- type SwapStatusResponseV2 = DepositAddressStatusResponseV2 | VaultSwapStatusResponseV2;
468
468
 
469
469
  type RequestOptions = {
470
470
  signal?: AbortSignal;
@@ -494,6 +494,7 @@ declare class SwapSDK {
494
494
  private getBoostPoolsDepth;
495
495
  getAssets(chain?: Chain): Promise<AssetData[]>;
496
496
  getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
497
+ getQuoteV2(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponseV2>;
497
498
  requestDepositAddress(depositAddressRequest: DepositAddressRequest): Promise<DepositAddressResponse>;
498
499
  getStatus(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponse>;
499
500
  getStatusV2(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponseV2>;
@@ -519,4 +520,4 @@ declare class SwapSDK {
519
520
  }): Promise<BoostPoolDepth[]>;
520
521
  }
521
522
 
522
- export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type DepositAddressStatusResponseV2, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse, type VaultSwapStatusResponseV2 };
523
+ export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, type QuoteResponseV2, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse };
package/dist/swap.d.ts CHANGED
@@ -2,7 +2,6 @@ import { Signer } from 'ethers';
2
2
  import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-DmShvHR7.js';
3
3
  export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-DmShvHR7.js';
4
4
  import { z } from 'zod';
5
- import { SwapType } from '.prisma/client';
6
5
 
7
6
  declare const ccmParamsSchema: z.ZodObject<{
8
7
  gasBudget: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodString, `0x${string}`, string>]>, `0x${string}`, string>;
@@ -35,6 +34,17 @@ declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
35
34
  commissionBps: number;
36
35
  }>;
37
36
  type AffiliateBroker = z.input<typeof affiliateBroker>;
37
+ declare const dcaParams: z.ZodObject<{
38
+ numberOfChunks: z.ZodNumber;
39
+ chunkIntervalBlocks: z.ZodNumber;
40
+ }, "strip", z.ZodTypeAny, {
41
+ numberOfChunks: number;
42
+ chunkIntervalBlocks: number;
43
+ }, {
44
+ numberOfChunks: number;
45
+ chunkIntervalBlocks: number;
46
+ }>;
47
+ type DcaParams = z.input<typeof dcaParams>;
38
48
  declare const fillOrKillParams: z.ZodObject<{
39
49
  retryDurationBlocks: z.ZodNumber;
40
50
  refundAddress: z.ZodString;
@@ -52,10 +62,6 @@ type FillOrKillParamsX128 = z.input<typeof fillOrKillParams>;
52
62
  type FillOrKillParams = Omit<FillOrKillParamsX128, 'minPriceX128'> & {
53
63
  minPrice: string;
54
64
  };
55
- type DcaParams = {
56
- numberOfChunks: number;
57
- chunkInterval: number;
58
- };
59
65
  type Fee<T> = {
60
66
  type: T;
61
67
  chain: Chain;
@@ -84,6 +90,10 @@ type BoostedQuoteDetails = QuoteDetails & {
84
90
  };
85
91
  type QuoteQueryResponse = QuoteDetails & {
86
92
  boostQuote?: BoostedQuoteDetails;
93
+ dcaParams?: {
94
+ numberOfChunks: number;
95
+ chunkIntervalBlocks: number;
96
+ };
87
97
  };
88
98
 
89
99
  interface ExecuteSwapParams {
@@ -134,6 +144,9 @@ interface QuoteRequest extends ChainsAndAssets {
134
144
  interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
135
145
  quote: QuoteQueryResponse;
136
146
  }
147
+ interface QuoteResponseV2 extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
148
+ quotes: QuoteQueryResponse[];
149
+ }
137
150
  interface DepositAddressRequest extends QuoteRequest {
138
151
  destAddress: string;
139
152
  ccmParams?: CcmParams;
@@ -223,7 +236,7 @@ type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
223
236
  state: 'FAILED';
224
237
  depositAddress: undefined;
225
238
  }>;
226
- type SwapState$1 = {
239
+ type SwapState = {
227
240
  state: 'AWAITING_DEPOSIT';
228
241
  depositAmount: string | undefined;
229
242
  depositTransactionConfirmations: number | undefined;
@@ -310,8 +323,8 @@ type SwapState$1 = {
310
323
  egressIgnoredAt: number;
311
324
  egressIgnoredBlockIndex: string;
312
325
  };
313
- type DepositAddressStatusResponse = DepositAddressFields & SwapState$1;
314
- type VaultSwapStatusResponse = VaultSwapFields & SwapState$1;
326
+ type DepositAddressStatusResponse = DepositAddressFields & SwapState;
327
+ type VaultSwapStatusResponse = VaultSwapFields & SwapState;
315
328
  type SwapStatusResponse = DepositAddressStatusResponse | VaultSwapStatusResponse | FailedVaultSwapStatusResponse;
316
329
  type BoostPoolDepth = {
317
330
  feeTierBps: number;
@@ -327,16 +340,6 @@ declare enum FailureMode {
327
340
  BroadcastAborted = "SENDING_FAILED"
328
341
  }
329
342
 
330
- interface DcaParameters {
331
- numberOfChunks: number;
332
- chunkIntervalBlocks: string;
333
- }
334
- interface Ccm {
335
- message: string;
336
- gasBudget: string;
337
- cfParameters: string | undefined;
338
- ccmDepositReceivedBlockIndex: string | undefined;
339
- }
340
343
  interface Failure {
341
344
  failedAt: number;
342
345
  failedBlockIndex: string;
@@ -366,39 +369,51 @@ interface DepositChannelFields {
366
369
  openedThroughBackend: boolean;
367
370
  affiliateBrokers: AffiliateBroker[];
368
371
  fillOrKillParams: FillOrKillParams | undefined;
369
- dcaParams: DcaParameters | undefined;
372
+ dcaParams: DcaParams | undefined;
370
373
  }
371
374
  interface DepositFields {
372
375
  amount: string;
373
376
  txRef: string | undefined;
374
377
  txConfirmations: number | undefined;
375
- receivedAt: number | undefined;
376
- receivedBlockIndex: string | undefined;
378
+ witnessedAt: number | undefined;
379
+ witnessedBlockIndex: string | undefined;
377
380
  failure: Failure | undefined;
378
381
  failedAt: number | undefined;
379
382
  failedBlockIndex: string | undefined;
380
383
  }
381
- interface SwapChunk {
382
- swapInputAmount: string;
383
- swapOutputAmount: string | undefined;
384
- scheduledAt: number;
385
- scheduledBlockIndex: string;
386
- executedAt: number | undefined;
387
- executedBlockIndex: string | undefined;
388
- retryCount: number;
389
- latestSwapRescheduledAt: number | undefined;
390
- latestSwapRescheduledBlockIndex: number | undefined;
391
- fees: PaidFee[];
392
- isDca: false;
393
- }
394
384
  interface SwapFields {
395
- totalInputAmountSwapped: string | undefined;
396
- totalOutputAmountSwapped: string | undefined;
397
- totalChunksExecuted: number;
398
- isDca: true;
399
- lastExecutedChunk: SwapChunk | undefined;
400
- currentChunk: SwapChunk;
401
- type: SwapType;
385
+ originalInputAmount: string;
386
+ remainingInputAmount: string;
387
+ swappedInputAmount: string;
388
+ swappedOutputAmount: string;
389
+ regular?: {
390
+ inputAmount: string;
391
+ outputAmount: string;
392
+ scheduledAt: number;
393
+ scheduledBlockIndex: string;
394
+ executedAt?: number;
395
+ executedBlockIndex?: string;
396
+ retryCount: 0;
397
+ };
398
+ dca?: {
399
+ lastExecutedChunk: {
400
+ inputAmount: string;
401
+ outputAmount: string;
402
+ scheduledAt: number;
403
+ scheduledBlockIndex: string;
404
+ executedAt: number;
405
+ executedBlockIndex: string;
406
+ retryCount: number;
407
+ } | null;
408
+ currentChunk: {
409
+ inputAmount: string;
410
+ scheduledAt: number;
411
+ scheduledBlockIndex: string;
412
+ retryCount: number;
413
+ } | null;
414
+ executedChunks: number;
415
+ remainingChunks: number;
416
+ };
402
417
  fees: PaidFee[];
403
418
  }
404
419
  interface EgressFields {
@@ -406,9 +421,8 @@ interface EgressFields {
406
421
  scheduledAt: number;
407
422
  scheduledBlockIndex: string;
408
423
  txRef: string | undefined;
409
- confirmedAt: number | undefined;
410
- confirmedBlockIndex: string | undefined;
411
- ignoredAmount: string | undefined;
424
+ witnessedAt: number | undefined;
425
+ witnessedBlockIndex: string | undefined;
412
426
  failure: Failure | undefined;
413
427
  failedAt: number | undefined;
414
428
  failedBlockIndex: string | undefined;
@@ -416,27 +430,16 @@ interface EgressFields {
416
430
  interface SwapStatusResponseCommonFields extends ChainsAndAssets {
417
431
  swapId: string;
418
432
  destAddress: string;
419
- ccm: Ccm | undefined;
433
+ depositChannel: DepositChannelFields | undefined;
434
+ ccmParams: CcmParams | undefined;
420
435
  boost: Boost | undefined;
421
436
  estimatedDurationSeconds: number | null | undefined;
422
437
  srcChainRequiredBlockConfirmations: number | null;
423
438
  }
424
- interface VaultSwapCommonFields extends Exclude<SwapStatusResponseCommonFields, 'boost'> {
425
- }
426
- interface ReceivingVaultSwap extends VaultSwapCommonFields {
427
- deposit: DepositFields;
428
- }
429
- interface SwappingVaultSwap extends ReceivingVaultSwap {
430
- swap: Exclude<SwapChunk, 'latestSwapRescheduledAt' | 'latestSwapRescheduledBlockIndex'> | undefined;
431
- swapEgress: EgressFields | undefined;
432
- }
433
- interface SendingVaultSwap extends SwappingVaultSwap {
434
- swapEgress: EgressFields | undefined;
435
- }
436
- interface DepositChannel extends SwapStatusResponseCommonFields {
439
+ interface Waiting extends SwapStatusResponseCommonFields {
437
440
  depositChannel: DepositChannelFields;
438
441
  }
439
- interface Receiving extends DepositChannel {
442
+ interface Receiving extends SwapStatusResponseCommonFields {
440
443
  deposit: DepositFields;
441
444
  }
442
445
  interface Swapping extends Receiving {
@@ -447,9 +450,9 @@ interface Sending extends Receiving {
447
450
  swapEgress: EgressFields | undefined;
448
451
  refundEgress: EgressFields | undefined;
449
452
  }
450
- type SwapState = ({
453
+ type SwapStatusResponseV2 = ({
451
454
  state: 'WAITING';
452
- } & DepositChannel) | ({
455
+ } & Waiting) | ({
453
456
  state: 'RECEIVING';
454
457
  } & Receiving) | ({
455
458
  state: 'SWAPPING';
@@ -462,9 +465,6 @@ type SwapState = ({
462
465
  } & Sending) | ({
463
466
  state: 'FAILED';
464
467
  } & Sending);
465
- type DepositAddressStatusResponseV2 = SwapState;
466
- type VaultSwapStatusResponseV2 = SwapState & SendingVaultSwap;
467
- type SwapStatusResponseV2 = DepositAddressStatusResponseV2 | VaultSwapStatusResponseV2;
468
468
 
469
469
  type RequestOptions = {
470
470
  signal?: AbortSignal;
@@ -494,6 +494,7 @@ declare class SwapSDK {
494
494
  private getBoostPoolsDepth;
495
495
  getAssets(chain?: Chain): Promise<AssetData[]>;
496
496
  getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
497
+ getQuoteV2(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponseV2>;
497
498
  requestDepositAddress(depositAddressRequest: DepositAddressRequest): Promise<DepositAddressResponse>;
498
499
  getStatus(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponse>;
499
500
  getStatusV2(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponseV2>;
@@ -519,4 +520,4 @@ declare class SwapSDK {
519
520
  }): Promise<BoostPoolDepth[]>;
520
521
  }
521
522
 
522
- export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type DepositAddressStatusResponseV2, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse, type VaultSwapStatusResponseV2 };
523
+ export { Asset, type AssetData, type BoostPoolDepth, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type ChainsAndAssets, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, type QuoteResponseV2, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type SwapStatusResponseV2, type VaultSwapStatusResponse };
package/dist/swap.js CHANGED
@@ -6925,7 +6925,7 @@ var affiliateBroker = z.object({
6925
6925
  }));
6926
6926
  var dcaParams = z.object({
6927
6927
  numberOfChunks: number,
6928
- chunkInterval: number
6928
+ chunkIntervalBlocks: number
6929
6929
  });
6930
6930
  var fillOrKillParams = z.object({
6931
6931
  retryDurationBlocks: number,
@@ -6944,10 +6944,7 @@ z.object({
6944
6944
  maxBoostFeeBps: z.number().optional(),
6945
6945
  srcAddress: z.string().optional(),
6946
6946
  fillOrKillParams: fillOrKillParams.optional(),
6947
- dcaParams: z.object({
6948
- numberOfChunks: z.number(),
6949
- chunkInterval: z.number()
6950
- }).optional()
6947
+ dcaParams: dcaParams.optional()
6951
6948
  }).transform(({ amount, ...rest }) => ({
6952
6949
  ...rest,
6953
6950
  expectedDepositAmount: amount
@@ -6982,9 +6979,9 @@ var validateRequest = /* @__PURE__ */ __name((network, params) => z.tuple([
6982
6979
  refund_address: refundAddress,
6983
6980
  min_price: `0x${BigInt(minPriceX128).toString(16)}`
6984
6981
  })).optional(),
6985
- dcaParams.transform(({ numberOfChunks, chunkInterval }) => ({
6982
+ dcaParams.transform(({ numberOfChunks, chunkIntervalBlocks }) => ({
6986
6983
  number_of_chunks: numberOfChunks,
6987
- chunk_interval: chunkInterval
6984
+ chunk_interval: chunkIntervalBlocks
6988
6985
  })).optional()
6989
6986
  ]).parse(params), "validateRequest");
6990
6987
  var validateResponse = /* @__PURE__ */ __name((network, response) => z.object({
@@ -8421,6 +8418,9 @@ createRequest("state_getMetadata");
8421
8418
  var getSupportedAssets = createRequest("cf_supported_assets");
8422
8419
  createRequest("state_getRuntimeVersion");
8423
8420
  createRequest("chain_getBlockHash");
8421
+ createRequest("cf_pool_depth");
8422
+ createRequest("cf_accounts");
8423
+ createRequest("cf_account_info");
8424
8424
  var getAllBoostPoolsDepth = transform(createRequest("cf_boost_pools_depth"), (result) => result.map(({ chain: chain2, asset: asset2, ...rest }) => ({
8425
8425
  asset: getInternalAsset({
8426
8426
  chain: chain2,
@@ -10029,7 +10029,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
10029
10029
  }), "getChainData");
10030
10030
 
10031
10031
  // package.json
10032
- var version = "1.6.0-alpha.6";
10032
+ var version = "1.6.0-beta.0";
10033
10033
 
10034
10034
  // src/swap/consts.ts
10035
10035
  var CF_SDK_VERSION_HEADERS = {
@@ -10064,6 +10064,29 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
10064
10064
  quote: data
10065
10065
  };
10066
10066
  }, "getQuote");
10067
+ var getQuoteV2 = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
10068
+ const { brokerCommissionBps, ...returnedRequestData } = quoteRequest;
10069
+ const params = {
10070
+ amount: returnedRequestData.amount,
10071
+ srcChain: returnedRequestData.srcChain,
10072
+ srcAsset: returnedRequestData.srcAsset,
10073
+ destChain: returnedRequestData.destChain,
10074
+ destAsset: returnedRequestData.destAsset,
10075
+ ...brokerCommissionBps && {
10076
+ brokerCommissionBps: String(brokerCommissionBps)
10077
+ }
10078
+ };
10079
+ const { data } = await axios__default.default.get("/v2/quote", {
10080
+ baseURL: baseUrl,
10081
+ params,
10082
+ signal,
10083
+ headers: CF_SDK_VERSION_HEADERS
10084
+ });
10085
+ return {
10086
+ ...returnedRequestData,
10087
+ quotes: data
10088
+ };
10089
+ }, "getQuoteV2");
10067
10090
  var getStatus = /* @__PURE__ */ __name(async (baseUrl, { id }, { signal }) => {
10068
10091
  const { data } = await axios__default.default.get(`/swaps/${id}`, {
10069
10092
  baseURL: baseUrl,
@@ -10140,6 +10163,7 @@ var _SwapSDK = class _SwapSDK {
10140
10163
  ]);
10141
10164
  return supportedAssets.map((asset2) => getAssetData(asset2, this.options.network, env)).filter((asset2) => !chain2 || asset2.chain === chain2);
10142
10165
  }
10166
+ /** @deprecated DEPRECATED(1.6) use getQuoteV2() */
10143
10167
  getQuote(quoteRequest, options = {}) {
10144
10168
  const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
10145
10169
  const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
@@ -10149,6 +10173,15 @@ var _SwapSDK = class _SwapSDK {
10149
10173
  brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
10150
10174
  }, options);
10151
10175
  }
10176
+ getQuoteV2(quoteRequest, options = {}) {
10177
+ const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
10178
+ const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
10179
+ const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
10180
+ return getQuoteV2(this.options.backendUrl, {
10181
+ ...remainingRequest,
10182
+ brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
10183
+ }, options);
10184
+ }
10152
10185
  async requestDepositAddress(depositAddressRequest) {
10153
10186
  const { srcChain, srcAsset, amount, destChain, destAsset, brokerCommissionBps, affiliateBrokers } = depositAddressRequest;
10154
10187
  await this.validateSwapAmount({
package/dist/swap.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { __name, isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __publicField, assetConstants, getEnvironment, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, assert, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, getTokenContractAddress, isTestnet, getEvmChainId, chainConstants, checkAllowance, extractOverrides, Vault__factory } from './chunk-EHDVKR7F.mjs';
2
- export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-EHDVKR7F.mjs';
1
+ import { __name, isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __publicField, assetConstants, getEnvironment, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, assert, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, getTokenContractAddress, isTestnet, getEvmChainId, chainConstants, checkAllowance, extractOverrides, Vault__factory } from './chunk-35BXEUA4.mjs';
2
+ export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-35BXEUA4.mjs';
3
3
  import { HttpClient } from '@chainflip/rpc';
4
4
  import * as ss582 from '@chainflip/utils/ss58';
5
5
  import * as base58 from '@chainflip/utils/base58';
@@ -6650,7 +6650,7 @@ var affiliateBroker = z.object({
6650
6650
  }));
6651
6651
  var dcaParams = z.object({
6652
6652
  numberOfChunks: number,
6653
- chunkInterval: number
6653
+ chunkIntervalBlocks: number
6654
6654
  });
6655
6655
  var fillOrKillParams = z.object({
6656
6656
  retryDurationBlocks: number,
@@ -6669,10 +6669,7 @@ z.object({
6669
6669
  maxBoostFeeBps: z.number().optional(),
6670
6670
  srcAddress: z.string().optional(),
6671
6671
  fillOrKillParams: fillOrKillParams.optional(),
6672
- dcaParams: z.object({
6673
- numberOfChunks: z.number(),
6674
- chunkInterval: z.number()
6675
- }).optional()
6672
+ dcaParams: dcaParams.optional()
6676
6673
  }).transform(({ amount, ...rest }) => ({
6677
6674
  ...rest,
6678
6675
  expectedDepositAmount: amount
@@ -6707,9 +6704,9 @@ var validateRequest = /* @__PURE__ */ __name((network, params) => z.tuple([
6707
6704
  refund_address: refundAddress,
6708
6705
  min_price: `0x${BigInt(minPriceX128).toString(16)}`
6709
6706
  })).optional(),
6710
- dcaParams.transform(({ numberOfChunks, chunkInterval }) => ({
6707
+ dcaParams.transform(({ numberOfChunks, chunkIntervalBlocks }) => ({
6711
6708
  number_of_chunks: numberOfChunks,
6712
- chunk_interval: chunkInterval
6709
+ chunk_interval: chunkIntervalBlocks
6713
6710
  })).optional()
6714
6711
  ]).parse(params), "validateRequest");
6715
6712
  var validateResponse = /* @__PURE__ */ __name((network, response) => z.object({
@@ -8307,7 +8304,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
8307
8304
  }), "getChainData");
8308
8305
 
8309
8306
  // package.json
8310
- var version = "1.6.0-alpha.6";
8307
+ var version = "1.6.0-beta.0";
8311
8308
 
8312
8309
  // src/swap/consts.ts
8313
8310
  var CF_SDK_VERSION_HEADERS = {
@@ -8342,6 +8339,29 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
8342
8339
  quote: data
8343
8340
  };
8344
8341
  }, "getQuote");
8342
+ var getQuoteV2 = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
8343
+ const { brokerCommissionBps, ...returnedRequestData } = quoteRequest;
8344
+ const params = {
8345
+ amount: returnedRequestData.amount,
8346
+ srcChain: returnedRequestData.srcChain,
8347
+ srcAsset: returnedRequestData.srcAsset,
8348
+ destChain: returnedRequestData.destChain,
8349
+ destAsset: returnedRequestData.destAsset,
8350
+ ...brokerCommissionBps && {
8351
+ brokerCommissionBps: String(brokerCommissionBps)
8352
+ }
8353
+ };
8354
+ const { data } = await axios.get("/v2/quote", {
8355
+ baseURL: baseUrl,
8356
+ params,
8357
+ signal,
8358
+ headers: CF_SDK_VERSION_HEADERS
8359
+ });
8360
+ return {
8361
+ ...returnedRequestData,
8362
+ quotes: data
8363
+ };
8364
+ }, "getQuoteV2");
8345
8365
  var getStatus = /* @__PURE__ */ __name(async (baseUrl, { id }, { signal }) => {
8346
8366
  const { data } = await axios.get(`/swaps/${id}`, {
8347
8367
  baseURL: baseUrl,
@@ -8418,6 +8438,7 @@ var _SwapSDK = class _SwapSDK {
8418
8438
  ]);
8419
8439
  return supportedAssets.map((asset2) => getAssetData(asset2, this.options.network, env)).filter((asset2) => !chain2 || asset2.chain === chain2);
8420
8440
  }
8441
+ /** @deprecated DEPRECATED(1.6) use getQuoteV2() */
8421
8442
  getQuote(quoteRequest, options = {}) {
8422
8443
  const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
8423
8444
  const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
@@ -8427,6 +8448,15 @@ var _SwapSDK = class _SwapSDK {
8427
8448
  brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
8428
8449
  }, options);
8429
8450
  }
8451
+ getQuoteV2(quoteRequest, options = {}) {
8452
+ const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
8453
+ const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
8454
+ const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
8455
+ return getQuoteV2(this.options.backendUrl, {
8456
+ ...remainingRequest,
8457
+ brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
8458
+ }, options);
8459
+ }
8430
8460
  async requestDepositAddress(depositAddressRequest) {
8431
8461
  const { srcChain, srcAsset, amount, destChain, destAsset, brokerCommissionBps, affiliateBrokers } = depositAddressRequest;
8432
8462
  await this.validateSwapAmount({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "1.6.0-alpha.6",
3
+ "version": "1.6.0-beta.0",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@chainflip/rpc": "^1.6.3",
44
+ "@chainflip/rpc": "^1.6.6",
45
45
  "@chainflip/utils": "^0.4.0",
46
46
  "axios": "^1.7.7",
47
47
  "ethers": "^6.13.2"