@gearbox-protocol/sdk 14.10.0 → 14.10.2-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/constants.js +34 -0
- package/dist/cjs/common-utils/utils/strategies/assets/assets.js +30 -0
- 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/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/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/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/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/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/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/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/validation/validate-open-account-pool-quota-status.js +37 -0
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +43 -0
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.js +76 -0
- 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/dev/claimFromFaucet.js +17 -7
- 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/constants.js +8 -0
- package/dist/esm/common-utils/utils/strategies/assets/assets.js +6 -0
- 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/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/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/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/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/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/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/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/validation/validate-open-account-pool-quota-status.js +13 -0
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +46 -0
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +54 -0
- 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/dev/claimFromFaucet.js +17 -7
- 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/constants.d.ts +4 -0
- package/dist/types/common-utils/utils/strategies/assets/assets.d.ts +3 -0
- 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/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/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/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/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 +2 -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/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/dev/claimFromFaucet.d.ts +1 -0
- 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
|
@@ -19,7 +19,8 @@ async function claimFromFaucet(opts) {
|
|
|
19
19
|
role,
|
|
20
20
|
amount,
|
|
21
21
|
logger,
|
|
22
|
-
gasMultiplier = 10n
|
|
22
|
+
gasMultiplier = 10n,
|
|
23
|
+
sync = false
|
|
23
24
|
} = opts;
|
|
24
25
|
let amnt = "default amount";
|
|
25
26
|
let args;
|
|
@@ -60,7 +61,8 @@ async function claimFromFaucet(opts) {
|
|
|
60
61
|
functionName: "claim",
|
|
61
62
|
args
|
|
62
63
|
});
|
|
63
|
-
|
|
64
|
+
logger?.debug({ gas }, "estimated claim tx gas");
|
|
65
|
+
const { request } = await publicClient.simulateContract({
|
|
64
66
|
account: claimer,
|
|
65
67
|
address: faucet,
|
|
66
68
|
abi: faucetAbi,
|
|
@@ -69,15 +71,23 @@ async function claimFromFaucet(opts) {
|
|
|
69
71
|
chain: wallet.chain,
|
|
70
72
|
gas: gas * gasMultiplier
|
|
71
73
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
logger?.debug({ request }, "simulated claim tx request");
|
|
75
|
+
let receipt;
|
|
76
|
+
if (sync) {
|
|
77
|
+
receipt = await wallet.writeContractSync(request);
|
|
78
|
+
} else {
|
|
79
|
+
const hash = await wallet.writeContract(request);
|
|
80
|
+
logger?.debug({ hash }, "claim tx hash");
|
|
81
|
+
receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
82
|
+
}
|
|
75
83
|
if (receipt.status === "reverted") {
|
|
76
84
|
throw new Error(
|
|
77
|
-
`${usr} failed to claimed ${amnt} from faucet, tx: ${
|
|
85
|
+
`${usr} failed to claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`
|
|
78
86
|
);
|
|
79
87
|
}
|
|
80
|
-
logger?.debug(
|
|
88
|
+
logger?.debug(
|
|
89
|
+
`${usr} claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`
|
|
90
|
+
);
|
|
81
91
|
}
|
|
82
92
|
export {
|
|
83
93
|
claimFromFaucet
|
|
@@ -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 {};
|
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 {};
|
|
@@ -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 {};
|
|
@@ -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 {};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { LocalDebtReward, LocalPointsInfo, LocalPointsReward } from "../types/points-slices.js";
|
|
5
|
+
export interface PointsData {
|
|
6
|
+
rates: Array<LocalPointsReward["multiplier"]>;
|
|
7
|
+
debtRates: {
|
|
8
|
+
rewards: Array<LocalDebtReward>;
|
|
9
|
+
rates: Array<LocalDebtReward["multiplier"]>;
|
|
10
|
+
};
|
|
11
|
+
info: LocalPointsInfo;
|
|
12
|
+
}
|
|
13
|
+
export declare function calculateTotalPoints({ pointsAsset, cmAddress, info, totalValue, assetValue, prices, tokensList, underlyingToken, }: {
|
|
14
|
+
pointsAsset: Asset | undefined;
|
|
15
|
+
cmAddress: Address;
|
|
16
|
+
info: LocalPointsInfo | undefined;
|
|
17
|
+
totalValue: bigint | undefined;
|
|
18
|
+
assetValue: bigint | undefined;
|
|
19
|
+
prices: Record<Address, bigint>;
|
|
20
|
+
tokensList: Record<Address, TokenData>;
|
|
21
|
+
underlyingToken: Address;
|
|
22
|
+
}): PointsData | null;
|
package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-points.spec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { TokenData } from "../../../charts/token-data.js";
|
|
3
|
+
import type { Strategy } from "../types/strategy.js";
|
|
4
|
+
import type { APYList, CreditManagerData, PoolData, PricesRecord } from "../types/strategy-data.js";
|
|
5
|
+
import type { StrategyCMEarningsInfo } from "../types/strategy-earnings.js";
|
|
6
|
+
export declare function getCMYouCanEarn<CM extends CreditManagerData>({ allPrices, creditManager, tokensList, delayedPhantoms, nativeTokenAddress, wrappedNativeTokenAddress, walletBalances, strategy, slippage, quotaReserve, apyList, pools, }: {
|
|
7
|
+
allPrices: PricesRecord | undefined;
|
|
8
|
+
creditManager: CM;
|
|
9
|
+
tokensList: Record<Address, TokenData>;
|
|
10
|
+
delayedPhantoms: Record<Address, boolean>;
|
|
11
|
+
nativeTokenAddress: Address;
|
|
12
|
+
wrappedNativeTokenAddress: Address | undefined;
|
|
13
|
+
walletBalances: Record<`0x${string}`, bigint> | undefined;
|
|
14
|
+
strategy: Strategy;
|
|
15
|
+
slippage: number;
|
|
16
|
+
quotaReserve: number;
|
|
17
|
+
apyList: APYList | undefined;
|
|
18
|
+
pools: Record<`0x${string}`, PoolData>;
|
|
19
|
+
}): StrategyCMEarningsInfo<CM>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { TokenData } from "../../../charts/token-data.js";
|
|
3
|
+
import type { Strategy } from "../types/strategy.js";
|
|
4
|
+
import type { APYList, CreditManagerData, PoolData, PricesRecord } from "../types/strategy-data.js";
|
|
5
|
+
import type { StrategyCMEarningsInfo } from "../types/strategy-earnings.js";
|
|
6
|
+
type EarningsList<CM extends CreditManagerData> = Array<StrategyCMEarningsInfo<CM>>;
|
|
7
|
+
interface GearboxSDKFullState {
|
|
8
|
+
pools: Record<Address, PoolData> | undefined;
|
|
9
|
+
tokens: {
|
|
10
|
+
tokenDataList: Record<Address, TokenData>;
|
|
11
|
+
} | undefined;
|
|
12
|
+
addressProvider: {
|
|
13
|
+
wrappedNativeToken: Address | undefined;
|
|
14
|
+
};
|
|
15
|
+
withdrawableAssets: Record<Address, Array<{
|
|
16
|
+
withdrawalPhantomToken: Address;
|
|
17
|
+
}>> | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare function getStrategyYouCanEarn<CM extends CreditManagerData>({ strategy, creditManagers, sdkState, apyList, quotaReserve, slippage, allPrices, walletBalances, }: {
|
|
20
|
+
strategy: Strategy;
|
|
21
|
+
creditManagers: Record<Address, CM> | undefined;
|
|
22
|
+
sdkState: GearboxSDKFullState | undefined;
|
|
23
|
+
apyList: APYList | undefined;
|
|
24
|
+
allPrices: PricesRecord | undefined;
|
|
25
|
+
walletBalances: Record<`0x${string}`, bigint> | undefined;
|
|
26
|
+
quotaReserve: number;
|
|
27
|
+
slippage: number;
|
|
28
|
+
}): EarningsList<CM>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
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 declare function addAmountInTarget<T extends Asset>(asset: T, tokensList: Record<Address, TokenData>, prices: Record<Address, bigint>, toPrice: bigint, toDecimals: number): T & {
|
|
5
|
+
amountInTarget: bigint;
|
|
6
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
interface WithdrawableAssetClient {
|
|
3
|
+
withdrawalPhantomToken: Address;
|
|
4
|
+
}
|
|
5
|
+
export declare function getChainPhantomTokens(config: Record<Address, WithdrawableAssetClient[]> | undefined): Record<`0x${string}`, boolean>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
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 AddAmountInTargetProps<T> {
|
|
5
|
+
assets: Array<T>;
|
|
6
|
+
targetToken: Address;
|
|
7
|
+
prices: Record<Address, bigint>;
|
|
8
|
+
tokensList: Record<Address, TokenData>;
|
|
9
|
+
}
|
|
10
|
+
export declare function getListWithAmountInTarget<T extends Asset>({ assets, targetToken, prices, tokensList, }: AddAmountInTargetProps<T>): Array<T & {
|
|
11
|
+
amountInTarget: bigint;
|
|
12
|
+
}>;
|
package/dist/types/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.spec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getNativeTokenAddress(): `0x${string}`;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export interface IsCollateralTokenProps {
|
|
7
|
+
address: Address;
|
|
8
|
+
tokensList: Record<Address, TokenData>;
|
|
9
|
+
creditManager: CreditManagerData;
|
|
10
|
+
delayedPhantoms: Record<Address, boolean>;
|
|
11
|
+
extraCollateralConfigs: ExtraCollateralConfig[] | undefined;
|
|
12
|
+
prices: Record<Address, bigint> | undefined;
|
|
13
|
+
zeroDebt?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function isCollateralToken({ address, tokensList, creditManager, zeroDebt, delayedPhantoms, extraCollateralConfigs, prices, }: IsCollateralTokenProps): boolean;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { QuotaInfo } from "../types/strategy-data.js";
|
|
3
|
+
export interface IsObtainableTokenProps {
|
|
4
|
+
address: Address;
|
|
5
|
+
creditManager: {
|
|
6
|
+
quotas: Record<Address, QuotaInfo | undefined>;
|
|
7
|
+
isQuoted(token: Address): boolean;
|
|
8
|
+
forbiddenTokens: Record<Address, true>;
|
|
9
|
+
liquidationThresholds: Record<Address, bigint>;
|
|
10
|
+
supportedTokens: Record<Address, true>;
|
|
11
|
+
};
|
|
12
|
+
delayedPhantoms: Record<Address, boolean>;
|
|
13
|
+
}
|
|
14
|
+
export declare function isObtainableToken({ address, creditManager, delayedPhantoms, }: IsObtainableTokenProps): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
export interface IsValidExtraCollateralTokenProps {
|
|
3
|
+
address: Address;
|
|
4
|
+
extraCollateralConfigs: Array<Address | {
|
|
5
|
+
token: Address;
|
|
6
|
+
cm: Address;
|
|
7
|
+
}> | undefined;
|
|
8
|
+
prices: Record<Address, bigint> | undefined;
|
|
9
|
+
creditManager: {
|
|
10
|
+
address: Address;
|
|
11
|
+
underlyingToken: Address;
|
|
12
|
+
forbiddenTokens: Record<Address, true>;
|
|
13
|
+
} | undefined;
|
|
14
|
+
tokensList: Record<Address, {
|
|
15
|
+
isPhantom: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
delayedPhantoms: Record<Address, boolean>;
|
|
18
|
+
zeroDebt?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function isValidExtraCollateralToken({ address, extraCollateralConfigs, prices, creditManager, tokensList, delayedPhantoms, zeroDebt, }: IsValidExtraCollateralTokenProps): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { QuotaSlice } from "../strategy-info/types.js";
|
|
2
|
+
export type QuotaInfo = QuotaSlice;
|
|
2
3
|
export * from "./chains.js";
|
|
3
4
|
export * from "./credit-manager-data-legacy.js";
|
|
4
5
|
export * from "./curator-filter.js";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { QuotaSlice } from "../strategy-info/types.js";
|
|
3
|
+
import type { LocalPointsInfo } from "./points-slices.js";
|
|
4
|
+
export type QuotaInfo = QuotaSlice;
|
|
5
|
+
export interface LinearModel {
|
|
6
|
+
U_1: bigint;
|
|
7
|
+
U_2: bigint;
|
|
8
|
+
R_base: bigint;
|
|
9
|
+
R_slope1: bigint;
|
|
10
|
+
R_slope2: bigint;
|
|
11
|
+
R_slope3: bigint;
|
|
12
|
+
interestModel: Address;
|
|
13
|
+
version: number;
|
|
14
|
+
isBorrowingMoreU2Forbidden: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface PoolData {
|
|
17
|
+
address: Address;
|
|
18
|
+
expectedLiquidity: bigint;
|
|
19
|
+
availableLiquidity: bigint;
|
|
20
|
+
interestModel: LinearModel;
|
|
21
|
+
totalDebtLimit: bigint;
|
|
22
|
+
totalBorrowed: bigint;
|
|
23
|
+
underlyingToken?: Address;
|
|
24
|
+
isPaused?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface CreditManagerData {
|
|
27
|
+
address: Address;
|
|
28
|
+
name: string;
|
|
29
|
+
underlyingToken: Address;
|
|
30
|
+
pool: Address;
|
|
31
|
+
isPaused: boolean;
|
|
32
|
+
collateralTokens: Array<Address>;
|
|
33
|
+
forbiddenTokens: Record<Address, true>;
|
|
34
|
+
supportedTokens: Record<Address, true>;
|
|
35
|
+
quotas: Record<Address, QuotaInfo>;
|
|
36
|
+
liquidationThresholds: Record<Address, bigint>;
|
|
37
|
+
maxDebt: bigint;
|
|
38
|
+
minDebt: bigint;
|
|
39
|
+
availableToBorrow: bigint;
|
|
40
|
+
totalDebt: bigint;
|
|
41
|
+
totalDebtLimit: bigint;
|
|
42
|
+
feeInterest: number;
|
|
43
|
+
baseBorrowRate: number;
|
|
44
|
+
maxEnabledTokensLength: number;
|
|
45
|
+
chainId: number;
|
|
46
|
+
isDegenMode: boolean;
|
|
47
|
+
degenNFT: Address;
|
|
48
|
+
isQuoted(token: Address): boolean;
|
|
49
|
+
isForbidden(token: Address): boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface PricesRecord {
|
|
52
|
+
[pool: Address]: {
|
|
53
|
+
[token: Address]: bigint;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface APYList {
|
|
57
|
+
apyList: Record<Address, number> | undefined;
|
|
58
|
+
extraCollateralAPYList: Record<Address, Record<Address, {
|
|
59
|
+
type: "relative" | "absolute";
|
|
60
|
+
value: number;
|
|
61
|
+
}>> | undefined;
|
|
62
|
+
pointsList: Record<Address, LocalPointsInfo> | undefined;
|
|
63
|
+
extraCollateralPointsList: Record<Address, Record<Address, LocalPointsInfo>> | undefined;
|
|
64
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Asset } from "../../../../sdk/router/types.js";
|
|
2
|
+
import type { calculateEarnings } from "../../apy/calculate-earnings.js";
|
|
3
|
+
import type { Strategy } from "../../strategies/types/strategy.js";
|
|
4
|
+
import type { calculateTotalAPY } from "../strategy-info/calculate-total-apy.js";
|
|
5
|
+
import type { calculateTotalPoints } from "../strategy-info/calculate-total-points.js";
|
|
6
|
+
import type { getListWithAmountInTarget } from "../tokens/get-list-with-amount-in-target.js";
|
|
7
|
+
import type { CreditManagerData } from "./strategy-data.js";
|
|
8
|
+
export type StrategyCMEarningsInfo<CM extends CreditManagerData> = {
|
|
9
|
+
status: "ok";
|
|
10
|
+
description: string;
|
|
11
|
+
otherInfo?: object;
|
|
12
|
+
data: {
|
|
13
|
+
info: {
|
|
14
|
+
strategy: Strategy;
|
|
15
|
+
creditManager: CM;
|
|
16
|
+
collateral: Array<Asset>;
|
|
17
|
+
assetsWithAmountInTarget: ReturnType<typeof getListWithAmountInTarget>;
|
|
18
|
+
assetValue: bigint;
|
|
19
|
+
debt: bigint;
|
|
20
|
+
totalAmount: bigint;
|
|
21
|
+
assetValueInUSD: bigint;
|
|
22
|
+
maxAPY: ReturnType<typeof calculateTotalAPY>;
|
|
23
|
+
bonusAPY: {
|
|
24
|
+
value: number;
|
|
25
|
+
} | undefined;
|
|
26
|
+
maxLeverage: bigint;
|
|
27
|
+
};
|
|
28
|
+
earnings: ReturnType<typeof calculateEarnings>;
|
|
29
|
+
points: ReturnType<typeof calculateTotalPoints>;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
status: "error";
|
|
33
|
+
description: string;
|
|
34
|
+
otherInfo?: object;
|
|
35
|
+
data: undefined;
|
|
36
|
+
};
|
|
37
|
+
export type EarningsList<CM extends CreditManagerData> = Array<StrategyCMEarningsInfo<CM>>;
|
|
38
|
+
export type StrategyEarningsListByChain<CM extends CreditManagerData> = Record<number, Record<string, EarningsList<CM>>>;
|
|
39
|
+
export interface BestEarningsState<CM extends CreditManagerData> {
|
|
40
|
+
best: StrategyCMEarningsInfo<CM> | undefined;
|
|
41
|
+
sorted: StrategyCMEarningsInfo<CM>[];
|
|
42
|
+
bestRecord: Record<number, Record<Strategy["id"], StrategyCMEarningsInfo<CM>>>;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isZeroBalance(balance: bigint | undefined): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
export interface ValidateBalanceProps {
|
|
3
|
+
amount: bigint;
|
|
4
|
+
tokenAddress: Address;
|
|
5
|
+
maxAmount: bigint | undefined;
|
|
6
|
+
zeroCheck?: boolean;
|
|
7
|
+
single?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type ValidateBalanceResult = {
|
|
10
|
+
message: "unknownToken";
|
|
11
|
+
token: Address;
|
|
12
|
+
} | {
|
|
13
|
+
message: "insufficientFunds";
|
|
14
|
+
token: Address;
|
|
15
|
+
} | {
|
|
16
|
+
message: "zeroBalance";
|
|
17
|
+
token: Address;
|
|
18
|
+
} | {
|
|
19
|
+
message: "enterAmount";
|
|
20
|
+
token: Address;
|
|
21
|
+
};
|
|
22
|
+
export declare function validateBalance({ amount, tokenAddress, maxAmount, zeroCheck, single, }: ValidateBalanceProps): ValidateBalanceResult | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { Asset } from "../../../sdk/router/types.js";
|
|
3
|
+
import type { ValidateBalanceResult } from "./validate-balance.js";
|
|
4
|
+
export interface ValidateBalancesProps {
|
|
5
|
+
balances: Record<Address, bigint>;
|
|
6
|
+
assets: Array<Asset>;
|
|
7
|
+
zeroCheck?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function validateBalances({ balances, assets, zeroCheck, }: ValidateBalancesProps): ValidateBalanceResult | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|