@chainflip/sdk 1.6.7-rc.1 → 1.6.7-rc.3

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.mts CHANGED
@@ -84,8 +84,8 @@ type BoostedQuoteDetails = {
84
84
  interface BaseQuoteDetails {
85
85
  srcAsset: AssetAndChain;
86
86
  destAsset: AssetAndChain;
87
- intermediateAmount?: string;
88
87
  depositAmount: string;
88
+ intermediateAmount?: string;
89
89
  egressAmount: string;
90
90
  includedFees: SwapFee[];
91
91
  poolInfo: PoolInfo[];
@@ -481,6 +481,7 @@ type SwapStatusResponseV2 = ({
481
481
 
482
482
  interface DepositAddressRequestV2 {
483
483
  quote: Quote | BoostQuote;
484
+ srcAddress?: string;
484
485
  destAddress: string;
485
486
  fillOrKillParams?: FillOrKillParamsWithMinPrice | FillOrKillParamsWithSlippage$1;
486
487
  affiliateBrokers?: {
@@ -534,6 +535,12 @@ declare class SwapSDK {
534
535
  signer?: Signer;
535
536
  }): Promise<TransactionHash | null>;
536
537
  private validateSwapAmount;
538
+ approveAndExecuteSwap(params: ExecuteSwapParams, txOpts?: Omit<TransactionOptions, 'nonce'> & {
539
+ signer?: Signer;
540
+ }): Promise<{
541
+ approveTxRef: TransactionHash | null;
542
+ swapTxRef: TransactionHash | null;
543
+ }>;
537
544
  getSwapLimits(): Promise<{
538
545
  minimumSwapAmounts: ChainAssetMap<bigint>;
539
546
  maximumSwapAmounts: ChainAssetMap<bigint | null>;
@@ -547,7 +554,7 @@ declare class SwapSDK {
547
554
  asset: Asset;
548
555
  chain: Chain;
549
556
  }): Promise<BoostPoolDepth[]>;
550
- requestDepositAddressV2({ quote, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps, }: DepositAddressRequestV2): Promise<{
557
+ requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps, }: DepositAddressRequestV2): Promise<{
551
558
  depositChannelId: string;
552
559
  depositAddress: string;
553
560
  brokerCommissionBps: number;
@@ -564,6 +571,7 @@ declare class SwapSDK {
564
571
  srcChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana";
565
572
  destAsset: "FLIP" | "USDC" | "DOT" | "ETH" | "BTC" | "USDT" | "SOL";
566
573
  destChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana";
574
+ srcAddress: string | undefined;
567
575
  destAddress: string;
568
576
  dcaParams: {
569
577
  numberOfChunks: number;
package/dist/swap.d.ts CHANGED
@@ -84,8 +84,8 @@ type BoostedQuoteDetails = {
84
84
  interface BaseQuoteDetails {
85
85
  srcAsset: AssetAndChain;
86
86
  destAsset: AssetAndChain;
87
- intermediateAmount?: string;
88
87
  depositAmount: string;
88
+ intermediateAmount?: string;
89
89
  egressAmount: string;
90
90
  includedFees: SwapFee[];
91
91
  poolInfo: PoolInfo[];
@@ -481,6 +481,7 @@ type SwapStatusResponseV2 = ({
481
481
 
482
482
  interface DepositAddressRequestV2 {
483
483
  quote: Quote | BoostQuote;
484
+ srcAddress?: string;
484
485
  destAddress: string;
485
486
  fillOrKillParams?: FillOrKillParamsWithMinPrice | FillOrKillParamsWithSlippage$1;
486
487
  affiliateBrokers?: {
@@ -534,6 +535,12 @@ declare class SwapSDK {
534
535
  signer?: Signer;
535
536
  }): Promise<TransactionHash | null>;
536
537
  private validateSwapAmount;
538
+ approveAndExecuteSwap(params: ExecuteSwapParams, txOpts?: Omit<TransactionOptions, 'nonce'> & {
539
+ signer?: Signer;
540
+ }): Promise<{
541
+ approveTxRef: TransactionHash | null;
542
+ swapTxRef: TransactionHash | null;
543
+ }>;
537
544
  getSwapLimits(): Promise<{
538
545
  minimumSwapAmounts: ChainAssetMap<bigint>;
539
546
  maximumSwapAmounts: ChainAssetMap<bigint | null>;
@@ -547,7 +554,7 @@ declare class SwapSDK {
547
554
  asset: Asset;
548
555
  chain: Chain;
549
556
  }): Promise<BoostPoolDepth[]>;
550
- requestDepositAddressV2({ quote, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps, }: DepositAddressRequestV2): Promise<{
557
+ requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps, }: DepositAddressRequestV2): Promise<{
551
558
  depositChannelId: string;
552
559
  depositAddress: string;
553
560
  brokerCommissionBps: number;
@@ -564,6 +571,7 @@ declare class SwapSDK {
564
571
  srcChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana";
565
572
  destAsset: "FLIP" | "USDC" | "DOT" | "ETH" | "BTC" | "USDT" | "SOL";
566
573
  destChain: "Bitcoin" | "Ethereum" | "Polkadot" | "Arbitrum" | "Solana";
574
+ srcAddress: string | undefined;
567
575
  destAddress: string;
568
576
  dcaParams: {
569
577
  numberOfChunks: number;
package/dist/swap.js CHANGED
@@ -12122,7 +12122,12 @@ z.object({
12122
12122
  maxBoostFeeBps: z.number().optional(),
12123
12123
  srcAddress: z.string().optional(),
12124
12124
  fillOrKillParams: fillOrKillParams.optional(),
12125
- dcaParams: dcaParams.optional()
12125
+ dcaParams: dcaParams.optional(),
12126
+ quote: z.object({
12127
+ intermediateAmount: z.string().optional(),
12128
+ egressAmount: z.string(),
12129
+ estimatedPrice: z.string()
12130
+ }).optional()
12126
12131
  }).superRefine(ensureDcaWithFok).transform(({ amount, ...rest }) => ({
12127
12132
  ...rest,
12128
12133
  expectedDepositAmount: amount
@@ -14043,7 +14048,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
14043
14048
  }), "getChainData");
14044
14049
 
14045
14050
  // package.json
14046
- var version = "1.6.7-rc.1";
14051
+ var version = "1.6.7-rc.3";
14047
14052
 
14048
14053
  // src/swap/consts.ts
14049
14054
  var CF_SDK_VERSION_HEADERS = {
@@ -14311,6 +14316,30 @@ var _SwapSDK = class _SwapSDK {
14311
14316
  const result = validateSwapAmount(stateChainEnv, internalAsset, amount);
14312
14317
  if (!result.success) throw new Error(result.reason);
14313
14318
  }
14319
+ async approveAndExecuteSwap(params, txOpts = {}) {
14320
+ const { srcChain, srcAsset } = params;
14321
+ const signer = txOpts.signer ?? this.options.signer;
14322
+ assert2(signer, "No signer provided");
14323
+ const internalAsset = getInternalAsset({
14324
+ chain: srcChain,
14325
+ asset: srcAsset
14326
+ });
14327
+ let approveTxRef = null;
14328
+ if (!isGasAsset(internalAsset)) {
14329
+ approveTxRef = await this.approveVault(params, {
14330
+ ...txOpts,
14331
+ nonce: void 0
14332
+ });
14333
+ }
14334
+ const swapTxRef = await this.executeSwap(params, {
14335
+ ...txOpts,
14336
+ nonce: void 0
14337
+ });
14338
+ return {
14339
+ approveTxRef,
14340
+ swapTxRef
14341
+ };
14342
+ }
14314
14343
  async getSwapLimits() {
14315
14344
  const { swapping: { maximumSwapAmounts }, ingressEgress: { minimumDepositAmounts } } = await this.getStateChainEnvironment();
14316
14345
  return {
@@ -14348,7 +14377,7 @@ var _SwapSDK = class _SwapSDK {
14348
14377
  ...getAssetAndChain(depth.asset)
14349
14378
  }));
14350
14379
  }
14351
- async requestDepositAddressV2({ quote, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps }) {
14380
+ async requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps }) {
14352
14381
  await this.validateSwapAmount(quote.srcAsset, BigInt(quote.depositAmount));
14353
14382
  assertQuoteValid(quote);
14354
14383
  const depositAddressRequest = {
@@ -14356,6 +14385,7 @@ var _SwapSDK = class _SwapSDK {
14356
14385
  srcChain: quote.srcAsset.chain,
14357
14386
  destAsset: quote.destAsset.asset,
14358
14387
  destChain: quote.destAsset.chain,
14388
+ srcAddress,
14359
14389
  destAddress,
14360
14390
  dcaParams: quote.type === "DCA" ? quote.dcaParams : void 0,
14361
14391
  fillOrKillParams: parseFoKParams(inputFoKParams, quote),
@@ -14381,7 +14411,10 @@ var _SwapSDK = class _SwapSDK {
14381
14411
  channelOpeningFee: result.channelOpeningFee
14382
14412
  };
14383
14413
  } else {
14384
- response = await this.trpc.openSwapDepositChannel.mutate(depositAddressRequest);
14414
+ response = await this.trpc.openSwapDepositChannel.mutate({
14415
+ ...depositAddressRequest,
14416
+ quote
14417
+ });
14385
14418
  }
14386
14419
  return {
14387
14420
  ...depositAddressRequest,
package/dist/swap.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { __commonJS, __name, __export, __toESM, isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __publicField, assert, getEnvironment, assetConstants, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, getTokenContractAddress, isTestnet, getEvmChainId, chainConstants, checkAllowance, extractOverrides, Vault__factory } from './chunk-G76RI3QK.mjs';
1
+ import { __commonJS, __name, __export, __toESM, isString, InternalAssets, Chains, Assets, ChainflipNetworks, isValidAssetAndChain, getInternalAssets, __publicField, assert, getEnvironment, assetConstants, getSupportedAssets, getInternalAsset, isNotNullish, getAllBoostPoolsDepth, getAssetAndChain, readChainAssetValue, getVaultContractAddress, approve, chainConstants, getTokenContractAddress, isTestnet, getEvmChainId, checkAllowance, extractOverrides, Vault__factory } from './chunk-G76RI3QK.mjs';
2
2
  export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-G76RI3QK.mjs';
3
3
  import { assert as assert$1 } from '@chainflip/utils/assertion';
4
4
  import { hexToBytes, bytesToHex } from '@chainflip/utils/bytes';
@@ -11818,7 +11818,12 @@ z.object({
11818
11818
  maxBoostFeeBps: z.number().optional(),
11819
11819
  srcAddress: z.string().optional(),
11820
11820
  fillOrKillParams: fillOrKillParams.optional(),
11821
- dcaParams: dcaParams.optional()
11821
+ dcaParams: dcaParams.optional(),
11822
+ quote: z.object({
11823
+ intermediateAmount: z.string().optional(),
11824
+ egressAmount: z.string(),
11825
+ estimatedPrice: z.string()
11826
+ }).optional()
11822
11827
  }).superRefine(ensureDcaWithFok).transform(({ amount, ...rest }) => ({
11823
11828
  ...rest,
11824
11829
  expectedDepositAmount: amount
@@ -12289,7 +12294,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
12289
12294
  }), "getChainData");
12290
12295
 
12291
12296
  // package.json
12292
- var version = "1.6.7-rc.1";
12297
+ var version = "1.6.7-rc.3";
12293
12298
 
12294
12299
  // src/swap/consts.ts
12295
12300
  var CF_SDK_VERSION_HEADERS = {
@@ -12557,6 +12562,30 @@ var _SwapSDK = class _SwapSDK {
12557
12562
  const result = validateSwapAmount(stateChainEnv, internalAsset, amount);
12558
12563
  if (!result.success) throw new Error(result.reason);
12559
12564
  }
12565
+ async approveAndExecuteSwap(params, txOpts = {}) {
12566
+ const { srcChain, srcAsset } = params;
12567
+ const signer = txOpts.signer ?? this.options.signer;
12568
+ assert(signer, "No signer provided");
12569
+ const internalAsset = getInternalAsset({
12570
+ chain: srcChain,
12571
+ asset: srcAsset
12572
+ });
12573
+ let approveTxRef = null;
12574
+ if (!isGasAsset(internalAsset)) {
12575
+ approveTxRef = await this.approveVault(params, {
12576
+ ...txOpts,
12577
+ nonce: void 0
12578
+ });
12579
+ }
12580
+ const swapTxRef = await this.executeSwap(params, {
12581
+ ...txOpts,
12582
+ nonce: void 0
12583
+ });
12584
+ return {
12585
+ approveTxRef,
12586
+ swapTxRef
12587
+ };
12588
+ }
12560
12589
  async getSwapLimits() {
12561
12590
  const { swapping: { maximumSwapAmounts }, ingressEgress: { minimumDepositAmounts } } = await this.getStateChainEnvironment();
12562
12591
  return {
@@ -12594,7 +12623,7 @@ var _SwapSDK = class _SwapSDK {
12594
12623
  ...getAssetAndChain(depth.asset)
12595
12624
  }));
12596
12625
  }
12597
- async requestDepositAddressV2({ quote, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps }) {
12626
+ async requestDepositAddressV2({ quote, srcAddress, destAddress, fillOrKillParams: inputFoKParams, affiliateBrokers: affiliates, ccmParams, brokerCommissionBps }) {
12598
12627
  await this.validateSwapAmount(quote.srcAsset, BigInt(quote.depositAmount));
12599
12628
  assertQuoteValid(quote);
12600
12629
  const depositAddressRequest = {
@@ -12602,6 +12631,7 @@ var _SwapSDK = class _SwapSDK {
12602
12631
  srcChain: quote.srcAsset.chain,
12603
12632
  destAsset: quote.destAsset.asset,
12604
12633
  destChain: quote.destAsset.chain,
12634
+ srcAddress,
12605
12635
  destAddress,
12606
12636
  dcaParams: quote.type === "DCA" ? quote.dcaParams : void 0,
12607
12637
  fillOrKillParams: parseFoKParams(inputFoKParams, quote),
@@ -12627,7 +12657,10 @@ var _SwapSDK = class _SwapSDK {
12627
12657
  channelOpeningFee: result.channelOpeningFee
12628
12658
  };
12629
12659
  } else {
12630
- response = await this.trpc.openSwapDepositChannel.mutate(depositAddressRequest);
12660
+ response = await this.trpc.openSwapDepositChannel.mutate({
12661
+ ...depositAddressRequest,
12662
+ quote
12663
+ });
12631
12664
  }
12632
12665
  return {
12633
12666
  ...depositAddressRequest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "1.6.7-rc.1",
3
+ "version": "1.6.7-rc.3",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {
@@ -49,7 +49,7 @@
49
49
  "ethers": "^6.13.3"
50
50
  },
51
51
  "devDependencies": {
52
- "tsup": "^8.2.4"
52
+ "tsup": "^8.3.0"
53
53
  },
54
54
  "scripts": {
55
55
  "test": "jest --forceExit",