@defisaver/positions-sdk 0.0.183-dev-allocator-5 → 0.0.183-dev-allocator-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.
@@ -189,7 +189,7 @@ const getLiquidityToAllocate = (amountToBorrow, totalBorrow, totalSupply, target
189
189
  .toFixed(0)
190
190
  .toString();
191
191
  if (new decimal_js_1.default(reallocatableLiquidityAssets).lt(liquidityToAllocate) || new decimal_js_1.default(liquidityToAllocate).lt('0')) {
192
- liquidityToAllocate = new decimal_js_1.default(amountToBorrow).sub(leftToBorrow).toString();
192
+ liquidityToAllocate = new decimal_js_1.default(amountToBorrow).lt(leftToBorrow) ? '0' : new decimal_js_1.default(amountToBorrow).sub(leftToBorrow).toString();
193
193
  if (new decimal_js_1.default(reallocatableLiquidityAssets).lt(liquidityToAllocate))
194
194
  throw new Error('Not enough liquidity available to allocate');
195
195
  }
@@ -178,7 +178,7 @@ export const getLiquidityToAllocate = (amountToBorrow, totalBorrow, totalSupply,
178
178
  .toFixed(0)
179
179
  .toString();
180
180
  if (new Dec(reallocatableLiquidityAssets).lt(liquidityToAllocate) || new Dec(liquidityToAllocate).lt('0')) {
181
- liquidityToAllocate = new Dec(amountToBorrow).sub(leftToBorrow).toString();
181
+ liquidityToAllocate = new Dec(amountToBorrow).lt(leftToBorrow) ? '0' : new Dec(amountToBorrow).sub(leftToBorrow).toString();
182
182
  if (new Dec(reallocatableLiquidityAssets).lt(liquidityToAllocate))
183
183
  throw new Error('Not enough liquidity available to allocate');
184
184
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "0.0.183-dev-allocator-5",
3
+ "version": "0.0.183-dev-allocator-6",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -202,7 +202,7 @@ export const getLiquidityToAllocate = (amountToBorrow: string, totalBorrow: stri
202
202
  .toString();
203
203
 
204
204
  if (new Dec(reallocatableLiquidityAssets).lt(liquidityToAllocate) || new Dec(liquidityToAllocate).lt('0')) {
205
- liquidityToAllocate = new Dec(amountToBorrow).sub(leftToBorrow).toString();
205
+ liquidityToAllocate = new Dec(amountToBorrow).lt(leftToBorrow) ? '0' : new Dec(amountToBorrow).sub(leftToBorrow).toString();
206
206
  if (new Dec(reallocatableLiquidityAssets).lt(liquidityToAllocate)) throw new Error('Not enough liquidity available to allocate');
207
207
  }
208
208