@meteora-ag/zap-sdk 1.2.0-rc.1 → 1.2.0-rc.2

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/index.js CHANGED
@@ -3863,21 +3863,103 @@ var Zap = class {
3863
3863
  )
3864
3864
  );
3865
3865
  const swapAmountToB = amountIn.sub(swapAmountToA);
3866
- const MIN_SWAP_AMOUNT = new import_anchor.BN(1e5);
3867
- let finalSwapAmountToA = swapAmountToA;
3868
- let finalSwapAmountToB = swapAmountToB;
3869
- if (swapAmountToB.lt(MIN_SWAP_AMOUNT) && amountIn.gt(MIN_SWAP_AMOUNT.muln(2))) {
3870
- finalSwapAmountToB = MIN_SWAP_AMOUNT;
3871
- finalSwapAmountToA = amountIn.sub(MIN_SWAP_AMOUNT);
3872
- } else if (swapAmountToA.lt(MIN_SWAP_AMOUNT) && amountIn.gt(MIN_SWAP_AMOUNT.muln(2))) {
3873
- finalSwapAmountToA = MIN_SWAP_AMOUNT;
3874
- finalSwapAmountToB = amountIn.sub(MIN_SWAP_AMOUNT);
3866
+ if (swapAmountToA.isZero()) {
3867
+ const { transaction: swapToBTransaction2, quoteResponse: swapToBQuote2 } = yield buildJupiterSwapTransaction(
3868
+ user,
3869
+ inputTokenMint,
3870
+ tokenBMint,
3871
+ swapAmountToB,
3872
+ maxAccounts,
3873
+ slippageBps,
3874
+ void 0,
3875
+ {
3876
+ jupiterApiUrl: this.jupiterApiUrl,
3877
+ jupiterApiKey: this.jupiterApiKey
3878
+ }
3879
+ );
3880
+ return {
3881
+ user,
3882
+ pool,
3883
+ position,
3884
+ positionNftAccount,
3885
+ maxSqrtPriceChangeBps,
3886
+ amount: new import_anchor.BN(0),
3887
+ isDirectPool: false,
3888
+ tokenAMint,
3889
+ tokenBMint,
3890
+ tokenAVault,
3891
+ tokenBVault,
3892
+ tokenAProgram,
3893
+ tokenBProgram,
3894
+ maxTransferAmountA: new import_anchor.BN(0),
3895
+ maxTransferAmountB: getExtendMaxAmountTransfer(
3896
+ swapToBQuote2.outAmount,
3897
+ maxTransferAmountExtendPercentage
3898
+ ),
3899
+ swapType: 1 /* swapToB */,
3900
+ preSqrtPrice: poolState.sqrtPrice,
3901
+ preInstructions,
3902
+ swapTransactions: [swapToBTransaction2],
3903
+ cleanUpInstructions,
3904
+ swapInEstimate: {
3905
+ inAmountA: new import_anchor.BN(0),
3906
+ inAmountB: swapAmountToB,
3907
+ routeA: "dammV2" /* DammV2 */,
3908
+ routeB: "jupiter" /* Jupiter */
3909
+ }
3910
+ };
3911
+ }
3912
+ if (swapAmountToB.isZero()) {
3913
+ const { transaction: swapToATransaction2, quoteResponse: swapToAQuote2 } = yield buildJupiterSwapTransaction(
3914
+ user,
3915
+ inputTokenMint,
3916
+ tokenAMint,
3917
+ swapAmountToA,
3918
+ maxAccounts,
3919
+ slippageBps,
3920
+ void 0,
3921
+ {
3922
+ jupiterApiUrl: this.jupiterApiUrl,
3923
+ jupiterApiKey: this.jupiterApiKey
3924
+ }
3925
+ );
3926
+ return {
3927
+ user,
3928
+ pool,
3929
+ position,
3930
+ positionNftAccount,
3931
+ maxSqrtPriceChangeBps,
3932
+ amount: new import_anchor.BN(0),
3933
+ isDirectPool: false,
3934
+ tokenAMint,
3935
+ tokenBMint,
3936
+ tokenAVault,
3937
+ tokenBVault,
3938
+ tokenAProgram,
3939
+ tokenBProgram,
3940
+ maxTransferAmountA: getExtendMaxAmountTransfer(
3941
+ swapToAQuote2.outAmount,
3942
+ maxTransferAmountExtendPercentage
3943
+ ),
3944
+ maxTransferAmountB: new import_anchor.BN(0),
3945
+ swapType: 0 /* swapToA */,
3946
+ preSqrtPrice: poolState.sqrtPrice,
3947
+ preInstructions,
3948
+ swapTransactions: [swapToATransaction2],
3949
+ cleanUpInstructions,
3950
+ swapInEstimate: {
3951
+ inAmountA: swapAmountToA,
3952
+ inAmountB: new import_anchor.BN(0),
3953
+ routeA: "jupiter" /* Jupiter */,
3954
+ routeB: "dammV2" /* DammV2 */
3955
+ }
3956
+ };
3875
3957
  }
3876
3958
  const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
3877
3959
  user,
3878
3960
  inputTokenMint,
3879
3961
  tokenAMint,
3880
- finalSwapAmountToA,
3962
+ swapAmountToA,
3881
3963
  maxAccounts,
3882
3964
  slippageBps,
3883
3965
  void 0,
@@ -3890,7 +3972,7 @@ var Zap = class {
3890
3972
  user,
3891
3973
  inputTokenMint,
3892
3974
  tokenBMint,
3893
- finalSwapAmountToB,
3975
+ swapAmountToB,
3894
3976
  maxAccounts,
3895
3977
  slippageBps,
3896
3978
  void 0,
@@ -3927,8 +4009,8 @@ var Zap = class {
3927
4009
  swapTransactions: [swapToATransaction, swapToBTransaction],
3928
4010
  cleanUpInstructions,
3929
4011
  swapInEstimate: {
3930
- inAmountA: finalSwapAmountToA,
3931
- inAmountB: finalSwapAmountToB,
4012
+ inAmountA: swapAmountToA,
4013
+ inAmountB: swapAmountToB,
3932
4014
  routeA: "jupiter" /* Jupiter */,
3933
4015
  routeB: "jupiter" /* Jupiter */
3934
4016
  }
package/dist/index.mjs CHANGED
@@ -3842,21 +3842,103 @@ var Zap = class {
3842
3842
  )
3843
3843
  );
3844
3844
  const swapAmountToB = amountIn.sub(swapAmountToA);
3845
- const MIN_SWAP_AMOUNT = new BN5(1e5);
3846
- let finalSwapAmountToA = swapAmountToA;
3847
- let finalSwapAmountToB = swapAmountToB;
3848
- if (swapAmountToB.lt(MIN_SWAP_AMOUNT) && amountIn.gt(MIN_SWAP_AMOUNT.muln(2))) {
3849
- finalSwapAmountToB = MIN_SWAP_AMOUNT;
3850
- finalSwapAmountToA = amountIn.sub(MIN_SWAP_AMOUNT);
3851
- } else if (swapAmountToA.lt(MIN_SWAP_AMOUNT) && amountIn.gt(MIN_SWAP_AMOUNT.muln(2))) {
3852
- finalSwapAmountToA = MIN_SWAP_AMOUNT;
3853
- finalSwapAmountToB = amountIn.sub(MIN_SWAP_AMOUNT);
3845
+ if (swapAmountToA.isZero()) {
3846
+ const { transaction: swapToBTransaction2, quoteResponse: swapToBQuote2 } = yield buildJupiterSwapTransaction(
3847
+ user,
3848
+ inputTokenMint,
3849
+ tokenBMint,
3850
+ swapAmountToB,
3851
+ maxAccounts,
3852
+ slippageBps,
3853
+ void 0,
3854
+ {
3855
+ jupiterApiUrl: this.jupiterApiUrl,
3856
+ jupiterApiKey: this.jupiterApiKey
3857
+ }
3858
+ );
3859
+ return {
3860
+ user,
3861
+ pool,
3862
+ position,
3863
+ positionNftAccount,
3864
+ maxSqrtPriceChangeBps,
3865
+ amount: new BN5(0),
3866
+ isDirectPool: false,
3867
+ tokenAMint,
3868
+ tokenBMint,
3869
+ tokenAVault,
3870
+ tokenBVault,
3871
+ tokenAProgram,
3872
+ tokenBProgram,
3873
+ maxTransferAmountA: new BN5(0),
3874
+ maxTransferAmountB: getExtendMaxAmountTransfer(
3875
+ swapToBQuote2.outAmount,
3876
+ maxTransferAmountExtendPercentage
3877
+ ),
3878
+ swapType: 1 /* swapToB */,
3879
+ preSqrtPrice: poolState.sqrtPrice,
3880
+ preInstructions,
3881
+ swapTransactions: [swapToBTransaction2],
3882
+ cleanUpInstructions,
3883
+ swapInEstimate: {
3884
+ inAmountA: new BN5(0),
3885
+ inAmountB: swapAmountToB,
3886
+ routeA: "dammV2" /* DammV2 */,
3887
+ routeB: "jupiter" /* Jupiter */
3888
+ }
3889
+ };
3890
+ }
3891
+ if (swapAmountToB.isZero()) {
3892
+ const { transaction: swapToATransaction2, quoteResponse: swapToAQuote2 } = yield buildJupiterSwapTransaction(
3893
+ user,
3894
+ inputTokenMint,
3895
+ tokenAMint,
3896
+ swapAmountToA,
3897
+ maxAccounts,
3898
+ slippageBps,
3899
+ void 0,
3900
+ {
3901
+ jupiterApiUrl: this.jupiterApiUrl,
3902
+ jupiterApiKey: this.jupiterApiKey
3903
+ }
3904
+ );
3905
+ return {
3906
+ user,
3907
+ pool,
3908
+ position,
3909
+ positionNftAccount,
3910
+ maxSqrtPriceChangeBps,
3911
+ amount: new BN5(0),
3912
+ isDirectPool: false,
3913
+ tokenAMint,
3914
+ tokenBMint,
3915
+ tokenAVault,
3916
+ tokenBVault,
3917
+ tokenAProgram,
3918
+ tokenBProgram,
3919
+ maxTransferAmountA: getExtendMaxAmountTransfer(
3920
+ swapToAQuote2.outAmount,
3921
+ maxTransferAmountExtendPercentage
3922
+ ),
3923
+ maxTransferAmountB: new BN5(0),
3924
+ swapType: 0 /* swapToA */,
3925
+ preSqrtPrice: poolState.sqrtPrice,
3926
+ preInstructions,
3927
+ swapTransactions: [swapToATransaction2],
3928
+ cleanUpInstructions,
3929
+ swapInEstimate: {
3930
+ inAmountA: swapAmountToA,
3931
+ inAmountB: new BN5(0),
3932
+ routeA: "jupiter" /* Jupiter */,
3933
+ routeB: "dammV2" /* DammV2 */
3934
+ }
3935
+ };
3854
3936
  }
3855
3937
  const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
3856
3938
  user,
3857
3939
  inputTokenMint,
3858
3940
  tokenAMint,
3859
- finalSwapAmountToA,
3941
+ swapAmountToA,
3860
3942
  maxAccounts,
3861
3943
  slippageBps,
3862
3944
  void 0,
@@ -3869,7 +3951,7 @@ var Zap = class {
3869
3951
  user,
3870
3952
  inputTokenMint,
3871
3953
  tokenBMint,
3872
- finalSwapAmountToB,
3954
+ swapAmountToB,
3873
3955
  maxAccounts,
3874
3956
  slippageBps,
3875
3957
  void 0,
@@ -3906,8 +3988,8 @@ var Zap = class {
3906
3988
  swapTransactions: [swapToATransaction, swapToBTransaction],
3907
3989
  cleanUpInstructions,
3908
3990
  swapInEstimate: {
3909
- inAmountA: finalSwapAmountToA,
3910
- inAmountB: finalSwapAmountToB,
3991
+ inAmountA: swapAmountToA,
3992
+ inAmountB: swapAmountToB,
3911
3993
  routeA: "jupiter" /* Jupiter */,
3912
3994
  routeB: "jupiter" /* Jupiter */
3913
3995
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteora-ag/zap-sdk",
3
- "version": "1.2.0-rc.1",
3
+ "version": "1.2.0-rc.2",
4
4
  "description": "A Typescript SDK for interacting with the Zap program on Meteora.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -32,17 +32,17 @@
32
32
  "@types/bn.js": "^5.1.0",
33
33
  "@types/bun": "latest",
34
34
  "@types/invariant": "^2.2.37",
35
- "bip39": "^3.1.0",
36
- "ed25519-hd-key": "^1.3.0",
37
35
  "tsup": "^8.4.0",
38
- "tsx": "^4.20.3"
36
+ "tsx": "^4.20.3",
37
+ "bip39": "^3.1.0",
38
+ "ed25519-hd-key": "^1.3.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "typescript": "^5"
42
42
  },
43
43
  "dependencies": {
44
44
  "@coral-xyz/anchor": "^0.31.1",
45
- "@meteora-ag/cp-amm-sdk": "^1.3.6",
45
+ "@meteora-ag/cp-amm-sdk": "^1.2.3",
46
46
  "@meteora-ag/dlmm": "^1.9.0",
47
47
  "@solana/spl-token": "^0.4.13",
48
48
  "@solana/web3.js": "^1.98.2",