@drift-labs/sdk 2.82.0-beta.12 → 2.82.0-beta.14
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/VERSION +1 -1
- package/lib/jupiter/jupiterClient.d.ts +2 -1
- package/lib/jupiter/jupiterClient.js +10 -6
- package/lib/types.d.ts +2 -1
- package/lib/types.js +1 -0
- package/package.json +1 -1
- package/src/jupiter/jupiterClient.ts +15 -6
- package/src/types.ts +1 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.82.0-beta.
|
|
1
|
+
2.82.0-beta.14
|
|
@@ -206,8 +206,9 @@ export declare class JupiterClient {
|
|
|
206
206
|
url: string;
|
|
207
207
|
connection: Connection;
|
|
208
208
|
lookupTableCahce: Map<string, AddressLookupTableAccount>;
|
|
209
|
-
constructor({ connection }: {
|
|
209
|
+
constructor({ connection, url }: {
|
|
210
210
|
connection: Connection;
|
|
211
|
+
url?: string;
|
|
211
212
|
});
|
|
212
213
|
/**
|
|
213
214
|
* ** @deprecated - use getQuote
|
|
@@ -7,10 +7,10 @@ exports.JupiterClient = void 0;
|
|
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
8
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
9
|
class JupiterClient {
|
|
10
|
-
constructor({ connection }) {
|
|
11
|
-
this.url = 'https://quote-api.jup.ag';
|
|
10
|
+
constructor({ connection, url }) {
|
|
12
11
|
this.lookupTableCahce = new Map();
|
|
13
12
|
this.connection = connection;
|
|
13
|
+
this.url = url !== null && url !== void 0 ? url : 'https://quote-api.jup.ag';
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* ** @deprecated - use getQuote
|
|
@@ -31,7 +31,8 @@ class JupiterClient {
|
|
|
31
31
|
swapMode,
|
|
32
32
|
onlyDirectRoutes: onlyDirectRoutes.toString(),
|
|
33
33
|
}).toString();
|
|
34
|
-
const
|
|
34
|
+
const apiVersionParam = this.url === 'https://quote-api.jup.ag' ? '/v4' : '';
|
|
35
|
+
const { data: routes } = await (await (0, node_fetch_1.default)(`${this.url}${apiVersionParam}/quote?${params}`)).json();
|
|
35
36
|
return routes;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
@@ -58,7 +59,8 @@ class JupiterClient {
|
|
|
58
59
|
if (swapMode === 'ExactOut') {
|
|
59
60
|
params.delete('maxAccounts');
|
|
60
61
|
}
|
|
61
|
-
const
|
|
62
|
+
const apiVersionParam = this.url === 'https://quote-api.jup.ag' ? '/v6' : '';
|
|
63
|
+
const quote = await (await (0, node_fetch_1.default)(`${this.url}${apiVersionParam}/quote?${params.toString()}`)).json();
|
|
62
64
|
return quote;
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
@@ -72,7 +74,8 @@ class JupiterClient {
|
|
|
72
74
|
if (!quote) {
|
|
73
75
|
throw new Error('Jupiter swap quote not provided. Please try again.');
|
|
74
76
|
}
|
|
75
|
-
const
|
|
77
|
+
const apiVersionParam = this.url === 'https://quote-api.jup.ag' ? '/v6' : '';
|
|
78
|
+
const resp = await (await (0, node_fetch_1.default)(`${this.url}${apiVersionParam}/swap`, {
|
|
76
79
|
method: 'POST',
|
|
77
80
|
headers: {
|
|
78
81
|
'Content-Type': 'application/json',
|
|
@@ -103,7 +106,8 @@ class JupiterClient {
|
|
|
103
106
|
* @param slippageBps the slippage tolerance in basis points
|
|
104
107
|
*/
|
|
105
108
|
async getSwapTransaction({ route, userPublicKey, slippageBps = 50, }) {
|
|
106
|
-
const
|
|
109
|
+
const apiVersionParam = this.url === 'https://quote-api.jup.ag' ? '/v4' : '';
|
|
110
|
+
const resp = await (await (0, node_fetch_1.default)(`${this.url}${apiVersionParam}/swap`, {
|
|
107
111
|
method: 'POST',
|
|
108
112
|
headers: {
|
|
109
113
|
'Content-Type': 'application/json',
|
package/lib/types.d.ts
CHANGED
package/lib/types.js
CHANGED
|
@@ -34,6 +34,7 @@ var PerpOperation;
|
|
|
34
34
|
PerpOperation[PerpOperation["FILL"] = 4] = "FILL";
|
|
35
35
|
PerpOperation[PerpOperation["SETTLE_PNL"] = 8] = "SETTLE_PNL";
|
|
36
36
|
PerpOperation[PerpOperation["SETTLE_PNL_WITH_POSITION"] = 16] = "SETTLE_PNL_WITH_POSITION";
|
|
37
|
+
PerpOperation[PerpOperation["LIQUIDATION"] = 32] = "LIQUIDATION";
|
|
37
38
|
})(PerpOperation = exports.PerpOperation || (exports.PerpOperation = {}));
|
|
38
39
|
var SpotOperation;
|
|
39
40
|
(function (SpotOperation) {
|
package/package.json
CHANGED
|
@@ -219,12 +219,13 @@ export interface QuoteResponse {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
export class JupiterClient {
|
|
222
|
-
url
|
|
222
|
+
url: string;
|
|
223
223
|
connection: Connection;
|
|
224
224
|
lookupTableCahce = new Map<string, AddressLookupTableAccount>();
|
|
225
225
|
|
|
226
|
-
constructor({ connection }: { connection: Connection }) {
|
|
226
|
+
constructor({ connection, url }: { connection: Connection; url?: string }) {
|
|
227
227
|
this.connection = connection;
|
|
228
|
+
this.url = url ?? 'https://quote-api.jup.ag';
|
|
228
229
|
}
|
|
229
230
|
|
|
230
231
|
/**
|
|
@@ -261,8 +262,10 @@ export class JupiterClient {
|
|
|
261
262
|
onlyDirectRoutes: onlyDirectRoutes.toString(),
|
|
262
263
|
}).toString();
|
|
263
264
|
|
|
265
|
+
const apiVersionParam =
|
|
266
|
+
this.url === 'https://quote-api.jup.ag' ? '/v4' : '';
|
|
264
267
|
const { data: routes } = await (
|
|
265
|
-
await fetch(`${this.url}/
|
|
268
|
+
await fetch(`${this.url}${apiVersionParam}/quote?${params}`)
|
|
266
269
|
).json();
|
|
267
270
|
|
|
268
271
|
return routes;
|
|
@@ -309,8 +312,10 @@ export class JupiterClient {
|
|
|
309
312
|
if (swapMode === 'ExactOut') {
|
|
310
313
|
params.delete('maxAccounts');
|
|
311
314
|
}
|
|
315
|
+
const apiVersionParam =
|
|
316
|
+
this.url === 'https://quote-api.jup.ag' ? '/v6' : '';
|
|
312
317
|
const quote = await (
|
|
313
|
-
await fetch(`${this.url}/
|
|
318
|
+
await fetch(`${this.url}${apiVersionParam}/quote?${params.toString()}`)
|
|
314
319
|
).json();
|
|
315
320
|
return quote as QuoteResponse;
|
|
316
321
|
}
|
|
@@ -334,8 +339,10 @@ export class JupiterClient {
|
|
|
334
339
|
throw new Error('Jupiter swap quote not provided. Please try again.');
|
|
335
340
|
}
|
|
336
341
|
|
|
342
|
+
const apiVersionParam =
|
|
343
|
+
this.url === 'https://quote-api.jup.ag' ? '/v6' : '';
|
|
337
344
|
const resp = await (
|
|
338
|
-
await fetch(`${this.url}/
|
|
345
|
+
await fetch(`${this.url}${apiVersionParam}/swap`, {
|
|
339
346
|
method: 'POST',
|
|
340
347
|
headers: {
|
|
341
348
|
'Content-Type': 'application/json',
|
|
@@ -382,8 +389,10 @@ export class JupiterClient {
|
|
|
382
389
|
userPublicKey: PublicKey;
|
|
383
390
|
slippageBps?: number;
|
|
384
391
|
}): Promise<VersionedTransaction> {
|
|
392
|
+
const apiVersionParam =
|
|
393
|
+
this.url === 'https://quote-api.jup.ag' ? '/v4' : '';
|
|
385
394
|
const resp = await (
|
|
386
|
-
await fetch(`${this.url}/
|
|
395
|
+
await fetch(`${this.url}${apiVersionParam}/swap`, {
|
|
387
396
|
method: 'POST',
|
|
388
397
|
headers: {
|
|
389
398
|
'Content-Type': 'application/json',
|