@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.
Files changed (64) hide show
  1. package/dist/index.browser.global.js +111371 -93151
  2. package/dist/index.browser.mjs +27815 -32690
  3. package/dist/index.d.ts +1095 -2011
  4. package/dist/index.js +27425 -32309
  5. package/dist/index.mjs +27590 -32452
  6. package/package.json +6 -5
  7. package/src/data/ekubo-price-fethcer.abi.json +265 -0
  8. package/src/data/universal-vault.abi.json +20 -135
  9. package/src/dataTypes/address.ts +0 -7
  10. package/src/dataTypes/index.ts +3 -2
  11. package/src/dataTypes/mynumber.ts +141 -0
  12. package/src/global.ts +296 -288
  13. package/src/index.browser.ts +6 -5
  14. package/src/interfaces/common.tsx +324 -184
  15. package/src/modules/apollo-client-config.ts +28 -0
  16. package/src/modules/avnu.ts +4 -17
  17. package/src/modules/ekubo-pricer.ts +79 -0
  18. package/src/modules/ekubo-quoter.ts +11 -88
  19. package/src/modules/erc20.ts +21 -67
  20. package/src/modules/harvests.ts +26 -15
  21. package/src/modules/index.ts +11 -13
  22. package/src/modules/lst-apr.ts +0 -36
  23. package/src/modules/pragma.ts +23 -8
  24. package/src/modules/pricer-from-api.ts +150 -14
  25. package/src/modules/pricer.ts +2 -1
  26. package/src/modules/pricerBase.ts +2 -1
  27. package/src/node/deployer.ts +36 -1
  28. package/src/node/pricer-redis.ts +2 -1
  29. package/src/strategies/autoCompounderStrk.ts +1 -1
  30. package/src/strategies/base-strategy.ts +5 -22
  31. package/src/strategies/ekubo-cl-vault.tsx +2904 -2175
  32. package/src/strategies/factory.ts +165 -0
  33. package/src/strategies/index.ts +10 -11
  34. package/src/strategies/registry.ts +268 -0
  35. package/src/strategies/sensei.ts +416 -292
  36. package/src/strategies/universal-adapters/adapter-utils.ts +1 -5
  37. package/src/strategies/universal-adapters/baseAdapter.ts +153 -181
  38. package/src/strategies/universal-adapters/common-adapter.ts +77 -98
  39. package/src/strategies/universal-adapters/index.ts +1 -5
  40. package/src/strategies/universal-adapters/vesu-adapter.ts +218 -220
  41. package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +51 -58
  42. package/src/strategies/universal-lst-muliplier-strategy.tsx +1952 -992
  43. package/src/strategies/universal-strategy.tsx +1713 -1150
  44. package/src/strategies/vesu-rebalance.tsx +1189 -986
  45. package/src/utils/health-factor-math.ts +5 -11
  46. package/src/utils/index.ts +8 -9
  47. package/src/utils/strategy-utils.ts +57 -0
  48. package/src/data/extended-deposit.abi.json +0 -3613
  49. package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
  50. package/src/modules/ExtendedWrapperSDk/types.ts +0 -311
  51. package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -395
  52. package/src/modules/midas.ts +0 -159
  53. package/src/modules/token-market-data.ts +0 -202
  54. package/src/strategies/svk-strategy.ts +0 -247
  55. package/src/strategies/universal-adapters/adapter-optimizer.ts +0 -65
  56. package/src/strategies/universal-adapters/avnu-adapter.ts +0 -413
  57. package/src/strategies/universal-adapters/extended-adapter.ts +0 -972
  58. package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
  59. package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +0 -1306
  60. package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -34
  61. package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -77
  62. package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -49
  63. package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -370
  64. 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 = ((ca * cp) + X) * maxLTV / (X)
57
- // => X * HF = ((ca * cp) + X) * maxLTV
58
- // => X * (HF - maxLTV) = ca * cp * maxLTV
59
- // => X = ca * cp * maxLTV / (HF - maxLTV)
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
- logger.verbose(`HealthFactorMath: Max debt amount on looping denominator: ${denominator}`);
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
 
@@ -1,16 +1,16 @@
1
-
2
- export * from '@/utils/logger';
3
- export * from './oz-merkle';
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 || 'https://app.troves.fi';
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
+ }