@meteora-ag/zap-sdk 1.2.0-rc.0 → 1.2.0-rc.1
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 +13 -102
- package/dist/index.mjs +13 -102
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3863,110 +3863,21 @@ var Zap = class {
|
|
|
3863
3863
|
)
|
|
3864
3864
|
);
|
|
3865
3865
|
const swapAmountToB = amountIn.sub(swapAmountToA);
|
|
3866
|
-
const MIN_SWAP_AMOUNT = new import_anchor.BN(
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
amountIn,
|
|
3876
|
-
maxAccounts,
|
|
3877
|
-
slippageBps,
|
|
3878
|
-
void 0,
|
|
3879
|
-
{
|
|
3880
|
-
jupiterApiUrl: this.jupiterApiUrl,
|
|
3881
|
-
jupiterApiKey: this.jupiterApiKey
|
|
3882
|
-
}
|
|
3883
|
-
);
|
|
3884
|
-
return {
|
|
3885
|
-
user,
|
|
3886
|
-
pool,
|
|
3887
|
-
position,
|
|
3888
|
-
positionNftAccount,
|
|
3889
|
-
maxSqrtPriceChangeBps,
|
|
3890
|
-
amount: new import_anchor.BN(0),
|
|
3891
|
-
isDirectPool: false,
|
|
3892
|
-
tokenAMint,
|
|
3893
|
-
tokenBMint,
|
|
3894
|
-
tokenAVault,
|
|
3895
|
-
tokenBVault,
|
|
3896
|
-
tokenAProgram,
|
|
3897
|
-
tokenBProgram,
|
|
3898
|
-
maxTransferAmountA: getExtendMaxAmountTransfer(
|
|
3899
|
-
swapToAQuote2.outAmount,
|
|
3900
|
-
maxTransferAmountExtendPercentage
|
|
3901
|
-
),
|
|
3902
|
-
swapType: 0 /* swapToA */,
|
|
3903
|
-
maxTransferAmountB: new import_anchor.BN(0),
|
|
3904
|
-
preSqrtPrice: poolState.sqrtPrice,
|
|
3905
|
-
preInstructions,
|
|
3906
|
-
swapTransactions: [swapTransaction],
|
|
3907
|
-
cleanUpInstructions,
|
|
3908
|
-
swapInEstimate: {
|
|
3909
|
-
inAmountA: amountIn,
|
|
3910
|
-
inAmountB: new import_anchor.BN(0),
|
|
3911
|
-
routeA: "jupiter" /* Jupiter */,
|
|
3912
|
-
routeB: "dammV2" /* DammV2 */
|
|
3913
|
-
}
|
|
3914
|
-
};
|
|
3915
|
-
}
|
|
3916
|
-
if (swapAmountToA.lt(MIN_SWAP_AMOUNT)) {
|
|
3917
|
-
const {
|
|
3918
|
-
transaction: swapTransaction,
|
|
3919
|
-
quoteResponse: swapToBQuote2
|
|
3920
|
-
} = yield buildJupiterSwapTransaction(
|
|
3921
|
-
user,
|
|
3922
|
-
inputTokenMint,
|
|
3923
|
-
tokenBMint,
|
|
3924
|
-
amountIn,
|
|
3925
|
-
maxAccounts,
|
|
3926
|
-
slippageBps,
|
|
3927
|
-
void 0,
|
|
3928
|
-
{
|
|
3929
|
-
jupiterApiUrl: this.jupiterApiUrl,
|
|
3930
|
-
jupiterApiKey: this.jupiterApiKey
|
|
3931
|
-
}
|
|
3932
|
-
);
|
|
3933
|
-
return {
|
|
3934
|
-
user,
|
|
3935
|
-
pool,
|
|
3936
|
-
position,
|
|
3937
|
-
positionNftAccount,
|
|
3938
|
-
maxSqrtPriceChangeBps,
|
|
3939
|
-
amount: new import_anchor.BN(0),
|
|
3940
|
-
isDirectPool: false,
|
|
3941
|
-
tokenAMint,
|
|
3942
|
-
tokenBMint,
|
|
3943
|
-
tokenAVault,
|
|
3944
|
-
tokenBVault,
|
|
3945
|
-
tokenAProgram,
|
|
3946
|
-
tokenBProgram,
|
|
3947
|
-
maxTransferAmountA: new import_anchor.BN(0),
|
|
3948
|
-
maxTransferAmountB: getExtendMaxAmountTransfer(
|
|
3949
|
-
swapToBQuote2.outAmount,
|
|
3950
|
-
maxTransferAmountExtendPercentage
|
|
3951
|
-
),
|
|
3952
|
-
swapType: 1 /* swapToB */,
|
|
3953
|
-
preSqrtPrice: poolState.sqrtPrice,
|
|
3954
|
-
preInstructions,
|
|
3955
|
-
swapTransactions: [swapTransaction],
|
|
3956
|
-
cleanUpInstructions,
|
|
3957
|
-
swapInEstimate: {
|
|
3958
|
-
inAmountA: new import_anchor.BN(0),
|
|
3959
|
-
inAmountB: amountIn,
|
|
3960
|
-
routeA: "dammV2" /* DammV2 */,
|
|
3961
|
-
routeB: "jupiter" /* Jupiter */
|
|
3962
|
-
}
|
|
3963
|
-
};
|
|
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);
|
|
3964
3875
|
}
|
|
3965
3876
|
const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
|
|
3966
3877
|
user,
|
|
3967
3878
|
inputTokenMint,
|
|
3968
3879
|
tokenAMint,
|
|
3969
|
-
|
|
3880
|
+
finalSwapAmountToA,
|
|
3970
3881
|
maxAccounts,
|
|
3971
3882
|
slippageBps,
|
|
3972
3883
|
void 0,
|
|
@@ -3979,7 +3890,7 @@ var Zap = class {
|
|
|
3979
3890
|
user,
|
|
3980
3891
|
inputTokenMint,
|
|
3981
3892
|
tokenBMint,
|
|
3982
|
-
|
|
3893
|
+
finalSwapAmountToB,
|
|
3983
3894
|
maxAccounts,
|
|
3984
3895
|
slippageBps,
|
|
3985
3896
|
void 0,
|
|
@@ -4016,8 +3927,8 @@ var Zap = class {
|
|
|
4016
3927
|
swapTransactions: [swapToATransaction, swapToBTransaction],
|
|
4017
3928
|
cleanUpInstructions,
|
|
4018
3929
|
swapInEstimate: {
|
|
4019
|
-
inAmountA:
|
|
4020
|
-
inAmountB:
|
|
3930
|
+
inAmountA: finalSwapAmountToA,
|
|
3931
|
+
inAmountB: finalSwapAmountToB,
|
|
4021
3932
|
routeA: "jupiter" /* Jupiter */,
|
|
4022
3933
|
routeB: "jupiter" /* Jupiter */
|
|
4023
3934
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -3842,110 +3842,21 @@ var Zap = class {
|
|
|
3842
3842
|
)
|
|
3843
3843
|
);
|
|
3844
3844
|
const swapAmountToB = amountIn.sub(swapAmountToA);
|
|
3845
|
-
const MIN_SWAP_AMOUNT = new BN5(
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
amountIn,
|
|
3855
|
-
maxAccounts,
|
|
3856
|
-
slippageBps,
|
|
3857
|
-
void 0,
|
|
3858
|
-
{
|
|
3859
|
-
jupiterApiUrl: this.jupiterApiUrl,
|
|
3860
|
-
jupiterApiKey: this.jupiterApiKey
|
|
3861
|
-
}
|
|
3862
|
-
);
|
|
3863
|
-
return {
|
|
3864
|
-
user,
|
|
3865
|
-
pool,
|
|
3866
|
-
position,
|
|
3867
|
-
positionNftAccount,
|
|
3868
|
-
maxSqrtPriceChangeBps,
|
|
3869
|
-
amount: new BN5(0),
|
|
3870
|
-
isDirectPool: false,
|
|
3871
|
-
tokenAMint,
|
|
3872
|
-
tokenBMint,
|
|
3873
|
-
tokenAVault,
|
|
3874
|
-
tokenBVault,
|
|
3875
|
-
tokenAProgram,
|
|
3876
|
-
tokenBProgram,
|
|
3877
|
-
maxTransferAmountA: getExtendMaxAmountTransfer(
|
|
3878
|
-
swapToAQuote2.outAmount,
|
|
3879
|
-
maxTransferAmountExtendPercentage
|
|
3880
|
-
),
|
|
3881
|
-
swapType: 0 /* swapToA */,
|
|
3882
|
-
maxTransferAmountB: new BN5(0),
|
|
3883
|
-
preSqrtPrice: poolState.sqrtPrice,
|
|
3884
|
-
preInstructions,
|
|
3885
|
-
swapTransactions: [swapTransaction],
|
|
3886
|
-
cleanUpInstructions,
|
|
3887
|
-
swapInEstimate: {
|
|
3888
|
-
inAmountA: amountIn,
|
|
3889
|
-
inAmountB: new BN5(0),
|
|
3890
|
-
routeA: "jupiter" /* Jupiter */,
|
|
3891
|
-
routeB: "dammV2" /* DammV2 */
|
|
3892
|
-
}
|
|
3893
|
-
};
|
|
3894
|
-
}
|
|
3895
|
-
if (swapAmountToA.lt(MIN_SWAP_AMOUNT)) {
|
|
3896
|
-
const {
|
|
3897
|
-
transaction: swapTransaction,
|
|
3898
|
-
quoteResponse: swapToBQuote2
|
|
3899
|
-
} = yield buildJupiterSwapTransaction(
|
|
3900
|
-
user,
|
|
3901
|
-
inputTokenMint,
|
|
3902
|
-
tokenBMint,
|
|
3903
|
-
amountIn,
|
|
3904
|
-
maxAccounts,
|
|
3905
|
-
slippageBps,
|
|
3906
|
-
void 0,
|
|
3907
|
-
{
|
|
3908
|
-
jupiterApiUrl: this.jupiterApiUrl,
|
|
3909
|
-
jupiterApiKey: this.jupiterApiKey
|
|
3910
|
-
}
|
|
3911
|
-
);
|
|
3912
|
-
return {
|
|
3913
|
-
user,
|
|
3914
|
-
pool,
|
|
3915
|
-
position,
|
|
3916
|
-
positionNftAccount,
|
|
3917
|
-
maxSqrtPriceChangeBps,
|
|
3918
|
-
amount: new BN5(0),
|
|
3919
|
-
isDirectPool: false,
|
|
3920
|
-
tokenAMint,
|
|
3921
|
-
tokenBMint,
|
|
3922
|
-
tokenAVault,
|
|
3923
|
-
tokenBVault,
|
|
3924
|
-
tokenAProgram,
|
|
3925
|
-
tokenBProgram,
|
|
3926
|
-
maxTransferAmountA: new BN5(0),
|
|
3927
|
-
maxTransferAmountB: getExtendMaxAmountTransfer(
|
|
3928
|
-
swapToBQuote2.outAmount,
|
|
3929
|
-
maxTransferAmountExtendPercentage
|
|
3930
|
-
),
|
|
3931
|
-
swapType: 1 /* swapToB */,
|
|
3932
|
-
preSqrtPrice: poolState.sqrtPrice,
|
|
3933
|
-
preInstructions,
|
|
3934
|
-
swapTransactions: [swapTransaction],
|
|
3935
|
-
cleanUpInstructions,
|
|
3936
|
-
swapInEstimate: {
|
|
3937
|
-
inAmountA: new BN5(0),
|
|
3938
|
-
inAmountB: amountIn,
|
|
3939
|
-
routeA: "dammV2" /* DammV2 */,
|
|
3940
|
-
routeB: "jupiter" /* Jupiter */
|
|
3941
|
-
}
|
|
3942
|
-
};
|
|
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);
|
|
3943
3854
|
}
|
|
3944
3855
|
const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
|
|
3945
3856
|
user,
|
|
3946
3857
|
inputTokenMint,
|
|
3947
3858
|
tokenAMint,
|
|
3948
|
-
|
|
3859
|
+
finalSwapAmountToA,
|
|
3949
3860
|
maxAccounts,
|
|
3950
3861
|
slippageBps,
|
|
3951
3862
|
void 0,
|
|
@@ -3958,7 +3869,7 @@ var Zap = class {
|
|
|
3958
3869
|
user,
|
|
3959
3870
|
inputTokenMint,
|
|
3960
3871
|
tokenBMint,
|
|
3961
|
-
|
|
3872
|
+
finalSwapAmountToB,
|
|
3962
3873
|
maxAccounts,
|
|
3963
3874
|
slippageBps,
|
|
3964
3875
|
void 0,
|
|
@@ -3995,8 +3906,8 @@ var Zap = class {
|
|
|
3995
3906
|
swapTransactions: [swapToATransaction, swapToBTransaction],
|
|
3996
3907
|
cleanUpInstructions,
|
|
3997
3908
|
swapInEstimate: {
|
|
3998
|
-
inAmountA:
|
|
3999
|
-
inAmountB:
|
|
3909
|
+
inAmountA: finalSwapAmountToA,
|
|
3910
|
+
inAmountB: finalSwapAmountToB,
|
|
4000
3911
|
routeA: "jupiter" /* Jupiter */,
|
|
4001
3912
|
routeB: "jupiter" /* Jupiter */
|
|
4002
3913
|
}
|