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

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