@drift-labs/sdk 2.48.0-beta.22 → 2.48.0-beta.24
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/events/webSocketLogProvider.js +4 -0
- package/lib/user.js +4 -0
- package/package.json +1 -1
- package/src/events/webSocketLogProvider.ts +4 -0
- package/src/user.ts +3 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.48.0-beta.
|
|
1
|
+
2.48.0-beta.24
|
|
@@ -39,6 +39,10 @@ class WebSocketLogProvider {
|
|
|
39
39
|
this.receivingData = true;
|
|
40
40
|
clearTimeout(this.timeoutId);
|
|
41
41
|
this.setTimeout();
|
|
42
|
+
if (this.reconnectAttempts > 0) {
|
|
43
|
+
console.log('Resetting reconnect attempts to 0');
|
|
44
|
+
}
|
|
45
|
+
this.reconnectAttempts = 0;
|
|
42
46
|
}
|
|
43
47
|
callback(logs.signature, ctx.slot, logs.logs, undefined);
|
|
44
48
|
}, this.commitment);
|
package/lib/user.js
CHANGED
|
@@ -1670,6 +1670,7 @@ class User {
|
|
|
1670
1670
|
// eslint-disable-next-line prefer-const
|
|
1671
1671
|
let { borrowLimit, withdrawLimit } = (0, spotBalance_1.calculateWithdrawLimit)(spotMarket, nowTs);
|
|
1672
1672
|
const freeCollateral = this.getFreeCollateral();
|
|
1673
|
+
const initialMarginRequirement = this.getInitialMarginRequirement();
|
|
1673
1674
|
const oracleData = this.getOracleDataForSpotMarket(marketIndex);
|
|
1674
1675
|
const precisionIncrease = numericConstants_1.TEN.pow(new _1.BN(spotMarket.decimals - 6));
|
|
1675
1676
|
const { canBypass, depositAmount: userDepositAmount } = this.canBypassWithdrawLimits(marketIndex);
|
|
@@ -1681,6 +1682,9 @@ class User {
|
|
|
1681
1682
|
if (assetWeight.eq(numericConstants_1.ZERO)) {
|
|
1682
1683
|
amountWithdrawable = userDepositAmount;
|
|
1683
1684
|
}
|
|
1685
|
+
else if (initialMarginRequirement.eq(numericConstants_1.ZERO)) {
|
|
1686
|
+
amountWithdrawable = userDepositAmount;
|
|
1687
|
+
}
|
|
1684
1688
|
else {
|
|
1685
1689
|
amountWithdrawable = (0, _1.divCeil)((0, _1.divCeil)(freeCollateral.mul(numericConstants_1.MARGIN_PRECISION), assetWeight).mul(numericConstants_1.PRICE_PRECISION), oracleData.price).mul(precisionIncrease);
|
|
1686
1690
|
}
|
package/package.json
CHANGED
|
@@ -50,6 +50,10 @@ export class WebSocketLogProvider implements LogProvider {
|
|
|
50
50
|
this.receivingData = true;
|
|
51
51
|
clearTimeout(this.timeoutId);
|
|
52
52
|
this.setTimeout();
|
|
53
|
+
if (this.reconnectAttempts > 0) {
|
|
54
|
+
console.log('Resetting reconnect attempts to 0');
|
|
55
|
+
}
|
|
56
|
+
this.reconnectAttempts = 0;
|
|
53
57
|
}
|
|
54
58
|
callback(logs.signature, ctx.slot, logs.logs, undefined);
|
|
55
59
|
},
|
package/src/user.ts
CHANGED
|
@@ -3041,6 +3041,7 @@ export class User {
|
|
|
3041
3041
|
);
|
|
3042
3042
|
|
|
3043
3043
|
const freeCollateral = this.getFreeCollateral();
|
|
3044
|
+
const initialMarginRequirement = this.getInitialMarginRequirement();
|
|
3044
3045
|
const oracleData = this.getOracleDataForSpotMarket(marketIndex);
|
|
3045
3046
|
const precisionIncrease = TEN.pow(new BN(spotMarket.decimals - 6));
|
|
3046
3047
|
|
|
@@ -3060,6 +3061,8 @@ export class User {
|
|
|
3060
3061
|
let amountWithdrawable;
|
|
3061
3062
|
if (assetWeight.eq(ZERO)) {
|
|
3062
3063
|
amountWithdrawable = userDepositAmount;
|
|
3064
|
+
} else if (initialMarginRequirement.eq(ZERO)) {
|
|
3065
|
+
amountWithdrawable = userDepositAmount;
|
|
3063
3066
|
} else {
|
|
3064
3067
|
amountWithdrawable = divCeil(
|
|
3065
3068
|
divCeil(freeCollateral.mul(MARGIN_PRECISION), assetWeight).mul(
|