@drift-labs/sdk 2.47.0-beta.1 → 2.47.0-beta.2

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.47.0-beta.1
1
+ 2.47.0-beta.2
@@ -65,6 +65,7 @@ class JupiterClient {
65
65
  * @param slippageBps the slippage tolerance in basis points
66
66
  */
67
67
  async getSwap({ quote, userPublicKey, slippageBps = 50, }) {
68
+ var _a;
68
69
  if (!quote) {
69
70
  throw new Error('Jupiter swap quote not provided. Please try again.');
70
71
  }
@@ -79,6 +80,9 @@ class JupiterClient {
79
80
  slippageBps,
80
81
  }),
81
82
  })).json();
83
+ if (!('swapTransaction' in resp)) {
84
+ throw new Error(`swapTransaction not found, error from Jupiter: ${resp.error} ${(_a = ', ' + resp.message) !== null && _a !== void 0 ? _a : ''}`);
85
+ }
82
86
  const { swapTransaction } = resp;
83
87
  try {
84
88
  const swapTransactionBuf = Buffer.from(swapTransaction, 'base64');
@@ -25,7 +25,7 @@ function getAuctionPrice(order, slot, oraclePrice) {
25
25
  return getAuctionPriceForOracleOffsetAuction(order, slot, oraclePrice);
26
26
  }
27
27
  else {
28
- throw Error(`Cant get auction price for order type ${order.orderType}`);
28
+ throw Error(`Cant get auction price for order type ${(0, _1.getVariant)(order.orderType)}`);
29
29
  }
30
30
  }
31
31
  exports.getAuctionPrice = getAuctionPrice;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.47.0-beta.1",
3
+ "version": "2.47.0-beta.2",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -336,6 +336,13 @@ export class JupiterClient {
336
336
  }),
337
337
  })
338
338
  ).json();
339
+ if (!('swapTransaction' in resp)) {
340
+ throw new Error(
341
+ `swapTransaction not found, error from Jupiter: ${resp.error} ${
342
+ ', ' + resp.message ?? ''
343
+ }`
344
+ );
345
+ }
339
346
  const { swapTransaction } = resp;
340
347
 
341
348
  try {
@@ -1,5 +1,5 @@
1
1
  import { isOneOfVariant, isVariant, Order, PositionDirection } from '../types';
2
- import { BN, ONE, ZERO } from '../.';
2
+ import { BN, getVariant, ONE, ZERO } from '../.';
3
3
 
4
4
  export function isAuctionComplete(order: Order, slot: number): boolean {
5
5
  if (order.auctionDuration === 0) {
@@ -31,7 +31,9 @@ export function getAuctionPrice(
31
31
  } else if (isVariant(order.orderType, 'oracle')) {
32
32
  return getAuctionPriceForOracleOffsetAuction(order, slot, oraclePrice);
33
33
  } else {
34
- throw Error(`Cant get auction price for order type ${order.orderType}`);
34
+ throw Error(
35
+ `Cant get auction price for order type ${getVariant(order.orderType)}`
36
+ );
35
37
  }
36
38
  }
37
39