@gearbox-protocol/sdk 14.10.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/test-utils/index.js +139 -0
- package/dist/cjs/common-utils/utils/apy/calculate-borrow-rate-from-utilization.js +59 -0
- package/dist/cjs/common-utils/utils/apy/calculate-borrow-rate-from-utilization.spec.js +32 -0
- package/dist/cjs/common-utils/utils/apy/calculate-earnings.js +59 -0
- package/dist/cjs/common-utils/utils/apy/calculate-earnings.spec.js +62 -0
- package/dist/cjs/common-utils/utils/apy/calculate-safe-borrow-rate.js +55 -0
- package/dist/cjs/common-utils/utils/apy/calculate-safe-borrow-rate.spec.js +39 -0
- package/dist/cjs/common-utils/utils/apy/get-safe-base-borrow-rate.js +38 -0
- package/dist/cjs/common-utils/utils/apy/index.js +8 -0
- package/dist/cjs/common-utils/utils/constants.js +34 -0
- package/dist/cjs/common-utils/utils/index.js +5 -1
- package/dist/cjs/common-utils/utils/strategies/assets/assets.js +30 -0
- 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/get-cm-allowed-collaterals.js +62 -0
- package/dist/cjs/common-utils/utils/strategies/credit-managers/get-cm-allowed-collaterals.spec.js +109 -0
- package/dist/cjs/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.js +75 -0
- package/dist/cjs/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.spec.js +93 -0
- 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/calculate-max-strategy-debt.js +63 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.spec.js +330 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/get-collateral-by-debt.js +34 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/get-collateral-by-debt.spec.js +30 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/get-recommended-debt.js +85 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/get-recommended-debt.spec.js +227 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/get-recommended-leverage-factor.js +33 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/get-recommended-leverage-factor.spec.js +23 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/index.js +8 -0
- package/dist/cjs/common-utils/utils/strategies/leverage/max-leverage.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/strategy-info/calculate-total-apy.js +112 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/calculate-total-apy.spec.js +183 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/calculate-total-points.js +74 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/calculate-total-points.spec.js +131 -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/get-cm-you-can-earn.js +410 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.js +274 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-strategy-you-can-earn.js +108 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/index.js +8 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/add-amount-in-target.js +41 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/add-amount-in-target.spec.js +38 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/get-chain-phantom-tokens.js +35 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.js +42 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.spec.js +32 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/get-native-token-address.js +31 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/index.js +19 -1
- package/dist/cjs/common-utils/utils/strategies/tokens/is-apy-with-points-exception.js +36 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/is-collateral-token.js +59 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/is-collateral-token.spec.js +135 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/is-obtainable-token.js +42 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/is-obtainable-token.spec.js +162 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/is-valid-extra-collateral-token.js +51 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/wrap-token-address.js +33 -0
- package/dist/cjs/common-utils/utils/strategies/tokens/wrap-token-address.spec.js +13 -0
- package/dist/cjs/common-utils/utils/strategies/types/index.js +4 -0
- package/dist/cjs/common-utils/utils/strategies/types/strategy-data.js +16 -0
- package/dist/cjs/common-utils/utils/strategies/types/strategy-earnings.js +16 -0
- package/dist/cjs/common-utils/utils/validation/index.js +38 -0
- package/dist/cjs/common-utils/utils/validation/is-zero-balance.js +30 -0
- package/dist/cjs/common-utils/utils/validation/validate-balance.js +47 -0
- package/dist/cjs/common-utils/utils/validation/validate-balance.spec.js +52 -0
- package/dist/cjs/common-utils/utils/validation/validate-balances.js +44 -0
- package/dist/cjs/common-utils/utils/validation/validate-balances.spec.js +37 -0
- package/dist/cjs/common-utils/utils/validation/validate-credit-manager.js +34 -0
- package/dist/cjs/common-utils/utils/validation/validate-credit-manager.spec.js +36 -0
- package/dist/cjs/common-utils/utils/validation/validate-hf.js +38 -0
- package/dist/cjs/common-utils/utils/validation/validate-hf.spec.js +24 -0
- package/dist/cjs/common-utils/utils/{strategies/availability → validation}/validate-open-account-pool-quota-status.js +1 -4
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +43 -0
- package/dist/cjs/common-utils/utils/{strategies/availability → validation}/validate-open-account-pool-status.js +1 -1
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.spec.js +98 -0
- package/dist/cjs/common-utils/utils/validation/validate-open-account.js +41 -0
- package/dist/cjs/common-utils/utils/validation/validate-open-account.spec.js +54 -0
- package/dist/cjs/common-utils/utils/validation/validate-quota.js +49 -0
- package/dist/cjs/common-utils/utils/validation/validate-quota.spec.js +79 -0
- package/dist/cjs/common-utils/utils/validation/validate-token-to-obtain.js +42 -0
- package/dist/cjs/common-utils/utils/validation/validate-token-to-obtain.spec.js +35 -0
- package/dist/cjs/common-utils/utils/validation/validation-types.js +16 -0
- package/dist/cjs/plugins/apy/strategy-data-source.js +1 -0
- package/dist/cjs/sdk/constants/math.js +3 -0
- package/dist/esm/common-utils/test-utils/index.js +104 -0
- package/dist/esm/common-utils/utils/apy/calculate-borrow-rate-from-utilization.js +35 -0
- package/dist/esm/common-utils/utils/apy/calculate-borrow-rate-from-utilization.spec.js +31 -0
- package/dist/esm/common-utils/utils/apy/calculate-earnings.js +35 -0
- package/dist/esm/common-utils/utils/apy/calculate-earnings.spec.js +65 -0
- package/dist/esm/common-utils/utils/apy/calculate-safe-borrow-rate.js +34 -0
- package/dist/esm/common-utils/utils/apy/calculate-safe-borrow-rate.spec.js +38 -0
- package/dist/esm/common-utils/utils/apy/get-safe-base-borrow-rate.js +16 -0
- package/dist/esm/common-utils/utils/apy/index.js +4 -0
- package/dist/esm/common-utils/utils/constants.js +8 -0
- package/dist/esm/common-utils/utils/index.js +2 -0
- package/dist/esm/common-utils/utils/strategies/assets/assets.js +6 -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/get-cm-allowed-collaterals.js +38 -0
- package/dist/esm/common-utils/utils/strategies/credit-managers/get-cm-allowed-collaterals.spec.js +115 -0
- package/dist/esm/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.js +51 -0
- package/dist/esm/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.spec.js +96 -0
- 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/calculate-max-strategy-debt.js +42 -0
- package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.spec.js +332 -0
- package/dist/esm/common-utils/utils/strategies/leverage/get-collateral-by-debt.js +10 -0
- package/dist/esm/common-utils/utils/strategies/leverage/get-collateral-by-debt.spec.js +29 -0
- package/dist/esm/common-utils/utils/strategies/leverage/get-recommended-debt.js +61 -0
- package/dist/esm/common-utils/utils/strategies/leverage/get-recommended-debt.spec.js +226 -0
- package/dist/esm/common-utils/utils/strategies/leverage/get-recommended-leverage-factor.js +9 -0
- package/dist/esm/common-utils/utils/strategies/leverage/get-recommended-leverage-factor.spec.js +22 -0
- package/dist/esm/common-utils/utils/strategies/leverage/index.js +4 -0
- package/dist/esm/common-utils/utils/strategies/leverage/max-leverage.js +2 -2
- package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-apy.js +88 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-apy.spec.js +187 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-points.js +54 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-points.spec.js +139 -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/get-cm-you-can-earn.js +389 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.js +278 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-strategy-you-can-earn.js +84 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/index.js +4 -0
- package/dist/esm/common-utils/utils/strategies/tokens/add-amount-in-target.js +17 -0
- package/dist/esm/common-utils/utils/strategies/tokens/add-amount-in-target.spec.js +41 -0
- package/dist/esm/common-utils/utils/strategies/tokens/get-chain-phantom-tokens.js +11 -0
- package/dist/esm/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.js +18 -0
- package/dist/esm/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.spec.js +36 -0
- package/dist/esm/common-utils/utils/strategies/tokens/get-native-token-address.js +7 -0
- package/dist/esm/common-utils/utils/strategies/tokens/index.js +9 -0
- package/dist/esm/common-utils/utils/strategies/tokens/is-apy-with-points-exception.js +11 -0
- package/dist/esm/common-utils/utils/strategies/tokens/is-collateral-token.js +35 -0
- package/dist/esm/common-utils/utils/strategies/tokens/is-collateral-token.spec.js +137 -0
- package/dist/esm/common-utils/utils/strategies/tokens/is-obtainable-token.js +18 -0
- package/dist/esm/common-utils/utils/strategies/tokens/is-obtainable-token.spec.js +161 -0
- package/dist/esm/common-utils/utils/strategies/tokens/is-valid-extra-collateral-token.js +27 -0
- package/dist/esm/common-utils/utils/strategies/tokens/wrap-token-address.js +9 -0
- package/dist/esm/common-utils/utils/strategies/tokens/wrap-token-address.spec.js +12 -0
- package/dist/esm/common-utils/utils/strategies/types/index.js +2 -0
- package/dist/esm/common-utils/utils/strategies/types/strategy-data.js +0 -0
- package/dist/esm/common-utils/utils/strategies/types/strategy-earnings.js +0 -0
- package/dist/esm/common-utils/utils/validation/index.js +9 -0
- package/dist/esm/common-utils/utils/validation/is-zero-balance.js +6 -0
- package/dist/esm/common-utils/utils/validation/validate-balance.js +23 -0
- package/dist/esm/common-utils/utils/validation/validate-balance.spec.js +51 -0
- package/dist/esm/common-utils/utils/validation/validate-balances.js +20 -0
- package/dist/esm/common-utils/utils/validation/validate-balances.spec.js +36 -0
- package/dist/esm/common-utils/utils/validation/validate-credit-manager.js +10 -0
- package/dist/esm/common-utils/utils/validation/validate-credit-manager.spec.js +35 -0
- package/dist/esm/common-utils/utils/validation/validate-hf.js +13 -0
- package/dist/esm/common-utils/utils/validation/validate-hf.spec.js +23 -0
- package/dist/esm/common-utils/utils/{strategies/availability → validation}/validate-open-account-pool-quota-status.js +1 -4
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +46 -0
- package/dist/esm/common-utils/utils/{strategies/availability → validation}/validate-open-account-pool-status.js +4 -2
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.spec.js +102 -0
- package/dist/esm/common-utils/utils/validation/validate-open-account.js +17 -0
- package/dist/esm/common-utils/utils/validation/validate-open-account.spec.js +56 -0
- package/dist/esm/common-utils/utils/validation/validate-quota.js +25 -0
- package/dist/esm/common-utils/utils/validation/validate-quota.spec.js +83 -0
- package/dist/esm/common-utils/utils/validation/validate-token-to-obtain.js +18 -0
- package/dist/esm/common-utils/utils/validation/validate-token-to-obtain.spec.js +34 -0
- package/dist/esm/common-utils/utils/validation/validation-types.js +0 -0
- package/dist/esm/plugins/apy/strategy-data-source.js +1 -0
- package/dist/esm/sdk/constants/math.js +2 -0
- package/dist/types/common-utils/test-utils/index.d.ts +16 -0
- package/dist/types/common-utils/utils/apy/calculate-borrow-rate-from-utilization.d.ts +2 -0
- package/dist/types/common-utils/utils/apy/calculate-borrow-rate-from-utilization.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/apy/calculate-earnings.d.ts +16 -0
- package/dist/types/common-utils/utils/apy/calculate-earnings.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/apy/calculate-safe-borrow-rate.d.ts +11 -0
- package/dist/types/common-utils/utils/apy/calculate-safe-borrow-rate.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/apy/get-safe-base-borrow-rate.d.ts +4 -0
- package/dist/types/common-utils/utils/apy/index.d.ts +4 -0
- package/dist/types/common-utils/utils/constants.d.ts +4 -0
- package/dist/types/common-utils/utils/index.d.ts +2 -0
- package/dist/types/common-utils/utils/strategies/assets/assets.d.ts +3 -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/get-cm-allowed-collaterals.d.ts +20 -0
- package/dist/types/common-utils/utils/strategies/credit-managers/get-cm-allowed-collaterals.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.d.ts +13 -0
- package/dist/types/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.spec.d.ts +1 -0
- 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/calculate-max-strategy-debt.d.ts +11 -0
- package/dist/types/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/leverage/get-collateral-by-debt.d.ts +2 -0
- package/dist/types/common-utils/utils/strategies/leverage/get-collateral-by-debt.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/leverage/get-recommended-debt.d.ts +21 -0
- package/dist/types/common-utils/utils/strategies/leverage/get-recommended-debt.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/leverage/get-recommended-leverage-factor.d.ts +4 -0
- package/dist/types/common-utils/utils/strategies/leverage/get-recommended-leverage-factor.spec.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/calculate-total-apy.d.ts +28 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-apy.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-points.d.ts +22 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-points.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.d.ts +19 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/get-strategy-you-can-earn.d.ts +29 -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/add-amount-in-target.d.ts +6 -0
- package/dist/types/common-utils/utils/strategies/tokens/add-amount-in-target.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/tokens/get-chain-phantom-tokens.d.ts +6 -0
- package/dist/types/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.d.ts +12 -0
- package/dist/types/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/tokens/get-native-token-address.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/tokens/index.d.ts +9 -0
- package/dist/types/common-utils/utils/strategies/tokens/is-apy-with-points-exception.d.ts +3 -0
- package/dist/types/common-utils/utils/strategies/tokens/is-collateral-token.d.ts +16 -0
- package/dist/types/common-utils/utils/strategies/tokens/is-collateral-token.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/tokens/is-obtainable-token.d.ts +14 -0
- package/dist/types/common-utils/utils/strategies/tokens/is-obtainable-token.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/tokens/is-valid-extra-collateral-token.d.ts +20 -0
- package/dist/types/common-utils/utils/strategies/tokens/wrap-token-address.d.ts +2 -0
- package/dist/types/common-utils/utils/strategies/tokens/wrap-token-address.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/types/index.d.ts +4 -1
- package/dist/types/common-utils/utils/strategies/types/strategy-data.d.ts +64 -0
- package/dist/types/common-utils/utils/strategies/types/strategy-earnings.d.ts +43 -0
- package/dist/types/common-utils/utils/validation/index.d.ts +9 -0
- package/dist/types/common-utils/utils/validation/is-zero-balance.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validate-balance.d.ts +22 -0
- package/dist/types/common-utils/utils/validation/validate-balance.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validate-balances.d.ts +9 -0
- package/dist/types/common-utils/utils/validation/validate-balances.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validate-credit-manager.d.ts +10 -0
- package/dist/types/common-utils/utils/validation/validate-credit-manager.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validate-hf.d.ts +9 -0
- package/dist/types/common-utils/utils/validation/validate-hf.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.d.ts +7 -0
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-status.d.ts +23 -0
- package/dist/types/common-utils/utils/validation/validate-open-account-pool-status.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validate-open-account.d.ts +21 -0
- package/dist/types/common-utils/utils/validation/validate-open-account.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validate-quota.d.ts +20 -0
- package/dist/types/common-utils/utils/validation/validate-quota.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validate-token-to-obtain.d.ts +13 -0
- package/dist/types/common-utils/utils/validation/validate-token-to-obtain.spec.d.ts +1 -0
- package/dist/types/common-utils/utils/validation/validation-types.d.ts +14 -0
- package/dist/types/dev/RevolverTransport.d.ts +4 -4
- package/dist/types/sdk/constants/math.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/common-utils/utils/strategies/__test-utils.js +0 -95
- package/dist/esm/common-utils/utils/strategies/__test-utils.js +0 -65
- package/dist/types/common-utils/utils/strategies/__test-utils.d.ts +0 -11
- 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
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { BigIntMath } from "
|
|
2
|
-
import {
|
|
1
|
+
import { BigIntMath } from "../bigint-math.js";
|
|
2
|
+
import {
|
|
3
|
+
validateOpenAccountPoolQuotaStatus
|
|
4
|
+
} from "./validate-open-account-pool-quota-status.js";
|
|
3
5
|
function validateOpenAccountPoolStatus(props) {
|
|
4
6
|
const { debt, creditManager, pool, targetToken } = props;
|
|
5
7
|
const effectiveDebt = BigIntMath.max(creditManager.minDebt, debt);
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
buildCreditManager,
|
|
4
|
+
buildPool,
|
|
5
|
+
buildQuota,
|
|
6
|
+
mockToken1
|
|
7
|
+
} from "../../test-utils/index.js";
|
|
8
|
+
import { validateOpenAccountPoolStatus } from "./validate-open-account-pool-status.js";
|
|
9
|
+
const mockCreditManager = buildCreditManager({
|
|
10
|
+
minDebt: 1000n,
|
|
11
|
+
maxDebt: 1000000n,
|
|
12
|
+
totalDebtLimit: 5000000n,
|
|
13
|
+
totalDebt: 2000000n,
|
|
14
|
+
availableToBorrow: 3000000n,
|
|
15
|
+
quotas: {
|
|
16
|
+
[mockToken1]: buildQuota({
|
|
17
|
+
token: mockToken1,
|
|
18
|
+
limit: 1000000n,
|
|
19
|
+
totalQuoted: 500000n,
|
|
20
|
+
rate: 0n
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const mockPool = buildPool({
|
|
25
|
+
totalDebtLimit: 10000000n,
|
|
26
|
+
totalBorrowed: 5000000n
|
|
27
|
+
});
|
|
28
|
+
describe("validateOpenAccountPoolStatus", () => {
|
|
29
|
+
it("returns null when all conditions are met", () => {
|
|
30
|
+
const result = validateOpenAccountPoolStatus({
|
|
31
|
+
debt: 50000n,
|
|
32
|
+
creditManager: mockCreditManager,
|
|
33
|
+
pool: mockPool,
|
|
34
|
+
targetToken: mockToken1
|
|
35
|
+
});
|
|
36
|
+
expect(result).toBeNull();
|
|
37
|
+
});
|
|
38
|
+
it("returns error when debt exceeds debt limit", () => {
|
|
39
|
+
const result = validateOpenAccountPoolStatus({
|
|
40
|
+
debt: 4000000n,
|
|
41
|
+
creditManager: mockCreditManager,
|
|
42
|
+
pool: mockPool,
|
|
43
|
+
targetToken: mockToken1
|
|
44
|
+
});
|
|
45
|
+
expect(result).toEqual({
|
|
46
|
+
message: "insufficientDebtLimit",
|
|
47
|
+
amount: 3000000n,
|
|
48
|
+
solutionAmount: 3000000n
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
it("returns error when debt exceeds pool debt limit", () => {
|
|
52
|
+
const result = validateOpenAccountPoolStatus({
|
|
53
|
+
debt: 6000000n,
|
|
54
|
+
creditManager: buildCreditManager({
|
|
55
|
+
...mockCreditManager,
|
|
56
|
+
totalDebtLimit: -1n
|
|
57
|
+
}),
|
|
58
|
+
pool: mockPool,
|
|
59
|
+
targetToken: mockToken1
|
|
60
|
+
});
|
|
61
|
+
expect(result).toEqual({
|
|
62
|
+
message: "insufficientPoolDebtLimit",
|
|
63
|
+
amount: 5000000n
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
it("returns error when debt exceeds available liquidity", () => {
|
|
67
|
+
const result = validateOpenAccountPoolStatus({
|
|
68
|
+
debt: 4000000n,
|
|
69
|
+
creditManager: buildCreditManager({
|
|
70
|
+
...mockCreditManager,
|
|
71
|
+
totalDebtLimit: -1n
|
|
72
|
+
}),
|
|
73
|
+
pool: buildPool({ totalDebtLimit: -1n }),
|
|
74
|
+
targetToken: mockToken1
|
|
75
|
+
});
|
|
76
|
+
expect(result).toEqual({
|
|
77
|
+
message: "insufficientPoolLiquidity",
|
|
78
|
+
amount: 3000000n
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
it("returns error when quota is insufficient", () => {
|
|
82
|
+
const result = validateOpenAccountPoolStatus({
|
|
83
|
+
debt: 600000n,
|
|
84
|
+
creditManager: mockCreditManager,
|
|
85
|
+
pool: mockPool,
|
|
86
|
+
targetToken: mockToken1
|
|
87
|
+
});
|
|
88
|
+
expect(result).toEqual({
|
|
89
|
+
message: "insufficientQuota",
|
|
90
|
+
token: mockToken1
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
it("returns null when targetToken is null", () => {
|
|
94
|
+
const result = validateOpenAccountPoolStatus({
|
|
95
|
+
debt: 50000n,
|
|
96
|
+
creditManager: mockCreditManager,
|
|
97
|
+
pool: mockPool,
|
|
98
|
+
targetToken: null
|
|
99
|
+
});
|
|
100
|
+
expect(result).toBeNull();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { validateQuota } from "./validate-quota.js";
|
|
2
|
+
function validateOpenAccount(props) {
|
|
3
|
+
const { debt, creditManager, loading } = props;
|
|
4
|
+
if (loading) {
|
|
5
|
+
return { message: "loading" };
|
|
6
|
+
}
|
|
7
|
+
if (debt < creditManager.minDebt) {
|
|
8
|
+
return { message: "amountLessMin", amount: creditManager.minDebt };
|
|
9
|
+
}
|
|
10
|
+
if (debt > creditManager.maxDebt) {
|
|
11
|
+
return { message: "debtGreaterMax", amount: creditManager.maxDebt };
|
|
12
|
+
}
|
|
13
|
+
return validateQuota(props);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
validateOpenAccount
|
|
17
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
buildCreditManager,
|
|
4
|
+
mockUnderlyingToken
|
|
5
|
+
} from "../../test-utils/index.js";
|
|
6
|
+
import { validateOpenAccount } from "./validate-open-account.js";
|
|
7
|
+
const mockCreditManager = buildCreditManager({
|
|
8
|
+
minDebt: 1000n,
|
|
9
|
+
maxDebt: 1000000n,
|
|
10
|
+
underlyingToken: mockUnderlyingToken
|
|
11
|
+
});
|
|
12
|
+
describe("validateOpenAccount", () => {
|
|
13
|
+
it("returns null when all conditions are met", () => {
|
|
14
|
+
const result = validateOpenAccount({
|
|
15
|
+
debt: 50000n,
|
|
16
|
+
creditManager: mockCreditManager,
|
|
17
|
+
desiredQuota: {},
|
|
18
|
+
quotaUpdate: []
|
|
19
|
+
});
|
|
20
|
+
expect(result).toBeNull();
|
|
21
|
+
});
|
|
22
|
+
it("returns loading error when loading is true", () => {
|
|
23
|
+
const result = validateOpenAccount({
|
|
24
|
+
debt: 50000n,
|
|
25
|
+
creditManager: mockCreditManager,
|
|
26
|
+
desiredQuota: {},
|
|
27
|
+
quotaUpdate: [],
|
|
28
|
+
loading: true
|
|
29
|
+
});
|
|
30
|
+
expect(result).toEqual({ message: "loading" });
|
|
31
|
+
});
|
|
32
|
+
it("returns error when debt is less than min", () => {
|
|
33
|
+
const result = validateOpenAccount({
|
|
34
|
+
debt: 500n,
|
|
35
|
+
creditManager: mockCreditManager,
|
|
36
|
+
desiredQuota: {},
|
|
37
|
+
quotaUpdate: []
|
|
38
|
+
});
|
|
39
|
+
expect(result).toEqual({
|
|
40
|
+
message: "amountLessMin",
|
|
41
|
+
amount: 1000n
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
it("returns error when debt is greater than max", () => {
|
|
45
|
+
const result = validateOpenAccount({
|
|
46
|
+
debt: 2000000n,
|
|
47
|
+
creditManager: mockCreditManager,
|
|
48
|
+
desiredQuota: {},
|
|
49
|
+
quotaUpdate: []
|
|
50
|
+
});
|
|
51
|
+
expect(result).toEqual({
|
|
52
|
+
message: "debtGreaterMax",
|
|
53
|
+
amount: 1000000n
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function validateQuota(props) {
|
|
2
|
+
const desiredQuotasList = Object.values(props.desiredQuota).filter(
|
|
3
|
+
(a) => a.balance > 0n
|
|
4
|
+
);
|
|
5
|
+
if (desiredQuotasList.length > props.creditManager.maxEnabledTokensLength)
|
|
6
|
+
return {
|
|
7
|
+
message: "maxQuotasLengthReached",
|
|
8
|
+
count: desiredQuotasList.length,
|
|
9
|
+
max: props.creditManager.maxEnabledTokensLength
|
|
10
|
+
};
|
|
11
|
+
if (props.quotaUpdate.length === 0 && props.throwOnZeroQuotaUpdate)
|
|
12
|
+
return { message: "quotaShouldBeUpdated" };
|
|
13
|
+
for (const { token, balance: updateBy } of props.quotaUpdate) {
|
|
14
|
+
const quota = props.creditManager.quotas[token];
|
|
15
|
+
if (updateBy > 0 && quota) {
|
|
16
|
+
const realLimit = quota.isActive ? quota.limit : 0n;
|
|
17
|
+
const quotaLeft = realLimit - quota.totalQuoted;
|
|
18
|
+
if (quotaLeft < updateBy) return { message: "insufficientQuota", token };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
validateQuota
|
|
25
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
buildCreditManager,
|
|
4
|
+
buildQuota,
|
|
5
|
+
mockToken1,
|
|
6
|
+
mockToken2
|
|
7
|
+
} from "../../test-utils/index.js";
|
|
8
|
+
import { validateQuota } from "./validate-quota.js";
|
|
9
|
+
const mockCreditManager = buildCreditManager({
|
|
10
|
+
minDebt: 1000n,
|
|
11
|
+
maxDebt: 1000000n,
|
|
12
|
+
totalDebtLimit: 5000000n,
|
|
13
|
+
totalDebt: 2000000n,
|
|
14
|
+
availableToBorrow: 3000000n,
|
|
15
|
+
quotas: {
|
|
16
|
+
[mockToken1]: buildQuota({
|
|
17
|
+
token: mockToken1,
|
|
18
|
+
limit: 1000000n,
|
|
19
|
+
totalQuoted: 500000n,
|
|
20
|
+
rate: 0n
|
|
21
|
+
}),
|
|
22
|
+
[mockToken2]: buildQuota({
|
|
23
|
+
token: mockToken2,
|
|
24
|
+
limit: 2000000n,
|
|
25
|
+
totalQuoted: 1000000n,
|
|
26
|
+
rate: 0n
|
|
27
|
+
})
|
|
28
|
+
},
|
|
29
|
+
maxEnabledTokensLength: 2
|
|
30
|
+
});
|
|
31
|
+
describe("validateQuota", () => {
|
|
32
|
+
it("returns null when all conditions are met", () => {
|
|
33
|
+
const result = validateQuota({
|
|
34
|
+
desiredQuota: {},
|
|
35
|
+
quotaUpdate: [],
|
|
36
|
+
creditManager: mockCreditManager,
|
|
37
|
+
throwOnZeroQuotaUpdate: false
|
|
38
|
+
});
|
|
39
|
+
expect(result).toBeNull();
|
|
40
|
+
});
|
|
41
|
+
it("returns error when max quotas length is reached", () => {
|
|
42
|
+
const result = validateQuota({
|
|
43
|
+
desiredQuota: {
|
|
44
|
+
[mockToken1]: { token: mockToken1, balance: 1000n },
|
|
45
|
+
[mockToken2]: { token: mockToken2, balance: 1000n }
|
|
46
|
+
},
|
|
47
|
+
quotaUpdate: [],
|
|
48
|
+
creditManager: buildCreditManager({
|
|
49
|
+
...mockCreditManager,
|
|
50
|
+
maxEnabledTokensLength: 1
|
|
51
|
+
}),
|
|
52
|
+
throwOnZeroQuotaUpdate: false
|
|
53
|
+
});
|
|
54
|
+
expect(result).toEqual({
|
|
55
|
+
message: "maxQuotasLengthReached",
|
|
56
|
+
count: 2,
|
|
57
|
+
max: 1
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
it("returns error when quota update is empty and throwOnZeroQuotaUpdate is true", () => {
|
|
61
|
+
const result = validateQuota({
|
|
62
|
+
desiredQuota: {},
|
|
63
|
+
quotaUpdate: [],
|
|
64
|
+
creditManager: mockCreditManager,
|
|
65
|
+
throwOnZeroQuotaUpdate: true
|
|
66
|
+
});
|
|
67
|
+
expect(result).toEqual({
|
|
68
|
+
message: "quotaShouldBeUpdated"
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
it("returns error when quota is insufficient", () => {
|
|
72
|
+
const result = validateQuota({
|
|
73
|
+
desiredQuota: {},
|
|
74
|
+
quotaUpdate: [{ token: mockToken1, balance: 600000n }],
|
|
75
|
+
creditManager: mockCreditManager,
|
|
76
|
+
throwOnZeroQuotaUpdate: false
|
|
77
|
+
});
|
|
78
|
+
expect(result).toEqual({
|
|
79
|
+
message: "insufficientQuota",
|
|
80
|
+
token: mockToken1
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function validateTokenToObtain({
|
|
2
|
+
creditManager,
|
|
3
|
+
targetToken
|
|
4
|
+
}) {
|
|
5
|
+
if (Array.isArray(targetToken)) {
|
|
6
|
+
for (const asset of targetToken) {
|
|
7
|
+
if (creditManager.forbiddenTokens[asset.token])
|
|
8
|
+
return { message: "tokenIsForbidden", token: asset.token };
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (targetToken !== null && creditManager.forbiddenTokens[targetToken])
|
|
13
|
+
return { message: "tokenIsForbidden", token: targetToken };
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
validateTokenToObtain
|
|
18
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { buildCreditManager, mockToken1 } from "../../test-utils/index.js";
|
|
3
|
+
import { validateTokenToObtain } from "./validate-token-to-obtain.js";
|
|
4
|
+
const mockCreditManager = buildCreditManager({
|
|
5
|
+
forbiddenTokens: {}
|
|
6
|
+
});
|
|
7
|
+
describe("validateTokenToObtain", () => {
|
|
8
|
+
it("returns null when targetToken is null", () => {
|
|
9
|
+
const result = validateTokenToObtain({
|
|
10
|
+
targetToken: null,
|
|
11
|
+
creditManager: mockCreditManager
|
|
12
|
+
});
|
|
13
|
+
expect(result).toBeNull();
|
|
14
|
+
});
|
|
15
|
+
it("returns null when targetToken is not forbidden", () => {
|
|
16
|
+
const result = validateTokenToObtain({
|
|
17
|
+
targetToken: mockToken1,
|
|
18
|
+
creditManager: mockCreditManager
|
|
19
|
+
});
|
|
20
|
+
expect(result).toBeNull();
|
|
21
|
+
});
|
|
22
|
+
it("returns error when targetToken is forbidden", () => {
|
|
23
|
+
const result = validateTokenToObtain({
|
|
24
|
+
targetToken: mockToken1,
|
|
25
|
+
creditManager: buildCreditManager({
|
|
26
|
+
...mockCreditManager,
|
|
27
|
+
forbiddenTokens: {
|
|
28
|
+
[mockToken1]: true
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
expect(result).toEqual({ message: "tokenIsForbidden", token: mockToken1 });
|
|
33
|
+
});
|
|
34
|
+
});
|
|
File without changes
|
|
@@ -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),
|
|
@@ -14,6 +14,7 @@ const PRICE_DECIMALS = 10n ** BigInt(PRICE_DECIMALS_POW);
|
|
|
14
14
|
const SECONDS_PER_YEAR = 365 * 24 * 3600;
|
|
15
15
|
const PERCENTAGE_DECIMALS = 100n;
|
|
16
16
|
const PERCENTAGE_FACTOR = 10000n;
|
|
17
|
+
const PERCENTAGE_FACTOR_1KK = PERCENTAGE_FACTOR * PERCENTAGE_DECIMALS;
|
|
17
18
|
const LEVERAGE_DECIMALS = 100n;
|
|
18
19
|
const SLIPPAGE_DECIMALS = 100n;
|
|
19
20
|
export {
|
|
@@ -24,6 +25,7 @@ export {
|
|
|
24
25
|
MIN_INT96,
|
|
25
26
|
PERCENTAGE_DECIMALS,
|
|
26
27
|
PERCENTAGE_FACTOR,
|
|
28
|
+
PERCENTAGE_FACTOR_1KK,
|
|
27
29
|
PRICE_DECIMALS,
|
|
28
30
|
PRICE_DECIMALS_POW,
|
|
29
31
|
RAY,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { TokenData } from "../charts/token-data.js";
|
|
3
|
+
export declare const mockToken1: Address;
|
|
4
|
+
export declare const mockToken2: Address;
|
|
5
|
+
export declare const mockUnderlyingToken: Address;
|
|
6
|
+
export declare const mockNativeTokenAddress: Address;
|
|
7
|
+
export declare const mockWrappedNativeTokenAddress: Address;
|
|
8
|
+
export declare const mockCMAddress: Address;
|
|
9
|
+
export declare function buildQuota(overrides: Record<string, unknown> & {
|
|
10
|
+
token: Address;
|
|
11
|
+
}): any;
|
|
12
|
+
export declare function buildPool(overrides?: Record<string, unknown>): any;
|
|
13
|
+
export declare function buildCreditManager(overrides?: Record<string, unknown>): any;
|
|
14
|
+
export declare function buildTokenData(address: Address, symbol: string, decimals?: number, isPhantom?: boolean): TokenData;
|
|
15
|
+
export declare const mockTokenData: Record<Address, TokenData>;
|
|
16
|
+
export declare const mockPrices: Record<Address, bigint>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { TokenData } from "../../charts/token-data.js";
|
|
3
|
+
export interface CalculateEarningsProps {
|
|
4
|
+
overallAPYBigInt: bigint | undefined | null;
|
|
5
|
+
targetAmount: bigint | undefined;
|
|
6
|
+
targetToken: Address;
|
|
7
|
+
tokensList: Record<Address, TokenData>;
|
|
8
|
+
prices: Record<Address, bigint>;
|
|
9
|
+
}
|
|
10
|
+
export declare function calculateEarnings({ overallAPYBigInt, targetAmount, targetToken, tokensList, prices, }: CalculateEarningsProps): {
|
|
11
|
+
earnings: null;
|
|
12
|
+
earningsUSD: null;
|
|
13
|
+
} | {
|
|
14
|
+
earnings: bigint;
|
|
15
|
+
earningsUSD: bigint;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CreditManagerData, PoolData } from "../strategies/types/strategy-data.js";
|
|
2
|
+
export interface CalculateBorrowRateSafelyProps {
|
|
3
|
+
pool: PoolData;
|
|
4
|
+
creditManager: CreditManagerData;
|
|
5
|
+
expectedLiquidityChange?: bigint;
|
|
6
|
+
availableLiquidityChange?: bigint;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Returns borrow rate multiplied by feeInterest
|
|
10
|
+
*/
|
|
11
|
+
export declare function calculateSafeBorrowRate({ pool, creditManager, expectedLiquidityChange, availableLiquidityChange, }: CalculateBorrowRateSafelyProps): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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";
|
package/dist/types/common-utils/utils/strategies/credit-managers/get-cm-allowed-collaterals.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { TokenData } from "../../../charts/token-data.js";
|
|
3
|
+
import type { StrategyConfigPayload } from "../../../static/strategy.js";
|
|
4
|
+
import type { CreditManagerData } from "../types/strategy-data.js";
|
|
5
|
+
type ExtraCollateralConfig = NonNullable<StrategyConfigPayload["additionalCollaterals"]>[number];
|
|
6
|
+
type ExtraCollaterals = Record<Address, Array<ExtraCollateralConfig>>;
|
|
7
|
+
export interface GetCMAllowedCollateralsProps {
|
|
8
|
+
creditManager: CreditManagerData | undefined;
|
|
9
|
+
tokensList: Record<Address, TokenData>;
|
|
10
|
+
zeroDebt?: boolean;
|
|
11
|
+
delayedPhantoms: Record<Address, boolean>;
|
|
12
|
+
extraCollaterals: {
|
|
13
|
+
list: ExtraCollaterals | undefined;
|
|
14
|
+
prices: Record<Address, bigint> | undefined;
|
|
15
|
+
} | undefined;
|
|
16
|
+
nativeTokenAddress: Address;
|
|
17
|
+
wrappedNativeTokenAddress: Address | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare function getCMAllowedCollaterals({ creditManager, tokensList, zeroDebt, delayedPhantoms, extraCollaterals, nativeTokenAddress, wrappedNativeTokenAddress, }: GetCMAllowedCollateralsProps): Record<Address, Address>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { Asset } from "../../../../sdk/router/types.js";
|
|
3
|
+
import type { TokenData } from "../../../charts/token-data.js";
|
|
4
|
+
export interface GetWalletBalancesAllowedOnCMProps {
|
|
5
|
+
walletBalances: Record<Address, bigint> | undefined;
|
|
6
|
+
collateralRecord: Record<Address, Address>;
|
|
7
|
+
tokensList: Record<Address, TokenData>;
|
|
8
|
+
prices: Record<Address, bigint>;
|
|
9
|
+
nativeTokenAddress: Address;
|
|
10
|
+
wrappedNativeTokenAddress: Address | undefined;
|
|
11
|
+
isPaused?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function getWalletBalancesAllowedOnCM({ walletBalances, collateralRecord, nativeTokenAddress, wrappedNativeTokenAddress, prices, tokensList, isPaused, }: GetWalletBalancesAllowedOnCMProps): Asset[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { CreditManagerData } from "../types/strategy-data.js";
|
|
3
|
+
export interface CalculateMaxDebtProps {
|
|
4
|
+
targetToken: Address;
|
|
5
|
+
amount: bigint;
|
|
6
|
+
creditManager: CreditManagerData;
|
|
7
|
+
slippage: number;
|
|
8
|
+
constantLoss?: bigint;
|
|
9
|
+
swapCollateral?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function calculateMaxStrategyDebt({ targetToken, amount, creditManager, slippage, constantLoss, swapCollateral, }: CalculateMaxDebtProps): bigint;
|
package/dist/types/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.spec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { CreditManagerData } from "../types/strategy-data.js";
|
|
3
|
+
import type { LeverageFactor } from "./get-factor-from-leverage.js";
|
|
4
|
+
export interface GetRecommendedDebtProps {
|
|
5
|
+
targetToken: Address;
|
|
6
|
+
amount: bigint;
|
|
7
|
+
creditManager: CreditManagerData;
|
|
8
|
+
slippage: number;
|
|
9
|
+
maxLeverageConstantLoss?: bigint;
|
|
10
|
+
maxDebtConstantLoss?: bigint;
|
|
11
|
+
recommendedDebtConstantLoss?: bigint;
|
|
12
|
+
swapCollateral?: boolean;
|
|
13
|
+
leverageLimit: number | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare function getRecommendedDebt({ targetToken, amount, creditManager, slippage, maxLeverageConstantLoss, maxDebtConstantLoss, recommendedDebtConstantLoss, swapCollateral, leverageLimit, }: GetRecommendedDebtProps): {
|
|
16
|
+
maxDebt: bigint;
|
|
17
|
+
recommended: {
|
|
18
|
+
factor: LeverageFactor;
|
|
19
|
+
debt: bigint;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/common-utils/utils/strategies/leverage/get-recommended-leverage-factor.spec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { Asset } from "../../../../sdk/router/types.js";
|
|
3
|
+
import type { TokenData } from "../../../charts/token-data.js";
|
|
4
|
+
import type { QuotaInfo } from "../types/strategy-data.js";
|
|
5
|
+
export interface TotalAPY {
|
|
6
|
+
overallAPY: number | undefined | null;
|
|
7
|
+
overallAPYBigInt: bigint | undefined | null;
|
|
8
|
+
overallAPYStatus: "loading" | "notEnoughFarmAssets" | "noAPY" | "calculated" | "pointsNoAPY" | "negativeForPoints";
|
|
9
|
+
}
|
|
10
|
+
export interface CalculateTotalAPYProps {
|
|
11
|
+
caAssets: Asset[];
|
|
12
|
+
lpAPY: Record<Address, number> | undefined;
|
|
13
|
+
pointsInfo: Pick<{
|
|
14
|
+
address: Address;
|
|
15
|
+
}, "address"> | undefined;
|
|
16
|
+
isValueTo?: boolean;
|
|
17
|
+
debt: bigint | undefined;
|
|
18
|
+
totalValue: bigint | undefined;
|
|
19
|
+
effectiveBorrowRate: number;
|
|
20
|
+
showAPY: boolean;
|
|
21
|
+
prices: Record<Address, bigint>;
|
|
22
|
+
quotaRates: Record<Address, Pick<QuotaInfo, "isActive" | "rate">>;
|
|
23
|
+
quotas: Record<Address, Asset>;
|
|
24
|
+
feeInterest: number;
|
|
25
|
+
underlyingToken: Address;
|
|
26
|
+
tokensList: Record<Address, TokenData>;
|
|
27
|
+
}
|
|
28
|
+
export declare function calculateTotalAPY({ caAssets, lpAPY, pointsInfo, isValueTo, debt, totalValue, effectiveBorrowRate, showAPY, prices, quotaRates, quotas, feeInterest, underlyingToken, tokensList, }: CalculateTotalAPYProps): Omit<TotalAPY, "extraAPY">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|