@meteora-ag/zap-sdk 1.0.1 → 1.0.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/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +16 -15
- package/dist/index.mjs +15 -15
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -118,6 +118,8 @@ type ZapOutThroughDammV2Params = {
|
|
|
118
118
|
poolAddress: PublicKey;
|
|
119
119
|
inputMint: PublicKey;
|
|
120
120
|
outputMint: PublicKey;
|
|
121
|
+
inputTokenProgram: PublicKey;
|
|
122
|
+
outputTokenProgram: PublicKey;
|
|
121
123
|
amountIn: BN;
|
|
122
124
|
minimumSwapAmountOut: BN;
|
|
123
125
|
maxSwapAmount: BN;
|
|
@@ -128,6 +130,8 @@ type ZapOutThroughDlmmParams = {
|
|
|
128
130
|
lbPairAddress: PublicKey;
|
|
129
131
|
inputMint: PublicKey;
|
|
130
132
|
outputMint: PublicKey;
|
|
133
|
+
inputTokenProgram: PublicKey;
|
|
134
|
+
outputTokenProgram: PublicKey;
|
|
131
135
|
amountIn: BN;
|
|
132
136
|
minimumSwapAmountOut: BN;
|
|
133
137
|
maxSwapAmount: BN;
|
|
@@ -137,6 +141,8 @@ interface ZapOutThroughJupiterParams {
|
|
|
137
141
|
user: PublicKey;
|
|
138
142
|
inputMint: PublicKey;
|
|
139
143
|
outputMint: PublicKey;
|
|
144
|
+
inputTokenProgram: PublicKey;
|
|
145
|
+
outputTokenProgram: PublicKey;
|
|
140
146
|
jupiterSwapResponse: JupiterSwapInstructionResponse;
|
|
141
147
|
maxSwapAmount: BN;
|
|
142
148
|
percentageToZapOut: number;
|
|
@@ -314,6 +320,13 @@ declare const getOrCreateATAInstruction: (connection: Connection, tokenMint: Pub
|
|
|
314
320
|
* @returns The unwrap SOL instruction
|
|
315
321
|
*/
|
|
316
322
|
declare function unwrapSOLInstruction(owner: PublicKey, receiver: PublicKey, allowOwnerOffCurve?: boolean): TransactionInstruction | null;
|
|
323
|
+
/**
|
|
324
|
+
* Get token account balance
|
|
325
|
+
* @param connection - Solana connection
|
|
326
|
+
* @param tokenAccount - The token account address
|
|
327
|
+
* @returns The token account balance as a string
|
|
328
|
+
*/
|
|
329
|
+
declare function getTokenAccountBalance(connection: Connection, tokenAccount: PublicKey): Promise<string>;
|
|
317
330
|
/**
|
|
318
331
|
* Wrap SOL instruction
|
|
319
332
|
* @param from - The from address
|
|
@@ -374,4 +387,4 @@ declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
|
|
|
374
387
|
declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
|
|
375
388
|
declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
|
|
376
389
|
|
|
377
|
-
export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
|
|
390
|
+
export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
|
package/dist/index.d.ts
CHANGED
|
@@ -118,6 +118,8 @@ type ZapOutThroughDammV2Params = {
|
|
|
118
118
|
poolAddress: PublicKey;
|
|
119
119
|
inputMint: PublicKey;
|
|
120
120
|
outputMint: PublicKey;
|
|
121
|
+
inputTokenProgram: PublicKey;
|
|
122
|
+
outputTokenProgram: PublicKey;
|
|
121
123
|
amountIn: BN;
|
|
122
124
|
minimumSwapAmountOut: BN;
|
|
123
125
|
maxSwapAmount: BN;
|
|
@@ -128,6 +130,8 @@ type ZapOutThroughDlmmParams = {
|
|
|
128
130
|
lbPairAddress: PublicKey;
|
|
129
131
|
inputMint: PublicKey;
|
|
130
132
|
outputMint: PublicKey;
|
|
133
|
+
inputTokenProgram: PublicKey;
|
|
134
|
+
outputTokenProgram: PublicKey;
|
|
131
135
|
amountIn: BN;
|
|
132
136
|
minimumSwapAmountOut: BN;
|
|
133
137
|
maxSwapAmount: BN;
|
|
@@ -137,6 +141,8 @@ interface ZapOutThroughJupiterParams {
|
|
|
137
141
|
user: PublicKey;
|
|
138
142
|
inputMint: PublicKey;
|
|
139
143
|
outputMint: PublicKey;
|
|
144
|
+
inputTokenProgram: PublicKey;
|
|
145
|
+
outputTokenProgram: PublicKey;
|
|
140
146
|
jupiterSwapResponse: JupiterSwapInstructionResponse;
|
|
141
147
|
maxSwapAmount: BN;
|
|
142
148
|
percentageToZapOut: number;
|
|
@@ -314,6 +320,13 @@ declare const getOrCreateATAInstruction: (connection: Connection, tokenMint: Pub
|
|
|
314
320
|
* @returns The unwrap SOL instruction
|
|
315
321
|
*/
|
|
316
322
|
declare function unwrapSOLInstruction(owner: PublicKey, receiver: PublicKey, allowOwnerOffCurve?: boolean): TransactionInstruction | null;
|
|
323
|
+
/**
|
|
324
|
+
* Get token account balance
|
|
325
|
+
* @param connection - Solana connection
|
|
326
|
+
* @param tokenAccount - The token account address
|
|
327
|
+
* @returns The token account balance as a string
|
|
328
|
+
*/
|
|
329
|
+
declare function getTokenAccountBalance(connection: Connection, tokenAccount: PublicKey): Promise<string>;
|
|
317
330
|
/**
|
|
318
331
|
* Wrap SOL instruction
|
|
319
332
|
* @param from - The from address
|
|
@@ -374,4 +387,4 @@ declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
|
|
|
374
387
|
declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
|
|
375
388
|
declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
|
|
376
389
|
|
|
377
|
-
export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
|
|
390
|
+
export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
|
package/dist/index.js
CHANGED
|
@@ -95,6 +95,7 @@ __export(index_exports, {
|
|
|
95
95
|
getLbPairState: () => getLbPairState,
|
|
96
96
|
getNextBinArrayIndexWithLiquidity: () => getNextBinArrayIndexWithLiquidity,
|
|
97
97
|
getOrCreateATAInstruction: () => getOrCreateATAInstruction,
|
|
98
|
+
getTokenAccountBalance: () => getTokenAccountBalance,
|
|
98
99
|
getTokenProgramFromMint: () => getTokenProgramFromMint,
|
|
99
100
|
unwrapSOLInstruction: () => unwrapSOLInstruction,
|
|
100
101
|
wrapSOLInstruction: () => wrapSOLInstruction
|
|
@@ -496,6 +497,11 @@ function unwrapSOLInstruction(owner, receiver, allowOwnerOffCurve = true) {
|
|
|
496
497
|
}
|
|
497
498
|
return null;
|
|
498
499
|
}
|
|
500
|
+
function getTokenAccountBalance(connection, tokenAccount) {
|
|
501
|
+
return __async(this, null, function* () {
|
|
502
|
+
return (yield connection.getTokenAccountBalance(tokenAccount)).value.amount;
|
|
503
|
+
});
|
|
504
|
+
}
|
|
499
505
|
function wrapSOLInstruction(from, to, amount, tokenProgram = import_spl_token3.TOKEN_PROGRAM_ID) {
|
|
500
506
|
return [
|
|
501
507
|
import_web34.SystemProgram.transfer({
|
|
@@ -865,16 +871,14 @@ var Zap = class {
|
|
|
865
871
|
user,
|
|
866
872
|
inputMint,
|
|
867
873
|
outputMint,
|
|
874
|
+
inputTokenProgram,
|
|
875
|
+
outputTokenProgram,
|
|
868
876
|
jupiterSwapResponse,
|
|
869
877
|
maxSwapAmount,
|
|
870
878
|
percentageToZapOut
|
|
871
879
|
} = params;
|
|
872
880
|
const preInstructions = [];
|
|
873
881
|
const postInstructions = [];
|
|
874
|
-
const [inputTokenProgram, outputTokenProgram] = yield Promise.all([
|
|
875
|
-
getTokenProgramFromMint(this.connection, inputMint),
|
|
876
|
-
getTokenProgramFromMint(this.connection, outputMint)
|
|
877
|
-
]);
|
|
878
882
|
const [
|
|
879
883
|
{ ataPubkey: inputTokenAccount, ix: inputTokenAccountIx },
|
|
880
884
|
{ ataPubkey: outputTokenAccount, ix: outputTokenAccountIx }
|
|
@@ -898,7 +902,7 @@ var Zap = class {
|
|
|
898
902
|
]);
|
|
899
903
|
inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
|
|
900
904
|
outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
|
|
901
|
-
const preUserTokenBalance =
|
|
905
|
+
const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
|
|
902
906
|
const remainingAccounts = jupiterSwapResponse.swapInstruction.accounts.map(
|
|
903
907
|
(account) => {
|
|
904
908
|
let pubkey = typeof account.pubkey === "string" ? new import_web37.PublicKey(account.pubkey) : account.pubkey;
|
|
@@ -957,6 +961,8 @@ var Zap = class {
|
|
|
957
961
|
poolAddress,
|
|
958
962
|
inputMint,
|
|
959
963
|
outputMint,
|
|
964
|
+
inputTokenProgram,
|
|
965
|
+
outputTokenProgram,
|
|
960
966
|
amountIn,
|
|
961
967
|
minimumSwapAmountOut,
|
|
962
968
|
maxSwapAmount,
|
|
@@ -965,10 +971,6 @@ var Zap = class {
|
|
|
965
971
|
const poolState = yield getDammV2Pool(this.connection, poolAddress);
|
|
966
972
|
const preInstructions = [];
|
|
967
973
|
const postInstructions = [];
|
|
968
|
-
const [inputTokenProgram, outputTokenProgram] = yield Promise.all([
|
|
969
|
-
getTokenProgramFromMint(this.connection, inputMint),
|
|
970
|
-
getTokenProgramFromMint(this.connection, outputMint)
|
|
971
|
-
]);
|
|
972
974
|
const [
|
|
973
975
|
{ ataPubkey: inputTokenAccount, ix: inputTokenAccountIx },
|
|
974
976
|
{ ataPubkey: outputTokenAccount, ix: outputTokenAccountIx }
|
|
@@ -992,7 +994,7 @@ var Zap = class {
|
|
|
992
994
|
]);
|
|
993
995
|
inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
|
|
994
996
|
outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
|
|
995
|
-
const preUserTokenBalance =
|
|
997
|
+
const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
|
|
996
998
|
const remainingAccounts = yield getDammV2RemainingAccounts(
|
|
997
999
|
poolAddress,
|
|
998
1000
|
user,
|
|
@@ -1047,6 +1049,8 @@ var Zap = class {
|
|
|
1047
1049
|
lbPairAddress,
|
|
1048
1050
|
inputMint,
|
|
1049
1051
|
outputMint,
|
|
1052
|
+
inputTokenProgram,
|
|
1053
|
+
outputTokenProgram,
|
|
1050
1054
|
amountIn,
|
|
1051
1055
|
minimumSwapAmountOut,
|
|
1052
1056
|
maxSwapAmount,
|
|
@@ -1055,10 +1059,6 @@ var Zap = class {
|
|
|
1055
1059
|
const lbPairState = yield getLbPairState(this.connection, lbPairAddress);
|
|
1056
1060
|
const preInstructions = [];
|
|
1057
1061
|
const postInstructions = [];
|
|
1058
|
-
const [inputTokenProgram, outputTokenProgram] = yield Promise.all([
|
|
1059
|
-
getTokenProgramFromMint(this.connection, inputMint),
|
|
1060
|
-
getTokenProgramFromMint(this.connection, outputMint)
|
|
1061
|
-
]);
|
|
1062
1062
|
const [
|
|
1063
1063
|
{ ataPubkey: inputTokenAccount, ix: inputTokenAccountIx },
|
|
1064
1064
|
{ ataPubkey: outputTokenAccount, ix: outputTokenAccountIx }
|
|
@@ -1082,7 +1082,7 @@ var Zap = class {
|
|
|
1082
1082
|
]);
|
|
1083
1083
|
inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
|
|
1084
1084
|
outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
|
|
1085
|
-
const preUserTokenBalance =
|
|
1085
|
+
const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
|
|
1086
1086
|
const { remainingAccounts, remainingAccountsInfo } = yield getDlmmRemainingAccounts(
|
|
1087
1087
|
this.connection,
|
|
1088
1088
|
lbPairAddress,
|
|
@@ -1151,6 +1151,7 @@ var Zap = class {
|
|
|
1151
1151
|
getLbPairState,
|
|
1152
1152
|
getNextBinArrayIndexWithLiquidity,
|
|
1153
1153
|
getOrCreateATAInstruction,
|
|
1154
|
+
getTokenAccountBalance,
|
|
1154
1155
|
getTokenProgramFromMint,
|
|
1155
1156
|
unwrapSOLInstruction,
|
|
1156
1157
|
wrapSOLInstruction
|
package/dist/index.mjs
CHANGED
|
@@ -453,6 +453,11 @@ function unwrapSOLInstruction(owner, receiver, allowOwnerOffCurve = true) {
|
|
|
453
453
|
}
|
|
454
454
|
return null;
|
|
455
455
|
}
|
|
456
|
+
function getTokenAccountBalance(connection, tokenAccount) {
|
|
457
|
+
return __async(this, null, function* () {
|
|
458
|
+
return (yield connection.getTokenAccountBalance(tokenAccount)).value.amount;
|
|
459
|
+
});
|
|
460
|
+
}
|
|
456
461
|
function wrapSOLInstruction(from, to, amount, tokenProgram = TOKEN_PROGRAM_ID3) {
|
|
457
462
|
return [
|
|
458
463
|
SystemProgram.transfer({
|
|
@@ -835,16 +840,14 @@ var Zap = class {
|
|
|
835
840
|
user,
|
|
836
841
|
inputMint,
|
|
837
842
|
outputMint,
|
|
843
|
+
inputTokenProgram,
|
|
844
|
+
outputTokenProgram,
|
|
838
845
|
jupiterSwapResponse,
|
|
839
846
|
maxSwapAmount,
|
|
840
847
|
percentageToZapOut
|
|
841
848
|
} = params;
|
|
842
849
|
const preInstructions = [];
|
|
843
850
|
const postInstructions = [];
|
|
844
|
-
const [inputTokenProgram, outputTokenProgram] = yield Promise.all([
|
|
845
|
-
getTokenProgramFromMint(this.connection, inputMint),
|
|
846
|
-
getTokenProgramFromMint(this.connection, outputMint)
|
|
847
|
-
]);
|
|
848
851
|
const [
|
|
849
852
|
{ ataPubkey: inputTokenAccount, ix: inputTokenAccountIx },
|
|
850
853
|
{ ataPubkey: outputTokenAccount, ix: outputTokenAccountIx }
|
|
@@ -868,7 +871,7 @@ var Zap = class {
|
|
|
868
871
|
]);
|
|
869
872
|
inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
|
|
870
873
|
outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
|
|
871
|
-
const preUserTokenBalance =
|
|
874
|
+
const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
|
|
872
875
|
const remainingAccounts = jupiterSwapResponse.swapInstruction.accounts.map(
|
|
873
876
|
(account) => {
|
|
874
877
|
let pubkey = typeof account.pubkey === "string" ? new PublicKey7(account.pubkey) : account.pubkey;
|
|
@@ -927,6 +930,8 @@ var Zap = class {
|
|
|
927
930
|
poolAddress,
|
|
928
931
|
inputMint,
|
|
929
932
|
outputMint,
|
|
933
|
+
inputTokenProgram,
|
|
934
|
+
outputTokenProgram,
|
|
930
935
|
amountIn,
|
|
931
936
|
minimumSwapAmountOut,
|
|
932
937
|
maxSwapAmount,
|
|
@@ -935,10 +940,6 @@ var Zap = class {
|
|
|
935
940
|
const poolState = yield getDammV2Pool(this.connection, poolAddress);
|
|
936
941
|
const preInstructions = [];
|
|
937
942
|
const postInstructions = [];
|
|
938
|
-
const [inputTokenProgram, outputTokenProgram] = yield Promise.all([
|
|
939
|
-
getTokenProgramFromMint(this.connection, inputMint),
|
|
940
|
-
getTokenProgramFromMint(this.connection, outputMint)
|
|
941
|
-
]);
|
|
942
943
|
const [
|
|
943
944
|
{ ataPubkey: inputTokenAccount, ix: inputTokenAccountIx },
|
|
944
945
|
{ ataPubkey: outputTokenAccount, ix: outputTokenAccountIx }
|
|
@@ -962,7 +963,7 @@ var Zap = class {
|
|
|
962
963
|
]);
|
|
963
964
|
inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
|
|
964
965
|
outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
|
|
965
|
-
const preUserTokenBalance =
|
|
966
|
+
const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
|
|
966
967
|
const remainingAccounts = yield getDammV2RemainingAccounts(
|
|
967
968
|
poolAddress,
|
|
968
969
|
user,
|
|
@@ -1017,6 +1018,8 @@ var Zap = class {
|
|
|
1017
1018
|
lbPairAddress,
|
|
1018
1019
|
inputMint,
|
|
1019
1020
|
outputMint,
|
|
1021
|
+
inputTokenProgram,
|
|
1022
|
+
outputTokenProgram,
|
|
1020
1023
|
amountIn,
|
|
1021
1024
|
minimumSwapAmountOut,
|
|
1022
1025
|
maxSwapAmount,
|
|
@@ -1025,10 +1028,6 @@ var Zap = class {
|
|
|
1025
1028
|
const lbPairState = yield getLbPairState(this.connection, lbPairAddress);
|
|
1026
1029
|
const preInstructions = [];
|
|
1027
1030
|
const postInstructions = [];
|
|
1028
|
-
const [inputTokenProgram, outputTokenProgram] = yield Promise.all([
|
|
1029
|
-
getTokenProgramFromMint(this.connection, inputMint),
|
|
1030
|
-
getTokenProgramFromMint(this.connection, outputMint)
|
|
1031
|
-
]);
|
|
1032
1031
|
const [
|
|
1033
1032
|
{ ataPubkey: inputTokenAccount, ix: inputTokenAccountIx },
|
|
1034
1033
|
{ ataPubkey: outputTokenAccount, ix: outputTokenAccountIx }
|
|
@@ -1052,7 +1051,7 @@ var Zap = class {
|
|
|
1052
1051
|
]);
|
|
1053
1052
|
inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
|
|
1054
1053
|
outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
|
|
1055
|
-
const preUserTokenBalance =
|
|
1054
|
+
const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
|
|
1056
1055
|
const { remainingAccounts, remainingAccountsInfo } = yield getDlmmRemainingAccounts(
|
|
1057
1056
|
this.connection,
|
|
1058
1057
|
lbPairAddress,
|
|
@@ -1120,6 +1119,7 @@ export {
|
|
|
1120
1119
|
getLbPairState,
|
|
1121
1120
|
getNextBinArrayIndexWithLiquidity,
|
|
1122
1121
|
getOrCreateATAInstruction,
|
|
1122
|
+
getTokenAccountBalance,
|
|
1123
1123
|
getTokenProgramFromMint,
|
|
1124
1124
|
unwrapSOLInstruction,
|
|
1125
1125
|
wrapSOLInstruction
|