@drift-labs/sdk 2.43.0-beta.11 → 2.43.0-beta.12
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/user.js +7 -8
- package/package.json +1 -1
- package/src/user.ts +12 -8
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.43.0-beta.
|
|
1
|
+
2.43.0-beta.12
|
package/lib/user.js
CHANGED
|
@@ -1677,14 +1677,13 @@ class User {
|
|
|
1677
1677
|
withdrawLimit = _1.BN.max(withdrawLimit, userDepositAmount);
|
|
1678
1678
|
}
|
|
1679
1679
|
const assetWeight = (0, spotBalance_1.calculateAssetWeight)(userDepositAmount, oracleData.price, spotMarket, 'Initial');
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
.mul(precisionIncrease);
|
|
1680
|
+
let amountWithdrawable;
|
|
1681
|
+
if (assetWeight.eq(numericConstants_1.ZERO)) {
|
|
1682
|
+
amountWithdrawable = userDepositAmount;
|
|
1683
|
+
}
|
|
1684
|
+
else {
|
|
1685
|
+
amountWithdrawable = (0, _1.divCeil)((0, _1.divCeil)(freeCollateral.mul(numericConstants_1.MARGIN_PRECISION), assetWeight).mul(numericConstants_1.PRICE_PRECISION), oracleData.price).mul(precisionIncrease);
|
|
1686
|
+
}
|
|
1688
1687
|
const maxWithdrawValue = _1.BN.min(_1.BN.min(amountWithdrawable, userDepositAmount), withdrawLimit.abs());
|
|
1689
1688
|
if (reduceOnly) {
|
|
1690
1689
|
return _1.BN.max(maxWithdrawValue, numericConstants_1.ZERO);
|
package/package.json
CHANGED
package/src/user.ts
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
calculateReservePrice,
|
|
49
49
|
calculateSpotMarketMarginRatio,
|
|
50
50
|
calculateUnrealizedAssetWeight,
|
|
51
|
+
divCeil,
|
|
51
52
|
getBalance,
|
|
52
53
|
getSignedTokenAmount,
|
|
53
54
|
getStrictTokenValue,
|
|
@@ -3054,14 +3055,17 @@ export class User {
|
|
|
3054
3055
|
'Initial'
|
|
3055
3056
|
);
|
|
3056
3057
|
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3058
|
+
let amountWithdrawable;
|
|
3059
|
+
if (assetWeight.eq(ZERO)) {
|
|
3060
|
+
amountWithdrawable = userDepositAmount;
|
|
3061
|
+
} else {
|
|
3062
|
+
amountWithdrawable = divCeil(
|
|
3063
|
+
divCeil(freeCollateral.mul(MARGIN_PRECISION), assetWeight).mul(
|
|
3064
|
+
PRICE_PRECISION
|
|
3065
|
+
),
|
|
3066
|
+
oracleData.price
|
|
3067
|
+
).mul(precisionIncrease);
|
|
3068
|
+
}
|
|
3065
3069
|
|
|
3066
3070
|
const maxWithdrawValue = BN.min(
|
|
3067
3071
|
BN.min(amountWithdrawable, userDepositAmount),
|