@strkfarm/sdk 2.0.0-dev.13 → 2.0.0-dev.15
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.browser.global.js +557 -556
- package/dist/index.browser.mjs +1333 -1332
- package/dist/index.d.ts +78 -28
- package/dist/index.js +565 -562
- package/dist/index.mjs +1333 -1332
- package/package.json +1 -1
- package/src/strategies/index.ts +2 -1
- package/src/strategies/universal-adapters/extended-adapter.ts +40 -11
- package/src/strategies/universal-adapters/index.ts +2 -1
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +23 -13
- package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +25 -0
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +40 -0
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +203 -235
package/dist/index.d.ts
CHANGED
|
@@ -1520,7 +1520,10 @@ declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams>
|
|
|
1520
1520
|
};
|
|
1521
1521
|
getSwapFromLegacyCall(params: DepositParams): Promise<ManageCall[]>;
|
|
1522
1522
|
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
1523
|
-
withdrawFromExtended(amount: Web3Number): Promise<
|
|
1523
|
+
withdrawFromExtended(amount: Web3Number): Promise<{
|
|
1524
|
+
status: boolean;
|
|
1525
|
+
receivedTxnHash: boolean;
|
|
1526
|
+
}>;
|
|
1524
1527
|
getHealthFactor(): Promise<number>;
|
|
1525
1528
|
getExtendedDepositAmount(): Promise<Balance | undefined>;
|
|
1526
1529
|
setLeverage(leverage: string, marketName: string): Promise<boolean>;
|
|
@@ -2178,8 +2181,29 @@ declare const _riskFactor: RiskFactor[];
|
|
|
2178
2181
|
declare function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string): string[];
|
|
2179
2182
|
declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
|
|
2180
2183
|
|
|
2184
|
+
/**
|
|
2185
|
+
* Transaction metadata that SDK generates and risk engine stores in DB.
|
|
2186
|
+
* This metadata is used to track transaction lifecycle without coupling SDK to DB.
|
|
2187
|
+
*/
|
|
2188
|
+
interface TransactionMetadata {
|
|
2189
|
+
protocolFrom: string;
|
|
2190
|
+
protocolTo: string;
|
|
2191
|
+
transactionType: 'DEPOSIT' | 'WITHDRAWAL' | 'NONE';
|
|
2192
|
+
usdAmount: string;
|
|
2193
|
+
status: 'COMPLETED' | 'FAILED' | 'PENDING';
|
|
2194
|
+
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Enhanced return type for operations that generate transactions.
|
|
2197
|
+
* Includes both the calls (for execution) and metadata (for DB storage).
|
|
2198
|
+
*/
|
|
2199
|
+
interface TransactionResult<T = any> {
|
|
2200
|
+
calls: Call[];
|
|
2201
|
+
status: boolean;
|
|
2202
|
+
transactionMetadata: TransactionMetadata;
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2181
2205
|
declare abstract class Operations {
|
|
2182
|
-
abstract shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<
|
|
2206
|
+
abstract shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<TransactionResult[]>;
|
|
2183
2207
|
abstract shouldInvest(): Promise<{
|
|
2184
2208
|
shouldInvest: boolean;
|
|
2185
2209
|
vesuAmount: Web3Number;
|
|
@@ -2187,22 +2211,27 @@ declare abstract class Operations {
|
|
|
2187
2211
|
extendedLeverage: number;
|
|
2188
2212
|
vesuLeverage: number;
|
|
2189
2213
|
}>;
|
|
2214
|
+
/**
|
|
2215
|
+
* Move assets between protocols.
|
|
2216
|
+
* Returns transaction calls and metadata for DB tracking.
|
|
2217
|
+
*/
|
|
2190
2218
|
abstract moveAssets(params: {
|
|
2191
2219
|
from: string;
|
|
2192
2220
|
to: string;
|
|
2193
2221
|
amount: Web3Number;
|
|
2194
|
-
}, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2222
|
+
}, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<TransactionResult>;
|
|
2223
|
+
/**
|
|
2224
|
+
* Handle deposit operation.
|
|
2225
|
+
* Returns transaction calls and metadata for DB tracking.
|
|
2226
|
+
*/
|
|
2227
|
+
abstract handleDeposit(): Promise<TransactionResult<{
|
|
2199
2228
|
extendedAmountInBTC: Web3Number;
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2229
|
+
}>>;
|
|
2230
|
+
/**
|
|
2231
|
+
* Handle withdrawal operation.
|
|
2232
|
+
* Returns transaction calls and metadata for DB tracking.
|
|
2233
|
+
*/
|
|
2234
|
+
abstract handleWithdraw(amount: Web3Number): Promise<TransactionResult[]>;
|
|
2206
2235
|
}
|
|
2207
2236
|
|
|
2208
2237
|
interface VesuExtendedStrategySettings extends UniversalStrategySettings {
|
|
@@ -2226,7 +2255,10 @@ declare class VesuExtendedMultiplierStrategy<S extends VesuExtendedStrategySetti
|
|
|
2226
2255
|
getVesuAdapter(): Promise<VesuMultiplyAdapter | null>;
|
|
2227
2256
|
getAvnuAdapter(): Promise<AvnuAdapter | null>;
|
|
2228
2257
|
getExtendedAdapter(): Promise<ExtendedAdapter | null>;
|
|
2229
|
-
moveAssetsToVaultAllocator(amount: Web3Number, extendedAdapter: ExtendedAdapter): Promise<
|
|
2258
|
+
moveAssetsToVaultAllocator(amount: Web3Number, extendedAdapter: ExtendedAdapter): Promise<{
|
|
2259
|
+
calls: Call[];
|
|
2260
|
+
status: boolean;
|
|
2261
|
+
}>;
|
|
2230
2262
|
shouldInvest(): Promise<{
|
|
2231
2263
|
shouldInvest: boolean;
|
|
2232
2264
|
vesuAmount: Web3Number;
|
|
@@ -2236,29 +2268,29 @@ declare class VesuExtendedMultiplierStrategy<S extends VesuExtendedStrategySetti
|
|
|
2236
2268
|
debtPrice: number;
|
|
2237
2269
|
vesuLeverage: number;
|
|
2238
2270
|
}>;
|
|
2239
|
-
shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<
|
|
2271
|
+
shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<TransactionResult[]>;
|
|
2272
|
+
/**
|
|
2273
|
+
* Helper method to create transaction result with metadata
|
|
2274
|
+
*/
|
|
2275
|
+
private createTransactionResult;
|
|
2240
2276
|
moveAssets(params: {
|
|
2241
2277
|
amount: Web3Number;
|
|
2242
2278
|
from: string;
|
|
2243
2279
|
to: string;
|
|
2244
|
-
}, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<
|
|
2245
|
-
|
|
2246
|
-
status: boolean;
|
|
2247
|
-
}>;
|
|
2248
|
-
handleDeposit(): Promise<{
|
|
2249
|
-
extendedAmountInBTC: Web3Number;
|
|
2250
|
-
calls: Call[];
|
|
2251
|
-
}>;
|
|
2280
|
+
}, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<TransactionResult>;
|
|
2281
|
+
handleDeposit(): Promise<TransactionResult>;
|
|
2252
2282
|
checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter, avnuAdapter: AvnuAdapter, positionType: PositionTypeAvnuExtended): Promise<boolean>;
|
|
2253
|
-
handleWithdraw(amount: Web3Number): Promise<
|
|
2254
|
-
calls: Call[];
|
|
2255
|
-
status: boolean;
|
|
2256
|
-
}>;
|
|
2283
|
+
handleWithdraw(amount: Web3Number): Promise<TransactionResult[]>;
|
|
2257
2284
|
getAUM(): Promise<{
|
|
2258
2285
|
net: SingleTokenInfo;
|
|
2259
2286
|
prevAum: Web3Number;
|
|
2260
2287
|
splits: PositionInfo[];
|
|
2261
2288
|
}>;
|
|
2289
|
+
processTransactionDataFromSDK(txnData: TransactionResult<any>[]): Promise<{
|
|
2290
|
+
callsToBeExecutedFinal: Call[];
|
|
2291
|
+
txnMetadata: TransactionMetadata[];
|
|
2292
|
+
} | null>;
|
|
2293
|
+
processTransactionMetadata(txnMetadata: TransactionMetadata[], extendedIntentFulfilled: boolean): Promise<TransactionMetadata[] | null>;
|
|
2262
2294
|
}
|
|
2263
2295
|
declare const VesuExtendedTestStrategies: (extendedBackendUrl: string, extendedApiKey: string, vaultIdExtended: number, minimumExtendedMovementAmount: number, minimumVesuMovementAmount: number, minimumExtendedRetriesDelayForOrderStatus: number, minimumExtendedPriceDifferenceForSwapOpen: number, maximumExtendedPriceDifferenceForSwapClosing: number) => IStrategyMetadata<VesuExtendedStrategySettings>[];
|
|
2264
2296
|
|
|
@@ -2673,6 +2705,24 @@ declare const calculateDebtReductionAmountForWithdrawal: (debtAmount: Web3Number
|
|
|
2673
2705
|
* @returns The amount to deposit on extended when incurring losses
|
|
2674
2706
|
*/
|
|
2675
2707
|
declare const calculateAmountDepositOnExtendedWhenIncurringLosses: (client: ExtendedWrapper) => Promise<Web3Number | null>;
|
|
2708
|
+
/**
|
|
2709
|
+
* calculate the amount of collateral to deposit to maintain the ltv
|
|
2710
|
+
* The formula is:
|
|
2711
|
+
* ((debt * debtPrice * targetHF) - (collateral * collateralPrice * ltv)) / ltv
|
|
2712
|
+
* @param collateralAmount in collateral units
|
|
2713
|
+
* @param debtAmount in debt units
|
|
2714
|
+
* @param debtPrice in usd
|
|
2715
|
+
* @param maxLtv
|
|
2716
|
+
* @param collateralPrice in usd
|
|
2717
|
+
* @param targetHF
|
|
2718
|
+
* @returns deltaCollateralAmountUnits in collateral units
|
|
2719
|
+
* null if there is an error
|
|
2720
|
+
*/
|
|
2721
|
+
declare const calculateWBTCAmountToMaintainLTV: (collateralAmount: Web3Number, debtAmount: Web3Number, debtPrice: number, maxLtv: number | undefined, collateralPrice: number, targetHF?: number) => {
|
|
2722
|
+
deltaCollateralAmountUnits: Web3Number;
|
|
2723
|
+
} | {
|
|
2724
|
+
deltaCollateralAmountUnits: null;
|
|
2725
|
+
};
|
|
2676
2726
|
declare const calculateExposureDelta: (exposure_extended: number, exposure_vesu: number) => number;
|
|
2677
2727
|
/**
|
|
2678
2728
|
* calculate the delta percentage between the current btc price and the last btc price
|
|
@@ -3032,4 +3082,4 @@ declare class PasswordJsonCryptoUtil {
|
|
|
3032
3082
|
decrypt(encryptedData: string, password: string): any;
|
|
3033
3083
|
}
|
|
3034
3084
|
|
|
3035
|
-
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, PositionTypeAvnuExtended, 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 };
|
|
3085
|
+
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, AvnuAdapter, type AvnuAdapterConfig, 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, PositionTypeAvnuExtended, 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, type TransactionMetadata, type TransactionResult, 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, calculateWBTCAmountToMaintainLTV, extensionMap, getAPIUsingHeadlessBrowser, getContractDetails, getDefaultStoreConfig, getFAQs, getInvestmentSteps, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, logger, returnFormattedAmount, toBigInt };
|