@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
|
@@ -0,0 +1,139 @@
|
|
|
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 test_utils_exports = {};
|
|
20
|
+
__export(test_utils_exports, {
|
|
21
|
+
buildCreditManager: () => buildCreditManager,
|
|
22
|
+
buildPool: () => buildPool,
|
|
23
|
+
buildQuota: () => buildQuota,
|
|
24
|
+
buildTokenData: () => buildTokenData,
|
|
25
|
+
mockCMAddress: () => mockCMAddress,
|
|
26
|
+
mockNativeTokenAddress: () => mockNativeTokenAddress,
|
|
27
|
+
mockPrices: () => mockPrices,
|
|
28
|
+
mockToken1: () => mockToken1,
|
|
29
|
+
mockToken2: () => mockToken2,
|
|
30
|
+
mockTokenData: () => mockTokenData,
|
|
31
|
+
mockUnderlyingToken: () => mockUnderlyingToken,
|
|
32
|
+
mockWrappedNativeTokenAddress: () => mockWrappedNativeTokenAddress
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(test_utils_exports);
|
|
35
|
+
var import_token_data = require("../charts/token-data.js");
|
|
36
|
+
const mockToken1 = "0x1111111111111111111111111111111111111111";
|
|
37
|
+
const mockToken2 = "0x2222222222222222222222222222222222222222";
|
|
38
|
+
const mockUnderlyingToken = "0x9999999999999999999999999999999999999999";
|
|
39
|
+
const mockNativeTokenAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
40
|
+
const mockWrappedNativeTokenAddress = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
|
|
41
|
+
const mockCMAddress = "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
|
|
42
|
+
function buildQuota(overrides) {
|
|
43
|
+
return {
|
|
44
|
+
rate: 0n,
|
|
45
|
+
quotaIncreaseFee: 0n,
|
|
46
|
+
totalQuoted: 0n,
|
|
47
|
+
limit: 0n,
|
|
48
|
+
isActive: true,
|
|
49
|
+
...overrides
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function buildPool(overrides = {}) {
|
|
53
|
+
const address = overrides.address ?? "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
54
|
+
return {
|
|
55
|
+
address,
|
|
56
|
+
expectedLiquidity: 0n,
|
|
57
|
+
availableLiquidity: 0n,
|
|
58
|
+
interestModel: {
|
|
59
|
+
interestModel: "0x0000000000000000000000000000000000000000",
|
|
60
|
+
U_1: 0n,
|
|
61
|
+
U_2: 0n,
|
|
62
|
+
R_base: 0n,
|
|
63
|
+
R_slope1: 0n,
|
|
64
|
+
R_slope2: 0n,
|
|
65
|
+
R_slope3: 0n,
|
|
66
|
+
version: 0,
|
|
67
|
+
isBorrowingMoreU2Forbidden: false
|
|
68
|
+
},
|
|
69
|
+
totalDebtLimit: 0n,
|
|
70
|
+
totalBorrowed: 0n,
|
|
71
|
+
...overrides
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function buildCreditManager(overrides = {}) {
|
|
75
|
+
const address = overrides.address ?? "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
|
|
76
|
+
const pool = overrides.pool ?? "0xcccccccccccccccccccccccccccccccccccccccc";
|
|
77
|
+
const underlyingToken = overrides.underlyingToken ?? mockUnderlyingToken;
|
|
78
|
+
const quotas = overrides.quotas ?? {};
|
|
79
|
+
return {
|
|
80
|
+
address,
|
|
81
|
+
name: overrides.name ?? "",
|
|
82
|
+
underlyingToken,
|
|
83
|
+
pool,
|
|
84
|
+
isPaused: overrides.isPaused ?? false,
|
|
85
|
+
collateralTokens: overrides.collateralTokens ?? [],
|
|
86
|
+
forbiddenTokens: overrides.forbiddenTokens ?? {},
|
|
87
|
+
supportedTokens: overrides.supportedTokens ?? {},
|
|
88
|
+
quotas,
|
|
89
|
+
liquidationThresholds: overrides.liquidationThresholds ?? {},
|
|
90
|
+
maxDebt: overrides.maxDebt ?? 0n,
|
|
91
|
+
minDebt: overrides.minDebt ?? 0n,
|
|
92
|
+
availableToBorrow: overrides.availableToBorrow ?? 0n,
|
|
93
|
+
totalDebt: overrides.totalDebt ?? 0n,
|
|
94
|
+
totalDebtLimit: overrides.totalDebtLimit ?? -1n,
|
|
95
|
+
feeInterest: overrides.feeInterest ?? 0,
|
|
96
|
+
baseBorrowRate: overrides.baseBorrowRate ?? 0,
|
|
97
|
+
maxEnabledTokensLength: overrides.maxEnabledTokensLength ?? 0,
|
|
98
|
+
chainId: overrides.chainId ?? 1,
|
|
99
|
+
isDegenMode: overrides.isDegenMode ?? false,
|
|
100
|
+
degenNFT: overrides.degenNFT ?? "0x0000000000000000000000000000000000000000",
|
|
101
|
+
isQuoted: overrides.isQuoted ?? (() => false),
|
|
102
|
+
isForbidden: overrides.isForbidden ?? (() => false),
|
|
103
|
+
...overrides
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function buildTokenData(address, symbol, decimals = 18, isPhantom = false) {
|
|
107
|
+
return new import_token_data.TokenData({
|
|
108
|
+
addr: address,
|
|
109
|
+
symbol,
|
|
110
|
+
name: symbol,
|
|
111
|
+
decimals,
|
|
112
|
+
isPhantom
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const mockTokenData = {
|
|
116
|
+
[mockToken1]: buildTokenData(mockToken1, "T1"),
|
|
117
|
+
[mockToken2]: buildTokenData(mockToken2, "T2"),
|
|
118
|
+
[mockUnderlyingToken]: buildTokenData(mockUnderlyingToken, "UNDER")
|
|
119
|
+
};
|
|
120
|
+
const mockPrices = {
|
|
121
|
+
[mockToken1]: 300000000n,
|
|
122
|
+
[mockToken2]: 200000000n,
|
|
123
|
+
[mockUnderlyingToken]: 100000000n
|
|
124
|
+
};
|
|
125
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
+
0 && (module.exports = {
|
|
127
|
+
buildCreditManager,
|
|
128
|
+
buildPool,
|
|
129
|
+
buildQuota,
|
|
130
|
+
buildTokenData,
|
|
131
|
+
mockCMAddress,
|
|
132
|
+
mockNativeTokenAddress,
|
|
133
|
+
mockPrices,
|
|
134
|
+
mockToken1,
|
|
135
|
+
mockToken2,
|
|
136
|
+
mockTokenData,
|
|
137
|
+
mockUnderlyingToken,
|
|
138
|
+
mockWrappedNativeTokenAddress
|
|
139
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
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 calculate_borrow_rate_from_utilization_exports = {};
|
|
20
|
+
__export(calculate_borrow_rate_from_utilization_exports, {
|
|
21
|
+
calculateBorrowRateFromUtilization: () => calculateBorrowRateFromUtilization
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(calculate_borrow_rate_from_utilization_exports);
|
|
24
|
+
var import_math = require("../../../sdk/constants/math.js");
|
|
25
|
+
function calculateBorrowRateFromUtilization(util, model, extraPrecision = 1n) {
|
|
26
|
+
const {
|
|
27
|
+
U_1: U_1_r,
|
|
28
|
+
U_2: U_2_r,
|
|
29
|
+
R_base: R_base_r,
|
|
30
|
+
R_slope1: R_slope1_r,
|
|
31
|
+
R_slope2: R_slope2_r,
|
|
32
|
+
R_slope3: R_slope3_r
|
|
33
|
+
} = model;
|
|
34
|
+
const U_1 = U_1_r * extraPrecision;
|
|
35
|
+
const U_2 = U_2_r * extraPrecision;
|
|
36
|
+
const R_base = R_base_r * extraPrecision;
|
|
37
|
+
const R_slope1 = R_slope1_r * extraPrecision;
|
|
38
|
+
const R_slope2 = R_slope2_r * extraPrecision;
|
|
39
|
+
const R_slope3 = R_slope3_r * extraPrecision;
|
|
40
|
+
const ONE = import_math.PERCENTAGE_FACTOR * extraPrecision;
|
|
41
|
+
if (util === 0n) {
|
|
42
|
+
return R_base;
|
|
43
|
+
}
|
|
44
|
+
if (util <= U_1) {
|
|
45
|
+
if (U_1 === 0n) return R_base;
|
|
46
|
+
const rate2 = R_base + R_slope1 * util / U_1;
|
|
47
|
+
return rate2;
|
|
48
|
+
}
|
|
49
|
+
if (util > U_1 && util <= U_2) {
|
|
50
|
+
const rate2 = R_base + R_slope1 + R_slope2 * (util - U_1) / (U_2 - U_1);
|
|
51
|
+
return rate2;
|
|
52
|
+
}
|
|
53
|
+
const rate = R_base + R_slope1 + R_slope2 + R_slope3 * (util - U_2) / (ONE - U_2);
|
|
54
|
+
return rate;
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
calculateBorrowRateFromUtilization
|
|
59
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_calculate_borrow_rate_from_utilization = require("./calculate-borrow-rate-from-utilization.js");
|
|
4
|
+
(0, import_vitest.describe)("calculateBorrowRateFromUtilization", () => {
|
|
5
|
+
const model = {
|
|
6
|
+
U_1: 30n,
|
|
7
|
+
U_2: 80n,
|
|
8
|
+
R_base: 100n,
|
|
9
|
+
R_slope1: 200n,
|
|
10
|
+
R_slope2: 300n,
|
|
11
|
+
R_slope3: 400n,
|
|
12
|
+
interestModel: "0x1",
|
|
13
|
+
isBorrowingMoreU2Forbidden: false,
|
|
14
|
+
version: 3
|
|
15
|
+
};
|
|
16
|
+
(0, import_vitest.it)("returns base rate when util is zero", () => {
|
|
17
|
+
(0, import_vitest.expect)((0, import_calculate_borrow_rate_from_utilization.calculateBorrowRateFromUtilization)(0n, model)).toBe(100n);
|
|
18
|
+
});
|
|
19
|
+
(0, import_vitest.it)("uses first segment when util <= U1", () => {
|
|
20
|
+
(0, import_vitest.expect)((0, import_calculate_borrow_rate_from_utilization.calculateBorrowRateFromUtilization)(15n, model)).toBe(200n);
|
|
21
|
+
});
|
|
22
|
+
(0, import_vitest.it)("uses second segment when U1 < util <= U2", () => {
|
|
23
|
+
(0, import_vitest.expect)((0, import_calculate_borrow_rate_from_utilization.calculateBorrowRateFromUtilization)(50n, model)).toBe(420n);
|
|
24
|
+
});
|
|
25
|
+
(0, import_vitest.it)("uses third segment when util > U2", () => {
|
|
26
|
+
(0, import_vitest.expect)((0, import_calculate_borrow_rate_from_utilization.calculateBorrowRateFromUtilization)(90n, model)).toBe(600n);
|
|
27
|
+
});
|
|
28
|
+
(0, import_vitest.it)("supports extraPrecision scaling", () => {
|
|
29
|
+
const scaled = (0, import_calculate_borrow_rate_from_utilization.calculateBorrowRateFromUtilization)(3000n, model, 100n);
|
|
30
|
+
(0, import_vitest.expect)(scaled).toBe(30000n);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
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 calculate_earnings_exports = {};
|
|
20
|
+
__export(calculate_earnings_exports, {
|
|
21
|
+
calculateEarnings: () => calculateEarnings
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(calculate_earnings_exports);
|
|
24
|
+
var import_math = require("../../../sdk/constants/math.js");
|
|
25
|
+
var import_price_math = require("../../utils/price-math.js");
|
|
26
|
+
function calculateEarnings({
|
|
27
|
+
overallAPYBigInt,
|
|
28
|
+
targetAmount,
|
|
29
|
+
targetToken,
|
|
30
|
+
tokensList,
|
|
31
|
+
prices
|
|
32
|
+
}) {
|
|
33
|
+
if (overallAPYBigInt === void 0 || overallAPYBigInt === null)
|
|
34
|
+
return {
|
|
35
|
+
earnings: null,
|
|
36
|
+
earningsUSD: null
|
|
37
|
+
};
|
|
38
|
+
if (targetAmount === void 0 || targetAmount <= 0n)
|
|
39
|
+
return {
|
|
40
|
+
earnings: null,
|
|
41
|
+
earningsUSD: null
|
|
42
|
+
};
|
|
43
|
+
const earnings = overallAPYBigInt * targetAmount / import_math.PERCENTAGE_FACTOR_1KK;
|
|
44
|
+
const targetPrice = prices[targetToken] || 0n;
|
|
45
|
+
const targetDecimals = tokensList[targetToken]?.decimals || 18;
|
|
46
|
+
const earningsUSD = import_price_math.PriceUtils.calcTotalPrice(
|
|
47
|
+
targetPrice,
|
|
48
|
+
earnings,
|
|
49
|
+
targetDecimals
|
|
50
|
+
);
|
|
51
|
+
return {
|
|
52
|
+
earnings,
|
|
53
|
+
earningsUSD
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
calculateEarnings
|
|
59
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_math = require("../../../sdk/constants/math.js");
|
|
4
|
+
var import_formatter = require("../../../sdk/utils/formatter.js");
|
|
5
|
+
var import_test_utils = require("../../test-utils/index.js");
|
|
6
|
+
var import_calculate_earnings = require("./calculate-earnings.js");
|
|
7
|
+
(0, import_vitest.describe)("calculateEarnings", () => {
|
|
8
|
+
const targetToken = import_test_utils.mockToken1;
|
|
9
|
+
const tokensList = import_test_utils.mockTokenData;
|
|
10
|
+
const prices = import_test_utils.mockPrices;
|
|
11
|
+
const targetAmount = (0, import_formatter.toBN)("100", 18);
|
|
12
|
+
const baseArgs = {
|
|
13
|
+
overallAPYBigInt: 1n,
|
|
14
|
+
targetAmount,
|
|
15
|
+
targetToken,
|
|
16
|
+
tokensList,
|
|
17
|
+
prices
|
|
18
|
+
};
|
|
19
|
+
(0, import_vitest.it)("returns null earnings when overallAPYBigInt is undefined", () => {
|
|
20
|
+
(0, import_vitest.expect)(
|
|
21
|
+
(0, import_calculate_earnings.calculateEarnings)({
|
|
22
|
+
...baseArgs,
|
|
23
|
+
overallAPYBigInt: void 0
|
|
24
|
+
})
|
|
25
|
+
).toEqual({ earnings: null, earningsUSD: null });
|
|
26
|
+
(0, import_vitest.expect)(
|
|
27
|
+
(0, import_calculate_earnings.calculateEarnings)({
|
|
28
|
+
...baseArgs,
|
|
29
|
+
overallAPYBigInt: null
|
|
30
|
+
})
|
|
31
|
+
).toEqual({ earnings: null, earningsUSD: null });
|
|
32
|
+
});
|
|
33
|
+
(0, import_vitest.it)("returns null earnings when targetAmount is missing or non-positive", () => {
|
|
34
|
+
(0, import_vitest.expect)(
|
|
35
|
+
(0, import_calculate_earnings.calculateEarnings)({
|
|
36
|
+
...baseArgs,
|
|
37
|
+
targetAmount: void 0
|
|
38
|
+
})
|
|
39
|
+
).toEqual({ earnings: null, earningsUSD: null });
|
|
40
|
+
(0, import_vitest.expect)(
|
|
41
|
+
(0, import_calculate_earnings.calculateEarnings)({
|
|
42
|
+
...baseArgs,
|
|
43
|
+
targetAmount: 0n
|
|
44
|
+
})
|
|
45
|
+
).toEqual({ earnings: null, earningsUSD: null });
|
|
46
|
+
});
|
|
47
|
+
(0, import_vitest.it)("calculates earnings and earningsUSD", () => {
|
|
48
|
+
const overallAPYBigInt = 2n * BigInt(import_math.PERCENTAGE_FACTOR_1KK);
|
|
49
|
+
const result = (0, import_calculate_earnings.calculateEarnings)({
|
|
50
|
+
...baseArgs,
|
|
51
|
+
overallAPYBigInt,
|
|
52
|
+
targetAmount,
|
|
53
|
+
targetToken,
|
|
54
|
+
tokensList,
|
|
55
|
+
prices
|
|
56
|
+
});
|
|
57
|
+
(0, import_vitest.expect)(result).toEqual({
|
|
58
|
+
earnings: 200000000000000000000n,
|
|
59
|
+
earningsUSD: 600000000000000000000n
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
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 calculate_safe_borrow_rate_exports = {};
|
|
20
|
+
__export(calculate_safe_borrow_rate_exports, {
|
|
21
|
+
calculateSafeBorrowRate: () => calculateSafeBorrowRate
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(calculate_safe_borrow_rate_exports);
|
|
24
|
+
var import_math = require("../../../sdk/constants/math.js");
|
|
25
|
+
var import_bigint_math = require("../../utils/bigint-math.js");
|
|
26
|
+
var import_calculate_borrow_rate_from_utilization = require("./calculate-borrow-rate-from-utilization.js");
|
|
27
|
+
function calculateSafeBorrowRate({
|
|
28
|
+
pool,
|
|
29
|
+
creditManager,
|
|
30
|
+
expectedLiquidityChange = 0n,
|
|
31
|
+
availableLiquidityChange = 0n
|
|
32
|
+
}) {
|
|
33
|
+
const expectedLiquidity = pool.expectedLiquidity + expectedLiquidityChange;
|
|
34
|
+
const availableLiquidity = pool.availableLiquidity + availableLiquidityChange;
|
|
35
|
+
const borrowed = import_bigint_math.BigIntMath.max(expectedLiquidity - availableLiquidity, 0n);
|
|
36
|
+
const EXTRA_PRECISION = 100n;
|
|
37
|
+
const ONE = import_math.PERCENTAGE_FACTOR * EXTRA_PRECISION;
|
|
38
|
+
const utilization = import_bigint_math.BigIntMath.min(
|
|
39
|
+
expectedLiquidity > 0 ? borrowed * ONE / expectedLiquidity : 0n,
|
|
40
|
+
ONE
|
|
41
|
+
);
|
|
42
|
+
const rate = (0, import_calculate_borrow_rate_from_utilization.calculateBorrowRateFromUtilization)(
|
|
43
|
+
utilization,
|
|
44
|
+
pool.interestModel,
|
|
45
|
+
EXTRA_PRECISION
|
|
46
|
+
);
|
|
47
|
+
const rateWithDaoFee = Number(
|
|
48
|
+
rate * (BigInt(creditManager.feeInterest) + import_math.PERCENTAGE_FACTOR) / import_math.PERCENTAGE_DECIMALS / EXTRA_PRECISION
|
|
49
|
+
);
|
|
50
|
+
return rateWithDaoFee;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
calculateSafeBorrowRate
|
|
55
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_test_utils = require("../../test-utils/index.js");
|
|
4
|
+
var import_calculate_safe_borrow_rate = require("./calculate-safe-borrow-rate.js");
|
|
5
|
+
(0, import_vitest.describe)("calculateSafeBorrowRate", () => {
|
|
6
|
+
const baseModel = {
|
|
7
|
+
U_1: 50n,
|
|
8
|
+
U_2: 80n,
|
|
9
|
+
R_base: 100n,
|
|
10
|
+
R_slope1: 0n,
|
|
11
|
+
R_slope2: 0n,
|
|
12
|
+
R_slope3: 0n,
|
|
13
|
+
interestModel: "0x1",
|
|
14
|
+
isBorrowingMoreU2Forbidden: false,
|
|
15
|
+
version: 3
|
|
16
|
+
};
|
|
17
|
+
const poolBase = (0, import_test_utils.buildPool)({
|
|
18
|
+
expectedLiquidity: 1000n,
|
|
19
|
+
availableLiquidity: 1000n,
|
|
20
|
+
// util = 0
|
|
21
|
+
interestModel: baseModel
|
|
22
|
+
});
|
|
23
|
+
(0, import_vitest.it)("returns rate with no fee at zero utilization", () => {
|
|
24
|
+
const creditManager = (0, import_test_utils.buildCreditManager)({ feeInterest: 0 });
|
|
25
|
+
const rate = (0, import_calculate_safe_borrow_rate.calculateSafeBorrowRate)({
|
|
26
|
+
pool: poolBase,
|
|
27
|
+
creditManager
|
|
28
|
+
});
|
|
29
|
+
(0, import_vitest.expect)(rate).toBe(1e4);
|
|
30
|
+
});
|
|
31
|
+
(0, import_vitest.it)("applies feeInterest scaling", () => {
|
|
32
|
+
const creditManager = (0, import_test_utils.buildCreditManager)({ feeInterest: 200 });
|
|
33
|
+
const rate = (0, import_calculate_safe_borrow_rate.calculateSafeBorrowRate)({
|
|
34
|
+
pool: poolBase,
|
|
35
|
+
creditManager
|
|
36
|
+
});
|
|
37
|
+
(0, import_vitest.expect)(rate).toBe(10200);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -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 __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 get_safe_base_borrow_rate_exports = {};
|
|
20
|
+
__export(get_safe_base_borrow_rate_exports, {
|
|
21
|
+
getSafeBaseBorrowRate: () => getSafeBaseBorrowRate
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_safe_base_borrow_rate_exports);
|
|
24
|
+
var import_calculate_safe_borrow_rate = require("./calculate-safe-borrow-rate.js");
|
|
25
|
+
const getSafeBaseBorrowRate = (props) => {
|
|
26
|
+
const { onError, ...rest } = props;
|
|
27
|
+
try {
|
|
28
|
+
const rate = (0, import_calculate_safe_borrow_rate.calculateSafeBorrowRate)(rest);
|
|
29
|
+
return rate;
|
|
30
|
+
} catch (e) {
|
|
31
|
+
onError?.(e);
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
getSafeBaseBorrowRate
|
|
38
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
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 constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
EMPTY_ADDRESS: () => EMPTY_ADDRESS,
|
|
22
|
+
EMPTY_ARRAY: () => EMPTY_ARRAY,
|
|
23
|
+
EMPTY_OBJECT: () => EMPTY_OBJECT
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(constants_exports);
|
|
26
|
+
const EMPTY_OBJECT = {};
|
|
27
|
+
const EMPTY_ARRAY = [];
|
|
28
|
+
const EMPTY_ADDRESS = "";
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
EMPTY_ADDRESS,
|
|
32
|
+
EMPTY_ARRAY,
|
|
33
|
+
EMPTY_OBJECT
|
|
34
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
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 assets_exports = {};
|
|
20
|
+
__export(assets_exports, {
|
|
21
|
+
getDefaultAsset: () => getDefaultAsset
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(assets_exports);
|
|
24
|
+
function getDefaultAsset(token) {
|
|
25
|
+
return { token };
|
|
26
|
+
}
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
getDefaultAsset
|
|
30
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
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 get_cm_allowed_collaterals_exports = {};
|
|
20
|
+
__export(get_cm_allowed_collaterals_exports, {
|
|
21
|
+
getCMAllowedCollaterals: () => getCMAllowedCollaterals
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_cm_allowed_collaterals_exports);
|
|
24
|
+
var import_is_collateral_token = require("../tokens/is-collateral-token.js");
|
|
25
|
+
function getCMAllowedCollaterals({
|
|
26
|
+
creditManager,
|
|
27
|
+
tokensList,
|
|
28
|
+
zeroDebt = false,
|
|
29
|
+
delayedPhantoms,
|
|
30
|
+
extraCollaterals,
|
|
31
|
+
nativeTokenAddress,
|
|
32
|
+
wrappedNativeTokenAddress
|
|
33
|
+
}) {
|
|
34
|
+
const tokens = creditManager?.collateralTokens;
|
|
35
|
+
if (!tokens) return {};
|
|
36
|
+
const collateralRecord = tokens.reduce(
|
|
37
|
+
(acc, address) => {
|
|
38
|
+
const allowed = (0, import_is_collateral_token.isCollateralToken)({
|
|
39
|
+
address,
|
|
40
|
+
tokensList,
|
|
41
|
+
creditManager,
|
|
42
|
+
zeroDebt,
|
|
43
|
+
delayedPhantoms,
|
|
44
|
+
extraCollateralConfigs: extraCollaterals?.list?.[address],
|
|
45
|
+
prices: extraCollaterals?.prices
|
|
46
|
+
});
|
|
47
|
+
if (allowed) {
|
|
48
|
+
acc[address] = address;
|
|
49
|
+
}
|
|
50
|
+
return acc;
|
|
51
|
+
},
|
|
52
|
+
{}
|
|
53
|
+
);
|
|
54
|
+
if (!creditManager.isPaused && wrappedNativeTokenAddress && collateralRecord[wrappedNativeTokenAddress] && nativeTokenAddress) {
|
|
55
|
+
collateralRecord[nativeTokenAddress] = nativeTokenAddress;
|
|
56
|
+
}
|
|
57
|
+
return collateralRecord;
|
|
58
|
+
}
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
getCMAllowedCollaterals
|
|
62
|
+
});
|