@strkfarm/sdk 2.0.0-dev.9 → 2.0.0-staging.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/index.browser.global.js +111371 -93151
  2. package/dist/index.browser.mjs +27815 -32690
  3. package/dist/index.d.ts +1095 -2011
  4. package/dist/index.js +27425 -32309
  5. package/dist/index.mjs +27590 -32452
  6. package/package.json +6 -5
  7. package/src/data/ekubo-price-fethcer.abi.json +265 -0
  8. package/src/data/universal-vault.abi.json +20 -135
  9. package/src/dataTypes/address.ts +0 -7
  10. package/src/dataTypes/index.ts +3 -2
  11. package/src/dataTypes/mynumber.ts +141 -0
  12. package/src/global.ts +296 -288
  13. package/src/index.browser.ts +6 -5
  14. package/src/interfaces/common.tsx +324 -184
  15. package/src/modules/apollo-client-config.ts +28 -0
  16. package/src/modules/avnu.ts +4 -17
  17. package/src/modules/ekubo-pricer.ts +79 -0
  18. package/src/modules/ekubo-quoter.ts +11 -88
  19. package/src/modules/erc20.ts +21 -67
  20. package/src/modules/harvests.ts +26 -15
  21. package/src/modules/index.ts +11 -13
  22. package/src/modules/lst-apr.ts +0 -36
  23. package/src/modules/pragma.ts +23 -8
  24. package/src/modules/pricer-from-api.ts +150 -14
  25. package/src/modules/pricer.ts +2 -1
  26. package/src/modules/pricerBase.ts +2 -1
  27. package/src/node/deployer.ts +36 -1
  28. package/src/node/pricer-redis.ts +2 -1
  29. package/src/strategies/autoCompounderStrk.ts +1 -1
  30. package/src/strategies/base-strategy.ts +5 -22
  31. package/src/strategies/ekubo-cl-vault.tsx +2904 -2175
  32. package/src/strategies/factory.ts +165 -0
  33. package/src/strategies/index.ts +10 -11
  34. package/src/strategies/registry.ts +268 -0
  35. package/src/strategies/sensei.ts +416 -292
  36. package/src/strategies/universal-adapters/adapter-utils.ts +1 -5
  37. package/src/strategies/universal-adapters/baseAdapter.ts +153 -181
  38. package/src/strategies/universal-adapters/common-adapter.ts +77 -98
  39. package/src/strategies/universal-adapters/index.ts +1 -5
  40. package/src/strategies/universal-adapters/vesu-adapter.ts +218 -220
  41. package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +51 -58
  42. package/src/strategies/universal-lst-muliplier-strategy.tsx +1952 -992
  43. package/src/strategies/universal-strategy.tsx +1713 -1150
  44. package/src/strategies/vesu-rebalance.tsx +1189 -986
  45. package/src/utils/health-factor-math.ts +5 -11
  46. package/src/utils/index.ts +8 -9
  47. package/src/utils/strategy-utils.ts +57 -0
  48. package/src/data/extended-deposit.abi.json +0 -3613
  49. package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
  50. package/src/modules/ExtendedWrapperSDk/types.ts +0 -311
  51. package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -395
  52. package/src/modules/midas.ts +0 -159
  53. package/src/modules/token-market-data.ts +0 -202
  54. package/src/strategies/svk-strategy.ts +0 -247
  55. package/src/strategies/universal-adapters/adapter-optimizer.ts +0 -65
  56. package/src/strategies/universal-adapters/avnu-adapter.ts +0 -413
  57. package/src/strategies/universal-adapters/extended-adapter.ts +0 -972
  58. package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
  59. package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +0 -1306
  60. package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -34
  61. package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -77
  62. package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -49
  63. package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -370
  64. package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1379
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import * as starknet from 'starknet';
3
- import { RpcProvider, BlockIdentifier, Contract, Call, Account, CairoCustomEnum, Uint256, RawArgs } from 'starknet';
3
+ import { RpcProvider, BlockIdentifier, Contract, Uint256, Call, Account, CairoCustomEnum, RawArgs } from 'starknet';
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 {
@@ -51,7 +51,33 @@ declare class ContractAddr {
51
51
  static eqString(a: string, b: string): boolean;
52
52
  toString(): string;
53
53
  toBigInt(): bigint;
54
- shortString(left?: number, right?: number): string;
54
+ }
55
+
56
+ declare const customInspectSymbol: unique symbol;
57
+ declare class MyNumber {
58
+ bigNumber: BigNumber;
59
+ decimals: number;
60
+ constructor(bigNumber: string, decimals: number);
61
+ static fromEther(num: string, decimals: number): MyNumber;
62
+ static fromZero(): MyNumber;
63
+ toString(): string;
64
+ toEtherStr(): string;
65
+ toFixedStr(decimals: number): string;
66
+ toEtherToFixedDecimals(decimals: number): string;
67
+ isZero(): boolean;
68
+ /**
69
+ *
70
+ * @param amountEther in token terms without decimal e.g. 1 for 1 STRK
71
+ * @param command BigNumber compare funds. e.g. gte, gt, lt
72
+ * @returns
73
+ * @dev Add more commands as needed
74
+ */
75
+ compare(amountEther: string, command: "gte" | "gt" | "lt"): boolean;
76
+ operate(command: "div" | "plus" | "mul", value: string | number): MyNumber;
77
+ subtract(value: MyNumber): MyNumber;
78
+ static min(a: MyNumber, b: MyNumber): MyNumber;
79
+ static max(a: MyNumber, b: MyNumber): MyNumber;
80
+ [customInspectSymbol](depth: any, inspectOptions: any, inspect: any): string;
55
81
  }
56
82
 
57
83
  declare enum RiskType {
@@ -97,6 +123,50 @@ interface IProtocol {
97
123
  name: string;
98
124
  logo: string;
99
125
  }
126
+ declare enum StrategyCategory {
127
+ ALL = "all",
128
+ BTC = "btc",
129
+ META_VAULTS = "meta-vaults"
130
+ }
131
+ declare enum AuditStatus {
132
+ AUDITED = "Audited",
133
+ NOT_AUDITED = "Not Audited"
134
+ }
135
+ declare enum SourceCodeType {
136
+ OPEN_SOURCE = "Open Source",
137
+ CLOSED_SOURCE = "Closed Source"
138
+ }
139
+ declare enum AccessControlType {
140
+ MULTISIG_ACCOUNT = "Multisig Account",
141
+ STANDARD_ACCOUNT = "Standard Account"
142
+ }
143
+ declare enum InstantWithdrawalVault {
144
+ YES = "Yes",
145
+ NO = "No"
146
+ }
147
+ interface SourceCodeInfo {
148
+ type: SourceCodeType;
149
+ contractLink: string;
150
+ }
151
+ interface AccessControlInfo {
152
+ type: AccessControlType;
153
+ addresses: ContractAddr[];
154
+ timeLock: string;
155
+ }
156
+ interface SecurityMetadata {
157
+ auditStatus: AuditStatus;
158
+ sourceCode: SourceCodeInfo;
159
+ accessControl: AccessControlInfo;
160
+ }
161
+ interface RedemptionExpectedTime {
162
+ upto1M: string;
163
+ upto10M: string;
164
+ above10M: string;
165
+ }
166
+ interface RedemptionInfo {
167
+ instantWithdrawalVault: InstantWithdrawalVault;
168
+ expectedRedemptionTime?: RedemptionExpectedTime;
169
+ }
100
170
  declare enum FlowChartColors {
101
171
  Green = "purple",
102
172
  Blue = "#35484f",
@@ -106,11 +176,63 @@ interface FAQ {
106
176
  question: string | React.ReactNode;
107
177
  answer: string | React.ReactNode;
108
178
  }
179
+ /**
180
+ * Strategy Live Status - indicates the current state of a strategy
181
+ */
182
+ declare enum StrategyLiveStatus {
183
+ ACTIVE = "Active",
184
+ NEW = "New",
185
+ COMING_SOON = "Coming Soon",
186
+ RETIRED = "Retired",
187
+ HOT = "Hot & New \uD83D\uDD25"
188
+ }
189
+ /**
190
+ * Strategy Tags - used for filtering and categorization
191
+ */
192
+ declare enum StrategyTag {
193
+ EKUBO = "Ekubo",
194
+ EVERGREEN = "Evergreen",
195
+ HYPER_LST = "Hyper-LST",
196
+ VESU = "Vesu",
197
+ SENSEI = "Sensei",
198
+ ENDUR = "Endur",
199
+ BTC = "BTC"
200
+ }
201
+ /**
202
+ * Strategy Alert - informational or warning messages for users
203
+ */
204
+ interface StrategyAlert {
205
+ type: "warning" | "info";
206
+ text: string | React.ReactNode;
207
+ tab: "all" | "deposit" | "withdraw";
208
+ }
209
+ /**
210
+ * Strategy Settings - configuration and UI settings for strategies
211
+ */
212
+ interface StrategySettings {
213
+ maxTVL?: Web3Number;
214
+ liveStatus?: StrategyLiveStatus;
215
+ isPaused?: boolean;
216
+ isInMaintenance?: boolean;
217
+ isAudited: boolean;
218
+ isInstantWithdrawal?: boolean;
219
+ hideHarvestInfo?: boolean;
220
+ is_promoted?: boolean;
221
+ isTransactionHistDisabled?: boolean;
222
+ quoteToken: TokenInfo;
223
+ hideNetEarnings?: boolean;
224
+ showWithdrawalWarningModal?: boolean;
225
+ alerts?: StrategyAlert[];
226
+ tags?: StrategyTag[];
227
+ }
109
228
  /**
110
229
  * @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
111
230
  * @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
231
+ * @property security - Security-related metadata including audit status, source code information, and access control details.
232
+ * @property redemptionInfo - Redemption information including instant withdrawal availability and expected redemption times.
112
233
  */
113
234
  interface IStrategyMetadata<T> {
235
+ id: string;
114
236
  name: string;
115
237
  description: string | React.ReactNode;
116
238
  address: ContractAddr;
@@ -119,7 +241,6 @@ interface IStrategyMetadata<T> {
119
241
  depositTokens: TokenInfo[];
120
242
  protocols: IProtocol[];
121
243
  auditUrl?: string;
122
- maxTVL: Web3Number;
123
244
  risk: {
124
245
  riskFactor: RiskFactor[];
125
246
  netRisk: number;
@@ -145,6 +266,30 @@ interface IStrategyMetadata<T> {
145
266
  logo: string;
146
267
  };
147
268
  isPreview?: boolean;
269
+ category?: StrategyCategory;
270
+ tags?: StrategyTag[];
271
+ security?: SecurityMetadata;
272
+ redemptionInfo?: RedemptionInfo;
273
+ settings?: StrategySettings;
274
+ actions?: Array<{
275
+ name?: string;
276
+ pool?: {
277
+ protocol?: {
278
+ name: string;
279
+ logo: string;
280
+ };
281
+ pool?: {
282
+ name: string;
283
+ logos?: string[];
284
+ };
285
+ apr?: number;
286
+ borrow?: {
287
+ apr?: number;
288
+ };
289
+ };
290
+ amount?: string | number;
291
+ isDeposit?: boolean;
292
+ }>;
148
293
  }
149
294
  interface IInvestmentFlow {
150
295
  id?: string;
@@ -170,16 +315,32 @@ interface VaultPosition {
170
315
  usdValue: number;
171
316
  token: TokenInfo;
172
317
  remarks: string;
173
- protocol: IProtocol;
318
+ }
319
+ interface AmountInfo {
320
+ amount: Web3Number;
321
+ usdValue: number;
322
+ tokenInfo: TokenInfo;
323
+ }
324
+ interface AmountsInfo {
325
+ usdValue: number;
326
+ amounts: AmountInfo[];
327
+ }
328
+ /**
329
+ * Strategy capabilities interface
330
+ * Describes what optional methods a strategy instance supports
331
+ */
332
+ interface StrategyCapabilities {
333
+ hasMatchInputAmounts: boolean;
334
+ hasNetAPY: boolean;
335
+ hasGetInvestmentFlows: boolean;
336
+ hasGetPendingRewards: boolean;
337
+ hasHarvest: boolean;
338
+ hasRebalance: boolean;
174
339
  }
175
340
  declare const Protocols: {
176
- NONE: IProtocol;
177
341
  VESU: IProtocol;
178
342
  ENDUR: IProtocol;
179
343
  EXTENDED: IProtocol;
180
- EKUBO: IProtocol;
181
- AVNU: IProtocol;
182
- VAULT: IProtocol;
183
344
  };
184
345
 
185
346
  interface ILendingMetadata {
@@ -258,7 +419,7 @@ declare class Pricer extends PricerBase {
258
419
  start(): void;
259
420
  isStale(timestamp: Date, tokenName: string): boolean;
260
421
  assertNotStale(timestamp: Date, tokenName: string): void;
261
- getPrice(tokenSymbol: string): Promise<PriceInfo>;
422
+ getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
262
423
  protected _loadPrices(onUpdate?: (tokenSymbol: string) => void): void;
263
424
  _getPrice(token: TokenInfo, defaultMethod?: string): Promise<number>;
264
425
  _getPriceCoinbase(token: TokenInfo): Promise<number>;
@@ -270,7 +431,140 @@ declare abstract class PricerBase {
270
431
  readonly config: IConfig;
271
432
  readonly tokens: TokenInfo[];
272
433
  constructor(config: IConfig, tokens: TokenInfo[]);
273
- getPrice(tokenSymbol: string): Promise<PriceInfo>;
434
+ getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
435
+ }
436
+
437
+ declare class Pragma extends PricerBase {
438
+ contractAddr: string;
439
+ readonly contract: Contract;
440
+ constructor(config: IConfig, tokens: TokenInfo[]);
441
+ getPrice(tokenAddr: string, blockIdentifier?: BlockIdentifier): Promise<PriceInfo>;
442
+ }
443
+
444
+ declare class ZkLend extends ILending implements ILending {
445
+ readonly pricer: Pricer;
446
+ static readonly POOLS_URL = "https://app.zklend.com/api/pools";
447
+ private POSITION_URL;
448
+ constructor(config: IConfig, pricer: Pricer);
449
+ init(): Promise<void>;
450
+ /**
451
+ * @description Get the health factor of the user for given lending and debt tokens
452
+ * @param lending_tokens
453
+ * @param debt_tokens
454
+ * @param user
455
+ * @returns hf (e.g. returns 1.5 for 150% health factor)
456
+ */
457
+ get_health_factor_tokenwise(lending_tokens: TokenInfo[], debt_tokens: TokenInfo[], user: ContractAddr): Promise<number>;
458
+ /**
459
+ * @description Get the health factor of the user
460
+ * - Considers all tokens for collateral and debt
461
+ */
462
+ get_health_factor(user: ContractAddr): Promise<number>;
463
+ getPositionsSummary(user: ContractAddr): Promise<{
464
+ collateralUSD: number;
465
+ debtUSD: number;
466
+ }>;
467
+ /**
468
+ * @description Get the token-wise collateral and debt positions of the user
469
+ * @param user Contract address of the user
470
+ * @returns Promise<ILendingPosition[]>
471
+ */
472
+ getPositions(user: ContractAddr): Promise<ILendingPosition[]>;
473
+ }
474
+
475
+ declare class PricerFromApi extends PricerBase {
476
+ private apolloClient;
477
+ private pragma;
478
+ private ekuboPricer;
479
+ private readonly PRAGMA_SUPPORTED_TOKENS;
480
+ constructor(config: IConfig, tokens: TokenInfo[]);
481
+ getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
482
+ getPriceFromMyAPI(tokenSymbol: string): Promise<{
483
+ price: number;
484
+ timestamp: Date;
485
+ }>;
486
+ /**
487
+ * Fetches historical price for a token at a specific block number
488
+ * @param tokenSymbol - The token symbol to get price for
489
+ * @param blockNumber - The block number to query
490
+ * @returns PriceInfo with price at the closest block <= blockNumber
491
+ */
492
+ getHistoricalPrice(tokenSymbol: string, blockNumber: BlockIdentifier): Promise<PriceInfo>;
493
+ }
494
+
495
+ declare class ERC20 {
496
+ readonly config: IConfig;
497
+ constructor(config: IConfig);
498
+ contract(addr: string | ContractAddr): Contract;
499
+ balanceOf(token: string | ContractAddr, address: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
500
+ allowance(token: string | ContractAddr, owner: string | ContractAddr, spender: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
501
+ }
502
+
503
+ interface Route {
504
+ token_from: string;
505
+ token_to: string;
506
+ exchange_address: string;
507
+ percent: number;
508
+ additional_swap_params: string[];
509
+ }
510
+ interface SwapInfo {
511
+ token_from_address: string;
512
+ token_from_amount: Uint256;
513
+ token_to_address: string;
514
+ token_to_amount: Uint256;
515
+ token_to_min_amount: Uint256;
516
+ beneficiary: string;
517
+ integrator_fee_amount_bps: number;
518
+ integrator_fee_recipient: string;
519
+ routes: Route[];
520
+ }
521
+ declare class AvnuWrapper {
522
+ getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number, excludeSources?: string[]): Promise<Quote>;
523
+ getSwapInfo(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount?: string, options?: AvnuOptions): Promise<SwapInfo>;
524
+ static buildZeroSwap(tokenToSell: ContractAddr, beneficiary: string, tokenToBuy?: ContractAddr): SwapInfo;
525
+ }
526
+
527
+ declare class AutoCompounderSTRK {
528
+ readonly config: IConfig;
529
+ readonly addr: ContractAddr;
530
+ readonly pricer: Pricer;
531
+ private initialized;
532
+ contract: Contract | null;
533
+ readonly metadata: {
534
+ decimals: number;
535
+ underlying: {
536
+ address: ContractAddr;
537
+ name: string;
538
+ symbol: string;
539
+ };
540
+ name: string;
541
+ };
542
+ constructor(config: IConfig, pricer: Pricer);
543
+ init(): Promise<void>;
544
+ waitForInitilisation(): Promise<void>;
545
+ /** Returns shares of user */
546
+ balanceOf(user: ContractAddr): Promise<Web3Number>;
547
+ /** Returns underlying assets of user */
548
+ balanceOfUnderlying(user: ContractAddr): Promise<Web3Number>;
549
+ /** Returns usd value of assets */
550
+ usdBalanceOfUnderlying(user: ContractAddr): Promise<{
551
+ usd: Web3Number;
552
+ assets: Web3Number;
553
+ }>;
554
+ }
555
+
556
+ interface HarvestInfo {
557
+ rewardsContract: ContractAddr;
558
+ token: ContractAddr;
559
+ startDate: Date;
560
+ endDate: Date;
561
+ claim: {
562
+ id: number;
563
+ amount: Web3Number;
564
+ claimee: ContractAddr;
565
+ };
566
+ actualReward: Web3Number;
567
+ proof: string[];
274
568
  }
275
569
 
276
570
  interface CacheData$1 {
@@ -285,275 +579,291 @@ declare class CacheClass {
285
579
  isCacheValid(key: string): boolean;
286
580
  }
287
581
 
288
- interface LeveledLogMethod {
289
- (message: string, ...meta: any[]): void;
290
- (message: any): void;
582
+ interface SingleActionAmount {
583
+ tokenInfo: TokenInfo;
584
+ amount: Web3Number;
291
585
  }
292
- interface MyLogger {
293
- error: LeveledLogMethod;
294
- warn: LeveledLogMethod;
295
- info: LeveledLogMethod;
296
- verbose: LeveledLogMethod;
297
- debug: LeveledLogMethod;
586
+ interface SingleTokenInfo extends SingleActionAmount {
587
+ usdValue: number;
298
588
  }
299
- declare const logger: MyLogger;
300
-
301
- interface LeafData {
302
- id: bigint;
303
- readableId: string;
304
- data: bigint[];
589
+ interface DualActionAmount {
590
+ token0: SingleActionAmount;
591
+ token1: SingleActionAmount;
305
592
  }
306
- interface StandardMerkleTreeData<T extends any> extends MerkleTreeData<T> {
307
- format: 'standard-v1';
308
- leafEncoding: ValueType[];
593
+ interface DualTokenInfo {
594
+ usdValue: number;
595
+ token0: SingleTokenInfo;
596
+ token1: SingleTokenInfo;
309
597
  }
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>;
598
+ interface CacheData {
599
+ timestamp: number;
600
+ ttl: number;
601
+ data: any;
602
+ }
603
+ declare class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
604
+ readonly config: IConfig;
605
+ readonly cache: Map<string, CacheData>;
606
+ constructor(config: IConfig);
607
+ getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<TVLInfo>;
608
+ getTVL(): Promise<TVLInfo>;
609
+ depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Promise<Call[]>;
610
+ withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
611
+ getVaultPositions(): Promise<VaultPosition[]>;
612
+ getPendingRewards(): Promise<HarvestInfo[]>;
319
613
  }
320
614
 
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
- };
615
+ interface PoolProps {
616
+ pool_id: ContractAddr;
617
+ max_weight: number;
618
+ v_token: ContractAddr;
337
619
  }
338
- interface DepositParams {
339
- amount: Web3Number;
620
+ interface Change {
621
+ pool_id: ContractAddr;
622
+ changeAmt: Web3Number;
623
+ finalAmt: Web3Number;
624
+ isDeposit: boolean;
340
625
  }
341
- interface WithdrawParams {
342
- amount: Web3Number;
626
+ interface VesuRebalanceSettings {
627
+ feeBps: number;
343
628
  }
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"
354
- }
355
- interface SupportedPosition {
356
- asset: TokenInfo;
357
- isDebt: boolean;
358
- }
359
- interface BaseAdapterConfig {
360
- baseToken: TokenInfo;
361
- supportedPositions: SupportedPosition[];
362
- networkConfig: IConfig;
363
- pricer: PricerBase;
364
- vaultAllocator: ContractAddr;
365
- vaultAddress: ContractAddr;
366
- }
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 = {
629
+ interface PoolInfoFull {
630
+ pool_id: ContractAddr;
631
+ pool_name: string | undefined;
632
+ max_weight: number;
633
+ current_weight: number;
634
+ v_token: ContractAddr;
380
635
  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);
636
+ usdValue: Web3Number;
637
+ APY: {
638
+ baseApy: number;
639
+ defiSpringApy: number;
640
+ netApy: number;
641
+ };
642
+ currentUtilization: number;
643
+ maxUtilization: number;
644
+ }
645
+ /**
646
+ * Represents a VesuRebalance strategy.
647
+ * This class implements an automated rebalancing strategy for Vesu pools,
648
+ * managing deposits and withdrawals while optimizing yield through STRK rewards.
649
+ */
650
+ declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
651
+ /** Contract address of the strategy */
652
+ readonly address: ContractAddr;
653
+ /** Pricer instance for token price calculations */
654
+ readonly pricer: PricerBase;
655
+ /** Metadata containing strategy information */
656
+ readonly metadata: IStrategyMetadata<VesuRebalanceSettings>;
657
+ /** Contract instance for interacting with the strategy */
658
+ readonly contract: Contract;
659
+ readonly BASE_WEIGHT = 10000;
388
660
  /**
389
- * Loop through all supported positions and return amount, usd value, remarks and apy for each
661
+ * Creates a new VesuRebalance strategy instance.
662
+ * @param config - Configuration object containing provider and other settings
663
+ * @param pricer - Pricer instance for token price calculations
664
+ * @param metadata - Strategy metadata including deposit tokens and address
665
+ * @throws {Error} If more than one deposit token is specified
390
666
  */
391
- getPositions(): Promise<PositionInfo[]>;
667
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>);
392
668
  /**
393
- * Implemented by child adapters to compute APY for a given supported position
669
+ * Creates a deposit call to the strategy contract.
670
+ * @param assets - Amount of assets to deposit
671
+ * @param receiver - Address that will receive the strategy tokens
672
+ * @returns Populated contract call for deposit
394
673
  */
395
- protected abstract getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
674
+ depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<starknet.Call[]>;
396
675
  /**
397
- * Implemented by child adapters to fetch amount for a given supported position
676
+ * Creates a withdrawal call to the strategy contract.
677
+ * @param assets - Amount of assets to withdraw
678
+ * @param receiver - Address that will receive the withdrawn assets
679
+ * @param owner - Address that owns the strategy tokens
680
+ * @returns Populated contract call for withdrawal
398
681
  */
399
- protected abstract getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
682
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<starknet.Call[]>;
400
683
  /**
401
- * Implemented by child adapters to calculate maximum deposit positions
402
- * @param amount Optional amount in baseToken to deposit
684
+ * Returns the underlying asset token of the strategy.
685
+ * @returns The deposit token supported by this strategy
403
686
  */
404
- abstract maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
687
+ asset(): TokenInfo;
405
688
  /**
406
- * Implemented by child adapters to calculate maximum withdraw positions
689
+ * Returns the number of decimals used by the strategy token.
690
+ * @returns Number of decimals (same as the underlying token)
407
691
  */
408
- abstract maxWithdraw(): Promise<PositionInfo>;
692
+ decimals(): number;
409
693
  /**
410
- * Uses pricer to convert an amount of an asset to USD value
694
+ * Calculates the Total Value Locked (TVL) for a specific user.
695
+ * @param user - Address of the user
696
+ * @param blockIdentifier - Block identifier for the query
697
+ * @returns Object containing the amount in token units and USD value
411
698
  */
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;
699
+ getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<{
700
+ tokenInfo: TokenInfo;
701
+ amount: Web3Number;
702
+ usdValue: number;
703
+ }>;
419
704
  /**
420
- * Implementor must provide target/method/packedArguments/sanitizer for deposit leaf construction
705
+ * Calculates user realized APY based on trueSharesBasedAPY method.
706
+ * Returns the APY as a number.
421
707
  */
422
- protected abstract _getDepositLeaf(): {
423
- target: ContractAddr;
424
- method: string;
425
- packedArguments: bigint[];
426
- sanitizer: ContractAddr;
427
- id: string;
428
- }[];
708
+ getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
429
709
  /**
430
- * Implementor must provide target/method/packedArguments/sanitizer for withdraw leaf construction
710
+ * Calculates the total TVL of the strategy.
711
+ * @returns Object containing the total amount in token units and USD value
431
712
  */
432
- protected abstract _getWithdrawLeaf(): {
433
- target: ContractAddr;
434
- method: string;
435
- packedArguments: bigint[];
436
- sanitizer: ContractAddr;
437
- id: string;
438
- }[];
713
+ getTVL(): Promise<SingleTokenInfo>;
714
+ static getAllPossibleVerifiedPools(asset: ContractAddr): Promise<any>;
715
+ getPoolInfo(p: PoolProps, pools: any[], vesuPositions: any[], totalAssets: Web3Number, isErrorPositionsAPI: boolean, isErrorPoolsAPI: boolean): Promise<{
716
+ pool_id: ContractAddr;
717
+ pool_name: any;
718
+ max_weight: number;
719
+ current_weight: number;
720
+ v_token: ContractAddr;
721
+ amount: Web3Number;
722
+ usdValue: Web3Number;
723
+ APY: {
724
+ baseApy: number;
725
+ defiSpringApy: number;
726
+ netApy: number;
727
+ };
728
+ currentUtilization: number;
729
+ maxUtilization: number;
730
+ }>;
731
+ /**
732
+ * Retrieves the list of allowed pools and their detailed information from multiple sources:
733
+ * 1. Contract's allowed pools
734
+ * 2. Vesu positions API for current positions
735
+ * 3. Vesu pools API for APY and utilization data
736
+ *
737
+ * @returns {Promise<{
738
+ * data: Array<PoolInfoFull>,
739
+ * isErrorPositionsAPI: boolean
740
+ * }>} Object containing:
741
+ * - data: Array of pool information including IDs, weights, amounts, APYs and utilization
742
+ * - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
743
+ */
744
+ getPools(): Promise<{
745
+ data: {
746
+ pool_id: ContractAddr;
747
+ pool_name: any;
748
+ max_weight: number;
749
+ current_weight: number;
750
+ v_token: ContractAddr;
751
+ amount: Web3Number;
752
+ usdValue: Web3Number;
753
+ APY: {
754
+ baseApy: number;
755
+ defiSpringApy: number;
756
+ netApy: number;
757
+ };
758
+ currentUtilization: number;
759
+ maxUtilization: number;
760
+ }[];
761
+ isErrorPositionsAPI: boolean;
762
+ isErrorPoolsAPI: boolean;
763
+ isError: boolean;
764
+ }>;
765
+ getVesuPools(retry?: number): Promise<{
766
+ pools: any[];
767
+ isErrorPoolsAPI: boolean;
768
+ }>;
439
769
  /**
440
- * Returns deposit leaf adapter using configured proof id
770
+ * Calculates the weighted average APY across all pools based on USD value.
771
+ * @returns {Promise<number>} The weighted average APY across all pools
441
772
  */
442
- getDepositLeaf(): AdapterLeafType<DepositParams>;
773
+ netAPY(): Promise<number>;
443
774
  /**
444
- * Returns withdraw leaf adapter using configured proof id
775
+ * Calculates the weighted average APY across all pools based on USD value.
776
+ * @returns {Promise<number>} The weighted average APY across all pools
445
777
  */
446
- getWithdrawLeaf(): AdapterLeafType<WithdrawParams>;
778
+ netAPYGivenPools(pools: PoolInfoFull[]): Promise<number>;
447
779
  /**
448
- * Implementor must provide deposit call
449
- * @param params
780
+ * Calculates optimal position changes to maximize APY while respecting max weights.
781
+ * The algorithm:
782
+ * 1. Sorts pools by APY (highest first)
783
+ * 2. Calculates target amounts based on max weights
784
+ * 3. For each pool that needs more funds:
785
+ * - Takes funds from lowest APY pools that are over their target
786
+ * 4. Validates that total assets remain constant
787
+ *
788
+ * @returns {Promise<{
789
+ * changes: Change[],
790
+ * finalPools: PoolInfoFull[],
791
+ * isAnyPoolOverMaxWeight: boolean
792
+ * }>} Object containing:
793
+ * - changes: Array of position changes
794
+ * - finalPools: Array of pool information after rebalance
795
+ * @throws Error if rebalance is not possible while maintaining constraints
796
+ */
797
+ getRebalancedPositions(_pools?: PoolInfoFull[]): Promise<{
798
+ changes: never[];
799
+ finalPools: never[];
800
+ isAnyPoolOverMaxWeight?: undefined;
801
+ } | {
802
+ changes: Change[];
803
+ finalPools: PoolInfoFull[];
804
+ isAnyPoolOverMaxWeight: boolean;
805
+ }>;
806
+ /**
807
+ * Creates a rebalance Call object for the strategy contract
808
+ * @param pools - Array of pool information including IDs, weights, amounts, APYs and utilization
809
+ * @returns Populated contract call for rebalance
450
810
  */
451
- abstract getDepositCall(params: DepositParams): Promise<ManageCall[]>;
811
+ getRebalanceCall(pools: Awaited<ReturnType<typeof this.getRebalancedPositions>>["changes"], isOverWeightAdjustment: boolean): Promise<starknet.Call | null>;
812
+ getInvestmentFlows(pools: PoolInfoFull[]): Promise<IInvestmentFlow[]>;
813
+ getPendingRewards(): Promise<HarvestInfo[]>;
814
+ harvest(acc: Account): Promise<starknet.Call[]>;
452
815
  /**
453
- * Implementor must provide withdraw call
454
- * @param params
816
+ * Calculates the fees deducted in different vTokens based on the current and previous state.
817
+ * @param previousTotalSupply - The total supply of the strategy token before the transaction
818
+ * @returns {Promise<Array<{ vToken: ContractAddr, fee: Web3Number }>>} Array of fees deducted in different vTokens
455
819
  */
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>;
820
+ getFee(allowedPools: Array<PoolInfoFull>): Promise<Array<{
821
+ vToken: ContractAddr;
822
+ fee: Web3Number;
823
+ }>>;
463
824
  }
825
+ /**
826
+ * Represents the Vesu Rebalance Strategies.
827
+ */
828
+ declare const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[];
464
829
 
465
- interface FlashloanCallParams {
466
- amount: Web3Number;
467
- data: bigint[];
830
+ interface EkuboPoolKey {
831
+ token0: ContractAddr;
832
+ token1: ContractAddr;
833
+ fee: string;
834
+ tick_spacing: string;
835
+ extension: string;
468
836
  }
469
- interface ApproveCallParams {
837
+ interface EkuboBounds {
838
+ lowerTick: bigint;
839
+ upperTick: bigint;
840
+ }
841
+ interface FeeHistory {
842
+ date: string;
843
+ tokenInfo: TokenInfo;
470
844
  amount: Web3Number;
471
845
  }
472
- interface AvnuSwapCallParams {
473
- props: SwapInfo;
474
- }
475
- interface CommonAdapterConfig {
476
- id: string;
477
- vaultAddress: ContractAddr;
478
- vaultAllocator: ContractAddr;
479
- manager: ContractAddr;
480
- asset: ContractAddr;
481
- }
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>;
504
- }
505
-
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;
515
- };
516
- actualReward: Web3Number;
517
- proof: string[];
518
- }
519
-
520
- interface EkuboPoolKey {
521
- token0: ContractAddr;
522
- token1: ContractAddr;
523
- fee: string;
524
- tick_spacing: string;
525
- extension: string;
526
- }
527
- interface EkuboBounds {
528
- lowerTick: bigint;
529
- upperTick: bigint;
530
- }
531
- interface FeeHistory {
532
- date: string;
533
- tokenInfo: TokenInfo;
534
- amount: Web3Number;
535
- }
536
- /**
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
542
- */
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;
846
+ /**
847
+ * Settings for the CLVaultStrategy
848
+ *
849
+ * @property newBounds - The new bounds for the strategy
850
+ * @property newBounds.lower - relative to the current tick
851
+ * @property newBounds.upper - relative to the current tick
852
+ */
853
+ interface CLVaultStrategySettings {
854
+ newBounds: {
855
+ lower: number;
856
+ upper: number;
857
+ } | string;
858
+ lstContract?: ContractAddr;
859
+ truePrice?: number;
860
+ feeBps: number;
861
+ rebalanceConditions: {
862
+ minWaitHours: number;
863
+ direction: "any" | "uponly";
864
+ customShouldRebalance: (currentPoolPrice: number) => Promise<boolean>;
865
+ };
866
+ quoteAsset: TokenInfo;
557
867
  }
558
868
  declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
559
869
  /** Contract address of the strategy */
@@ -571,11 +881,11 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
571
881
  poolKey: EkuboPoolKey | undefined;
572
882
  readonly avnu: AvnuWrapper;
573
883
  /**
574
- * Creates a new VesuRebalance strategy instance.
884
+ * Creates a new EkuboCLVault strategy instance.
575
885
  * @param config - Configuration object containing provider and other settings
576
886
  * @param pricer - Pricer instance for token price calculations
577
887
  * @param metadata - Strategy metadata including deposit tokens and address
578
- * @throws {Error} If more than one deposit token is specified
888
+ * @throws {Error} If more than two deposit tokens are specified
579
889
  */
580
890
  constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>);
581
891
  matchInputAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
@@ -587,17 +897,23 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
587
897
  rebalanceCall(newBounds: EkuboBounds, swapParams: SwapInfo): Call[];
588
898
  handleUnusedCall(swapParams: SwapInfo): Call[];
589
899
  handleFeesCall(): Call[];
590
- getFeeHistory(timePeriod?: '24h' | '7d' | '30d' | '3m'): Promise<{
900
+ getFeeHistory(timePeriod?: "24h" | "7d" | "30d" | "3m"): Promise<{
591
901
  summary: DualTokenInfo;
592
902
  history: FeeHistory[];
593
903
  }>;
594
904
  netSharesBasedTrueAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
595
- feeBasedAPY(timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<number>;
905
+ /**
906
+ * Calculates realized APY based on TVL per share growth, always valued in USDC.
907
+ * This is a vault-level metric (same for all users) and works for all strategies,
908
+ * regardless of quote asset configuration.
909
+ */
910
+ getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
911
+ feeBasedAPY(timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number>;
596
912
  /**
597
913
  * Calculates assets before and now in a given token of TVL per share to observe growth
598
914
  * @returns {Promise<number>} The weighted average APY across all pools
599
915
  */
600
- netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<APYInfo>;
916
+ netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number>;
601
917
  getHarvestRewardShares(fromBlock: number, toBlock: number): Promise<Web3Number>;
602
918
  balanceOf(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<Web3Number>;
603
919
  getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<DualTokenInfo>;
@@ -705,7 +1021,8 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
705
1021
  amount0: Web3Number;
706
1022
  amount1: Web3Number;
707
1023
  }>;
708
- harvest(acc: Account, maxIterations?: number, priceRatioPrecision?: number): Promise<Call[]>;
1024
+ getPendingRewards(): Promise<HarvestInfo[]>;
1025
+ harvest(acc: Account, maxIterations?: number, priceRatioPrecision?: number, minRewardAmount?: Web3Number): Promise<Call[]>;
709
1026
  /**
710
1027
  * @description This funciton requires atleast one of the pool tokens to be reward token
711
1028
  * i.e. STRK.
@@ -754,6 +1071,190 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
754
1071
  */
755
1072
  declare const EkuboCLVaultStrategies: IStrategyMetadata<CLVaultStrategySettings>[];
756
1073
 
1074
+ interface SenseiVaultSettings {
1075
+ mainToken: TokenInfo;
1076
+ secondaryToken: TokenInfo;
1077
+ targetHfBps: number;
1078
+ feeBps: number;
1079
+ }
1080
+ declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
1081
+ readonly address: ContractAddr;
1082
+ readonly metadata: IStrategyMetadata<SenseiVaultSettings>;
1083
+ readonly pricer: PricerBase;
1084
+ readonly contract: Contract;
1085
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>);
1086
+ getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<SingleTokenInfo>;
1087
+ getTVL(): Promise<SingleTokenInfo>;
1088
+ depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
1089
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1090
+ getPositionInfo(): Promise<{
1091
+ collateralXSTRK: Web3Number;
1092
+ collateralUSDValue: Web3Number;
1093
+ debtSTRK: Web3Number;
1094
+ debtUSDValue: Web3Number;
1095
+ xSTRKPrice: number;
1096
+ collateralInSTRK: number;
1097
+ }>;
1098
+ getSecondaryTokenPriceRelativeToMain(retry?: number): Promise<number>;
1099
+ getSettings: () => Promise<starknet.CallResult>;
1100
+ }
1101
+ declare const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[];
1102
+
1103
+ interface LeveledLogMethod {
1104
+ (message: string, ...meta: any[]): void;
1105
+ (message: any): void;
1106
+ }
1107
+ interface MyLogger {
1108
+ error: LeveledLogMethod;
1109
+ warn: LeveledLogMethod;
1110
+ info: LeveledLogMethod;
1111
+ verbose: LeveledLogMethod;
1112
+ debug: LeveledLogMethod;
1113
+ }
1114
+ declare const logger: MyLogger;
1115
+
1116
+ interface LeafData {
1117
+ id: bigint;
1118
+ readableId: string;
1119
+ data: bigint[];
1120
+ }
1121
+ interface StandardMerkleTreeData<T extends any> extends MerkleTreeData<T> {
1122
+ format: 'standard-v1';
1123
+ leafEncoding: ValueType[];
1124
+ }
1125
+ declare class StandardMerkleTree extends MerkleTreeImpl<LeafData> {
1126
+ protected readonly tree: HexString[];
1127
+ protected readonly values: StandardMerkleTreeData<LeafData>['values'];
1128
+ protected readonly leafEncoding: ValueType[];
1129
+ protected constructor(tree: HexString[], values: StandardMerkleTreeData<LeafData>['values'], leafEncoding: ValueType[]);
1130
+ static of(values: LeafData[], leafEncoding?: ValueType[], options?: MerkleTreeOptions): StandardMerkleTree;
1131
+ static verify<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], leaf: T, proof: BytesLike[]): boolean;
1132
+ static verifyMultiProof<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], multiproof: MultiProof<BytesLike, T>): boolean;
1133
+ dump(): StandardMerkleTreeData<LeafData>;
1134
+ }
1135
+
1136
+ /**
1137
+ * Convert SDK TVL info (SingleTokenInfo or DualTokenInfo) to client AmountsInfo format
1138
+ */
1139
+ declare function toAmountsInfo(tvlInfo: SingleTokenInfo | DualTokenInfo): Omit<AmountsInfo, "amounts"> & {
1140
+ amounts: Array<{
1141
+ amount: Web3Number;
1142
+ tokenInfo: TokenInfo;
1143
+ }>;
1144
+ };
1145
+ /**
1146
+ * Detect what capabilities a strategy instance has
1147
+ */
1148
+ declare function detectCapabilities(strategy: BaseStrategy<any, any>): StrategyCapabilities;
1149
+ /**
1150
+ * Check if a strategy is a dual-token strategy
1151
+ */
1152
+ declare function isDualTokenStrategy(strategy: BaseStrategy<any, any>): boolean;
1153
+
1154
+ type RequiredFields<T> = {
1155
+ [K in keyof T]-?: T[K];
1156
+ };
1157
+ type RequiredKeys<T> = {
1158
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
1159
+ }[keyof T];
1160
+ declare function assert(condition: boolean, message: string): void;
1161
+ declare function getTrovesEndpoint(): string;
1162
+
1163
+ interface ManageCall {
1164
+ sanitizer: ContractAddr;
1165
+ call: {
1166
+ contractAddress: ContractAddr;
1167
+ selector: string;
1168
+ calldata: bigint[];
1169
+ };
1170
+ }
1171
+ type GenerateCallFn<T> = (params: T) => ManageCall;
1172
+ type AdapterLeafType<T> = {
1173
+ leaf: LeafData;
1174
+ callConstructor: GenerateCallFn<T>;
1175
+ };
1176
+ type LeafAdapterFn<T> = () => AdapterLeafType<T>;
1177
+ declare enum APYType {
1178
+ BASE = "base",
1179
+ REWARD = "reward",
1180
+ LST = "lst"
1181
+ }
1182
+ interface SupportedPosition {
1183
+ asset: TokenInfo;
1184
+ isDebt: boolean;
1185
+ }
1186
+ interface BaseAdapterConfig {
1187
+ baseToken: TokenInfo;
1188
+ supportedPositions: SupportedPosition[];
1189
+ networkConfig: IConfig;
1190
+ pricer: PricerBase;
1191
+ vaultAllocator: ContractAddr;
1192
+ vaultAddress: ContractAddr;
1193
+ }
1194
+ type PositionAPY = {
1195
+ apy: number;
1196
+ type: APYType;
1197
+ };
1198
+ type PositionInfo = {
1199
+ amount: Web3Number;
1200
+ usdValue: number;
1201
+ remarks?: string;
1202
+ apy: PositionAPY;
1203
+ };
1204
+ declare abstract class BaseAdapter extends CacheClass {
1205
+ constructor();
1206
+ protected constructSimpleLeafData(params: {
1207
+ id: string;
1208
+ target: ContractAddr;
1209
+ method: string;
1210
+ packedArguments: bigint[];
1211
+ }, sanitizer?: ContractAddr): LeafData;
1212
+ }
1213
+
1214
+ interface FlashloanCallParams {
1215
+ amount: Web3Number;
1216
+ data: bigint[];
1217
+ }
1218
+ interface ApproveCallParams {
1219
+ amount: Web3Number;
1220
+ }
1221
+ interface AvnuSwapCallParams {
1222
+ props: SwapInfo;
1223
+ }
1224
+ interface CommonAdapterConfig {
1225
+ id: string;
1226
+ vaultAddress: ContractAddr;
1227
+ vaultAllocator: ContractAddr;
1228
+ manager: ContractAddr;
1229
+ asset: ContractAddr;
1230
+ }
1231
+ declare class CommonAdapter extends BaseAdapter {
1232
+ config: CommonAdapterConfig;
1233
+ constructor(config: CommonAdapterConfig);
1234
+ getFlashloanAdapter(): AdapterLeafType<FlashloanCallParams>;
1235
+ getFlashloanCall(params: FlashloanCallParams): ManageCall;
1236
+ getApproveAdapter(token: ContractAddr, spender: ContractAddr, id: string): () => AdapterLeafType<ApproveCallParams>;
1237
+ getApproveCall(token: ContractAddr, spender: ContractAddr): (params: ApproveCallParams) => {
1238
+ sanitizer: ContractAddr;
1239
+ call: {
1240
+ contractAddress: ContractAddr;
1241
+ selector: string;
1242
+ calldata: bigint[];
1243
+ };
1244
+ };
1245
+ getBringLiquidityAdapter(id: string): () => AdapterLeafType<ApproveCallParams>;
1246
+ getBringLiquidityCall(): (params: ApproveCallParams) => {
1247
+ sanitizer: ContractAddr;
1248
+ call: {
1249
+ contractAddress: ContractAddr;
1250
+ selector: string;
1251
+ calldata: bigint[];
1252
+ };
1253
+ };
1254
+ getAvnuAdapter(fromToken: ContractAddr, toToken: ContractAddr, id: string, isMiddleware: boolean): () => AdapterLeafType<AvnuSwapCallParams>;
1255
+ getAvnuCall(fromToken: ContractAddr, toToken: ContractAddr, isMiddleware: boolean): GenerateCallFn<AvnuSwapCallParams>;
1256
+ }
1257
+
757
1258
  interface VesuPoolsInfo {
758
1259
  pools: any[];
759
1260
  isErrorPoolsAPI: boolean;
@@ -851,7 +1352,6 @@ declare const VesuPools: {
851
1352
  Genesis: ContractAddr;
852
1353
  Re7xSTRK: ContractAddr;
853
1354
  Re7xBTC: ContractAddr;
854
- Re7USDCPrime: ContractAddr;
855
1355
  };
856
1356
  declare const extensionMap: {
857
1357
  [key: string]: ContractAddr;
@@ -860,14 +1360,44 @@ declare function getVesuSingletonAddress(vesuPool: ContractAddr): {
860
1360
  addr: ContractAddr;
861
1361
  isV2: boolean;
862
1362
  };
863
- declare class VesuAdapter extends CacheClass {
1363
+ declare class VesuAdapter extends BaseAdapter {
864
1364
  VESU_MULTIPLY_V1: ContractAddr;
865
1365
  VESU_MULTIPLY: ContractAddr;
866
1366
  config: VesuAdapterConfig;
867
1367
  networkConfig: IConfig | undefined;
868
1368
  pricer: PricerBase | undefined;
869
1369
  constructor(config: VesuAdapterConfig);
1370
+ getModifyPosition: () => AdapterLeafType<VesuModifyPositionCallParams>;
1371
+ static getDefaultModifyPositionCallParams(params: {
1372
+ collateralAmount: Web3Number;
1373
+ isAddCollateral: boolean;
1374
+ debtAmount: Web3Number;
1375
+ isBorrow: boolean;
1376
+ }): {
1377
+ collateralAmount: {
1378
+ amount_type: VesuAmountType;
1379
+ denomination: VesuAmountDenomination;
1380
+ value: {
1381
+ abs: Web3Number;
1382
+ is_negative: boolean;
1383
+ };
1384
+ };
1385
+ debtAmount: {
1386
+ amount_type: VesuAmountType;
1387
+ denomination: VesuAmountDenomination;
1388
+ value: {
1389
+ abs: Web3Number;
1390
+ is_negative: boolean;
1391
+ };
1392
+ };
1393
+ };
1394
+ getModifyPositionCall: (params: VesuModifyPositionCallParams) => ManageCall;
1395
+ getMultiplyAdapter: (id: string) => LeafAdapterFn<VesuMultiplyCallParams>;
1396
+ getMultiplyCall: (params: VesuMultiplyCallParams) => ManageCall;
1397
+ getVesuModifyDelegationAdapter: (id: string) => LeafAdapterFn<VesuModifyDelegationCallParams>;
870
1398
  getVesuModifyDelegationCall: (params: VesuModifyDelegationCallParams) => ManageCall;
1399
+ getDefispringRewardsAdapter: (id: string) => () => AdapterLeafType<VesuDefiSpringRewardsCallParams>;
1400
+ getDefiSpringClaimCall: () => GenerateCallFn<VesuDefiSpringRewardsCallParams>;
871
1401
  formatAmountTypeEnum(amountType: VesuAmountType): CairoCustomEnum;
872
1402
  formatAmountDenominationEnum(denomination: VesuAmountDenomination): CairoCustomEnum;
873
1403
  getVesuSingletonContract(config: IConfig, poolId: ContractAddr): {
@@ -906,1112 +1436,15 @@ declare class VesuAdapter extends CacheClass {
906
1436
  getMaxUtilizationGivenRatePerSecond(interestRateConfig: InterestRateConfig, ratePerSecond: bigint, timeDelta: bigint, last_full_utilization_rate: bigint): bigint;
907
1437
  }
908
1438
 
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>;
939
- }
940
-
941
- interface VesuMultiplyAdapterConfig extends BaseAdapterConfig {
942
- poolId: ContractAddr;
943
- collateral: TokenInfo;
944
- debt: TokenInfo;
945
- targetHealthFactor: number;
946
- minHealthFactor: number;
947
- quoteAmountToFetchPrice: Web3Number;
948
- minimumVesuMovementAmount: number;
949
- }
950
- declare class VesuMultiplyAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
951
- readonly config: VesuMultiplyAdapterConfig;
952
- readonly vesuAdapter: VesuAdapter;
953
- readonly tokenMarketData: TokenMarketData;
954
- readonly minimumVesuMovementAmount: number;
955
- constructor(config: VesuMultiplyAdapterConfig);
956
- protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
957
- protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
958
- maxBorrowableAPY(): Promise<number>;
959
- maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
960
- maxWithdraw(): Promise<PositionInfo>;
961
- protected _getDepositLeaf(): {
962
- target: ContractAddr;
963
- method: string;
964
- packedArguments: bigint[];
965
- sanitizer: ContractAddr;
966
- id: string;
967
- }[];
968
- protected _getWithdrawLeaf(): {
969
- target: ContractAddr;
970
- method: string;
971
- packedArguments: bigint[];
972
- sanitizer: ContractAddr;
973
- id: string;
974
- }[];
975
- getDepositAdapter(): AdapterLeafType<DepositParams>;
976
- getWithdrawAdapter(): AdapterLeafType<WithdrawParams>;
977
- getDepositCall(params: DepositParams): Promise<ManageCall[]>;
978
- getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
979
- private getMultiplyCallCalldata;
980
- private getLeverParams;
981
- private getWithdrawalCalldata;
982
- formatMultiplyParams(isIncrease: boolean, params: IncreaseLeverParams | DecreaseLeverParams): {
983
- action: CairoCustomEnum;
984
- };
985
- getHealthFactor(): Promise<number>;
986
- getNetAPY(): Promise<number>;
987
- }
988
-
989
- /**
990
- * TypeScript type definitions for Extended Exchange API
991
- * Based on Python SDK models from x10.perpetual
992
- */
993
- declare enum OrderSide {
994
- BUY = "BUY",
995
- SELL = "SELL"
996
- }
997
- declare enum TimeInForce {
998
- GTT = "GTT",
999
- IOC = "IOC",
1000
- FOK = "FOK"
1001
- }
1002
- declare enum OrderType {
1003
- LIMIT = "LIMIT",
1004
- CONDITIONAL = "CONDITIONAL",
1005
- MARKET = "MARKET",
1006
- TPSL = "TPSL"
1007
- }
1008
- declare enum OrderStatus {
1009
- UNKNOWN = "UNKNOWN",
1010
- NEW = "NEW",
1011
- UNTRIGGERED = "UNTRIGGERED",
1012
- PARTIALLY_FILLED = "PARTIALLY_FILLED",
1013
- FILLED = "FILLED",
1014
- CANCELLED = "CANCELLED",
1015
- EXPIRED = "EXPIRED",
1016
- REJECTED = "REJECTED"
1017
- }
1018
- declare enum OrderStatusReason {
1019
- UNKNOWN = "UNKNOWN",
1020
- NONE = "NONE",
1021
- UNKNOWN_MARKET = "UNKNOWN_MARKET",
1022
- DISABLED_MARKET = "DISABLED_MARKET",
1023
- NOT_ENOUGH_FUNDS = "NOT_ENOUGH_FUNDS",
1024
- NO_LIQUIDITY = "NO_LIQUIDITY",
1025
- INVALID_FEE = "INVALID_FEE",
1026
- INVALID_QTY = "INVALID_QTY",
1027
- INVALID_PRICE = "INVALID_PRICE",
1028
- INVALID_VALUE = "INVALID_VALUE",
1029
- UNKNOWN_ACCOUNT = "UNKNOWN_ACCOUNT",
1030
- SELF_TRADE_PROTECTION = "SELF_TRADE_PROTECTION",
1031
- POST_ONLY_FAILED = "POST_ONLY_FAILED",
1032
- REDUCE_ONLY_FAILED = "REDUCE_ONLY_FAILED",
1033
- INVALID_EXPIRE_TIME = "INVALID_EXPIRE_TIME",
1034
- POSITION_TPSL_CONFLICT = "POSITION_TPSL_CONFLICT",
1035
- INVALID_LEVERAGE = "INVALID_LEVERAGE",
1036
- PREV_ORDER_NOT_FOUND = "PREV_ORDER_NOT_FOUND",
1037
- PREV_ORDER_TRIGGERED = "PREV_ORDER_TRIGGERED",
1038
- TPSL_OTHER_SIDE_FILLED = "TPSL_OTHER_SIDE_FILLED",
1039
- PREV_ORDER_CONFLICT = "PREV_ORDER_CONFLICT",
1040
- ORDER_REPLACED = "ORDER_REPLACED",
1041
- POST_ONLY_MODE = "POST_ONLY_MODE",
1042
- REDUCE_ONLY_MODE = "REDUCE_ONLY_MODE",
1043
- TRADING_OFF_MODE = "TRADING_OFF_MODE"
1044
- }
1045
- declare enum PositionSide {
1046
- LONG = "LONG",
1047
- SHORT = "SHORT"
1048
- }
1049
- declare enum ExitType {
1050
- TRADE = "TRADE",
1051
- LIQUIDATION = "LIQUIDATION",
1052
- ADL = "ADL"
1053
- }
1054
- declare enum AssetOperationType {
1055
- DEPOSIT = "DEPOSIT",
1056
- WITHDRAWAL = "WITHDRAWAL",
1057
- TRANSFER = "TRANSFER"
1058
- }
1059
- declare enum AssetOperationStatus {
1060
- PENDING = "PENDING",
1061
- COMPLETED = "COMPLETED",
1062
- FAILED = "FAILED"
1063
- }
1064
- interface SettlementSignature {
1065
- r: string;
1066
- s: string;
1067
- }
1068
- interface StarkSettlement {
1069
- signature: SettlementSignature;
1070
- stark_key: string;
1071
- collateral_position: string;
1072
- }
1073
- interface StarkDebuggingOrderAmounts {
1074
- collateral_amount: string;
1075
- fee_amount: string;
1076
- synthetic_amount: string;
1077
- }
1078
- interface PlacedOrder {
1079
- id: number;
1080
- external_id: string;
1081
- }
1082
- interface OpenOrder {
1083
- id: number;
1084
- account_id: number;
1085
- external_id: string;
1086
- market: string;
1087
- type: OrderType;
1088
- side: OrderSide;
1089
- status: OrderStatus;
1090
- status_reason?: OrderStatusReason;
1091
- price: string;
1092
- average_price?: string;
1093
- qty: string;
1094
- filled_qty?: string;
1095
- reduce_only: boolean;
1096
- post_only: boolean;
1097
- payed_fee?: string;
1098
- created_time: number;
1099
- updated_time: number;
1100
- expiry_time?: number;
1101
- }
1102
- interface Position {
1103
- id: number;
1104
- accountId: number;
1105
- market: string;
1106
- side: PositionSide;
1107
- leverage: string;
1108
- size: string;
1109
- value: string;
1110
- openPrice: string;
1111
- markPrice: string;
1112
- liquidationPrice?: string;
1113
- unrealisedPnl: string;
1114
- realisedPnl: string;
1115
- tpPrice?: string;
1116
- slPrice?: string;
1117
- adl?: number;
1118
- createdAt: number;
1119
- updatedAt: number;
1120
- }
1121
- interface PositionHistory {
1122
- id: number;
1123
- account_id: number;
1124
- market: string;
1125
- side: PositionSide;
1126
- leverage: string;
1127
- size: string;
1128
- open_price: string;
1129
- exit_type?: ExitType;
1130
- exit_price?: string;
1131
- realised_pnl: string;
1132
- created_time: number;
1133
- closed_time?: number;
1134
- }
1135
- interface Balance {
1136
- collateral_name: string;
1137
- balance: string;
1138
- equity: string;
1139
- availableForTrade: string;
1140
- availableForWithdrawal: string;
1141
- unrealisedPnl: string;
1142
- initialMargin: string;
1143
- marginRatio: string;
1144
- updatedTime: number;
1145
- }
1146
- interface RiskFactorConfig {
1147
- upper_bound: string;
1148
- risk_factor: string;
1149
- }
1150
- interface MarketStats {
1151
- daily_volume: string;
1152
- daily_volume_base: string;
1153
- daily_price_change: string;
1154
- daily_low: string;
1155
- daily_high: string;
1156
- last_price: string;
1157
- ask_price: string;
1158
- bid_price: string;
1159
- mark_price: string;
1160
- index_price: string;
1161
- funding_rate: string;
1162
- next_funding_rate: number;
1163
- open_interest: string;
1164
- open_interest_base: string;
1165
- }
1166
- interface TradingConfig {
1167
- min_order_size: string;
1168
- min_order_size_change: string;
1169
- min_price_change: string;
1170
- max_market_order_value: string;
1171
- max_limit_order_value: string;
1172
- max_position_value: string;
1173
- max_leverage: string;
1174
- max_num_orders: number;
1175
- limit_price_cap: string;
1176
- limit_price_floor: string;
1177
- risk_factor_config: RiskFactorConfig[];
1178
- }
1179
- interface L2Config {
1180
- type: string;
1181
- collateral_id: string;
1182
- collateral_resolution: number;
1183
- synthetic_id: string;
1184
- synthetic_resolution: number;
1185
- }
1186
- interface Market {
1187
- name: string;
1188
- asset_name: string;
1189
- asset_precision: number;
1190
- collateral_asset_name: string;
1191
- collateral_asset_precision: number;
1192
- active: boolean;
1193
- market_stats: MarketStats;
1194
- trading_config: TradingConfig;
1195
- l2_config: L2Config;
1196
- }
1197
- interface AssetOperation {
1198
- id: number;
1199
- type: AssetOperationType;
1200
- status: AssetOperationStatus;
1201
- amount: string;
1202
- asset: string;
1203
- created_time: number;
1204
- updated_time: number;
1205
- description?: string;
1206
- transactionHash?: string;
1207
- }
1208
- interface CreateOrderRequest {
1209
- market_name: string;
1210
- amount: string;
1211
- price: string;
1212
- side: OrderSide;
1213
- post_only?: boolean;
1214
- previous_order_id?: number;
1215
- external_id?: string;
1216
- time_in_force?: TimeInForce;
1217
- }
1218
- interface WithdrawRequest {
1219
- amount: string;
1220
- asset?: string;
1221
- }
1222
- interface SignedWithdrawRequest {
1223
- recipient: string;
1224
- position_id: number;
1225
- amount: number;
1226
- expiration: number;
1227
- salt: number;
1228
- }
1229
- interface CancelOrderRequest {
1230
- order_id: number;
1231
- }
1232
- interface ApiResponse<T> {
1233
- success: boolean;
1234
- message: string;
1235
- data: T;
1236
- }
1237
- interface ExtendedApiResponse<T> {
1238
- status: 'OK' | 'ERROR';
1239
- message: string;
1240
- data: T;
1241
- }
1242
- interface ExtendedWrapperConfig {
1243
- baseUrl: string;
1244
- apiKey?: string;
1245
- timeout?: number;
1246
- retries?: number;
1247
- }
1248
- interface UpdateLeverageRequest {
1249
- leverage: string;
1250
- market: string;
1251
- }
1252
- interface FundingRate {
1253
- m: string;
1254
- f: string;
1255
- t: number;
1256
- }
1257
-
1258
- /**
1259
- * ExtendedWrapper - TypeScript wrapper for Extended Exchange API
1260
- * Provides a clean interface to interact with the Extended Exchange trading API
1261
- */
1262
-
1263
- declare class ExtendedWrapper {
1264
- private baseUrl;
1265
- private apiKey?;
1266
- private timeout;
1267
- private retries;
1268
- constructor(config: ExtendedWrapperConfig);
1269
- /**
1270
- * Make HTTP request with retry logic and error handling
1271
- */
1272
- private makeRequest;
1273
- /**
1274
- * Create a new order on Extended Exchange
1275
- */
1276
- createOrder(request: CreateOrderRequest): Promise<ExtendedApiResponse<PlacedOrder>>;
1277
- /**
1278
- * Get all markets
1279
- */
1280
- getMarkets(marketNames?: string): Promise<ExtendedApiResponse<Market[]>>;
1281
- /**
1282
- *
1283
- * @param orderId - The ID of the order to get
1284
- * @returns The order
1285
- */
1286
- getOrderByOrderId(orderId: string): Promise<ExtendedApiResponse<OpenOrder>>;
1287
- /**
1288
- * Get market statistics for a specific market
1289
- */
1290
- getMarketStatistics(marketName: string): Promise<ExtendedApiResponse<MarketStats>>;
1291
- /**
1292
- * Get current trading positions
1293
- */
1294
- getPositions(marketNames?: string): Promise<ExtendedApiResponse<Position[]>>;
1295
- /**
1296
- * Get account balance and holdings
1297
- */
1298
- getHoldings(): Promise<ExtendedApiResponse<Balance>>;
1299
- /**
1300
- * Initiate a withdrawal from Extended Exchange
1301
- */
1302
- withdraw(request: WithdrawRequest): Promise<ExtendedApiResponse<number>>;
1303
- /**
1304
- * Create and sign a withdrawal request hash
1305
- */
1306
- signWithdrawalRequest(request: SignedWithdrawRequest): Promise<ExtendedApiResponse<{
1307
- withdraw_request_hash: string;
1308
- signature: {
1309
- r: string;
1310
- s: string;
1311
- };
1312
- }>>;
1313
- /**
1314
- * Cancel an existing order
1315
- */
1316
- cancelOrder(request: CancelOrderRequest): Promise<ExtendedApiResponse<{}>>;
1317
- /**
1318
- * Get all open orders
1319
- */
1320
- getOpenOrders(marketName?: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
1321
- /**
1322
- * Update leverage on the market
1323
- * @param request
1324
- * @returns
1325
- */
1326
- updateLeverage(request: UpdateLeverageRequest): Promise<ExtendedApiResponse<{}>>;
1327
- /**
1328
- * Get asset operations with optional filtering
1329
- */
1330
- getAssetOperations(options?: {
1331
- id?: number;
1332
- operationsType?: AssetOperationType[];
1333
- operationsStatus?: AssetOperationStatus[];
1334
- startTime?: number;
1335
- endTime?: number;
1336
- cursor?: number;
1337
- limit?: number;
1338
- }): Promise<ExtendedApiResponse<AssetOperation[]>>;
1339
- /**
1340
- * Health check endpoint
1341
- */
1342
- healthCheck(): Promise<ExtendedApiResponse<MarketStats>>;
1343
- /**
1344
- * Convenience method to create a buy order
1345
- */
1346
- createBuyOrder(marketName: string, amount: string, price: string, options?: {
1347
- postOnly?: boolean;
1348
- previousOrderId?: number;
1349
- externalId?: string;
1350
- timeInForce?: TimeInForce;
1351
- }): Promise<ExtendedApiResponse<PlacedOrder>>;
1352
- /**
1353
- * Get order by ID
1354
- * @param orderId - The ID of the order to get
1355
- * @returns The order
1356
- */
1357
- getOrderById(orderId: number): Promise<ExtendedApiResponse<OpenOrder>>;
1358
- /**
1359
- * Convenience method to create a sell order
1360
- */
1361
- createSellOrder(marketName: string, amount: string, price: string, options?: {
1362
- postOnly?: boolean;
1363
- previousOrderId?: number;
1364
- externalId?: string;
1365
- timeInForce?: TimeInForce;
1366
- }): Promise<ExtendedApiResponse<PlacedOrder>>;
1367
- /**
1368
- * Get positions for a specific market
1369
- */
1370
- getPositionsForMarket(marketName: string): Promise<ExtendedApiResponse<Position[]>>;
1371
- /**
1372
- * Get open orders for a specific market
1373
- */
1374
- getOpenOrdersForMarket(marketName: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
1375
- /**
1376
- * Cancel order by ID (convenience method)
1377
- */
1378
- cancelOrderById(orderId: number): Promise<ExtendedApiResponse<{}>>;
1379
- /**
1380
- * Get order history for a specific market
1381
- * @param marketName - The name of the market to get order history for
1382
- * @returns The order history for the specified market
1383
- */
1384
- getOrderHistory(marketName: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
1385
- /**
1386
- * Withdraw USDC (convenience method)
1387
- */
1388
- withdrawUSDC(amount: string): Promise<ExtendedApiResponse<number>>;
1389
- /**
1390
- * Get funding rates for a specific market
1391
- * @param marketName - The name of the market to get funding rates for
1392
- * @returns The funding rates for the specified market
1393
- */
1394
- getFundingRates(marketName: string, side: string): Promise<ExtendedApiResponse<FundingRate[]>>;
1395
- }
1396
-
1397
- interface Route {
1398
- token_from: string;
1399
- token_to: string;
1400
- exchange_address: string;
1401
- percent: number;
1402
- additional_swap_params: string[];
1403
- }
1404
- interface SwapInfo {
1405
- token_from_address: string;
1406
- token_from_amount: Uint256;
1407
- token_to_address: string;
1408
- token_to_amount: Uint256;
1409
- token_to_min_amount: Uint256;
1410
- beneficiary: string;
1411
- integrator_fee_amount_bps: number;
1412
- integrator_fee_recipient: string;
1413
- routes: Route[];
1414
- }
1415
- declare class AvnuWrapper {
1416
- getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number, excludeSources?: string[]): Promise<Quote>;
1417
- getSwapInfo(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount?: string, options?: AvnuOptions): Promise<SwapInfo>;
1418
- static buildZeroSwap(tokenToSell: ContractAddr, beneficiary: string, tokenToBuy?: ContractAddr): SwapInfo;
1419
- getSwapCallData(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string): Promise<bigint[][]>;
1420
- }
1421
-
1422
- interface AvnuAdapterConfig extends BaseAdapterConfig {
1423
- baseUrl: string;
1424
- avnuContract: ContractAddr;
1425
- slippage: number;
1426
- }
1427
- declare class AvnuAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
1428
- readonly config: AvnuAdapterConfig;
1429
- protected avnuWrapper: AvnuWrapper;
1430
- constructor(config: AvnuAdapterConfig);
1431
- protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
1432
- protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
1433
- maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
1434
- maxWithdraw(): Promise<PositionInfo>;
1435
- protected _getDepositLeaf(): {
1436
- target: ContractAddr;
1437
- method: string;
1438
- packedArguments: bigint[];
1439
- sanitizer: ContractAddr;
1440
- id: string;
1441
- }[];
1442
- protected _getWithdrawLeaf(): {
1443
- target: ContractAddr;
1444
- method: string;
1445
- packedArguments: bigint[];
1446
- sanitizer: ContractAddr;
1447
- id: string;
1448
- }[];
1449
- protected _getLegacySwapLeaf(): {
1450
- target: ContractAddr;
1451
- method: string;
1452
- packedArguments: bigint[];
1453
- sanitizer: ContractAddr;
1454
- id: string;
1455
- }[];
1456
- getDepositCall(params: DepositParams): Promise<ManageCall[]>;
1457
- getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
1458
- getSwapCallData(quote: Quote): Promise<bigint[][]>;
1459
- getHealthFactor(): Promise<number>;
1460
- fetchQuoteWithRetry(params: Record<string, any>, retries?: number): Promise<any>;
1461
- getQuotesAvnu(from_token_address: string, to_token_address: string, amount: number, //amount in btc units
1462
- takerAddress: string, toTokenDecimals: number, usdcToBtc: boolean, maxIterations?: number, tolerance?: number): Promise<Quote | null>;
1463
- getPriceOfToken(tokenAddress: string, retries?: number): Promise<number | null>;
1464
- }
1465
-
1466
- interface ExtendedAdapterConfig extends BaseAdapterConfig {
1467
- vaultIdExtended: number;
1468
- extendedContract: ContractAddr;
1469
- extendedBackendUrl: string;
1470
- extendedApiKey: string;
1471
- extendedTimeout: number;
1472
- extendedRetries: number;
1473
- extendedBaseUrl: string;
1474
- extendedMarketName: string;
1475
- extendedPrecision: number;
1476
- avnuAdapter: AvnuAdapter;
1477
- retryDelayForOrderStatus: number;
1478
- minimumExtendedMovementAmount: number;
1479
- }
1480
- declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
1481
- readonly config: ExtendedAdapterConfig;
1482
- readonly client: ExtendedWrapper;
1483
- readonly retryDelayForOrderStatus: number;
1484
- readonly minimumExtendedMovementAmount: number;
1485
- constructor(config: ExtendedAdapterConfig);
1486
- protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
1487
- protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
1488
- maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
1489
- maxWithdraw(): Promise<PositionInfo>;
1490
- protected _getDepositLeaf(): {
1491
- target: ContractAddr;
1492
- method: string;
1493
- packedArguments: bigint[];
1494
- sanitizer: ContractAddr;
1495
- id: string;
1496
- }[];
1497
- getSwapFromLegacyLeaf(): AdapterLeafType<DepositParams>;
1498
- protected _getSwapFromLegacyLeaf(): {
1499
- target: ContractAddr;
1500
- method: string;
1501
- packedArguments: bigint[];
1502
- sanitizer: ContractAddr;
1503
- id: string;
1504
- }[];
1505
- protected _getWithdrawLeaf(): {
1506
- target: ContractAddr;
1507
- method: string;
1508
- packedArguments: bigint[];
1509
- sanitizer: ContractAddr;
1510
- id: string;
1511
- }[];
1512
- getDepositCall(params: DepositParams): Promise<ManageCall[]>;
1513
- getProofsForFromLegacySwap<T>(tree: StandardMerkleTree): {
1514
- proofs: string[][];
1515
- callConstructor: GenerateCallFn<DepositParams> | GenerateCallFn<WithdrawParams>;
1516
- };
1517
- getSwapFromLegacyCall(params: DepositParams): Promise<ManageCall[]>;
1518
- getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
1519
- withdrawFromExtended(amount: Web3Number): Promise<boolean>;
1520
- getHealthFactor(): Promise<number>;
1521
- getExtendedDepositAmount(): Promise<Balance | undefined>;
1522
- setLeverage(leverage: string, marketName: string): Promise<boolean>;
1523
- getAllOpenPositions(): Promise<Position[] | null>;
1524
- getOrderHistory(marketName: string): Promise<OpenOrder[] | null>;
1525
- getOrderStatus(orderId: string, marketName: string): Promise<OpenOrder | null>;
1526
- fetchOrderBookBTCUSDC(): Promise<{
1527
- status: boolean;
1528
- bid: Web3Number;
1529
- ask: Web3Number;
1530
- }>;
1531
- createOrder(leverage: string, btcAmount: number, side: OrderSide, attempt?: number, maxAttempts?: number): Promise<{
1532
- position_id: string;
1533
- btc_exposure: string;
1534
- } | null>;
1535
- createExtendedPositon(client: ExtendedWrapper, marketName: string, amount: string, price: string, side: OrderSide): Promise<{
1536
- position_id: string;
1537
- } | null>;
1538
- getDepositOrWithdrawalStatus(orderId: number | string, // for deposits, send txn hash as string
1539
- operationsType: AssetOperationType): Promise<boolean>;
1540
- }
1541
-
1542
- declare const SIMPLE_SANITIZER: ContractAddr;
1543
- declare const EXTENDED_SANITIZER: ContractAddr;
1544
- declare const AVNU_LEGACY_SANITIZER: ContractAddr;
1545
- declare const SIMPLE_SANITIZER_V2: ContractAddr;
1546
- declare const VESU_V2_MODIFY_POSITION_SANITIZER: ContractAddr;
1547
- declare const SIMPLE_SANITIZER_VESU_V1_DELEGATIONS: ContractAddr;
1548
- declare const PRICE_ROUTER: ContractAddr;
1549
- declare const AVNU_MIDDLEWARE: ContractAddr;
1550
- declare const AVNU_EXCHANGE: ContractAddr;
1551
- declare const AVNU_EXCHANGE_FOR_LEGACY_USDC: ContractAddr;
1552
- declare const AVNU_QUOTE_URL = "https://starknet.api.avnu.fi/swap/v3/quotes";
1553
- declare const EXTENDED_CONTRACT: ContractAddr;
1554
- declare const VESU_SINGLETON: ContractAddr;
1555
- declare function toBigInt(value: string | number): bigint;
1556
-
1557
- interface UnusedBalanceAdapterConfig extends BaseAdapterConfig {
1558
- }
1559
- declare class UnusedBalanceAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
1560
- readonly config: UnusedBalanceAdapterConfig;
1561
- readonly tokenMarketData: TokenMarketData;
1562
- constructor(config: UnusedBalanceAdapterConfig);
1563
- protected getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY>;
1564
- protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
1565
- maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
1566
- maxWithdraw(): Promise<PositionInfo>;
1567
- protected _getDepositLeaf(): {
1568
- target: ContractAddr;
1569
- method: string;
1570
- packedArguments: bigint[];
1571
- sanitizer: ContractAddr;
1572
- id: string;
1573
- }[];
1574
- protected _getWithdrawLeaf(): {
1575
- target: ContractAddr;
1576
- method: string;
1577
- packedArguments: bigint[];
1578
- sanitizer: ContractAddr;
1579
- id: string;
1580
- }[];
1581
- getHealthFactor(): Promise<number>;
1582
- getDepositCall(params: DepositParams): Promise<ManageCall[]>;
1583
- getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
1584
- }
1585
-
1586
- interface SingleActionAmount {
1587
- tokenInfo: TokenInfo;
1588
- amount: Web3Number;
1589
- }
1590
- interface SingleTokenInfo extends SingleActionAmount {
1591
- usdValue: number;
1592
- }
1593
- interface APYInfo {
1594
- net: number;
1595
- splits: {
1596
- apy: number;
1597
- id: string;
1598
- }[];
1599
- }
1600
- interface DualActionAmount {
1601
- token0: SingleActionAmount;
1602
- token1: SingleActionAmount;
1603
- }
1604
- interface DualTokenInfo {
1605
- usdValue: number;
1606
- token0: SingleTokenInfo;
1607
- token1: SingleTokenInfo;
1608
- }
1609
- interface CacheData {
1610
- timestamp: number;
1611
- ttl: number;
1612
- data: any;
1613
- }
1614
- declare class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
1615
- readonly config: IConfig;
1616
- readonly cache: Map<string, CacheData>;
1617
- constructor(config: IConfig);
1618
- getUserTVL(user: ContractAddr): Promise<TVLInfo>;
1619
- getTVL(): Promise<TVLInfo>;
1620
- depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Promise<Call[]>;
1621
- withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
1622
- getVaultPositions(): Promise<VaultPosition[]>;
1623
- getUnusedBalance(): Promise<SingleTokenInfo>;
1624
- netAPY(): Promise<APYInfo>;
1625
- getAUM(): Promise<{
1626
- net: SingleTokenInfo;
1627
- prevAum: Web3Number;
1628
- splits: PositionInfo[];
1629
- }>;
1630
- getHealthFactors(): Promise<number[]>;
1631
- }
1632
-
1633
- /**
1634
- * TokenMarketData class that combines LST APR and Midas modules
1635
- * to provide unified APY, price, and TVL functions for tokens
1636
- */
1637
- declare class TokenMarketData {
1638
- private pricer;
1639
- private config;
1640
- constructor(pricer: PricerBase, config: IConfig);
1641
- /**
1642
- * Get APY for a token
1643
- * - If it's an LST token, returns LST APY
1644
- * - If it's a Midas token, returns Midas APY
1645
- * - Otherwise returns 0
1646
- * @param tokenInfo The token to get APY for
1647
- * @returns APY in absolute terms (not percentage)
1648
- */
1649
- getAPY(tokenInfo: TokenInfo): Promise<number>;
1650
- /**
1651
- * Get price for a token using the pricer module
1652
- * @param tokenInfo The token to get price for
1653
- * @returns Price as a number
1654
- * @throws Error if price is 0 or unavailable
1655
- */
1656
- getPrice(tokenInfo: TokenInfo): Promise<number>;
1657
- /**
1658
- * Get true price for a token
1659
- * - For LST tokens: Uses convert_to_assets to get true exchange rate
1660
- * - For Midas tokens: Uses Midas price API
1661
- * - For other tokens: Falls back to regular pricer
1662
- * @param tokenInfo The token to get true price for
1663
- * @returns True price as a number
1664
- * @throws Error if price is 0 or unavailable
1665
- */
1666
- getTruePrice(tokenInfo: TokenInfo): Promise<number>;
1667
- /**
1668
- * Get TVL for a token
1669
- * - If it's a Midas token, returns Midas TVL data
1670
- * - Otherwise returns 0
1671
- * @param tokenInfo The token to get TVL for
1672
- * @returns TVL as SingleTokenInfo or 0
1673
- */
1674
- getTVL(tokenInfo: TokenInfo): Promise<SingleTokenInfo>;
1675
- /**
1676
- * Check if a token is supported for APY data
1677
- * @param tokenInfo The token to check
1678
- * @returns True if the token has APY data available
1679
- */
1680
- isAPYSupported(tokenInfo: TokenInfo): boolean;
1681
- /**
1682
- * Check if a token is supported for TVL data
1683
- * @param tokenInfo The token to check
1684
- * @returns True if the token has TVL data available
1685
- */
1686
- isTVLSupported(tokenInfo: TokenInfo): boolean;
1687
- }
1688
-
1689
- declare class Pragma {
1690
- contractAddr: string;
1691
- readonly contract: Contract;
1692
- constructor(provider: RpcProvider);
1693
- getPrice(tokenAddr: string): Promise<number>;
1694
- }
1695
-
1696
- declare class ZkLend extends ILending implements ILending {
1697
- readonly pricer: Pricer;
1698
- static readonly POOLS_URL = "https://app.zklend.com/api/pools";
1699
- private POSITION_URL;
1700
- constructor(config: IConfig, pricer: Pricer);
1701
- init(): Promise<void>;
1702
- /**
1703
- * @description Get the health factor of the user for given lending and debt tokens
1704
- * @param lending_tokens
1705
- * @param debt_tokens
1706
- * @param user
1707
- * @returns hf (e.g. returns 1.5 for 150% health factor)
1708
- */
1709
- get_health_factor_tokenwise(lending_tokens: TokenInfo[], debt_tokens: TokenInfo[], user: ContractAddr): Promise<number>;
1710
- /**
1711
- * @description Get the health factor of the user
1712
- * - Considers all tokens for collateral and debt
1713
- */
1714
- get_health_factor(user: ContractAddr): Promise<number>;
1715
- getPositionsSummary(user: ContractAddr): Promise<{
1716
- collateralUSD: number;
1717
- debtUSD: number;
1718
- }>;
1719
- /**
1720
- * @description Get the token-wise collateral and debt positions of the user
1721
- * @param user Contract address of the user
1722
- * @returns Promise<ILendingPosition[]>
1723
- */
1724
- getPositions(user: ContractAddr): Promise<ILendingPosition[]>;
1725
- }
1726
-
1727
- declare class PricerFromApi extends PricerBase {
1728
- constructor(config: IConfig, tokens: TokenInfo[]);
1729
- getPrice(tokenSymbol: string): Promise<PriceInfo>;
1730
- getPriceFromMyAPI(tokenSymbol: string): Promise<{
1731
- price: number;
1732
- timestamp: Date;
1733
- }>;
1734
- }
1735
-
1736
- declare class ERC20 {
1737
- readonly config: IConfig;
1738
- constructor(config: IConfig);
1739
- contract(addr: string | ContractAddr): Contract;
1740
- balanceOf(token: string | ContractAddr, address: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
1741
- allowance(token: string | ContractAddr, owner: string | ContractAddr, spender: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
1742
- transfer(token: string | ContractAddr, to: string | ContractAddr, amount: Web3Number): starknet.Call;
1743
- approve(token: string | ContractAddr, spender: string | ContractAddr, amount: Web3Number): starknet.Call;
1744
- }
1745
-
1746
- declare class AutoCompounderSTRK {
1747
- readonly config: IConfig;
1748
- readonly addr: ContractAddr;
1749
- readonly pricer: Pricer;
1750
- private initialized;
1751
- contract: Contract | null;
1752
- readonly metadata: {
1753
- decimals: number;
1754
- underlying: {
1755
- address: ContractAddr;
1756
- name: string;
1757
- symbol: string;
1758
- };
1759
- name: string;
1760
- };
1761
- constructor(config: IConfig, pricer: Pricer);
1762
- init(): Promise<void>;
1763
- waitForInitilisation(): Promise<void>;
1764
- /** Returns shares of user */
1765
- balanceOf(user: ContractAddr): Promise<Web3Number>;
1766
- /** Returns underlying assets of user */
1767
- balanceOfUnderlying(user: ContractAddr): Promise<Web3Number>;
1768
- /** Returns usd value of assets */
1769
- usdBalanceOfUnderlying(user: ContractAddr): Promise<{
1770
- usd: Web3Number;
1771
- assets: Web3Number;
1772
- }>;
1773
- }
1774
-
1775
- interface PoolProps {
1776
- pool_id: ContractAddr;
1777
- max_weight: number;
1778
- v_token: ContractAddr;
1779
- }
1780
- interface Change {
1781
- pool_id: ContractAddr;
1782
- changeAmt: Web3Number;
1783
- finalAmt: Web3Number;
1784
- isDeposit: boolean;
1785
- }
1786
- interface VesuRebalanceSettings {
1787
- feeBps: number;
1788
- }
1789
- interface PoolInfoFull {
1790
- pool_id: ContractAddr;
1791
- pool_name: string | undefined;
1792
- max_weight: number;
1793
- current_weight: number;
1794
- v_token: ContractAddr;
1795
- amount: Web3Number;
1796
- usdValue: Web3Number;
1797
- APY: {
1798
- baseApy: number;
1799
- defiSpringApy: number;
1800
- netApy: number;
1801
- };
1802
- currentUtilization: number;
1803
- maxUtilization: number;
1804
- }
1805
- /**
1806
- * Represents a VesuRebalance strategy.
1807
- * This class implements an automated rebalancing strategy for Vesu pools,
1808
- * managing deposits and withdrawals while optimizing yield through STRK rewards.
1809
- */
1810
- declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
1811
- /** Contract address of the strategy */
1812
- readonly address: ContractAddr;
1813
- /** Pricer instance for token price calculations */
1814
- readonly pricer: PricerBase;
1815
- /** Metadata containing strategy information */
1816
- readonly metadata: IStrategyMetadata<VesuRebalanceSettings>;
1817
- /** Contract instance for interacting with the strategy */
1818
- readonly contract: Contract;
1819
- readonly BASE_WEIGHT = 10000;
1820
- /**
1821
- * Creates a new VesuRebalance strategy instance.
1822
- * @param config - Configuration object containing provider and other settings
1823
- * @param pricer - Pricer instance for token price calculations
1824
- * @param metadata - Strategy metadata including deposit tokens and address
1825
- * @throws {Error} If more than one deposit token is specified
1826
- */
1827
- constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>);
1828
- /**
1829
- * Creates a deposit call to the strategy contract.
1830
- * @param assets - Amount of assets to deposit
1831
- * @param receiver - Address that will receive the strategy tokens
1832
- * @returns Populated contract call for deposit
1833
- */
1834
- depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<starknet.Call[]>;
1835
- /**
1836
- * Creates a withdrawal call to the strategy contract.
1837
- * @param assets - Amount of assets to withdraw
1838
- * @param receiver - Address that will receive the withdrawn assets
1839
- * @param owner - Address that owns the strategy tokens
1840
- * @returns Populated contract call for withdrawal
1841
- */
1842
- withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<starknet.Call[]>;
1843
- /**
1844
- * Returns the underlying asset token of the strategy.
1845
- * @returns The deposit token supported by this strategy
1846
- */
1847
- asset(): TokenInfo;
1848
- /**
1849
- * Returns the number of decimals used by the strategy token.
1850
- * @returns Number of decimals (same as the underlying token)
1851
- */
1852
- decimals(): number;
1853
- /**
1854
- * Calculates the Total Value Locked (TVL) for a specific user.
1855
- * @param user - Address of the user
1856
- * @returns Object containing the amount in token units and USD value
1857
- */
1858
- getUserTVL(user: ContractAddr): Promise<{
1859
- tokenInfo: TokenInfo;
1860
- amount: Web3Number;
1861
- usdValue: number;
1862
- }>;
1863
- /**
1864
- * Calculates the total TVL of the strategy.
1865
- * @returns Object containing the total amount in token units and USD value
1866
- */
1867
- getTVL(): Promise<{
1868
- tokenInfo: TokenInfo;
1869
- amount: Web3Number;
1870
- usdValue: number;
1871
- }>;
1872
- static getAllPossibleVerifiedPools(asset: ContractAddr): Promise<any>;
1873
- getPoolInfo(p: PoolProps, pools: any[], vesuPositions: any[], totalAssets: Web3Number, isErrorPositionsAPI: boolean, isErrorPoolsAPI: boolean): Promise<{
1874
- pool_id: ContractAddr;
1875
- pool_name: any;
1876
- max_weight: number;
1877
- current_weight: number;
1878
- v_token: ContractAddr;
1879
- amount: Web3Number;
1880
- usdValue: Web3Number;
1881
- APY: {
1882
- baseApy: number;
1883
- defiSpringApy: number;
1884
- netApy: number;
1885
- };
1886
- currentUtilization: number;
1887
- maxUtilization: number;
1888
- }>;
1889
- /**
1890
- * Retrieves the list of allowed pools and their detailed information from multiple sources:
1891
- * 1. Contract's allowed pools
1892
- * 2. Vesu positions API for current positions
1893
- * 3. Vesu pools API for APY and utilization data
1894
- *
1895
- * @returns {Promise<{
1896
- * data: Array<PoolInfoFull>,
1897
- * isErrorPositionsAPI: boolean
1898
- * }>} Object containing:
1899
- * - data: Array of pool information including IDs, weights, amounts, APYs and utilization
1900
- * - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
1901
- */
1902
- getPools(): Promise<{
1903
- data: {
1904
- pool_id: ContractAddr;
1905
- pool_name: any;
1906
- max_weight: number;
1907
- current_weight: number;
1908
- v_token: ContractAddr;
1909
- amount: Web3Number;
1910
- usdValue: Web3Number;
1911
- APY: {
1912
- baseApy: number;
1913
- defiSpringApy: number;
1914
- netApy: number;
1915
- };
1916
- currentUtilization: number;
1917
- maxUtilization: number;
1918
- }[];
1919
- isErrorPositionsAPI: boolean;
1920
- isErrorPoolsAPI: boolean;
1921
- isError: boolean;
1922
- }>;
1923
- getVesuPools(retry?: number): Promise<{
1924
- pools: any[];
1925
- isErrorPoolsAPI: boolean;
1926
- }>;
1927
- /**
1928
- * Calculates the weighted average APY across all pools based on USD value.
1929
- * @returns {Promise<number>} The weighted average APY across all pools
1930
- */
1931
- netAPY(): Promise<APYInfo>;
1932
- /**
1933
- * Calculates the weighted average APY across all pools based on USD value.
1934
- * @returns {Promise<number>} The weighted average APY across all pools
1935
- */
1936
- netAPYGivenPools(pools: PoolInfoFull[]): Promise<number>;
1937
- /**
1938
- * Calculates optimal position changes to maximize APY while respecting max weights.
1939
- * The algorithm:
1940
- * 1. Sorts pools by APY (highest first)
1941
- * 2. Calculates target amounts based on max weights
1942
- * 3. For each pool that needs more funds:
1943
- * - Takes funds from lowest APY pools that are over their target
1944
- * 4. Validates that total assets remain constant
1945
- *
1946
- * @returns {Promise<{
1947
- * changes: Change[],
1948
- * finalPools: PoolInfoFull[],
1949
- * isAnyPoolOverMaxWeight: boolean
1950
- * }>} Object containing:
1951
- * - changes: Array of position changes
1952
- * - finalPools: Array of pool information after rebalance
1953
- * @throws Error if rebalance is not possible while maintaining constraints
1954
- */
1955
- getRebalancedPositions(_pools?: PoolInfoFull[]): Promise<{
1956
- changes: never[];
1957
- finalPools: never[];
1958
- isAnyPoolOverMaxWeight?: undefined;
1959
- } | {
1960
- changes: Change[];
1961
- finalPools: PoolInfoFull[];
1962
- isAnyPoolOverMaxWeight: boolean;
1963
- }>;
1964
- /**
1965
- * Creates a rebalance Call object for the strategy contract
1966
- * @param pools - Array of pool information including IDs, weights, amounts, APYs and utilization
1967
- * @returns Populated contract call for rebalance
1968
- */
1969
- getRebalanceCall(pools: Awaited<ReturnType<typeof this.getRebalancedPositions>>["changes"], isOverWeightAdjustment: boolean): Promise<starknet.Call | null>;
1970
- getInvestmentFlows(pools: PoolInfoFull[]): Promise<IInvestmentFlow[]>;
1971
- harvest(acc: Account, endpoint?: string): Promise<starknet.Call[]>;
1972
- /**
1973
- * Calculates the fees deducted in different vTokens based on the current and previous state.
1974
- * @param previousTotalSupply - The total supply of the strategy token before the transaction
1975
- * @returns {Promise<Array<{ vToken: ContractAddr, fee: Web3Number }>>} Array of fees deducted in different vTokens
1976
- */
1977
- getFee(allowedPools: Array<PoolInfoFull>): Promise<Array<{
1978
- vToken: ContractAddr;
1979
- fee: Web3Number;
1980
- }>>;
1981
- }
1982
- /**
1983
- * Represents the Vesu Rebalance Strategies.
1984
- */
1985
- declare const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[];
1986
-
1987
- interface SenseiVaultSettings {
1988
- mainToken: TokenInfo;
1989
- secondaryToken: TokenInfo;
1990
- targetHfBps: number;
1991
- feeBps: number;
1992
- }
1993
- declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
1994
- readonly address: ContractAddr;
1995
- readonly metadata: IStrategyMetadata<SenseiVaultSettings>;
1996
- readonly pricer: PricerBase;
1997
- readonly contract: Contract;
1998
- constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>);
1999
- getUserTVL(user: ContractAddr): Promise<SingleTokenInfo>;
2000
- getTVL(): Promise<SingleTokenInfo>;
2001
- depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
2002
- withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
2003
- getPositionInfo(): Promise<{
2004
- collateralXSTRK: Web3Number;
2005
- collateralUSDValue: Web3Number;
2006
- debtSTRK: Web3Number;
2007
- debtUSDValue: Web3Number;
2008
- xSTRKPrice: number;
2009
- collateralInSTRK: number;
2010
- }>;
2011
- getSecondaryTokenPriceRelativeToMain(retry?: number): Promise<number>;
2012
- getSettings: () => Promise<starknet.CallResult>;
2013
- }
2014
- declare const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[];
1439
+ declare const SIMPLE_SANITIZER: ContractAddr;
1440
+ declare const SIMPLE_SANITIZER_V2: ContractAddr;
1441
+ declare const VESU_V2_MODIFY_POSITION_SANITIZER: ContractAddr;
1442
+ declare const SIMPLE_SANITIZER_VESU_V1_DELEGATIONS: ContractAddr;
1443
+ declare const PRICE_ROUTER: ContractAddr;
1444
+ declare const AVNU_MIDDLEWARE: ContractAddr;
1445
+ declare const AVNU_EXCHANGE: ContractAddr;
1446
+ declare const VESU_SINGLETON: ContractAddr;
1447
+ declare function toBigInt(value: string | number): bigint;
2015
1448
 
2016
1449
  interface UniversalManageCall {
2017
1450
  proofs: string[];
@@ -2023,40 +1456,20 @@ interface UniversalStrategySettings {
2023
1456
  manager: ContractAddr;
2024
1457
  vaultAllocator: ContractAddr;
2025
1458
  redeemRequestNFT: ContractAddr;
1459
+ aumOracle: ContractAddr;
2026
1460
  leafAdapters: LeafAdapterFn<any>[];
2027
- adapters: {
2028
- id: string;
2029
- adapter: BaseAdapter<DepositParams, WithdrawParams>;
2030
- }[];
2031
- }
2032
- declare enum AUMTypes {
2033
- FINALISED = "finalised",
2034
- DEFISPRING = "defispring"
2035
- }
2036
- declare enum UNIVERSAL_MANAGE_IDS {
2037
- FLASH_LOAN = "flash_loan_init",
2038
- VESU_LEG1 = "vesu_leg1",
2039
- VESU_LEG2 = "vesu_leg2",
2040
- APPROVE_TOKEN1 = "approve_token1",
2041
- APPROVE_TOKEN2 = "approve_token2",
2042
- APPROVE_BRING_LIQUIDITY = "approve_bring_liquidity",
2043
- BRING_LIQUIDITY = "bring_liquidity",
2044
- DEFISPRING_REWARDS = "defispring_rewards",
2045
- APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
2046
- AVNU_SWAP_REWARDS = "avnu_swap_rewards"
1461
+ adapters: {
1462
+ id: string;
1463
+ adapter: BaseAdapter;
1464
+ }[];
1465
+ targetHealthFactor: number;
1466
+ minHealthFactor: number;
2047
1467
  }
2048
- declare function getContractDetails(settings: UniversalStrategySettings & {
2049
- aumOracle?: ContractAddr;
2050
- }): {
2051
- address: ContractAddr;
2052
- name: string;
2053
- }[];
2054
-
2055
- /**
2056
- * Base class for all SVK (Starknet Vault Kit) strategies.
2057
- * Contains common functions that are shared across all SVK strategies.
2058
- */
2059
- declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
1468
+ declare enum AUMTypes {
1469
+ FINALISED = "finalised",
1470
+ DEFISPRING = "defispring"
1471
+ }
1472
+ declare class UniversalStrategy<S extends UniversalStrategySettings> extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
2060
1473
  /** Contract address of the strategy */
2061
1474
  readonly address: ContractAddr;
2062
1475
  /** Pricer instance for token price calculations */
@@ -2065,63 +1478,50 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
2065
1478
  readonly metadata: IStrategyMetadata<S>;
2066
1479
  /** Contract instance for interacting with the strategy */
2067
1480
  readonly contract: Contract;
2068
- /** Manager contract instance for merkle verification */
2069
1481
  readonly managerContract: Contract;
2070
- /** Cached merkle tree instance */
2071
1482
  merkleTree: StandardMerkleTree | undefined;
2072
1483
  constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
2073
1484
  /**
2074
- * Returns the asset token for this strategy
1485
+ * Returns the underlying asset token of the strategy.
1486
+ * @returns The deposit token supported by this strategy
2075
1487
  */
2076
1488
  asset(): TokenInfo;
2077
- /**
2078
- * Returns the unused balance in the vault allocator.
2079
- * Note: This function is common for any SVK strategy.
2080
- */
2081
- getUnusedBalance(): Promise<SingleTokenInfo>;
2082
- /**
2083
- * Bridges liquidity from the vault allocator back to the vault.
2084
- * Note: This function is common for any SVK strategy.
2085
- */
2086
- getBringLiquidityCall(params: {
2087
- amount: Web3Number;
2088
- }): Promise<Call>;
2089
- /**
2090
- * Gets all leaves from all leaf adapters.
2091
- * Note: This function is common for any SVK strategy.
2092
- */
2093
- getAllLeaves(): LeafData[];
2094
- /**
2095
- * Builds and caches the merkle tree from all leaf adapters.
2096
- * Note: This function is common for any SVK strategy.
2097
- */
2098
1489
  getMerkleTree(): StandardMerkleTree;
2099
- /**
2100
- * Gets the merkle root of the tree.
2101
- * Note: This function is common for any SVK strategy.
2102
- */
2103
1490
  getMerkleRoot(): string;
1491
+ getProofs<T>(id: string): {
1492
+ proofs: string[];
1493
+ callConstructor: GenerateCallFn<T>;
1494
+ };
2104
1495
  /**
2105
- * Combines proofs and manage calls into a single Starknet call.
2106
- * Note: This function is common for any SVK strategy.
1496
+ * Calculates user realized APY based on trueSharesBasedAPY method.
1497
+ * Returns the APY as a number.
2107
1498
  */
2108
- getManageCall(proofGroups: string[][], manageCalls: ManageCall[]): Call;
1499
+ getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
2109
1500
  /**
2110
- * Creates a call to set the merkle root on the manager contract.
2111
- * Note: This function is common for any SVK strategy.
1501
+ * Calculates the total TVL of the strategy.
1502
+ * @returns Object containing the total amount in token units and USD value
2112
1503
  */
2113
- getSetManagerCall(strategist: ContractAddr, root?: string): Call;
1504
+ getTVL(): Promise<SingleTokenInfo>;
1505
+ getUnusedBalance(): Promise<SingleTokenInfo>;
1506
+ protected getVesuAUM(adapter: VesuAdapter): Promise<Web3Number>;
1507
+ getPrevAUM(): Promise<Web3Number>;
1508
+ getAUM(): Promise<{
1509
+ net: SingleTokenInfo;
1510
+ prevAum: Web3Number;
1511
+ splits: {
1512
+ id: string;
1513
+ aum: Web3Number;
1514
+ }[];
1515
+ }>;
1516
+ protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
2114
1517
  /**
2115
- * Returns a tag for logging purposes.
2116
- * Should be overridden by subclasses to provide strategy-specific tags.
1518
+ * Gets an adapter by its ID from the metadata
2117
1519
  */
2118
- abstract getTag(): string;
1520
+ getAdapter(id: string): BaseAdapter;
2119
1521
  /**
2120
- * Returns the positions in the vault.
2121
- * @returns An array of VaultPosition objects representing the positions in the vault.
1522
+ * Calculates net APY for the strategy
1523
+ * @returns Promise with net APY and splits
2122
1524
  */
2123
- getVaultPositions(): Promise<VaultPosition[]>;
2124
- getHealthFactors(): Promise<number[]>;
2125
1525
  netAPY(): Promise<{
2126
1526
  net: number;
2127
1527
  splits: {
@@ -2129,555 +1529,300 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
2129
1529
  id: string;
2130
1530
  }[];
2131
1531
  }>;
2132
- getPrevAUM(): Promise<Web3Number>;
2133
- maxDepositables(): Promise<PositionInfo[]>;
2134
- maxWithdrawables(): Promise<PositionInfo[]>;
1532
+ getVesuAdapters(): VesuAdapter[];
1533
+ getVesuPositions(blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
1534
+ getVaultPositions(): Promise<VaultPosition[]>;
1535
+ getSetManagerCall(strategist: ContractAddr, root?: string): Call;
1536
+ getManageCall(proofIds: string[], manageCalls: ManageCall[]): Call;
1537
+ getVesuModifyPositionCalls(params: {
1538
+ isLeg1: boolean;
1539
+ isDeposit: boolean;
1540
+ depositAmount: Web3Number;
1541
+ debtAmount: Web3Number;
1542
+ }): UniversalManageCall[];
1543
+ getTag(): string;
1544
+ /**
1545
+ * Gets LST APR for the strategy's underlying asset from Endur API
1546
+ * @returns Promise<number> The LST APR (not divided by 1e18)
1547
+ */
1548
+ getLSTAPR(address: ContractAddr): Promise<number>;
1549
+ getVesuHealthFactors(blockNumber?: BlockIdentifier): Promise<number[]>;
1550
+ computeRebalanceConditionAndReturnCalls(): Promise<Call[]>;
1551
+ private getNewHealthFactor;
1552
+ /**
1553
+ *
1554
+ * @param vesuAdapter
1555
+ * @param currentHf
1556
+ * @param isDeposit if true, attempt by adding collateral, else by repaying
1557
+ * @returns
1558
+ */
1559
+ private getLegRebalanceAmount;
1560
+ getVesuModifyPositionCall(params: {
1561
+ isDeposit: boolean;
1562
+ leg1DepositAmount: Web3Number;
1563
+ }): Promise<Call>;
1564
+ getBringLiquidityCall(params: {
1565
+ amount: Web3Number;
1566
+ }): Promise<Call>;
1567
+ getPendingRewards(): Promise<HarvestInfo[]>;
1568
+ getHarvestCall(): Promise<{
1569
+ call: Call;
1570
+ reward: Web3Number;
1571
+ tokenInfo: TokenInfo;
1572
+ }>;
1573
+ getRebalanceCall(params: {
1574
+ isLeg1toLeg2: boolean;
1575
+ amount: Web3Number;
1576
+ }): Promise<Call>;
1577
+ }
1578
+ declare enum UNIVERSAL_MANAGE_IDS {
1579
+ FLASH_LOAN = "flash_loan_init",
1580
+ VESU_LEG1 = "vesu_leg1",
1581
+ VESU_LEG2 = "vesu_leg2",
1582
+ APPROVE_TOKEN1 = "approve_token1",
1583
+ APPROVE_TOKEN2 = "approve_token2",
1584
+ APPROVE_BRING_LIQUIDITY = "approve_bring_liquidity",
1585
+ BRING_LIQUIDITY = "bring_liquidity",
1586
+ DEFISPRING_REWARDS = "defispring_rewards",
1587
+ APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
1588
+ AVNU_SWAP_REWARDS = "avnu_swap_rewards"
2135
1589
  }
1590
+ declare enum UNIVERSAL_ADAPTERS {
1591
+ COMMON = "common_adapter",
1592
+ VESU_LEG1 = "vesu_leg1_adapter",
1593
+ VESU_LEG2 = "vesu_leg2_adapter"
1594
+ }
1595
+ declare function getContractDetails(settings: UniversalStrategySettings): {
1596
+ address: ContractAddr;
1597
+ name: string;
1598
+ }[];
1599
+ declare const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[];
2136
1600
 
2137
1601
  interface HyperLSTStrategySettings extends UniversalStrategySettings {
2138
1602
  borrowable_assets: TokenInfo[];
2139
1603
  underlyingToken: TokenInfo;
2140
- quoteAmountToFetchPrice: Web3Number;
2141
- targetHealthFactor: number;
2142
- minHealthFactor: number;
2143
- aumOracle: ContractAddr;
2144
1604
  }
2145
- declare class UniversalLstMultiplierStrategy<S extends HyperLSTStrategySettings> extends SVKStrategy<S> {
1605
+ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTStrategySettings> {
2146
1606
  private quoteAmountToFetchPrice;
2147
- constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
1607
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<HyperLSTStrategySettings>);
1608
+ asset(): TokenInfo;
2148
1609
  getTag(): string;
2149
- getVesuSameTokenAdapter(): VesuMultiplyAdapter;
2150
- getVesuAdapters(): VesuMultiplyAdapter[];
1610
+ getVesuSameTokenAdapter(): VesuAdapter;
1611
+ getVesuAdapters(): VesuAdapter[];
1612
+ protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
1613
+ getLSTUnderlyingTokenInfo(): TokenInfo;
1614
+ getLSTDexPrice(): Promise<number>;
1615
+ getAvnuSwapMultiplyCall(params: {
1616
+ isDeposit: boolean;
1617
+ leg1DepositAmount: Web3Number;
1618
+ }): Promise<{
1619
+ call: Call | undefined;
1620
+ vesuAdapter: VesuAdapter;
1621
+ }>;
1622
+ _getAvnuDepositSwapLegCall(params: {
1623
+ isDeposit: boolean;
1624
+ leg1DepositAmount: Web3Number;
1625
+ minHF: number;
1626
+ vesuAdapter: VesuAdapter;
1627
+ }): Promise<Call | undefined>;
1628
+ getLSTMultiplierRebalanceCall(): Promise<{
1629
+ shouldRebalance: boolean;
1630
+ manageCalls: {
1631
+ vesuAdapter: VesuAdapter;
1632
+ manageCall: Call;
1633
+ }[];
1634
+ }>;
1635
+ _getLSTMultiplierRebalanceCall(vesuAdapter: VesuAdapter): Promise<{
1636
+ shouldRebalance: boolean;
1637
+ manageCall: Call | undefined;
1638
+ }>;
1639
+ protected getVesuAUM(adapter: VesuAdapter): Promise<Web3Number>;
1640
+ private _getMinOutputAmountLSTBuy;
1641
+ private _getMinOutputAmountLSTSell;
2151
1642
  /**
2152
1643
  * Uses vesu's multiple call to create leverage on LST
2153
1644
  * Deposit amount is in LST
2154
1645
  * @param params
2155
1646
  */
2156
- getFundManagementCall(params: {
1647
+ getVesuMultiplyCall(params: {
2157
1648
  isDeposit: boolean;
2158
1649
  leg1DepositAmount: Web3Number;
2159
- }): Promise<Call[] | null>;
2160
- getLSTUnderlyingTokenInfo(): TokenInfo;
2161
- getAUM(): Promise<{
2162
- net: SingleTokenInfo;
2163
- prevAum: Web3Number;
2164
- splits: PositionInfo[];
2165
- }>;
2166
- }
2167
- declare const AUDIT_URL = "https://docs.troves.fi/p/security#starknet-vault-kit";
2168
- declare function getFAQs(lstSymbol: string, underlyingSymbol: string, isLST: boolean): FAQ[];
2169
- declare const _riskFactor: RiskFactor[];
2170
- declare function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string): string[];
2171
- declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
2172
-
2173
- declare abstract class Operations {
2174
- abstract shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<Call[]>;
2175
- abstract shouldInvest(): Promise<{
2176
- shouldInvest: boolean;
2177
- vesuAmount: Web3Number;
2178
- extendedAmount: Web3Number;
2179
- extendedLeverage: number;
2180
- vesuLeverage: number;
1650
+ maxEkuboPriceImpact?: number;
1651
+ }): Promise<Call[]>;
1652
+ getMaxBorrowableAmount(params?: {
1653
+ isAPYComputation: boolean;
1654
+ }): Promise<{
1655
+ netMaxBorrowableAmount: Web3Number;
1656
+ maxBorrowables: {
1657
+ amount: Web3Number;
1658
+ dexSwappableAmount: Web3Number;
1659
+ maxBorrowableAmount: Web3Number;
1660
+ borrowableAsset: TokenInfo;
1661
+ }[];
2181
1662
  }>;
2182
- abstract moveAssets(params: {
2183
- from: string;
2184
- to: string;
1663
+ getMaxSwappableWithMaxSlippage(fromToken: TokenInfo, toToken: TokenInfo, maxSlippage: number, maxAmount: Web3Number): Promise<Web3Number>;
1664
+ getMaxBorrowableAmountByVesuAdapter(vesuAdapter: VesuAdapter, isAPYComputation: boolean): Promise<{
2185
1665
  amount: Web3Number;
2186
- }, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<{
2187
- calls: Call[];
2188
- status: boolean;
2189
- }>;
2190
- abstract handleDeposit(): Promise<{
2191
- extendedAmountInBTC: Web3Number;
2192
- calls: Call[];
2193
- }>;
2194
- abstract handleWithdraw(amount: Web3Number): Promise<{
2195
- calls: Call[];
2196
- status: boolean;
2197
- }>;
2198
- }
2199
-
2200
- interface VesuExtendedStrategySettings extends UniversalStrategySettings {
2201
- underlyingToken: TokenInfo;
2202
- borrowable_assets: TokenInfo[];
2203
- targetHealthFactor: number;
2204
- quoteAmountToFetchPrice: Web3Number;
2205
- minHealthFactor: number;
2206
- aumOracle: ContractAddr;
2207
- minimumWBTCDifferenceForAvnuSwap: number;
2208
- }
2209
- declare class VesuExtendedMultiplierStrategy<S extends VesuExtendedStrategySettings> extends SVKStrategy<S> implements Operations {
2210
- constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
2211
- getTag(): string;
2212
- getAssetPrices(): Promise<{
2213
- collateralPrice: PriceInfo;
2214
- debtPrice: PriceInfo;
2215
- }>;
2216
- getUnusedBalanceUSDCE(): Promise<SingleTokenInfo>;
2217
- getUnusedBalanceWBTC(): Promise<SingleTokenInfo>;
2218
- getVesuAdapter(): Promise<VesuMultiplyAdapter | null>;
2219
- getAvnuAdapter(): Promise<AvnuAdapter | null>;
2220
- getExtendedAdapter(): Promise<ExtendedAdapter | null>;
2221
- moveAssetsToVaultAllocator(amount: Web3Number, extendedAdapter: ExtendedAdapter): Promise<Call[]>;
2222
- shouldInvest(): Promise<{
2223
- shouldInvest: boolean;
2224
- vesuAmount: Web3Number;
2225
- extendedAmount: Web3Number;
2226
- extendedLeverage: number;
2227
- collateralPrice: number;
2228
- debtPrice: number;
2229
- vesuLeverage: number;
1666
+ dexSwappableAmount: Web3Number;
1667
+ maxBorrowableAmount: Web3Number;
1668
+ borrowableAsset: TokenInfo;
2230
1669
  }>;
2231
- shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<Call[]>;
2232
- moveAssets(params: {
2233
- amount: Web3Number;
2234
- from: string;
2235
- to: string;
2236
- }, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<{
2237
- calls: Call[];
2238
- status: boolean;
1670
+ /**
1671
+ * Gets LST APR for the strategy's underlying asset from Endur API
1672
+ * @returns Promise<number> The LST APR (not divided by 1e18)
1673
+ */
1674
+ getLSTAPR(_address: ContractAddr): Promise<number>;
1675
+ netAPY(): Promise<{
1676
+ net: number;
1677
+ splits: {
1678
+ apy: number;
1679
+ id: string;
1680
+ }[];
2239
1681
  }>;
2240
- handleDeposit(): Promise<{
2241
- extendedAmountInBTC: Web3Number;
2242
- calls: Call[];
1682
+ maxNewDeposits(params?: {
1683
+ isAPYComputation: boolean;
1684
+ }): Promise<number>;
1685
+ /**
1686
+ * Gets Vesu APYs for all positions
1687
+ * @returns Object with positions, baseAPYs, and rewardAPYs
1688
+ */
1689
+ getVesuAPYs(): Promise<{
1690
+ positions: VaultPosition[];
1691
+ baseAPYs: number[];
1692
+ rewardAPYs: number[];
2243
1693
  }>;
2244
- checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter, avnuAdapter: AvnuAdapter): Promise<boolean>;
2245
- handleWithdraw(amount: Web3Number): Promise<{
2246
- calls: Call[];
2247
- status: boolean;
1694
+ /**
1695
+ * Returns net APY based on base APYs, reward APYs, weights, and AUM
1696
+ * @param baseAPYs Array of base APY values
1697
+ * @param rewardAPYs Array of reward APY values
1698
+ * @param weights Array of weights for each position
1699
+ * @param aum Total assets under management
1700
+ * @returns Object with net APY and splits
1701
+ */
1702
+ protected returnNetAPY(baseAPYs: number[], rewardAPYs: number[], weights: number[], aum: Web3Number): Promise<{
1703
+ net: number;
1704
+ splits: {
1705
+ apy: number;
1706
+ id: string;
1707
+ }[];
2248
1708
  }>;
2249
- getAUM(): Promise<{
2250
- net: SingleTokenInfo;
2251
- prevAum: Web3Number;
2252
- splits: PositionInfo[];
1709
+ protected getUnusedBalanceAPY(): Promise<{
1710
+ apy: number;
1711
+ weight: number;
2253
1712
  }>;
1713
+ getLSTExchangeRate(): Promise<number>;
1714
+ /**
1715
+ *
1716
+ * @param params marginAmount is in LST, debtAmount is in underlying
1717
+ */
1718
+ getModifyLeverCall(params: {
1719
+ marginAmount: Web3Number;
1720
+ debtAmount: Web3Number;
1721
+ lstDexPriceInUnderlying: number;
1722
+ isIncrease: boolean;
1723
+ maxEkuboPriceImpact: number;
1724
+ }): Promise<Call[]>;
2254
1725
  }
2255
- declare const VesuExtendedTestStrategies: (extendedBackendUrl: string, extendedApiKey: string, vaultIdExtended: number, minimumExtendedMovementAmount: number, minimumVesuMovementAmount: number, minimumExtendedRetriesDelayForOrderStatus: number) => IStrategyMetadata<VesuExtendedStrategySettings>[];
1726
+ declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
2256
1727
 
2257
- declare const AddressesConfig: {
2258
- readonly tokens: {
2259
- readonly USDC: {
2260
- readonly address: "0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8";
2261
- readonly decimals: 6;
2262
- };
2263
- readonly WBTC: {
2264
- readonly address: "0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac";
2265
- readonly decimals: 8;
2266
- };
2267
- };
2268
- readonly contracts: {
2269
- readonly EXTENDED: "0x062da0780fae50d68cecaa5a051606dc21217ba290969b302db4dd99d2e9b470";
2270
- readonly MULTIPLY: "0x07964760e90baa28841ec94714151e03fbc13321797e68a874e88f27c9d58513";
2271
- };
2272
- readonly wallet: {
2273
- readonly address: string;
2274
- };
2275
- };
2276
- declare const ExtendedConfig: {
2277
- readonly baseUrl: string;
2278
- readonly marketName: "BTC-USD";
2279
- readonly maintenanceMargin: 0.01;
2280
- readonly precision: 5;
2281
- readonly fees: number;
2282
- readonly minPositionSize: 0.0001;
2283
- };
2284
- declare const VesuConfig: {
2285
- readonly poolId: "0x02eef0c13b10b487ea5916b54c0a7f98ec43fb3048f60fdeedaf5b08f6f88aaf";
2286
- readonly maxLtv: 0.8428;
2287
- readonly maxLiquidationRatio: 0.86;
2288
- readonly targetHealthFactor: number;
2289
- readonly ekubo: {
2290
- readonly endpoint: "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_FROM_ADDRESS}}/{{TOKEN_TO_ADDRESS}}";
2291
- readonly priceMaxSlippage: number;
2292
- };
2293
- readonly avnu: {
2294
- readonly api: "https://starknet.api.avnu.fi/swap/v2/quotes";
2295
- };
2296
- readonly minDebtForVesuRebalacing: number;
2297
- };
2298
- declare const AbisConfig: {
2299
- readonly vesu: {
2300
- readonly multiply: ({
2301
- type: string;
2302
- name: string;
2303
- interface_name: string;
2304
- members?: undefined;
2305
- items?: undefined;
2306
- variants?: undefined;
2307
- inputs?: undefined;
2308
- kind?: undefined;
2309
- } | {
2310
- type: string;
2311
- name: string;
2312
- members: {
2313
- name: string;
2314
- type: string;
2315
- }[];
2316
- interface_name?: undefined;
2317
- items?: undefined;
2318
- variants?: undefined;
2319
- inputs?: undefined;
2320
- kind?: undefined;
2321
- } | {
2322
- type: string;
2323
- name: string;
2324
- items: {
2325
- type: string;
2326
- name: string;
2327
- inputs: {
2328
- name: string;
2329
- type: string;
2330
- }[];
2331
- outputs: {
2332
- type: string;
2333
- }[];
2334
- state_mutability: string;
2335
- }[];
2336
- interface_name?: undefined;
2337
- members?: undefined;
2338
- variants?: undefined;
2339
- inputs?: undefined;
2340
- kind?: undefined;
2341
- } | {
2342
- type: string;
2343
- name: string;
2344
- variants: {
2345
- name: string;
2346
- type: string;
2347
- }[];
2348
- interface_name?: undefined;
2349
- members?: undefined;
2350
- items?: undefined;
2351
- inputs?: undefined;
2352
- kind?: undefined;
2353
- } | {
2354
- type: string;
2355
- name: string;
2356
- inputs: {
2357
- name: string;
2358
- type: string;
2359
- }[];
2360
- interface_name?: undefined;
2361
- members?: undefined;
2362
- items?: undefined;
2363
- variants?: undefined;
2364
- kind?: undefined;
2365
- } | {
2366
- type: string;
2367
- name: string;
2368
- kind: string;
2369
- members: {
2370
- name: string;
2371
- type: string;
2372
- kind: string;
2373
- }[];
2374
- interface_name?: undefined;
2375
- items?: undefined;
2376
- variants?: undefined;
2377
- inputs?: undefined;
2378
- } | {
2379
- type: string;
2380
- name: string;
2381
- kind: string;
2382
- variants: {
2383
- name: string;
2384
- type: string;
2385
- kind: string;
2386
- }[];
2387
- interface_name?: undefined;
2388
- members?: undefined;
2389
- items?: undefined;
2390
- inputs?: undefined;
2391
- })[];
2392
- readonly pool: ({
2393
- type: string;
2394
- name: string;
2395
- interface_name: string;
2396
- members?: undefined;
2397
- variants?: undefined;
2398
- items?: undefined;
2399
- inputs?: undefined;
2400
- kind?: undefined;
2401
- } | {
2402
- type: string;
2403
- name: string;
2404
- members: {
2405
- name: string;
2406
- type: string;
2407
- }[];
2408
- interface_name?: undefined;
2409
- variants?: undefined;
2410
- items?: undefined;
2411
- inputs?: undefined;
2412
- kind?: undefined;
2413
- } | {
2414
- type: string;
2415
- name: string;
2416
- variants: {
2417
- name: string;
2418
- type: string;
2419
- }[];
2420
- interface_name?: undefined;
2421
- members?: undefined;
2422
- items?: undefined;
2423
- inputs?: undefined;
2424
- kind?: undefined;
2425
- } | {
2426
- type: string;
2427
- name: string;
2428
- items: {
2429
- type: string;
2430
- name: string;
2431
- inputs: {
2432
- name: string;
2433
- type: string;
2434
- }[];
2435
- outputs: {
2436
- type: string;
2437
- }[];
2438
- state_mutability: string;
2439
- }[];
2440
- interface_name?: undefined;
2441
- members?: undefined;
2442
- variants?: undefined;
2443
- inputs?: undefined;
2444
- kind?: undefined;
2445
- } | {
2446
- type: string;
2447
- name: string;
2448
- inputs: {
2449
- name: string;
2450
- type: string;
2451
- }[];
2452
- interface_name?: undefined;
2453
- members?: undefined;
2454
- variants?: undefined;
2455
- items?: undefined;
2456
- kind?: undefined;
2457
- } | {
2458
- type: string;
2459
- name: string;
2460
- kind: string;
2461
- members: {
2462
- name: string;
2463
- type: string;
2464
- kind: string;
2465
- }[];
2466
- interface_name?: undefined;
2467
- variants?: undefined;
2468
- items?: undefined;
2469
- inputs?: undefined;
2470
- } | {
2471
- type: string;
2472
- name: string;
2473
- kind: string;
2474
- variants: {
2475
- name: string;
2476
- type: string;
2477
- kind: string;
2478
- }[];
2479
- interface_name?: undefined;
2480
- members?: undefined;
2481
- items?: undefined;
2482
- inputs?: undefined;
2483
- })[];
2484
- };
2485
- readonly extended: {
2486
- readonly contract: ({
2487
- type: string;
2488
- name: string;
2489
- interface_name: string;
2490
- members?: undefined;
2491
- variants?: undefined;
2492
- items?: undefined;
2493
- inputs?: undefined;
2494
- kind?: undefined;
2495
- } | {
2496
- type: string;
2497
- name: string;
2498
- members: {
2499
- name: string;
2500
- type: string;
2501
- }[];
2502
- interface_name?: undefined;
2503
- variants?: undefined;
2504
- items?: undefined;
2505
- inputs?: undefined;
2506
- kind?: undefined;
2507
- } | {
2508
- type: string;
2509
- name: string;
2510
- variants: {
2511
- name: string;
2512
- type: string;
2513
- }[];
2514
- interface_name?: undefined;
2515
- members?: undefined;
2516
- items?: undefined;
2517
- inputs?: undefined;
2518
- kind?: undefined;
2519
- } | {
2520
- type: string;
2521
- name: string;
2522
- items: {
2523
- type: string;
2524
- name: string;
2525
- inputs: {
2526
- name: string;
2527
- type: string;
2528
- }[];
2529
- outputs: {
2530
- type: string;
2531
- }[];
2532
- state_mutability: string;
2533
- }[];
2534
- interface_name?: undefined;
2535
- members?: undefined;
2536
- variants?: undefined;
2537
- inputs?: undefined;
2538
- kind?: undefined;
2539
- } | {
2540
- type: string;
2541
- name: string;
2542
- inputs: {
2543
- name: string;
2544
- type: string;
2545
- }[];
2546
- interface_name?: undefined;
2547
- members?: undefined;
2548
- variants?: undefined;
2549
- items?: undefined;
2550
- kind?: undefined;
2551
- } | {
2552
- type: string;
2553
- name: string;
2554
- kind: string;
2555
- members: {
2556
- name: string;
2557
- type: string;
2558
- kind: string;
2559
- }[];
2560
- interface_name?: undefined;
2561
- variants?: undefined;
2562
- items?: undefined;
2563
- inputs?: undefined;
2564
- } | {
2565
- type: string;
2566
- name: string;
2567
- kind: string;
2568
- variants: {
2569
- name: string;
2570
- type: string;
2571
- kind: string;
2572
- }[];
2573
- interface_name?: undefined;
2574
- members?: undefined;
2575
- items?: undefined;
2576
- inputs?: undefined;
2577
- })[];
1728
+ /**
1729
+ * Filter option definition
1730
+ */
1731
+ interface FilterOption {
1732
+ id: string;
1733
+ label: string;
1734
+ icon?: string;
1735
+ }
1736
+ /**
1737
+ * Strategy filter metadata - defines what filters are available
1738
+ */
1739
+ interface StrategyFilterMetadata {
1740
+ assets: FilterOption[];
1741
+ protocols: FilterOption[];
1742
+ categories: FilterOption[];
1743
+ quickFilters: FilterOption[];
1744
+ }
1745
+ /**
1746
+ * Strategy type enum
1747
+ */
1748
+ declare enum StrategyType {
1749
+ EKUBO_CL = "ekubo",
1750
+ UNIVERSAL = "universal",
1751
+ HYPER_LST = "hyper-lst",
1752
+ VESU_REBALANCE = "vesu-rebalance",
1753
+ SENSEI = "sensei"
1754
+ }
1755
+ /**
1756
+ * Strategy metadata extracted from IStrategyMetadata
1757
+ */
1758
+ interface StrategyMetadata {
1759
+ id: string;
1760
+ name: string;
1761
+ type: StrategyType;
1762
+ assets: string[];
1763
+ protocols: string[];
1764
+ category: string;
1765
+ tags: string[];
1766
+ curator?: {
1767
+ name: string;
1768
+ logo: string;
2578
1769
  };
2579
- };
2580
-
1770
+ isRetired: boolean;
1771
+ }
2581
1772
  /**
2582
- * Function to return formatted amount to BigInt
2583
- * Converts a decimal amount to the proper format for blockchain transactions
2584
- * @param {number} amount - The decimal amount to convert
2585
- * @param {number} fromTokenDecimals - The decimal precision of the token
2586
- * @returns {string} The formatted amount as a hexadecimal string
1773
+ * Strategy registry entry
2587
1774
  */
2588
- declare const returnFormattedAmount: (amount: number, toTokenDecimals: number) => string;
1775
+ interface StrategyRegistryEntry<T = any> {
1776
+ metadata: IStrategyMetadata<T>;
1777
+ type: StrategyType;
1778
+ }
2589
1779
  /**
2590
- * calculates the amount to distribute to Extend and Vesu
2591
- * Determines how much to allocate to each platform based on leverage calculations
2592
- * @param {number} amount - The total amount to distribute
2593
- * @returns {object} Object containing avnu_amount, extended_amount, and extended_leverage
1780
+ * Build strategy registry from SDK strategies
2594
1781
  */
2595
- declare const calculateAmountDistribution: (amount: number, client: ExtendedWrapper, marketName: string, collateralPrice: number, debtPrice: number, collateralUnits: Web3Number, extendedPosition: Position[] | null) => Promise<{
2596
- vesu_amount: Web3Number;
2597
- extended_amount: Web3Number;
2598
- extended_leverage: number;
2599
- vesu_leverage: number;
2600
- }>;
1782
+ declare function buildStrategyRegistry(): StrategyRegistryEntry[];
2601
1783
  /**
2602
- * calculate the amount distribution for withdrawal
2603
- * @param amount - The amount to withdraw
2604
- * @param client - The client
2605
- * @param marketName - The market name
2606
- * @returns {object} Object containing avnu_amount and extended_amount
1784
+ * Get all strategy metadata from registry
2607
1785
  */
2608
- declare const calculateAmountDistributionForWithdrawal: (amountInUsdc: Web3Number, collateralPrice: number, collateralUnits: Web3Number, extendedPosition: Position[] | null) => Promise<{
2609
- vesu_amount: Web3Number;
2610
- extended_amount: Web3Number;
2611
- extended_leverage: number;
2612
- vesu_leverage: number;
2613
- } | null>;
1786
+ declare function getAllStrategyMetadata(): StrategyMetadata[];
2614
1787
  /**
2615
- * calculate the leverage required for Avnu
2616
- * calculates the optimal leverage for Avnu based on LTV ratios and price drop protection
2617
- * @returns {number} The calculated leverage value
1788
+ * Get filter metadata - defines available filters and their options
2618
1789
  */
2619
- declare const calculateVesuLeverage: () => number;
1790
+ declare function getFilterMetadata(): StrategyFilterMetadata;
2620
1791
  /**
2621
- * calculate leverage for extended
2622
- * calculates the maximum safe leverage for Extended based on maintenance margin and price drop protection
2623
- * @returns {number} The calculated leverage value
1792
+ * Get live strategies (filter out retired)
2624
1793
  */
2625
- declare const calculateExtendedLevergae: () => number;
1794
+ declare function getLiveStrategies(): StrategyRegistryEntry[];
2626
1795
  /**
2627
- * calculates the debt amount for leverage operations
2628
- * Determines how much debt to add or remove based on collateral changes and target health factor
2629
- * @param {Web3Number} collateralAmount - Current collateral amount
2630
- * @param {Web3Number} debtAmount - Current debt amount
2631
- * @param {number} debtPrice - Current price of the debt token
2632
- * @param {number} maxLtv - Maximum loan-to-value ratio (default: MAX_LTV_BTC_USDC)
2633
- * @param {number} addedAmount - Amount being added to collateral
2634
- * @param {number} collateralPrice - Current price of the collateral token
2635
- * @param {boolean} isDeposit - Whether this is a deposit (true) or withdrawal (false)
2636
- * @returns {object} Object containing deltadebtAmountUnits and isIncrease flag
1796
+ * Get strategies by type
2637
1797
  */
2638
- declare const calculateDebtAmount: (collateralAmount: Web3Number, debtAmount: Web3Number, debtPrice: number, maxLtv: number | undefined, addedAmount: Web3Number, // this is in btc
2639
- collateralPrice: number, isDeposit: boolean) => {
2640
- deltadebtAmountUnits: Web3Number;
2641
- isIncrease: boolean;
2642
- } | {
2643
- deltadebtAmountUnits: null;
2644
- isIncrease: null;
2645
- };
1798
+ declare function getStrategiesByType(type: StrategyType): StrategyRegistryEntry[];
1799
+
2646
1800
  /**
2647
- * calculate the debt amount to be repaid for withdrawal
2648
- * @param debtAmount in debt units
2649
- * @param collateralAmount in collateral units
2650
- * @param maxLtv in percentage
2651
- * @param withdrawalAmount in collateral units
2652
- * @param collateralPrice in usd
2653
- * @param debtPrice in usd
2654
- * @returns deltadebtAmountUnits in debt units
2655
- * isIncrease: true if the debt amount is increasing, false if it is decreasing
1801
+ * SDK Strategy Factory
1802
+ *
1803
+ * Creates SDK strategy instances from metadata.
2656
1804
  */
2657
- declare const calculateDebtReductionAmountForWithdrawal: (debtAmount: Web3Number, collateralAmount: Web3Number, maxLtv: number | undefined, withdrawalAmount: Web3Number, collateralPrice: number, debtPrice: number, usdcDecimals: number) => {
2658
- deltadebtAmountUnits: string;
2659
- } | {
2660
- deltadebtAmountUnits: null;
2661
- };
1805
+
1806
+ declare enum FactoryStrategyType {
1807
+ UNIVERSAL = "UNIVERSAL",
1808
+ EKUBO_CL = "EKUBO_CL",
1809
+ HYPER_LST = "HYPER_LST",
1810
+ VESU_REBALANCE = "VESU_REBALANCE",
1811
+ SENSEI = "SENSEI"
1812
+ }
1813
+ declare function createUniversalStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<UniversalStrategySettings>): UniversalStrategy<UniversalStrategySettings>;
1814
+ declare function createEkuboCLStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>): EkuboCLVault;
1815
+ declare function createHyperLSTStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<HyperLSTStrategySettings>): UniversalLstMultiplierStrategy;
1816
+ declare function createVesuRebalanceStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>): VesuRebalance;
1817
+ declare function createSenseiStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>): SenseiVault;
2662
1818
  /**
2663
- * calculate the amount to deposit on extended when incurring losses
2664
- * @param client - The client
2665
- * @returns The amount to deposit on extended when incurring losses
1819
+ * Determines the strategy type from metadata by inspecting the additionalInfo structure
2666
1820
  */
2667
- declare const calculateAmountDepositOnExtendedWhenIncurringLosses: (client: ExtendedWrapper) => Promise<Web3Number | null>;
2668
- declare const calculateExposureDelta: (exposure_extended: number, exposure_vesu: number) => number;
1821
+ declare function getStrategyTypeFromMetadata(metadata: IStrategyMetadata<any>): FactoryStrategyType;
2669
1822
  /**
2670
- * calculate the delta percentage between the current btc price and the last btc price
2671
- * @param {number} btcPrice - The current btc price
2672
- * @param {number} lastBtcPrice - The last btc price
2673
- * @returns {number} The delta percentage
1823
+ * Generic factory function that creates SDK strategy instances based on type
2674
1824
  */
2675
- declare const calculateBTCPriceDelta: (btcPrice: number, lastBtcPrice: number) => number;
2676
- declare const calculateVesUPositionSizeGivenExtended: (extendedPositonValue: number, extendedHoldingAmount: Web3Number, collateralAmount: Web3Number, collateralPrice: number) => {
2677
- vesuAmountInUsd: string;
2678
- vesuAmountInBTC: Web3Number;
2679
- extendedAmountInBTC: Web3Number;
2680
- };
1825
+ declare function createStrategy(type: FactoryStrategyType, config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<any>): VesuRebalance | EkuboCLVault | SenseiVault | UniversalStrategy<UniversalStrategySettings>;
2681
1826
 
2682
1827
  interface EkuboRouteNode {
2683
1828
  pool_key: {
@@ -2703,8 +1848,7 @@ interface EkuboQuote {
2703
1848
  declare class EkuboQuoter {
2704
1849
  private readonly config;
2705
1850
  ENDPOINT: string;
2706
- tokenMarketData: TokenMarketData;
2707
- constructor(config: IConfig, pricer: PricerBase);
1851
+ constructor(config: IConfig);
2708
1852
  /**
2709
1853
  *
2710
1854
  * @param fromToken
@@ -2713,9 +1857,6 @@ declare class EkuboQuoter {
2713
1857
  * @returns
2714
1858
  */
2715
1859
  getQuote(fromToken: string, toToken: string, amount: Web3Number, retry?: number): Promise<EkuboQuote>;
2716
- getDexPrice(baseToken: TokenInfo, quoteToken: TokenInfo, amount: Web3Number): Promise<number>;
2717
- getLSTTrueExchangeRate(baseToken: TokenInfo, quoteToken: TokenInfo, amount: Web3Number): Promise<number>;
2718
- getSwapLimitAmount(fromToken: TokenInfo, toToken: TokenInfo, amount: Web3Number, max_slippage?: number): Promise<Web3Number>;
2719
1860
  /**
2720
1861
  * Formats Ekubo response for Vesu multiple use
2721
1862
  * @param quote
@@ -2725,6 +1866,16 @@ declare class EkuboQuoter {
2725
1866
  getVesuMultiplyQuote(quote: EkuboQuote, fromTokenInfo: TokenInfo, toTokenInfo: TokenInfo): Swap[];
2726
1867
  }
2727
1868
 
1869
+ declare class EkuboPricer extends PricerBase {
1870
+ EKUBO_PRICE_FETCHER_ADDRESS: string;
1871
+ readonly contract: Contract;
1872
+ private readonly USDC_ADDRESS;
1873
+ private readonly USDC_DECIMALS;
1874
+ constructor(config: IConfig, tokens: TokenInfo[]);
1875
+ private div2Power128;
1876
+ getPrice(tokenAddr: string, blockIdentifier?: BlockIdentifier): Promise<PriceInfo>;
1877
+ }
1878
+
2728
1879
  declare class FatalError extends Error {
2729
1880
  constructor(message: string, err?: Error);
2730
1881
  }
@@ -2743,6 +1894,7 @@ declare class Global {
2743
1894
  static getTokens(): Promise<TokenInfo[]>;
2744
1895
  static assert(condition: any, message: string): void;
2745
1896
  static getTokenInfoFromAddr(addr: ContractAddr): Promise<TokenInfo>;
1897
+ static getTokenInfoFromName(tokenName: string): Promise<TokenInfo>;
2746
1898
  static setGlobalCache(key: string, data: any, ttl?: number): void;
2747
1899
  static getGlobalCache<T>(key: string): T | null;
2748
1900
  }
@@ -2776,9 +1928,6 @@ declare class LSTAPRService {
2776
1928
  private static cache;
2777
1929
  private static cacheTimestamp;
2778
1930
  private static readonly CACHE_DURATION;
2779
- static lstMapping: Record<string, TokenInfo>;
2780
- static isLST(address: ContractAddr): boolean;
2781
- static getUnderlyingFromLST(lstAddress: ContractAddr): TokenInfo;
2782
1931
  /**
2783
1932
  * Fetches LST stats from Endur API with caching
2784
1933
  * @returns Promise<LSTStats[]> Array of LST statistics
@@ -2807,73 +1956,6 @@ declare class LSTAPRService {
2807
1956
  static clearCache(): void;
2808
1957
  }
2809
1958
 
2810
- /**
2811
- * Midas module for interacting with Midas API
2812
- * Provides functions to get APY, price, and TVL data for Midas tokens
2813
- */
2814
- declare class Midas {
2815
- private static readonly CONTRACT_TO_SYMBOL;
2816
- private static readonly BASE_URL;
2817
- /**
2818
- * Check if a contract address is supported by Midas
2819
- * @param contractAddr The contract address to check
2820
- * @returns True if the contract address is supported
2821
- */
2822
- static isSupported(contractAddr: ContractAddr): boolean;
2823
- /**
2824
- * Get the Midas symbol for a given contract address
2825
- * @param contractAddr The contract address to look up
2826
- * @returns The Midas symbol for the contract
2827
- * @throws Error if contract address is not found
2828
- */
2829
- static getSymbolFromContract(contractAddr: ContractAddr): string;
2830
- /**
2831
- * Get APY data for all Midas tokens
2832
- * @returns Object with token symbols as keys and APY values as numbers
2833
- * @throws Error if API request fails
2834
- */
2835
- static getAPYs(): Promise<Record<string, number>>;
2836
- /**
2837
- * Get APY for a specific token by contract address
2838
- * @param contractAddr The contract address of the token
2839
- * @returns The APY value for the token
2840
- * @throws Error if contract address not found or API request fails
2841
- */
2842
- static getAPY(contractAddr: ContractAddr): Promise<number>;
2843
- /**
2844
- * Get price data for a specific token
2845
- * @param contractAddr The contract address of the token
2846
- * @param timestampFrom Optional start timestamp (defaults to 30 days ago)
2847
- * @param timestampTo Optional end timestamp (defaults to now)
2848
- * @param environment Environment (defaults to 'mainnet')
2849
- * @returns The latest price for the token
2850
- * @throws Error if contract address not found or API request fails
2851
- */
2852
- static getPrice(contractAddr: ContractAddr, timestampFrom?: number, timestampTo?: number, environment?: string): Promise<number>;
2853
- /**
2854
- * Get TVL data for all tokens
2855
- * @param environment Environment (defaults to 'mainnet')
2856
- * @returns Object with TVL data including totalTvl and tokenTvl
2857
- * @throws Error if API request fails
2858
- */
2859
- static getTVLData(environment?: string): Promise<{
2860
- lastUpdatedAt: string;
2861
- totalTvl: number;
2862
- tokenTvl: Record<string, any>;
2863
- }>;
2864
- /**
2865
- * Get TVL for a specific token by contract address
2866
- * @param contractAddr The contract address of the token
2867
- * @param environment Environment (defaults to 'mainnet')
2868
- * @returns The TVL data for the token (USD and native amounts)
2869
- * @throws Error if contract address not found or API request fails
2870
- */
2871
- static getTVL(contractAddr: ContractAddr, environment?: string): Promise<{
2872
- usd: number;
2873
- native: number;
2874
- } | number>;
2875
- }
2876
-
2877
1959
  declare class TelegramNotif {
2878
1960
  private subscribers;
2879
1961
  readonly bot: TelegramBot;
@@ -2910,7 +1992,7 @@ declare class PricerRedis extends Pricer {
2910
1992
  /** sets current local price in redis */
2911
1993
  private _setRedisPrices;
2912
1994
  /** Returns price from redis */
2913
- getPrice(tokenSymbol: string): Promise<PriceInfo>;
1995
+ getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
2914
1996
  }
2915
1997
 
2916
1998
  declare function getAPIUsingHeadlessBrowser(url: string): Promise<any>;
@@ -2937,6 +2019,7 @@ declare function executeDeployCalls(contractsInfo: DeployContractResult[], acc:
2937
2019
  declare function executeTransactions(calls: Call[], acc: Account, provider: RpcProvider, remarks?: string): Promise<{
2938
2020
  transaction_hash: string;
2939
2021
  }>;
2022
+ declare function myWaitForTransaction(transaction_hash: string, provider: RpcProvider, retry?: number): Promise<boolean>;
2940
2023
  declare const Deployer: {
2941
2024
  getAccount: typeof getAccount;
2942
2025
  myDeclare: typeof myDeclare;
@@ -2944,6 +2027,7 @@ declare const Deployer: {
2944
2027
  prepareMultiDeployContracts: typeof prepareMultiDeployContracts;
2945
2028
  executeDeployCalls: typeof executeDeployCalls;
2946
2029
  executeTransactions: typeof executeTransactions;
2030
+ myWaitForTransaction: typeof myWaitForTransaction;
2947
2031
  };
2948
2032
 
2949
2033
  /**
@@ -3024,4 +2108,4 @@ declare class PasswordJsonCryptoUtil {
3024
2108
  decrypt(encryptedData: string, password: string): any;
3025
2109
  }
3026
2110
 
3027
- 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 };
2111
+ export { APYType, AUMTypes, AVNU_EXCHANGE, AVNU_MIDDLEWARE, type AccessControlInfo, AccessControlType, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type AmountInfo, type AmountsInfo, type ApproveCallParams, AuditStatus, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, 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, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, InstantWithdrawalVault, LSTAPRService, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, MyNumber, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, type PositionAPY, type PositionInfo, Pragma, type PriceInfo, Pricer, PricerBase, PricerFromApi, PricerLST, PricerRedis, Protocols, type RedemptionExpectedTime, 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, type SecurityMetadata, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, type SourceCodeInfo, SourceCodeType, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type StrategyAlert, type StrategyCapabilities, StrategyCategory, type StrategyFilterMetadata, StrategyLiveStatus, type StrategyMetadata, type StrategyRegistryEntry, type StrategySettings, StrategyTag, StrategyType, type SupportedPosition, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, type VesuMultiplyCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, buildStrategyRegistry, createEkuboCLStrategy, createHyperLSTStrategy, createSenseiStrategy, createStrategy, createUniversalStrategy, createVesuRebalanceStrategy, detectCapabilities, extensionMap, getAPIUsingHeadlessBrowser, getAllStrategyMetadata, getContractDetails, getDefaultStoreConfig, getFilterMetadata, getLiveStrategies, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getStrategiesByType, getStrategyTypeFromMetadata, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, isDualTokenStrategy, logger, toAmountsInfo, toBigInt };