@drift-labs/sdk 2.32.1-beta.7 → 2.32.1-beta.9
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 +3 -2
- package/package.json +1 -1
- package/src/user.ts +3 -2
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.32.1-beta.
|
|
1
|
+
2.32.1-beta.9
|
package/lib/user.js
CHANGED
|
@@ -1151,7 +1151,7 @@ class User {
|
|
|
1151
1151
|
.div(numericConstants_1.SPOT_MARKET_WEIGHT_PRECISION.div(new _1.BN(100)))
|
|
1152
1152
|
.div(inOraclePrice); // just assume user can go 100x
|
|
1153
1153
|
inSwap = maxSwap.div(numericConstants_1.TWO);
|
|
1154
|
-
const error =
|
|
1154
|
+
const error = freeCollateral.div(new _1.BN(10000));
|
|
1155
1155
|
let i = 0;
|
|
1156
1156
|
let freeCollateralAfter = freeCollateral;
|
|
1157
1157
|
while (freeCollateralAfter.gt(error) || freeCollateralAfter.isNeg()) {
|
|
@@ -1172,7 +1172,8 @@ class User {
|
|
|
1172
1172
|
inSwap = minSwap.add(maxSwap).div(numericConstants_1.TWO);
|
|
1173
1173
|
}
|
|
1174
1174
|
if (i++ > iterationLimit) {
|
|
1175
|
-
|
|
1175
|
+
console.log('getMaxSwapAmount iteration limit reached');
|
|
1176
|
+
break;
|
|
1176
1177
|
}
|
|
1177
1178
|
}
|
|
1178
1179
|
}
|
package/package.json
CHANGED
package/src/user.ts
CHANGED
|
@@ -2066,7 +2066,7 @@ export class User {
|
|
|
2066
2066
|
.div(SPOT_MARKET_WEIGHT_PRECISION.div(new BN(100)))
|
|
2067
2067
|
.div(inOraclePrice); // just assume user can go 100x
|
|
2068
2068
|
inSwap = maxSwap.div(TWO);
|
|
2069
|
-
const error =
|
|
2069
|
+
const error = freeCollateral.div(new BN(10000));
|
|
2070
2070
|
|
|
2071
2071
|
let i = 0;
|
|
2072
2072
|
let freeCollateralAfter = freeCollateral;
|
|
@@ -2106,7 +2106,8 @@ export class User {
|
|
|
2106
2106
|
}
|
|
2107
2107
|
|
|
2108
2108
|
if (i++ > iterationLimit) {
|
|
2109
|
-
|
|
2109
|
+
console.log('getMaxSwapAmount iteration limit reached');
|
|
2110
|
+
break;
|
|
2110
2111
|
}
|
|
2111
2112
|
}
|
|
2112
2113
|
}
|