@strkfarm/sdk 2.0.0-dev.4 → 2.0.0-dev.40

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 (77) hide show
  1. package/dist/cli.js +190 -36
  2. package/dist/cli.mjs +188 -34
  3. package/dist/index.browser.global.js +116018 -90768
  4. package/dist/index.browser.mjs +12769 -10876
  5. package/dist/index.d.ts +2222 -1947
  6. package/dist/index.js +13171 -11077
  7. package/dist/index.mjs +13076 -11004
  8. package/package.json +3 -3
  9. package/src/data/avnu.abi.json +840 -0
  10. package/src/data/ekubo-price-fethcer.abi.json +265 -0
  11. package/src/data/redeem-request-nft.abi.json +752 -0
  12. package/src/data/universal-vault.abi.json +8 -7
  13. package/src/dataTypes/_bignumber.ts +13 -4
  14. package/src/dataTypes/bignumber.browser.ts +10 -1
  15. package/src/dataTypes/bignumber.node.ts +10 -1
  16. package/src/dataTypes/index.ts +3 -2
  17. package/src/dataTypes/mynumber.ts +141 -0
  18. package/src/global.ts +96 -41
  19. package/src/index.browser.ts +2 -1
  20. package/src/interfaces/common.tsx +212 -5
  21. package/src/modules/apollo-client-config.ts +28 -0
  22. package/src/modules/avnu.ts +21 -12
  23. package/src/modules/ekubo-pricer.ts +79 -0
  24. package/src/modules/ekubo-quoter.ts +48 -30
  25. package/src/modules/erc20.ts +17 -0
  26. package/src/modules/harvests.ts +43 -29
  27. package/src/modules/index.ts +1 -1
  28. package/src/modules/pragma.ts +23 -8
  29. package/src/modules/pricer-from-api.ts +156 -15
  30. package/src/modules/pricer-lst.ts +1 -1
  31. package/src/modules/pricer.ts +40 -4
  32. package/src/modules/pricerBase.ts +2 -1
  33. package/src/node/deployer.ts +36 -1
  34. package/src/node/pricer-redis.ts +2 -1
  35. package/src/strategies/base-strategy.ts +168 -16
  36. package/src/strategies/constants.ts +8 -3
  37. package/src/strategies/ekubo-cl-vault.tsx +1044 -351
  38. package/src/strategies/factory.ts +199 -0
  39. package/src/strategies/index.ts +5 -3
  40. package/src/strategies/registry.ts +262 -0
  41. package/src/strategies/sensei.ts +353 -9
  42. package/src/strategies/svk-strategy.ts +125 -30
  43. package/src/strategies/token-boosted-xstrk-carry-strategy.tsx +1225 -0
  44. package/src/strategies/types.ts +4 -0
  45. package/src/strategies/universal-adapters/adapter-utils.ts +4 -1
  46. package/src/strategies/universal-adapters/avnu-adapter.ts +196 -272
  47. package/src/strategies/universal-adapters/baseAdapter.ts +263 -251
  48. package/src/strategies/universal-adapters/common-adapter.ts +206 -203
  49. package/src/strategies/universal-adapters/index.ts +10 -8
  50. package/src/strategies/universal-adapters/svk-troves-adapter.ts +511 -0
  51. package/src/strategies/universal-adapters/token-transfer-adapter.ts +200 -0
  52. package/src/strategies/universal-adapters/vesu-adapter.ts +120 -82
  53. package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +525 -0
  54. package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +1098 -712
  55. package/src/strategies/universal-adapters/vesu-position-common.ts +258 -0
  56. package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +18 -3
  57. package/src/strategies/universal-lst-muliplier-strategy.tsx +551 -405
  58. package/src/strategies/universal-strategy.tsx +1487 -1173
  59. package/src/strategies/vesu-rebalance.tsx +252 -152
  60. package/src/strategies/yoloVault.ts +1084 -0
  61. package/src/utils/cacheClass.ts +11 -2
  62. package/src/utils/health-factor-math.ts +33 -1
  63. package/src/utils/index.ts +3 -1
  64. package/src/utils/logger.browser.ts +22 -4
  65. package/src/utils/logger.node.ts +259 -24
  66. package/src/utils/starknet-call-parser.ts +1036 -0
  67. package/src/utils/strategy-utils.ts +61 -0
  68. package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
  69. package/src/modules/ExtendedWrapperSDk/types.ts +0 -311
  70. package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -395
  71. package/src/strategies/universal-adapters/extended-adapter.ts +0 -661
  72. package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
  73. package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -34
  74. package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -77
  75. package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -49
  76. package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -372
  77. package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1140
@@ -0,0 +1,199 @@
1
+ import { IConfig, IStrategyMetadata } from "@/interfaces";
2
+ import { PricerBase } from "@/modules/pricerBase";
3
+ import {
4
+ UniversalStrategy,
5
+ UniversalStrategySettings
6
+ } from "./universal-strategy";
7
+ import { EkuboCLVault, CLVaultStrategySettings } from "./ekubo-cl-vault";
8
+ import {
9
+ UniversalLstMultiplierStrategy,
10
+ HyperLSTStrategySettings
11
+ } from "./universal-lst-muliplier-strategy";
12
+ import { YoLoVault, YoloVaultSettings } from "./yoloVault";
13
+ import { VesuRebalance, VesuRebalanceSettings } from "./vesu-rebalance";
14
+ import { SenseiVault, SenseiVaultSettings } from "./sensei";
15
+ import { BoostedxSTRKCarryStrategy, BoostedxSTRKCarryStrategySettings } from "./token-boosted-xstrk-carry-strategy";
16
+
17
+ export enum FactoryStrategyType {
18
+ UNIVERSAL = "UNIVERSAL",
19
+ EKUBO_CL = "EKUBO_CL",
20
+ HYPER_LST = "HYPER_LST",
21
+ VESU_REBALANCE = "VESU_REBALANCE",
22
+ SENSEI = "SENSEI",
23
+ YOLO_VAULT = "YOLO_VAULT",
24
+ BOOSTEDXSTRKCARRY = "BOOSTEDXSTRKCARRY"
25
+ }
26
+
27
+ export function createUniversalStrategy(
28
+ config: IConfig,
29
+ pricer: PricerBase,
30
+ metadata: IStrategyMetadata<UniversalStrategySettings>
31
+ ): UniversalStrategy<UniversalStrategySettings> {
32
+ return new UniversalStrategy(config, pricer, metadata);
33
+ }
34
+
35
+ export function createEkuboCLStrategy(
36
+ config: IConfig,
37
+ pricer: PricerBase,
38
+ metadata: IStrategyMetadata<CLVaultStrategySettings>
39
+ ): EkuboCLVault {
40
+ return new EkuboCLVault(config, pricer, metadata);
41
+ }
42
+
43
+ export function createYoloVaultStrategy(
44
+ config: IConfig,
45
+ pricer: PricerBase,
46
+ metadata: IStrategyMetadata<YoloVaultSettings>
47
+ ): YoLoVault {
48
+ return new YoLoVault(config, pricer, metadata);
49
+ }
50
+
51
+ export function createHyperLSTStrategy(
52
+ config: IConfig,
53
+ pricer: PricerBase,
54
+ metadata: IStrategyMetadata<HyperLSTStrategySettings>
55
+ ): UniversalLstMultiplierStrategy<HyperLSTStrategySettings> {
56
+ return new UniversalLstMultiplierStrategy(config, pricer, metadata);
57
+ }
58
+
59
+ export function createVesuRebalanceStrategy(
60
+ config: IConfig,
61
+ pricer: PricerBase,
62
+ metadata: IStrategyMetadata<VesuRebalanceSettings>
63
+ ): VesuRebalance {
64
+ return new VesuRebalance(config, pricer, metadata);
65
+ }
66
+
67
+ export function createSenseiStrategy(
68
+ config: IConfig,
69
+ pricer: PricerBase,
70
+ metadata: IStrategyMetadata<SenseiVaultSettings>
71
+ ): SenseiVault {
72
+ return new SenseiVault(config, pricer, metadata);
73
+ }
74
+
75
+ export function createBoostedXSTRKCarryStrategy(
76
+ config: IConfig,
77
+ pricer: PricerBase,
78
+ metadata: IStrategyMetadata<BoostedxSTRKCarryStrategySettings>
79
+ ): BoostedxSTRKCarryStrategy<BoostedxSTRKCarryStrategySettings> {
80
+ return new BoostedxSTRKCarryStrategy<BoostedxSTRKCarryStrategySettings>(config, pricer, metadata);
81
+ }
82
+
83
+ /**
84
+ * Determines the strategy type from metadata by inspecting the additionalInfo structure
85
+ */
86
+ export function getStrategyTypeFromMetadata(
87
+ metadata: IStrategyMetadata<any>
88
+ ): FactoryStrategyType {
89
+ const info = metadata.additionalInfo;
90
+
91
+ if (info && "mainToken" in info && "secondaryToken" in info && "minEpochDurationSeconds" in info && "feeBps" in info) {
92
+ return FactoryStrategyType.YOLO_VAULT;
93
+ }
94
+
95
+ // Check for HyperLST (extends UniversalStrategySettings with borrowable_assets and underlyingToken)
96
+ if (info && "borrowable_assets" in info && "underlyingToken" in info) {
97
+ return FactoryStrategyType.HYPER_LST;
98
+ }
99
+
100
+ if (info && "depositToken" in info && "debtToken" in info && "lstToken" in info) {
101
+ return FactoryStrategyType.BOOSTEDXSTRKCARRY;
102
+ }
103
+
104
+ // Check for EkuboCL (has newBounds, rebalanceConditions, quoteAsset)
105
+ if (
106
+ info &&
107
+ ("newBounds" in info || typeof info.newBounds !== "undefined") &&
108
+ "rebalanceConditions" in info &&
109
+ "quoteAsset" in info
110
+ ) {
111
+ return FactoryStrategyType.EKUBO_CL;
112
+ }
113
+
114
+ // Check for Sensei (has mainToken, secondaryToken, targetHfBps)
115
+ if (
116
+ info &&
117
+ "mainToken" in info &&
118
+ "secondaryToken" in info &&
119
+ "targetHfBps" in info
120
+ ) {
121
+ return FactoryStrategyType.SENSEI;
122
+ }
123
+
124
+ // Check for VesuRebalance (has feeBps, but simpler structure)
125
+ if (info && "feeBps" in info && Object.keys(info).length <= 2) {
126
+ return FactoryStrategyType.VESU_REBALANCE;
127
+ }
128
+
129
+ // Check for Universal (has vaultAddress, manager, vaultAllocator, etc.)
130
+ if (
131
+ info &&
132
+ "vaultAddress" in info &&
133
+ "manager" in info &&
134
+ "vaultAllocator" in info
135
+ ) {
136
+ return FactoryStrategyType.UNIVERSAL;
137
+ }
138
+
139
+ throw new Error(
140
+ `Unable to determine strategy type from metadata: ${metadata.id}`
141
+ );
142
+ }
143
+
144
+ /**
145
+ * Generic factory function that creates SDK strategy instances based on type
146
+ */
147
+ export function createStrategy(
148
+ type: FactoryStrategyType,
149
+ config: IConfig,
150
+ pricer: PricerBase,
151
+ metadata: IStrategyMetadata<any>
152
+ ) {
153
+ switch (type) {
154
+ case FactoryStrategyType.UNIVERSAL:
155
+ return createUniversalStrategy(
156
+ config,
157
+ pricer,
158
+ metadata as IStrategyMetadata<UniversalStrategySettings>
159
+ );
160
+ case FactoryStrategyType.EKUBO_CL:
161
+ return createEkuboCLStrategy(
162
+ config,
163
+ pricer,
164
+ metadata as IStrategyMetadata<CLVaultStrategySettings>
165
+ );
166
+ case FactoryStrategyType.HYPER_LST:
167
+ return createHyperLSTStrategy(
168
+ config,
169
+ pricer,
170
+ metadata as IStrategyMetadata<HyperLSTStrategySettings>
171
+ );
172
+ case FactoryStrategyType.VESU_REBALANCE:
173
+ return createVesuRebalanceStrategy(
174
+ config,
175
+ pricer,
176
+ metadata as IStrategyMetadata<VesuRebalanceSettings>
177
+ );
178
+ case FactoryStrategyType.SENSEI:
179
+ return createSenseiStrategy(
180
+ config,
181
+ pricer,
182
+ metadata as IStrategyMetadata<SenseiVaultSettings>
183
+ );
184
+ case FactoryStrategyType.YOLO_VAULT:
185
+ return createYoloVaultStrategy(
186
+ config,
187
+ pricer,
188
+ metadata as IStrategyMetadata<YoloVaultSettings>
189
+ );
190
+ case FactoryStrategyType.BOOSTEDXSTRKCARRY:
191
+ return createBoostedXSTRKCarryStrategy(
192
+ config,
193
+ pricer,
194
+ metadata as IStrategyMetadata<BoostedxSTRKCarryStrategySettings>
195
+ );
196
+ default:
197
+ throw new Error(`Unknown strategy type: ${type}`);
198
+ }
199
+ }
@@ -3,9 +3,11 @@ export * from './vesu-rebalance';
3
3
  export * from './ekubo-cl-vault';
4
4
  export * from './base-strategy';
5
5
  export * from './sensei';
6
+ export * from './yoloVault';
6
7
  export * from './universal-adapters';
7
8
  export * from './universal-strategy';
8
9
  export * from './universal-lst-muliplier-strategy';
9
- export * from './vesu-extended-strategy/vesu-extended-strategy';
10
- export * from './vesu-extended-strategy/utils/config.runtime';
11
- export * from './vesu-extended-strategy/utils/helper';
10
+ export * from './token-boosted-xstrk-carry-strategy';
11
+ export * from "./registry";
12
+ export * from "./factory";
13
+ export * from "./types";
@@ -0,0 +1,262 @@
1
+ import { getAllStrategyTags, IStrategyMetadata } from "@/interfaces";
2
+ import {
3
+ EkuboCLVaultStrategies,
4
+ CLVaultStrategySettings,
5
+ } from "./ekubo-cl-vault";
6
+ import {
7
+ HyperLSTStrategies,
8
+ HyperLSTStrategySettings,
9
+ } from "./universal-lst-muliplier-strategy";
10
+ import { UniversalStrategies } from "./universal-strategy";
11
+ import { VesuRebalanceStrategies } from "./vesu-rebalance";
12
+ import { SenseiStrategies } from "./sensei";
13
+ import { YoloVaultStrategies } from "./yoloVault";
14
+ import { BoostedxSTRKCarryStrategies } from "./token-boosted-xstrk-carry-strategy";
15
+
16
+ /**
17
+ * Filter option definition
18
+ */
19
+ export interface FilterOption {
20
+ id: string;
21
+ label: string;
22
+ icon?: string;
23
+ }
24
+
25
+ /**
26
+ * Strategy filter metadata - defines what filters are available
27
+ */
28
+ export interface StrategyFilterMetadata {
29
+ assets: FilterOption[];
30
+ protocols: FilterOption[];
31
+ quickFilters: FilterOption[];
32
+ }
33
+
34
+ /**
35
+ * Strategy type enum
36
+ */
37
+ export enum StrategyType {
38
+ EKUBO_CL = "ekubo",
39
+ UNIVERSAL = "universal",
40
+ HYPER_LST = "hyper-lst",
41
+ VESU_REBALANCE = "vesu-rebalance",
42
+ SENSEI = "sensei",
43
+ YOLO_VAULT = "yolo-vault",
44
+ BOOSTEDXSTRKCARRY = "boostedxstrkcarry",
45
+ }
46
+
47
+ /**
48
+ * Strategy metadata extracted from IStrategyMetadata
49
+ */
50
+ export interface StrategyMetadata {
51
+ id: string;
52
+ name: string;
53
+ type: StrategyType;
54
+ assets: string[]; // Token symbols (e.g., ["STRK", "USDC"])
55
+ protocols: string[]; // Protocol names (e.g., ["Ekubo"])
56
+ tags: string[];
57
+ curator?: { name: string; logo: string };
58
+ isRetired: boolean;
59
+ }
60
+
61
+ /**
62
+ * Strategy registry entry
63
+ */
64
+ export interface StrategyRegistryEntry<T = any> {
65
+ metadata: IStrategyMetadata<T>;
66
+ type: StrategyType;
67
+ }
68
+
69
+ /**
70
+ * Extract assets from strategy metadata
71
+ */
72
+ function extractAssets(metadata: IStrategyMetadata<any>): string[] {
73
+ const assets: string[] = [];
74
+ if (metadata.depositTokens) {
75
+ metadata.depositTokens.forEach((token) => {
76
+ const symbol = token.symbol?.toLowerCase() || "";
77
+ if (symbol) {
78
+ assets.push(symbol);
79
+ }
80
+ });
81
+ }
82
+ return assets;
83
+ }
84
+
85
+ /**
86
+ * Check if strategy is retired
87
+ */
88
+ function isRetired(metadata: IStrategyMetadata<any>): boolean {
89
+ // Check liveStatus if available
90
+ const liveStatus = (metadata as any).liveStatus?.toLowerCase() || "";
91
+ return liveStatus === "retired" || liveStatus === "coming soon";
92
+ }
93
+
94
+ /**
95
+ * Build strategy registry from SDK strategies
96
+ */
97
+ export function buildStrategyRegistry(): StrategyRegistryEntry[] {
98
+ const registry: StrategyRegistryEntry[] = [];
99
+
100
+ // Register Ekubo CL Vault strategies
101
+ if (EkuboCLVaultStrategies && Array.isArray(EkuboCLVaultStrategies)) {
102
+ EkuboCLVaultStrategies.forEach((metadata) => {
103
+ registry.push({
104
+ metadata,
105
+ type: StrategyType.EKUBO_CL,
106
+ });
107
+ });
108
+ }
109
+
110
+ // Register Universal strategies
111
+ if (UniversalStrategies && Array.isArray(UniversalStrategies)) {
112
+ UniversalStrategies.forEach((metadata) => {
113
+ registry.push({
114
+ metadata,
115
+ type: StrategyType.UNIVERSAL,
116
+ });
117
+ });
118
+ }
119
+
120
+ // Register Hyper LST strategies
121
+ if (HyperLSTStrategies && Array.isArray(HyperLSTStrategies)) {
122
+ HyperLSTStrategies.forEach((metadata) => {
123
+ registry.push({
124
+ metadata,
125
+ type: StrategyType.HYPER_LST,
126
+ });
127
+ });
128
+ }
129
+
130
+ // Register Vesu Rebalance strategies
131
+ if (VesuRebalanceStrategies && Array.isArray(VesuRebalanceStrategies)) {
132
+ VesuRebalanceStrategies.forEach((metadata) => {
133
+ registry.push({
134
+ metadata: metadata as any, // Type cast for compatibility
135
+ type: StrategyType.VESU_REBALANCE,
136
+ });
137
+ });
138
+ }
139
+
140
+ // Register Sensei strategies
141
+ if (SenseiStrategies && Array.isArray(SenseiStrategies)) {
142
+ SenseiStrategies.forEach((metadata) => {
143
+ registry.push({
144
+ metadata: metadata as any,
145
+ type: StrategyType.SENSEI,
146
+ });
147
+ });
148
+ }
149
+
150
+ // Register Yolo Vault strategies
151
+ if (YoloVaultStrategies && Array.isArray(YoloVaultStrategies)) {
152
+ YoloVaultStrategies.forEach((metadata) => {
153
+ registry.push({
154
+ metadata: metadata as any,
155
+ type: StrategyType.YOLO_VAULT,
156
+ });
157
+ });
158
+ }
159
+
160
+ if (BoostedxSTRKCarryStrategies && Array.isArray(BoostedxSTRKCarryStrategies)) {
161
+ BoostedxSTRKCarryStrategies.forEach((metadata) => {
162
+ registry.push({
163
+ metadata: metadata as any,
164
+ type: StrategyType.BOOSTEDXSTRKCARRY,
165
+ });
166
+ });
167
+ }
168
+
169
+ return registry;
170
+ }
171
+
172
+ /**
173
+ * Get all strategy metadata from registry
174
+ */
175
+ export function getAllStrategyMetadata(): StrategyMetadata[] {
176
+ const registry = buildStrategyRegistry();
177
+ return registry.map((entry) => {
178
+ const metadataAny = entry.metadata as any;
179
+ return {
180
+ id: metadataAny.id || entry.metadata.name || "unknown",
181
+ name: entry.metadata.name || "Unknown Strategy",
182
+ type: entry.type,
183
+ assets: extractAssets(entry.metadata),
184
+ protocols: entry.metadata.protocols.map(p => p.name.toLowerCase()),
185
+ tags: entry.metadata.tags || [],
186
+ curator: entry.metadata.curator,
187
+ isRetired: isRetired(entry.metadata),
188
+ };
189
+ });
190
+ }
191
+
192
+ /**
193
+ * Get filter metadata - defines available filters and their options
194
+ */
195
+ export function getFilterMetadata(): StrategyFilterMetadata {
196
+ const allMetadata = getAllStrategyMetadata();
197
+
198
+ // Extract unique assets
199
+ const assetSet = new Set<string>();
200
+ allMetadata.forEach((meta) => {
201
+ meta.assets.forEach((asset) => assetSet.add(asset));
202
+ });
203
+
204
+ const allowedAssets = new Set(["eth", "btc", "strk", "usdt", "usdc"]);
205
+ const assets: FilterOption[] = Array.from(assetSet)
206
+ .filter((asset) => allowedAssets.has(asset.toLowerCase()))
207
+ .sort((a, b) => {
208
+ // Sort in specific order: ETH, BTC, STRK, USDT, USDC
209
+ const order = ["eth", "btc", "strk", "usdt", "usdc"];
210
+ const aIndex = order.indexOf(a.toLowerCase());
211
+ const bIndex = order.indexOf(b.toLowerCase());
212
+ if (aIndex === -1 && bIndex === -1) return 0;
213
+ if (aIndex === -1) return 1;
214
+ if (bIndex === -1) return -1;
215
+ return aIndex - bIndex;
216
+ })
217
+ .map((id) => ({
218
+ id,
219
+ label: id.toUpperCase()
220
+ }));
221
+
222
+ // Extract unique protocols
223
+ const protocolSet = new Set<string>();
224
+ allMetadata.forEach((meta) => {
225
+ meta.protocols.forEach((protocol) => protocolSet.add(protocol));
226
+ });
227
+ const protocols: FilterOption[] = Array.from(protocolSet)
228
+ .sort()
229
+ .map((id) => ({
230
+ id,
231
+ label: id.charAt(0).toUpperCase() + id.slice(1)
232
+ }));
233
+
234
+ const quickFilters: FilterOption[] = [
235
+ { id: "all", label: "All Strategies" },
236
+ ...getAllStrategyTags().map((tag) => ({ id: tag.toLowerCase().replaceAll(" ", "-"), label: tag })),
237
+ ];
238
+
239
+ return {
240
+ assets,
241
+ protocols,
242
+ quickFilters
243
+ };
244
+ }
245
+
246
+ /**
247
+ * Get live strategies (filter out retired)
248
+ */
249
+ export function getLiveStrategies(): StrategyRegistryEntry[] {
250
+ const registry = buildStrategyRegistry();
251
+ return registry.filter((entry) => !isRetired(entry.metadata));
252
+ }
253
+
254
+ /**
255
+ * Get strategies by type
256
+ */
257
+ export function getStrategiesByType(
258
+ type: StrategyType,
259
+ ): StrategyRegistryEntry[] {
260
+ const registry = buildStrategyRegistry();
261
+ return registry.filter((entry) => entry.type === type);
262
+ }