@gearbox-protocol/sdk 14.10.2-next.1 → 14.10.2-next.2
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/dist/cjs/common-utils/utils/apy/index.js +8 -0
- package/dist/cjs/common-utils/utils/index.js +5 -1
- package/dist/cjs/common-utils/utils/strategies/assets/index.js +22 -0
- package/dist/cjs/common-utils/utils/strategies/availability/index.js +1 -5
- package/dist/cjs/common-utils/utils/strategies/credit-managers/index.js +4 -0
- package/dist/cjs/common-utils/utils/strategies/index.js +2 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/index.js +8 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/cm-availability-condition.js +5 -4
- package/dist/cjs/common-utils/utils/strategies/strategy-info/index.js +8 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/index.js +19 -1
- package/dist/cjs/common-utils/utils/strategies/types/index.js +4 -0
- package/dist/cjs/common-utils/utils/validation/index.js +38 -0
- package/dist/cjs/plugins/apy/strategy-data-source.js +1 -0
- package/dist/esm/common-utils/utils/apy/index.js +4 -0
- package/dist/esm/common-utils/utils/index.js +2 -0
- package/dist/esm/common-utils/utils/strategies/assets/index.js +1 -0
- package/dist/esm/common-utils/utils/strategies/availability/index.js +0 -2
- package/dist/esm/common-utils/utils/strategies/credit-managers/index.js +2 -0
- package/dist/esm/common-utils/utils/strategies/index.js +1 -0
- package/dist/esm/common-utils/utils/strategies/leverage/index.js +4 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/cm-availability-condition.js +2 -5
- package/dist/esm/common-utils/utils/strategies/strategy-info/index.js +4 -0
- package/dist/esm/common-utils/utils/strategies/tokens/index.js +9 -0
- package/dist/esm/common-utils/utils/strategies/types/index.js +2 -0
- package/dist/esm/common-utils/utils/validation/index.js +9 -0
- package/dist/esm/plugins/apy/strategy-data-source.js +1 -0
- package/dist/types/common-utils/utils/apy/index.d.ts +4 -0
- package/dist/types/common-utils/utils/index.d.ts +2 -0
- package/dist/types/common-utils/utils/strategies/assets/index.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/availability/index.d.ts +0 -2
- package/dist/types/common-utils/utils/strategies/credit-managers/index.d.ts +2 -0
- package/dist/types/common-utils/utils/strategies/index.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/leverage/index.d.ts +4 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/index.d.ts +4 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/types.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/tokens/index.d.ts +9 -0
- package/dist/types/common-utils/utils/strategies/types/index.d.ts +2 -0
- package/dist/types/common-utils/utils/validation/index.d.ts +9 -0
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.d.ts +2 -2
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-status.d.ts +3 -3
- package/dist/types/common-utils/utils/validation/validate-open-account.d.ts +2 -2
- package/dist/types/common-utils/utils/validation/validate-quota.d.ts +2 -2
- package/package.json +1 -1
- package/dist/cjs/common-utils/utils/strategies/availability/validate-open-account-pool-quota-status.js +0 -40
- package/dist/cjs/common-utils/utils/strategies/availability/validate-open-account-pool-status.js +0 -76
- package/dist/esm/common-utils/utils/strategies/availability/validate-open-account-pool-quota-status.js +0 -16
- package/dist/esm/common-utils/utils/strategies/availability/validate-open-account-pool-status.js +0 -52
- package/dist/types/common-utils/utils/strategies/availability/validate-open-account-pool-quota-status.d.ts +0 -6
- package/dist/types/common-utils/utils/strategies/availability/validate-open-account-pool-status.d.ts +0 -24
|
@@ -16,17 +16,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var apy_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(apy_exports);
|
|
18
18
|
__reExport(apy_exports, require("./bonus-apy-from-points.js"), module.exports);
|
|
19
|
+
__reExport(apy_exports, require("./calculate-borrow-rate-from-utilization.js"), module.exports);
|
|
20
|
+
__reExport(apy_exports, require("./calculate-earnings.js"), module.exports);
|
|
19
21
|
__reExport(apy_exports, require("./calculate-effective-borrow-rate.js"), module.exports);
|
|
22
|
+
__reExport(apy_exports, require("./calculate-safe-borrow-rate.js"), module.exports);
|
|
20
23
|
__reExport(apy_exports, require("./get-complex-apy-list.js"), module.exports);
|
|
21
24
|
__reExport(apy_exports, require("./get-rate-with-fee.js"), module.exports);
|
|
25
|
+
__reExport(apy_exports, require("./get-safe-base-borrow-rate.js"), module.exports);
|
|
22
26
|
__reExport(apy_exports, require("./get-single-quota-borrow-rate.js"), module.exports);
|
|
23
27
|
__reExport(apy_exports, require("./max-apy-formula.js"), module.exports);
|
|
24
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
29
|
0 && (module.exports = {
|
|
26
30
|
...require("./bonus-apy-from-points.js"),
|
|
31
|
+
...require("./calculate-borrow-rate-from-utilization.js"),
|
|
32
|
+
...require("./calculate-earnings.js"),
|
|
27
33
|
...require("./calculate-effective-borrow-rate.js"),
|
|
34
|
+
...require("./calculate-safe-borrow-rate.js"),
|
|
28
35
|
...require("./get-complex-apy-list.js"),
|
|
29
36
|
...require("./get-rate-with-fee.js"),
|
|
37
|
+
...require("./get-safe-base-borrow-rate.js"),
|
|
30
38
|
...require("./get-single-quota-borrow-rate.js"),
|
|
31
39
|
...require("./max-apy-formula.js")
|
|
32
40
|
});
|
|
@@ -18,15 +18,19 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
18
18
|
__reExport(utils_exports, require("./apy/index.js"), module.exports);
|
|
19
19
|
__reExport(utils_exports, require("./assets-math.js"), module.exports);
|
|
20
20
|
__reExport(utils_exports, require("./bigint-math.js"), module.exports);
|
|
21
|
+
__reExport(utils_exports, require("./constants.js"), module.exports);
|
|
21
22
|
__reExport(utils_exports, require("./creditAccount/index.js"), module.exports);
|
|
22
23
|
__reExport(utils_exports, require("./price-math.js"), module.exports);
|
|
23
24
|
__reExport(utils_exports, require("./strategies/index.js"), module.exports);
|
|
25
|
+
__reExport(utils_exports, require("./validation/index.js"), module.exports);
|
|
24
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
27
|
0 && (module.exports = {
|
|
26
28
|
...require("./apy/index.js"),
|
|
27
29
|
...require("./assets-math.js"),
|
|
28
30
|
...require("./bigint-math.js"),
|
|
31
|
+
...require("./constants.js"),
|
|
29
32
|
...require("./creditAccount/index.js"),
|
|
30
33
|
...require("./price-math.js"),
|
|
31
|
-
...require("./strategies/index.js")
|
|
34
|
+
...require("./strategies/index.js"),
|
|
35
|
+
...require("./validation/index.js")
|
|
32
36
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var assets_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(assets_exports);
|
|
18
|
+
__reExport(assets_exports, require("./assets.js"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./assets.js")
|
|
22
|
+
});
|
|
@@ -17,12 +17,8 @@ var availability_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(availability_exports);
|
|
18
18
|
__reExport(availability_exports, require("./check-boolean.js"), module.exports);
|
|
19
19
|
__reExport(availability_exports, require("./check-degen-nft.js"), module.exports);
|
|
20
|
-
__reExport(availability_exports, require("./validate-open-account-pool-quota-status.js"), module.exports);
|
|
21
|
-
__reExport(availability_exports, require("./validate-open-account-pool-status.js"), module.exports);
|
|
22
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23
21
|
0 && (module.exports = {
|
|
24
22
|
...require("./check-boolean.js"),
|
|
25
|
-
...require("./check-degen-nft.js")
|
|
26
|
-
...require("./validate-open-account-pool-quota-status.js"),
|
|
27
|
-
...require("./validate-open-account-pool-status.js")
|
|
23
|
+
...require("./check-degen-nft.js")
|
|
28
24
|
});
|
|
@@ -15,14 +15,18 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var credit_managers_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(credit_managers_exports);
|
|
18
|
+
__reExport(credit_managers_exports, require("./get-cm-allowed-collaterals.js"), module.exports);
|
|
18
19
|
__reExport(credit_managers_exports, require("./get-strategy-credit-managers.js"), module.exports);
|
|
19
20
|
__reExport(credit_managers_exports, require("./get-strategy-credit-managers-list.js"), module.exports);
|
|
20
21
|
__reExport(credit_managers_exports, require("./get-strategy-credit-managers-list-core.js"), module.exports);
|
|
22
|
+
__reExport(credit_managers_exports, require("./get-wallet-balances-allowed-on-cm.js"), module.exports);
|
|
21
23
|
__reExport(credit_managers_exports, require("./is-credit-manager-usable.js"), module.exports);
|
|
22
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23
25
|
0 && (module.exports = {
|
|
26
|
+
...require("./get-cm-allowed-collaterals.js"),
|
|
24
27
|
...require("./get-strategy-credit-managers.js"),
|
|
25
28
|
...require("./get-strategy-credit-managers-list.js"),
|
|
26
29
|
...require("./get-strategy-credit-managers-list-core.js"),
|
|
30
|
+
...require("./get-wallet-balances-allowed-on-cm.js"),
|
|
27
31
|
...require("./is-credit-manager-usable.js")
|
|
28
32
|
});
|
|
@@ -15,6 +15,7 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var strategies_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(strategies_exports);
|
|
18
|
+
__reExport(strategies_exports, require("./assets/index.js"), module.exports);
|
|
18
19
|
__reExport(strategies_exports, require("./availability/index.js"), module.exports);
|
|
19
20
|
__reExport(strategies_exports, require("./credit-managers/index.js"), module.exports);
|
|
20
21
|
__reExport(strategies_exports, require("./eligibility/index.js"), module.exports);
|
|
@@ -28,6 +29,7 @@ __reExport(strategies_exports, require("./tokens/index.js"), module.exports);
|
|
|
28
29
|
__reExport(strategies_exports, require("./types.js"), module.exports);
|
|
29
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
31
|
0 && (module.exports = {
|
|
32
|
+
...require("./assets/index.js"),
|
|
31
33
|
...require("./availability/index.js"),
|
|
32
34
|
...require("./credit-managers/index.js"),
|
|
33
35
|
...require("./eligibility/index.js"),
|
|
@@ -17,16 +17,24 @@ var leverage_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(leverage_exports);
|
|
18
18
|
__reExport(leverage_exports, require("./calculate-loss-coefficient.js"), module.exports);
|
|
19
19
|
__reExport(leverage_exports, require("./calculate-max-leverage-factor.js"), module.exports);
|
|
20
|
+
__reExport(leverage_exports, require("./calculate-max-strategy-debt.js"), module.exports);
|
|
21
|
+
__reExport(leverage_exports, require("./get-collateral-by-debt.js"), module.exports);
|
|
20
22
|
__reExport(leverage_exports, require("./get-factor-from-leverage.js"), module.exports);
|
|
21
23
|
__reExport(leverage_exports, require("./get-leverage-from-factor.js"), module.exports);
|
|
24
|
+
__reExport(leverage_exports, require("./get-recommended-debt.js"), module.exports);
|
|
25
|
+
__reExport(leverage_exports, require("./get-recommended-leverage-factor.js"), module.exports);
|
|
22
26
|
__reExport(leverage_exports, require("./max-leverage.js"), module.exports);
|
|
23
27
|
__reExport(leverage_exports, require("./max-leverage-threshold.js"), module.exports);
|
|
24
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
29
|
0 && (module.exports = {
|
|
26
30
|
...require("./calculate-loss-coefficient.js"),
|
|
27
31
|
...require("./calculate-max-leverage-factor.js"),
|
|
32
|
+
...require("./calculate-max-strategy-debt.js"),
|
|
33
|
+
...require("./get-collateral-by-debt.js"),
|
|
28
34
|
...require("./get-factor-from-leverage.js"),
|
|
29
35
|
...require("./get-leverage-from-factor.js"),
|
|
36
|
+
...require("./get-recommended-debt.js"),
|
|
37
|
+
...require("./get-recommended-leverage-factor.js"),
|
|
30
38
|
...require("./max-leverage.js"),
|
|
31
39
|
...require("./max-leverage-threshold.js")
|
|
32
40
|
});
|
|
@@ -21,15 +21,16 @@ __export(cm_availability_condition_exports, {
|
|
|
21
21
|
cmAvailabilityCondition: () => cmAvailabilityCondition
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(cm_availability_condition_exports);
|
|
24
|
+
var import_validate_open_account_pool_status = require("../../validation/validate-open-account-pool-status.js");
|
|
24
25
|
var import_availability = require("../availability/index.js");
|
|
25
26
|
function cmAvailabilityCondition(targetToken, cmA, cmB, pools) {
|
|
26
|
-
const aHasMinError = (0,
|
|
27
|
+
const aHasMinError = (0, import_validate_open_account_pool_status.validateOpenAccountPoolStatus)({
|
|
27
28
|
pool: pools?.[cmA.pool],
|
|
28
29
|
debt: cmA.minDebt,
|
|
29
30
|
creditManager: cmA,
|
|
30
31
|
targetToken
|
|
31
32
|
});
|
|
32
|
-
const bHasMinError = (0,
|
|
33
|
+
const bHasMinError = (0, import_validate_open_account_pool_status.validateOpenAccountPoolStatus)({
|
|
33
34
|
pool: pools?.[cmB.pool],
|
|
34
35
|
debt: cmB.minDebt,
|
|
35
36
|
creditManager: cmB,
|
|
@@ -41,13 +42,13 @@ function cmAvailabilityCondition(targetToken, cmA, cmB, pools) {
|
|
|
41
42
|
const { freeOfNFT: bFreeOfNFT } = (0, import_availability.checkDegenNFT)(cmB);
|
|
42
43
|
const nftSort = (0, import_availability.checkBoolean)(aFreeOfNFT, bFreeOfNFT);
|
|
43
44
|
if (nftSort !== 0) return nftSort;
|
|
44
|
-
const aHasMaxError = (0,
|
|
45
|
+
const aHasMaxError = (0, import_validate_open_account_pool_status.validateOpenAccountPoolStatus)({
|
|
45
46
|
pool: pools?.[cmA.pool],
|
|
46
47
|
debt: cmA.maxDebt,
|
|
47
48
|
creditManager: cmA,
|
|
48
49
|
targetToken
|
|
49
50
|
});
|
|
50
|
-
const bHasMaxError = (0,
|
|
51
|
+
const bHasMaxError = (0, import_validate_open_account_pool_status.validateOpenAccountPoolStatus)({
|
|
51
52
|
pool: pools?.[cmB.pool],
|
|
52
53
|
debt: cmB.maxDebt,
|
|
53
54
|
creditManager: cmB,
|
|
@@ -15,18 +15,26 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var strategy_info_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(strategy_info_exports);
|
|
18
|
+
__reExport(strategy_info_exports, require("./calculate-total-apy.js"), module.exports);
|
|
19
|
+
__reExport(strategy_info_exports, require("./calculate-total-points.js"), module.exports);
|
|
18
20
|
__reExport(strategy_info_exports, require("./cm-availability-condition.js"), module.exports);
|
|
21
|
+
__reExport(strategy_info_exports, require("./get-cm-you-can-earn.js"), module.exports);
|
|
19
22
|
__reExport(strategy_info_exports, require("./get-strategy-info.js"), module.exports);
|
|
20
23
|
__reExport(strategy_info_exports, require("./get-strategy-info-core.js"), module.exports);
|
|
21
24
|
__reExport(strategy_info_exports, require("./get-strategy-max-apy.js"), module.exports);
|
|
25
|
+
__reExport(strategy_info_exports, require("./get-strategy-you-can-earn.js"), module.exports);
|
|
22
26
|
__reExport(strategy_info_exports, require("./is-strategy-cm-disabled.js"), module.exports);
|
|
23
27
|
__reExport(strategy_info_exports, require("./types.js"), module.exports);
|
|
24
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
29
|
0 && (module.exports = {
|
|
30
|
+
...require("./calculate-total-apy.js"),
|
|
31
|
+
...require("./calculate-total-points.js"),
|
|
26
32
|
...require("./cm-availability-condition.js"),
|
|
33
|
+
...require("./get-cm-you-can-earn.js"),
|
|
27
34
|
...require("./get-strategy-info.js"),
|
|
28
35
|
...require("./get-strategy-info-core.js"),
|
|
29
36
|
...require("./get-strategy-max-apy.js"),
|
|
37
|
+
...require("./get-strategy-you-can-earn.js"),
|
|
30
38
|
...require("./is-strategy-cm-disabled.js"),
|
|
31
39
|
...require("./types.js")
|
|
32
40
|
});
|
|
@@ -15,12 +15,30 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var tokens_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(tokens_exports);
|
|
18
|
+
__reExport(tokens_exports, require("./add-amount-in-target.js"), module.exports);
|
|
19
|
+
__reExport(tokens_exports, require("./get-chain-phantom-tokens.js"), module.exports);
|
|
20
|
+
__reExport(tokens_exports, require("./get-list-with-amount-in-target.js"), module.exports);
|
|
21
|
+
__reExport(tokens_exports, require("./get-native-token-address.js"), module.exports);
|
|
18
22
|
__reExport(tokens_exports, require("./is-activated-token.js"), module.exports);
|
|
23
|
+
__reExport(tokens_exports, require("./is-apy-with-points-exception.js"), module.exports);
|
|
24
|
+
__reExport(tokens_exports, require("./is-collateral-token.js"), module.exports);
|
|
19
25
|
__reExport(tokens_exports, require("./is-forbidden-token.js"), module.exports);
|
|
26
|
+
__reExport(tokens_exports, require("./is-obtainable-token.js"), module.exports);
|
|
20
27
|
__reExport(tokens_exports, require("./is-usable-token.js"), module.exports);
|
|
28
|
+
__reExport(tokens_exports, require("./is-valid-extra-collateral-token.js"), module.exports);
|
|
29
|
+
__reExport(tokens_exports, require("./wrap-token-address.js"), module.exports);
|
|
21
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
31
|
0 && (module.exports = {
|
|
32
|
+
...require("./add-amount-in-target.js"),
|
|
33
|
+
...require("./get-chain-phantom-tokens.js"),
|
|
34
|
+
...require("./get-list-with-amount-in-target.js"),
|
|
35
|
+
...require("./get-native-token-address.js"),
|
|
23
36
|
...require("./is-activated-token.js"),
|
|
37
|
+
...require("./is-apy-with-points-exception.js"),
|
|
38
|
+
...require("./is-collateral-token.js"),
|
|
24
39
|
...require("./is-forbidden-token.js"),
|
|
25
|
-
...require("./is-
|
|
40
|
+
...require("./is-obtainable-token.js"),
|
|
41
|
+
...require("./is-usable-token.js"),
|
|
42
|
+
...require("./is-valid-extra-collateral-token.js"),
|
|
43
|
+
...require("./wrap-token-address.js")
|
|
26
44
|
});
|
|
@@ -23,7 +23,9 @@ __reExport(types_exports, require("./points-slices.js"), module.exports);
|
|
|
23
23
|
__reExport(types_exports, require("./sdk-state.js"), module.exports);
|
|
24
24
|
__reExport(types_exports, require("./strategies-cm-list.js"), module.exports);
|
|
25
25
|
__reExport(types_exports, require("./strategy.js"), module.exports);
|
|
26
|
+
__reExport(types_exports, require("./strategy-data.js"), module.exports);
|
|
26
27
|
__reExport(types_exports, require("./strategy-data-source.js"), module.exports);
|
|
28
|
+
__reExport(types_exports, require("./strategy-earnings.js"), module.exports);
|
|
27
29
|
__reExport(types_exports, require("./targetable.js"), module.exports);
|
|
28
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
31
|
0 && (module.exports = {
|
|
@@ -35,6 +37,8 @@ __reExport(types_exports, require("./targetable.js"), module.exports);
|
|
|
35
37
|
...require("./sdk-state.js"),
|
|
36
38
|
...require("./strategies-cm-list.js"),
|
|
37
39
|
...require("./strategy.js"),
|
|
40
|
+
...require("./strategy-data.js"),
|
|
38
41
|
...require("./strategy-data-source.js"),
|
|
42
|
+
...require("./strategy-earnings.js"),
|
|
39
43
|
...require("./targetable.js")
|
|
40
44
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var validation_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(validation_exports);
|
|
18
|
+
__reExport(validation_exports, require("./is-zero-balance.js"), module.exports);
|
|
19
|
+
__reExport(validation_exports, require("./validate-balance.js"), module.exports);
|
|
20
|
+
__reExport(validation_exports, require("./validate-balances.js"), module.exports);
|
|
21
|
+
__reExport(validation_exports, require("./validate-credit-manager.js"), module.exports);
|
|
22
|
+
__reExport(validation_exports, require("./validate-hf.js"), module.exports);
|
|
23
|
+
__reExport(validation_exports, require("./validate-open-account.js"), module.exports);
|
|
24
|
+
__reExport(validation_exports, require("./validate-quota.js"), module.exports);
|
|
25
|
+
__reExport(validation_exports, require("./validate-token-to-obtain.js"), module.exports);
|
|
26
|
+
__reExport(validation_exports, require("./validation-types.js"), module.exports);
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
...require("./is-zero-balance.js"),
|
|
30
|
+
...require("./validate-balance.js"),
|
|
31
|
+
...require("./validate-balances.js"),
|
|
32
|
+
...require("./validate-credit-manager.js"),
|
|
33
|
+
...require("./validate-hf.js"),
|
|
34
|
+
...require("./validate-open-account.js"),
|
|
35
|
+
...require("./validate-quota.js"),
|
|
36
|
+
...require("./validate-token-to-obtain.js"),
|
|
37
|
+
...require("./validation-types.js")
|
|
38
|
+
});
|
|
@@ -137,6 +137,7 @@ class OnchainSdkStrategyDataSource {
|
|
|
137
137
|
liquidationThresholds,
|
|
138
138
|
quotas,
|
|
139
139
|
collateralTokens: cm.collateralTokens.map(lc),
|
|
140
|
+
maxEnabledTokensLength: cm.maxEnabledTokens,
|
|
140
141
|
version: Number(facade.version),
|
|
141
142
|
isBorrowingForbidden: facade.maxDebtPerBlockMultiplier === 0,
|
|
142
143
|
marketConfigurator: lc(cs.marketConfigurator),
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from "./bonus-apy-from-points.js";
|
|
2
|
+
export * from "./calculate-borrow-rate-from-utilization.js";
|
|
3
|
+
export * from "./calculate-earnings.js";
|
|
2
4
|
export * from "./calculate-effective-borrow-rate.js";
|
|
5
|
+
export * from "./calculate-safe-borrow-rate.js";
|
|
3
6
|
export * from "./get-complex-apy-list.js";
|
|
4
7
|
export * from "./get-rate-with-fee.js";
|
|
8
|
+
export * from "./get-safe-base-borrow-rate.js";
|
|
5
9
|
export * from "./get-single-quota-borrow-rate.js";
|
|
6
10
|
export * from "./max-apy-formula.js";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./apy/index.js";
|
|
2
2
|
export * from "./assets-math.js";
|
|
3
3
|
export * from "./bigint-math.js";
|
|
4
|
+
export * from "./constants.js";
|
|
4
5
|
export * from "./creditAccount/index.js";
|
|
5
6
|
export * from "./price-math.js";
|
|
6
7
|
export * from "./strategies/index.js";
|
|
8
|
+
export * from "./validation/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./assets.js";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export * from "./get-cm-allowed-collaterals.js";
|
|
1
2
|
export * from "./get-strategy-credit-managers.js";
|
|
2
3
|
export * from "./get-strategy-credit-managers-list.js";
|
|
3
4
|
export * from "./get-strategy-credit-managers-list-core.js";
|
|
5
|
+
export * from "./get-wallet-balances-allowed-on-cm.js";
|
|
4
6
|
export * from "./is-credit-manager-usable.js";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from "./calculate-loss-coefficient.js";
|
|
2
2
|
export * from "./calculate-max-leverage-factor.js";
|
|
3
|
+
export * from "./calculate-max-strategy-debt.js";
|
|
4
|
+
export * from "./get-collateral-by-debt.js";
|
|
3
5
|
export * from "./get-factor-from-leverage.js";
|
|
4
6
|
export * from "./get-leverage-from-factor.js";
|
|
7
|
+
export * from "./get-recommended-debt.js";
|
|
8
|
+
export * from "./get-recommended-leverage-factor.js";
|
|
5
9
|
export * from "./max-leverage.js";
|
|
6
10
|
export * from "./max-leverage-threshold.js";
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
checkDegenNFT,
|
|
4
|
-
validateOpenAccountPoolStatus
|
|
5
|
-
} from "../availability/index.js";
|
|
1
|
+
import { validateOpenAccountPoolStatus } from "../../validation/validate-open-account-pool-status.js";
|
|
2
|
+
import { checkBoolean, checkDegenNFT } from "../availability/index.js";
|
|
6
3
|
function cmAvailabilityCondition(targetToken, cmA, cmB, pools) {
|
|
7
4
|
const aHasMinError = validateOpenAccountPoolStatus({
|
|
8
5
|
pool: pools?.[cmA.pool],
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export * from "./calculate-total-apy.js";
|
|
2
|
+
export * from "./calculate-total-points.js";
|
|
1
3
|
export * from "./cm-availability-condition.js";
|
|
4
|
+
export * from "./get-cm-you-can-earn.js";
|
|
2
5
|
export * from "./get-strategy-info.js";
|
|
3
6
|
export * from "./get-strategy-info-core.js";
|
|
4
7
|
export * from "./get-strategy-max-apy.js";
|
|
8
|
+
export * from "./get-strategy-you-can-earn.js";
|
|
5
9
|
export * from "./is-strategy-cm-disabled.js";
|
|
6
10
|
export * from "./types.js";
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export * from "./add-amount-in-target.js";
|
|
2
|
+
export * from "./get-chain-phantom-tokens.js";
|
|
3
|
+
export * from "./get-list-with-amount-in-target.js";
|
|
4
|
+
export * from "./get-native-token-address.js";
|
|
1
5
|
export * from "./is-activated-token.js";
|
|
6
|
+
export * from "./is-apy-with-points-exception.js";
|
|
7
|
+
export * from "./is-collateral-token.js";
|
|
2
8
|
export * from "./is-forbidden-token.js";
|
|
9
|
+
export * from "./is-obtainable-token.js";
|
|
3
10
|
export * from "./is-usable-token.js";
|
|
11
|
+
export * from "./is-valid-extra-collateral-token.js";
|
|
12
|
+
export * from "./wrap-token-address.js";
|
|
@@ -6,5 +6,7 @@ export * from "./points-slices.js";
|
|
|
6
6
|
export * from "./sdk-state.js";
|
|
7
7
|
export * from "./strategies-cm-list.js";
|
|
8
8
|
export * from "./strategy.js";
|
|
9
|
+
export * from "./strategy-data.js";
|
|
9
10
|
export * from "./strategy-data-source.js";
|
|
11
|
+
export * from "./strategy-earnings.js";
|
|
10
12
|
export * from "./targetable.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./is-zero-balance.js";
|
|
2
|
+
export * from "./validate-balance.js";
|
|
3
|
+
export * from "./validate-balances.js";
|
|
4
|
+
export * from "./validate-credit-manager.js";
|
|
5
|
+
export * from "./validate-hf.js";
|
|
6
|
+
export * from "./validate-open-account.js";
|
|
7
|
+
export * from "./validate-quota.js";
|
|
8
|
+
export * from "./validate-token-to-obtain.js";
|
|
9
|
+
export * from "./validation-types.js";
|
|
@@ -121,6 +121,7 @@ class OnchainSdkStrategyDataSource {
|
|
|
121
121
|
liquidationThresholds,
|
|
122
122
|
quotas,
|
|
123
123
|
collateralTokens: cm.collateralTokens.map(lc),
|
|
124
|
+
maxEnabledTokensLength: cm.maxEnabledTokens,
|
|
124
125
|
version: Number(facade.version),
|
|
125
126
|
isBorrowingForbidden: facade.maxDebtPerBlockMultiplier === 0,
|
|
126
127
|
marketConfigurator: lc(cs.marketConfigurator),
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from "./bonus-apy-from-points.js";
|
|
2
|
+
export * from "./calculate-borrow-rate-from-utilization.js";
|
|
3
|
+
export * from "./calculate-earnings.js";
|
|
2
4
|
export * from "./calculate-effective-borrow-rate.js";
|
|
5
|
+
export * from "./calculate-safe-borrow-rate.js";
|
|
3
6
|
export * from "./get-complex-apy-list.js";
|
|
4
7
|
export * from "./get-rate-with-fee.js";
|
|
8
|
+
export * from "./get-safe-base-borrow-rate.js";
|
|
5
9
|
export * from "./get-single-quota-borrow-rate.js";
|
|
6
10
|
export * from "./max-apy-formula.js";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./apy/index.js";
|
|
2
2
|
export * from "./assets-math.js";
|
|
3
3
|
export * from "./bigint-math.js";
|
|
4
|
+
export * from "./constants.js";
|
|
4
5
|
export * from "./creditAccount/index.js";
|
|
5
6
|
export * from "./price-math.js";
|
|
6
7
|
export * from "./strategies/index.js";
|
|
8
|
+
export * from "./validation/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./assets.js";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export * from "./get-cm-allowed-collaterals.js";
|
|
1
2
|
export * from "./get-strategy-credit-managers.js";
|
|
2
3
|
export * from "./get-strategy-credit-managers-list.js";
|
|
3
4
|
export * from "./get-strategy-credit-managers-list-core.js";
|
|
5
|
+
export * from "./get-wallet-balances-allowed-on-cm.js";
|
|
4
6
|
export * from "./is-credit-manager-usable.js";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from "./calculate-loss-coefficient.js";
|
|
2
2
|
export * from "./calculate-max-leverage-factor.js";
|
|
3
|
+
export * from "./calculate-max-strategy-debt.js";
|
|
4
|
+
export * from "./get-collateral-by-debt.js";
|
|
3
5
|
export * from "./get-factor-from-leverage.js";
|
|
4
6
|
export * from "./get-leverage-from-factor.js";
|
|
7
|
+
export * from "./get-recommended-debt.js";
|
|
8
|
+
export * from "./get-recommended-leverage-factor.js";
|
|
5
9
|
export * from "./max-leverage.js";
|
|
6
10
|
export * from "./max-leverage-threshold.js";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export * from "./calculate-total-apy.js";
|
|
2
|
+
export * from "./calculate-total-points.js";
|
|
1
3
|
export * from "./cm-availability-condition.js";
|
|
4
|
+
export * from "./get-cm-you-can-earn.js";
|
|
2
5
|
export * from "./get-strategy-info.js";
|
|
3
6
|
export * from "./get-strategy-info-core.js";
|
|
4
7
|
export * from "./get-strategy-max-apy.js";
|
|
8
|
+
export * from "./get-strategy-you-can-earn.js";
|
|
5
9
|
export * from "./is-strategy-cm-disabled.js";
|
|
6
10
|
export * from "./types.js";
|
|
@@ -26,6 +26,7 @@ export interface CreditManagerSlice {
|
|
|
26
26
|
liquidationThresholds: Record<Address, bigint>;
|
|
27
27
|
quotas: Record<Address, QuotaSlice | undefined>;
|
|
28
28
|
collateralTokens: readonly Address[];
|
|
29
|
+
maxEnabledTokensLength: number;
|
|
29
30
|
}
|
|
30
31
|
export interface PoolSlice {
|
|
31
32
|
address: Address;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export * from "./add-amount-in-target.js";
|
|
2
|
+
export * from "./get-chain-phantom-tokens.js";
|
|
3
|
+
export * from "./get-list-with-amount-in-target.js";
|
|
4
|
+
export * from "./get-native-token-address.js";
|
|
1
5
|
export * from "./is-activated-token.js";
|
|
6
|
+
export * from "./is-apy-with-points-exception.js";
|
|
7
|
+
export * from "./is-collateral-token.js";
|
|
2
8
|
export * from "./is-forbidden-token.js";
|
|
9
|
+
export * from "./is-obtainable-token.js";
|
|
3
10
|
export * from "./is-usable-token.js";
|
|
11
|
+
export * from "./is-valid-extra-collateral-token.js";
|
|
12
|
+
export * from "./wrap-token-address.js";
|
|
@@ -8,5 +8,7 @@ export * from "./points-slices.js";
|
|
|
8
8
|
export * from "./sdk-state.js";
|
|
9
9
|
export * from "./strategies-cm-list.js";
|
|
10
10
|
export * from "./strategy.js";
|
|
11
|
+
export * from "./strategy-data.js";
|
|
11
12
|
export * from "./strategy-data-source.js";
|
|
13
|
+
export * from "./strategy-earnings.js";
|
|
12
14
|
export * from "./targetable.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./is-zero-balance.js";
|
|
2
|
+
export * from "./validate-balance.js";
|
|
3
|
+
export * from "./validate-balances.js";
|
|
4
|
+
export * from "./validate-credit-manager.js";
|
|
5
|
+
export * from "./validate-hf.js";
|
|
6
|
+
export * from "./validate-open-account.js";
|
|
7
|
+
export * from "./validate-quota.js";
|
|
8
|
+
export * from "./validate-token-to-obtain.js";
|
|
9
|
+
export * from "./validation-types.js";
|
package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreditManagerSlice } from "../strategies/strategy-info/types.js";
|
|
3
3
|
export interface ValidateOpenAccountPoolQuotaStatusResult {
|
|
4
4
|
message: "insufficientQuota";
|
|
5
5
|
token: Address;
|
|
6
6
|
}
|
|
7
|
-
export declare function validateOpenAccountPoolQuotaStatus(targetToken: Address, creditManager: Pick<
|
|
7
|
+
export declare function validateOpenAccountPoolQuotaStatus(targetToken: Address, creditManager: Pick<CreditManagerSlice, "quotas">, amountToBorrow: bigint): ValidateOpenAccountPoolQuotaStatusResult | null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreditManagerSlice, PoolSlice } from "../strategies/strategy-info/types.js";
|
|
3
3
|
import { type ValidateOpenAccountPoolQuotaStatusResult } from "./validate-open-account-pool-quota-status.js";
|
|
4
4
|
export interface ValidateOpenAccountPoolStatusProps {
|
|
5
|
-
creditManager: Pick<
|
|
6
|
-
pool: Pick<
|
|
5
|
+
creditManager: Pick<CreditManagerSlice, "minDebt" | "totalDebtLimit" | "totalDebt" | "availableToBorrow" | "quotas">;
|
|
6
|
+
pool: Pick<PoolSlice, "totalDebtLimit" | "totalBorrowed"> | undefined | null;
|
|
7
7
|
debt: bigint;
|
|
8
8
|
targetToken: Address | null;
|
|
9
9
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { Asset } from "../../../sdk/router/types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CreditManagerSlice } from "../strategies/strategy-info/types.js";
|
|
4
4
|
import type { ValidateQuotaResult } from "./validate-quota.js";
|
|
5
5
|
export interface ValidateOpenAccountProps {
|
|
6
6
|
debt: bigint;
|
|
7
|
-
creditManager: Pick<
|
|
7
|
+
creditManager: Pick<CreditManagerSlice, "minDebt" | "maxDebt" | "underlyingToken" | "quotas" | "maxEnabledTokensLength">;
|
|
8
8
|
desiredQuota: Record<Address, Asset>;
|
|
9
9
|
quotaUpdate: Array<Asset>;
|
|
10
10
|
loading?: boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import type { Asset } from "../../../sdk/router/types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CreditManagerSlice } from "../strategies/strategy-info/types.js";
|
|
4
4
|
export interface ValidateQuotaProps {
|
|
5
5
|
desiredQuota: Record<Address, Asset>;
|
|
6
6
|
quotaUpdate: Array<Asset>;
|
|
7
|
-
creditManager: Pick<
|
|
7
|
+
creditManager: Pick<CreditManagerSlice, "quotas" | "maxEnabledTokensLength">;
|
|
8
8
|
throwOnZeroQuotaUpdate?: boolean;
|
|
9
9
|
}
|
|
10
10
|
export type ValidateQuotaResult = {
|
package/package.json
CHANGED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var validate_open_account_pool_quota_status_exports = {};
|
|
20
|
-
__export(validate_open_account_pool_quota_status_exports, {
|
|
21
|
-
validateOpenAccountPoolQuotaStatus: () => validateOpenAccountPoolQuotaStatus
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(validate_open_account_pool_quota_status_exports);
|
|
24
|
-
function validateOpenAccountPoolQuotaStatus(targetToken, creditManager, amountToBorrow) {
|
|
25
|
-
const quota = creditManager.quotas[targetToken];
|
|
26
|
-
if (quota) {
|
|
27
|
-
const realLimit = quota.isActive ? quota.limit : 0n;
|
|
28
|
-
const quotaLeft = realLimit - quota.totalQuoted;
|
|
29
|
-
if (quotaLeft < amountToBorrow)
|
|
30
|
-
return {
|
|
31
|
-
message: "insufficientQuota",
|
|
32
|
-
token: targetToken
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
validateOpenAccountPoolQuotaStatus
|
|
40
|
-
});
|
package/dist/cjs/common-utils/utils/strategies/availability/validate-open-account-pool-status.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var validate_open_account_pool_status_exports = {};
|
|
20
|
-
__export(validate_open_account_pool_status_exports, {
|
|
21
|
-
validateOpenAccountPoolStatus: () => validateOpenAccountPoolStatus
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(validate_open_account_pool_status_exports);
|
|
24
|
-
var import_bigint_math = require("../../bigint-math.js");
|
|
25
|
-
var import_validate_open_account_pool_quota_status = require("./validate-open-account-pool-quota-status.js");
|
|
26
|
-
function validateOpenAccountPoolStatus(props) {
|
|
27
|
-
const { debt, creditManager, pool, targetToken } = props;
|
|
28
|
-
const effectiveDebt = import_bigint_math.BigIntMath.max(creditManager.minDebt, debt);
|
|
29
|
-
const hasDebtLimit = creditManager.totalDebtLimit >= 0n;
|
|
30
|
-
const debtLimitLeft = import_bigint_math.BigIntMath.max(
|
|
31
|
-
creditManager.totalDebtLimit - creditManager.totalDebt,
|
|
32
|
-
0n
|
|
33
|
-
);
|
|
34
|
-
const { totalDebtLimit = 0n, totalBorrowed = 0n } = pool || {};
|
|
35
|
-
const hasPoolDebtLimit = totalDebtLimit > 0n;
|
|
36
|
-
const poolDebtLimitLeft = totalDebtLimit - totalBorrowed;
|
|
37
|
-
const canOpenMinDebt = creditManager.minDebt <= debtLimitLeft && creditManager.minDebt <= poolDebtLimitLeft && creditManager.minDebt <= creditManager.availableToBorrow;
|
|
38
|
-
const minPositionSize = import_bigint_math.BigIntMath.min(
|
|
39
|
-
import_bigint_math.BigIntMath.min(debtLimitLeft, poolDebtLimitLeft),
|
|
40
|
-
creditManager.availableToBorrow
|
|
41
|
-
);
|
|
42
|
-
if (hasDebtLimit && effectiveDebt > debtLimitLeft) {
|
|
43
|
-
return {
|
|
44
|
-
message: "insufficientDebtLimit",
|
|
45
|
-
amount: debtLimitLeft,
|
|
46
|
-
solutionAmount: canOpenMinDebt ? minPositionSize : void 0
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (hasPoolDebtLimit && effectiveDebt > poolDebtLimitLeft) {
|
|
50
|
-
return {
|
|
51
|
-
message: "insufficientPoolDebtLimit",
|
|
52
|
-
amount: poolDebtLimitLeft,
|
|
53
|
-
solutionAmount: canOpenMinDebt ? minPositionSize : void 0
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (effectiveDebt > creditManager.availableToBorrow) {
|
|
57
|
-
return {
|
|
58
|
-
message: "insufficientPoolLiquidity",
|
|
59
|
-
amount: creditManager.availableToBorrow,
|
|
60
|
-
solutionAmount: canOpenMinDebt ? minPositionSize : void 0
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (targetToken !== null) {
|
|
64
|
-
const quotaError = (0, import_validate_open_account_pool_quota_status.validateOpenAccountPoolQuotaStatus)(
|
|
65
|
-
targetToken,
|
|
66
|
-
creditManager,
|
|
67
|
-
effectiveDebt
|
|
68
|
-
);
|
|
69
|
-
if (quotaError) return quotaError;
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 && (module.exports = {
|
|
75
|
-
validateOpenAccountPoolStatus
|
|
76
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
function validateOpenAccountPoolQuotaStatus(targetToken, creditManager, amountToBorrow) {
|
|
2
|
-
const quota = creditManager.quotas[targetToken];
|
|
3
|
-
if (quota) {
|
|
4
|
-
const realLimit = quota.isActive ? quota.limit : 0n;
|
|
5
|
-
const quotaLeft = realLimit - quota.totalQuoted;
|
|
6
|
-
if (quotaLeft < amountToBorrow)
|
|
7
|
-
return {
|
|
8
|
-
message: "insufficientQuota",
|
|
9
|
-
token: targetToken
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
validateOpenAccountPoolQuotaStatus
|
|
16
|
-
};
|
package/dist/esm/common-utils/utils/strategies/availability/validate-open-account-pool-status.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { BigIntMath } from "../../bigint-math.js";
|
|
2
|
-
import { validateOpenAccountPoolQuotaStatus } from "./validate-open-account-pool-quota-status.js";
|
|
3
|
-
function validateOpenAccountPoolStatus(props) {
|
|
4
|
-
const { debt, creditManager, pool, targetToken } = props;
|
|
5
|
-
const effectiveDebt = BigIntMath.max(creditManager.minDebt, debt);
|
|
6
|
-
const hasDebtLimit = creditManager.totalDebtLimit >= 0n;
|
|
7
|
-
const debtLimitLeft = BigIntMath.max(
|
|
8
|
-
creditManager.totalDebtLimit - creditManager.totalDebt,
|
|
9
|
-
0n
|
|
10
|
-
);
|
|
11
|
-
const { totalDebtLimit = 0n, totalBorrowed = 0n } = pool || {};
|
|
12
|
-
const hasPoolDebtLimit = totalDebtLimit > 0n;
|
|
13
|
-
const poolDebtLimitLeft = totalDebtLimit - totalBorrowed;
|
|
14
|
-
const canOpenMinDebt = creditManager.minDebt <= debtLimitLeft && creditManager.minDebt <= poolDebtLimitLeft && creditManager.minDebt <= creditManager.availableToBorrow;
|
|
15
|
-
const minPositionSize = BigIntMath.min(
|
|
16
|
-
BigIntMath.min(debtLimitLeft, poolDebtLimitLeft),
|
|
17
|
-
creditManager.availableToBorrow
|
|
18
|
-
);
|
|
19
|
-
if (hasDebtLimit && effectiveDebt > debtLimitLeft) {
|
|
20
|
-
return {
|
|
21
|
-
message: "insufficientDebtLimit",
|
|
22
|
-
amount: debtLimitLeft,
|
|
23
|
-
solutionAmount: canOpenMinDebt ? minPositionSize : void 0
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (hasPoolDebtLimit && effectiveDebt > poolDebtLimitLeft) {
|
|
27
|
-
return {
|
|
28
|
-
message: "insufficientPoolDebtLimit",
|
|
29
|
-
amount: poolDebtLimitLeft,
|
|
30
|
-
solutionAmount: canOpenMinDebt ? minPositionSize : void 0
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
if (effectiveDebt > creditManager.availableToBorrow) {
|
|
34
|
-
return {
|
|
35
|
-
message: "insufficientPoolLiquidity",
|
|
36
|
-
amount: creditManager.availableToBorrow,
|
|
37
|
-
solutionAmount: canOpenMinDebt ? minPositionSize : void 0
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
if (targetToken !== null) {
|
|
41
|
-
const quotaError = validateOpenAccountPoolQuotaStatus(
|
|
42
|
-
targetToken,
|
|
43
|
-
creditManager,
|
|
44
|
-
effectiveDebt
|
|
45
|
-
);
|
|
46
|
-
if (quotaError) return quotaError;
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
export {
|
|
51
|
-
validateOpenAccountPoolStatus
|
|
52
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { CreditManagerSlice } from "../strategy-info/types.js";
|
|
3
|
-
export declare function validateOpenAccountPoolQuotaStatus(targetToken: Address, creditManager: Pick<CreditManagerSlice, "quotas">, amountToBorrow: bigint): {
|
|
4
|
-
readonly message: "insufficientQuota";
|
|
5
|
-
readonly token: `0x${string}`;
|
|
6
|
-
} | null;
|
package/dist/types/common-utils/utils/strategies/availability/validate-open-account-pool-status.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { CreditManagerSlice, PoolSlice } from "../strategy-info/types.js";
|
|
3
|
-
export interface ValidateOpenAccountPoolStatusProps {
|
|
4
|
-
creditManager: Pick<CreditManagerSlice, "minDebt" | "totalDebtLimit" | "totalDebt" | "availableToBorrow" | "quotas">;
|
|
5
|
-
pool: PoolSlice | undefined | null;
|
|
6
|
-
debt: bigint;
|
|
7
|
-
targetToken: Address | null;
|
|
8
|
-
}
|
|
9
|
-
export declare function validateOpenAccountPoolStatus(props: ValidateOpenAccountPoolStatusProps): {
|
|
10
|
-
readonly message: "insufficientQuota";
|
|
11
|
-
readonly token: `0x${string}`;
|
|
12
|
-
} | {
|
|
13
|
-
readonly message: "insufficientDebtLimit";
|
|
14
|
-
readonly amount: bigint;
|
|
15
|
-
readonly solutionAmount: bigint | undefined;
|
|
16
|
-
} | {
|
|
17
|
-
readonly message: "insufficientPoolDebtLimit";
|
|
18
|
-
readonly amount: bigint;
|
|
19
|
-
readonly solutionAmount: bigint | undefined;
|
|
20
|
-
} | {
|
|
21
|
-
readonly message: "insufficientPoolLiquidity";
|
|
22
|
-
readonly amount: bigint;
|
|
23
|
-
readonly solutionAmount: bigint | undefined;
|
|
24
|
-
} | null;
|