@gearbox-protocol/sdk 18.3.0 → 18.3.1
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_utils_bigint_math = require("../../utils/bigint-math.js");
|
|
3
|
+
const require_onchain_constants_math = require("../../constants/math.js");
|
|
3
4
|
const require_onchain_accounts_intents_utils_common = require("./utils/common.js");
|
|
4
5
|
const require_onchain_accounts_intents_collateral_valuation = require("./collateral-valuation.js");
|
|
5
6
|
//#region src/onchain/accounts/intents/maxBorrowAndWithdraw.ts
|
|
@@ -19,7 +20,8 @@ function maxBorrowAndWithdraw(props) {
|
|
|
19
20
|
return market.priceOracle.safeConvertFromUSD(creditAccount.underlying, backed / target).value;
|
|
20
21
|
};
|
|
21
22
|
const totalDebt = require_onchain_utils_bigint_math.BigIntMath.min(supportedDebt(targetHF, false), supportedDebt(targetSafeHF, true), suite.creditFacade.maxDebt);
|
|
22
|
-
const
|
|
23
|
+
const borrowable = suite.maxBorrowAmount().amount.value * (require_onchain_constants_math.PERCENTAGE_FACTOR - 2n) / require_onchain_constants_math.PERCENTAGE_FACTOR;
|
|
24
|
+
const additional = require_onchain_utils_bigint_math.BigIntMath.max(0n, require_onchain_utils_bigint_math.BigIntMath.min(totalDebt - creditAccount.totalDebt, borrowable));
|
|
23
25
|
const asset = sdk.tokensMeta.rwaUnderlyings.get(creditAccount.underlying)?.asset;
|
|
24
26
|
const payout = asset ? require_onchain_accounts_intents_utils_common.toTargetDecimals(additional, creditAccount.underlying, asset, sdk) : additional;
|
|
25
27
|
const increase = asset ? require_onchain_accounts_intents_utils_common.toTargetDecimals(payout, asset, creditAccount.underlying, sdk) : payout;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BigIntMath } from "../../utils/bigint-math.js";
|
|
2
|
+
import { PERCENTAGE_FACTOR } from "../../constants/math.js";
|
|
2
3
|
import { toTargetDecimals } from "./utils/common.js";
|
|
3
4
|
import { collateralValuation } from "./collateral-valuation.js";
|
|
4
5
|
//#region src/onchain/accounts/intents/maxBorrowAndWithdraw.ts
|
|
@@ -18,7 +19,8 @@ function maxBorrowAndWithdraw(props) {
|
|
|
18
19
|
return market.priceOracle.safeConvertFromUSD(creditAccount.underlying, backed / target).value;
|
|
19
20
|
};
|
|
20
21
|
const totalDebt = BigIntMath.min(supportedDebt(targetHF, false), supportedDebt(targetSafeHF, true), suite.creditFacade.maxDebt);
|
|
21
|
-
const
|
|
22
|
+
const borrowable = suite.maxBorrowAmount().amount.value * (PERCENTAGE_FACTOR - 2n) / PERCENTAGE_FACTOR;
|
|
23
|
+
const additional = BigIntMath.max(0n, BigIntMath.min(totalDebt - creditAccount.totalDebt, borrowable));
|
|
22
24
|
const asset = sdk.tokensMeta.rwaUnderlyings.get(creditAccount.underlying)?.asset;
|
|
23
25
|
const payout = asset ? toTargetDecimals(additional, creditAccount.underlying, asset, sdk) : additional;
|
|
24
26
|
const increase = asset ? toTargetDecimals(payout, asset, creditAccount.underlying, sdk) : payout;
|