@defisaver/positions-sdk 0.0.183-dev-allocator-4 → 0.0.183-dev-allocator-5
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.
|
@@ -188,7 +188,7 @@ const getLiquidityToAllocate = (amountToBorrow, totalBorrow, totalSupply, target
|
|
|
188
188
|
let liquidityToAllocate = new decimal_js_1.default(newTotalBorrowAssets).div(targetBorrowUtilization).mul(1e18).sub(totalSupply)
|
|
189
189
|
.toFixed(0)
|
|
190
190
|
.toString();
|
|
191
|
-
if (new decimal_js_1.default(reallocatableLiquidityAssets).lt(liquidityToAllocate)) {
|
|
191
|
+
if (new decimal_js_1.default(reallocatableLiquidityAssets).lt(liquidityToAllocate) || new decimal_js_1.default(liquidityToAllocate).lt('0')) {
|
|
192
192
|
liquidityToAllocate = 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');
|
|
@@ -177,7 +177,7 @@ export const getLiquidityToAllocate = (amountToBorrow, totalBorrow, totalSupply,
|
|
|
177
177
|
let liquidityToAllocate = new Dec(newTotalBorrowAssets).div(targetBorrowUtilization).mul(1e18).sub(totalSupply)
|
|
178
178
|
.toFixed(0)
|
|
179
179
|
.toString();
|
|
180
|
-
if (new Dec(reallocatableLiquidityAssets).lt(liquidityToAllocate)) {
|
|
180
|
+
if (new Dec(reallocatableLiquidityAssets).lt(liquidityToAllocate) || new Dec(liquidityToAllocate).lt('0')) {
|
|
181
181
|
liquidityToAllocate = 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');
|
package/package.json
CHANGED
|
@@ -201,7 +201,7 @@ export const getLiquidityToAllocate = (amountToBorrow: string, totalBorrow: stri
|
|
|
201
201
|
.toFixed(0)
|
|
202
202
|
.toString();
|
|
203
203
|
|
|
204
|
-
if (new Dec(reallocatableLiquidityAssets).lt(liquidityToAllocate)) {
|
|
204
|
+
if (new Dec(reallocatableLiquidityAssets).lt(liquidityToAllocate) || new Dec(liquidityToAllocate).lt('0')) {
|
|
205
205
|
liquidityToAllocate = 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
|
}
|