@gearbox-protocol/sdk 14.6.0-next.4 → 14.6.0
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/abi/compressors/subcompressors/withdrawal/infinifiWithdrawalSubcompressor.js +2 -1
- package/dist/cjs/abi/compressors/subcompressors/withdrawal/kelpLRTWithdrawalSubcompressor.js +2 -1
- package/dist/cjs/abi/compressors/subcompressors/withdrawal/mellowWithdrawalSubcompressor.js +2 -1
- package/dist/cjs/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.js +2 -1
- package/dist/cjs/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.js +2 -1
- package/dist/cjs/abi/compressors/subcompressors/withdrawal/upshiftWithdrawalSubcompressor.js +2 -1
- package/dist/cjs/abi/compressors/withdrawalCompressor.js +2 -1
- package/dist/cjs/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers-list-core.js +66 -0
- package/dist/cjs/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers-list.js +7 -18
- package/dist/cjs/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers.js +4 -6
- package/dist/cjs/common-utils/utils/strategies/credit-managers/index.js +2 -0
- package/dist/cjs/common-utils/utils/strategies/lists/get-released-strategies-list-core.js +61 -0
- package/dist/cjs/common-utils/utils/strategies/lists/get-released-strategies-list.js +9 -31
- package/dist/cjs/common-utils/utils/strategies/lists/index.js +3 -1
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-strategy-info-core.js +104 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-strategy-info.js +35 -59
- package/dist/cjs/common-utils/utils/strategies/strategy-info/index.js +2 -0
- package/dist/cjs/common-utils/utils/strategies/strategy-state/is-strategy-disabled.js +3 -1
- package/dist/cjs/common-utils/utils/strategies/types/index.js +4 -0
- package/dist/cjs/common-utils/utils/strategies/types/legacy-strategy-data-source.js +62 -0
- package/dist/cjs/common-utils/utils/strategies/types/strategy-data-source.js +16 -0
- package/dist/cjs/plugins/apy/ApyPlugin.js +65 -0
- package/dist/cjs/plugins/apy/strategy-data-source.js +176 -0
- package/dist/esm/abi/compressors/subcompressors/withdrawal/infinifiWithdrawalSubcompressor.js +2 -1
- package/dist/esm/abi/compressors/subcompressors/withdrawal/kelpLRTWithdrawalSubcompressor.js +2 -1
- package/dist/esm/abi/compressors/subcompressors/withdrawal/mellowWithdrawalSubcompressor.js +2 -1
- package/dist/esm/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.js +2 -1
- package/dist/esm/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.js +2 -1
- package/dist/esm/abi/compressors/subcompressors/withdrawal/upshiftWithdrawalSubcompressor.js +2 -1
- package/dist/esm/abi/compressors/withdrawalCompressor.js +2 -1
- package/dist/esm/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers-list-core.js +42 -0
- package/dist/esm/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers-list.js +7 -18
- package/dist/esm/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers.js +4 -6
- package/dist/esm/common-utils/utils/strategies/credit-managers/index.js +1 -0
- package/dist/esm/common-utils/utils/strategies/lists/get-released-strategies-list-core.js +37 -0
- package/dist/esm/common-utils/utils/strategies/lists/get-released-strategies-list.js +9 -31
- package/dist/esm/common-utils/utils/strategies/lists/index.js +1 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-strategy-info-core.js +80 -0
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-strategy-info.js +35 -59
- package/dist/esm/common-utils/utils/strategies/strategy-info/index.js +1 -0
- package/dist/esm/common-utils/utils/strategies/strategy-state/is-strategy-disabled.js +3 -1
- package/dist/esm/common-utils/utils/strategies/types/index.js +2 -0
- package/dist/esm/common-utils/utils/strategies/types/legacy-strategy-data-source.js +38 -0
- package/dist/esm/common-utils/utils/strategies/types/strategy-data-source.js +0 -0
- package/dist/esm/plugins/apy/ApyPlugin.js +70 -0
- package/dist/esm/plugins/apy/strategy-data-source.js +159 -0
- package/dist/types/abi/compressors/subcompressors/withdrawal/infinifiWithdrawalSubcompressor.d.ts +4 -0
- package/dist/types/abi/compressors/subcompressors/withdrawal/kelpLRTWithdrawalSubcompressor.d.ts +4 -0
- package/dist/types/abi/compressors/subcompressors/withdrawal/mellowWithdrawalSubcompressor.d.ts +4 -0
- package/dist/types/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.d.ts +4 -0
- package/dist/types/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.d.ts +4 -0
- package/dist/types/abi/compressors/subcompressors/withdrawal/upshiftWithdrawalSubcompressor.d.ts +4 -0
- package/dist/types/abi/compressors/withdrawalCompressor.d.ts +4 -0
- package/dist/types/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers-list-core.d.ts +7 -0
- package/dist/types/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers-list.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers.d.ts +3 -3
- package/dist/types/common-utils/utils/strategies/credit-managers/index.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/credit-managers/is-credit-manager-usable.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/eligibility/is-strategy-eligible.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/lists/get-available-and-disabled-strategies.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/lists/get-available-strategies.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/lists/get-disabled-strategies.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/lists/get-released-strategies-list-core.d.ts +9 -0
- package/dist/types/common-utils/utils/strategies/lists/get-released-strategies-list.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/lists/index.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/get-strategy-info-core.d.ts +12 -0
- package/dist/types/common-utils/utils/strategies/strategy-info/index.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/strategy-state/is-strategy-disabled.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/tokens/is-activated-token.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/tokens/is-forbidden-token.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/types/credit-manager-data-legacy.d.ts +3 -7
- package/dist/types/common-utils/utils/strategies/types/index.d.ts +2 -0
- package/dist/types/common-utils/utils/strategies/types/legacy-strategy-data-source.d.ts +4 -0
- package/dist/types/common-utils/utils/strategies/types/sdk-state.d.ts +5 -4
- package/dist/types/common-utils/utils/strategies/types/strategies-cm-list.d.ts +2 -2
- package/dist/types/common-utils/utils/strategies/types/strategy-data-source.d.ts +19 -0
- package/dist/types/common-utils/utils/strategies/types/targetable.d.ts +2 -2
- package/dist/types/permissionless/bindings/compressors/withdrawal-compressor.d.ts +4 -0
- package/dist/types/plugins/apy/ApyPlugin.d.ts +8 -1
- package/dist/types/plugins/apy/strategy-data-source.d.ts +16 -0
- package/dist/types/plugins/apy/types.d.ts +18 -1
- package/package.json +1 -1
|
@@ -0,0 +1,66 @@
|
|
|
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_strategy_credit_managers_list_core_exports = {};
|
|
20
|
+
__export(get_strategy_credit_managers_list_core_exports, {
|
|
21
|
+
getStrategyCreditManagersListCore: () => getStrategyCreditManagersListCore
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_strategy_credit_managers_list_core_exports);
|
|
24
|
+
var import_mappers = require("../../../../sdk/utils/mappers.js");
|
|
25
|
+
var import_tokens = require("../tokens/index.js");
|
|
26
|
+
var import_is_credit_manager_usable = require("./is-credit-manager-usable.js");
|
|
27
|
+
const lc = (address) => address.toLowerCase();
|
|
28
|
+
function getStrategyCreditManagersListCore({
|
|
29
|
+
strategies,
|
|
30
|
+
source,
|
|
31
|
+
curatorFilter
|
|
32
|
+
}) {
|
|
33
|
+
if (!strategies) return strategies;
|
|
34
|
+
return strategies.reduce((acc, strategy) => {
|
|
35
|
+
const targetToken = lc(strategy.tokenOutAddress);
|
|
36
|
+
const cms = (strategy.creditManagers || []).reduce(
|
|
37
|
+
(cmAcc, cmAddress) => {
|
|
38
|
+
const cm = source.getCreditManager(strategy.chainId, cmAddress);
|
|
39
|
+
if (!cm || !(0, import_is_credit_manager_usable.isCreditManagerUsable)(cm)) return cmAcc;
|
|
40
|
+
const usable = (0, import_tokens.isUsableToken)({
|
|
41
|
+
address: targetToken,
|
|
42
|
+
creditManager: cm
|
|
43
|
+
});
|
|
44
|
+
const limit = cm.quotas[targetToken]?.limit || 0n;
|
|
45
|
+
const limitZero = targetToken === cm.underlyingToken ? false : limit === 0n;
|
|
46
|
+
if (usable && !cm.isBorrowingForbidden && !limitZero) {
|
|
47
|
+
cmAcc[cm.address] = cm;
|
|
48
|
+
}
|
|
49
|
+
return cmAcc;
|
|
50
|
+
},
|
|
51
|
+
{}
|
|
52
|
+
);
|
|
53
|
+
const cmsAfterCuratorFilter = curatorFilter ? import_mappers.TypedObjectUtils.entries(cms).filter(
|
|
54
|
+
([, cm]) => curatorFilter[cm.marketConfigurator]
|
|
55
|
+
) : import_mappers.TypedObjectUtils.entries(cms);
|
|
56
|
+
if (!acc[strategy.chainId]) acc[strategy.chainId] = {};
|
|
57
|
+
acc[strategy.chainId][strategy.id] = Object.fromEntries(
|
|
58
|
+
cmsAfterCuratorFilter
|
|
59
|
+
);
|
|
60
|
+
return acc;
|
|
61
|
+
}, {});
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
getStrategyCreditManagersListCore
|
|
66
|
+
});
|
package/dist/cjs/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers-list.js
CHANGED
|
@@ -21,26 +21,15 @@ __export(get_strategy_credit_managers_list_exports, {
|
|
|
21
21
|
getStrategyCreditManagersList: () => getStrategyCreditManagersList
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(get_strategy_credit_managers_list_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var import_types = require("../types.js");
|
|
25
|
+
var import_get_strategy_credit_managers_list_core = require("./get-strategy-credit-managers-list-core.js");
|
|
26
26
|
function getStrategyCreditManagersList(strategies, sdkStateByChain, curatorFilter) {
|
|
27
27
|
if (!sdkStateByChain) return sdkStateByChain;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
strategy: s,
|
|
34
|
-
allCreditManagers: creditManagers
|
|
35
|
-
}) : {};
|
|
36
|
-
const cmsAfterCuratorFilter = curatorFilter ? import_mappers.TypedObjectUtils.entries(cms).filter(
|
|
37
|
-
([, cm]) => curatorFilter[cm.marketConfigurator]
|
|
38
|
-
) : import_mappers.TypedObjectUtils.entries(cms);
|
|
39
|
-
if (!acc[s.chainId]) acc[s.chainId] = {};
|
|
40
|
-
acc[s.chainId][s.id] = Object.fromEntries(cmsAfterCuratorFilter);
|
|
41
|
-
return acc;
|
|
42
|
-
}, {});
|
|
43
|
-
return r;
|
|
28
|
+
return (0, import_get_strategy_credit_managers_list_core.getStrategyCreditManagersListCore)({
|
|
29
|
+
strategies,
|
|
30
|
+
source: (0, import_types.createLegacyStrategyDataSource)(sdkStateByChain),
|
|
31
|
+
curatorFilter
|
|
32
|
+
});
|
|
44
33
|
}
|
|
45
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
35
|
0 && (module.exports = {
|
package/dist/cjs/common-utils/utils/strategies/credit-managers/get-strategy-credit-managers.js
CHANGED
|
@@ -23,14 +23,12 @@ __export(get_strategy_credit_managers_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(get_strategy_credit_managers_exports);
|
|
24
24
|
var import_is_usable_token = require("../tokens/is-usable-token.js");
|
|
25
25
|
var import_is_credit_manager_usable = require("./is-credit-manager-usable.js");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}) {
|
|
30
|
-
const lpAddress = strategy.tokenOutAddress;
|
|
26
|
+
const lc = (address) => address.toLowerCase();
|
|
27
|
+
function getStrategyCreditManagers({ strategy, allCreditManagers }) {
|
|
28
|
+
const lpAddress = lc(strategy.tokenOutAddress);
|
|
31
29
|
const res = (strategy?.creditManagers || []).reduce(
|
|
32
30
|
(acc, cmAddress) => {
|
|
33
|
-
const cm = allCreditManagers[cmAddress];
|
|
31
|
+
const cm = allCreditManagers[cmAddress] ?? allCreditManagers[lc(cmAddress)];
|
|
34
32
|
if (cm && (0, import_is_credit_manager_usable.isCreditManagerUsable)(cm)) {
|
|
35
33
|
const usable = (0, import_is_usable_token.isUsableToken)({
|
|
36
34
|
address: lpAddress,
|
|
@@ -17,10 +17,12 @@ var credit_managers_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(credit_managers_exports);
|
|
18
18
|
__reExport(credit_managers_exports, require("./get-strategy-credit-managers.js"), module.exports);
|
|
19
19
|
__reExport(credit_managers_exports, require("./get-strategy-credit-managers-list.js"), module.exports);
|
|
20
|
+
__reExport(credit_managers_exports, require("./get-strategy-credit-managers-list-core.js"), module.exports);
|
|
20
21
|
__reExport(credit_managers_exports, require("./is-credit-manager-usable.js"), module.exports);
|
|
21
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
23
|
0 && (module.exports = {
|
|
23
24
|
...require("./get-strategy-credit-managers.js"),
|
|
24
25
|
...require("./get-strategy-credit-managers-list.js"),
|
|
26
|
+
...require("./get-strategy-credit-managers-list-core.js"),
|
|
25
27
|
...require("./is-credit-manager-usable.js")
|
|
26
28
|
});
|
|
@@ -0,0 +1,61 @@
|
|
|
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_released_strategies_list_core_exports = {};
|
|
20
|
+
__export(get_released_strategies_list_core_exports, {
|
|
21
|
+
getReleasedStrategiesListCore: () => getReleasedStrategiesListCore
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_released_strategies_list_core_exports);
|
|
24
|
+
var import_is_strategy_released = require("../eligibility/is-strategy-released.js");
|
|
25
|
+
function getReleasedStrategiesListCore({
|
|
26
|
+
strategyPayloadsList,
|
|
27
|
+
allowedChains,
|
|
28
|
+
source,
|
|
29
|
+
curatorFilter,
|
|
30
|
+
showHiddenStrategies
|
|
31
|
+
}) {
|
|
32
|
+
if (!allowedChains) return void 0;
|
|
33
|
+
if (!strategyPayloadsList) return void 0;
|
|
34
|
+
const eligibleStrategies = strategyPayloadsList.reduce(
|
|
35
|
+
(acc, s) => {
|
|
36
|
+
const network = s.chainId !== void 0 ? allowedChains[s.chainId] : void 0;
|
|
37
|
+
const isNetworkCorrect = !!network && network === s.network;
|
|
38
|
+
const isHidden = !showHiddenStrategies && s.hideInProd;
|
|
39
|
+
const showInMainApp = s.showInMainApp ?? true;
|
|
40
|
+
const showCondition = curatorFilter || showInMainApp;
|
|
41
|
+
if (isNetworkCorrect && !isHidden && source.hasToken(s.chainId, s.tokenOutAddress) && showCondition) {
|
|
42
|
+
acc.push({
|
|
43
|
+
...s,
|
|
44
|
+
id: s.tokenOutAddress,
|
|
45
|
+
network
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return acc;
|
|
49
|
+
},
|
|
50
|
+
[]
|
|
51
|
+
);
|
|
52
|
+
return eligibleStrategies.filter((s) => {
|
|
53
|
+
const lastSyncTimestamp = source.getLastSyncTimestamp(s.chainId);
|
|
54
|
+
if (!lastSyncTimestamp) return true;
|
|
55
|
+
return showHiddenStrategies ? true : (0, import_is_strategy_released.isStrategyReleased)(s.releaseAt, lastSyncTimestamp);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
getReleasedStrategiesListCore
|
|
61
|
+
});
|
|
@@ -21,38 +21,16 @@ __export(get_released_strategies_list_exports, {
|
|
|
21
21
|
getReleasedStrategiesList: () => getReleasedStrategiesList
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(get_released_strategies_list_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var import_types = require("../types.js");
|
|
25
|
+
var import_get_released_strategies_list_core = require("./get-released-strategies-list-core.js");
|
|
26
26
|
function getReleasedStrategiesList(strategyPayloadsList, allowedChains, sdkStateByChain, curatorFilter, showHiddenStrategies) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
showHiddenStrategies,
|
|
35
|
-
sdkStateByChain,
|
|
36
|
-
curatorFilter
|
|
37
|
-
);
|
|
38
|
-
if (eligible.isEligible) {
|
|
39
|
-
acc.push({
|
|
40
|
-
...s,
|
|
41
|
-
id: s.tokenOutAddress,
|
|
42
|
-
network: eligible.network
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return acc;
|
|
46
|
-
},
|
|
47
|
-
[]
|
|
48
|
-
);
|
|
49
|
-
if (!sdkStateByChain) return eligibleStrategies;
|
|
50
|
-
const releasedStrategies = eligibleStrategies.filter((s) => {
|
|
51
|
-
const lastSyncBlock = sdkStateByChain?.[s.chainId]?.lastSyncBlock;
|
|
52
|
-
if (!lastSyncBlock) return true;
|
|
53
|
-
return showHiddenStrategies ? true : (0, import_is_strategy_released.isStrategyReleased)(s.releaseAt, lastSyncBlock.blockTimestamp_js);
|
|
54
|
-
}, {});
|
|
55
|
-
return releasedStrategies;
|
|
27
|
+
return (0, import_get_released_strategies_list_core.getReleasedStrategiesListCore)({
|
|
28
|
+
strategyPayloadsList,
|
|
29
|
+
allowedChains,
|
|
30
|
+
source: (0, import_types.createLegacyStrategyDataSource)(sdkStateByChain),
|
|
31
|
+
curatorFilter,
|
|
32
|
+
showHiddenStrategies
|
|
33
|
+
});
|
|
56
34
|
}
|
|
57
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
36
|
0 && (module.exports = {
|
|
@@ -17,8 +17,10 @@ var lists_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(lists_exports);
|
|
18
18
|
__reExport(lists_exports, require("./get-available-and-disabled-strategies.js"), module.exports);
|
|
19
19
|
__reExport(lists_exports, require("./get-released-strategies-list.js"), module.exports);
|
|
20
|
+
__reExport(lists_exports, require("./get-released-strategies-list-core.js"), module.exports);
|
|
20
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
22
|
0 && (module.exports = {
|
|
22
23
|
...require("./get-available-and-disabled-strategies.js"),
|
|
23
|
-
...require("./get-released-strategies-list.js")
|
|
24
|
+
...require("./get-released-strategies-list.js"),
|
|
25
|
+
...require("./get-released-strategies-list-core.js")
|
|
24
26
|
});
|
|
@@ -0,0 +1,104 @@
|
|
|
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_strategy_info_core_exports = {};
|
|
20
|
+
__export(get_strategy_info_core_exports, {
|
|
21
|
+
getStrategyInfoCore: () => getStrategyInfoCore
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_strategy_info_core_exports);
|
|
24
|
+
var import_price_math = require("../../price-math.js");
|
|
25
|
+
var import_leverage = require("../leverage/index.js");
|
|
26
|
+
var import_sort_strategy_cms_by_availability = require("../sort-strategy-cms-by-availability/index.js");
|
|
27
|
+
var import_get_strategy_max_apy = require("./get-strategy-max-apy.js");
|
|
28
|
+
var import_is_strategy_cm_disabled = require("./is-strategy-cm-disabled.js");
|
|
29
|
+
const EMPTY_ADDRESS = "";
|
|
30
|
+
const lc = (address) => address.toLowerCase();
|
|
31
|
+
function getStrategyInfoCore({
|
|
32
|
+
strategy,
|
|
33
|
+
creditManagers,
|
|
34
|
+
source,
|
|
35
|
+
apyListByNetwork,
|
|
36
|
+
quotaReserve,
|
|
37
|
+
slippage
|
|
38
|
+
}) {
|
|
39
|
+
const strategyCMsList = Object.values(creditManagers || {});
|
|
40
|
+
if (strategyCMsList.length === 0) return void 0;
|
|
41
|
+
const targetTokenAddress = lc(strategy.tokenOutAddress);
|
|
42
|
+
const openableCMsList = strategyCMsList.filter(
|
|
43
|
+
(cm) => !(0, import_is_strategy_cm_disabled.isStrategyCMDisabled)(cm, cm.quotas[targetTokenAddress])
|
|
44
|
+
);
|
|
45
|
+
const pools = strategyCMsList.reduce(
|
|
46
|
+
(acc, cm) => {
|
|
47
|
+
const pool = source.getPool(cm.chainId, cm.pool);
|
|
48
|
+
if (pool) acc[cm.pool] = pool;
|
|
49
|
+
return acc;
|
|
50
|
+
},
|
|
51
|
+
{}
|
|
52
|
+
);
|
|
53
|
+
const minCreditManager = (0, import_sort_strategy_cms_by_availability.sortStrategyCMsByAvailability)({
|
|
54
|
+
targetToken: targetTokenAddress,
|
|
55
|
+
allCreditManagers: openableCMsList.length > 0 ? openableCMsList : strategyCMsList,
|
|
56
|
+
apyListByNetwork,
|
|
57
|
+
slippage,
|
|
58
|
+
quotaReserve,
|
|
59
|
+
pools,
|
|
60
|
+
leverageLimit: strategy.maxLeverage,
|
|
61
|
+
isStrategy: true
|
|
62
|
+
})?.[0] || strategyCMsList[0];
|
|
63
|
+
const { underlyingToken = EMPTY_ADDRESS, availableToBorrow = 0n } = minCreditManager || {};
|
|
64
|
+
const {
|
|
65
|
+
bonusAPY,
|
|
66
|
+
totalMaxApy = 0,
|
|
67
|
+
maxLeverage = 0n,
|
|
68
|
+
baseBorrowRate = 0,
|
|
69
|
+
quotaRateMin = 0n
|
|
70
|
+
} = (0, import_get_strategy_max_apy.getStrategyMaxAPY)(
|
|
71
|
+
targetTokenAddress,
|
|
72
|
+
minCreditManager,
|
|
73
|
+
apyListByNetwork,
|
|
74
|
+
slippage,
|
|
75
|
+
quotaReserve,
|
|
76
|
+
strategy.maxLeverage
|
|
77
|
+
) || {};
|
|
78
|
+
const prices = source.getMarketPrices(
|
|
79
|
+
minCreditManager?.chainId ?? strategy.chainId,
|
|
80
|
+
minCreditManager?.pool || EMPTY_ADDRESS
|
|
81
|
+
);
|
|
82
|
+
const underlyingPrice = prices?.[underlyingToken] || 0n;
|
|
83
|
+
const underlyingDecimals = source.getToken(strategy.chainId, underlyingToken)?.decimals || 18;
|
|
84
|
+
const availableToBorrowMoney = import_price_math.PriceUtils.calcTotalPrice(
|
|
85
|
+
underlyingPrice,
|
|
86
|
+
availableToBorrow,
|
|
87
|
+
underlyingDecimals
|
|
88
|
+
);
|
|
89
|
+
const r = BigInt(baseBorrowRate) * (0, import_leverage.getFactorFromLeverage)(maxLeverage) / maxLeverage;
|
|
90
|
+
const qr = quotaRateMin;
|
|
91
|
+
const totalBorrowRate = Number(r + qr);
|
|
92
|
+
return {
|
|
93
|
+
maxLeverage,
|
|
94
|
+
maxAPY: totalMaxApy,
|
|
95
|
+
bonusAPY,
|
|
96
|
+
totalBorrowRate,
|
|
97
|
+
availableToBorrowMoney,
|
|
98
|
+
minCreditManager
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
getStrategyInfoCore
|
|
104
|
+
});
|
|
@@ -21,13 +21,10 @@ __export(get_strategy_info_exports, {
|
|
|
21
21
|
getStrategyInfo: () => getStrategyInfo
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(get_strategy_info_exports);
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var import_is_strategy_cm_disabled = require("./is-strategy-cm-disabled.js");
|
|
29
|
-
const EMPTY_ADDRESS = "";
|
|
30
|
-
const EMPTY_CHAIN_ID = 0;
|
|
24
|
+
var import_get_strategy_info_core = require("./get-strategy-info-core.js");
|
|
25
|
+
function getByAddress(record, address) {
|
|
26
|
+
return record?.[address] ?? record?.[address.toLowerCase()];
|
|
27
|
+
}
|
|
31
28
|
function getStrategyInfo({
|
|
32
29
|
strategy,
|
|
33
30
|
creditManagers,
|
|
@@ -37,60 +34,39 @@ function getStrategyInfo({
|
|
|
37
34
|
slippage,
|
|
38
35
|
allPricesByChain
|
|
39
36
|
}) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
minCreditManager,
|
|
37
|
+
return (0, import_get_strategy_info_core.getStrategyInfoCore)({
|
|
38
|
+
strategy,
|
|
39
|
+
creditManagers: creditManagers?.[strategy.chainId]?.[strategy.id],
|
|
40
|
+
source: {
|
|
41
|
+
hasToken(chainId, token) {
|
|
42
|
+
return !!getByAddress(
|
|
43
|
+
sdkStateByChain?.[chainId]?.tokens?.tokenDataList,
|
|
44
|
+
token
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
getToken(chainId, token) {
|
|
48
|
+
return getByAddress(
|
|
49
|
+
sdkStateByChain?.[chainId]?.tokens?.tokenDataList,
|
|
50
|
+
token
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
getPool(chainId, pool) {
|
|
54
|
+
return getByAddress(sdkStateByChain?.[chainId]?.pools, pool);
|
|
55
|
+
},
|
|
56
|
+
getCreditManager() {
|
|
57
|
+
return void 0;
|
|
58
|
+
},
|
|
59
|
+
getMarketPrices(chainId, pool) {
|
|
60
|
+
return getByAddress(allPricesByChain?.[chainId]?.prices, pool) || {};
|
|
61
|
+
},
|
|
62
|
+
getLastSyncTimestamp() {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
70
66
|
apyListByNetwork,
|
|
71
|
-
slippage,
|
|
72
67
|
quotaReserve,
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
const prices = allPricesByChain?.[minCreditManager?.chainId ?? EMPTY_CHAIN_ID]?.prices?.[minCreditManager?.pool || EMPTY_ADDRESS];
|
|
76
|
-
const underlyingPrice = prices?.[underlyingToken] || 0n;
|
|
77
|
-
const underlyingDecimals = tokensList?.[underlyingToken]?.decimals || 18;
|
|
78
|
-
const availableToBorrowMoney = import_price_math.PriceUtils.calcTotalPrice(
|
|
79
|
-
underlyingPrice,
|
|
80
|
-
availableToBorrow,
|
|
81
|
-
underlyingDecimals
|
|
82
|
-
);
|
|
83
|
-
const r = BigInt(baseBorrowRate) * (0, import_leverage.getFactorFromLeverage)(maxLeverage) / maxLeverage;
|
|
84
|
-
const qr = quotaRateMin;
|
|
85
|
-
const totalBorrowRate = Number(r + qr);
|
|
86
|
-
return {
|
|
87
|
-
maxLeverage,
|
|
88
|
-
maxAPY: totalMaxApy,
|
|
89
|
-
bonusAPY,
|
|
90
|
-
totalBorrowRate,
|
|
91
|
-
availableToBorrowMoney,
|
|
92
|
-
minCreditManager
|
|
93
|
-
};
|
|
68
|
+
slippage
|
|
69
|
+
});
|
|
94
70
|
}
|
|
95
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
96
72
|
0 && (module.exports = {
|
|
@@ -17,6 +17,7 @@ var strategy_info_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(strategy_info_exports);
|
|
18
18
|
__reExport(strategy_info_exports, require("./cm-availability-condition.js"), module.exports);
|
|
19
19
|
__reExport(strategy_info_exports, require("./get-strategy-info.js"), module.exports);
|
|
20
|
+
__reExport(strategy_info_exports, require("./get-strategy-info-core.js"), module.exports);
|
|
20
21
|
__reExport(strategy_info_exports, require("./get-strategy-max-apy.js"), module.exports);
|
|
21
22
|
__reExport(strategy_info_exports, require("./is-strategy-cm-disabled.js"), module.exports);
|
|
22
23
|
__reExport(strategy_info_exports, require("./types.js"), module.exports);
|
|
@@ -24,6 +25,7 @@ __reExport(strategy_info_exports, require("./types.js"), module.exports);
|
|
|
24
25
|
0 && (module.exports = {
|
|
25
26
|
...require("./cm-availability-condition.js"),
|
|
26
27
|
...require("./get-strategy-info.js"),
|
|
28
|
+
...require("./get-strategy-info-core.js"),
|
|
27
29
|
...require("./get-strategy-max-apy.js"),
|
|
28
30
|
...require("./is-strategy-cm-disabled.js"),
|
|
29
31
|
...require("./types.js")
|
|
@@ -22,10 +22,12 @@ __export(is_strategy_disabled_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(is_strategy_disabled_exports);
|
|
24
24
|
var import_is_strategy_cm_disabled = require("../strategy-info/is-strategy-cm-disabled.js");
|
|
25
|
+
const lc = (address) => address.toLowerCase();
|
|
25
26
|
function isStrategyDisabled(tokenOutAddress, cms) {
|
|
26
27
|
if (cms.length === 0) return true;
|
|
28
|
+
const targetToken = lc(tokenOutAddress);
|
|
27
29
|
const allCmsUnavailable = cms.every((cm) => {
|
|
28
|
-
const quota = cm.quotas[
|
|
30
|
+
const quota = cm.quotas[targetToken];
|
|
29
31
|
return (0, import_is_strategy_cm_disabled.isStrategyCMDisabled)(cm, quota);
|
|
30
32
|
});
|
|
31
33
|
return allCmsUnavailable;
|
|
@@ -19,9 +19,11 @@ __reExport(types_exports, require("./chains.js"), module.exports);
|
|
|
19
19
|
__reExport(types_exports, require("./constants.js"), module.exports);
|
|
20
20
|
__reExport(types_exports, require("./credit-manager-data-legacy.js"), module.exports);
|
|
21
21
|
__reExport(types_exports, require("./curator-filter.js"), module.exports);
|
|
22
|
+
__reExport(types_exports, require("./legacy-strategy-data-source.js"), module.exports);
|
|
22
23
|
__reExport(types_exports, require("./sdk-state.js"), module.exports);
|
|
23
24
|
__reExport(types_exports, require("./strategies-cm-list.js"), module.exports);
|
|
24
25
|
__reExport(types_exports, require("./strategy.js"), module.exports);
|
|
26
|
+
__reExport(types_exports, require("./strategy-data-source.js"), module.exports);
|
|
25
27
|
__reExport(types_exports, require("./targetable.js"), module.exports);
|
|
26
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
29
|
0 && (module.exports = {
|
|
@@ -29,8 +31,10 @@ __reExport(types_exports, require("./targetable.js"), module.exports);
|
|
|
29
31
|
...require("./constants.js"),
|
|
30
32
|
...require("./credit-manager-data-legacy.js"),
|
|
31
33
|
...require("./curator-filter.js"),
|
|
34
|
+
...require("./legacy-strategy-data-source.js"),
|
|
32
35
|
...require("./sdk-state.js"),
|
|
33
36
|
...require("./strategies-cm-list.js"),
|
|
34
37
|
...require("./strategy.js"),
|
|
38
|
+
...require("./strategy-data-source.js"),
|
|
35
39
|
...require("./targetable.js")
|
|
36
40
|
});
|