@drift-labs/sdk 2.10.0 → 2.11.0-beta.0
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/lib/factory/oracleClient.js +4 -4
- package/lib/idl/drift.json +6 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -1
- package/lib/types.d.ts +0 -3
- package/lib/types.js +1 -1
- package/lib/user.js +3 -0
- package/package.json +1 -2
- package/src/factory/oracleClient.ts +4 -4
- package/src/idl/drift.json +6 -1
- package/src/index.ts +1 -1
- package/src/types.ts +1 -1
- package/src/user.ts +4 -0
- package/lib/idl/switchboard_v2.json +0 -4663
- package/lib/oracles/switchboardClient.d.ts +0 -11
- package/lib/oracles/switchboardClient.js +0 -58
- package/src/idl/switchboard_v2.json +0 -4663
- package/src/oracles/switchboardClient.ts +0 -79
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getOracleClient = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const pythClient_1 = require("../oracles/pythClient");
|
|
6
|
-
|
|
6
|
+
// import { SwitchboardClient } from '../oracles/switchboardClient';
|
|
7
7
|
const quoteAssetOracleClient_1 = require("../oracles/quoteAssetOracleClient");
|
|
8
8
|
function getOracleClient(oracleSource, connection) {
|
|
9
9
|
if ((0, types_1.isVariant)(oracleSource, 'pyth')) {
|
|
10
10
|
return new pythClient_1.PythClient(connection);
|
|
11
11
|
}
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
// if (isVariant(oracleSource, 'switchboard')) {
|
|
13
|
+
// return new SwitchboardClient(connection);
|
|
14
|
+
// }
|
|
15
15
|
if ((0, types_1.isVariant)(oracleSource, 'quoteAsset')) {
|
|
16
16
|
return new quoteAssetOracleClient_1.QuoteAssetOracleClient();
|
|
17
17
|
}
|
package/lib/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.11.0-beta.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -8558,6 +8558,11 @@
|
|
|
8558
8558
|
"code": 6223,
|
|
8559
8559
|
"name": "FailedUnwrap",
|
|
8560
8560
|
"msg": "Failed Unwrap"
|
|
8561
|
+
},
|
|
8562
|
+
{
|
|
8563
|
+
"code": 6224,
|
|
8564
|
+
"name": "MaxNumberOfUsers",
|
|
8565
|
+
"msg": "Max Number Of Users"
|
|
8561
8566
|
}
|
|
8562
8567
|
]
|
|
8563
8568
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import pyth from '@pythnetwork/client';
|
|
|
4
4
|
export * from './tokenFaucet';
|
|
5
5
|
export * from './oracles/types';
|
|
6
6
|
export * from './oracles/pythClient';
|
|
7
|
-
export * from './oracles/switchboardClient';
|
|
8
7
|
export * from './types';
|
|
9
8
|
export * from './constants/perpMarkets';
|
|
10
9
|
export * from './accounts/fetch';
|
package/lib/index.js
CHANGED
|
@@ -27,7 +27,7 @@ exports.pyth = client_1.default;
|
|
|
27
27
|
__exportStar(require("./tokenFaucet"), exports);
|
|
28
28
|
__exportStar(require("./oracles/types"), exports);
|
|
29
29
|
__exportStar(require("./oracles/pythClient"), exports);
|
|
30
|
-
|
|
30
|
+
// export * from './oracles/switchboardClient';
|
|
31
31
|
__exportStar(require("./types"), exports);
|
|
32
32
|
__exportStar(require("./constants/perpMarkets"), exports);
|
|
33
33
|
__exportStar(require("./accounts/fetch"), exports);
|
package/lib/types.d.ts
CHANGED
package/lib/types.js
CHANGED
|
@@ -76,7 +76,7 @@ class OracleSource {
|
|
|
76
76
|
}
|
|
77
77
|
exports.OracleSource = OracleSource;
|
|
78
78
|
OracleSource.PYTH = { pyth: {} };
|
|
79
|
-
|
|
79
|
+
// static readonly SWITCHBOARD = { switchboard: {} };
|
|
80
80
|
OracleSource.QUOTE_ASSET = { quoteAsset: {} };
|
|
81
81
|
class OrderType {
|
|
82
82
|
}
|
package/lib/user.js
CHANGED
|
@@ -291,6 +291,9 @@ class User {
|
|
|
291
291
|
.reduce((unrealizedPnl, perpPosition) => {
|
|
292
292
|
const market = this.driftClient.getPerpMarketAccount(perpPosition.marketIndex);
|
|
293
293
|
const oraclePriceData = this.getOracleDataForPerpMarket(market.marketIndex);
|
|
294
|
+
if (perpPosition.lpShares.gt(numericConstants_1.ZERO)) {
|
|
295
|
+
perpPosition = this.getSettledLPPosition(perpPosition.marketIndex)[0];
|
|
296
|
+
}
|
|
294
297
|
let positionUnrealizedPnl = (0, _1.calculatePositionPNL)(market, perpPosition, withFunding, oraclePriceData);
|
|
295
298
|
if (withWeightMarginCategory !== undefined) {
|
|
296
299
|
if (positionUnrealizedPnl.gt(numericConstants_1.ZERO)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drift-labs/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0-beta.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"author": "crispheaney",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"@pythnetwork/client": "2.5.3",
|
|
39
39
|
"@solana/spl-token": "^0.1.6",
|
|
40
40
|
"@solana/web3.js": "1.66.2",
|
|
41
|
-
"@switchboard-xyz/switchboard-v2": "^0.0.67",
|
|
42
41
|
"strict-event-emitter-types": "^2.0.0",
|
|
43
42
|
"uuid": "^8.3.2"
|
|
44
43
|
},
|
|
@@ -2,7 +2,7 @@ import { isVariant, OracleSource } from '../types';
|
|
|
2
2
|
import { Connection } from '@solana/web3.js';
|
|
3
3
|
import { OracleClient } from '../oracles/types';
|
|
4
4
|
import { PythClient } from '../oracles/pythClient';
|
|
5
|
-
import { SwitchboardClient } from '../oracles/switchboardClient';
|
|
5
|
+
// import { SwitchboardClient } from '../oracles/switchboardClient';
|
|
6
6
|
import { QuoteAssetOracleClient } from '../oracles/quoteAssetOracleClient';
|
|
7
7
|
|
|
8
8
|
export function getOracleClient(
|
|
@@ -13,9 +13,9 @@ export function getOracleClient(
|
|
|
13
13
|
return new PythClient(connection);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
if (isVariant(oracleSource, 'switchboard')) {
|
|
17
|
-
|
|
18
|
-
}
|
|
16
|
+
// if (isVariant(oracleSource, 'switchboard')) {
|
|
17
|
+
// return new SwitchboardClient(connection);
|
|
18
|
+
// }
|
|
19
19
|
|
|
20
20
|
if (isVariant(oracleSource, 'quoteAsset')) {
|
|
21
21
|
return new QuoteAssetOracleClient();
|
package/src/idl/drift.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.11.0-beta.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -8558,6 +8558,11 @@
|
|
|
8558
8558
|
"code": 6223,
|
|
8559
8559
|
"name": "FailedUnwrap",
|
|
8560
8560
|
"msg": "Failed Unwrap"
|
|
8561
|
+
},
|
|
8562
|
+
{
|
|
8563
|
+
"code": 6224,
|
|
8564
|
+
"name": "MaxNumberOfUsers",
|
|
8565
|
+
"msg": "Max Number Of Users"
|
|
8561
8566
|
}
|
|
8562
8567
|
]
|
|
8563
8568
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import pyth from '@pythnetwork/client';
|
|
|
5
5
|
export * from './tokenFaucet';
|
|
6
6
|
export * from './oracles/types';
|
|
7
7
|
export * from './oracles/pythClient';
|
|
8
|
-
export * from './oracles/switchboardClient';
|
|
8
|
+
// export * from './oracles/switchboardClient';
|
|
9
9
|
export * from './types';
|
|
10
10
|
export * from './constants/perpMarkets';
|
|
11
11
|
export * from './accounts/fetch';
|
package/src/types.ts
CHANGED
|
@@ -74,7 +74,7 @@ export class DepositDirection {
|
|
|
74
74
|
|
|
75
75
|
export class OracleSource {
|
|
76
76
|
static readonly PYTH = { pyth: {} };
|
|
77
|
-
static readonly SWITCHBOARD = { switchboard: {} };
|
|
77
|
+
// static readonly SWITCHBOARD = { switchboard: {} };
|
|
78
78
|
static readonly QUOTE_ASSET = { quoteAsset: {} };
|
|
79
79
|
}
|
|
80
80
|
|
package/src/user.ts
CHANGED
|
@@ -447,6 +447,10 @@ export class User {
|
|
|
447
447
|
market.marketIndex
|
|
448
448
|
);
|
|
449
449
|
|
|
450
|
+
if (perpPosition.lpShares.gt(ZERO)) {
|
|
451
|
+
perpPosition = this.getSettledLPPosition(perpPosition.marketIndex)[0];
|
|
452
|
+
}
|
|
453
|
+
|
|
450
454
|
let positionUnrealizedPnl = calculatePositionPNL(
|
|
451
455
|
market,
|
|
452
456
|
perpPosition,
|