@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 CHANGED
@@ -1 +1 @@
1
- 2.32.1-beta.7
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 = _1.BN.min(numericConstants_1.QUOTE_PRECISION, freeCollateral.div(new _1.BN(100)));
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
- throw new Error('getMaxSwapAmount iteration limit reached');
1175
+ console.log('getMaxSwapAmount iteration limit reached');
1176
+ break;
1176
1177
  }
1177
1178
  }
1178
1179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.32.1-beta.7",
3
+ "version": "2.32.1-beta.9",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
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 = BN.min(QUOTE_PRECISION, freeCollateral.div(new BN(100)));
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
- throw new Error('getMaxSwapAmount iteration limit reached');
2109
+ console.log('getMaxSwapAmount iteration limit reached');
2110
+ break;
2110
2111
  }
2111
2112
  }
2112
2113
  }