@strkfarm/sdk 2.0.0-dev.9 → 2.0.0-staging.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.global.js +111371 -93151
- package/dist/index.browser.mjs +27815 -32690
- package/dist/index.d.ts +1095 -2011
- package/dist/index.js +27425 -32309
- package/dist/index.mjs +27590 -32452
- package/package.json +6 -5
- package/src/data/ekubo-price-fethcer.abi.json +265 -0
- package/src/data/universal-vault.abi.json +20 -135
- package/src/dataTypes/address.ts +0 -7
- package/src/dataTypes/index.ts +3 -2
- package/src/dataTypes/mynumber.ts +141 -0
- package/src/global.ts +296 -288
- package/src/index.browser.ts +6 -5
- package/src/interfaces/common.tsx +324 -184
- package/src/modules/apollo-client-config.ts +28 -0
- package/src/modules/avnu.ts +4 -17
- package/src/modules/ekubo-pricer.ts +79 -0
- package/src/modules/ekubo-quoter.ts +11 -88
- package/src/modules/erc20.ts +21 -67
- package/src/modules/harvests.ts +26 -15
- package/src/modules/index.ts +11 -13
- package/src/modules/lst-apr.ts +0 -36
- package/src/modules/pragma.ts +23 -8
- package/src/modules/pricer-from-api.ts +150 -14
- package/src/modules/pricer.ts +2 -1
- package/src/modules/pricerBase.ts +2 -1
- package/src/node/deployer.ts +36 -1
- package/src/node/pricer-redis.ts +2 -1
- package/src/strategies/autoCompounderStrk.ts +1 -1
- package/src/strategies/base-strategy.ts +5 -22
- package/src/strategies/ekubo-cl-vault.tsx +2904 -2175
- package/src/strategies/factory.ts +165 -0
- package/src/strategies/index.ts +10 -11
- package/src/strategies/registry.ts +268 -0
- package/src/strategies/sensei.ts +416 -292
- package/src/strategies/universal-adapters/adapter-utils.ts +1 -5
- package/src/strategies/universal-adapters/baseAdapter.ts +153 -181
- package/src/strategies/universal-adapters/common-adapter.ts +77 -98
- package/src/strategies/universal-adapters/index.ts +1 -5
- package/src/strategies/universal-adapters/vesu-adapter.ts +218 -220
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +51 -58
- package/src/strategies/universal-lst-muliplier-strategy.tsx +1952 -992
- package/src/strategies/universal-strategy.tsx +1713 -1150
- package/src/strategies/vesu-rebalance.tsx +1189 -986
- package/src/utils/health-factor-math.ts +5 -11
- package/src/utils/index.ts +8 -9
- package/src/utils/strategy-utils.ts +57 -0
- package/src/data/extended-deposit.abi.json +0 -3613
- package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
- package/src/modules/ExtendedWrapperSDk/types.ts +0 -311
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -395
- package/src/modules/midas.ts +0 -159
- package/src/modules/token-market-data.ts +0 -202
- package/src/strategies/svk-strategy.ts +0 -247
- package/src/strategies/universal-adapters/adapter-optimizer.ts +0 -65
- package/src/strategies/universal-adapters/avnu-adapter.ts +0 -413
- package/src/strategies/universal-adapters/extended-adapter.ts +0 -972
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +0 -1306
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -34
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -77
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -49
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -370
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1379
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Web3Number } from "@/dataTypes";
|
|
2
2
|
import { TokenInfo } from "@/interfaces";
|
|
3
|
-
import { logger } from "@/utils/logger";
|
|
4
3
|
|
|
5
4
|
export class HealthFactorMath {
|
|
6
5
|
static getCollateralRequired(
|
|
@@ -53,18 +52,13 @@ export class HealthFactorMath {
|
|
|
53
52
|
debtTokenInfo: TokenInfo
|
|
54
53
|
) {
|
|
55
54
|
// lets say debt usd value is X
|
|
56
|
-
// HF = ((
|
|
57
|
-
// => X * HF = ((
|
|
58
|
-
// => X * (HF - maxLTV) =
|
|
59
|
-
// => X =
|
|
55
|
+
// HF = ((1 * cp) + X) * maxLTV / (X)
|
|
56
|
+
// => X * HF = ((1 * cp) + X) * maxLTV
|
|
57
|
+
// => X * (HF - maxLTV) = 1 * cp * maxLTV
|
|
58
|
+
// => X = 1 * cp * maxLTV / (HF - maxLTV)
|
|
60
59
|
const numerator = collateralAmount.multipliedBy(collateralPrice).multipliedBy(maxLTV);
|
|
61
|
-
logger.verbose(`HealthFactorMath: Max debt amount on looping numerator: ${numerator.toNumber()}, collateralAmount: ${collateralAmount.toNumber()}, collateralPrice: ${collateralPrice}, maxLTV: ${maxLTV}, targetHF: ${targetHF}, debtPrice: ${debtPrice}`);
|
|
62
60
|
const denominator = targetHF - maxLTV;
|
|
63
|
-
|
|
64
|
-
const debtAmountUSD = numerator.dividedBy(denominator);
|
|
65
|
-
logger.verbose(`HealthFactorMath: Max debt amount on looping debtAmountUSD: ${debtAmountUSD.toNumber()}`);
|
|
66
|
-
const debtAmount = debtAmountUSD.dividedBy(debtPrice);
|
|
67
|
-
logger.verbose(`HealthFactorMath: Max debt amount on looping debtAmount: ${debtAmount.toNumber()}`);
|
|
61
|
+
const debtAmount = numerator.dividedBy(denominator);
|
|
68
62
|
return new Web3Number(debtAmount.toString(), debtTokenInfo.decimals);
|
|
69
63
|
}
|
|
70
64
|
|
package/src/utils/index.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "@/utils/logger";
|
|
2
|
+
export * from "./oz-merkle";
|
|
3
|
+
export * from "./strategy-utils";
|
|
4
4
|
|
|
5
5
|
// Utility type to make all optional properties required
|
|
6
6
|
export type RequiredFields<T> = {
|
|
7
|
-
[K in keyof T]-?: T[K]
|
|
8
|
-
}
|
|
7
|
+
[K in keyof T]-?: T[K];
|
|
8
|
+
};
|
|
9
9
|
|
|
10
10
|
// Utility type to get only the required fields of a type
|
|
11
11
|
export type RequiredKeys<T> = {
|
|
12
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? never : K
|
|
13
|
-
}[keyof T]
|
|
12
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
13
|
+
}[keyof T];
|
|
14
14
|
|
|
15
15
|
export function assert(condition: boolean, message: string) {
|
|
16
16
|
if (!condition) {
|
|
@@ -19,6 +19,5 @@ export function assert(condition: boolean, message: string) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function getTrovesEndpoint(): string {
|
|
22
|
-
return process.env.TROVES_ENDPOINT ||
|
|
22
|
+
return process.env.TROVES_ENDPOINT || "https://app.troves.fi";
|
|
23
23
|
}
|
|
24
|
-
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { SingleTokenInfo, DualTokenInfo } from "../strategies/base-strategy";
|
|
2
|
+
import { BaseStrategy } from "../strategies/base-strategy";
|
|
3
|
+
import { AmountsInfo, StrategyCapabilities, TokenInfo } from "@/interfaces";
|
|
4
|
+
import { Web3Number } from "@/dataTypes";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Convert SDK TVL info (SingleTokenInfo or DualTokenInfo) to client AmountsInfo format
|
|
8
|
+
*/
|
|
9
|
+
export function toAmountsInfo(tvlInfo: SingleTokenInfo | DualTokenInfo): Omit<
|
|
10
|
+
AmountsInfo,
|
|
11
|
+
"amounts"
|
|
12
|
+
> & {
|
|
13
|
+
amounts: Array<{
|
|
14
|
+
amount: Web3Number;
|
|
15
|
+
tokenInfo: TokenInfo;
|
|
16
|
+
}>;
|
|
17
|
+
} {
|
|
18
|
+
if ("token0" in tvlInfo) {
|
|
19
|
+
// Dual token
|
|
20
|
+
return {
|
|
21
|
+
usdValue: tvlInfo.usdValue,
|
|
22
|
+
amounts: [tvlInfo.token0, tvlInfo.token1]
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
// Single token
|
|
26
|
+
return {
|
|
27
|
+
usdValue: tvlInfo.usdValue,
|
|
28
|
+
amounts: [tvlInfo]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Detect what capabilities a strategy instance has
|
|
35
|
+
*/
|
|
36
|
+
export function detectCapabilities(
|
|
37
|
+
strategy: BaseStrategy<any, any>
|
|
38
|
+
): StrategyCapabilities {
|
|
39
|
+
return {
|
|
40
|
+
hasMatchInputAmounts:
|
|
41
|
+
typeof (strategy as any).matchInputAmounts === "function",
|
|
42
|
+
hasNetAPY: typeof (strategy as any).netAPY === "function",
|
|
43
|
+
hasGetInvestmentFlows:
|
|
44
|
+
typeof (strategy as any).getInvestmentFlows === "function",
|
|
45
|
+
hasGetPendingRewards: typeof strategy.getPendingRewards === "function",
|
|
46
|
+
hasHarvest: typeof (strategy as any).harvest === "function",
|
|
47
|
+
hasRebalance: typeof (strategy as any).getRebalanceCall === "function"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Check if a strategy is a dual-token strategy
|
|
53
|
+
*/
|
|
54
|
+
export function isDualTokenStrategy(strategy: BaseStrategy<any, any>): boolean {
|
|
55
|
+
// Check if strategy has matchInputAmounts (dual token strategies have this)
|
|
56
|
+
return typeof (strategy as any).matchInputAmounts === "function";
|
|
57
|
+
}
|