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

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 (78) hide show
  1. package/dist/cli.js +190 -36
  2. package/dist/cli.mjs +188 -34
  3. package/dist/index.browser.global.js +116250 -90801
  4. package/dist/index.browser.mjs +13050 -10957
  5. package/dist/index.d.ts +2232 -1933
  6. package/dist/index.js +13380 -11084
  7. package/dist/index.mjs +13280 -11007
  8. package/package.json +6 -7
  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 +93 -36
  19. package/src/index.browser.ts +2 -1
  20. package/src/interfaces/common.tsx +218 -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 +2 -1
  28. package/src/modules/pragma.ts +23 -8
  29. package/src/modules/pricer-avnu-api.ts +114 -0
  30. package/src/modules/pricer-from-api.ts +156 -15
  31. package/src/modules/pricer-lst.ts +1 -1
  32. package/src/modules/pricer.ts +94 -40
  33. package/src/modules/pricerBase.ts +2 -1
  34. package/src/node/deployer.ts +36 -1
  35. package/src/node/pricer-redis.ts +3 -1
  36. package/src/strategies/base-strategy.ts +168 -16
  37. package/src/strategies/constants.ts +8 -3
  38. package/src/strategies/ekubo-cl-vault.tsx +1047 -351
  39. package/src/strategies/factory.ts +199 -0
  40. package/src/strategies/index.ts +5 -3
  41. package/src/strategies/registry.ts +262 -0
  42. package/src/strategies/sensei.ts +353 -9
  43. package/src/strategies/svk-strategy.ts +283 -31
  44. package/src/strategies/token-boosted-xstrk-carry-strategy.tsx +1262 -0
  45. package/src/strategies/types.ts +4 -0
  46. package/src/strategies/universal-adapters/adapter-utils.ts +4 -1
  47. package/src/strategies/universal-adapters/avnu-adapter.ts +196 -272
  48. package/src/strategies/universal-adapters/baseAdapter.ts +263 -251
  49. package/src/strategies/universal-adapters/common-adapter.ts +206 -203
  50. package/src/strategies/universal-adapters/index.ts +10 -8
  51. package/src/strategies/universal-adapters/svk-troves-adapter.ts +511 -0
  52. package/src/strategies/universal-adapters/token-transfer-adapter.ts +200 -0
  53. package/src/strategies/universal-adapters/vesu-adapter.ts +120 -82
  54. package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +525 -0
  55. package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +1098 -712
  56. package/src/strategies/universal-adapters/vesu-position-common.ts +258 -0
  57. package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +18 -3
  58. package/src/strategies/universal-lst-muliplier-strategy.tsx +631 -414
  59. package/src/strategies/universal-strategy.tsx +1331 -1173
  60. package/src/strategies/vesu-rebalance.tsx +252 -152
  61. package/src/strategies/yoloVault.ts +1087 -0
  62. package/src/utils/cacheClass.ts +11 -2
  63. package/src/utils/health-factor-math.ts +33 -1
  64. package/src/utils/index.ts +3 -1
  65. package/src/utils/logger.browser.ts +22 -4
  66. package/src/utils/logger.node.ts +259 -24
  67. package/src/utils/starknet-call-parser.ts +1036 -0
  68. package/src/utils/strategy-utils.ts +61 -0
  69. package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
  70. package/src/modules/ExtendedWrapperSDk/types.ts +0 -311
  71. package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -395
  72. package/src/strategies/universal-adapters/extended-adapter.ts +0 -661
  73. package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
  74. package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -34
  75. package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -77
  76. package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -49
  77. package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -372
  78. package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1140
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import BigNumber from 'bignumber.js';
2
1
  import * as starknet from 'starknet';
3
- import { RpcProvider, BlockIdentifier, Contract, Call, Account, CairoCustomEnum, Uint256, RawArgs } from 'starknet';
2
+ import { Uint256, RpcProvider, BlockIdentifier, Call, Contract, Account, CairoCustomEnum, RawArgs } from 'starknet';
3
+ import BigNumber from 'bignumber.js';
4
4
  import React, { ReactNode } from 'react';
5
+ import { Quote, AvnuOptions } from '@avnu/avnu-sdk';
5
6
  import { HexString, BytesLike } from '@ericnordelo/strk-merkle-tree/dist/bytes';
6
7
  import { MultiProof } from '@ericnordelo/strk-merkle-tree/dist/core';
7
8
  import { MerkleTreeImpl, MerkleTreeData } from '@ericnordelo/strk-merkle-tree/dist/merkletree';
8
9
  import { MerkleTreeOptions } from '@ericnordelo/strk-merkle-tree/dist/options';
9
10
  import { ValueType } from '@ericnordelo/strk-merkle-tree/dist/serde';
10
- import { Quote, AvnuOptions } from '@avnu/avnu-sdk';
11
11
  import TelegramBot from 'node-telegram-bot-api';
12
12
 
13
13
  declare class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
@@ -27,14 +27,18 @@ declare class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
27
27
  minimum(value: string | number | T): T;
28
28
  maximum(value: string | number | T): T;
29
29
  abs(): T;
30
+ toFixedRoundDown(dp?: number): string;
30
31
  toI129(): {
31
32
  mag: bigint;
32
33
  sign: 0 | 1;
33
34
  };
35
+ toUint256(): starknet.Uint256;
34
36
  }
35
37
 
36
38
  declare class Web3Number extends _Web3Number<Web3Number> {
37
39
  static fromWei(weiNumber: string | number, decimals: number): Web3Number;
40
+ static fromNumber(number: number, decimals: number): Web3Number;
41
+ static fromUint256(uint256Value: Uint256): Web3Number;
38
42
  }
39
43
 
40
44
  /**
@@ -54,6 +58,33 @@ declare class ContractAddr {
54
58
  shortString(left?: number, right?: number): string;
55
59
  }
56
60
 
61
+ declare const customInspectSymbol: unique symbol;
62
+ declare class MyNumber {
63
+ bigNumber: BigNumber;
64
+ decimals: number;
65
+ constructor(bigNumber: string, decimals: number);
66
+ static fromEther(num: string, decimals: number): MyNumber;
67
+ static fromZero(): MyNumber;
68
+ toString(): string;
69
+ toEtherStr(): string;
70
+ toFixedStr(decimals: number): string;
71
+ toEtherToFixedDecimals(decimals: number): string;
72
+ isZero(): boolean;
73
+ /**
74
+ *
75
+ * @param amountEther in token terms without decimal e.g. 1 for 1 STRK
76
+ * @param command BigNumber compare funds. e.g. gte, gt, lt
77
+ * @returns
78
+ * @dev Add more commands as needed
79
+ */
80
+ compare(amountEther: string, command: "gte" | "gt" | "lt"): boolean;
81
+ operate(command: "div" | "plus" | "mul", value: string | number): MyNumber;
82
+ subtract(value: MyNumber): MyNumber;
83
+ static min(a: MyNumber, b: MyNumber): MyNumber;
84
+ static max(a: MyNumber, b: MyNumber): MyNumber;
85
+ [customInspectSymbol](depth: any, inspectOptions: any, inspect: any): string;
86
+ }
87
+
57
88
  declare enum RiskType {
58
89
  MARKET_RISK = "Market Risk",
59
90
  IMPERMANENT_LOSS = "Impermanent Loss Risk",
@@ -81,6 +112,7 @@ interface TokenInfo {
81
112
  displayDecimals: number;
82
113
  priceProxySymbol?: string;
83
114
  priceCheckAmount?: number;
115
+ dontPrice?: boolean;
84
116
  }
85
117
  declare enum Network {
86
118
  mainnet = "mainnet",
@@ -97,6 +129,62 @@ interface IProtocol {
97
129
  name: string;
98
130
  logo: string;
99
131
  }
132
+ interface ICurator {
133
+ name: string;
134
+ logo: string;
135
+ }
136
+ declare enum StrategyTag {
137
+ META_VAULT = "Meta Vaults",
138
+ LEVERED = "Maxx",
139
+ AUTOMATED_LP = "Ekubo",
140
+ BTC = "BTC"
141
+ }
142
+ declare enum VaultType {
143
+ LOOPING = "Looping",
144
+ META_VAULT = "Meta Vault",
145
+ DELTA_NEUTRAL = "Delta Neutral",
146
+ AUTOMATED_LP = "Automated LP",
147
+ TVA = "Troves Value Averaging"
148
+ }
149
+ declare enum AuditStatus {
150
+ AUDITED = "Audited",
151
+ NOT_AUDITED = "Not Audited"
152
+ }
153
+ declare enum SourceCodeType {
154
+ OPEN_SOURCE = "Open Source",
155
+ CLOSED_SOURCE = "Closed Source"
156
+ }
157
+ declare enum AccessControlType {
158
+ MULTISIG_ACCOUNT = "Multisig Account",
159
+ STANDARD_ACCOUNT = "Standard Account",
160
+ ROLE_BASED_ACCESS = "Role Based Access"
161
+ }
162
+ declare enum InstantWithdrawalVault {
163
+ YES = "Yes",
164
+ NO = "No"
165
+ }
166
+ interface SourceCodeInfo {
167
+ type: SourceCodeType;
168
+ contractLink: string;
169
+ }
170
+ interface AccessControlInfo {
171
+ type: AccessControlType;
172
+ addresses: ContractAddr[];
173
+ timeLock?: string;
174
+ }
175
+ interface SecurityMetadata {
176
+ auditStatus: AuditStatus;
177
+ sourceCode: SourceCodeInfo;
178
+ accessControl: AccessControlInfo;
179
+ }
180
+ interface RedemptionInfo {
181
+ instantWithdrawalVault: InstantWithdrawalVault;
182
+ redemptionsInfo: {
183
+ title: string;
184
+ description: string;
185
+ }[];
186
+ alerts: StrategyAlert[];
187
+ }
100
188
  declare enum FlowChartColors {
101
189
  Green = "purple",
102
190
  Blue = "#35484f",
@@ -106,26 +194,83 @@ interface FAQ {
106
194
  question: string | React.ReactNode;
107
195
  answer: string | React.ReactNode;
108
196
  }
197
+ declare enum StrategyLiveStatus {
198
+ ACTIVE = "Active",
199
+ NEW = "New",
200
+ COMING_SOON = "Coming Soon",
201
+ DEPRECATED = "Deprecated",// active but not recommended
202
+ RETIRED = "Retired",// not active anymore
203
+ HOT = "Hot & New \uD83D\uDD25"
204
+ }
205
+ interface StrategyAlert {
206
+ type: "warning" | "info";
207
+ text: string | React.ReactNode;
208
+ tab: "all" | "deposit" | "withdraw";
209
+ }
210
+ interface StrategySettings {
211
+ maxTVL?: Web3Number;
212
+ liveStatus?: StrategyLiveStatus;
213
+ isPaused?: boolean;
214
+ isInMaintenance?: boolean;
215
+ isAudited: boolean;
216
+ isInstantWithdrawal?: boolean;
217
+ hideHarvestInfo?: boolean;
218
+ is_promoted?: boolean;
219
+ isTransactionHistDisabled?: boolean;
220
+ quoteToken: TokenInfo;
221
+ hideNetEarnings?: boolean;
222
+ showWithdrawalWarningModal?: boolean;
223
+ alerts?: StrategyAlert[];
224
+ tags?: StrategyTag[];
225
+ }
226
+ interface StrategyApyHistoryUIConfig {
227
+ showApyHistory?: boolean;
228
+ noApyHistoryMessage?: string;
229
+ }
230
+ interface FeeBps {
231
+ performanceFeeBps: number;
232
+ }
109
233
  /**
110
234
  * @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
111
235
  * @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
236
+ * @property security - Security-related metadata including audit status, source code information, and access control details.
237
+ * @property redemptionInfo - Redemption information including instant withdrawal availability and expected redemption times.
112
238
  */
113
239
  interface IStrategyMetadata<T> {
240
+ id: string;
114
241
  name: string;
115
242
  description: string | React.ReactNode;
243
+ /**
244
+ * Optional UI sort priority. Higher shows earlier.
245
+ * Intended for pinning flagship parent vaults (e.g. BTC above STRK).
246
+ */
247
+ priority?: number;
248
+ /**
249
+ * Optional UI config for the variant intro popup (strategy page).
250
+ * Should be identical across strategies that share the same `parentId`.
251
+ */
252
+ variantIntro?: {
253
+ title: string;
254
+ description: string;
255
+ };
116
256
  address: ContractAddr;
117
257
  launchBlock: number;
118
258
  type: "ERC4626" | "ERC721" | "Other";
259
+ vaultType: {
260
+ type: VaultType;
261
+ description: string;
262
+ };
119
263
  depositTokens: TokenInfo[];
120
264
  protocols: IProtocol[];
121
265
  auditUrl?: string;
122
- maxTVL: Web3Number;
123
266
  risk: {
124
267
  riskFactor: RiskFactor[];
125
268
  netRisk: number;
126
269
  notARisks: RiskType[];
127
270
  };
128
271
  apyMethodology?: string;
272
+ realizedApyMethodology?: string;
273
+ feeBps?: FeeBps;
129
274
  additionalInfo: T;
130
275
  contractDetails: {
131
276
  address: ContractAddr;
@@ -140,11 +285,41 @@ interface IStrategyMetadata<T> {
140
285
  }[];
141
286
  docs?: string;
142
287
  investmentSteps: string[];
143
- curator?: {
144
- name: string;
145
- logo: string;
146
- };
288
+ curator?: ICurator;
147
289
  isPreview?: boolean;
290
+ tags?: StrategyTag[];
291
+ security: SecurityMetadata;
292
+ redemptionInfo: RedemptionInfo;
293
+ usualTimeToEarnings: null | string;
294
+ usualTimeToEarningsDescription: null | string;
295
+ discontinuationInfo?: {
296
+ date?: Date;
297
+ reason?: React.ReactNode | string;
298
+ info?: React.ReactNode | string;
299
+ };
300
+ settings?: StrategySettings;
301
+ apyHistoryUIConfig?: StrategyApyHistoryUIConfig;
302
+ actions?: Array<{
303
+ name?: string;
304
+ pool?: {
305
+ protocol?: {
306
+ name: string;
307
+ logo: string;
308
+ };
309
+ pool?: {
310
+ name: string;
311
+ logos?: string[];
312
+ };
313
+ apr?: number;
314
+ borrow?: {
315
+ apr?: number;
316
+ };
317
+ };
318
+ amount?: string | number;
319
+ isDeposit?: boolean;
320
+ }>;
321
+ parentId?: string;
322
+ parentName?: string;
148
323
  }
149
324
  interface IInvestmentFlow {
150
325
  id?: string;
@@ -157,6 +332,8 @@ interface IInvestmentFlow {
157
332
  style?: any;
158
333
  }
159
334
  declare function getMainnetConfig(rpcUrl?: string, blockIdentifier?: BlockIdentifier): IConfig;
335
+ declare const getStrategyTagDesciption: (tag: StrategyTag) => string;
336
+ declare const getAllStrategyTags: () => StrategyTag[];
160
337
  declare const getRiskExplaination: (riskType: RiskType) => "The risk of the market moving against the position." | "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them." | "The risk of losing funds due to the position being liquidated." | "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position." | "The risk of the oracle being manipulated or incorrect." | "The risk of the smart contract being vulnerable to attacks." | "The risk of technical issues e.g. backend failure." | "The risk of the counterparty defaulting e.g. bad debt on lending platforms." | "The risk of a token losing its peg to the underlying asset, leading to potential losses for holders.";
161
338
  declare const getRiskColor: (risk: RiskFactor) => "light_green_2" | "yellow" | "red";
162
339
  declare const getNoRiskTags: (risks: RiskFactor[]) => RiskType[];
@@ -172,6 +349,27 @@ interface VaultPosition {
172
349
  remarks: string;
173
350
  protocol: IProtocol;
174
351
  }
352
+ interface AmountInfo {
353
+ amount: Web3Number;
354
+ usdValue: number;
355
+ tokenInfo: TokenInfo;
356
+ }
357
+ interface AmountsInfo {
358
+ usdValue: number;
359
+ amounts: AmountInfo[];
360
+ }
361
+ /**
362
+ * Strategy capabilities interface
363
+ * Describes what optional methods a strategy instance supports
364
+ */
365
+ interface StrategyCapabilities {
366
+ hasMatchInputAmounts: boolean;
367
+ hasNetAPY: boolean;
368
+ hasGetInvestmentFlows: boolean;
369
+ hasGetPendingRewards: boolean;
370
+ hasHarvest: boolean;
371
+ hasRebalance: boolean;
372
+ }
175
373
  declare const Protocols: {
176
374
  NONE: IProtocol;
177
375
  VESU: IProtocol;
@@ -180,7 +378,9 @@ declare const Protocols: {
180
378
  EKUBO: IProtocol;
181
379
  AVNU: IProtocol;
182
380
  VAULT: IProtocol;
381
+ TROVES: IProtocol;
183
382
  };
383
+ declare const UnwrapLabsCurator: ICurator;
184
384
 
185
385
  interface ILendingMetadata {
186
386
  name: string;
@@ -234,18 +434,41 @@ declare abstract class Initializable {
234
434
  waitForInitilisation(): Promise<void>;
235
435
  }
236
436
 
437
+ /**
438
+ * Polls Avnu impulse tokens API and keeps USD prices in memory for configured tokens.
439
+ * Price timestamp is set when each poll request completes.
440
+ */
441
+ declare class PricerAvnuApi extends PricerBase {
442
+ protected prices: {
443
+ [key: string]: PriceInfo;
444
+ };
445
+ readonly refreshInterval = 15000;
446
+ readonly staleTime: number;
447
+ private pollTimer;
448
+ private loading;
449
+ constructor(config: IConfig, tokens: TokenInfo[]);
450
+ start(): void;
451
+ stop(): void;
452
+ isStale(timestamp: Date): boolean;
453
+ hasPrice(tokenSymbol: string): boolean;
454
+ getPrice(tokenSymbol: string): Promise<PriceInfo>;
455
+ protected _loadPrices(): Promise<void>;
456
+ }
457
+
237
458
  interface PriceInfo {
238
459
  price: number;
239
460
  timestamp: Date;
240
461
  }
462
+ type PriceMethod = 'AvnuApi' | 'Coinbase' | 'Coinmarketcap' | 'Ekubo' | 'Avnu';
241
463
  declare class Pricer extends PricerBase {
242
464
  protected prices: {
243
465
  [key: string]: PriceInfo;
244
466
  };
245
467
  refreshInterval: number;
246
468
  staleTime: number;
469
+ protected readonly avnuApiPricer: PricerAvnuApi;
247
470
  protected methodToUse: {
248
- [tokenSymbol: string]: 'Ekubo' | 'Coinbase' | 'Coinmarketcap';
471
+ [tokenSymbol: string]: PriceMethod;
249
472
  };
250
473
  /**
251
474
  * TOKENA and TOKENB are the two token names to get price of TokenA in terms of TokenB
@@ -258,11 +481,14 @@ declare class Pricer extends PricerBase {
258
481
  start(): void;
259
482
  isStale(timestamp: Date, tokenName: string): boolean;
260
483
  assertNotStale(timestamp: Date, tokenName: string): void;
261
- getPrice(tokenSymbol: string): Promise<PriceInfo>;
484
+ getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
262
485
  protected _loadPrices(onUpdate?: (tokenSymbol: string) => void): void;
263
- _getPrice(token: TokenInfo, defaultMethod?: string): Promise<number>;
486
+ _getPrice(token: TokenInfo): Promise<number>;
487
+ protected _tryPriceMethod(token: TokenInfo, method: PriceMethod): Promise<number>;
488
+ _getPriceAvnuApi(token: TokenInfo): Promise<number>;
264
489
  _getPriceCoinbase(token: TokenInfo): Promise<number>;
265
490
  _getPriceCoinMarketCap(token: TokenInfo): Promise<number>;
491
+ _getAvnuPrice(token: TokenInfo, amountIn?: Web3Number, retry?: number): Promise<number>;
266
492
  _getPriceEkubo(token: TokenInfo, amountIn?: Web3Number, retry?: number): Promise<number>;
267
493
  }
268
494
 
@@ -270,7 +496,7 @@ declare abstract class PricerBase {
270
496
  readonly config: IConfig;
271
497
  readonly tokens: TokenInfo[];
272
498
  constructor(config: IConfig, tokens: TokenInfo[]);
273
- getPrice(tokenSymbol: string): Promise<PriceInfo>;
499
+ getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
274
500
  }
275
501
 
276
502
  interface CacheData$1 {
@@ -280,296 +506,356 @@ interface CacheData$1 {
280
506
  }
281
507
  declare class CacheClass {
282
508
  readonly cache: Map<string, CacheData$1>;
509
+ isCacheEnabled: boolean;
283
510
  setCache(key: string, data: any, ttl?: number): void;
284
511
  getCache<T>(key: string): T | null;
285
512
  isCacheValid(key: string): boolean;
513
+ disableCache(): void;
514
+ enableCache(): void;
286
515
  }
287
516
 
288
- interface LeveledLogMethod {
289
- (message: string, ...meta: any[]): void;
290
- (message: any): void;
291
- }
292
- interface MyLogger {
293
- error: LeveledLogMethod;
294
- warn: LeveledLogMethod;
295
- info: LeveledLogMethod;
296
- verbose: LeveledLogMethod;
297
- debug: LeveledLogMethod;
517
+ interface HarvestInfo {
518
+ rewardsContract: ContractAddr;
519
+ token: ContractAddr;
520
+ startDate: Date;
521
+ endDate: Date;
522
+ claim: {
523
+ id: number;
524
+ amount: Web3Number;
525
+ claimee: ContractAddr;
526
+ };
527
+ actualReward: Web3Number;
528
+ proof: string[];
298
529
  }
299
- declare const logger: MyLogger;
300
530
 
301
- interface LeafData {
302
- id: bigint;
303
- readableId: string;
304
- data: bigint[];
531
+ interface SingleActionAmount {
532
+ tokenInfo: TokenInfo;
533
+ amount: Web3Number;
305
534
  }
306
- interface StandardMerkleTreeData<T extends any> extends MerkleTreeData<T> {
307
- format: 'standard-v1';
308
- leafEncoding: ValueType[];
535
+ interface SingleTokenInfo extends SingleActionAmount {
536
+ usdValue: number;
309
537
  }
310
- declare class StandardMerkleTree extends MerkleTreeImpl<LeafData> {
311
- protected readonly tree: HexString[];
312
- protected readonly values: StandardMerkleTreeData<LeafData>['values'];
313
- protected readonly leafEncoding: ValueType[];
314
- protected constructor(tree: HexString[], values: StandardMerkleTreeData<LeafData>['values'], leafEncoding: ValueType[]);
315
- static of(values: LeafData[], leafEncoding?: ValueType[], options?: MerkleTreeOptions): StandardMerkleTree;
316
- static verify<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], leaf: T, proof: BytesLike[]): boolean;
317
- static verifyMultiProof<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], multiproof: MultiProof<BytesLike, T>): boolean;
318
- dump(): StandardMerkleTreeData<LeafData>;
538
+ interface APYInfo {
539
+ net: number;
540
+ splits: {
541
+ apy: number;
542
+ id: string;
543
+ }[];
319
544
  }
320
-
321
- type RequiredFields<T> = {
322
- [K in keyof T]-?: T[K];
323
- };
324
- type RequiredKeys<T> = {
325
- [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
326
- }[keyof T];
327
- declare function assert(condition: boolean, message: string): void;
328
- declare function getTrovesEndpoint(): string;
329
-
330
- interface ManageCall {
331
- sanitizer: ContractAddr;
332
- call: {
333
- contractAddress: ContractAddr;
334
- selector: string;
335
- calldata: bigint[];
336
- };
545
+ interface DualActionAmount {
546
+ token0: SingleActionAmount;
547
+ token1: SingleActionAmount;
337
548
  }
338
- interface DepositParams {
339
- amount: Web3Number;
549
+ interface DualTokenInfo {
550
+ usdValue: number;
551
+ token0: SingleTokenInfo;
552
+ token1: SingleTokenInfo;
340
553
  }
341
- interface WithdrawParams {
342
- amount: Web3Number;
554
+ type StrategyInputMode = "single" | "dual";
555
+ type InputModeFromAction<T> = T extends DualActionAmount ? "dual" : "single";
556
+ interface NetAPYSplit {
557
+ apy: number;
558
+ id: string;
343
559
  }
344
- type GenerateCallFn<T> = (params: T) => Promise<ManageCall[]>;
345
- type AdapterLeafType<T> = {
346
- leaves: LeafData[];
347
- callConstructor: GenerateCallFn<T>;
348
- };
349
- type LeafAdapterFn<T> = () => AdapterLeafType<T>;
350
- declare enum APYType {
351
- BASE = "base",
352
- REWARD = "reward",
353
- LST = "lst"
560
+ interface NetAPYDetails {
561
+ net: number;
562
+ splits: NetAPYSplit[];
354
563
  }
355
- interface SupportedPosition {
356
- asset: TokenInfo;
357
- isDebt: boolean;
564
+ type UserPositionCardSubValueColor = "default" | "positive" | "negative" | "info";
565
+ interface UserPositionCard {
566
+ title: string;
567
+ value: string;
568
+ tooltip?: string;
569
+ subValue?: string;
570
+ subValueColor?: UserPositionCardSubValueColor;
358
571
  }
359
- interface BaseAdapterConfig {
360
- baseToken: TokenInfo;
361
- supportedPositions: SupportedPosition[];
362
- networkConfig: IConfig;
363
- pricer: PricerBase;
364
- vaultAllocator: ContractAddr;
365
- vaultAddress: ContractAddr;
572
+ interface UserPositionCardsInput {
573
+ user: ContractAddr;
574
+ investmentFlows?: Array<{
575
+ amount: string;
576
+ type: string;
577
+ timestamp: number;
578
+ tx_hash: string;
579
+ }>;
580
+ usualTimeToEarnings?: string | null;
581
+ usualTimeToEarningsDescription?: string | null;
366
582
  }
367
- type PositionAPY = {
368
- apy: number;
369
- type: APYType;
370
- };
371
- type PositionInfo = {
372
- tokenInfo: TokenInfo;
373
- amount: Web3Number;
374
- usdValue: number;
375
- remarks: string;
376
- apy: PositionAPY;
377
- protocol: IProtocol;
378
- };
379
- type PositionAmount = {
380
- amount: Web3Number;
381
- remarks: string;
382
- };
383
- declare abstract class BaseAdapter<DepositParams, WithdrawParams> extends CacheClass {
384
- readonly name: string;
385
- readonly config: BaseAdapterConfig;
386
- readonly protocol: IProtocol;
387
- constructor(config: BaseAdapterConfig, name: string, protocol: IProtocol);
583
+ interface CacheData {
584
+ timestamp: number;
585
+ ttl: number;
586
+ data: any;
587
+ }
588
+ declare class BaseStrategy<TVLInfo, DepositActionInfo, WithdrawActionInfo = DepositActionInfo> extends CacheClass {
589
+ readonly config: IConfig;
590
+ readonly cache: Map<string, CacheData>;
591
+ private readonly _depositInputMode;
592
+ private readonly _withdrawInputMode;
593
+ constructor(config: IConfig, inputModes?: {
594
+ depositInputMode?: InputModeFromAction<DepositActionInfo>;
595
+ withdrawInputMode?: InputModeFromAction<WithdrawActionInfo>;
596
+ });
597
+ depositInputMode(): InputModeFromAction<DepositActionInfo>;
598
+ withdrawInputMode(): InputModeFromAction<WithdrawActionInfo>;
599
+ getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<TVLInfo>;
600
+ getTVL(): Promise<TVLInfo>;
601
+ depositCall(amountInfo: DepositActionInfo, receiver: ContractAddr): Promise<Call[]>;
602
+ withdrawCall(amountInfo: WithdrawActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
603
+ getVaultPositions(): Promise<VaultPosition[]>;
604
+ netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number | string | NetAPYDetails>;
605
+ getPendingRewards(): Promise<HarvestInfo[]>;
606
+ getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
607
+ getUserPositionCards(_input: UserPositionCardsInput): Promise<UserPositionCard[]>;
608
+ getMaxTVL(): Promise<Web3Number>;
609
+ protected formatTokenAmountForCard(amount: Web3Number, tokenInfo: TokenInfo): string;
610
+ protected formatPercentForCard(value: number): string;
611
+ protected formatUSDForCard(value: number): string;
612
+ protected getSubValueColorFromSignedNumber(value: number): UserPositionCardSubValueColor;
613
+ /**
614
+ * Calculate lifetime earnings for a user based on provided data from client
615
+ * Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
616
+ *
617
+ * @param userTVL - The user's current TVL (SingleTokenInfo with amount, usdValue, tokenInfo)
618
+ * @param investmentFlows - Array of investment flow transactions from client
619
+ * @returns Object containing lifetime earnings, current value, and total deposits/withdrawals
620
+ */
621
+ getLifetimeEarnings(userTVL: SingleTokenInfo, investmentFlows: Array<{
622
+ amount: string;
623
+ type: string;
624
+ timestamp: number;
625
+ tx_hash: string;
626
+ }>): {
627
+ tokenInfo: SingleTokenInfo;
628
+ lifetimeEarnings: Web3Number;
629
+ currentValue: Web3Number;
630
+ totalDeposits: Web3Number;
631
+ totalWithdrawals: Web3Number;
632
+ };
633
+ }
634
+
635
+ /**
636
+ * TokenMarketData class that combines LST APR and Midas modules
637
+ * to provide unified APY, price, and TVL functions for tokens
638
+ */
639
+ declare class TokenMarketData {
640
+ private pricer;
641
+ private config;
642
+ constructor(pricer: PricerBase, config: IConfig);
388
643
  /**
389
- * Loop through all supported positions and return amount, usd value, remarks and apy for each
644
+ * Get APY for a token
645
+ * - If it's an LST token, returns LST APY
646
+ * - If it's a Midas token, returns Midas APY
647
+ * - Otherwise returns 0
648
+ * @param tokenInfo The token to get APY for
649
+ * @returns APY in absolute terms (not percentage)
390
650
  */
391
- getPositions(): Promise<PositionInfo[]>;
651
+ getAPY(tokenInfo: TokenInfo): Promise<number>;
392
652
  /**
393
- * Implemented by child adapters to compute APY for a given supported position
653
+ * Get price for a token using the pricer module
654
+ * @param tokenInfo The token to get price for
655
+ * @returns Price as a number
656
+ * @throws Error if price is 0 or unavailable
394
657
  */
395
- protected abstract getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
658
+ getPrice(tokenInfo: TokenInfo): Promise<number>;
396
659
  /**
397
- * Implemented by child adapters to fetch amount for a given supported position
660
+ * Get true price for a token
661
+ * - For LST tokens: Uses convert_to_assets to get true exchange rate
662
+ * - For Midas tokens: Uses Midas price API
663
+ * - For other tokens: Falls back to regular pricer
664
+ * @param tokenInfo The token to get true price for
665
+ * @returns True price as a number
666
+ * @throws Error if price is 0 or unavailable
398
667
  */
399
- protected abstract getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
668
+ getTruePrice(tokenInfo: TokenInfo): Promise<number>;
400
669
  /**
401
- * Implemented by child adapters to calculate maximum deposit positions
402
- * @param amount Optional amount in baseToken to deposit
670
+ * Get TVL for a token
671
+ * - If it's a Midas token, returns Midas TVL data
672
+ * - Otherwise returns 0
673
+ * @param tokenInfo The token to get TVL for
674
+ * @returns TVL as SingleTokenInfo or 0
403
675
  */
404
- abstract maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
676
+ getTVL(tokenInfo: TokenInfo): Promise<SingleTokenInfo>;
405
677
  /**
406
- * Implemented by child adapters to calculate maximum withdraw positions
678
+ * Check if a token is supported for APY data
679
+ * @param tokenInfo The token to check
680
+ * @returns True if the token has APY data available
407
681
  */
408
- abstract maxWithdraw(): Promise<PositionInfo>;
682
+ isAPYSupported(tokenInfo: TokenInfo): boolean;
409
683
  /**
410
- * Uses pricer to convert an amount of an asset to USD value
684
+ * Check if a token is supported for TVL data
685
+ * @param tokenInfo The token to check
686
+ * @returns True if the token has TVL data available
411
687
  */
412
- protected getUSDValue(asset: TokenInfo, amount: Web3Number): Promise<number>;
413
- protected constructSimpleLeafData(params: {
414
- id: string;
415
- target: ContractAddr;
416
- method: string;
417
- packedArguments: bigint[];
418
- }, sanitizer?: ContractAddr): LeafData;
419
- /**
420
- * Implementor must provide target/method/packedArguments/sanitizer for deposit leaf construction
421
- */
422
- protected abstract _getDepositLeaf(): {
423
- target: ContractAddr;
424
- method: string;
425
- packedArguments: bigint[];
426
- sanitizer: ContractAddr;
427
- id: string;
428
- }[];
429
- /**
430
- * Implementor must provide target/method/packedArguments/sanitizer for withdraw leaf construction
431
- */
432
- protected abstract _getWithdrawLeaf(): {
433
- target: ContractAddr;
434
- method: string;
435
- packedArguments: bigint[];
436
- sanitizer: ContractAddr;
437
- id: string;
438
- }[];
688
+ isTVLSupported(tokenInfo: TokenInfo): boolean;
689
+ }
690
+
691
+ declare class Pragma extends PricerBase {
692
+ contractAddr: string;
693
+ readonly contract: Contract;
694
+ constructor(config: IConfig, tokens: TokenInfo[]);
695
+ getPrice(tokenAddr: string, blockIdentifier?: BlockIdentifier): Promise<PriceInfo>;
696
+ }
697
+
698
+ declare class ZkLend extends ILending implements ILending {
699
+ readonly pricer: Pricer;
700
+ static readonly POOLS_URL = "https://app.zklend.com/api/pools";
701
+ private POSITION_URL;
702
+ constructor(config: IConfig, pricer: Pricer);
703
+ init(): Promise<void>;
439
704
  /**
440
- * Returns deposit leaf adapter using configured proof id
705
+ * @description Get the health factor of the user for given lending and debt tokens
706
+ * @param lending_tokens
707
+ * @param debt_tokens
708
+ * @param user
709
+ * @returns hf (e.g. returns 1.5 for 150% health factor)
441
710
  */
442
- getDepositLeaf(): AdapterLeafType<DepositParams>;
711
+ get_health_factor_tokenwise(lending_tokens: TokenInfo[], debt_tokens: TokenInfo[], user: ContractAddr): Promise<number>;
443
712
  /**
444
- * Returns withdraw leaf adapter using configured proof id
713
+ * @description Get the health factor of the user
714
+ * - Considers all tokens for collateral and debt
445
715
  */
446
- getWithdrawLeaf(): AdapterLeafType<WithdrawParams>;
716
+ get_health_factor(user: ContractAddr): Promise<number>;
717
+ getPositionsSummary(user: ContractAddr): Promise<{
718
+ collateralUSD: number;
719
+ debtUSD: number;
720
+ }>;
447
721
  /**
448
- * Implementor must provide deposit call
449
- * @param params
722
+ * @description Get the token-wise collateral and debt positions of the user
723
+ * @param user Contract address of the user
724
+ * @returns Promise<ILendingPosition[]>
450
725
  */
451
- abstract getDepositCall(params: DepositParams): Promise<ManageCall[]>;
726
+ getPositions(user: ContractAddr): Promise<ILendingPosition[]>;
727
+ }
728
+
729
+ declare class PricerFromApi extends PricerBase {
730
+ private apolloClient;
731
+ private pragma;
732
+ private ekuboPricer;
733
+ private readonly PRAGMA_SUPPORTED_TOKENS;
734
+ constructor(config: IConfig, tokens: TokenInfo[]);
735
+ getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
736
+ getPriceFromMyAPI(tokenSymbol: string): Promise<{
737
+ price: number;
738
+ timestamp: Date;
739
+ }>;
452
740
  /**
453
- * Implementor must provide withdraw call
454
- * @param params
741
+ * Fetches historical price for a token at a specific block number
742
+ * @param tokenSymbol - The token symbol to get price for
743
+ * @param blockNumber - The block number to query
744
+ * @returns PriceInfo with price at the closest block <= blockNumber
455
745
  */
456
- abstract getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
457
- getProofs<T>(isDeposit: boolean, tree: StandardMerkleTree): {
458
- proofs: string[][];
459
- callConstructor: GenerateCallFn<DepositParams> | GenerateCallFn<WithdrawParams>;
460
- };
461
- getNetAPY(): Promise<number>;
462
- abstract getHealthFactor(): Promise<number>;
746
+ getHistoricalPrice(tokenSymbol: string, blockNumber: BlockIdentifier): Promise<PriceInfo>;
463
747
  }
464
748
 
465
- interface FlashloanCallParams {
466
- amount: Web3Number;
467
- data: bigint[];
468
- }
469
- interface ApproveCallParams {
470
- amount: Web3Number;
749
+ declare class ERC20 {
750
+ readonly config: IConfig;
751
+ constructor(config: IConfig);
752
+ contract(addr: string | ContractAddr): Contract;
753
+ balanceOf(token: string | ContractAddr, address: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
754
+ allowance(token: string | ContractAddr, owner: string | ContractAddr, spender: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
755
+ transfer(token: string | ContractAddr, to: string | ContractAddr, amount: Web3Number): starknet.Call;
756
+ transferFrom(token: string | ContractAddr, from: string | ContractAddr, to: string | ContractAddr, amount: Web3Number): starknet.Call;
757
+ approve(token: string | ContractAddr, spender: string | ContractAddr, amount: Web3Number): starknet.Call;
471
758
  }
472
- interface AvnuSwapCallParams {
473
- props: SwapInfo;
759
+
760
+ interface Route {
761
+ token_from: string;
762
+ token_to: string;
763
+ exchange_address: string;
764
+ percent: number;
765
+ additional_swap_params: string[];
474
766
  }
475
- interface CommonAdapterConfig {
476
- id: string;
477
- vaultAddress: ContractAddr;
478
- vaultAllocator: ContractAddr;
479
- manager: ContractAddr;
480
- asset: ContractAddr;
767
+ interface SwapInfo {
768
+ token_from_address: string;
769
+ token_from_amount: Uint256;
770
+ token_to_address: string;
771
+ token_to_amount: Uint256;
772
+ token_to_min_amount: Uint256;
773
+ beneficiary: string;
774
+ integrator_fee_amount_bps: number;
775
+ integrator_fee_recipient: string;
776
+ routes: Route[];
481
777
  }
482
- declare class CommonAdapter {
483
- config: CommonAdapterConfig;
484
- constructor(config: CommonAdapterConfig);
485
- protected constructSimpleLeafData(params: {
486
- id: string;
487
- target: ContractAddr;
488
- method: string;
489
- packedArguments: bigint[];
490
- }, sanitizer?: ContractAddr): LeafData;
491
- getFlashloanAdapter(): Promise<AdapterLeafType<FlashloanCallParams>>;
492
- getFlashloanCall(params: FlashloanCallParams): Promise<ManageCall[]>;
493
- getBringLiquidityAdapter(id: string): () => AdapterLeafType<ApproveCallParams>;
494
- getApproveAdapter(token: ContractAddr, spender: ContractAddr, id: string): () => AdapterLeafType<ApproveCallParams>;
495
- getApproveCall(token: ContractAddr, spender: ContractAddr): (params: ApproveCallParams) => Promise<{
496
- sanitizer: ContractAddr;
497
- call: {
498
- contractAddress: ContractAddr;
499
- selector: string;
500
- calldata: bigint[];
501
- };
502
- }[]>;
503
- getBringLiquidityCall(): GenerateCallFn<ApproveCallParams>;
778
+ declare class AvnuWrapper {
779
+ getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number, excludeSources?: string[]): Promise<Quote>;
780
+ getSwapInfo(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount?: string, options?: AvnuOptions): Promise<SwapInfo>;
781
+ static buildZeroSwap(tokenToSell: ContractAddr, beneficiary: string, tokenToBuy?: ContractAddr): SwapInfo;
782
+ getSwapCallData(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, minAmount?: Web3Number): Promise<bigint[][]>;
504
783
  }
505
784
 
506
- interface HarvestInfo {
507
- rewardsContract: ContractAddr;
508
- token: ContractAddr;
509
- startDate: Date;
510
- endDate: Date;
511
- claim: {
512
- id: number;
513
- amount: Web3Number;
514
- claimee: ContractAddr;
785
+ declare class AutoCompounderSTRK {
786
+ readonly config: IConfig;
787
+ readonly addr: ContractAddr;
788
+ readonly pricer: Pricer;
789
+ private initialized;
790
+ contract: Contract | null;
791
+ readonly metadata: {
792
+ decimals: number;
793
+ underlying: {
794
+ address: ContractAddr;
795
+ name: string;
796
+ symbol: string;
797
+ };
798
+ name: string;
515
799
  };
516
- actualReward: Web3Number;
517
- proof: string[];
800
+ constructor(config: IConfig, pricer: Pricer);
801
+ init(): Promise<void>;
802
+ waitForInitilisation(): Promise<void>;
803
+ /** Returns shares of user */
804
+ balanceOf(user: ContractAddr): Promise<Web3Number>;
805
+ /** Returns underlying assets of user */
806
+ balanceOfUnderlying(user: ContractAddr): Promise<Web3Number>;
807
+ /** Returns usd value of assets */
808
+ usdBalanceOfUnderlying(user: ContractAddr): Promise<{
809
+ usd: Web3Number;
810
+ assets: Web3Number;
811
+ }>;
518
812
  }
519
813
 
520
- interface EkuboPoolKey {
521
- token0: ContractAddr;
522
- token1: ContractAddr;
523
- fee: string;
524
- tick_spacing: string;
525
- extension: string;
814
+ interface PoolProps {
815
+ pool_id: ContractAddr;
816
+ max_weight: number;
817
+ v_token: ContractAddr;
526
818
  }
527
- interface EkuboBounds {
528
- lowerTick: bigint;
529
- upperTick: bigint;
819
+ interface Change {
820
+ pool_id: ContractAddr;
821
+ changeAmt: Web3Number;
822
+ finalAmt: Web3Number;
823
+ isDeposit: boolean;
530
824
  }
531
- interface FeeHistory {
532
- date: string;
533
- tokenInfo: TokenInfo;
825
+ interface VesuRebalanceSettings {
826
+ feeBps: number;
827
+ }
828
+ interface PoolInfoFull {
829
+ pool_id: ContractAddr;
830
+ pool_name: string | undefined;
831
+ max_weight: number;
832
+ current_weight: number;
833
+ v_token: ContractAddr;
534
834
  amount: Web3Number;
835
+ usdValue: Web3Number;
836
+ APY: {
837
+ baseApy: number;
838
+ defiSpringApy: number;
839
+ netApy: number;
840
+ };
841
+ currentUtilization: number;
842
+ maxUtilization: number;
535
843
  }
536
844
  /**
537
- * Settings for the CLVaultStrategy
538
- *
539
- * @property newBounds - The new bounds for the strategy
540
- * @property newBounds.lower - relative to the current tick
541
- * @property newBounds.upper - relative to the current tick
845
+ * Represents a VesuRebalance strategy.
846
+ * This class implements an automated rebalancing strategy for Vesu pools,
847
+ * managing deposits and withdrawals while optimizing yield through STRK rewards.
542
848
  */
543
- interface CLVaultStrategySettings {
544
- newBounds: {
545
- lower: number;
546
- upper: number;
547
- } | string;
548
- lstContract?: ContractAddr;
549
- truePrice?: number;
550
- feeBps: number;
551
- rebalanceConditions: {
552
- minWaitHours: number;
553
- direction: "any" | "uponly";
554
- customShouldRebalance: (currentPoolPrice: number) => Promise<boolean>;
555
- };
556
- quoteAsset: TokenInfo;
557
- }
558
- declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
849
+ declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
559
850
  /** Contract address of the strategy */
560
851
  readonly address: ContractAddr;
561
852
  /** Pricer instance for token price calculations */
562
853
  readonly pricer: PricerBase;
563
854
  /** Metadata containing strategy information */
564
- readonly metadata: IStrategyMetadata<CLVaultStrategySettings>;
855
+ readonly metadata: IStrategyMetadata<VesuRebalanceSettings>;
565
856
  /** Contract instance for interacting with the strategy */
566
857
  readonly contract: Contract;
567
858
  readonly BASE_WEIGHT = 10000;
568
- readonly ekuboPositionsContract: Contract;
569
- readonly ekuboMathContract: Contract;
570
- readonly lstContract: Contract | null;
571
- poolKey: EkuboPoolKey | undefined;
572
- readonly avnu: AvnuWrapper;
573
859
  /**
574
860
  * Creates a new VesuRebalance strategy instance.
575
861
  * @param config - Configuration object containing provider and other settings
@@ -577,27 +863,269 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
577
863
  * @param metadata - Strategy metadata including deposit tokens and address
578
864
  * @throws {Error} If more than one deposit token is specified
579
865
  */
580
- constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>);
581
- matchInputAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
582
- /** Returns minimum amounts give given two amounts based on what can be added for liq */
583
- getMinDepositAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
584
- depositCall(amountInfo: DualActionAmount, receiver: ContractAddr): Promise<Call[]>;
585
- tokensToShares(amountInfo: DualActionAmount): Promise<Web3Number>;
586
- withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
866
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>);
867
+ /**
868
+ * Creates a deposit call to the strategy contract.
869
+ * @param assets - Amount of assets to deposit
870
+ * @param receiver - Address that will receive the strategy tokens
871
+ * @returns Populated contract call for deposit
872
+ */
873
+ depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<starknet.Call[]>;
874
+ /**
875
+ * Creates a withdrawal call to the strategy contract.
876
+ * @param assets - Amount of assets to withdraw
877
+ * @param receiver - Address that will receive the withdrawn assets
878
+ * @param owner - Address that owns the strategy tokens
879
+ * @returns Populated contract call for withdrawal
880
+ */
881
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<starknet.Call[]>;
882
+ /**
883
+ * Returns the underlying asset token of the strategy.
884
+ * @returns The deposit token supported by this strategy
885
+ */
886
+ asset(): TokenInfo;
887
+ /**
888
+ * Returns the number of decimals used by the strategy token.
889
+ * @returns Number of decimals (same as the underlying token)
890
+ */
891
+ decimals(): number;
892
+ getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<{
893
+ tokenInfo: TokenInfo;
894
+ amount: Web3Number;
895
+ usdValue: number;
896
+ }>;
897
+ /**
898
+ * Calculates user realized APY based on trueSharesBasedAPY method.
899
+ * Returns the APY as a number.
900
+ */
901
+ getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
902
+ /**
903
+ * Calculates the total TVL of the strategy.
904
+ * @returns Object containing the total amount in token units and USD value
905
+ */
906
+ getTVL(): Promise<{
907
+ tokenInfo: TokenInfo;
908
+ amount: Web3Number;
909
+ usdValue: number;
910
+ }>;
911
+ static getAllPossibleVerifiedPools(asset: ContractAddr): Promise<any>;
912
+ getPoolInfo(p: PoolProps, pools: any[], vesuPositions: any[], totalAssets: Web3Number, isErrorPositionsAPI: boolean, isErrorPoolsAPI: boolean): Promise<{
913
+ pool_id: ContractAddr;
914
+ pool_name: any;
915
+ max_weight: number;
916
+ current_weight: number;
917
+ v_token: ContractAddr;
918
+ amount: Web3Number;
919
+ usdValue: Web3Number;
920
+ APY: {
921
+ baseApy: number;
922
+ defiSpringApy: number;
923
+ netApy: number;
924
+ };
925
+ currentUtilization: number;
926
+ maxUtilization: number;
927
+ }>;
928
+ /**
929
+ * Retrieves the list of allowed pools and their detailed information from multiple sources:
930
+ * 1. Contract's allowed pools
931
+ * 2. Vesu positions API for current positions
932
+ * 3. Vesu pools API for APY and utilization data
933
+ *
934
+ * @returns {Promise<{
935
+ * data: Array<PoolInfoFull>,
936
+ * isErrorPositionsAPI: boolean
937
+ * }>} Object containing:
938
+ * - data: Array of pool information including IDs, weights, amounts, APYs and utilization
939
+ * - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
940
+ */
941
+ getPools(): Promise<{
942
+ data: {
943
+ pool_id: ContractAddr;
944
+ pool_name: any;
945
+ max_weight: number;
946
+ current_weight: number;
947
+ v_token: ContractAddr;
948
+ amount: Web3Number;
949
+ usdValue: Web3Number;
950
+ APY: {
951
+ baseApy: number;
952
+ defiSpringApy: number;
953
+ netApy: number;
954
+ };
955
+ currentUtilization: number;
956
+ maxUtilization: number;
957
+ }[];
958
+ isErrorPositionsAPI: boolean;
959
+ isErrorPoolsAPI: boolean;
960
+ isError: boolean;
961
+ }>;
962
+ getVesuPools(retry?: number): Promise<{
963
+ pools: any[];
964
+ isErrorPoolsAPI: boolean;
965
+ }>;
966
+ /**
967
+ * Calculates the weighted average APY across all pools based on USD value.
968
+ * @returns {Promise<number>} The weighted average APY across all pools
969
+ */
970
+ netAPY(): Promise<APYInfo>;
971
+ /**
972
+ * Calculates the weighted average APY across all pools based on USD value.
973
+ * @returns {Promise<number>} The weighted average APY across all pools
974
+ */
975
+ netAPYGivenPools(pools: PoolInfoFull[]): Promise<number>;
976
+ /**
977
+ * Calculates optimal position changes to maximize APY while respecting max weights.
978
+ * The algorithm:
979
+ * 1. Sorts pools by APY (highest first)
980
+ * 2. Calculates target amounts based on max weights
981
+ * 3. For each pool that needs more funds:
982
+ * - Takes funds from lowest APY pools that are over their target
983
+ * 4. Validates that total assets remain constant
984
+ *
985
+ * @returns {Promise<{
986
+ * changes: Change[],
987
+ * finalPools: PoolInfoFull[],
988
+ * isAnyPoolOverMaxWeight: boolean
989
+ * }>} Object containing:
990
+ * - changes: Array of position changes
991
+ * - finalPools: Array of pool information after rebalance
992
+ * @throws Error if rebalance is not possible while maintaining constraints
993
+ */
994
+ getRebalancedPositions(_pools?: PoolInfoFull[]): Promise<{
995
+ changes: never[];
996
+ finalPools: never[];
997
+ isAnyPoolOverMaxWeight?: undefined;
998
+ } | {
999
+ changes: Change[];
1000
+ finalPools: PoolInfoFull[];
1001
+ isAnyPoolOverMaxWeight: boolean;
1002
+ }>;
1003
+ /**
1004
+ * Creates a rebalance Call object for the strategy contract
1005
+ * @param pools - Array of pool information including IDs, weights, amounts, APYs and utilization
1006
+ * @returns Populated contract call for rebalance
1007
+ */
1008
+ getRebalanceCall(pools: Awaited<ReturnType<typeof this.getRebalancedPositions>>["changes"], isOverWeightAdjustment: boolean): Promise<starknet.Call | null>;
1009
+ getInvestmentFlows(pools: PoolInfoFull[]): Promise<IInvestmentFlow[]>;
1010
+ getPendingRewards(): Promise<HarvestInfo[]>;
1011
+ harvest(acc: Account): Promise<starknet.Call[]>;
1012
+ /**
1013
+ * Calculates the fees deducted in different vTokens based on the current and previous state.
1014
+ * @param previousTotalSupply - The total supply of the strategy token before the transaction
1015
+ * @returns {Promise<Array<{ vToken: ContractAddr, fee: Web3Number }>>} Array of fees deducted in different vTokens
1016
+ */
1017
+ getFee(allowedPools: Array<PoolInfoFull>): Promise<Array<{
1018
+ vToken: ContractAddr;
1019
+ fee: Web3Number;
1020
+ }>>;
1021
+ }
1022
+ /**
1023
+ * Represents the Vesu Rebalance Strategies.
1024
+ */
1025
+ declare const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[];
1026
+
1027
+ interface EkuboPoolKey {
1028
+ token0: ContractAddr;
1029
+ token1: ContractAddr;
1030
+ fee: string;
1031
+ tick_spacing: string;
1032
+ extension: string;
1033
+ }
1034
+ interface EkuboBounds {
1035
+ lowerTick: bigint;
1036
+ upperTick: bigint;
1037
+ }
1038
+ interface FeeHistory {
1039
+ date: string;
1040
+ tokenInfo: TokenInfo;
1041
+ amount: Web3Number;
1042
+ }
1043
+ /**
1044
+ * Settings for the CLVaultStrategy
1045
+ *
1046
+ * @property newBounds - The new bounds for the strategy
1047
+ * @property newBounds.lower - relative to the current tick
1048
+ * @property newBounds.upper - relative to the current tick
1049
+ */
1050
+ interface CLVaultStrategySettings {
1051
+ newBounds: {
1052
+ lower: number;
1053
+ upper: number;
1054
+ } | string;
1055
+ lstContract?: ContractAddr;
1056
+ truePrice?: number;
1057
+ feeBps: number;
1058
+ rebalanceConditions: {
1059
+ minWaitHours: number;
1060
+ direction: "any" | "uponly";
1061
+ customShouldRebalance: (currentPoolPrice: number) => Promise<boolean>;
1062
+ };
1063
+ quoteAsset: TokenInfo;
1064
+ }
1065
+ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
1066
+ /** Contract address of the strategy */
1067
+ readonly address: ContractAddr;
1068
+ /** Pricer instance for token price calculations */
1069
+ readonly pricer: PricerBase;
1070
+ /** Metadata containing strategy information */
1071
+ readonly metadata: IStrategyMetadata<CLVaultStrategySettings>;
1072
+ /** Contract instance for interacting with the strategy */
1073
+ readonly contract: Contract;
1074
+ readonly BASE_WEIGHT = 10000;
1075
+ readonly ekuboPositionsContract: Contract;
1076
+ readonly ekuboMathContract: Contract;
1077
+ readonly lstContract: Contract | null;
1078
+ poolKey: EkuboPoolKey | undefined;
1079
+ readonly avnu: AvnuWrapper;
1080
+ /**
1081
+ * Creates a new VesuRebalance strategy instance.
1082
+ * @param config - Configuration object containing provider and other settings
1083
+ * @param pricer - Pricer instance for token price calculations
1084
+ * @param metadata - Strategy metadata including deposit tokens and address
1085
+ * @throws {Error} If more than one deposit token is specified
1086
+ */
1087
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>);
1088
+ matchInputAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
1089
+ /** Returns minimum amounts give given two amounts based on what can be added for liq */
1090
+ getMinDepositAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
1091
+ depositCall(amountInfo: DualActionAmount, receiver: ContractAddr): Promise<Call[]>;
1092
+ tokensToShares(amountInfo: DualActionAmount): Promise<Web3Number>;
1093
+ withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
587
1094
  rebalanceCall(newBounds: EkuboBounds, swapParams: SwapInfo): Call[];
588
1095
  handleUnusedCall(swapParams: SwapInfo): Call[];
589
1096
  handleFeesCall(): Call[];
590
- getFeeHistory(timePeriod?: '24h' | '7d' | '30d' | '3m'): Promise<{
1097
+ getFeeHistory(timePeriod?: '24h' | '7d' | '30d' | '3m' | '6m', range?: {
1098
+ startTimestamp?: number;
1099
+ endTimestamp?: number;
1100
+ }): Promise<{
591
1101
  summary: DualTokenInfo;
592
1102
  history: FeeHistory[];
593
1103
  }>;
594
1104
  netSharesBasedTrueAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
1105
+ /**
1106
+ * Calculate lifetime earnings for a user
1107
+ * Not yet implemented for Ekubo CL Vault strategy
1108
+ */
1109
+ getLifetimeEarnings(userTVL: SingleTokenInfo, investmentFlows: Array<{
1110
+ amount: string;
1111
+ type: string;
1112
+ timestamp: number;
1113
+ tx_hash: string;
1114
+ }>): any;
1115
+ /**
1116
+ * Calculates realized APY based on TVL per share growth, always valued in USDC.
1117
+ * This is a vault-level metric (same for all users) and works for all strategies,
1118
+ * regardless of quote asset configuration.
1119
+ */
1120
+ getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
1121
+ getMaxTVL(): Promise<Web3Number>;
1122
+ getUserPositionCards(input: UserPositionCardsInput): Promise<UserPositionCard[]>;
595
1123
  feeBasedAPY(timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<number>;
596
1124
  /**
597
1125
  * Calculates assets before and now in a given token of TVL per share to observe growth
598
1126
  * @returns {Promise<number>} The weighted average APY across all pools
599
1127
  */
600
- netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<APYInfo>;
1128
+ netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<number>;
601
1129
  getHarvestRewardShares(fromBlock: number, toBlock: number): Promise<Web3Number>;
602
1130
  balanceOf(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<Web3Number>;
603
1131
  getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<DualTokenInfo>;
@@ -652,7 +1180,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
652
1180
  usdValue: number;
653
1181
  };
654
1182
  }>;
655
- getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null, maxIterations?: number, priceRatioPrecision?: number): Promise<SwapInfo>;
1183
+ getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null, maxIterations?: number, priceRatioPrecision?: number, getQuoteCallback?: (tokenToSell: string, tokenToBuy: string, amountWei: string, beneficiary: string) => Promise<Quote>): Promise<SwapInfo>;
656
1184
  assertValidBounds(bounds: EkuboBounds): void;
657
1185
  assertValidAmounts(expectedAmounts: any, token0Bal: Web3Number, token1Bal: Web3Number): void;
658
1186
  getSwapParams(expectedAmounts: any, poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number): {
@@ -672,7 +1200,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
672
1200
  * @returns {Promise<SwapInfo>}
673
1201
  *
674
1202
  */
675
- getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds, maxIterations?: number, priceRatioPrecision?: number): Promise<SwapInfo>;
1203
+ getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds, maxIterations?: number, priceRatioPrecision?: number, getQuoteCallback?: (tokenToSell: string, tokenToBuy: string, amountWei: string, beneficiary: string) => Promise<Quote>): Promise<SwapInfo>;
676
1204
  /**
677
1205
  * Attempts to rebalance the vault by iteratively adjusting swap amounts if initial attempt fails.
678
1206
  * Uses binary search approach to find optimal swap amount.
@@ -683,10 +1211,16 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
683
1211
  * @param retry - Current retry attempt number (default 0)
684
1212
  * @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
685
1213
  * @param isToken0Deficit - Whether token0 balance needs increasing (default true)
1214
+ * @param MAX_RETRIES - Maximum number of retries (default 40)
1215
+ * @param sameErrorCount - For certain errors, we just retry with same amount again. This is the count of such retries (default { count: 0, error: null })
1216
+ * @param MAX_SAME_ERROR_COUNT - For certain errors, we just retry with same amount again. This limits such retries (default 10)
686
1217
  * @returns Array of contract calls needed for rebalancing
687
- * @throws Error if max retries reached without successful rebalance
1218
+ * @throws Error if max retries reached without successful rebalance or max same errors reached
688
1219
  */
689
- rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint, MAX_RETRIES?: number): Promise<Call[]>;
1220
+ rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint, MAX_RETRIES?: number, sameErrorCount?: {
1221
+ count: number;
1222
+ error: null | string;
1223
+ }, MAX_SAME_ERROR_COUNT?: number): Promise<Call[]>;
690
1224
  static tickToi129(tick: number): {
691
1225
  mag: number;
692
1226
  sign: number;
@@ -705,7 +1239,8 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
705
1239
  amount0: Web3Number;
706
1240
  amount1: Web3Number;
707
1241
  }>;
708
- harvest(acc: Account, maxIterations?: number, priceRatioPrecision?: number): Promise<Call[]>;
1242
+ getPendingRewards(): Promise<HarvestInfo[]>;
1243
+ harvest(acc: Account, maxIterations?: number, priceRatioPrecision?: number, minRewardAmount?: Web3Number): Promise<Call[]>;
709
1244
  /**
710
1245
  * @description This funciton requires atleast one of the pool tokens to be reward token
711
1246
  * i.e. STRK.
@@ -754,748 +1289,719 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
754
1289
  */
755
1290
  declare const EkuboCLVaultStrategies: IStrategyMetadata<CLVaultStrategySettings>[];
756
1291
 
757
- interface VesuPoolsInfo {
758
- pools: any[];
759
- isErrorPoolsAPI: boolean;
760
- }
761
- declare enum VesuAmountType {
762
- Delta = 0,
763
- Target = 1
764
- }
765
- declare enum VesuAmountDenomination {
766
- Native = 0,
767
- Assets = 1
768
- }
769
- interface i257 {
770
- abs: Web3Number;
771
- is_negative: boolean;
772
- }
773
- interface VesuAmount {
774
- amount_type: VesuAmountType;
775
- denomination: VesuAmountDenomination;
776
- value: i257;
777
- }
778
- interface VesuModifyPositionCallParams {
779
- collateralAmount: VesuAmount;
780
- debtAmount: VesuAmount;
1292
+ interface SenseiVaultSettings {
1293
+ mainToken: TokenInfo;
1294
+ secondaryToken: TokenInfo;
1295
+ targetHfBps: number;
1296
+ feeBps: number;
781
1297
  }
782
- interface VesuDefiSpringRewardsCallParams {
783
- amount: Web3Number;
784
- proofs: string[];
785
- }
786
- interface VesuAdapterConfig {
787
- poolId: ContractAddr;
788
- collateral: TokenInfo;
789
- debt: TokenInfo;
790
- vaultAllocator: ContractAddr;
791
- id: string;
792
- }
793
- type InterestRateConfig = {
794
- target_utilization: bigint;
795
- zero_utilization_rate: bigint;
796
- target_rate_percent: bigint;
797
- min_target_utilization: bigint;
798
- max_target_utilization: bigint;
799
- rate_half_life: bigint;
800
- min_full_utilization_rate: bigint;
801
- max_full_utilization_rate: bigint;
802
- };
803
- interface TokenAmount {
804
- token: ContractAddr;
805
- amount: Web3Number;
806
- }
807
- interface Swap {
808
- route: RouteNode[];
809
- token_amount: TokenAmount;
810
- }
811
- interface RouteNode {
812
- pool_key: EkuboPoolKey;
813
- sqrt_ratio_limit: Web3Number;
814
- skip_ahead: Web3Number;
815
- }
816
- interface IncreaseLeverParams {
817
- pool_id: ContractAddr;
818
- collateral_asset: ContractAddr;
819
- debt_asset: ContractAddr;
820
- user: ContractAddr;
821
- add_margin: Web3Number;
822
- margin_swap: Swap[];
823
- margin_swap_limit_amount: Web3Number;
824
- lever_swap: Swap[];
825
- lever_swap_limit_amount: Web3Number;
826
- }
827
- interface DecreaseLeverParams {
828
- pool_id: ContractAddr;
829
- collateral_asset: ContractAddr;
830
- debt_asset: ContractAddr;
831
- user: ContractAddr;
832
- sub_margin: Web3Number;
833
- recipient: ContractAddr;
834
- lever_swap: Swap[];
835
- lever_swap_limit_amount: Web3Number;
836
- lever_swap_weights: Web3Number[];
837
- withdraw_swap: Swap[];
838
- withdraw_swap_limit_amount: Web3Number;
839
- withdraw_swap_weights: Web3Number[];
840
- close_position: boolean;
841
- }
842
- interface VesuMultiplyCallParams {
843
- increaseParams?: Omit<IncreaseLeverParams, 'user' | 'pool_id' | 'collateral_asset' | 'debt_asset'>;
844
- decreaseParams?: Omit<DecreaseLeverParams, 'user' | 'pool_id' | 'collateral_asset' | 'debt_asset' | 'recipient'>;
845
- isIncrease: boolean;
846
- }
847
- interface VesuModifyDelegationCallParams {
848
- delegation: boolean;
849
- }
850
- declare const VesuPools: {
851
- Genesis: ContractAddr;
852
- Re7xSTRK: ContractAddr;
853
- Re7xBTC: ContractAddr;
854
- Re7USDCPrime: ContractAddr;
855
- };
856
- declare const extensionMap: {
857
- [key: string]: ContractAddr;
858
- };
859
- declare function getVesuSingletonAddress(vesuPool: ContractAddr): {
860
- addr: ContractAddr;
861
- isV2: boolean;
862
- };
863
- declare class VesuAdapter extends CacheClass {
864
- VESU_MULTIPLY_V1: ContractAddr;
865
- VESU_MULTIPLY: ContractAddr;
866
- config: VesuAdapterConfig;
867
- networkConfig: IConfig | undefined;
868
- pricer: PricerBase | undefined;
869
- constructor(config: VesuAdapterConfig);
870
- getVesuModifyDelegationCall: (params: VesuModifyDelegationCallParams) => ManageCall;
871
- formatAmountTypeEnum(amountType: VesuAmountType): CairoCustomEnum;
872
- formatAmountDenominationEnum(denomination: VesuAmountDenomination): CairoCustomEnum;
873
- getVesuSingletonContract(config: IConfig, poolId: ContractAddr): {
874
- contract: Contract;
875
- isV2: boolean;
876
- };
877
- getDebtCap(config: IConfig): Promise<Web3Number>;
878
- getCurrentDebtUtilisationAmount(config: IConfig): Promise<Web3Number>;
879
- getMaxBorrowableByInterestRate(config: IConfig, asset: TokenInfo, maxBorrowAPY: number): Promise<Web3Number>;
880
- getLTVConfig(config: IConfig, blockNumber?: BlockIdentifier): Promise<number>;
881
- getPositions(config: IConfig, blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
882
- getCollateralization(config: IConfig, blockNumber?: BlockIdentifier): Promise<Omit<VaultPosition, 'amount'>[]>;
883
- getAssetPrices(): Promise<{
884
- collateralTokenAmount: Web3Number;
885
- collateralUSDAmount: number;
886
- collateralPrice: number;
887
- debtTokenAmount: Web3Number;
888
- debtUSDAmount: number;
889
- debtPrice: number;
890
- ltv: number;
1298
+ declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
1299
+ readonly address: ContractAddr;
1300
+ readonly metadata: IStrategyMetadata<SenseiVaultSettings>;
1301
+ readonly pricer: PricerBase;
1302
+ readonly contract: Contract;
1303
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>);
1304
+ getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<SingleTokenInfo>;
1305
+ getTVL(): Promise<SingleTokenInfo>;
1306
+ depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
1307
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1308
+ getPositionInfo(): Promise<{
1309
+ collateralXSTRK: Web3Number;
1310
+ collateralUSDValue: Web3Number;
1311
+ debtSTRK: Web3Number;
1312
+ debtUSDValue: Web3Number;
1313
+ xSTRKPrice: number;
1314
+ collateralInSTRK: number;
891
1315
  }>;
892
- getHealthFactor(blockNumber?: BlockIdentifier): Promise<number>;
893
- static getVesuPools(retry?: number): Promise<VesuPoolsInfo>;
894
- fullUtilizationRate(interestRateConfig: InterestRateConfig, timeDelta: bigint, utilization: bigint, fullUtilizationRate: bigint): bigint;
1316
+ getSecondaryTokenPriceRelativeToMain(retry?: number): Promise<number>;
1317
+ getSettings: () => Promise<starknet.CallResult>;
895
1318
  /**
896
- * Calculates new interest rate per second and next full utilization rate.
1319
+ * Calculate lifetime earnings for a user
1320
+ * Not yet implemented for Sensei Vault strategy
897
1321
  */
898
- calculateInterestRate(interestRateConfig: InterestRateConfig, utilization: bigint, timeDelta: bigint, lastFullUtilizationRate: bigint): {
899
- newRatePerSecond: bigint;
900
- nextFullUtilizationRate: bigint;
901
- };
1322
+ getLifetimeEarnings(userTVL: SingleTokenInfo, investmentFlows: Array<{
1323
+ amount: string;
1324
+ type: string;
1325
+ timestamp: number;
1326
+ tx_hash: string;
1327
+ }>): any;
1328
+ netAPY(): Promise<number>;
902
1329
  /**
903
- * Calculates utilization given a specific rate per second.
904
- * This is an inverse function of the piecewise interest rate formula above.
1330
+ * Calculates user realized APY based on position growth accounting for deposits and withdrawals.
1331
+ * Returns the APY as a number.
1332
+ * Not implemented for Sensei Strategy yet.
905
1333
  */
906
- getMaxUtilizationGivenRatePerSecond(interestRateConfig: InterestRateConfig, ratePerSecond: bigint, timeDelta: bigint, last_full_utilization_rate: bigint): bigint;
1334
+ getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
1335
+ getUserPositionCards(_input: UserPositionCardsInput): Promise<UserPositionCard[]>;
907
1336
  }
1337
+ declare const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[];
908
1338
 
909
- interface VesuSupplyOnlyAdapterConfig extends BaseAdapterConfig {
910
- vTokenContract: ContractAddr;
911
- }
912
- declare class VesuSupplyOnlyAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
913
- readonly config: VesuSupplyOnlyAdapterConfig;
914
- readonly tokenMarketData: TokenMarketData;
915
- constructor(config: VesuSupplyOnlyAdapterConfig);
916
- protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
917
- protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
918
- maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
919
- maxWithdraw(): Promise<PositionInfo>;
920
- protected _getDepositLeaf(): {
921
- target: ContractAddr;
922
- method: string;
923
- packedArguments: bigint[];
924
- sanitizer: ContractAddr;
925
- id: string;
926
- }[];
927
- protected _getWithdrawLeaf(): {
928
- target: ContractAddr;
929
- method: string;
930
- packedArguments: bigint[];
931
- sanitizer: ContractAddr;
932
- id: string;
933
- }[];
934
- getDepositAdapter(): AdapterLeafType<DepositParams>;
935
- getWithdrawAdapter(): AdapterLeafType<WithdrawParams>;
936
- getDepositCall(params: DepositParams): Promise<ManageCall[]>;
937
- getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
938
- getHealthFactor(): Promise<number>;
1339
+ interface YoloVaultSettings {
1340
+ startDate: string;
1341
+ expiryDate: string;
1342
+ mainToken: TokenInfo;
1343
+ secondaryToken: TokenInfo;
1344
+ totalEpochs: number;
1345
+ minEpochDurationSeconds: number;
1346
+ spendingLevels: YoloSpendingLevel[];
1347
+ feeBps: number;
1348
+ /** When true, base token is ERC-4626 (e.g. vUSDC); amounts for TVL / user info use `convert_to_assets` into `baseUnderlying`. */
1349
+ isBaseERC4626?: boolean;
1350
+ /** When true, second token is ERC-4626 (e.g. xSTRK); amounts use `convert_to_assets` into `secondUnderlying`. */
1351
+ isSecondERC4626?: boolean;
1352
+ /** Required when `isBaseERC4626` is true (e.g. USDC). */
1353
+ baseUnderlying?: TokenInfo;
1354
+ /** Required when `isSecondERC4626` is true (e.g. STRK / WBTC for xSTRK / xWBTC). */
1355
+ secondUnderlying?: TokenInfo;
1356
+ }
1357
+ interface YoloSpendingLevel {
1358
+ minPrice?: number;
1359
+ maxPrice?: number;
1360
+ spendPercent: number;
1361
+ }
1362
+ interface UserYoloInfo {
1363
+ shares: bigint;
1364
+ claimable_second_tokens: bigint;
1365
+ base_token_balance: bigint;
1366
+ base_token_consumed: bigint;
1367
+ base_consumed_last_index: bigint;
1368
+ second_token_last_index: bigint;
1369
+ second_token_balance: bigint;
1370
+ }
1371
+ interface YoloVaultStatus {
1372
+ current_epoch: bigint;
1373
+ total_epochs: bigint;
1374
+ remaining_base: bigint;
1375
+ total_second_tokens: bigint;
1376
+ global_second_token_index: bigint;
1377
+ cumulative_spend_index: bigint;
1378
+ total_shares: bigint;
1379
+ base_token_assets_per_share: bigint;
1380
+ }
1381
+ interface YoloSettings {
1382
+ base_token: bigint;
1383
+ second_token: bigint;
1384
+ total_epochs: bigint;
1385
+ min_time_per_epoch: bigint;
1386
+ max_spend_units_per_epoch: bigint;
1387
+ base_token_assets_per_share: bigint;
1388
+ oracle: bigint;
1389
+ }
1390
+ type YoloErc4626RuntimeConfig = {
1391
+ isBaseERC4626: boolean;
1392
+ isSecondERC4626: boolean;
1393
+ baseUnderlying?: TokenInfo;
1394
+ secondUnderlying?: TokenInfo;
1395
+ };
1396
+ declare class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, DualActionAmount> {
1397
+ readonly address: ContractAddr;
1398
+ readonly metadata: IStrategyMetadata<YoloVaultSettings>;
1399
+ readonly pricer: PricerBase;
1400
+ /** Resolves to a `Contract` built from `provider.getClassAt` at the vault address (no checked-in vault ABI). */
1401
+ readonly contract: Promise<Contract>;
1402
+ readonly primaryToken: TokenInfo;
1403
+ readonly secondaryToken: TokenInfo;
1404
+ readonly erc4626: YoloErc4626RuntimeConfig;
1405
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<YoloVaultSettings>);
1406
+ /** Underlying (or base token) used for pricing / swap sell leg when base is ERC-4626. */
1407
+ tokenForPrimaryPricing(): TokenInfo;
1408
+ /** Underlying (or second token) for price ratios when second leg is ERC-4626 (e.g. STRK for xSTRK). */
1409
+ tokenForSecondaryPricing(): TokenInfo;
1410
+ private primaryAmountDecimals;
1411
+ private secondaryAmountDecimals;
1412
+ private convertWrapperSharesToUnderlying;
1413
+ private getNormalizedUserInfo;
1414
+ private resolveWithdrawRequest;
1415
+ getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<DualTokenInfo>;
1416
+ getVaultPositions(): Promise<VaultPosition[]>;
1417
+ getTVL(): Promise<DualTokenInfo>;
1418
+ depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
1419
+ getVaultStatus(): Promise<YoloVaultStatus>;
1420
+ matchInputAmounts(amountInfo: DualActionAmount, user: ContractAddr): Promise<DualActionAmount>;
1421
+ withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1422
+ netAPY(): Promise<number | string | NetAPYDetails>;
1423
+ getSwapAmounts(spendUnits: Web3Number): Promise<{
1424
+ grossSpend: Web3Number;
1425
+ netSpend: Web3Number;
1426
+ isReadyForNextSwap: boolean;
1427
+ }>;
1428
+ getSettings: () => Promise<YoloSettings>;
1429
+ getMaxTVL(): Promise<Web3Number>;
1430
+ getUserPositionCards(input: UserPositionCardsInput): Promise<UserPositionCard[]>;
939
1431
  }
1432
+ declare const YoloVaultStrategies: IStrategyMetadata<YoloVaultSettings>[];
940
1433
 
941
- interface VesuMultiplyAdapterConfig extends BaseAdapterConfig {
942
- poolId: ContractAddr;
943
- collateral: TokenInfo;
944
- debt: TokenInfo;
945
- targetHealthFactor: number;
946
- minHealthFactor: number;
947
- quoteAmountToFetchPrice: Web3Number;
1434
+ interface LeveledLogMethod {
1435
+ (message: string, ...meta: any[]): void;
1436
+ (message: any): void;
948
1437
  }
949
- declare class VesuMultiplyAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
950
- readonly config: VesuMultiplyAdapterConfig;
951
- readonly vesuAdapter: VesuAdapter;
952
- readonly tokenMarketData: TokenMarketData;
953
- constructor(config: VesuMultiplyAdapterConfig);
954
- protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
955
- protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
956
- maxBorrowableAPY(): Promise<number>;
957
- maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
958
- maxWithdraw(): Promise<PositionInfo>;
959
- protected _getDepositLeaf(): {
960
- target: ContractAddr;
961
- method: string;
962
- packedArguments: bigint[];
963
- sanitizer: ContractAddr;
964
- id: string;
965
- }[];
966
- protected _getWithdrawLeaf(): {
967
- target: ContractAddr;
968
- method: string;
969
- packedArguments: bigint[];
970
- sanitizer: ContractAddr;
971
- id: string;
972
- }[];
973
- getDepositAdapter(): AdapterLeafType<DepositParams>;
974
- getWithdrawAdapter(): AdapterLeafType<WithdrawParams>;
975
- getDepositCall(params: DepositParams): Promise<ManageCall[]>;
976
- getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
977
- private getMultiplyCallCalldata;
978
- private getLeverParams;
979
- private getWithdrawalCalldata;
980
- formatMultiplyParams(isIncrease: boolean, params: IncreaseLeverParams | DecreaseLeverParams): {
981
- action: CairoCustomEnum;
982
- };
983
- getHealthFactor(): Promise<number>;
984
- getNetAPY(): Promise<number>;
1438
+ type LoggerLevel = "error" | "warn" | "info" | "verbose" | "debug";
1439
+ interface LoggerConfig {
1440
+ level?: LoggerLevel;
1441
+ consoleLevel?: LoggerLevel;
1442
+ fileLevel?: LoggerLevel;
1443
+ filePath?: string;
1444
+ enableConsole?: boolean;
1445
+ enableFile?: boolean;
1446
+ colorizeConsole?: boolean;
1447
+ shortErrorsInConsole?: boolean;
1448
+ emitConfigLog?: boolean;
1449
+ }
1450
+ interface MyLogger {
1451
+ error: LeveledLogMethod;
1452
+ warn: LeveledLogMethod;
1453
+ info: LeveledLogMethod;
1454
+ verbose: LeveledLogMethod;
1455
+ debug: LeveledLogMethod;
985
1456
  }
1457
+ declare const logger: MyLogger;
1458
+ declare function configureLogger(_config?: LoggerConfig): MyLogger;
986
1459
 
987
- /**
988
- * TypeScript type definitions for Extended Exchange API
989
- * Based on Python SDK models from x10.perpetual
990
- */
991
- declare enum OrderSide {
992
- BUY = "BUY",
993
- SELL = "SELL"
994
- }
995
- declare enum TimeInForce {
996
- GTT = "GTT",
997
- IOC = "IOC",
998
- FOK = "FOK"
999
- }
1000
- declare enum OrderType {
1001
- LIMIT = "LIMIT",
1002
- CONDITIONAL = "CONDITIONAL",
1003
- MARKET = "MARKET",
1004
- TPSL = "TPSL"
1005
- }
1006
- declare enum OrderStatus {
1007
- UNKNOWN = "UNKNOWN",
1008
- NEW = "NEW",
1009
- UNTRIGGERED = "UNTRIGGERED",
1010
- PARTIALLY_FILLED = "PARTIALLY_FILLED",
1011
- FILLED = "FILLED",
1012
- CANCELLED = "CANCELLED",
1013
- EXPIRED = "EXPIRED",
1014
- REJECTED = "REJECTED"
1015
- }
1016
- declare enum OrderStatusReason {
1017
- UNKNOWN = "UNKNOWN",
1018
- NONE = "NONE",
1019
- UNKNOWN_MARKET = "UNKNOWN_MARKET",
1020
- DISABLED_MARKET = "DISABLED_MARKET",
1021
- NOT_ENOUGH_FUNDS = "NOT_ENOUGH_FUNDS",
1022
- NO_LIQUIDITY = "NO_LIQUIDITY",
1023
- INVALID_FEE = "INVALID_FEE",
1024
- INVALID_QTY = "INVALID_QTY",
1025
- INVALID_PRICE = "INVALID_PRICE",
1026
- INVALID_VALUE = "INVALID_VALUE",
1027
- UNKNOWN_ACCOUNT = "UNKNOWN_ACCOUNT",
1028
- SELF_TRADE_PROTECTION = "SELF_TRADE_PROTECTION",
1029
- POST_ONLY_FAILED = "POST_ONLY_FAILED",
1030
- REDUCE_ONLY_FAILED = "REDUCE_ONLY_FAILED",
1031
- INVALID_EXPIRE_TIME = "INVALID_EXPIRE_TIME",
1032
- POSITION_TPSL_CONFLICT = "POSITION_TPSL_CONFLICT",
1033
- INVALID_LEVERAGE = "INVALID_LEVERAGE",
1034
- PREV_ORDER_NOT_FOUND = "PREV_ORDER_NOT_FOUND",
1035
- PREV_ORDER_TRIGGERED = "PREV_ORDER_TRIGGERED",
1036
- TPSL_OTHER_SIDE_FILLED = "TPSL_OTHER_SIDE_FILLED",
1037
- PREV_ORDER_CONFLICT = "PREV_ORDER_CONFLICT",
1038
- ORDER_REPLACED = "ORDER_REPLACED",
1039
- POST_ONLY_MODE = "POST_ONLY_MODE",
1040
- REDUCE_ONLY_MODE = "REDUCE_ONLY_MODE",
1041
- TRADING_OFF_MODE = "TRADING_OFF_MODE"
1042
- }
1043
- declare enum PositionSide {
1044
- LONG = "LONG",
1045
- SHORT = "SHORT"
1046
- }
1047
- declare enum ExitType {
1048
- TRADE = "TRADE",
1049
- LIQUIDATION = "LIQUIDATION",
1050
- ADL = "ADL"
1051
- }
1052
- declare enum AssetOperationType {
1053
- DEPOSIT = "DEPOSIT",
1054
- WITHDRAWAL = "WITHDRAWAL",
1055
- TRANSFER = "TRANSFER"
1056
- }
1057
- declare enum AssetOperationStatus {
1058
- PENDING = "PENDING",
1059
- COMPLETED = "COMPLETED",
1060
- FAILED = "FAILED"
1061
- }
1062
- interface SettlementSignature {
1063
- r: string;
1064
- s: string;
1065
- }
1066
- interface StarkSettlement {
1067
- signature: SettlementSignature;
1068
- stark_key: string;
1069
- collateral_position: string;
1070
- }
1071
- interface StarkDebuggingOrderAmounts {
1072
- collateral_amount: string;
1073
- fee_amount: string;
1074
- synthetic_amount: string;
1075
- }
1076
- interface PlacedOrder {
1077
- id: number;
1078
- external_id: string;
1079
- }
1080
- interface OpenOrder {
1081
- id: number;
1082
- account_id: number;
1083
- external_id: string;
1084
- market: string;
1085
- type: OrderType;
1086
- side: OrderSide;
1087
- status: OrderStatus;
1088
- status_reason?: OrderStatusReason;
1089
- price: string;
1090
- average_price?: string;
1091
- qty: string;
1092
- filled_qty?: string;
1093
- reduce_only: boolean;
1094
- post_only: boolean;
1095
- payed_fee?: string;
1096
- created_time: number;
1097
- updated_time: number;
1098
- expiry_time?: number;
1099
- }
1100
- interface Position {
1101
- id: number;
1102
- accountId: number;
1103
- market: string;
1104
- side: PositionSide;
1105
- leverage: string;
1106
- size: string;
1107
- value: string;
1108
- openPrice: string;
1109
- markPrice: string;
1110
- liquidationPrice?: string;
1111
- unrealisedPnl: string;
1112
- realisedPnl: string;
1113
- tpPrice?: string;
1114
- slPrice?: string;
1115
- adl?: number;
1116
- createdAt: number;
1117
- updatedAt: number;
1118
- }
1119
- interface PositionHistory {
1120
- id: number;
1121
- account_id: number;
1122
- market: string;
1123
- side: PositionSide;
1124
- leverage: string;
1125
- size: string;
1126
- open_price: string;
1127
- exit_type?: ExitType;
1128
- exit_price?: string;
1129
- realised_pnl: string;
1130
- created_time: number;
1131
- closed_time?: number;
1132
- }
1133
- interface Balance {
1134
- collateral_name: string;
1135
- balance: string;
1136
- equity: string;
1137
- availableForTrade: string;
1138
- availableForWithdrawal: string;
1139
- unrealisedPnl: string;
1140
- initialMargin: string;
1141
- marginRatio: string;
1142
- updatedTime: number;
1143
- }
1144
- interface RiskFactorConfig {
1145
- upper_bound: string;
1146
- risk_factor: string;
1147
- }
1148
- interface MarketStats {
1149
- daily_volume: string;
1150
- daily_volume_base: string;
1151
- daily_price_change: string;
1152
- daily_low: string;
1153
- daily_high: string;
1154
- last_price: string;
1155
- ask_price: string;
1156
- bid_price: string;
1157
- mark_price: string;
1158
- index_price: string;
1159
- funding_rate: string;
1160
- next_funding_rate: number;
1161
- open_interest: string;
1162
- open_interest_base: string;
1163
- }
1164
- interface TradingConfig {
1165
- min_order_size: string;
1166
- min_order_size_change: string;
1167
- min_price_change: string;
1168
- max_market_order_value: string;
1169
- max_limit_order_value: string;
1170
- max_position_value: string;
1171
- max_leverage: string;
1172
- max_num_orders: number;
1173
- limit_price_cap: string;
1174
- limit_price_floor: string;
1175
- risk_factor_config: RiskFactorConfig[];
1176
- }
1177
- interface L2Config {
1178
- type: string;
1179
- collateral_id: string;
1180
- collateral_resolution: number;
1181
- synthetic_id: string;
1182
- synthetic_resolution: number;
1183
- }
1184
- interface Market {
1185
- name: string;
1186
- asset_name: string;
1187
- asset_precision: number;
1188
- collateral_asset_name: string;
1189
- collateral_asset_precision: number;
1190
- active: boolean;
1191
- market_stats: MarketStats;
1192
- trading_config: TradingConfig;
1193
- l2_config: L2Config;
1194
- }
1195
- interface AssetOperation {
1196
- id: number;
1197
- type: AssetOperationType;
1198
- status: AssetOperationStatus;
1199
- amount: string;
1200
- asset: string;
1201
- created_time: number;
1202
- updated_time: number;
1203
- description?: string;
1204
- transactionHash?: string;
1205
- }
1206
- interface CreateOrderRequest {
1207
- market_name: string;
1208
- amount: string;
1209
- price: string;
1210
- side: OrderSide;
1211
- post_only?: boolean;
1212
- previous_order_id?: number;
1213
- external_id?: string;
1214
- time_in_force?: TimeInForce;
1215
- }
1216
- interface WithdrawRequest {
1217
- amount: string;
1218
- asset?: string;
1219
- }
1220
- interface SignedWithdrawRequest {
1221
- recipient: string;
1222
- position_id: number;
1223
- amount: number;
1224
- expiration: number;
1225
- salt: number;
1226
- }
1227
- interface CancelOrderRequest {
1228
- order_id: number;
1229
- }
1230
- interface ApiResponse<T> {
1231
- success: boolean;
1232
- message: string;
1233
- data: T;
1234
- }
1235
- interface ExtendedApiResponse<T> {
1236
- status: 'OK' | 'ERROR';
1237
- message: string;
1238
- data: T;
1239
- }
1240
- interface ExtendedWrapperConfig {
1241
- baseUrl: string;
1242
- apiKey?: string;
1243
- timeout?: number;
1244
- retries?: number;
1460
+ interface LeafData {
1461
+ id: bigint;
1462
+ readableId: string;
1463
+ data: bigint[];
1245
1464
  }
1246
- interface UpdateLeverageRequest {
1247
- leverage: string;
1248
- market: string;
1465
+ interface StandardMerkleTreeData<T extends any> extends MerkleTreeData<T> {
1466
+ format: 'standard-v1';
1467
+ leafEncoding: ValueType[];
1249
1468
  }
1250
- interface FundingRate {
1251
- m: string;
1252
- f: string;
1253
- t: number;
1469
+ declare class StandardMerkleTree extends MerkleTreeImpl<LeafData> {
1470
+ protected readonly tree: HexString[];
1471
+ protected readonly values: StandardMerkleTreeData<LeafData>['values'];
1472
+ protected readonly leafEncoding: ValueType[];
1473
+ protected constructor(tree: HexString[], values: StandardMerkleTreeData<LeafData>['values'], leafEncoding: ValueType[]);
1474
+ static of(values: LeafData[], leafEncoding?: ValueType[], options?: MerkleTreeOptions): StandardMerkleTree;
1475
+ static verify<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], leaf: T, proof: BytesLike[]): boolean;
1476
+ static verifyMultiProof<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], multiproof: MultiProof<BytesLike, T>): boolean;
1477
+ dump(): StandardMerkleTreeData<LeafData>;
1254
1478
  }
1255
1479
 
1256
1480
  /**
1257
- * ExtendedWrapper - TypeScript wrapper for Extended Exchange API
1258
- * Provides a clean interface to interact with the Extended Exchange trading API
1481
+ * Convert SDK TVL info (SingleTokenInfo or DualTokenInfo) to client AmountsInfo format
1259
1482
  */
1260
-
1261
- declare class ExtendedWrapper {
1262
- private baseUrl;
1263
- private apiKey?;
1264
- private timeout;
1265
- private retries;
1266
- constructor(config: ExtendedWrapperConfig);
1267
- /**
1268
- * Make HTTP request with retry logic and error handling
1269
- */
1270
- private makeRequest;
1271
- /**
1272
- * Create a new order on Extended Exchange
1273
- */
1274
- createOrder(request: CreateOrderRequest): Promise<ExtendedApiResponse<PlacedOrder>>;
1275
- /**
1276
- * Get all markets
1277
- */
1278
- getMarkets(marketNames?: string): Promise<ExtendedApiResponse<Market[]>>;
1279
- /**
1280
- *
1281
- * @param orderId - The ID of the order to get
1282
- * @returns The order
1283
- */
1284
- getOrderByOrderId(orderId: string): Promise<ExtendedApiResponse<OpenOrder>>;
1285
- /**
1286
- * Get market statistics for a specific market
1287
- */
1288
- getMarketStatistics(marketName: string): Promise<ExtendedApiResponse<MarketStats>>;
1289
- /**
1290
- * Get current trading positions
1291
- */
1292
- getPositions(marketNames?: string): Promise<ExtendedApiResponse<Position[]>>;
1293
- /**
1294
- * Get account balance and holdings
1295
- */
1296
- getHoldings(): Promise<ExtendedApiResponse<Balance>>;
1297
- /**
1298
- * Initiate a withdrawal from Extended Exchange
1299
- */
1300
- withdraw(request: WithdrawRequest): Promise<ExtendedApiResponse<number>>;
1301
- /**
1302
- * Create and sign a withdrawal request hash
1303
- */
1304
- signWithdrawalRequest(request: SignedWithdrawRequest): Promise<ExtendedApiResponse<{
1305
- withdraw_request_hash: string;
1306
- signature: {
1307
- r: string;
1308
- s: string;
1309
- };
1310
- }>>;
1311
- /**
1312
- * Cancel an existing order
1313
- */
1314
- cancelOrder(request: CancelOrderRequest): Promise<ExtendedApiResponse<{}>>;
1483
+ declare function toAmountsInfo(tvlInfo: SingleTokenInfo | DualTokenInfo): Omit<AmountsInfo, "amounts"> & {
1484
+ amounts: Array<{
1485
+ amount: Web3Number;
1486
+ tokenInfo: TokenInfo;
1487
+ }>;
1488
+ };
1489
+ /**
1490
+ * Detect what capabilities a strategy instance has
1491
+ */
1492
+ declare function detectCapabilities(strategy: BaseStrategy<any, any>): StrategyCapabilities;
1493
+ /**
1494
+ * Check if a strategy is a dual-token strategy
1495
+ */
1496
+ declare function isDualTokenStrategy(strategy: BaseStrategy<any, any>): boolean;
1497
+
1498
+ type ParsedStarknetCall = {
1499
+ target: string;
1500
+ method: string;
1501
+ selector?: string;
1502
+ sanitizer?: string;
1503
+ decodedArgs: unknown;
1504
+ rawCalldata: string[];
1505
+ parserUsed: string;
1506
+ parseError?: string;
1507
+ };
1508
+ type StarknetCallParserOptions = {
1509
+ tokenSymbols?: Record<string, string>;
1510
+ tokenDecimals?: Record<string, number>;
1511
+ poolNames?: Record<string, string>;
1512
+ };
1513
+ /**
1514
+ * Integration guide for new methods/protocols:
1515
+ * 1) Add method name to METHOD_BY_SELECTOR if it comes from ManageCall selector.
1516
+ * 2) Add a decoder in METHOD_DECODERS with a focused decode* method.
1517
+ * 3) Keep decoder output concise and operator-friendly.
1518
+ * 4) Prefer existing primitives (ContractAddr, uint256, Web3Number where needed).
1519
+ * 5) Add/extend tests in test/starknet-call-parser.test.ts for parse + log behavior.
1520
+ */
1521
+ declare class StarknetCallParser {
1522
+ private static readonly METHOD_DECODERS;
1523
+ private static readonly METHOD_BY_SELECTOR;
1524
+ static parseManageCall(manageCall: ManageCall, options?: StarknetCallParserOptions): ParsedStarknetCall;
1525
+ static parseManageCalls(manageCalls: ManageCall[], options?: StarknetCallParserOptions): ParsedStarknetCall[];
1526
+ static parseCall(call: Call, options?: StarknetCallParserOptions): ParsedStarknetCall;
1527
+ static parseCalls(calls: Call[], options?: StarknetCallParserOptions): ParsedStarknetCall[];
1528
+ static logManageCalls(context: string, manageCalls: ManageCall[], options?: StarknetCallParserOptions): void;
1529
+ static logCalls(context: string, calls: Call[], options?: StarknetCallParserOptions): void;
1530
+ static logCallsSummary(context: string, calls: Call[], options?: StarknetCallParserOptions, sink?: (message: string) => void): void;
1531
+ static logManageCallsSummary(context: string, manageCalls: ManageCall[], options?: StarknetCallParserOptions, sink?: (message: string) => void): void;
1532
+ static formatCallsSummary(context: string, calls: Call[], options?: StarknetCallParserOptions): string;
1533
+ static formatManageCallsSummary(context: string, manageCalls: ManageCall[], options?: StarknetCallParserOptions): string;
1534
+ static buildTokenSymbolLookup(tokens: TokenInfo[]): Record<string, string>;
1535
+ static buildPoolNameLookup(pools: {
1536
+ poolId: string | bigint;
1537
+ name: string;
1538
+ }[]): Record<string, string>;
1539
+ static buildTokenDecimalsLookup(tokens: TokenInfo[]): Record<string, number>;
1540
+ private static parseRaw;
1541
+ private static enrichDecodedArgs;
1542
+ private static toStringCalldata;
1543
+ private static toBigInt;
1544
+ private static decodeApprove;
1545
+ private static decodeBringLiquidity;
1546
+ private static decodeFlashLoan;
1547
+ private static decodeModifyDelegation;
1548
+ private static parseVesuAmount;
1549
+ private static decodeModifyPosition;
1550
+ private static decodeModifyLever;
1551
+ private static decodeMultiRouteSwap;
1552
+ private static decodeManageVaultWithMerkleVerification;
1553
+ private static toCallSummary;
1554
+ private static pickKeyFields;
1555
+ private static u256FromParts;
1556
+ private static toSelectorHex;
1557
+ private static parseSwapArray;
1558
+ private static toPoolIdKey;
1559
+ private static toAssetLabel;
1560
+ private static toHumanAmount;
1561
+ private static toHumanAmountIfDecimals;
1562
+ private static normalizeHex;
1563
+ private static toAddressHex;
1564
+ private static addressToString;
1565
+ }
1566
+
1567
+ declare class HealthFactorMath {
1568
+ static getCollateralRequired(debtAmount: Web3Number, debtPrice: number, targetHF: number, maxLTV: number, collateralPrice: number, collateralTokenInfo: TokenInfo): Web3Number;
1569
+ static getMinCollateralRequiredOnLooping(debtAmount: Web3Number, debtPrice: number, targetHF: number, maxLTV: number, collateralPrice: number, collateralTokenInfo: TokenInfo): Web3Number;
1570
+ static getHealthFactor(collateralAmount: Web3Number, collateralPrice: number, maxLTV: number, debtAmount: Web3Number, debtPrice: number): number;
1571
+ static getMaxDebtAmountOnLooping(collateralAmount: Web3Number, collateralPrice: number, maxLTV: number, targetHF: number, debtPrice: number, debtTokenInfo: TokenInfo): Web3Number;
1572
+ static getMaxDebtAmount(collateralAmount: Web3Number, collateralPrice: number, maxLTV: number, targetHF: number, debtPrice: number, debtTokenInfo: TokenInfo): Web3Number;
1573
+ static calculateDebtReductionAmountForWithdrawal: (debtAmount: Web3Number, collateralAmount: Web3Number, maxLtv: number, targetHF: number, withdrawalAmount: Web3Number, collateralPrice: number, debtPrice: number, collateralTokenInfo: TokenInfo, debtTokenInfo: TokenInfo) => {
1574
+ deltadebtAmountUnits: null;
1575
+ } | {
1576
+ deltadebtAmountUnits: Web3Number;
1577
+ };
1578
+ }
1579
+
1580
+ type RequiredFields<T> = {
1581
+ [K in keyof T]-?: T[K];
1582
+ };
1583
+ type RequiredKeys<T> = {
1584
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
1585
+ }[keyof T];
1586
+ declare function assert(condition: boolean, message: string): void;
1587
+ declare function getTrovesEndpoint(): string;
1588
+
1589
+ interface ManageCall {
1590
+ proofReadableId: string;
1591
+ sanitizer: ContractAddr;
1592
+ call: {
1593
+ contractAddress: ContractAddr;
1594
+ selector: string;
1595
+ calldata: bigint[];
1596
+ };
1597
+ }
1598
+ interface SwapPriceInfo {
1599
+ source: 'avnu' | 'ekubo';
1600
+ fromTokenSymbol: string;
1601
+ toTokenSymbol: string;
1602
+ fromAmount: number;
1603
+ toAmount: number;
1604
+ effectivePrice: number;
1605
+ }
1606
+ interface DepositParams {
1607
+ amount: Web3Number;
1608
+ }
1609
+ interface WithdrawParams {
1610
+ amount: Web3Number;
1611
+ }
1612
+ type GenerateCallFn<T> = (params: T) => Promise<ManageCall[]>;
1613
+ type AdapterLeafType<T> = {
1614
+ leaves: LeafData[];
1615
+ callConstructor: GenerateCallFn<T>;
1616
+ };
1617
+ type LeafAdapterFn<T> = () => AdapterLeafType<T>;
1618
+ declare enum APYType {
1619
+ BASE = "base",
1620
+ REWARD = "reward",
1621
+ LST = "lst"
1622
+ }
1623
+ interface SupportedPosition {
1624
+ asset: TokenInfo;
1625
+ isDebt: boolean;
1626
+ }
1627
+ interface BaseAdapterConfig {
1628
+ baseToken: TokenInfo;
1629
+ supportedPositions: SupportedPosition[];
1630
+ networkConfig: IConfig;
1631
+ pricer: PricerBase;
1632
+ vaultAllocator: ContractAddr;
1633
+ vaultAddress: ContractAddr;
1634
+ }
1635
+ type PositionAPY = {
1636
+ apy: number;
1637
+ type: APYType;
1638
+ };
1639
+ type PositionInfo = {
1640
+ tokenInfo: TokenInfo;
1641
+ amount: Web3Number;
1642
+ usdValue: number;
1643
+ remarks: string;
1644
+ apy: PositionAPY;
1645
+ protocol: IProtocol;
1646
+ };
1647
+ type PositionAmount = {
1648
+ amount: Web3Number;
1649
+ remarks: string;
1650
+ };
1651
+ declare abstract class BaseAdapter<DepositParams, WithdrawParams> extends CacheClass {
1652
+ readonly name: string;
1653
+ readonly config: BaseAdapterConfig;
1654
+ readonly protocol: IProtocol;
1655
+ constructor(config: BaseAdapterConfig, name: string, protocol: IProtocol);
1315
1656
  /**
1316
- * Get all open orders
1657
+ * Loop through all supported positions and return amount, usd value, remarks and apy for each
1317
1658
  */
1318
- getOpenOrders(marketName?: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
1659
+ getPositions(): Promise<PositionInfo[]>;
1319
1660
  /**
1320
- * Update leverage on the market
1321
- * @param request
1322
- * @returns
1661
+ * Implemented by child adapters to compute APY for a given supported position
1323
1662
  */
1324
- updateLeverage(request: UpdateLeverageRequest): Promise<ExtendedApiResponse<{}>>;
1663
+ protected abstract getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
1325
1664
  /**
1326
- * Get asset operations with optional filtering
1665
+ * Implemented by child adapters to fetch amount for a given supported position
1327
1666
  */
1328
- getAssetOperations(options?: {
1329
- id?: number;
1330
- operationsType?: AssetOperationType[];
1331
- operationsStatus?: AssetOperationStatus[];
1332
- startTime?: number;
1333
- endTime?: number;
1334
- cursor?: number;
1335
- limit?: number;
1336
- }): Promise<ExtendedApiResponse<AssetOperation[]>>;
1667
+ protected abstract getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
1337
1668
  /**
1338
- * Health check endpoint
1669
+ * Implemented by child adapters to calculate maximum deposit positions
1670
+ * @param amount Optional amount in baseToken to deposit
1339
1671
  */
1340
- healthCheck(): Promise<ExtendedApiResponse<MarketStats>>;
1672
+ abstract maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
1341
1673
  /**
1342
- * Convenience method to create a buy order
1674
+ * Implemented by child adapters to calculate maximum withdraw positions
1343
1675
  */
1344
- createBuyOrder(marketName: string, amount: string, price: string, options?: {
1345
- postOnly?: boolean;
1346
- previousOrderId?: number;
1347
- externalId?: string;
1348
- timeInForce?: TimeInForce;
1349
- }): Promise<ExtendedApiResponse<PlacedOrder>>;
1350
- /**
1351
- * Get order by ID
1352
- * @param orderId - The ID of the order to get
1353
- * @returns The order
1354
- */
1355
- getOrderById(orderId: number): Promise<ExtendedApiResponse<OpenOrder>>;
1676
+ abstract maxWithdraw(): Promise<PositionInfo>;
1356
1677
  /**
1357
- * Convenience method to create a sell order
1678
+ * Uses pricer to convert an amount of an asset to USD value
1358
1679
  */
1359
- createSellOrder(marketName: string, amount: string, price: string, options?: {
1360
- postOnly?: boolean;
1361
- previousOrderId?: number;
1362
- externalId?: string;
1363
- timeInForce?: TimeInForce;
1364
- }): Promise<ExtendedApiResponse<PlacedOrder>>;
1680
+ protected getUSDValue(asset: TokenInfo, amount: Web3Number): Promise<number>;
1681
+ protected constructSimpleLeafData(params: {
1682
+ id: string;
1683
+ target: ContractAddr;
1684
+ method: string;
1685
+ packedArguments: bigint[];
1686
+ }, sanitizer?: ContractAddr): LeafData;
1365
1687
  /**
1366
- * Get positions for a specific market
1688
+ * Implementor must provide target/method/packedArguments/sanitizer for deposit leaf construction
1367
1689
  */
1368
- getPositionsForMarket(marketName: string): Promise<ExtendedApiResponse<Position[]>>;
1690
+ protected abstract _getDepositLeaf(): {
1691
+ target: ContractAddr;
1692
+ method: string;
1693
+ packedArguments: bigint[];
1694
+ sanitizer: ContractAddr;
1695
+ id: string;
1696
+ }[];
1369
1697
  /**
1370
- * Get open orders for a specific market
1698
+ * Implementor must provide target/method/packedArguments/sanitizer for withdraw leaf construction
1371
1699
  */
1372
- getOpenOrdersForMarket(marketName: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
1700
+ protected abstract _getWithdrawLeaf(): {
1701
+ target: ContractAddr;
1702
+ method: string;
1703
+ packedArguments: bigint[];
1704
+ sanitizer: ContractAddr;
1705
+ id: string;
1706
+ }[];
1373
1707
  /**
1374
- * Cancel order by ID (convenience method)
1708
+ * Returns deposit leaf adapter using configured proof id
1375
1709
  */
1376
- cancelOrderById(orderId: number): Promise<ExtendedApiResponse<{}>>;
1710
+ getDepositLeaf(): AdapterLeafType<DepositParams>;
1377
1711
  /**
1378
- * Get order history for a specific market
1379
- * @param marketName - The name of the market to get order history for
1380
- * @returns The order history for the specified market
1712
+ * Returns withdraw leaf adapter using configured proof id
1381
1713
  */
1382
- getOrderHistory(marketName: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
1714
+ getWithdrawLeaf(): AdapterLeafType<WithdrawParams>;
1383
1715
  /**
1384
- * Withdraw USDC (convenience method)
1716
+ * Implementor must provide deposit call
1717
+ * @param params
1385
1718
  */
1386
- withdrawUSDC(amount: string): Promise<ExtendedApiResponse<number>>;
1719
+ abstract getDepositCall(params: DepositParams): Promise<ManageCall[]>;
1387
1720
  /**
1388
- * Get funding rates for a specific market
1389
- * @param marketName - The name of the market to get funding rates for
1390
- * @returns The funding rates for the specified market
1721
+ * Implementor must provide withdraw call
1722
+ * @param params
1391
1723
  */
1392
- getFundingRates(marketName: string, side: string): Promise<ExtendedApiResponse<FundingRate[]>>;
1724
+ abstract getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
1725
+ getProofs<T>(isDeposit: boolean, tree: StandardMerkleTree): {
1726
+ proofs: string[][];
1727
+ callConstructor: GenerateCallFn<DepositParams> | GenerateCallFn<WithdrawParams>;
1728
+ };
1729
+ getNetAPY(): Promise<number>;
1730
+ abstract getHealthFactor(): Promise<number>;
1393
1731
  }
1394
1732
 
1395
- interface Route {
1396
- token_from: string;
1397
- token_to: string;
1398
- exchange_address: string;
1399
- percent: number;
1400
- additional_swap_params: string[];
1733
+ interface FlashloanCallParams {
1734
+ amount: Web3Number;
1735
+ data: bigint[];
1401
1736
  }
1402
- interface SwapInfo {
1403
- token_from_address: string;
1404
- token_from_amount: Uint256;
1405
- token_to_address: string;
1406
- token_to_amount: Uint256;
1407
- token_to_min_amount: Uint256;
1408
- beneficiary: string;
1409
- integrator_fee_amount_bps: number;
1410
- integrator_fee_recipient: string;
1411
- routes: Route[];
1737
+ interface ApproveCallParams {
1738
+ amount: Web3Number;
1412
1739
  }
1413
- declare class AvnuWrapper {
1414
- getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number, excludeSources?: string[]): Promise<Quote>;
1415
- getSwapInfo(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount?: string, options?: AvnuOptions): Promise<SwapInfo>;
1416
- static buildZeroSwap(tokenToSell: ContractAddr, beneficiary: string, tokenToBuy?: ContractAddr): SwapInfo;
1417
- getSwapCallData(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string): Promise<bigint[][]>;
1740
+ interface AvnuSwapCallParams {
1741
+ props: SwapInfo;
1418
1742
  }
1419
-
1420
- interface AvnuAdapterConfig extends BaseAdapterConfig {
1421
- baseUrl: string;
1422
- avnuContract: ContractAddr;
1423
- slippage: number;
1743
+ interface CommonAdapterConfig {
1744
+ id: string;
1745
+ vaultAddress: ContractAddr;
1746
+ vaultAllocator: ContractAddr;
1747
+ manager: ContractAddr;
1748
+ asset: ContractAddr;
1424
1749
  }
1425
- declare class AvnuAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
1426
- readonly config: AvnuAdapterConfig;
1427
- protected avnuWrapper: AvnuWrapper;
1428
- constructor(config: AvnuAdapterConfig);
1429
- protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
1430
- protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
1431
- maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
1432
- maxWithdraw(): Promise<PositionInfo>;
1433
- protected _getDepositLeaf(): {
1434
- target: ContractAddr;
1435
- method: string;
1436
- packedArguments: bigint[];
1437
- sanitizer: ContractAddr;
1438
- id: string;
1439
- }[];
1440
- protected _getWithdrawLeaf(): {
1441
- target: ContractAddr;
1442
- method: string;
1443
- packedArguments: bigint[];
1444
- sanitizer: ContractAddr;
1750
+ declare class CommonAdapter {
1751
+ config: CommonAdapterConfig;
1752
+ constructor(config: CommonAdapterConfig);
1753
+ protected constructSimpleLeafData(params: {
1445
1754
  id: string;
1446
- }[];
1447
- protected _getLegacySwapLeaf(): {
1448
1755
  target: ContractAddr;
1449
1756
  method: string;
1450
1757
  packedArguments: bigint[];
1758
+ }, sanitizer?: ContractAddr): LeafData;
1759
+ getFlashloanAdapter(): Promise<AdapterLeafType<FlashloanCallParams>>;
1760
+ getFlashloanCall(params: FlashloanCallParams): Promise<ManageCall[]>;
1761
+ getBringLiquidityAdapter(id: string): () => AdapterLeafType<ApproveCallParams>;
1762
+ getApproveAdapter(token: ContractAddr, spender: ContractAddr, id: string): () => AdapterLeafType<ApproveCallParams>;
1763
+ getApproveCall(token: ContractAddr, spender: ContractAddr, proofReadableId: string): (params: ApproveCallParams) => Promise<{
1764
+ proofReadableId: string;
1451
1765
  sanitizer: ContractAddr;
1452
- id: string;
1453
- }[];
1454
- getDepositCall(params: DepositParams): Promise<ManageCall[]>;
1455
- getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
1456
- getSwapCallData(quote: Quote): Promise<bigint[][]>;
1457
- getHealthFactor(): Promise<number>;
1458
- fetchQuoteWithRetry(params: Record<string, any>, retries?: number): Promise<any>;
1459
- getQuotesAvnu(from_token_address: string, to_token_address: string, amount: number, //amount in btc units
1460
- takerAddress: string, toTokenDecimals: number, usdcToBtc: boolean, maxIterations?: number, tolerance?: number): Promise<Quote | null>;
1461
- getPriceOfToken(tokenAddress: string, retries?: number): Promise<number | null>;
1766
+ call: {
1767
+ contractAddress: ContractAddr;
1768
+ selector: string;
1769
+ calldata: bigint[];
1770
+ };
1771
+ }[]>;
1772
+ getBringLiquidityCall(proofReadableId: string): GenerateCallFn<ApproveCallParams>;
1462
1773
  }
1463
1774
 
1464
- interface ExtendedAdapterConfig extends BaseAdapterConfig {
1465
- vaultIdExtended: number;
1466
- extendedContract: ContractAddr;
1467
- extendedBackendUrl: string;
1468
- extendedApiKey: string;
1469
- extendedTimeout: number;
1470
- extendedRetries: number;
1471
- extendedBaseUrl: string;
1472
- extendedMarketName: string;
1473
- extendedPrecision: number;
1474
- avnuAdapter: AvnuAdapter;
1475
- }
1476
- declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
1477
- readonly config: ExtendedAdapterConfig;
1478
- readonly client: ExtendedWrapper;
1479
- constructor(config: ExtendedAdapterConfig);
1480
- protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
1481
- protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
1482
- maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
1483
- maxWithdraw(): Promise<PositionInfo>;
1484
- protected _getDepositLeaf(): {
1485
- target: ContractAddr;
1486
- method: string;
1487
- packedArguments: bigint[];
1488
- sanitizer: ContractAddr;
1489
- id: string;
1490
- }[];
1491
- getSwapFromLegacyLeaf(): AdapterLeafType<DepositParams>;
1492
- protected _getSwapFromLegacyLeaf(): {
1493
- target: ContractAddr;
1494
- method: string;
1495
- packedArguments: bigint[];
1496
- sanitizer: ContractAddr;
1497
- id: string;
1498
- }[];
1775
+ interface VesuPoolsInfo {
1776
+ pools: any[];
1777
+ isErrorPoolsAPI: boolean;
1778
+ }
1779
+ declare enum VesuAmountType {
1780
+ Delta = 0,
1781
+ Target = 1
1782
+ }
1783
+ declare enum VesuAmountDenomination {
1784
+ Native = 0,
1785
+ Assets = 1
1786
+ }
1787
+ interface i257 {
1788
+ abs: Web3Number;
1789
+ is_negative: boolean;
1790
+ }
1791
+ interface VesuAmount {
1792
+ amount_type: VesuAmountType;
1793
+ denomination: VesuAmountDenomination;
1794
+ value: i257;
1795
+ }
1796
+ interface VesuModifyPositionCallParams {
1797
+ collateralAmount: VesuAmount;
1798
+ debtAmount: VesuAmount;
1799
+ }
1800
+ interface VesuDefiSpringRewardsCallParams {
1801
+ amount: Web3Number;
1802
+ proofs: string[];
1803
+ }
1804
+ interface VesuAdapterConfig {
1805
+ poolId: ContractAddr;
1806
+ collateral: TokenInfo;
1807
+ debt: TokenInfo;
1808
+ vaultAllocator: ContractAddr;
1809
+ id: string;
1810
+ }
1811
+ type InterestRateConfig = {
1812
+ target_utilization: bigint;
1813
+ zero_utilization_rate: bigint;
1814
+ target_rate_percent: bigint;
1815
+ min_target_utilization: bigint;
1816
+ max_target_utilization: bigint;
1817
+ rate_half_life: bigint;
1818
+ min_full_utilization_rate: bigint;
1819
+ max_full_utilization_rate: bigint;
1820
+ };
1821
+ interface TokenAmount {
1822
+ token: ContractAddr;
1823
+ amount: Web3Number;
1824
+ }
1825
+ interface Swap {
1826
+ route: RouteNode[];
1827
+ token_amount: TokenAmount;
1828
+ }
1829
+ interface RouteNode {
1830
+ pool_key: EkuboPoolKey;
1831
+ sqrt_ratio_limit: Web3Number;
1832
+ skip_ahead: Web3Number;
1833
+ }
1834
+ interface IncreaseLeverParams {
1835
+ pool_id: ContractAddr;
1836
+ collateral_asset: ContractAddr;
1837
+ debt_asset: ContractAddr;
1838
+ user: ContractAddr;
1839
+ add_margin: Web3Number;
1840
+ margin_swap: Swap[];
1841
+ margin_swap_limit_amount: Web3Number;
1842
+ lever_swap: Swap[];
1843
+ lever_swap_limit_amount: Web3Number;
1844
+ }
1845
+ interface DecreaseLeverParams {
1846
+ pool_id: ContractAddr;
1847
+ collateral_asset: ContractAddr;
1848
+ debt_asset: ContractAddr;
1849
+ user: ContractAddr;
1850
+ sub_margin: Web3Number;
1851
+ recipient: ContractAddr;
1852
+ lever_swap: Swap[];
1853
+ lever_swap_limit_amount: Web3Number;
1854
+ lever_swap_weights: Web3Number[];
1855
+ withdraw_swap: Swap[];
1856
+ withdraw_swap_limit_amount: Web3Number;
1857
+ withdraw_swap_weights: Web3Number[];
1858
+ close_position: boolean;
1859
+ }
1860
+ interface VesuMultiplyCallParams {
1861
+ increaseParams?: Omit<IncreaseLeverParams, 'user' | 'pool_id' | 'collateral_asset' | 'debt_asset'>;
1862
+ decreaseParams?: Omit<DecreaseLeverParams, 'user' | 'pool_id' | 'collateral_asset' | 'debt_asset' | 'recipient'>;
1863
+ isIncrease: boolean;
1864
+ }
1865
+ interface VesuModifyDelegationCallParams {
1866
+ delegation: boolean;
1867
+ }
1868
+ declare const VesuPools: {
1869
+ Genesis: ContractAddr;
1870
+ Re7xSTRK: ContractAddr;
1871
+ Re7xBTC: ContractAddr;
1872
+ Re7USDCPrime: ContractAddr;
1873
+ Prime: ContractAddr;
1874
+ Re7STRK: ContractAddr;
1875
+ };
1876
+ declare const VesuPoolMetadata: {
1877
+ [VesuPools.Genesis.address]: {
1878
+ name: string;
1879
+ };
1880
+ [VesuPools.Re7xSTRK.address]: {
1881
+ name: string;
1882
+ };
1883
+ [VesuPools.Re7xBTC.address]: {
1884
+ name: string;
1885
+ };
1886
+ [VesuPools.Prime.address]: {
1887
+ name: string;
1888
+ };
1889
+ [VesuPools.Re7STRK.address]: {
1890
+ name: string;
1891
+ };
1892
+ [VesuPools.Re7USDCPrime.address]: {
1893
+ name: string;
1894
+ };
1895
+ };
1896
+ declare const extensionMap: {
1897
+ [key: string]: ContractAddr;
1898
+ };
1899
+ declare function getVesuSingletonAddress(vesuPool: ContractAddr): {
1900
+ addr: ContractAddr;
1901
+ isV2: boolean;
1902
+ };
1903
+ declare class VesuAdapter extends CacheClass {
1904
+ VESU_MULTIPLY_V1: ContractAddr;
1905
+ VESU_MULTIPLY: ContractAddr;
1906
+ VESU_WITHDRAW_SWAP_FIXED_MULTIPLIER: ContractAddr;
1907
+ config: VesuAdapterConfig;
1908
+ networkConfig: IConfig | undefined;
1909
+ pricer: PricerBase | undefined;
1910
+ constructor(config: VesuAdapterConfig);
1911
+ static getDefaultModifyPositionCallParams(params: {
1912
+ collateralAmount: Web3Number;
1913
+ isAddCollateral: boolean;
1914
+ debtAmount: Web3Number;
1915
+ isBorrow: boolean;
1916
+ }): {
1917
+ collateralAmount: {
1918
+ amount_type: VesuAmountType;
1919
+ denomination: VesuAmountDenomination;
1920
+ value: {
1921
+ abs: Web3Number;
1922
+ is_negative: boolean;
1923
+ };
1924
+ };
1925
+ debtAmount: {
1926
+ amount_type: VesuAmountType;
1927
+ denomination: VesuAmountDenomination;
1928
+ value: {
1929
+ abs: Web3Number;
1930
+ is_negative: boolean;
1931
+ };
1932
+ };
1933
+ };
1934
+ getVesuModifyDelegationCall: (delegatee: ContractAddr) => (params: VesuModifyDelegationCallParams) => {
1935
+ sanitizer: ContractAddr;
1936
+ call: {
1937
+ contractAddress: ContractAddr;
1938
+ selector: string;
1939
+ calldata: bigint[];
1940
+ };
1941
+ };
1942
+ formatAmountTypeEnum(amountType: VesuAmountType): CairoCustomEnum;
1943
+ formatAmountDenominationEnum(denomination: VesuAmountDenomination): CairoCustomEnum;
1944
+ getVesuSingletonContract(config: IConfig, poolId: ContractAddr): {
1945
+ contract: Contract;
1946
+ isV2: boolean;
1947
+ };
1948
+ getDebtCap(config: IConfig): Promise<Web3Number>;
1949
+ getCurrentDebtUtilisationAmount(config: IConfig): Promise<Web3Number>;
1950
+ getMaxBorrowableByInterestRate(config: IConfig, asset: TokenInfo, maxBorrowAPY: number): Promise<{
1951
+ maxDebtToHave: Web3Number;
1952
+ currentDebt: Web3Number;
1953
+ totalSupply: Web3Number;
1954
+ }>;
1955
+ getLTVConfig(config: IConfig, blockNumber?: BlockIdentifier): Promise<number>;
1956
+ getPositions(config: IConfig, blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
1957
+ getCollateralization(config: IConfig, blockNumber?: BlockIdentifier): Promise<Omit<VaultPosition, 'amount'>[]>;
1958
+ getAssetPrices(): Promise<{
1959
+ collateralTokenAmount: Web3Number;
1960
+ collateralUSDAmount: number;
1961
+ collateralPrice: number;
1962
+ debtTokenAmount: Web3Number;
1963
+ debtUSDAmount: number;
1964
+ debtPrice: number;
1965
+ ltv: number;
1966
+ }>;
1967
+ getHealthFactor(blockNumber?: BlockIdentifier): Promise<number>;
1968
+ static getVesuPools(retry?: number): Promise<VesuPoolsInfo>;
1969
+ fullUtilizationRate(interestRateConfig: InterestRateConfig, timeDelta: bigint, utilization: bigint, fullUtilizationRate: bigint): bigint;
1970
+ /**
1971
+ * Calculates new interest rate per second and next full utilization rate.
1972
+ */
1973
+ calculateInterestRate(interestRateConfig: InterestRateConfig, utilization: bigint, timeDelta: bigint, lastFullUtilizationRate: bigint): {
1974
+ newRatePerSecond: bigint;
1975
+ nextFullUtilizationRate: bigint;
1976
+ };
1977
+ /**
1978
+ * Calculates utilization given a specific rate per second.
1979
+ * This is an inverse function of the piecewise interest rate formula above.
1980
+ */
1981
+ getMaxUtilizationGivenRatePerSecond(interestRateConfig: InterestRateConfig, ratePerSecond: bigint, timeDelta: bigint, last_full_utilization_rate: bigint): bigint;
1982
+ }
1983
+
1984
+ interface VesuSupplyOnlyAdapterConfig extends BaseAdapterConfig {
1985
+ vTokenContract: ContractAddr;
1986
+ }
1987
+ declare class VesuSupplyOnlyAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
1988
+ readonly config: VesuSupplyOnlyAdapterConfig;
1989
+ readonly tokenMarketData: TokenMarketData;
1990
+ constructor(config: VesuSupplyOnlyAdapterConfig);
1991
+ private _depositApproveProofReadableId;
1992
+ private _depositCallProofReadableId;
1993
+ private _withdrawCallProofReadableId;
1994
+ protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
1995
+ protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
1996
+ maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
1997
+ maxWithdraw(): Promise<PositionInfo>;
1998
+ protected _getDepositLeaf(): {
1999
+ target: ContractAddr;
2000
+ method: string;
2001
+ packedArguments: bigint[];
2002
+ sanitizer: ContractAddr;
2003
+ id: string;
2004
+ }[];
1499
2005
  protected _getWithdrawLeaf(): {
1500
2006
  target: ContractAddr;
1501
2007
  method: string;
@@ -1503,58 +2009,59 @@ declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams>
1503
2009
  sanitizer: ContractAddr;
1504
2010
  id: string;
1505
2011
  }[];
2012
+ getDepositAdapter(): AdapterLeafType<DepositParams>;
2013
+ getWithdrawAdapter(): AdapterLeafType<WithdrawParams>;
1506
2014
  getDepositCall(params: DepositParams): Promise<ManageCall[]>;
1507
- getProofsForFromLegacySwap<T>(tree: StandardMerkleTree): {
1508
- proofs: string[][];
1509
- callConstructor: GenerateCallFn<DepositParams> | GenerateCallFn<WithdrawParams>;
1510
- };
1511
- getSwapFromLegacyCall(params: DepositParams): Promise<ManageCall[]>;
1512
2015
  getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
1513
- withdrawFromExtended(amount: Web3Number): Promise<boolean>;
1514
2016
  getHealthFactor(): Promise<number>;
1515
- getExtendedDepositAmount(): Promise<Balance | undefined>;
1516
- setLeverage(leverage: string, marketName: string): Promise<boolean>;
1517
- getAllOpenPositions(): Promise<Position[] | null>;
1518
- getOrderHistory(marketName: string): Promise<OpenOrder[] | null>;
1519
- getOrderStatus(orderId: string, marketName: string): Promise<OpenOrder | null>;
1520
- fetchOrderBookBTCUSDC(): Promise<{
1521
- status: boolean;
1522
- bid: Web3Number;
1523
- ask: Web3Number;
1524
- }>;
1525
- createOrder(leverage: string, btcAmount: number, side: OrderSide, attempt?: number, maxAttempts?: number): Promise<{
1526
- position_id: string;
1527
- btc_exposure: string;
1528
- } | null>;
1529
- createExtendedPositon(client: ExtendedWrapper, marketName: string, amount: string, price: string, side: OrderSide): Promise<{
1530
- position_id: string;
1531
- } | null>;
1532
- getDepositOrWithdrawalStatus(orderId: number | string, operationsType: AssetOperationType): Promise<boolean>;
1533
2017
  }
1534
2018
 
1535
- declare const SIMPLE_SANITIZER: ContractAddr;
1536
- declare const EXTENDED_SANITIZER: ContractAddr;
1537
- declare const AVNU_LEGACY_SANITIZER: ContractAddr;
1538
- declare const SIMPLE_SANITIZER_V2: ContractAddr;
1539
- declare const VESU_V2_MODIFY_POSITION_SANITIZER: ContractAddr;
1540
- declare const SIMPLE_SANITIZER_VESU_V1_DELEGATIONS: ContractAddr;
1541
- declare const PRICE_ROUTER: ContractAddr;
1542
- declare const AVNU_MIDDLEWARE: ContractAddr;
1543
- declare const AVNU_EXCHANGE: ContractAddr;
1544
- declare const AVNU_EXCHANGE_FOR_LEGACY_USDC: ContractAddr;
1545
- declare const AVNU_QUOTE_URL = "https://starknet.api.avnu.fi/swap/v3/quotes";
1546
- declare const EXTENDED_CONTRACT: ContractAddr;
1547
- declare const VESU_SINGLETON: ContractAddr;
1548
- declare function toBigInt(value: string | number): bigint;
1549
-
1550
- interface UnusedBalanceAdapterConfig extends BaseAdapterConfig {
2019
+ interface VesuDepositParams {
2020
+ amount: Web3Number;
2021
+ marginSwap?: {
2022
+ marginToken: TokenInfo;
2023
+ };
2024
+ leverSwap?: {
2025
+ exactOutput?: Web3Number;
2026
+ };
2027
+ }
2028
+ interface VesuWithdrawParams {
2029
+ amount: Web3Number;
2030
+ withdrawSwap?: {
2031
+ outputToken: TokenInfo;
2032
+ };
2033
+ }
2034
+ interface VesuMultiplyAdapterConfig extends BaseAdapterConfig {
2035
+ poolId: ContractAddr;
2036
+ collateral: TokenInfo;
2037
+ debt: TokenInfo;
2038
+ marginToken: TokenInfo;
2039
+ targetHealthFactor: number;
2040
+ minHealthFactor: number;
2041
+ quoteAmountToFetchPrice: Web3Number;
2042
+ minimumVesuMovementAmount: number;
2043
+ maxSlippage?: number;
1551
2044
  }
1552
- declare class UnusedBalanceAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
1553
- readonly config: UnusedBalanceAdapterConfig;
2045
+ declare class VesuMultiplyAdapter extends BaseAdapter<VesuDepositParams, VesuWithdrawParams> {
2046
+ readonly config: VesuMultiplyAdapterConfig;
2047
+ readonly _vesuAdapter: VesuAdapter;
1554
2048
  readonly tokenMarketData: TokenMarketData;
1555
- constructor(config: UnusedBalanceAdapterConfig);
1556
- protected getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY>;
1557
- protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
2049
+ readonly minimumVesuMovementAmount: number;
2050
+ lastSwapPriceInfo: SwapPriceInfo | null;
2051
+ maxSlippage: number;
2052
+ constructor(config: VesuMultiplyAdapterConfig);
2053
+ private _getMultiplyContract;
2054
+ private _buildDelegationWrappedCalls;
2055
+ private _getDepositProofReadableIds;
2056
+ private _getWithdrawProofReadableIds;
2057
+ private _buildZeroAmountSwapsWithWeights;
2058
+ private _fetchPositionAndPrices;
2059
+ private _computeTargetDebtDelta;
2060
+ private _getPositionCommonContext;
2061
+ protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
2062
+ protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
2063
+ maxBorrowableAPY(): Promise<number>;
2064
+ private _computeMax;
1558
2065
  maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
1559
2066
  maxWithdraw(): Promise<PositionInfo>;
1560
2067
  protected _getDepositLeaf(): {
@@ -1571,479 +2078,298 @@ declare class UnusedBalanceAdapter extends BaseAdapter<DepositParams, WithdrawPa
1571
2078
  sanitizer: ContractAddr;
1572
2079
  id: string;
1573
2080
  }[];
2081
+ getDepositAdapter(approveToken?: TokenInfo): AdapterLeafType<VesuDepositParams>;
2082
+ getWithdrawAdapter(): AdapterLeafType<VesuWithdrawParams>;
2083
+ getDepositCall(params: VesuDepositParams): Promise<ManageCall[]>;
2084
+ getWithdrawCall(params: VesuWithdrawParams): Promise<ManageCall[]>;
2085
+ private _getIncreaseCalldata;
2086
+ private _buildDecreaseLikeCalldata;
2087
+ private _getDecreaseCalldata;
2088
+ formatMultiplyParams(isIncrease: boolean, params: IncreaseLeverParams | DecreaseLeverParams): {
2089
+ action: CairoCustomEnum;
2090
+ };
1574
2091
  getHealthFactor(): Promise<number>;
1575
- getDepositCall(params: DepositParams): Promise<ManageCall[]>;
1576
- getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
2092
+ getNetAPY(): Promise<number>;
1577
2093
  }
1578
2094
 
1579
- interface SingleActionAmount {
1580
- tokenInfo: TokenInfo;
2095
+ interface VesuModifyPositionDepositParams {
1581
2096
  amount: Web3Number;
2097
+ debtAmount?: Web3Number;
1582
2098
  }
1583
- interface SingleTokenInfo extends SingleActionAmount {
1584
- usdValue: number;
1585
- }
1586
- interface APYInfo {
1587
- net: number;
1588
- splits: {
1589
- apy: number;
1590
- id: string;
1591
- }[];
2099
+ interface VesuModifyPositionWithdrawParams {
2100
+ amount: Web3Number;
2101
+ debtAmount?: Web3Number;
1592
2102
  }
1593
- interface DualActionAmount {
1594
- token0: SingleActionAmount;
1595
- token1: SingleActionAmount;
1596
- }
1597
- interface DualTokenInfo {
1598
- usdValue: number;
1599
- token0: SingleTokenInfo;
1600
- token1: SingleTokenInfo;
1601
- }
1602
- interface CacheData {
1603
- timestamp: number;
1604
- ttl: number;
1605
- data: any;
1606
- }
1607
- declare class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
1608
- readonly config: IConfig;
1609
- readonly cache: Map<string, CacheData>;
1610
- constructor(config: IConfig);
1611
- getUserTVL(user: ContractAddr): Promise<TVLInfo>;
1612
- getTVL(): Promise<TVLInfo>;
1613
- depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Promise<Call[]>;
1614
- withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1615
- getVaultPositions(): Promise<VaultPosition[]>;
1616
- getUnusedBalance(): Promise<SingleTokenInfo>;
1617
- netAPY(): Promise<APYInfo>;
1618
- getAUM(): Promise<{
1619
- net: SingleTokenInfo;
1620
- prevAum: Web3Number;
1621
- splits: PositionInfo[];
1622
- }>;
1623
- getHealthFactors(): Promise<number[]>;
1624
- }
1625
-
1626
- /**
1627
- * TokenMarketData class that combines LST APR and Midas modules
1628
- * to provide unified APY, price, and TVL functions for tokens
1629
- */
1630
- declare class TokenMarketData {
1631
- private pricer;
1632
- private config;
1633
- constructor(pricer: PricerBase, config: IConfig);
1634
- /**
1635
- * Get APY for a token
1636
- * - If it's an LST token, returns LST APY
1637
- * - If it's a Midas token, returns Midas APY
1638
- * - Otherwise returns 0
1639
- * @param tokenInfo The token to get APY for
1640
- * @returns APY in absolute terms (not percentage)
1641
- */
1642
- getAPY(tokenInfo: TokenInfo): Promise<number>;
1643
- /**
1644
- * Get price for a token using the pricer module
1645
- * @param tokenInfo The token to get price for
1646
- * @returns Price as a number
1647
- * @throws Error if price is 0 or unavailable
1648
- */
1649
- getPrice(tokenInfo: TokenInfo): Promise<number>;
1650
- /**
1651
- * Get true price for a token
1652
- * - For LST tokens: Uses convert_to_assets to get true exchange rate
1653
- * - For Midas tokens: Uses Midas price API
1654
- * - For other tokens: Falls back to regular pricer
1655
- * @param tokenInfo The token to get true price for
1656
- * @returns True price as a number
1657
- * @throws Error if price is 0 or unavailable
1658
- */
1659
- getTruePrice(tokenInfo: TokenInfo): Promise<number>;
1660
- /**
1661
- * Get TVL for a token
1662
- * - If it's a Midas token, returns Midas TVL data
1663
- * - Otherwise returns 0
1664
- * @param tokenInfo The token to get TVL for
1665
- * @returns TVL as SingleTokenInfo or 0
1666
- */
1667
- getTVL(tokenInfo: TokenInfo): Promise<SingleTokenInfo>;
1668
- /**
1669
- * Check if a token is supported for APY data
1670
- * @param tokenInfo The token to check
1671
- * @returns True if the token has APY data available
1672
- */
1673
- isAPYSupported(tokenInfo: TokenInfo): boolean;
1674
- /**
1675
- * Check if a token is supported for TVL data
1676
- * @param tokenInfo The token to check
1677
- * @returns True if the token has TVL data available
1678
- */
1679
- isTVLSupported(tokenInfo: TokenInfo): boolean;
1680
- }
1681
-
1682
- declare class Pragma {
1683
- contractAddr: string;
1684
- readonly contract: Contract;
1685
- constructor(provider: RpcProvider);
1686
- getPrice(tokenAddr: string): Promise<number>;
1687
- }
1688
-
1689
- declare class ZkLend extends ILending implements ILending {
1690
- readonly pricer: Pricer;
1691
- static readonly POOLS_URL = "https://app.zklend.com/api/pools";
1692
- private POSITION_URL;
1693
- constructor(config: IConfig, pricer: Pricer);
1694
- init(): Promise<void>;
1695
- /**
1696
- * @description Get the health factor of the user for given lending and debt tokens
1697
- * @param lending_tokens
1698
- * @param debt_tokens
1699
- * @param user
1700
- * @returns hf (e.g. returns 1.5 for 150% health factor)
1701
- */
1702
- get_health_factor_tokenwise(lending_tokens: TokenInfo[], debt_tokens: TokenInfo[], user: ContractAddr): Promise<number>;
1703
- /**
1704
- * @description Get the health factor of the user
1705
- * - Considers all tokens for collateral and debt
1706
- */
1707
- get_health_factor(user: ContractAddr): Promise<number>;
1708
- getPositionsSummary(user: ContractAddr): Promise<{
1709
- collateralUSD: number;
1710
- debtUSD: number;
1711
- }>;
1712
- /**
1713
- * @description Get the token-wise collateral and debt positions of the user
1714
- * @param user Contract address of the user
1715
- * @returns Promise<ILendingPosition[]>
1716
- */
1717
- getPositions(user: ContractAddr): Promise<ILendingPosition[]>;
1718
- }
1719
-
1720
- declare class PricerFromApi extends PricerBase {
1721
- constructor(config: IConfig, tokens: TokenInfo[]);
1722
- getPrice(tokenSymbol: string): Promise<PriceInfo>;
1723
- getPriceFromMyAPI(tokenSymbol: string): Promise<{
1724
- price: number;
1725
- timestamp: Date;
1726
- }>;
1727
- }
1728
-
1729
- declare class ERC20 {
1730
- readonly config: IConfig;
1731
- constructor(config: IConfig);
1732
- contract(addr: string | ContractAddr): Contract;
1733
- balanceOf(token: string | ContractAddr, address: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
1734
- allowance(token: string | ContractAddr, owner: string | ContractAddr, spender: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
1735
- transfer(token: string | ContractAddr, to: string | ContractAddr, amount: Web3Number): starknet.Call;
1736
- approve(token: string | ContractAddr, spender: string | ContractAddr, amount: Web3Number): starknet.Call;
1737
- }
1738
-
1739
- declare class AutoCompounderSTRK {
1740
- readonly config: IConfig;
1741
- readonly addr: ContractAddr;
1742
- readonly pricer: Pricer;
1743
- private initialized;
1744
- contract: Contract | null;
1745
- readonly metadata: {
1746
- decimals: number;
1747
- underlying: {
1748
- address: ContractAddr;
1749
- name: string;
1750
- symbol: string;
1751
- };
1752
- name: string;
1753
- };
1754
- constructor(config: IConfig, pricer: Pricer);
1755
- init(): Promise<void>;
1756
- waitForInitilisation(): Promise<void>;
1757
- /** Returns shares of user */
1758
- balanceOf(user: ContractAddr): Promise<Web3Number>;
1759
- /** Returns underlying assets of user */
1760
- balanceOfUnderlying(user: ContractAddr): Promise<Web3Number>;
1761
- /** Returns usd value of assets */
1762
- usdBalanceOfUnderlying(user: ContractAddr): Promise<{
1763
- usd: Web3Number;
1764
- assets: Web3Number;
1765
- }>;
1766
- }
1767
-
1768
- interface PoolProps {
1769
- pool_id: ContractAddr;
1770
- max_weight: number;
1771
- v_token: ContractAddr;
1772
- }
1773
- interface Change {
1774
- pool_id: ContractAddr;
1775
- changeAmt: Web3Number;
1776
- finalAmt: Web3Number;
1777
- isDeposit: boolean;
1778
- }
1779
- interface VesuRebalanceSettings {
1780
- feeBps: number;
1781
- }
1782
- interface PoolInfoFull {
1783
- pool_id: ContractAddr;
1784
- pool_name: string | undefined;
1785
- max_weight: number;
1786
- current_weight: number;
1787
- v_token: ContractAddr;
1788
- amount: Web3Number;
1789
- usdValue: Web3Number;
1790
- APY: {
1791
- baseApy: number;
1792
- defiSpringApy: number;
1793
- netApy: number;
1794
- };
1795
- currentUtilization: number;
1796
- maxUtilization: number;
1797
- }
1798
- /**
1799
- * Represents a VesuRebalance strategy.
1800
- * This class implements an automated rebalancing strategy for Vesu pools,
1801
- * managing deposits and withdrawals while optimizing yield through STRK rewards.
1802
- */
1803
- declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
1804
- /** Contract address of the strategy */
1805
- readonly address: ContractAddr;
1806
- /** Pricer instance for token price calculations */
1807
- readonly pricer: PricerBase;
1808
- /** Metadata containing strategy information */
1809
- readonly metadata: IStrategyMetadata<VesuRebalanceSettings>;
1810
- /** Contract instance for interacting with the strategy */
1811
- readonly contract: Contract;
1812
- readonly BASE_WEIGHT = 10000;
1813
- /**
1814
- * Creates a new VesuRebalance strategy instance.
1815
- * @param config - Configuration object containing provider and other settings
1816
- * @param pricer - Pricer instance for token price calculations
1817
- * @param metadata - Strategy metadata including deposit tokens and address
1818
- * @throws {Error} If more than one deposit token is specified
1819
- */
1820
- constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>);
1821
- /**
1822
- * Creates a deposit call to the strategy contract.
1823
- * @param assets - Amount of assets to deposit
1824
- * @param receiver - Address that will receive the strategy tokens
1825
- * @returns Populated contract call for deposit
1826
- */
1827
- depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<starknet.Call[]>;
1828
- /**
1829
- * Creates a withdrawal call to the strategy contract.
1830
- * @param assets - Amount of assets to withdraw
1831
- * @param receiver - Address that will receive the withdrawn assets
1832
- * @param owner - Address that owns the strategy tokens
1833
- * @returns Populated contract call for withdrawal
1834
- */
1835
- withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<starknet.Call[]>;
1836
- /**
1837
- * Returns the underlying asset token of the strategy.
1838
- * @returns The deposit token supported by this strategy
1839
- */
1840
- asset(): TokenInfo;
1841
- /**
1842
- * Returns the number of decimals used by the strategy token.
1843
- * @returns Number of decimals (same as the underlying token)
1844
- */
1845
- decimals(): number;
1846
- /**
1847
- * Calculates the Total Value Locked (TVL) for a specific user.
1848
- * @param user - Address of the user
1849
- * @returns Object containing the amount in token units and USD value
1850
- */
1851
- getUserTVL(user: ContractAddr): Promise<{
1852
- tokenInfo: TokenInfo;
1853
- amount: Web3Number;
1854
- usdValue: number;
1855
- }>;
1856
- /**
1857
- * Calculates the total TVL of the strategy.
1858
- * @returns Object containing the total amount in token units and USD value
1859
- */
1860
- getTVL(): Promise<{
1861
- tokenInfo: TokenInfo;
1862
- amount: Web3Number;
1863
- usdValue: number;
1864
- }>;
1865
- static getAllPossibleVerifiedPools(asset: ContractAddr): Promise<any>;
1866
- getPoolInfo(p: PoolProps, pools: any[], vesuPositions: any[], totalAssets: Web3Number, isErrorPositionsAPI: boolean, isErrorPoolsAPI: boolean): Promise<{
1867
- pool_id: ContractAddr;
1868
- pool_name: any;
1869
- max_weight: number;
1870
- current_weight: number;
1871
- v_token: ContractAddr;
1872
- amount: Web3Number;
1873
- usdValue: Web3Number;
1874
- APY: {
1875
- baseApy: number;
1876
- defiSpringApy: number;
1877
- netApy: number;
1878
- };
1879
- currentUtilization: number;
1880
- maxUtilization: number;
1881
- }>;
1882
- /**
1883
- * Retrieves the list of allowed pools and their detailed information from multiple sources:
1884
- * 1. Contract's allowed pools
1885
- * 2. Vesu positions API for current positions
1886
- * 3. Vesu pools API for APY and utilization data
1887
- *
1888
- * @returns {Promise<{
1889
- * data: Array<PoolInfoFull>,
1890
- * isErrorPositionsAPI: boolean
1891
- * }>} Object containing:
1892
- * - data: Array of pool information including IDs, weights, amounts, APYs and utilization
1893
- * - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
1894
- */
1895
- getPools(): Promise<{
1896
- data: {
1897
- pool_id: ContractAddr;
1898
- pool_name: any;
1899
- max_weight: number;
1900
- current_weight: number;
1901
- v_token: ContractAddr;
1902
- amount: Web3Number;
1903
- usdValue: Web3Number;
1904
- APY: {
1905
- baseApy: number;
1906
- defiSpringApy: number;
1907
- netApy: number;
1908
- };
1909
- currentUtilization: number;
1910
- maxUtilization: number;
1911
- }[];
1912
- isErrorPositionsAPI: boolean;
1913
- isErrorPoolsAPI: boolean;
1914
- isError: boolean;
1915
- }>;
1916
- getVesuPools(retry?: number): Promise<{
1917
- pools: any[];
1918
- isErrorPoolsAPI: boolean;
1919
- }>;
1920
- /**
1921
- * Calculates the weighted average APY across all pools based on USD value.
1922
- * @returns {Promise<number>} The weighted average APY across all pools
1923
- */
1924
- netAPY(): Promise<APYInfo>;
1925
- /**
1926
- * Calculates the weighted average APY across all pools based on USD value.
1927
- * @returns {Promise<number>} The weighted average APY across all pools
1928
- */
1929
- netAPYGivenPools(pools: PoolInfoFull[]): Promise<number>;
1930
- /**
1931
- * Calculates optimal position changes to maximize APY while respecting max weights.
1932
- * The algorithm:
1933
- * 1. Sorts pools by APY (highest first)
1934
- * 2. Calculates target amounts based on max weights
1935
- * 3. For each pool that needs more funds:
1936
- * - Takes funds from lowest APY pools that are over their target
1937
- * 4. Validates that total assets remain constant
1938
- *
1939
- * @returns {Promise<{
1940
- * changes: Change[],
1941
- * finalPools: PoolInfoFull[],
1942
- * isAnyPoolOverMaxWeight: boolean
1943
- * }>} Object containing:
1944
- * - changes: Array of position changes
1945
- * - finalPools: Array of pool information after rebalance
1946
- * @throws Error if rebalance is not possible while maintaining constraints
1947
- */
1948
- getRebalancedPositions(_pools?: PoolInfoFull[]): Promise<{
1949
- changes: never[];
1950
- finalPools: never[];
1951
- isAnyPoolOverMaxWeight?: undefined;
1952
- } | {
1953
- changes: Change[];
1954
- finalPools: PoolInfoFull[];
1955
- isAnyPoolOverMaxWeight: boolean;
1956
- }>;
2103
+ interface VesuModifyPositionAdapterConfig extends BaseAdapterConfig {
2104
+ poolId: ContractAddr;
2105
+ collateral: TokenInfo;
2106
+ debt: TokenInfo;
2107
+ targetLtv: number;
2108
+ maxLtv: number;
2109
+ }
2110
+ declare class VesuModifyPositionAdapter extends BaseAdapter<VesuModifyPositionDepositParams, VesuModifyPositionWithdrawParams> {
2111
+ readonly config: VesuModifyPositionAdapterConfig;
2112
+ readonly _vesuAdapter: VesuAdapter;
2113
+ private readonly _tokenMarketData;
2114
+ constructor(config: VesuModifyPositionAdapterConfig);
2115
+ private _prepareVesuAdapter;
2116
+ private _getTargetHealthFactor;
2117
+ private _getPositionCommonContext;
2118
+ private _getEffectiveMaxLtv;
2119
+ private _toSigned;
2120
+ private _depositApproveProofReadableId;
2121
+ private _depositModifyProofReadableId;
2122
+ private _withdrawApproveProofReadableId;
2123
+ private _withdrawModifyProofReadableId;
2124
+ private _clampWithdrawCollateral;
2125
+ private _clampRepayDebt;
2126
+ private _normalizeDebtAmountFromHelper;
2127
+ private _getState;
2128
+ private _buildDefaultDepositDeltas;
2129
+ private _buildDefaultWithdrawDeltas;
2130
+ private _amountStruct;
2131
+ private _getModifyPositionCall;
2132
+ private _getApproveCall;
2133
+ protected getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY>;
2134
+ protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
2135
+ maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
2136
+ maxWithdraw(): Promise<PositionInfo>;
2137
+ protected _getDepositLeaf(): {
2138
+ target: ContractAddr;
2139
+ method: string;
2140
+ packedArguments: bigint[];
2141
+ sanitizer: ContractAddr;
2142
+ id: string;
2143
+ }[];
2144
+ protected _getWithdrawLeaf(): {
2145
+ target: ContractAddr;
2146
+ method: string;
2147
+ packedArguments: bigint[];
2148
+ sanitizer: ContractAddr;
2149
+ id: string;
2150
+ }[];
2151
+ getDepositCall(params: VesuModifyPositionDepositParams): Promise<ManageCall[]>;
2152
+ getWithdrawCall(params: VesuModifyPositionWithdrawParams): Promise<ManageCall[]>;
2153
+ getHealthFactor(): Promise<number>;
1957
2154
  /**
1958
- * Creates a rebalance Call object for the strategy contract
1959
- * @param pools - Array of pool information including IDs, weights, amounts, APYs and utilization
1960
- * @returns Populated contract call for rebalance
2155
+ * Simulates a deposit of `depositAmount` collateral and returns how much
2156
+ * debt (STRK) would be incrementally borrowed to reach the target LTV.
2157
+ * Used upstream to size the AVNU swap call in the same transaction batch.
1961
2158
  */
1962
- getRebalanceCall(pools: Awaited<ReturnType<typeof this.getRebalancedPositions>>["changes"], isOverWeightAdjustment: boolean): Promise<starknet.Call | null>;
1963
- getInvestmentFlows(pools: PoolInfoFull[]): Promise<IInvestmentFlow[]>;
1964
- harvest(acc: Account, endpoint?: string): Promise<starknet.Call[]>;
2159
+ getExpectedDepositDebtDelta(depositAmount: Web3Number): Promise<Web3Number>;
1965
2160
  /**
1966
- * Calculates the fees deducted in different vTokens based on the current and previous state.
1967
- * @param previousTotalSupply - The total supply of the strategy token before the transaction
1968
- * @returns {Promise<Array<{ vToken: ContractAddr, fee: Web3Number }>>} Array of fees deducted in different vTokens
2161
+ * Simulates a withdrawal of `withdrawAmount` collateral and returns the
2162
+ * incremental debt delta needed to keep the target health factor.
2163
+ * Positive means borrow, negative means repay.
1969
2164
  */
1970
- getFee(allowedPools: Array<PoolInfoFull>): Promise<Array<{
1971
- vToken: ContractAddr;
1972
- fee: Web3Number;
1973
- }>>;
2165
+ getExpectedWithdrawDebtDelta(withdrawAmount: Web3Number): Promise<Web3Number>;
2166
+ }
2167
+
2168
+ declare const SIMPLE_SANITIZER: ContractAddr;
2169
+ declare const SVK_SIMPLE_SANITIZER: ContractAddr;
2170
+ declare const EXTENDED_SANITIZER: ContractAddr;
2171
+ declare const AVNU_LEGACY_SANITIZER: ContractAddr;
2172
+ declare const SIMPLE_SANITIZER_V2: ContractAddr;
2173
+ declare const VESU_V2_MODIFY_POSITION_SANITIZER: ContractAddr;
2174
+ declare const SIMPLE_SANITIZER_VESU_V1_DELEGATIONS: ContractAddr;
2175
+ declare const PRICE_ROUTER: ContractAddr;
2176
+ declare const AVNU_MIDDLEWARE: ContractAddr;
2177
+ declare const AVNU_EXCHANGE: ContractAddr;
2178
+ declare const AVNU_EXCHANGE_FOR_LEGACY_USDC: ContractAddr;
2179
+ declare const AVNU_QUOTE_URL = "https://starknet.api.avnu.fi/swap/v3/quotes";
2180
+ declare const EXTENDED_CONTRACT: ContractAddr;
2181
+ declare const VESU_SINGLETON: ContractAddr;
2182
+ declare const TRANSFER_SANITIZER: ContractAddr;
2183
+ declare function toBigInt(value: string | number): bigint;
2184
+
2185
+ interface TokenTransferAdapterConfig extends BaseAdapterConfig {
2186
+ /** Address that funds are sent FROM during deposit (and returned TO during withdraw) */
2187
+ fromAddress: ContractAddr;
2188
+ /** Address that funds are sent TO during deposit (and pulled FROM during withdraw) */
2189
+ toAddress: ContractAddr;
1974
2190
  }
1975
2191
  /**
1976
- * Represents the Vesu Rebalance Strategies.
2192
+ * Adapter for transferring a single token between two fixed addresses.
2193
+ *
2194
+ * Deposit: transfers baseToken from `fromAddress` → `toAddress`
2195
+ * Withdraw: transfers baseToken from `toAddress` → `fromAddress` (requires toAddress to approve fromAddress/VA)
2196
+ *
2197
+ * Proof IDs are derived from `tr_<symbol>_<toAddrShort>` to be unique per token+destination pair.
1977
2198
  */
1978
- declare const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[];
2199
+ declare class TokenTransferAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
2200
+ readonly config: TokenTransferAdapterConfig;
2201
+ readonly tokenMarketData: TokenMarketData;
2202
+ constructor(config: TokenTransferAdapterConfig);
2203
+ private _idBase;
2204
+ private _depositCallProofReadableId;
2205
+ private _withdrawCallProofReadableId;
2206
+ protected getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY>;
2207
+ protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
2208
+ maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
2209
+ maxWithdraw(): Promise<PositionInfo>;
2210
+ protected _getDepositLeaf(): {
2211
+ target: ContractAddr;
2212
+ method: string;
2213
+ packedArguments: bigint[];
2214
+ sanitizer: ContractAddr;
2215
+ id: string;
2216
+ }[];
2217
+ protected _getWithdrawLeaf(): {
2218
+ target: ContractAddr;
2219
+ method: string;
2220
+ packedArguments: bigint[];
2221
+ sanitizer: ContractAddr;
2222
+ id: string;
2223
+ }[];
2224
+ getDepositCall(params: DepositParams): Promise<ManageCall[]>;
2225
+ getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
2226
+ getHealthFactor(): Promise<number>;
2227
+ }
1979
2228
 
1980
- interface SenseiVaultSettings {
1981
- mainToken: TokenInfo;
1982
- secondaryToken: TokenInfo;
1983
- targetHfBps: number;
1984
- feeBps: number;
2229
+ interface AvnuDepositParams extends DepositParams {
2230
+ minAmount?: Web3Number;
1985
2231
  }
1986
- declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
1987
- readonly address: ContractAddr;
1988
- readonly metadata: IStrategyMetadata<SenseiVaultSettings>;
1989
- readonly pricer: PricerBase;
1990
- readonly contract: Contract;
1991
- constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>);
1992
- getUserTVL(user: ContractAddr): Promise<SingleTokenInfo>;
1993
- getTVL(): Promise<SingleTokenInfo>;
1994
- depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
1995
- withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1996
- getPositionInfo(): Promise<{
1997
- collateralXSTRK: Web3Number;
1998
- collateralUSDValue: Web3Number;
1999
- debtSTRK: Web3Number;
2000
- debtUSDValue: Web3Number;
2001
- xSTRKPrice: number;
2002
- collateralInSTRK: number;
2003
- }>;
2004
- getSecondaryTokenPriceRelativeToMain(retry?: number): Promise<number>;
2005
- getSettings: () => Promise<starknet.CallResult>;
2232
+ interface AvnuWithdrawParams extends WithdrawParams {
2233
+ minAmount?: Web3Number;
2006
2234
  }
2007
- declare const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[];
2008
-
2009
- interface UniversalManageCall {
2010
- proofs: string[];
2011
- manageCall: ManageCall;
2012
- step: UNIVERSAL_MANAGE_IDS;
2235
+ interface AvnuAdapterConfig extends BaseAdapterConfig {
2236
+ baseUrl: string;
2237
+ avnuContract: ContractAddr;
2238
+ slippage: number;
2239
+ minimumExtendedPriceDifferenceForSwapOpen: number;
2240
+ maximumExtendedPriceDifferenceForSwapClosing: number;
2013
2241
  }
2014
- interface UniversalStrategySettings {
2015
- vaultAddress: ContractAddr;
2016
- manager: ContractAddr;
2017
- vaultAllocator: ContractAddr;
2018
- redeemRequestNFT: ContractAddr;
2019
- leafAdapters: LeafAdapterFn<any>[];
2020
- adapters: {
2242
+ declare class AvnuAdapter extends BaseAdapter<AvnuDepositParams, AvnuWithdrawParams> {
2243
+ readonly config: AvnuAdapterConfig;
2244
+ protected avnuWrapper: AvnuWrapper;
2245
+ lastSwapPriceInfo: SwapPriceInfo | null;
2246
+ private _depositApproveProofReadableId;
2247
+ private _depositSwapProofReadableId;
2248
+ private _withdrawApproveProofReadableId;
2249
+ private _withdrawSwapProofReadableId;
2250
+ private buildSwapLeafConfigs;
2251
+ private buildSwapCalls;
2252
+ constructor(config: AvnuAdapterConfig);
2253
+ protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
2254
+ protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
2255
+ maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
2256
+ maxWithdraw(): Promise<PositionInfo>;
2257
+ protected _getDepositLeaf(): {
2258
+ target: ContractAddr;
2259
+ method: string;
2260
+ packedArguments: bigint[];
2261
+ sanitizer: ContractAddr;
2262
+ id: string;
2263
+ }[];
2264
+ protected _getWithdrawLeaf(): {
2265
+ target: ContractAddr;
2266
+ method: string;
2267
+ packedArguments: bigint[];
2268
+ sanitizer: ContractAddr;
2269
+ id: string;
2270
+ }[];
2271
+ protected _getLegacySwapLeaf(): {
2272
+ target: ContractAddr;
2273
+ method: string;
2274
+ packedArguments: bigint[];
2275
+ sanitizer: ContractAddr;
2021
2276
  id: string;
2022
- adapter: BaseAdapter<DepositParams, WithdrawParams>;
2023
2277
  }[];
2278
+ getDepositCall(params: AvnuDepositParams): Promise<ManageCall[]>;
2279
+ getWithdrawCall(params: AvnuWithdrawParams): Promise<ManageCall[]>;
2280
+ getSwapCallData(quote: Quote): Promise<bigint[][]>;
2281
+ getHealthFactor(): Promise<number>;
2282
+ fetchQuoteWithRetry(params: Record<string, any>, retries?: number): Promise<any>;
2024
2283
  }
2025
- declare enum AUMTypes {
2026
- FINALISED = "finalised",
2027
- DEFISPRING = "defispring"
2284
+
2285
+ /** Public Troves strategies feed (APY + metadata). Override in config for tests. */
2286
+ declare const DEFAULT_TROVES_STRATEGIES_API = "https://app.troves.fi/api/strategies";
2287
+ interface SvkTrovesAdapterConfig extends BaseAdapterConfig {
2288
+ /**
2289
+ * On-chain Troves / SVK strategy vault: ERC-4626-style `deposit` / `withdraw` on the underlying asset,
2290
+ * plus `due_assets_from_owner` for redemption NFT value still owed to an owner.
2291
+ */
2292
+ strategyVault: ContractAddr;
2293
+ /**
2294
+ * Troves API `strategies[].id` string (e.g. `hyper_xstrk`). Used to resolve APY from the public JSON feed.
2295
+ */
2296
+ trovesStrategyId: string;
2297
+ /**
2298
+ * Address whose vault **share** balance and **pending** redemption assets are measured.
2299
+ * Defaults to `vaultAllocator` when omitted (typical STRKFarm vault wiring).
2300
+ */
2301
+ positionOwner?: ContractAddr;
2302
+ /** Optional APY endpoint (defaults to {@link DEFAULT_TROVES_STRATEGIES_API}). */
2303
+ trovesStrategiesApiUrl?: string;
2304
+ /**
2305
+ * Optional redeem request NFT contract address. When provided, pending assets are calculated
2306
+ * using `getPendingAssetsFromOwnerNFTMethod` instead of `due_assets_from_owner`.
2307
+ */
2308
+ redeemRequestNFT?: ContractAddr;
2028
2309
  }
2029
- declare enum UNIVERSAL_MANAGE_IDS {
2030
- FLASH_LOAN = "flash_loan_init",
2031
- VESU_LEG1 = "vesu_leg1",
2032
- VESU_LEG2 = "vesu_leg2",
2033
- APPROVE_TOKEN1 = "approve_token1",
2034
- APPROVE_TOKEN2 = "approve_token2",
2035
- APPROVE_BRING_LIQUIDITY = "approve_bring_liquidity",
2036
- BRING_LIQUIDITY = "bring_liquidity",
2037
- DEFISPRING_REWARDS = "defispring_rewards",
2038
- APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
2039
- AVNU_SWAP_REWARDS = "avnu_swap_rewards"
2310
+ /**
2311
+ * Universal adapter for **Starknet Vault Kit (SVK)** style Troves strategies:
2312
+ * approve underlying → `deposit(assets, receiver)`, and `withdraw(assets, receiver, owner)` on the strategy vault.
2313
+ *
2314
+ * **Position sizing** (underlying asset, same decimals as `baseToken`):
2315
+ * - Liquid: `convert_to_assets(balance_of(positionOwner))` on the strategy vault (vault shares).
2316
+ * - Pending redemptions: `due_assets_from_owner(positionOwner)` on the same vault (NFT / queue claims not yet settled).
2317
+ *
2318
+ * **APY**: Fetched from Troves public API by `trovesStrategyId` (numeric `apy` field; non-numeric marketing values fall back to `0`).
2319
+ */
2320
+ declare class SvkTrovesAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
2321
+ readonly config: SvkTrovesAdapterConfig;
2322
+ constructor(config: SvkTrovesAdapterConfig);
2323
+ /** Owner used for share balance + `due_assets_from_owner`. */
2324
+ private _positionOwner;
2325
+ /**
2326
+ * Proof readable IDs must stay ≤ 31 chars (Cairo short string). We derive a short ASCII suffix from
2327
+ * `strategyVault` address so multiple SVK adapters in one tree stay distinct.
2328
+ */
2329
+ private _proofSuffix;
2330
+ private _depositApproveProofReadableId;
2331
+ private _depositCallProofReadableId;
2332
+ private _withdrawCallProofReadableId;
2333
+ protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
2334
+ protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
2335
+ getPendingAssetsFromOwner(owner?: ContractAddr, decimals?: number): Promise<Web3Number>;
2336
+ /**
2337
+ * Get pending assets from owner by scanning redeem request NFTs.
2338
+ * This method iterates backwards through NFT IDs to find all pending redemptions for a specific owner.
2339
+ *
2340
+ * @param redeemRequestNFT - The redeem request NFT contract address
2341
+ * @param owner - The owner address to check for pending redemptions (defaults to positionOwner)
2342
+ * @param decimals - Token decimals for conversion (defaults to baseToken decimals)
2343
+ * @returns Total pending assets from all NFTs owned by the specified address
2344
+ */
2345
+ getPendingAssetsFromOwnerNFTMethod(redeemRequestNFT: ContractAddr, owner?: ContractAddr, decimals?: number): Promise<Web3Number>;
2346
+ maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
2347
+ maxWithdraw(): Promise<PositionInfo>;
2348
+ protected _getDepositLeaf(): {
2349
+ target: ContractAddr;
2350
+ method: string;
2351
+ packedArguments: bigint[];
2352
+ sanitizer: ContractAddr;
2353
+ id: string;
2354
+ }[];
2355
+ protected _getWithdrawLeaf(): {
2356
+ target: ContractAddr;
2357
+ method: string;
2358
+ packedArguments: bigint[];
2359
+ sanitizer: ContractAddr;
2360
+ id: string;
2361
+ }[];
2362
+ getDepositAdapter(): AdapterLeafType<DepositParams>;
2363
+ getWithdrawAdapter(): AdapterLeafType<WithdrawParams>;
2364
+ getDepositCall(params: DepositParams): Promise<ManageCall[]>;
2365
+ getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
2366
+ getHealthFactor(): Promise<number>;
2367
+ }
2368
+
2369
+ declare enum LSTPriceType {
2370
+ ENDUR_PRICE = "ENDUR_PRICE",
2371
+ AVNU_PRICE = "AVNU_PRICE"
2040
2372
  }
2041
- declare function getContractDetails(settings: UniversalStrategySettings & {
2042
- aumOracle?: ContractAddr;
2043
- }): {
2044
- address: ContractAddr;
2045
- name: string;
2046
- }[];
2047
2373
 
2048
2374
  /**
2049
2375
  * Base class for all SVK (Starknet Vault Kit) strategies.
@@ -2067,11 +2393,21 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
2067
2393
  * Returns the asset token for this strategy
2068
2394
  */
2069
2395
  asset(): TokenInfo;
2396
+ depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
2397
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
2398
+ getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<SingleTokenInfo>;
2070
2399
  /**
2071
2400
  * Returns the unused balance in the vault allocator.
2072
2401
  * Note: This function is common for any SVK strategy.
2073
2402
  */
2074
2403
  getUnusedBalance(): Promise<SingleTokenInfo>;
2404
+ /**
2405
+ * Builds a manage call from an adapter's proof tree.
2406
+ * DRY helper for the repeated getProofs → getManageCall pattern.
2407
+ */
2408
+ protected buildManageCallFromAdapter(adapter: {
2409
+ getProofs: (isDeposit: boolean, tree: any) => any;
2410
+ }, isDeposit: boolean, amount: Web3Number, additionalParams?: Record<string, any>): Promise<Call>;
2075
2411
  /**
2076
2412
  * Bridges liquidity from the vault allocator back to the vault.
2077
2413
  * Note: This function is common for any SVK strategy.
@@ -2079,6 +2415,11 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
2079
2415
  getBringLiquidityCall(params: {
2080
2416
  amount: Web3Number;
2081
2417
  }): Promise<Call>;
2418
+ /**
2419
+ * Resolves ordered merkle proofs from emitted manage calls.
2420
+ * This ensures only runtime-required proofs are passed to manager calls.
2421
+ */
2422
+ protected getProofGroupsForManageCalls(manageCalls: ManageCall[]): string[][];
2082
2423
  /**
2083
2424
  * Gets all leaves from all leaf adapters.
2084
2425
  * Note: This function is common for any SVK strategy.
@@ -2110,11 +2451,76 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
2110
2451
  */
2111
2452
  abstract getTag(): string;
2112
2453
  /**
2113
- * Returns the positions in the vault.
2114
- * @returns An array of VaultPosition objects representing the positions in the vault.
2454
+ * Returns the positions in the vault.
2455
+ * @returns An array of VaultPosition objects representing the positions in the vault.
2456
+ */
2457
+ getVaultPositions(): Promise<VaultPosition[]>;
2458
+ getHealthFactors(): Promise<number[]>;
2459
+ netAPY(): Promise<{
2460
+ net: number;
2461
+ splits: {
2462
+ apy: number;
2463
+ id: string;
2464
+ }[];
2465
+ }>;
2466
+ getTVL(): Promise<SingleTokenInfo>;
2467
+ getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
2468
+ getUserPositionCards(input: UserPositionCardsInput): Promise<UserPositionCard[]>;
2469
+ getPrevAUM(): Promise<Web3Number>;
2470
+ maxDepositables(): Promise<PositionInfo[]>;
2471
+ maxWithdrawables(): Promise<PositionInfo[]>;
2472
+ }
2473
+
2474
+ interface UniversalManageCall {
2475
+ proofs: string[];
2476
+ manageCall: ManageCall;
2477
+ step: UNIVERSAL_MANAGE_IDS;
2478
+ }
2479
+ interface UniversalStrategySettings {
2480
+ vaultAddress: ContractAddr;
2481
+ manager: ContractAddr;
2482
+ vaultAllocator: ContractAddr;
2483
+ redeemRequestNFT: ContractAddr;
2484
+ aumOracle: ContractAddr;
2485
+ redemptionRouter?: ContractAddr;
2486
+ leafAdapters: LeafAdapterFn<any>[];
2487
+ adapters: {
2488
+ id: string;
2489
+ adapter: BaseAdapter<DepositParams, WithdrawParams>;
2490
+ }[];
2491
+ targetHealthFactor: number;
2492
+ minHealthFactor: number;
2493
+ }
2494
+ declare enum AUMTypes {
2495
+ FINALISED = "finalised",
2496
+ DEFISPRING = "defispring",
2497
+ BTCFI = "btcfi"
2498
+ }
2499
+ declare enum PositionTypeAvnuExtended {
2500
+ OPEN = "open",
2501
+ CLOSE = "close"
2502
+ }
2503
+ declare class UniversalStrategy<S extends UniversalStrategySettings> extends SVKStrategy<S> {
2504
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
2505
+ getMerkleTree(): StandardMerkleTree;
2506
+ getMerkleRoot(): string;
2507
+ getProofs<T>(id: string): {
2508
+ proofs: string[];
2509
+ callConstructor: GenerateCallFn<T>;
2510
+ };
2511
+ getAdapter(id: string): BaseAdapter<any, any>;
2512
+ asset(): TokenInfo;
2513
+ depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
2514
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
2515
+ getVesuAPYs(): Promise<{
2516
+ baseAPYs: number[];
2517
+ rewardAPYs: number[];
2518
+ positions: VaultPosition[];
2519
+ }>;
2520
+ /**
2521
+ * Calculates the weighted average APY across all pools based on USD value.
2522
+ * @returns {Promise<number>} The weighted average APY across all pools
2115
2523
  */
2116
- getVaultPositions(): Promise<VaultPosition[]>;
2117
- getHealthFactors(): Promise<number[]>;
2118
2524
  netAPY(): Promise<{
2119
2525
  net: number;
2120
2526
  splits: {
@@ -2122,25 +2528,147 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
2122
2528
  id: string;
2123
2529
  }[];
2124
2530
  }>;
2531
+ protected returnNetAPY(baseAPYs: number[], rewardAPYs: number[], weights: number[], prevAUMUSD: Web3Number): Promise<{
2532
+ net: number;
2533
+ splits: {
2534
+ apy: number;
2535
+ id: string;
2536
+ }[];
2537
+ }>;
2538
+ protected getUnusedBalanceAPY(): Promise<{
2539
+ apy: number;
2540
+ weight: number;
2541
+ }>;
2542
+ private computeAPY;
2543
+ /**
2544
+ * Calculates the total TVL of the strategy.
2545
+ * @returns Object containing the total amount in token units and USD value
2546
+ */
2547
+ getTVL(): Promise<{
2548
+ tokenInfo: TokenInfo;
2549
+ amount: Web3Number;
2550
+ usdValue: number;
2551
+ }>;
2552
+ getUnusedBalance(): Promise<SingleTokenInfo>;
2553
+ protected getVesuAUM(adapter: VesuAdapter, _priceType?: LSTPriceType): Promise<Web3Number>;
2125
2554
  getPrevAUM(): Promise<Web3Number>;
2126
- maxDepositables(): Promise<PositionInfo[]>;
2127
- maxWithdrawables(): Promise<PositionInfo[]>;
2555
+ getAUM(unrealizedAUM?: boolean): Promise<{
2556
+ net: SingleTokenInfo;
2557
+ prevAum: Web3Number;
2558
+ splits: {
2559
+ id: string;
2560
+ aum: Web3Number;
2561
+ }[];
2562
+ }>;
2563
+ protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
2564
+ getVesuMultiplyAdapter(): VesuMultiplyAdapter;
2565
+ getVesuModifyPositionAdapter(): VesuModifyPositionAdapter;
2566
+ /**
2567
+ * Legacy helper for retired Evergreen flows. New integrations should use
2568
+ * getVesuMultiplyAdapter / getVesuModifyPositionAdapter and BaseAdapter deposit/withdraw leaves.
2569
+ */
2570
+ getVesuAdapters(): VesuAdapter[];
2571
+ getVesuPositions(blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
2572
+ getVaultPositions(): Promise<VaultPosition[]>;
2573
+ getSetManagerCall(strategist: ContractAddr, root?: string): Call;
2574
+ /**
2575
+ * Compatibility helper: SVKStrategy's `getManageCall` expects proof-groups.
2576
+ * We derive proof-groups from each manageCall's `proofReadableId`.
2577
+ */
2578
+ protected getManageCallFromManageCalls(manageCalls: ManageCall[]): Call;
2579
+ getVesuModifyPositionCalls(params: {
2580
+ isLeg1: boolean;
2581
+ isDeposit: boolean;
2582
+ depositAmount: Web3Number;
2583
+ debtAmount: Web3Number;
2584
+ }): UniversalManageCall[];
2585
+ getTag(): string;
2586
+ /**
2587
+ * Gets LST APR for the strategy's underlying asset from Endur API
2588
+ * @returns Promise<number> The LST APR (not divided by 1e18)
2589
+ */
2590
+ getLSTAPR(address: ContractAddr): Promise<number>;
2591
+ getVesuHealthFactors(blockNumber?: BlockIdentifier): Promise<number[]>;
2592
+ computeRebalanceConditionAndReturnCalls(): Promise<Call[]>;
2593
+ private getNewHealthFactor;
2594
+ /**
2595
+ *
2596
+ * @param vesuAdapter
2597
+ * @param currentHf
2598
+ * @param isDeposit if true, attempt by adding collateral, else by repaying
2599
+ * @returns
2600
+ */
2601
+ private getLegRebalanceAmount;
2602
+ getVesuModifyPositionCall(params: {
2603
+ isDeposit: boolean;
2604
+ leg1DepositAmount: Web3Number;
2605
+ }): Promise<Call>;
2606
+ getPendingRewards(): Promise<HarvestInfo[]>;
2607
+ getHarvestCall(): Promise<{
2608
+ call: Call;
2609
+ reward: Web3Number;
2610
+ tokenInfo: TokenInfo;
2611
+ }>;
2612
+ getRebalanceCall(params: {
2613
+ isLeg1toLeg2: boolean;
2614
+ amount: Web3Number;
2615
+ }): Promise<Call>;
2616
+ }
2617
+ declare enum UNIVERSAL_MANAGE_IDS {
2618
+ FLASH_LOAN = "flash_loan_init",
2619
+ VESU_LEG1 = "vesu_leg1",
2620
+ VESU_LEG2 = "vesu_leg2",
2621
+ APPROVE_TOKEN1 = "approve_token1",
2622
+ APPROVE_TOKEN2 = "approve_token2",
2623
+ APPROVE_BRING_LIQUIDITY = "approve_bring_liquidity",
2624
+ BRING_LIQUIDITY = "bring_liquidity",
2625
+ DEFISPRING_REWARDS = "defispring_rewards",
2626
+ APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
2627
+ AVNU_SWAP_REWARDS = "avnu_swap_rewards"
2628
+ }
2629
+ declare enum UNIVERSAL_ADAPTER_IDS {
2630
+ VESU_MULTIPLY = "vesu_multiply",
2631
+ VESU_MODIFY = "vesu_modify",
2632
+ AVNU = "avnu"
2128
2633
  }
2634
+ declare function getContractDetails(settings: UniversalStrategySettings & {
2635
+ aumOracle?: ContractAddr;
2636
+ }): {
2637
+ address: ContractAddr;
2638
+ name: string;
2639
+ }[];
2640
+ declare const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[];
2129
2641
 
2130
2642
  interface HyperLSTStrategySettings extends UniversalStrategySettings {
2131
- borrowable_assets: TokenInfo[];
2643
+ borrowable_assets: {
2644
+ tokenInfo: TokenInfo;
2645
+ poolId: ContractAddr;
2646
+ }[];
2132
2647
  underlyingToken: TokenInfo;
2133
2648
  quoteAmountToFetchPrice: Web3Number;
2134
2649
  targetHealthFactor: number;
2135
2650
  minHealthFactor: number;
2136
2651
  aumOracle: ContractAddr;
2652
+ adapterIds?: {
2653
+ /** VesuMultiplyAdapter for underlying-matched debt (first matching borrowable pool) */
2654
+ primaryMultiply: string;
2655
+ multiply: Record<string, string>;
2656
+ modify: Record<string, string>;
2657
+ };
2137
2658
  }
2138
2659
  declare class UniversalLstMultiplierStrategy<S extends HyperLSTStrategySettings> extends SVKStrategy<S> {
2139
2660
  private quoteAmountToFetchPrice;
2140
2661
  constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
2141
2662
  getTag(): string;
2663
+ private getAdapterById;
2664
+ getVesuMultiplyAdapterByKey(key: string): VesuMultiplyAdapter;
2142
2665
  getVesuSameTokenAdapter(): VesuMultiplyAdapter;
2143
- getVesuAdapters(): VesuMultiplyAdapter[];
2666
+ getVesuMultiplyAdapters(): VesuMultiplyAdapter[];
2667
+ getRewardsAUM(_prevAum: Web3Number): Promise<Web3Number>;
2668
+ getLSTAvnuRate(): Promise<number>;
2669
+ getLSTExchangeRate(): Promise<number>;
2670
+ private _getMinOutputAmountLSTBuy;
2671
+ private _getMinOutputAmountLSTSell;
2144
2672
  /**
2145
2673
  * Uses vesu's multiple call to create leverage on LST
2146
2674
  * Deposit amount is in LST
@@ -2151,11 +2679,37 @@ declare class UniversalLstMultiplierStrategy<S extends HyperLSTStrategySettings>
2151
2679
  leg1DepositAmount: Web3Number;
2152
2680
  }): Promise<Call[] | null>;
2153
2681
  getLSTUnderlyingTokenInfo(): TokenInfo;
2154
- getAUM(): Promise<{
2682
+ getLSTAPR(_address: ContractAddr): Promise<number>;
2683
+ netAPY(): Promise<{
2684
+ net: number;
2685
+ splits: {
2686
+ apy: number;
2687
+ id: string;
2688
+ }[];
2689
+ }>;
2690
+ maxNewDeposits(params?: {
2691
+ isAPYComputation: boolean;
2692
+ }): Promise<number>;
2693
+ protected getUnusedBalanceAPY(): Promise<{
2694
+ apy: number;
2695
+ weight: number;
2696
+ }>;
2697
+ getAUM(unrealizedAUM?: boolean): Promise<{
2698
+ net: SingleTokenInfo;
2699
+ prevAum: Web3Number;
2700
+ splits: PositionInfo[];
2701
+ }>;
2702
+ getTVLUnrealized(): Promise<{
2155
2703
  net: SingleTokenInfo;
2156
2704
  prevAum: Web3Number;
2157
2705
  splits: PositionInfo[];
2158
2706
  }>;
2707
+ getUserUnrealizedGains(user: ContractAddr): Promise<{
2708
+ unrealizedGains: Web3Number;
2709
+ userShare: number;
2710
+ tokenInfo: TokenInfo;
2711
+ }>;
2712
+ getUserPositionCards(input: UserPositionCardsInput): Promise<UserPositionCard[]>;
2159
2713
  }
2160
2714
  declare const AUDIT_URL = "https://docs.troves.fi/p/security#starknet-vault-kit";
2161
2715
  declare function getFAQs(lstSymbol: string, underlyingSymbol: string, isLST: boolean): FAQ[];
@@ -2163,514 +2717,237 @@ declare const _riskFactor: RiskFactor[];
2163
2717
  declare function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string): string[];
2164
2718
  declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
2165
2719
 
2166
- declare abstract class Operations {
2167
- abstract shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<Call[]>;
2168
- abstract shouldInvest(): Promise<{
2169
- shouldInvest: boolean;
2170
- vesuAmount: Web3Number;
2171
- extendedAmount: Web3Number;
2172
- extendedLeverage: number;
2173
- vesuLeverage: number;
2174
- }>;
2175
- abstract moveAssets(params: {
2176
- from: string;
2177
- to: string;
2178
- amount: Web3Number;
2179
- }, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<{
2180
- calls: Call[];
2181
- status: boolean;
2182
- }>;
2183
- abstract handleDeposit(): Promise<{
2184
- extendedAmountInBTC: Web3Number;
2185
- calls: Call[];
2186
- }>;
2187
- abstract handleWithdraw(amount: Web3Number): Promise<{
2188
- calls: Call[];
2189
- status: boolean;
2190
- }>;
2191
- }
2192
-
2193
- interface VesuExtendedStrategySettings extends UniversalStrategySettings {
2194
- underlyingToken: TokenInfo;
2195
- borrowable_assets: TokenInfo[];
2196
- targetHealthFactor: number;
2197
- quoteAmountToFetchPrice: Web3Number;
2198
- minHealthFactor: number;
2199
- aumOracle: ContractAddr;
2200
- minimumWBTCDifferenceForAvnuSwap: number;
2720
+ interface BoostedxSTRKCarryStrategySettings extends UniversalStrategySettings {
2721
+ depositToken: TokenInfo;
2722
+ debtToken: TokenInfo;
2723
+ lstHyperToken: TokenInfo;
2724
+ vesuPoolId: ContractAddr;
2725
+ maxLTV: number;
2726
+ targetLTV: number;
2727
+ hyperLstVaultAddress: ContractAddr;
2728
+ hyperLstRedeemNFT: ContractAddr;
2729
+ trovesStrategyId: string;
2730
+ hasBtcFiRewards: boolean;
2731
+ adapterIds?: {
2732
+ vesu: string;
2733
+ avnu: string;
2734
+ hyper: string;
2735
+ transfer: string;
2736
+ };
2201
2737
  }
2202
- declare class VesuExtendedMultiplierStrategy<S extends VesuExtendedStrategySettings> extends SVKStrategy<S> implements Operations {
2738
+ declare class BoostedxSTRKCarryStrategy<S extends BoostedxSTRKCarryStrategySettings> extends SVKStrategy<S> {
2203
2739
  constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
2204
2740
  getTag(): string;
2205
- getAssetPrices(): Promise<{
2206
- collateralPrice: PriceInfo;
2207
- debtPrice: PriceInfo;
2208
- }>;
2209
- getUnusedBalanceUSDCE(): Promise<SingleTokenInfo>;
2210
- getUnusedBalanceWBTC(): Promise<SingleTokenInfo>;
2211
- getVesuAdapter(): Promise<VesuMultiplyAdapter | null>;
2212
- getAvnuAdapter(): Promise<AvnuAdapter | null>;
2213
- getExtendedAdapter(): Promise<ExtendedAdapter | null>;
2214
- moveAssetsToVaultAllocator(amount: Web3Number, extendedAdapter: ExtendedAdapter): Promise<Call[]>;
2215
- shouldInvest(): Promise<{
2216
- shouldInvest: boolean;
2217
- vesuAmount: Web3Number;
2218
- extendedAmount: Web3Number;
2219
- extendedLeverage: number;
2220
- collateralPrice: number;
2221
- debtPrice: number;
2222
- vesuLeverage: number;
2223
- }>;
2224
- shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<Call[]>;
2225
- moveAssets(params: {
2741
+ private getAdapterById;
2742
+ private getTruePriceForToken;
2743
+ getMinOutputAmountLSTBuy(amountInUnderlying: Web3Number): Promise<Web3Number>;
2744
+ getMinOutputAmountLSTSell(amountInLST: Web3Number): Promise<Web3Number>;
2745
+ getVesuModifyPositionCall(params: {
2746
+ isDeposit: boolean;
2747
+ leg1DepositAmount: Web3Number;
2748
+ debtAmount?: Web3Number;
2749
+ }): Promise<Call>;
2750
+ getVesuPositions(): Promise<VaultPosition[]>;
2751
+ getVesuHealthFactor(blockNumber?: BlockIdentifier): Promise<number>;
2752
+ getModifyHyperPositionCall(params: {
2753
+ isDeposit: boolean;
2226
2754
  amount: Web3Number;
2227
- from: string;
2228
- to: string;
2229
- }, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<{
2230
- calls: Call[];
2231
- status: boolean;
2232
- }>;
2233
- handleDeposit(): Promise<{
2234
- extendedAmountInBTC: Web3Number;
2235
- calls: Call[];
2236
- }>;
2237
- checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter, avnuAdapter: AvnuAdapter): Promise<boolean>;
2238
- handleWithdraw(amount: Web3Number): Promise<{
2239
- calls: Call[];
2240
- status: boolean;
2755
+ }): Promise<Call>;
2756
+ getAvnuSwapCall(params: {
2757
+ isDeposit: boolean;
2758
+ amount: Web3Number;
2759
+ minAmount?: Web3Number;
2760
+ }): Promise<Call>;
2761
+ /**
2762
+ * Returns the deposit token balance sitting idle inside the vault contract itself.
2763
+ * This balance can offset the required liquidity during withdrawal processing.
2764
+ */
2765
+ getUnusedBalanceVault(): Promise<Web3Number>;
2766
+ /**
2767
+ * Returns the current borrow token balance sitting unused in the vault allocator.
2768
+ * This covers borrow token from prior borrow cycles that hasn't been swapped yet.
2769
+ */
2770
+ getUnusedDebt(): Promise<Web3Number>;
2771
+ /**
2772
+ * Returns the LST balance sitting in the vault allocator.
2773
+ * This is non-zero when the previous cycle's request_redeem on the HyperPosition
2774
+ * has been settled — the redeemed LST lands here and is ready to be swapped.
2775
+ */
2776
+ getLstInVaultAllocator(): Promise<Web3Number>;
2777
+ /**
2778
+ * Simulates depositing `depositAmount` on Vesu and returns the
2779
+ * incremental borrow token that would be borrowed. Needed to size the AVNU swap
2780
+ * call that is batched together with the Vesu call in the same transaction.
2781
+ */
2782
+ computeVesuDepositBorrowAmount(depositAmount: Web3Number): Promise<Web3Number>;
2783
+ computeVesuWithdrawDebtDelta(withdrawAmount: Web3Number): Promise<Web3Number>;
2784
+ getPendingHyperAssets(): Promise<Web3Number>;
2785
+ getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<{
2786
+ tokenInfo: TokenInfo;
2787
+ amount: Web3Number;
2788
+ usdValue: number;
2241
2789
  }>;
2790
+ getUserPositionCards(input: UserPositionCardsInput): Promise<UserPositionCard[]>;
2242
2791
  getAUM(): Promise<{
2243
2792
  net: SingleTokenInfo;
2244
2793
  prevAum: Web3Number;
2245
2794
  splits: PositionInfo[];
2246
2795
  }>;
2796
+ /**
2797
+ * Get Vesu APYs for collateral and debt positions
2798
+ */
2799
+ getVesuAPYs(): Promise<{
2800
+ baseAPYs: number[];
2801
+ rewardAPYs: number[];
2802
+ positions: VaultPosition[];
2803
+ }>;
2804
+ /**
2805
+ * Get APY from the Hyper LST vault position
2806
+ */
2807
+ getHyperVaultAPY(): Promise<{
2808
+ apy: number;
2809
+ weight: number;
2810
+ }>;
2811
+ /**
2812
+ * Get APY for unused balance (idle funds in vault allocator)
2813
+ */
2814
+ protected getUnusedBalanceAPY(): Promise<{
2815
+ apy: number;
2816
+ weight: number;
2817
+ }>;
2818
+ /**
2819
+ * Compute weighted APY from individual APYs, weights, and total AUM
2820
+ */
2821
+ private computeAPY;
2822
+ /**
2823
+ * Calculate net APY from base and reward APYs
2824
+ */
2825
+ protected returnNetAPY(baseAPYs: number[], rewardAPYs: number[], weights: number[], totalWeightUSD: number): Promise<{
2826
+ net: number;
2827
+ splits: {
2828
+ apy: number;
2829
+ id: string;
2830
+ }[];
2831
+ }>;
2832
+ /**
2833
+ * Calculate net APY across all positions (Vesu, Hyper vault, unused balance)
2834
+ * weighted by USD value
2835
+ */
2836
+ netAPY(): Promise<{
2837
+ net: number;
2838
+ splits: {
2839
+ apy: number;
2840
+ id: string;
2841
+ }[];
2842
+ }>;
2843
+ /**
2844
+ * Calculate future rewards (e.g. BTCFI rewards) contribution to AUM
2845
+ * Similar to universal-strategy.tsx approach
2846
+ */
2847
+ protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
2848
+ getFundManagementCall(params: {
2849
+ isDeposit: boolean;
2850
+ leg1DepositAmount: Web3Number;
2851
+ }): Promise<Call[] | null>;
2247
2852
  }
2248
- declare const VesuExtendedTestStrategies: (extendedBackendUrl: string, extendedApiKey: string, vaultIdExtended: number) => IStrategyMetadata<VesuExtendedStrategySettings>[];
2249
-
2250
- declare const AddressesConfig: {
2251
- readonly tokens: {
2252
- readonly USDC: {
2253
- readonly address: "0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8";
2254
- readonly decimals: 6;
2255
- };
2256
- readonly WBTC: {
2257
- readonly address: "0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac";
2258
- readonly decimals: 8;
2259
- };
2260
- };
2261
- readonly contracts: {
2262
- readonly EXTENDED: "0x062da0780fae50d68cecaa5a051606dc21217ba290969b302db4dd99d2e9b470";
2263
- readonly MULTIPLY: "0x07964760e90baa28841ec94714151e03fbc13321797e68a874e88f27c9d58513";
2264
- };
2265
- readonly wallet: {
2266
- readonly address: string;
2267
- };
2268
- };
2269
- declare const ExtendedConfig: {
2270
- readonly baseUrl: string;
2271
- readonly marketName: "BTC-USD";
2272
- readonly maintenanceMargin: 0.01;
2273
- readonly precision: 5;
2274
- readonly fees: number;
2275
- readonly minPositionSize: 0.0001;
2276
- };
2277
- declare const VesuConfig: {
2278
- readonly poolId: "0x02eef0c13b10b487ea5916b54c0a7f98ec43fb3048f60fdeedaf5b08f6f88aaf";
2279
- readonly maxLtv: 0.8428;
2280
- readonly maxLiquidationRatio: 0.86;
2281
- readonly targetHealthFactor: number;
2282
- readonly ekubo: {
2283
- readonly endpoint: "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_FROM_ADDRESS}}/{{TOKEN_TO_ADDRESS}}";
2284
- readonly priceMaxSlippage: number;
2285
- };
2286
- readonly avnu: {
2287
- readonly api: "https://starknet.api.avnu.fi/swap/v2/quotes";
2288
- };
2289
- readonly minDebtForVesuRebalacing: number;
2290
- };
2291
- declare const AbisConfig: {
2292
- readonly vesu: {
2293
- readonly multiply: ({
2294
- type: string;
2295
- name: string;
2296
- interface_name: string;
2297
- members?: undefined;
2298
- items?: undefined;
2299
- variants?: undefined;
2300
- inputs?: undefined;
2301
- kind?: undefined;
2302
- } | {
2303
- type: string;
2304
- name: string;
2305
- members: {
2306
- name: string;
2307
- type: string;
2308
- }[];
2309
- interface_name?: undefined;
2310
- items?: undefined;
2311
- variants?: undefined;
2312
- inputs?: undefined;
2313
- kind?: undefined;
2314
- } | {
2315
- type: string;
2316
- name: string;
2317
- items: {
2318
- type: string;
2319
- name: string;
2320
- inputs: {
2321
- name: string;
2322
- type: string;
2323
- }[];
2324
- outputs: {
2325
- type: string;
2326
- }[];
2327
- state_mutability: string;
2328
- }[];
2329
- interface_name?: undefined;
2330
- members?: undefined;
2331
- variants?: undefined;
2332
- inputs?: undefined;
2333
- kind?: undefined;
2334
- } | {
2335
- type: string;
2336
- name: string;
2337
- variants: {
2338
- name: string;
2339
- type: string;
2340
- }[];
2341
- interface_name?: undefined;
2342
- members?: undefined;
2343
- items?: undefined;
2344
- inputs?: undefined;
2345
- kind?: undefined;
2346
- } | {
2347
- type: string;
2348
- name: string;
2349
- inputs: {
2350
- name: string;
2351
- type: string;
2352
- }[];
2353
- interface_name?: undefined;
2354
- members?: undefined;
2355
- items?: undefined;
2356
- variants?: undefined;
2357
- kind?: undefined;
2358
- } | {
2359
- type: string;
2360
- name: string;
2361
- kind: string;
2362
- members: {
2363
- name: string;
2364
- type: string;
2365
- kind: string;
2366
- }[];
2367
- interface_name?: undefined;
2368
- items?: undefined;
2369
- variants?: undefined;
2370
- inputs?: undefined;
2371
- } | {
2372
- type: string;
2373
- name: string;
2374
- kind: string;
2375
- variants: {
2376
- name: string;
2377
- type: string;
2378
- kind: string;
2379
- }[];
2380
- interface_name?: undefined;
2381
- members?: undefined;
2382
- items?: undefined;
2383
- inputs?: undefined;
2384
- })[];
2385
- readonly pool: ({
2386
- type: string;
2387
- name: string;
2388
- interface_name: string;
2389
- members?: undefined;
2390
- variants?: undefined;
2391
- items?: undefined;
2392
- inputs?: undefined;
2393
- kind?: undefined;
2394
- } | {
2395
- type: string;
2396
- name: string;
2397
- members: {
2398
- name: string;
2399
- type: string;
2400
- }[];
2401
- interface_name?: undefined;
2402
- variants?: undefined;
2403
- items?: undefined;
2404
- inputs?: undefined;
2405
- kind?: undefined;
2406
- } | {
2407
- type: string;
2408
- name: string;
2409
- variants: {
2410
- name: string;
2411
- type: string;
2412
- }[];
2413
- interface_name?: undefined;
2414
- members?: undefined;
2415
- items?: undefined;
2416
- inputs?: undefined;
2417
- kind?: undefined;
2418
- } | {
2419
- type: string;
2420
- name: string;
2421
- items: {
2422
- type: string;
2423
- name: string;
2424
- inputs: {
2425
- name: string;
2426
- type: string;
2427
- }[];
2428
- outputs: {
2429
- type: string;
2430
- }[];
2431
- state_mutability: string;
2432
- }[];
2433
- interface_name?: undefined;
2434
- members?: undefined;
2435
- variants?: undefined;
2436
- inputs?: undefined;
2437
- kind?: undefined;
2438
- } | {
2439
- type: string;
2440
- name: string;
2441
- inputs: {
2442
- name: string;
2443
- type: string;
2444
- }[];
2445
- interface_name?: undefined;
2446
- members?: undefined;
2447
- variants?: undefined;
2448
- items?: undefined;
2449
- kind?: undefined;
2450
- } | {
2451
- type: string;
2452
- name: string;
2453
- kind: string;
2454
- members: {
2455
- name: string;
2456
- type: string;
2457
- kind: string;
2458
- }[];
2459
- interface_name?: undefined;
2460
- variants?: undefined;
2461
- items?: undefined;
2462
- inputs?: undefined;
2463
- } | {
2464
- type: string;
2465
- name: string;
2466
- kind: string;
2467
- variants: {
2468
- name: string;
2469
- type: string;
2470
- kind: string;
2471
- }[];
2472
- interface_name?: undefined;
2473
- members?: undefined;
2474
- items?: undefined;
2475
- inputs?: undefined;
2476
- })[];
2477
- };
2478
- readonly extended: {
2479
- readonly contract: ({
2480
- type: string;
2481
- name: string;
2482
- interface_name: string;
2483
- members?: undefined;
2484
- variants?: undefined;
2485
- items?: undefined;
2486
- inputs?: undefined;
2487
- kind?: undefined;
2488
- } | {
2489
- type: string;
2490
- name: string;
2491
- members: {
2492
- name: string;
2493
- type: string;
2494
- }[];
2495
- interface_name?: undefined;
2496
- variants?: undefined;
2497
- items?: undefined;
2498
- inputs?: undefined;
2499
- kind?: undefined;
2500
- } | {
2501
- type: string;
2502
- name: string;
2503
- variants: {
2504
- name: string;
2505
- type: string;
2506
- }[];
2507
- interface_name?: undefined;
2508
- members?: undefined;
2509
- items?: undefined;
2510
- inputs?: undefined;
2511
- kind?: undefined;
2512
- } | {
2513
- type: string;
2514
- name: string;
2515
- items: {
2516
- type: string;
2517
- name: string;
2518
- inputs: {
2519
- name: string;
2520
- type: string;
2521
- }[];
2522
- outputs: {
2523
- type: string;
2524
- }[];
2525
- state_mutability: string;
2526
- }[];
2527
- interface_name?: undefined;
2528
- members?: undefined;
2529
- variants?: undefined;
2530
- inputs?: undefined;
2531
- kind?: undefined;
2532
- } | {
2533
- type: string;
2534
- name: string;
2535
- inputs: {
2536
- name: string;
2537
- type: string;
2538
- }[];
2539
- interface_name?: undefined;
2540
- members?: undefined;
2541
- variants?: undefined;
2542
- items?: undefined;
2543
- kind?: undefined;
2544
- } | {
2545
- type: string;
2546
- name: string;
2547
- kind: string;
2548
- members: {
2549
- name: string;
2550
- type: string;
2551
- kind: string;
2552
- }[];
2553
- interface_name?: undefined;
2554
- variants?: undefined;
2555
- items?: undefined;
2556
- inputs?: undefined;
2557
- } | {
2558
- type: string;
2559
- name: string;
2560
- kind: string;
2561
- variants: {
2562
- name: string;
2563
- type: string;
2564
- kind: string;
2565
- }[];
2566
- interface_name?: undefined;
2567
- members?: undefined;
2568
- items?: undefined;
2569
- inputs?: undefined;
2570
- })[];
2571
- };
2572
- };
2853
+ declare const BoostedxSTRKCarryStrategies: IStrategyMetadata<BoostedxSTRKCarryStrategySettings>[];
2573
2854
 
2574
2855
  /**
2575
- * Function to return formatted amount to BigInt
2576
- * Converts a decimal amount to the proper format for blockchain transactions
2577
- * @param {number} amount - The decimal amount to convert
2578
- * @param {number} fromTokenDecimals - The decimal precision of the token
2579
- * @returns {string} The formatted amount as a hexadecimal string
2856
+ * Filter option definition
2857
+ */
2858
+ interface FilterOption {
2859
+ id: string;
2860
+ label: string;
2861
+ icon?: string;
2862
+ }
2863
+ /**
2864
+ * Strategy filter metadata - defines what filters are available
2580
2865
  */
2581
- declare const returnFormattedAmount: (amount: number, toTokenDecimals: number) => string;
2866
+ interface StrategyFilterMetadata {
2867
+ assets: FilterOption[];
2868
+ protocols: FilterOption[];
2869
+ quickFilters: FilterOption[];
2870
+ }
2582
2871
  /**
2583
- * calculates the amount to distribute to Extend and Vesu
2584
- * Determines how much to allocate to each platform based on leverage calculations
2585
- * @param {number} amount - The total amount to distribute
2586
- * @returns {object} Object containing avnu_amount, extended_amount, and extended_leverage
2872
+ * Strategy type enum
2587
2873
  */
2588
- declare const calculateAmountDistribution: (amount: number, client: ExtendedWrapper, marketName: string, collateralPrice: number, debtPrice: number, collateralUnits: Web3Number, extendedPosition: Position[] | null) => Promise<{
2589
- vesu_amount: Web3Number;
2590
- extended_amount: Web3Number;
2591
- extended_leverage: number;
2592
- vesu_leverage: number;
2593
- }>;
2874
+ declare enum StrategyType {
2875
+ EKUBO_CL = "ekubo",
2876
+ UNIVERSAL = "universal",
2877
+ HYPER_LST = "hyper-lst",
2878
+ VESU_REBALANCE = "vesu-rebalance",
2879
+ SENSEI = "sensei",
2880
+ YOLO_VAULT = "yolo-vault",
2881
+ BOOSTEDXSTRKCARRY = "boostedxstrkcarry"
2882
+ }
2594
2883
  /**
2595
- * calculate the amount distribution for withdrawal
2596
- * @param amount - The amount to withdraw
2597
- * @param client - The client
2598
- * @param marketName - The market name
2599
- * @returns {object} Object containing avnu_amount and extended_amount
2884
+ * Strategy metadata extracted from IStrategyMetadata
2600
2885
  */
2601
- declare const calculateAmountDistributionForWithdrawal: (amountInUsdc: Web3Number, collateralPrice: number, collateralUnits: Web3Number, extendedPosition: Position[] | null) => Promise<{
2602
- vesu_amount: Web3Number;
2603
- extended_amount: Web3Number;
2604
- extended_leverage: number;
2605
- vesu_leverage: number;
2606
- } | null>;
2886
+ interface StrategyMetadata {
2887
+ id: string;
2888
+ name: string;
2889
+ type: StrategyType;
2890
+ assets: string[];
2891
+ protocols: string[];
2892
+ tags: string[];
2893
+ curator?: {
2894
+ name: string;
2895
+ logo: string;
2896
+ };
2897
+ isRetired: boolean;
2898
+ }
2607
2899
  /**
2608
- * calculate the leverage required for Avnu
2609
- * calculates the optimal leverage for Avnu based on LTV ratios and price drop protection
2610
- * @returns {number} The calculated leverage value
2900
+ * Strategy registry entry
2611
2901
  */
2612
- declare const calculateVesuLeverage: () => number;
2902
+ interface StrategyRegistryEntry<T = any> {
2903
+ metadata: IStrategyMetadata<T>;
2904
+ type: StrategyType;
2905
+ }
2613
2906
  /**
2614
- * calculate leverage for extended
2615
- * calculates the maximum safe leverage for Extended based on maintenance margin and price drop protection
2616
- * @returns {number} The calculated leverage value
2907
+ * Build strategy registry from SDK strategies
2617
2908
  */
2618
- declare const calculateExtendedLevergae: () => number;
2909
+ declare function buildStrategyRegistry(): StrategyRegistryEntry[];
2619
2910
  /**
2620
- * calculates the debt amount for leverage operations
2621
- * Determines how much debt to add or remove based on collateral changes and target health factor
2622
- * @param {Web3Number} collateralAmount - Current collateral amount
2623
- * @param {Web3Number} debtAmount - Current debt amount
2624
- * @param {number} debtPrice - Current price of the debt token
2625
- * @param {number} maxLtv - Maximum loan-to-value ratio (default: MAX_LTV_BTC_USDC)
2626
- * @param {number} addedAmount - Amount being added to collateral
2627
- * @param {number} collateralPrice - Current price of the collateral token
2628
- * @param {boolean} isDeposit - Whether this is a deposit (true) or withdrawal (false)
2629
- * @returns {object} Object containing deltadebtAmountUnits and isIncrease flag
2911
+ * Get all strategy metadata from registry
2630
2912
  */
2631
- declare const calculateDebtAmount: (collateralAmount: Web3Number, debtAmount: Web3Number, debtPrice: number, maxLtv: number | undefined, addedAmount: Web3Number, // this is in btc
2632
- collateralPrice: number, isDeposit: boolean) => {
2633
- deltadebtAmountUnits: Web3Number;
2634
- isIncrease: boolean;
2635
- } | {
2636
- deltadebtAmountUnits: null;
2637
- isIncrease: null;
2638
- };
2913
+ declare function getAllStrategyMetadata(): StrategyMetadata[];
2639
2914
  /**
2640
- * calculate the debt amount to be repaid for withdrawal
2641
- * @param debtAmount in debt units
2642
- * @param collateralAmount in collateral units
2643
- * @param maxLtv in percentage
2644
- * @param withdrawalAmount in collateral units
2645
- * @param collateralPrice in usd
2646
- * @param debtPrice in usd
2647
- * @returns deltadebtAmountUnits in debt units
2648
- * isIncrease: true if the debt amount is increasing, false if it is decreasing
2915
+ * Get filter metadata - defines available filters and their options
2649
2916
  */
2650
- declare const calculateDebtReductionAmountForWithdrawal: (debtAmount: Web3Number, collateralAmount: Web3Number, maxLtv: number | undefined, withdrawalAmount: Web3Number, collateralPrice: number, debtPrice: number, usdcDecimals: number) => {
2651
- deltadebtAmountUnits: string;
2652
- } | {
2653
- deltadebtAmountUnits: null;
2654
- };
2917
+ declare function getFilterMetadata(): StrategyFilterMetadata;
2655
2918
  /**
2656
- * calculate the amount to deposit on extended when incurring losses
2657
- * @param client - The client
2658
- * @returns The amount to deposit on extended when incurring losses
2919
+ * Get live strategies (filter out retired)
2659
2920
  */
2660
- declare const calculateAmountDepositOnExtendedWhenIncurringLosses: (client: ExtendedWrapper) => Promise<Web3Number | null>;
2661
- declare const calculateExposureDelta: (exposure_extended: number, exposure_vesu: number) => number;
2921
+ declare function getLiveStrategies(): StrategyRegistryEntry[];
2662
2922
  /**
2663
- * calculate the delta percentage between the current btc price and the last btc price
2664
- * @param {number} btcPrice - The current btc price
2665
- * @param {number} lastBtcPrice - The last btc price
2666
- * @returns {number} The delta percentage
2923
+ * Get strategies by type
2667
2924
  */
2668
- declare const calculateBTCPriceDelta: (btcPrice: number, lastBtcPrice: number) => number;
2669
- declare const calculateVesUPositionSizeGivenExtended: (extendedPositonValue: number, extendedHoldingAmount: Web3Number, collateralAmount: Web3Number, collateralPrice: number) => {
2670
- vesuAmountInUsd: string;
2671
- vesuAmountInBTC: Web3Number;
2672
- extendedAmountInBTC: Web3Number;
2673
- };
2925
+ declare function getStrategiesByType(type: StrategyType): StrategyRegistryEntry[];
2926
+
2927
+ declare enum FactoryStrategyType {
2928
+ UNIVERSAL = "UNIVERSAL",
2929
+ EKUBO_CL = "EKUBO_CL",
2930
+ HYPER_LST = "HYPER_LST",
2931
+ VESU_REBALANCE = "VESU_REBALANCE",
2932
+ SENSEI = "SENSEI",
2933
+ YOLO_VAULT = "YOLO_VAULT",
2934
+ BOOSTEDXSTRKCARRY = "BOOSTEDXSTRKCARRY"
2935
+ }
2936
+ declare function createUniversalStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<UniversalStrategySettings>): UniversalStrategy<UniversalStrategySettings>;
2937
+ declare function createEkuboCLStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>): EkuboCLVault;
2938
+ declare function createYoloVaultStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<YoloVaultSettings>): YoLoVault;
2939
+ declare function createHyperLSTStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<HyperLSTStrategySettings>): UniversalLstMultiplierStrategy<HyperLSTStrategySettings>;
2940
+ declare function createVesuRebalanceStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>): VesuRebalance;
2941
+ declare function createSenseiStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>): SenseiVault;
2942
+ declare function createBoostedXSTRKCarryStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<BoostedxSTRKCarryStrategySettings>): BoostedxSTRKCarryStrategy<BoostedxSTRKCarryStrategySettings>;
2943
+ /**
2944
+ * Determines the strategy type from metadata by inspecting the additionalInfo structure
2945
+ */
2946
+ declare function getStrategyTypeFromMetadata(metadata: IStrategyMetadata<any>): FactoryStrategyType;
2947
+ /**
2948
+ * Generic factory function that creates SDK strategy instances based on type
2949
+ */
2950
+ declare function createStrategy(type: FactoryStrategyType, config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<any>): EkuboCLVault | VesuRebalance | SenseiVault | YoLoVault | UniversalStrategy<UniversalStrategySettings> | UniversalLstMultiplierStrategy<HyperLSTStrategySettings> | BoostedxSTRKCarryStrategy<BoostedxSTRKCarryStrategySettings>;
2674
2951
 
2675
2952
  interface EkuboRouteNode {
2676
2953
  pool_key: {
@@ -2698,14 +2975,23 @@ declare class EkuboQuoter {
2698
2975
  ENDPOINT: string;
2699
2976
  tokenMarketData: TokenMarketData;
2700
2977
  constructor(config: IConfig, pricer: PricerBase);
2978
+ private _callQuoterApi;
2701
2979
  /**
2702
- *
2703
- * @param fromToken
2704
- * @param toToken
2705
- * @param amount Can be negative too, which would mean to get exact amount out
2706
- * @returns
2980
+ * Given exactly `inputAmount` of `fromToken`, how much `toToken` do I receive?
2981
+ * @param fromToken - address of the token being sold
2982
+ * @param toToken - address of the token being bought
2983
+ * @param inputAmount - must be positive (the amount of fromToken to sell)
2984
+ * @returns EkuboQuote where `total_calculated` is the output amount (positive)
2985
+ */
2986
+ getQuoteExactInput(fromToken: string, toToken: string, inputAmount: Web3Number): Promise<EkuboQuote>;
2987
+ /**
2988
+ * To receive exactly `outputAmount` of `toToken`, how much `fromToken` must I provide?
2989
+ * @param fromToken - address of the token being sold
2990
+ * @param toToken - address of the token being bought
2991
+ * @param outputAmount - must be positive (the desired amount of toToken to receive)
2992
+ * @returns EkuboQuote where `total_calculated` is the required input amount (negative per Ekubo convention)
2707
2993
  */
2708
- getQuote(fromToken: string, toToken: string, amount: Web3Number, retry?: number): Promise<EkuboQuote>;
2994
+ getQuoteExactOutput(fromToken: string, toToken: string, outputAmount: Web3Number): Promise<EkuboQuote>;
2709
2995
  getDexPrice(baseToken: TokenInfo, quoteToken: TokenInfo, amount: Web3Number): Promise<number>;
2710
2996
  getLSTTrueExchangeRate(baseToken: TokenInfo, quoteToken: TokenInfo, amount: Web3Number): Promise<number>;
2711
2997
  getSwapLimitAmount(fromToken: TokenInfo, toToken: TokenInfo, amount: Web3Number, max_slippage?: number): Promise<Web3Number>;
@@ -2735,6 +3021,7 @@ declare class Global {
2735
3021
  static getDefaultTokens(): TokenInfo[];
2736
3022
  static getTokens(): Promise<TokenInfo[]>;
2737
3023
  static assert(condition: any, message: string): void;
3024
+ static getTokenInfoFromName(tokenName: string): Promise<TokenInfo>;
2738
3025
  static getTokenInfoFromAddr(addr: ContractAddr): Promise<TokenInfo>;
2739
3026
  static setGlobalCache(key: string, data: any, ttl?: number): void;
2740
3027
  static getGlobalCache<T>(key: string): T | null;
@@ -2867,6 +3154,16 @@ declare class Midas {
2867
3154
  } | number>;
2868
3155
  }
2869
3156
 
3157
+ declare class EkuboPricer extends PricerBase {
3158
+ EKUBO_PRICE_FETCHER_ADDRESS: string;
3159
+ readonly contract: Contract;
3160
+ private readonly USDC_ADDRESS;
3161
+ private readonly USDC_DECIMALS;
3162
+ constructor(config: IConfig, tokens: TokenInfo[]);
3163
+ private div2Power128;
3164
+ getPrice(tokenAddr: string, blockIdentifier?: BlockIdentifier): Promise<PriceInfo>;
3165
+ }
3166
+
2870
3167
  declare class TelegramNotif {
2871
3168
  private subscribers;
2872
3169
  readonly bot: TelegramBot;
@@ -2903,7 +3200,7 @@ declare class PricerRedis extends Pricer {
2903
3200
  /** sets current local price in redis */
2904
3201
  private _setRedisPrices;
2905
3202
  /** Returns price from redis */
2906
- getPrice(tokenSymbol: string): Promise<PriceInfo>;
3203
+ getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
2907
3204
  }
2908
3205
 
2909
3206
  declare function getAPIUsingHeadlessBrowser(url: string): Promise<any>;
@@ -2930,6 +3227,7 @@ declare function executeDeployCalls(contractsInfo: DeployContractResult[], acc:
2930
3227
  declare function executeTransactions(calls: Call[], acc: Account, provider: RpcProvider, remarks?: string): Promise<{
2931
3228
  transaction_hash: string;
2932
3229
  }>;
3230
+ declare function myWaitForTransaction(transaction_hash: string, provider: RpcProvider, retry?: number): Promise<boolean>;
2933
3231
  declare const Deployer: {
2934
3232
  getAccount: typeof getAccount;
2935
3233
  myDeclare: typeof myDeclare;
@@ -2937,6 +3235,7 @@ declare const Deployer: {
2937
3235
  prepareMultiDeployContracts: typeof prepareMultiDeployContracts;
2938
3236
  executeDeployCalls: typeof executeDeployCalls;
2939
3237
  executeTransactions: typeof executeTransactions;
3238
+ myWaitForTransaction: typeof myWaitForTransaction;
2940
3239
  };
2941
3240
 
2942
3241
  /**
@@ -3017,4 +3316,4 @@ declare class PasswordJsonCryptoUtil {
3017
3316
  decrypt(encryptedData: string, password: string): any;
3018
3317
  }
3019
3318
 
3020
- export { type APYInfo, APYType, AUDIT_URL, AUMTypes, AVNU_EXCHANGE, AVNU_EXCHANGE_FOR_LEGACY_USDC, AVNU_LEGACY_SANITIZER, AVNU_MIDDLEWARE, AVNU_QUOTE_URL, AbisConfig, type AccountInfo, type AdapterLeafType, AddressesConfig, type AllAccountsStore, type ApiResponse, type ApproveCallParams, type AssetOperation, AssetOperationStatus, AssetOperationType, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, type Balance, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type CLVaultStrategySettings, type CancelOrderRequest, CommonAdapter, type CommonAdapterConfig, ContractAddr, type CreateOrderRequest, type DecreaseLeverParams, Deployer, type DepositParams, type DualActionAmount, type DualTokenInfo, ERC20, EXTENDED_CONTRACT, EXTENDED_SANITIZER, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, ExitType, ExtendedAdapter, type ExtendedAdapterConfig, type ExtendedApiResponse, ExtendedConfig, ExtendedWrapper, type ExtendedWrapperConfig, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type FundingRate, type GenerateCallFn, Global, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, type L2Config, LSTAPRService, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, type Market, type MarketStats, Midas, Network, type OpenOrder, OrderSide, OrderStatus, OrderStatusReason, OrderType, PRICE_ROUTER, PasswordJsonCryptoUtil, type PlacedOrder, type Position, type PositionAPY, type PositionAmount, type PositionHistory, type PositionInfo, PositionSide, Pragma, type PriceInfo, Pricer, PricerBase, PricerFromApi, PricerLST, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, type RiskFactorConfig, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SettlementSignature, type SignedWithdrawRequest, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, type StarkDebuggingOrderAmounts, type StarkSettlement, Store, type StoreConfig, type SupportedPosition, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, TimeInForce, type TokenAmount, type TokenInfo, TokenMarketData, type TradingConfig, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, type UniversalStrategySettings, UnusedBalanceAdapter, type UnusedBalanceAdapterConfig, type UpdateLeverageRequest, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, VesuConfig, type VesuDefiSpringRewardsCallParams, VesuExtendedMultiplierStrategy, type VesuExtendedStrategySettings, VesuExtendedTestStrategies, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, VesuMultiplyAdapter, type VesuMultiplyAdapterConfig, type VesuMultiplyCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, VesuSupplyOnlyAdapter, type VesuSupplyOnlyAdapterConfig, Web3Number, type WithdrawParams, type WithdrawRequest, ZkLend, _riskFactor, assert, calculateAmountDepositOnExtendedWhenIncurringLosses, calculateAmountDistribution, calculateAmountDistributionForWithdrawal, calculateBTCPriceDelta, calculateDebtAmount, calculateDebtReductionAmountForWithdrawal, calculateExposureDelta, calculateExtendedLevergae, calculateVesUPositionSizeGivenExtended, calculateVesuLeverage, extensionMap, getAPIUsingHeadlessBrowser, getContractDetails, getDefaultStoreConfig, getFAQs, getInvestmentSteps, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, logger, returnFormattedAmount, toBigInt };
3319
+ export { type APYInfo, APYType, AUDIT_URL, AUMTypes, AVNU_EXCHANGE, AVNU_EXCHANGE_FOR_LEGACY_USDC, AVNU_LEGACY_SANITIZER, AVNU_MIDDLEWARE, AVNU_QUOTE_URL, type AccessControlInfo, AccessControlType, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type AmountInfo, type AmountsInfo, type ApproveCallParams, AuditStatus, AutoCompounderSTRK, AvnuAdapter, type AvnuAdapterConfig, type AvnuDepositParams, type AvnuSwapCallParams, type AvnuWithdrawParams, AvnuWrapper, BaseAdapter, type BaseAdapterConfig, BaseStrategy, BoostedxSTRKCarryStrategies, BoostedxSTRKCarryStrategy, type BoostedxSTRKCarryStrategySettings, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, DEFAULT_TROVES_STRATEGIES_API, type DecreaseLeverParams, Deployer, type DepositParams, type DualActionAmount, type DualTokenInfo, ERC20, EXTENDED_CONTRACT, EXTENDED_SANITIZER, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, EkuboPricer, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FactoryStrategyType, FatalError, type FeeBps, type FilterOption, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HealthFactorMath, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type ICurator, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, type InputModeFromAction, InstantWithdrawalVault, LSTAPRService, LSTPriceType, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type LoggerConfig, type LoggerLevel, type ManageCall, MarginType, Midas, MyNumber, type NetAPYDetails, type NetAPYSplit, Network, PRICE_ROUTER, type ParsedStarknetCall, PasswordJsonCryptoUtil, type PositionAPY, type PositionAmount, type PositionInfo, PositionTypeAvnuExtended, Pragma, type PriceInfo, Pricer, PricerAvnuApi, PricerBase, PricerFromApi, PricerLST, PricerRedis, Protocols, type RedemptionInfo, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SVK_SIMPLE_SANITIZER, type SecurityMetadata, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, type SourceCodeInfo, SourceCodeType, StandardMerkleTree, type StandardMerkleTreeData, StarknetCallParser, type StarknetCallParserOptions, Store, type StoreConfig, type StrategyAlert, type StrategyApyHistoryUIConfig, type StrategyCapabilities, type StrategyFilterMetadata, type StrategyInputMode, StrategyLiveStatus, type StrategyMetadata, type StrategyRegistryEntry, type StrategySettings, StrategyTag, StrategyType, type SupportedPosition, SvkTrovesAdapter, type SvkTrovesAdapterConfig, type Swap, type SwapInfo, type SwapPriceInfo, TRANSFER_SANITIZER, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, TokenMarketData, TokenTransferAdapter, type TokenTransferAdapterConfig, UNIVERSAL_ADAPTER_IDS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, UnwrapLabsCurator, type UserPositionCard, type UserPositionCardSubValueColor, type UserPositionCardsInput, type UserYoloInfo, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VaultType, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuDepositParams, type VesuModifyDelegationCallParams, VesuModifyPositionAdapter, type VesuModifyPositionAdapterConfig, type VesuModifyPositionCallParams, type VesuModifyPositionDepositParams, type VesuModifyPositionWithdrawParams, VesuMultiplyAdapter, type VesuMultiplyAdapterConfig, type VesuMultiplyCallParams, VesuPoolMetadata, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, VesuSupplyOnlyAdapter, type VesuSupplyOnlyAdapterConfig, type VesuWithdrawParams, Web3Number, type WithdrawParams, YoLoVault, type YoloSettings, type YoloSpendingLevel, type YoloVaultSettings, type YoloVaultStatus, YoloVaultStrategies, ZkLend, _riskFactor, assert, buildStrategyRegistry, configureLogger, createBoostedXSTRKCarryStrategy, createEkuboCLStrategy, createHyperLSTStrategy, createSenseiStrategy, createStrategy, createUniversalStrategy, createVesuRebalanceStrategy, createYoloVaultStrategy, detectCapabilities, extensionMap, getAPIUsingHeadlessBrowser, getAllStrategyMetadata, getAllStrategyTags, getContractDetails, getDefaultStoreConfig, getFAQs, getFilterMetadata, getInvestmentSteps, getLiveStrategies, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getStrategiesByType, getStrategyTagDesciption, getStrategyTypeFromMetadata, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, isDualTokenStrategy, logger, toAmountsInfo, toBigInt };