@strkfarm/sdk 1.0.17 → 1.0.19

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.
package/dist/index.d.ts CHANGED
@@ -1,19 +1,26 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import * as starknet from 'starknet';
3
- import { RpcProvider, BlockIdentifier, Contract, Account } from 'starknet';
3
+ import { RpcProvider, BlockIdentifier, Contract, Uint256, Call, Account } from 'starknet';
4
+ import { Quote } from '@avnu/avnu-sdk';
4
5
  import * as util from 'util';
5
6
  import TelegramBot from 'node-telegram-bot-api';
6
7
 
7
- declare class Web3Number extends BigNumber {
8
+ declare class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
8
9
  decimals: number;
9
10
  constructor(value: string | number, decimals: number);
10
- static fromWei(weiNumber: string | number, decimals: number): Web3Number;
11
11
  toWei(): string;
12
- multipliedBy(value: string | number): Web3Number;
13
- dividedBy(value: string | number): Web3Number;
14
- plus(value: string | number): Web3Number;
15
- minus(n: number | string, base?: number): Web3Number;
12
+ multipliedBy(value: string | number | T): T;
13
+ dividedBy(value: string | number | T): T;
14
+ plus(value: string | number | T): T;
15
+ minus(n: number | string | T, base?: number): T;
16
+ protected construct(value: string | number, decimals: number): T;
16
17
  toString(base?: number | undefined): string;
18
+ toJSON(): string;
19
+ valueOf(): string;
20
+ }
21
+
22
+ declare class Web3Number extends _Web3Number<Web3Number> {
23
+ static fromWei(weiNumber: string | number, decimals: number): Web3Number;
17
24
  }
18
25
 
19
26
  /**
@@ -28,15 +35,18 @@ declare class ContractAddr {
28
35
  eqString(other: string): boolean;
29
36
  static standardise(address: string | bigint): string;
30
37
  static eqString(a: string, b: string): boolean;
38
+ toString(): string;
31
39
  }
32
40
 
33
41
  declare enum RiskType {
34
- MARKET_RISK = "MARKET_RISK",
35
- IMPERMANENT_LOSS = "IMPERMANENT_LOSS",
36
- LIQUIDITY_RISK = "LIQUIDITY_RISK",
37
- SMART_CONTRACT_RISK = "SMART_CONTRACT_RISK",
38
- TECHNICAL_RISK = "TECHNICAL_RISK",
39
- COUNTERPARTY_RISK = "COUNTERPARTY_RISK"
42
+ MARKET_RISK = "Market Risk",
43
+ IMPERMANENT_LOSS = "Impermanent Loss Risk",
44
+ LIQUIDATION_RISK = "Liquidation Risk",
45
+ LOW_LIQUIDITY_RISK = "Low Liquidity Risk",
46
+ SMART_CONTRACT_RISK = "Smart Contract Risk",
47
+ ORACLE_RISK = "Oracle Risk",
48
+ TECHNICAL_RISK = "Technical Risk",
49
+ COUNTERPARTY_RISK = "Counterparty Risk"
40
50
  }
41
51
  interface RiskFactor {
42
52
  type: RiskType;
@@ -46,7 +56,7 @@ interface RiskFactor {
46
56
  interface TokenInfo {
47
57
  name: string;
48
58
  symbol: string;
49
- address: string;
59
+ address: ContractAddr;
50
60
  decimals: number;
51
61
  logo: string;
52
62
  coingeckId?: string;
@@ -66,11 +76,16 @@ interface IProtocol {
66
76
  name: string;
67
77
  logo: string;
68
78
  }
79
+ declare enum FlowChartColors {
80
+ Green = "purple",
81
+ Blue = "#35484f",
82
+ Purple = "#6e53dc"
83
+ }
69
84
  /**
70
85
  * @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
71
86
  * @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
72
87
  */
73
- interface IStrategyMetadata {
88
+ interface IStrategyMetadata<T> {
74
89
  name: string;
75
90
  description: string;
76
91
  address: ContractAddr;
@@ -83,13 +98,21 @@ interface IStrategyMetadata {
83
98
  riskFactor: RiskFactor[];
84
99
  netRisk: number;
85
100
  };
101
+ additionalInfo: T;
86
102
  }
87
103
  interface IInvestmentFlow {
88
104
  title: string;
89
- subItems: string[];
105
+ subItems: {
106
+ key: string;
107
+ value: string;
108
+ }[];
90
109
  linkedFlows: IInvestmentFlow[];
110
+ style?: any;
91
111
  }
92
112
  declare function getMainnetConfig(rpcUrl?: string, blockIdentifier?: BlockIdentifier): IConfig;
113
+ declare const getRiskExplaination: (riskType: RiskType) => "The risk of the market moving against the position." | "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them." | "The risk of losing funds due to the position being liquidated." | "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position." | "The risk of the oracle being manipulated or incorrect." | "The risk of the smart contract being vulnerable to attacks." | "The risk of technical issues e.g. backend failure." | "The risk of the counterparty defaulting e.g. bad debt on lending platforms.";
114
+ declare const getRiskColor: (risk: RiskFactor) => "green" | "yellow" | "red";
115
+ declare const getNoRiskTags: (risks: RiskFactor[]) => string[];
93
116
 
94
117
  interface ILendingMetadata {
95
118
  name: string;
@@ -225,6 +248,36 @@ declare class PricerFromApi extends PricerBase {
225
248
  }>;
226
249
  }
227
250
 
251
+ declare class ERC20 {
252
+ readonly config: IConfig;
253
+ constructor(config: IConfig);
254
+ contract(addr: string | ContractAddr): Contract;
255
+ balanceOf(token: string | ContractAddr, address: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
256
+ }
257
+
258
+ interface Route {
259
+ token_from: string;
260
+ token_to: string;
261
+ exchange_address: string;
262
+ percent: number;
263
+ additional_swap_params: string[];
264
+ }
265
+ interface SwapInfo {
266
+ token_from_address: string;
267
+ token_from_amount: Uint256;
268
+ token_to_address: string;
269
+ token_to_amount: Uint256;
270
+ token_to_min_amount: Uint256;
271
+ beneficiary: string;
272
+ integrator_fee_amount_bps: number;
273
+ integrator_fee_recipient: string;
274
+ routes: Route[];
275
+ }
276
+ declare class AvnuWrapper {
277
+ getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string): Promise<Quote>;
278
+ getSwapInfo(quote: Quote, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount: string): Promise<SwapInfo>;
279
+ }
280
+
228
281
  declare const logger: {
229
282
  verbose(message: string): void;
230
283
  assert(condition?: boolean, ...data: any[]): void;
@@ -283,6 +336,7 @@ declare class Global {
283
336
  static getDefaultTokens(): TokenInfo[];
284
337
  static getTokens(): Promise<TokenInfo[]>;
285
338
  static assert(condition: any, message: string): void;
339
+ static getTokenInfoFromAddr(addr: ContractAddr): Promise<TokenInfo>;
286
340
  }
287
341
 
288
342
  declare class AutoCompounderSTRK {
@@ -314,12 +368,40 @@ declare class AutoCompounderSTRK {
314
368
  }>;
315
369
  }
316
370
 
371
+ interface SingleActionAmount {
372
+ tokenInfo: TokenInfo;
373
+ amount: Web3Number;
374
+ }
375
+ interface SingleTokenInfo extends SingleActionAmount {
376
+ usdValue: number;
377
+ }
378
+ interface DualActionAmount {
379
+ token0: SingleActionAmount;
380
+ token1: SingleActionAmount;
381
+ }
382
+ interface DualTokenInfo {
383
+ netUsdValue: number;
384
+ token0: SingleTokenInfo;
385
+ token1: SingleTokenInfo;
386
+ }
387
+ declare class BaseStrategy<TVLInfo, ActionInfo> {
388
+ readonly config: IConfig;
389
+ constructor(config: IConfig);
390
+ getUserTVL(user: ContractAddr): Promise<TVLInfo>;
391
+ getTVL(): Promise<TVLInfo>;
392
+ depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Call[];
393
+ withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Call[];
394
+ }
395
+
317
396
  interface Change {
318
397
  pool_id: ContractAddr;
319
398
  changeAmt: Web3Number;
320
399
  finalAmt: Web3Number;
321
400
  isDeposit: boolean;
322
401
  }
402
+ interface VesuRebalanceSettings {
403
+ feeBps: number;
404
+ }
323
405
  interface PoolInfoFull {
324
406
  pool_id: ContractAddr;
325
407
  pool_name: string | undefined;
@@ -341,15 +423,13 @@ interface PoolInfoFull {
341
423
  * This class implements an automated rebalancing strategy for Vesu pools,
342
424
  * managing deposits and withdrawals while optimizing yield through STRK rewards.
343
425
  */
344
- declare class VesuRebalance {
345
- /** Configuration object for the strategy */
346
- readonly config: IConfig;
426
+ declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
347
427
  /** Contract address of the strategy */
348
428
  readonly address: ContractAddr;
349
429
  /** Pricer instance for token price calculations */
350
430
  readonly pricer: PricerBase;
351
431
  /** Metadata containing strategy information */
352
- readonly metadata: IStrategyMetadata;
432
+ readonly metadata: IStrategyMetadata<VesuRebalanceSettings>;
353
433
  /** Contract instance for interacting with the strategy */
354
434
  readonly contract: Contract;
355
435
  readonly BASE_WEIGHT = 10000;
@@ -360,14 +440,14 @@ declare class VesuRebalance {
360
440
  * @param metadata - Strategy metadata including deposit tokens and address
361
441
  * @throws {Error} If more than one deposit token is specified
362
442
  */
363
- constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata);
443
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>);
364
444
  /**
365
445
  * Creates a deposit call to the strategy contract.
366
446
  * @param assets - Amount of assets to deposit
367
447
  * @param receiver - Address that will receive the strategy tokens
368
448
  * @returns Populated contract call for deposit
369
449
  */
370
- depositCall(assets: Web3Number, receiver: ContractAddr): starknet.Call[];
450
+ depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): starknet.Call[];
371
451
  /**
372
452
  * Creates a withdrawal call to the strategy contract.
373
453
  * @param assets - Amount of assets to withdraw
@@ -375,7 +455,7 @@ declare class VesuRebalance {
375
455
  * @param owner - Address that owns the strategy tokens
376
456
  * @returns Populated contract call for withdrawal
377
457
  */
378
- withdrawCall(assets: Web3Number, receiver: ContractAddr, owner: ContractAddr): starknet.Call[];
458
+ withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): starknet.Call[];
379
459
  /**
380
460
  * Returns the underlying asset token of the strategy.
381
461
  * @returns The deposit token supported by this strategy
@@ -392,6 +472,7 @@ declare class VesuRebalance {
392
472
  * @returns Object containing the amount in token units and USD value
393
473
  */
394
474
  getUserTVL(user: ContractAddr): Promise<{
475
+ tokenInfo: TokenInfo;
395
476
  amount: Web3Number;
396
477
  usdValue: number;
397
478
  }>;
@@ -400,9 +481,11 @@ declare class VesuRebalance {
400
481
  * @returns Object containing the total amount in token units and USD value
401
482
  */
402
483
  getTVL(): Promise<{
484
+ tokenInfo: TokenInfo;
403
485
  amount: Web3Number;
404
486
  usdValue: number;
405
487
  }>;
488
+ static getAllPossibleVerifiedPools(asset: ContractAddr): Promise<any>;
406
489
  /**
407
490
  * Retrieves the list of allowed pools and their detailed information from multiple sources:
408
491
  * 1. Contract's allowed pools
@@ -485,7 +568,108 @@ declare class VesuRebalance {
485
568
  /**
486
569
  * Represents the Vesu Rebalance Strategies.
487
570
  */
488
- declare const VesuRebalanceStrategies: IStrategyMetadata[];
571
+ declare const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[];
572
+
573
+ interface EkuboPoolKey {
574
+ token0: ContractAddr;
575
+ token1: ContractAddr;
576
+ fee: string;
577
+ tick_spacing: string;
578
+ extension: string;
579
+ }
580
+ interface EkuboBounds {
581
+ lowerTick: bigint;
582
+ upperTick: bigint;
583
+ }
584
+ /**
585
+ * Settings for the CLVaultStrategy
586
+ *
587
+ * @property newBounds - The new bounds for the strategy
588
+ * @property newBounds.lower - relative to the current tick
589
+ * @property newBounds.upper - relative to the current tick
590
+ */
591
+ interface CLVaultStrategySettings {
592
+ newBounds: {
593
+ lower: number;
594
+ upper: number;
595
+ };
596
+ lstContract: ContractAddr;
597
+ }
598
+ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
599
+ /** Contract address of the strategy */
600
+ readonly address: ContractAddr;
601
+ /** Pricer instance for token price calculations */
602
+ readonly pricer: PricerBase;
603
+ /** Metadata containing strategy information */
604
+ readonly metadata: IStrategyMetadata<CLVaultStrategySettings>;
605
+ /** Contract instance for interacting with the strategy */
606
+ readonly contract: Contract;
607
+ readonly BASE_WEIGHT = 10000;
608
+ readonly ekuboPositionsContract: Contract;
609
+ readonly ekuboMathContract: Contract;
610
+ readonly lstContract: Contract;
611
+ poolKey: EkuboPoolKey | undefined;
612
+ readonly avnu: AvnuWrapper;
613
+ /**
614
+ * Creates a new VesuRebalance strategy instance.
615
+ * @param config - Configuration object containing provider and other settings
616
+ * @param pricer - Pricer instance for token price calculations
617
+ * @param metadata - Strategy metadata including deposit tokens and address
618
+ * @throws {Error} If more than one deposit token is specified
619
+ */
620
+ constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>);
621
+ depositCall(amountInfo: DualActionAmount, receiver: ContractAddr): Call[];
622
+ withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Call[];
623
+ rebalanceCall(newBounds: EkuboBounds, swapParams: SwapInfo): Call[];
624
+ handleUnusedCall(swapParams: SwapInfo): Call[];
625
+ handleFeesCall(): Call[];
626
+ getUserTVL(user: ContractAddr): Promise<DualTokenInfo>;
627
+ getTVL(): Promise<DualTokenInfo>;
628
+ getUncollectedFees(): Promise<DualTokenInfo>;
629
+ getCurrentNFTID(): Promise<number>;
630
+ truePrice(): Promise<number>;
631
+ getCurrentPrice(): Promise<{
632
+ price: number;
633
+ tick: number;
634
+ }>;
635
+ private _getCurrentPrice;
636
+ getCurrentBounds(): Promise<EkuboBounds>;
637
+ static div2Power128(num: BigInt): number;
638
+ static priceToTick(price: number, isRoundDown: boolean, tickSpacing: number): {
639
+ mag: number;
640
+ sign: number;
641
+ };
642
+ getPoolKey(): Promise<EkuboPoolKey>;
643
+ getNewBounds(): Promise<EkuboBounds>;
644
+ /**
645
+ * Computes the expected amounts to fully utilize amount in
646
+ * to add liquidity to the pool
647
+ * @param amount0: amount of token0
648
+ * @param amount1: amount of token1
649
+ * @returns {amount0, amount1}
650
+ */
651
+ private _getExpectedAmountsForLiquidity;
652
+ private _solveExpectedAmountsEq;
653
+ getSwapInfoToHandleUnused(considerRebalance?: boolean): Promise<SwapInfo>;
654
+ static tickToi129(tick: number): {
655
+ mag: number;
656
+ sign: number;
657
+ };
658
+ static priceToSqrtRatio(price: number): bigint;
659
+ static i129ToNumber(i129: {
660
+ mag: bigint;
661
+ sign: number;
662
+ }): bigint;
663
+ static tickToPrice(tick: bigint): number;
664
+ getLiquidityToAmounts(liquidity: Web3Number, bounds: EkuboBounds): Promise<{
665
+ amount0: Web3Number;
666
+ amount1: Web3Number;
667
+ }>;
668
+ }
669
+ /**
670
+ * Represents the Vesu Rebalance Strategies.
671
+ */
672
+ declare const EkuboCLVaultStrategies: IStrategyMetadata<CLVaultStrategySettings>[];
489
673
 
490
674
  declare class TelegramNotif {
491
675
  private subscribers;
@@ -516,6 +700,8 @@ declare class PricerRedis extends Pricer {
516
700
  getPrice(tokenSymbol: string): Promise<PriceInfo>;
517
701
  }
518
702
 
703
+ declare function getAPIUsingHeadlessBrowser(url: string): Promise<any>;
704
+
519
705
  /**
520
706
  * @description Config to manage storage of files on disk
521
707
  * @param SECRET_FILE_FOLDER - Folder to store secret files (default: ~/.starknet-store)
@@ -594,4 +780,4 @@ declare class PasswordJsonCryptoUtil {
594
780
  decrypt(encryptedData: string, password: string): any;
595
781
  }
596
782
 
597
- export { type AccountInfo, type AllAccountsStore, AutoCompounderSTRK, ContractAddr, FatalError, Global, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, Initializable, type LendingToken, MarginType, Network, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerRedis, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, Store, type StoreConfig, TelegramNotif, type TokenInfo, VesuRebalance, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getDefaultStoreConfig, getMainnetConfig, logger };
783
+ export { type AccountInfo, type AllAccountsStore, AutoCompounderSTRK, AvnuWrapper, type CLVaultStrategySettings, ContractAddr, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, FatalError, FlowChartColors, Global, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, Initializable, type LendingToken, MarginType, Network, PasswordJsonCryptoUtil, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerRedis, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, Store, type StoreConfig, type SwapInfo, TelegramNotif, type TokenInfo, VesuRebalance, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, logger };