@strkfarm/sdk 1.0.28 → 1.0.29
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/cli.js +48 -24
- package/dist/cli.mjs +46 -22
- package/dist/index.browser.global.js +496 -75
- package/dist/index.browser.mjs +504 -82
- package/dist/index.d.ts +56 -15
- package/dist/index.js +511 -88
- package/dist/index.mjs +506 -84
- package/package.json +1 -1
- package/src/dataTypes/_bignumber.ts +15 -7
- package/src/global.ts +13 -6
- package/src/interfaces/common.ts +3 -0
- package/src/modules/avnu.ts +74 -59
- package/src/modules/harvests.ts +74 -0
- package/src/modules/pricer-from-api.ts +9 -8
- package/src/modules/zkLend.ts +2 -1
- package/src/strategies/base-strategy.ts +3 -3
- package/src/strategies/ekubo-cl-vault.ts +477 -55
- package/src/strategies/index.ts +2 -1
- package/src/strategies/vesu-rebalance.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
|
|
|
18
18
|
toJSON(): string;
|
|
19
19
|
valueOf(): string;
|
|
20
20
|
private maxToFixedDecimals;
|
|
21
|
+
private getStandardString;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
declare class Web3Number extends _Web3Number<Web3Number> {
|
|
@@ -61,6 +62,7 @@ interface TokenInfo {
|
|
|
61
62
|
decimals: number;
|
|
62
63
|
logo: string;
|
|
63
64
|
coingeckId?: string;
|
|
65
|
+
displayDecimals: number;
|
|
64
66
|
}
|
|
65
67
|
declare enum Network {
|
|
66
68
|
mainnet = "mainnet",
|
|
@@ -100,9 +102,11 @@ interface IStrategyMetadata<T> {
|
|
|
100
102
|
netRisk: number;
|
|
101
103
|
notARisks: string[];
|
|
102
104
|
};
|
|
105
|
+
apyMethodology?: string;
|
|
103
106
|
additionalInfo: T;
|
|
104
107
|
}
|
|
105
108
|
interface IInvestmentFlow {
|
|
109
|
+
id?: string;
|
|
106
110
|
title: string;
|
|
107
111
|
subItems: {
|
|
108
112
|
key: string;
|
|
@@ -276,7 +280,7 @@ interface SwapInfo {
|
|
|
276
280
|
routes: Route[];
|
|
277
281
|
}
|
|
278
282
|
declare class AvnuWrapper {
|
|
279
|
-
getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string): Promise<Quote>;
|
|
283
|
+
getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number): Promise<Quote>;
|
|
280
284
|
getSwapInfo(quote: Quote, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount: string): Promise<SwapInfo>;
|
|
281
285
|
}
|
|
282
286
|
|
|
@@ -382,7 +386,7 @@ interface DualActionAmount {
|
|
|
382
386
|
token1: SingleActionAmount;
|
|
383
387
|
}
|
|
384
388
|
interface DualTokenInfo {
|
|
385
|
-
|
|
389
|
+
usdValue: number;
|
|
386
390
|
token0: SingleTokenInfo;
|
|
387
391
|
token1: SingleTokenInfo;
|
|
388
392
|
}
|
|
@@ -391,8 +395,8 @@ declare class BaseStrategy<TVLInfo, ActionInfo> {
|
|
|
391
395
|
constructor(config: IConfig);
|
|
392
396
|
getUserTVL(user: ContractAddr): Promise<TVLInfo>;
|
|
393
397
|
getTVL(): Promise<TVLInfo>;
|
|
394
|
-
depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Call[]
|
|
395
|
-
withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Call[]
|
|
398
|
+
depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Promise<Call[]>;
|
|
399
|
+
withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
396
400
|
}
|
|
397
401
|
|
|
398
402
|
interface PoolProps {
|
|
@@ -454,7 +458,7 @@ declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAm
|
|
|
454
458
|
* @param receiver - Address that will receive the strategy tokens
|
|
455
459
|
* @returns Populated contract call for deposit
|
|
456
460
|
*/
|
|
457
|
-
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): starknet.Call[]
|
|
461
|
+
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<starknet.Call[]>;
|
|
458
462
|
/**
|
|
459
463
|
* Creates a withdrawal call to the strategy contract.
|
|
460
464
|
* @param assets - Amount of assets to withdraw
|
|
@@ -462,7 +466,7 @@ declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAm
|
|
|
462
466
|
* @param owner - Address that owns the strategy tokens
|
|
463
467
|
* @returns Populated contract call for withdrawal
|
|
464
468
|
*/
|
|
465
|
-
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): starknet.Call[]
|
|
469
|
+
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<starknet.Call[]>;
|
|
466
470
|
/**
|
|
467
471
|
* Returns the underlying asset token of the strategy.
|
|
468
472
|
* @returns The deposit token supported by this strategy
|
|
@@ -617,6 +621,7 @@ interface CLVaultStrategySettings {
|
|
|
617
621
|
upper: number;
|
|
618
622
|
};
|
|
619
623
|
lstContract: ContractAddr;
|
|
624
|
+
feeBps: number;
|
|
620
625
|
}
|
|
621
626
|
declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
|
|
622
627
|
/** Contract address of the strategy */
|
|
@@ -641,28 +646,43 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
641
646
|
* @throws {Error} If more than one deposit token is specified
|
|
642
647
|
*/
|
|
643
648
|
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>);
|
|
644
|
-
|
|
645
|
-
|
|
649
|
+
matchInputAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
|
|
650
|
+
/** Returns minimum amounts give given two amounts based on what can be added for liq */
|
|
651
|
+
getMinDepositAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
|
|
652
|
+
depositCall(amountInfo: DualActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
653
|
+
tokensToShares(amountInfo: DualActionAmount): Promise<Web3Number>;
|
|
654
|
+
withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
646
655
|
rebalanceCall(newBounds: EkuboBounds, swapParams: SwapInfo): Call[];
|
|
647
656
|
handleUnusedCall(swapParams: SwapInfo): Call[];
|
|
648
657
|
handleFeesCall(): Call[];
|
|
649
|
-
|
|
650
|
-
|
|
658
|
+
/**
|
|
659
|
+
* Calculates assets before and now in a given token of TVL per share to observe growth
|
|
660
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
661
|
+
*/
|
|
662
|
+
netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
663
|
+
getHarvestRewardShares(fromBlock: number, toBlock: number): Promise<Web3Number>;
|
|
664
|
+
balanceOf(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<Web3Number>;
|
|
665
|
+
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<DualTokenInfo>;
|
|
666
|
+
private _getTVL;
|
|
667
|
+
totalSupply(blockIdentifier?: BlockIdentifier): Promise<Web3Number>;
|
|
668
|
+
assertValidDepositTokens(poolKey: EkuboPoolKey): void;
|
|
669
|
+
getTVL(blockIdentifier?: BlockIdentifier): Promise<DualTokenInfo>;
|
|
651
670
|
getUncollectedFees(): Promise<DualTokenInfo>;
|
|
652
671
|
getCurrentNFTID(): Promise<number>;
|
|
653
672
|
truePrice(): Promise<number>;
|
|
654
|
-
getCurrentPrice(): Promise<{
|
|
673
|
+
getCurrentPrice(blockIdentifier?: BlockIdentifier): Promise<{
|
|
655
674
|
price: number;
|
|
656
675
|
tick: number;
|
|
676
|
+
sqrtRatio: any;
|
|
657
677
|
}>;
|
|
658
678
|
private _getCurrentPrice;
|
|
659
|
-
getCurrentBounds(): Promise<EkuboBounds>;
|
|
679
|
+
getCurrentBounds(blockIdentifier?: BlockIdentifier): Promise<EkuboBounds>;
|
|
660
680
|
static div2Power128(num: BigInt): number;
|
|
661
681
|
static priceToTick(price: number, isRoundDown: boolean, tickSpacing: number): {
|
|
662
682
|
mag: number;
|
|
663
683
|
sign: number;
|
|
664
684
|
};
|
|
665
|
-
getPoolKey(): Promise<EkuboPoolKey>;
|
|
685
|
+
getPoolKey(blockIdentifier?: BlockIdentifier): Promise<EkuboPoolKey>;
|
|
666
686
|
getNewBounds(): Promise<EkuboBounds>;
|
|
667
687
|
/**
|
|
668
688
|
* Computes the expected amounts to fully utilize amount in
|
|
@@ -674,6 +694,21 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
674
694
|
private _getExpectedAmountsForLiquidity;
|
|
675
695
|
private _solveExpectedAmountsEq;
|
|
676
696
|
getSwapInfoToHandleUnused(considerRebalance?: boolean): Promise<SwapInfo>;
|
|
697
|
+
getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds): Promise<SwapInfo>;
|
|
698
|
+
/**
|
|
699
|
+
* Attempts to rebalance the vault by iteratively adjusting swap amounts if initial attempt fails.
|
|
700
|
+
* Uses binary search approach to find optimal swap amount.
|
|
701
|
+
*
|
|
702
|
+
* @param newBounds - The new tick bounds to rebalance to
|
|
703
|
+
* @param swapInfo - Initial swap parameters for rebalancing
|
|
704
|
+
* @param acc - Account to estimate gas fees with
|
|
705
|
+
* @param retry - Current retry attempt number (default 0)
|
|
706
|
+
* @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
|
|
707
|
+
* @param isToken0Deficit - Whether token0 balance needs increasing (default true)
|
|
708
|
+
* @returns Array of contract calls needed for rebalancing
|
|
709
|
+
* @throws Error if max retries reached without successful rebalance
|
|
710
|
+
*/
|
|
711
|
+
rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, retry?: number, adjustmentFactor?: number, isToken0Deficit?: boolean): Promise<Call[]>;
|
|
677
712
|
static tickToi129(tick: number): {
|
|
678
713
|
mag: number;
|
|
679
714
|
sign: number;
|
|
@@ -684,10 +719,16 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
684
719
|
sign: number;
|
|
685
720
|
}): bigint;
|
|
686
721
|
static tickToPrice(tick: bigint): number;
|
|
687
|
-
getLiquidityToAmounts(liquidity: Web3Number, bounds: EkuboBounds
|
|
722
|
+
getLiquidityToAmounts(liquidity: Web3Number, bounds: EkuboBounds, blockIdentifier?: BlockIdentifier, _poolKey?: EkuboPoolKey | null, _currentPrice?: {
|
|
723
|
+
price: number;
|
|
724
|
+
tick: number;
|
|
725
|
+
sqrtRatio: string;
|
|
726
|
+
} | null): Promise<{
|
|
688
727
|
amount0: Web3Number;
|
|
689
728
|
amount1: Web3Number;
|
|
690
729
|
}>;
|
|
730
|
+
harvest(acc: Account): Promise<Call[]>;
|
|
731
|
+
getInvestmentFlows(): Promise<IInvestmentFlow[]>;
|
|
691
732
|
}
|
|
692
733
|
/**
|
|
693
734
|
* Represents the Vesu Rebalance Strategies.
|
|
@@ -803,4 +844,4 @@ declare class PasswordJsonCryptoUtil {
|
|
|
803
844
|
decrypt(encryptedData: string, password: string): any;
|
|
804
845
|
}
|
|
805
846
|
|
|
806
|
-
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, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, logger };
|
|
847
|
+
export { type AccountInfo, type AllAccountsStore, AutoCompounderSTRK, AvnuWrapper, BaseStrategy, type CLVaultStrategySettings, ContractAddr, type DualActionAmount, type DualTokenInfo, 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, type SingleActionAmount, type SingleTokenInfo, Store, type StoreConfig, type SwapInfo, TelegramNotif, type TokenInfo, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, Web3Number, ZkLend, assert, getAPIUsingHeadlessBrowser, getDefaultStoreConfig, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, logger };
|