@drift-labs/sdk 2.35.1-beta.4 → 2.35.1-beta.6
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/driftClient.js +3 -2
- package/lib/user.js +7 -0
- package/package.json +1 -1
- package/src/driftClient.ts +3 -2
- package/src/user.ts +13 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.35.1-beta.
|
|
1
|
+
2.35.1-beta.6
|
package/lib/driftClient.js
CHANGED
|
@@ -3086,8 +3086,9 @@ class DriftClient {
|
|
|
3086
3086
|
* @param name
|
|
3087
3087
|
*/
|
|
3088
3088
|
getMarketIndexAndType(name) {
|
|
3089
|
+
name = name.toUpperCase();
|
|
3089
3090
|
for (const perpMarketAccount of this.getPerpMarketAccounts()) {
|
|
3090
|
-
if ((0, userName_1.decodeName)(perpMarketAccount.name) === name) {
|
|
3091
|
+
if ((0, userName_1.decodeName)(perpMarketAccount.name).toUpperCase() === name) {
|
|
3091
3092
|
return {
|
|
3092
3093
|
marketIndex: perpMarketAccount.marketIndex,
|
|
3093
3094
|
marketType: types_1.MarketType.PERP,
|
|
@@ -3095,7 +3096,7 @@ class DriftClient {
|
|
|
3095
3096
|
}
|
|
3096
3097
|
}
|
|
3097
3098
|
for (const spotMarketAccount of this.getSpotMarketAccounts()) {
|
|
3098
|
-
if ((0, userName_1.decodeName)(spotMarketAccount.name) === name) {
|
|
3099
|
+
if ((0, userName_1.decodeName)(spotMarketAccount.name).toUpperCase() === name) {
|
|
3099
3100
|
return {
|
|
3100
3101
|
marketIndex: spotMarketAccount.marketIndex,
|
|
3101
3102
|
marketType: types_1.MarketType.SPOT,
|
package/lib/user.js
CHANGED
|
@@ -709,6 +709,13 @@ class User {
|
|
|
709
709
|
.div(numericConstants_1.MARGIN_PRECISION);
|
|
710
710
|
if (includeOpenOrders) {
|
|
711
711
|
baseAssetValue = baseAssetValue.add(new _1.BN(perpPosition.openOrders).mul(numericConstants_1.OPEN_ORDER_MARGIN_REQUIREMENT));
|
|
712
|
+
if (perpPosition.lpShares.gt(numericConstants_1.ZERO)) {
|
|
713
|
+
baseAssetValue = baseAssetValue.add(_1.BN.max(numericConstants_1.QUOTE_PRECISION, valuationPrice
|
|
714
|
+
.mul(market.amm.orderStepSize)
|
|
715
|
+
.mul(numericConstants_1.QUOTE_PRECISION)
|
|
716
|
+
.div(numericConstants_1.AMM_RESERVE_PRECISION)
|
|
717
|
+
.div(numericConstants_1.PRICE_PRECISION)));
|
|
718
|
+
}
|
|
712
719
|
}
|
|
713
720
|
}
|
|
714
721
|
return totalPerpValue.add(baseAssetValue);
|
package/package.json
CHANGED
package/src/driftClient.ts
CHANGED
|
@@ -5566,8 +5566,9 @@ export class DriftClient {
|
|
|
5566
5566
|
getMarketIndexAndType(
|
|
5567
5567
|
name: string
|
|
5568
5568
|
): { marketIndex: number; marketType: MarketType } | undefined {
|
|
5569
|
+
name = name.toUpperCase();
|
|
5569
5570
|
for (const perpMarketAccount of this.getPerpMarketAccounts()) {
|
|
5570
|
-
if (decodeName(perpMarketAccount.name) === name) {
|
|
5571
|
+
if (decodeName(perpMarketAccount.name).toUpperCase() === name) {
|
|
5571
5572
|
return {
|
|
5572
5573
|
marketIndex: perpMarketAccount.marketIndex,
|
|
5573
5574
|
marketType: MarketType.PERP,
|
|
@@ -5576,7 +5577,7 @@ export class DriftClient {
|
|
|
5576
5577
|
}
|
|
5577
5578
|
|
|
5578
5579
|
for (const spotMarketAccount of this.getSpotMarketAccounts()) {
|
|
5579
|
-
if (decodeName(spotMarketAccount.name) === name) {
|
|
5580
|
+
if (decodeName(spotMarketAccount.name).toUpperCase() === name) {
|
|
5580
5581
|
return {
|
|
5581
5582
|
marketIndex: spotMarketAccount.marketIndex,
|
|
5582
5583
|
marketType: MarketType.SPOT,
|
package/src/user.ts
CHANGED
|
@@ -1290,6 +1290,19 @@ export class User {
|
|
|
1290
1290
|
baseAssetValue = baseAssetValue.add(
|
|
1291
1291
|
new BN(perpPosition.openOrders).mul(OPEN_ORDER_MARGIN_REQUIREMENT)
|
|
1292
1292
|
);
|
|
1293
|
+
|
|
1294
|
+
if (perpPosition.lpShares.gt(ZERO)) {
|
|
1295
|
+
baseAssetValue = baseAssetValue.add(
|
|
1296
|
+
BN.max(
|
|
1297
|
+
QUOTE_PRECISION,
|
|
1298
|
+
valuationPrice
|
|
1299
|
+
.mul(market.amm.orderStepSize)
|
|
1300
|
+
.mul(QUOTE_PRECISION)
|
|
1301
|
+
.div(AMM_RESERVE_PRECISION)
|
|
1302
|
+
.div(PRICE_PRECISION)
|
|
1303
|
+
)
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1293
1306
|
}
|
|
1294
1307
|
}
|
|
1295
1308
|
|