@drift-labs/sdk 2.82.0-beta.13 → 2.82.0-beta.15

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 CHANGED
@@ -1 +1 @@
1
- 2.82.0-beta.13
1
+ 2.82.0-beta.15
@@ -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 { data: routes } = await (await (0, node_fetch_1.default)(`${this.url}/v4/quote?${params}`)).json();
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 quote = await (await (0, node_fetch_1.default)(`${this.url}/v6/quote?${params.toString()}`)).json();
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 resp = await (await (0, node_fetch_1.default)(`${this.url}/v6/swap`, {
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 resp = await (await (0, node_fetch_1.default)(`${this.url}/v4/swap`, {
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
@@ -52,7 +52,8 @@ export declare enum PerpOperation {
52
52
  export declare enum SpotOperation {
53
53
  UPDATE_CUMULATIVE_INTEREST = 1,
54
54
  FILL = 2,
55
- WITHDRAW = 4
55
+ WITHDRAW = 4,
56
+ LIQUIDATION = 8
56
57
  }
57
58
  export declare enum UserStatus {
58
59
  BEING_LIQUIDATED = 1,
package/lib/types.js CHANGED
@@ -41,6 +41,7 @@ var SpotOperation;
41
41
  SpotOperation[SpotOperation["UPDATE_CUMULATIVE_INTEREST"] = 1] = "UPDATE_CUMULATIVE_INTEREST";
42
42
  SpotOperation[SpotOperation["FILL"] = 2] = "FILL";
43
43
  SpotOperation[SpotOperation["WITHDRAW"] = 4] = "WITHDRAW";
44
+ SpotOperation[SpotOperation["LIQUIDATION"] = 8] = "LIQUIDATION";
44
45
  })(SpotOperation = exports.SpotOperation || (exports.SpotOperation = {}));
45
46
  var UserStatus;
46
47
  (function (UserStatus) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.82.0-beta.13",
3
+ "version": "2.82.0-beta.15",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -219,12 +219,13 @@ export interface QuoteResponse {
219
219
  }
220
220
 
221
221
  export class JupiterClient {
222
- url = 'https://quote-api.jup.ag';
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}/v4/quote?${params}`)
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}/v6/quote?${params.toString()}`)
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}/v6/swap`, {
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}/v4/swap`, {
395
+ await fetch(`${this.url}${apiVersionParam}/swap`, {
387
396
  method: 'POST',
388
397
  headers: {
389
398
  'Content-Type': 'application/json',
package/src/types.ts CHANGED
@@ -40,6 +40,7 @@ export enum SpotOperation {
40
40
  UPDATE_CUMULATIVE_INTEREST = 1,
41
41
  FILL = 2,
42
42
  WITHDRAW = 4,
43
+ LIQUIDATION = 8,
43
44
  }
44
45
 
45
46
  export enum UserStatus {