@drift-labs/sdk 2.47.0-beta.1 → 2.47.0-beta.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/VERSION +1 -1
- package/lib/jupiter/jupiterClient.js +4 -0
- package/lib/math/auction.js +1 -1
- package/lib/user.js +1 -1
- package/package.json +1 -1
- package/src/jupiter/jupiterClient.ts +7 -0
- package/src/math/auction.ts +4 -2
- package/src/user.ts +1 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.47.0-beta.
|
|
1
|
+
2.47.0-beta.3
|
|
@@ -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');
|
package/lib/math/auction.js
CHANGED
|
@@ -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/lib/user.js
CHANGED
|
@@ -1748,7 +1748,7 @@ class User {
|
|
|
1748
1748
|
const { totalAssetValue, totalLiabilityValue } = this.getSpotMarketAssetAndLiabilityValue();
|
|
1749
1749
|
const equity = totalAssetValue.sub(totalLiabilityValue);
|
|
1750
1750
|
let slotsBeforeIdle;
|
|
1751
|
-
if (equity.lt(numericConstants_1.QUOTE_PRECISION)) {
|
|
1751
|
+
if (equity.lt(numericConstants_1.QUOTE_PRECISION.muln(1000))) {
|
|
1752
1752
|
slotsBeforeIdle = new _1.BN(9000); // 1 hour
|
|
1753
1753
|
}
|
|
1754
1754
|
else {
|
package/package.json
CHANGED
|
@@ -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 {
|
package/src/math/auction.ts
CHANGED
|
@@ -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(
|
|
34
|
+
throw Error(
|
|
35
|
+
`Cant get auction price for order type ${getVariant(order.orderType)}`
|
|
36
|
+
);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
package/src/user.ts
CHANGED
|
@@ -3169,7 +3169,7 @@ export class User {
|
|
|
3169
3169
|
const equity = totalAssetValue.sub(totalLiabilityValue);
|
|
3170
3170
|
|
|
3171
3171
|
let slotsBeforeIdle: BN;
|
|
3172
|
-
if (equity.lt(QUOTE_PRECISION)) {
|
|
3172
|
+
if (equity.lt(QUOTE_PRECISION.muln(1000))) {
|
|
3173
3173
|
slotsBeforeIdle = new BN(9000); // 1 hour
|
|
3174
3174
|
} else {
|
|
3175
3175
|
slotsBeforeIdle = new BN(1512000); // 1 week
|