@meteora-ag/zap-sdk 1.0.5 → 1.0.7-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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -5
- package/dist/index.mjs +30 -5
- package/package.json +48 -48
package/dist/index.d.mts
CHANGED
|
@@ -274,7 +274,7 @@ declare class Zap {
|
|
|
274
274
|
zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse>;
|
|
277
|
+
declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse>;
|
|
278
278
|
declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, apiUrl?: string, apiKey?: string): Promise<JupiterSwapInstructionResponse>;
|
|
279
279
|
|
|
280
280
|
declare function getDammV2Pool(connection: Connection, poolAddress: PublicKey): Promise<PoolState>;
|
package/dist/index.d.ts
CHANGED
|
@@ -274,7 +274,7 @@ declare class Zap {
|
|
|
274
274
|
zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse>;
|
|
277
|
+
declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse>;
|
|
278
278
|
declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, apiUrl?: string, apiKey?: string): Promise<JupiterSwapInstructionResponse>;
|
|
279
279
|
|
|
280
280
|
declare function getDammV2Pool(connection: Connection, poolAddress: PublicKey): Promise<PoolState>;
|
package/dist/index.js
CHANGED
|
@@ -209,7 +209,7 @@ var idl_default = {
|
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
// src/helpers/jupiter.ts
|
|
212
|
-
function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps, onlyDirectRoutes, restrictIntermediateTokens, apiUrl = "https://lite-api.jup.ag", apiKey) {
|
|
212
|
+
function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, apiUrl = "https://lite-api.jup.ag", apiKey) {
|
|
213
213
|
return __async(this, null, function* () {
|
|
214
214
|
const params = new URLSearchParams({
|
|
215
215
|
inputMint: inputMint.toString(),
|
|
@@ -218,7 +218,8 @@ function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps
|
|
|
218
218
|
slippageBps: slippageBps.toString(),
|
|
219
219
|
maxAccounts: maxAccounts.toString(),
|
|
220
220
|
onlyDirectRoutes: onlyDirectRoutes.toString(),
|
|
221
|
-
restrictIntermediateTokens: restrictIntermediateTokens.toString()
|
|
221
|
+
restrictIntermediateTokens: restrictIntermediateTokens.toString(),
|
|
222
|
+
dynamicSlippage: dynamicSlippage.toString()
|
|
222
223
|
});
|
|
223
224
|
const url = `${apiUrl}/swap/v1/quote?${params.toString()}`;
|
|
224
225
|
console.log(url);
|
|
@@ -902,7 +903,15 @@ var Zap = class {
|
|
|
902
903
|
preInstructions.push(...wrapIxs);
|
|
903
904
|
}
|
|
904
905
|
}
|
|
905
|
-
|
|
906
|
+
let preUserTokenBalance;
|
|
907
|
+
try {
|
|
908
|
+
preUserTokenBalance = yield getTokenAccountBalance(
|
|
909
|
+
this.connection,
|
|
910
|
+
inputTokenAccount
|
|
911
|
+
);
|
|
912
|
+
} catch (e) {
|
|
913
|
+
preUserTokenBalance = "0";
|
|
914
|
+
}
|
|
906
915
|
const remainingAccounts = jupiterSwapResponse.swapInstruction.accounts.map(
|
|
907
916
|
(account) => {
|
|
908
917
|
let pubkey = typeof account.pubkey === "string" ? new import_web37.PublicKey(account.pubkey) : account.pubkey;
|
|
@@ -1004,7 +1013,15 @@ var Zap = class {
|
|
|
1004
1013
|
preInstructions.push(...wrapIxs);
|
|
1005
1014
|
}
|
|
1006
1015
|
}
|
|
1007
|
-
|
|
1016
|
+
let preUserTokenBalance;
|
|
1017
|
+
try {
|
|
1018
|
+
preUserTokenBalance = yield getTokenAccountBalance(
|
|
1019
|
+
this.connection,
|
|
1020
|
+
inputTokenAccount
|
|
1021
|
+
);
|
|
1022
|
+
} catch (e) {
|
|
1023
|
+
preUserTokenBalance = "0";
|
|
1024
|
+
}
|
|
1008
1025
|
const remainingAccounts = yield getDammV2RemainingAccounts(
|
|
1009
1026
|
poolAddress,
|
|
1010
1027
|
user,
|
|
@@ -1102,7 +1119,15 @@ var Zap = class {
|
|
|
1102
1119
|
preInstructions.push(...wrapIxs);
|
|
1103
1120
|
}
|
|
1104
1121
|
}
|
|
1105
|
-
|
|
1122
|
+
let preUserTokenBalance;
|
|
1123
|
+
try {
|
|
1124
|
+
preUserTokenBalance = yield getTokenAccountBalance(
|
|
1125
|
+
this.connection,
|
|
1126
|
+
inputTokenAccount
|
|
1127
|
+
);
|
|
1128
|
+
} catch (e) {
|
|
1129
|
+
preUserTokenBalance = "0";
|
|
1130
|
+
}
|
|
1106
1131
|
const { remainingAccounts, remainingAccountsInfo } = yield getDlmmRemainingAccounts(
|
|
1107
1132
|
this.connection,
|
|
1108
1133
|
lbPairAddress,
|
package/dist/index.mjs
CHANGED
|
@@ -147,7 +147,7 @@ var idl_default = {
|
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
// src/helpers/jupiter.ts
|
|
150
|
-
function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps, onlyDirectRoutes, restrictIntermediateTokens, apiUrl = "https://lite-api.jup.ag", apiKey) {
|
|
150
|
+
function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, apiUrl = "https://lite-api.jup.ag", apiKey) {
|
|
151
151
|
return __async(this, null, function* () {
|
|
152
152
|
const params = new URLSearchParams({
|
|
153
153
|
inputMint: inputMint.toString(),
|
|
@@ -156,7 +156,8 @@ function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps
|
|
|
156
156
|
slippageBps: slippageBps.toString(),
|
|
157
157
|
maxAccounts: maxAccounts.toString(),
|
|
158
158
|
onlyDirectRoutes: onlyDirectRoutes.toString(),
|
|
159
|
-
restrictIntermediateTokens: restrictIntermediateTokens.toString()
|
|
159
|
+
restrictIntermediateTokens: restrictIntermediateTokens.toString(),
|
|
160
|
+
dynamicSlippage: dynamicSlippage.toString()
|
|
160
161
|
});
|
|
161
162
|
const url = `${apiUrl}/swap/v1/quote?${params.toString()}`;
|
|
162
163
|
console.log(url);
|
|
@@ -868,7 +869,15 @@ var Zap = class {
|
|
|
868
869
|
preInstructions.push(...wrapIxs);
|
|
869
870
|
}
|
|
870
871
|
}
|
|
871
|
-
|
|
872
|
+
let preUserTokenBalance;
|
|
873
|
+
try {
|
|
874
|
+
preUserTokenBalance = yield getTokenAccountBalance(
|
|
875
|
+
this.connection,
|
|
876
|
+
inputTokenAccount
|
|
877
|
+
);
|
|
878
|
+
} catch (e) {
|
|
879
|
+
preUserTokenBalance = "0";
|
|
880
|
+
}
|
|
872
881
|
const remainingAccounts = jupiterSwapResponse.swapInstruction.accounts.map(
|
|
873
882
|
(account) => {
|
|
874
883
|
let pubkey = typeof account.pubkey === "string" ? new PublicKey7(account.pubkey) : account.pubkey;
|
|
@@ -970,7 +979,15 @@ var Zap = class {
|
|
|
970
979
|
preInstructions.push(...wrapIxs);
|
|
971
980
|
}
|
|
972
981
|
}
|
|
973
|
-
|
|
982
|
+
let preUserTokenBalance;
|
|
983
|
+
try {
|
|
984
|
+
preUserTokenBalance = yield getTokenAccountBalance(
|
|
985
|
+
this.connection,
|
|
986
|
+
inputTokenAccount
|
|
987
|
+
);
|
|
988
|
+
} catch (e) {
|
|
989
|
+
preUserTokenBalance = "0";
|
|
990
|
+
}
|
|
974
991
|
const remainingAccounts = yield getDammV2RemainingAccounts(
|
|
975
992
|
poolAddress,
|
|
976
993
|
user,
|
|
@@ -1068,7 +1085,15 @@ var Zap = class {
|
|
|
1068
1085
|
preInstructions.push(...wrapIxs);
|
|
1069
1086
|
}
|
|
1070
1087
|
}
|
|
1071
|
-
|
|
1088
|
+
let preUserTokenBalance;
|
|
1089
|
+
try {
|
|
1090
|
+
preUserTokenBalance = yield getTokenAccountBalance(
|
|
1091
|
+
this.connection,
|
|
1092
|
+
inputTokenAccount
|
|
1093
|
+
);
|
|
1094
|
+
} catch (e) {
|
|
1095
|
+
preUserTokenBalance = "0";
|
|
1096
|
+
}
|
|
1072
1097
|
const { remainingAccounts, remainingAccountsInfo } = yield getDlmmRemainingAccounts(
|
|
1073
1098
|
this.connection,
|
|
1074
1099
|
lbPairAddress,
|
package/package.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
2
|
+
"name": "@meteora-ag/zap-sdk",
|
|
3
|
+
"version": "1.0.7-rc.1",
|
|
4
|
+
"description": "A Typescript SDK for interacting with the Zap program on Meteora.",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"source": "src/index.ts",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"author": "Minh Do <minh@raccoons.dev>, Dann Wee <dann@raccoons.dev>",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"meteora-ag",
|
|
12
|
+
"zap",
|
|
13
|
+
"damm-v2",
|
|
14
|
+
"dlmm",
|
|
15
|
+
"jupiter"
|
|
16
|
+
],
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/**"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rm -rf dist && tsup src/index.ts --format esm,cjs --dts",
|
|
22
|
+
"clean": "rm -rf dist && rm -rf node_modules rm -rf pnpm-lock.yaml"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/bn.js": "^5.1.0",
|
|
33
|
+
"@types/bun": "latest",
|
|
34
|
+
"tsup": "^8.4.0",
|
|
35
|
+
"tsx": "^4.20.3"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"typescript": "^5"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@coral-xyz/anchor": "^0.31.1",
|
|
42
|
+
"@meteora-ag/cp-amm-sdk": "1.1.0",
|
|
43
|
+
"@meteora-ag/dlmm": "^1.6.1",
|
|
44
|
+
"@solana/spl-token": "^0.4.13",
|
|
45
|
+
"@solana/web3.js": "^1.98.2",
|
|
46
|
+
"bn.js": "^5.2.2",
|
|
47
|
+
"decimal.js": "^10.4.2",
|
|
48
|
+
"jito-ts": "^4.2.0"
|
|
49
|
+
}
|
|
50
50
|
}
|