@strkfarm/sdk 2.0.0-dev.34 → 2.0.0-dev.36
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 +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.browser.global.js +16173 -24081
- package/dist/index.browser.mjs +8572 -16661
- package/dist/index.d.ts +600 -2666
- package/dist/index.js +8660 -16784
- package/dist/index.mjs +8585 -16674
- package/package.json +3 -3
- package/src/data/redeem-request-nft.abi.json +752 -0
- package/src/data/universal-vault.abi.json +8 -7
- package/src/dataTypes/bignumber.browser.ts +5 -1
- package/src/dataTypes/bignumber.node.ts +5 -0
- package/src/global.ts +21 -1
- package/src/interfaces/common.tsx +39 -4
- package/src/modules/avnu.ts +19 -10
- package/src/modules/index.ts +1 -1
- package/src/strategies/base-strategy.ts +92 -8
- package/src/strategies/constants.ts +8 -3
- package/src/strategies/ekubo-cl-vault.tsx +150 -16
- package/src/strategies/factory.ts +21 -1
- package/src/strategies/index.ts +2 -6
- package/src/strategies/registry.ts +28 -5
- package/src/strategies/sensei.ts +29 -13
- package/src/strategies/svk-strategy.ts +29 -4
- package/src/strategies/token-boosted-xstrk-carry-strategy.tsx +1057 -0
- package/src/strategies/universal-adapters/adapter-utils.ts +2 -0
- package/src/strategies/universal-adapters/avnu-adapter.ts +19 -10
- package/src/strategies/universal-adapters/index.ts +1 -2
- package/src/strategies/universal-adapters/svk-troves-adapter.ts +160 -13
- package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +91 -42
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +75 -52
- package/src/strategies/universal-adapters/vesu-position-common.ts +38 -31
- package/src/strategies/universal-lst-muliplier-strategy.tsx +222 -269
- package/src/strategies/universal-strategy.tsx +166 -105
- package/src/strategies/vesu-rebalance.tsx +3 -6
- package/src/strategies/yoloVault.ts +1084 -0
- package/src/utils/health-factor-math.ts +29 -0
- package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
- package/src/modules/ExtendedWrapperSDk/types.ts +0 -334
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -611
- package/src/strategies/universal-adapters/extended-adapter.ts +0 -835
- package/src/strategies/universal-adapters/usdc<>usdce-adapter.ts +0 -200
- package/src/strategies/vesu-extended-strategy/services/executionService.ts +0 -2233
- package/src/strategies/vesu-extended-strategy/services/extended-vesu-state-manager.ts +0 -4254
- package/src/strategies/vesu-extended-strategy/services/ltv-imbalance-rebalance-math.ts +0 -783
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -56
- package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +0 -88
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -78
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -48
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -528
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1014
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as starknet from 'starknet';
|
|
2
|
-
import { RpcProvider, BlockIdentifier, Call, Contract,
|
|
2
|
+
import { Uint256, RpcProvider, BlockIdentifier, Call, Contract, Account, CairoCustomEnum, RawArgs } from 'starknet';
|
|
3
3
|
import BigNumber from 'bignumber.js';
|
|
4
4
|
import React, { ReactNode } from 'react';
|
|
5
5
|
import { Quote, AvnuOptions } from '@avnu/avnu-sdk';
|
|
@@ -38,6 +38,7 @@ declare class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
|
|
|
38
38
|
declare class Web3Number extends _Web3Number<Web3Number> {
|
|
39
39
|
static fromWei(weiNumber: string | number, decimals: number): Web3Number;
|
|
40
40
|
static fromNumber(number: number, decimals: number): Web3Number;
|
|
41
|
+
static fromUint256(uint256Value: Uint256): Web3Number;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
/**
|
|
@@ -127,6 +128,10 @@ interface IProtocol {
|
|
|
127
128
|
name: string;
|
|
128
129
|
logo: string;
|
|
129
130
|
}
|
|
131
|
+
interface ICurator {
|
|
132
|
+
name: string;
|
|
133
|
+
logo: string;
|
|
134
|
+
}
|
|
130
135
|
declare enum StrategyTag {
|
|
131
136
|
META_VAULT = "Meta Vaults",
|
|
132
137
|
LEVERED = "Maxx",
|
|
@@ -137,7 +142,8 @@ declare enum VaultType {
|
|
|
137
142
|
LOOPING = "Looping",
|
|
138
143
|
META_VAULT = "Meta Vault",
|
|
139
144
|
DELTA_NEUTRAL = "Delta Neutral",
|
|
140
|
-
AUTOMATED_LP = "Automated LP"
|
|
145
|
+
AUTOMATED_LP = "Automated LP",
|
|
146
|
+
TVA = "Troves Value Averaging"
|
|
141
147
|
}
|
|
142
148
|
declare enum AuditStatus {
|
|
143
149
|
AUDITED = "Audited",
|
|
@@ -149,7 +155,8 @@ declare enum SourceCodeType {
|
|
|
149
155
|
}
|
|
150
156
|
declare enum AccessControlType {
|
|
151
157
|
MULTISIG_ACCOUNT = "Multisig Account",
|
|
152
|
-
STANDARD_ACCOUNT = "Standard Account"
|
|
158
|
+
STANDARD_ACCOUNT = "Standard Account",
|
|
159
|
+
ROLE_BASED_ACCESS = "Role Based Access"
|
|
153
160
|
}
|
|
154
161
|
declare enum InstantWithdrawalVault {
|
|
155
162
|
YES = "Yes",
|
|
@@ -162,7 +169,7 @@ interface SourceCodeInfo {
|
|
|
162
169
|
interface AccessControlInfo {
|
|
163
170
|
type: AccessControlType;
|
|
164
171
|
addresses: ContractAddr[];
|
|
165
|
-
timeLock
|
|
172
|
+
timeLock?: string;
|
|
166
173
|
}
|
|
167
174
|
interface SecurityMetadata {
|
|
168
175
|
auditStatus: AuditStatus;
|
|
@@ -215,6 +222,10 @@ interface StrategySettings {
|
|
|
215
222
|
alerts?: StrategyAlert[];
|
|
216
223
|
tags?: StrategyTag[];
|
|
217
224
|
}
|
|
225
|
+
interface StrategyApyHistoryUIConfig {
|
|
226
|
+
showApyHistory?: boolean;
|
|
227
|
+
noApyHistoryMessage?: string;
|
|
228
|
+
}
|
|
218
229
|
/**
|
|
219
230
|
* @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
|
|
220
231
|
* @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
|
|
@@ -225,6 +236,19 @@ interface IStrategyMetadata<T> {
|
|
|
225
236
|
id: string;
|
|
226
237
|
name: string;
|
|
227
238
|
description: string | React.ReactNode;
|
|
239
|
+
/**
|
|
240
|
+
* Optional UI sort priority. Higher shows earlier.
|
|
241
|
+
* Intended for pinning flagship parent vaults (e.g. BTC above STRK).
|
|
242
|
+
*/
|
|
243
|
+
priority?: number;
|
|
244
|
+
/**
|
|
245
|
+
* Optional UI config for the variant intro popup (strategy page).
|
|
246
|
+
* Should be identical across strategies that share the same `parentId`.
|
|
247
|
+
*/
|
|
248
|
+
variantIntro?: {
|
|
249
|
+
title: string;
|
|
250
|
+
description: string;
|
|
251
|
+
};
|
|
228
252
|
address: ContractAddr;
|
|
229
253
|
launchBlock: number;
|
|
230
254
|
type: "ERC4626" | "ERC721" | "Other";
|
|
@@ -241,7 +265,7 @@ interface IStrategyMetadata<T> {
|
|
|
241
265
|
notARisks: RiskType[];
|
|
242
266
|
};
|
|
243
267
|
apyMethodology?: string;
|
|
244
|
-
|
|
268
|
+
realizedApyMethodology?: string;
|
|
245
269
|
additionalInfo: T;
|
|
246
270
|
contractDetails: {
|
|
247
271
|
address: ContractAddr;
|
|
@@ -256,10 +280,7 @@ interface IStrategyMetadata<T> {
|
|
|
256
280
|
}[];
|
|
257
281
|
docs?: string;
|
|
258
282
|
investmentSteps: string[];
|
|
259
|
-
curator?:
|
|
260
|
-
name: string;
|
|
261
|
-
logo: string;
|
|
262
|
-
};
|
|
283
|
+
curator?: ICurator;
|
|
263
284
|
isPreview?: boolean;
|
|
264
285
|
tags?: StrategyTag[];
|
|
265
286
|
security: SecurityMetadata;
|
|
@@ -272,6 +293,7 @@ interface IStrategyMetadata<T> {
|
|
|
272
293
|
info?: React.ReactNode | string;
|
|
273
294
|
};
|
|
274
295
|
settings?: StrategySettings;
|
|
296
|
+
apyHistoryUIConfig?: StrategyApyHistoryUIConfig;
|
|
275
297
|
actions?: Array<{
|
|
276
298
|
name?: string;
|
|
277
299
|
pool?: {
|
|
@@ -291,6 +313,8 @@ interface IStrategyMetadata<T> {
|
|
|
291
313
|
amount?: string | number;
|
|
292
314
|
isDeposit?: boolean;
|
|
293
315
|
}>;
|
|
316
|
+
parentId?: string;
|
|
317
|
+
parentName?: string;
|
|
294
318
|
}
|
|
295
319
|
interface IInvestmentFlow {
|
|
296
320
|
id?: string;
|
|
@@ -351,6 +375,7 @@ declare const Protocols: {
|
|
|
351
375
|
VAULT: IProtocol;
|
|
352
376
|
TROVES: IProtocol;
|
|
353
377
|
};
|
|
378
|
+
declare const UnwrapLabsCurator: ICurator;
|
|
354
379
|
|
|
355
380
|
interface ILendingMetadata {
|
|
356
381
|
name: string;
|
|
@@ -496,6 +521,8 @@ interface DualTokenInfo {
|
|
|
496
521
|
token0: SingleTokenInfo;
|
|
497
522
|
token1: SingleTokenInfo;
|
|
498
523
|
}
|
|
524
|
+
type StrategyInputMode = "single" | "dual";
|
|
525
|
+
type InputModeFromAction<T> = T extends DualActionAmount ? "dual" : "single";
|
|
499
526
|
interface NetAPYSplit {
|
|
500
527
|
apy: number;
|
|
501
528
|
id: string;
|
|
@@ -504,23 +531,55 @@ interface NetAPYDetails {
|
|
|
504
531
|
net: number;
|
|
505
532
|
splits: NetAPYSplit[];
|
|
506
533
|
}
|
|
534
|
+
type UserPositionCardSubValueColor = "default" | "positive" | "negative" | "info";
|
|
535
|
+
interface UserPositionCard {
|
|
536
|
+
title: string;
|
|
537
|
+
value: string;
|
|
538
|
+
tooltip?: string;
|
|
539
|
+
subValue?: string;
|
|
540
|
+
subValueColor?: UserPositionCardSubValueColor;
|
|
541
|
+
}
|
|
542
|
+
interface UserPositionCardsInput {
|
|
543
|
+
user: ContractAddr;
|
|
544
|
+
investmentFlows?: Array<{
|
|
545
|
+
amount: string;
|
|
546
|
+
type: string;
|
|
547
|
+
timestamp: number;
|
|
548
|
+
tx_hash: string;
|
|
549
|
+
}>;
|
|
550
|
+
usualTimeToEarnings?: string | null;
|
|
551
|
+
usualTimeToEarningsDescription?: string | null;
|
|
552
|
+
}
|
|
507
553
|
interface CacheData {
|
|
508
554
|
timestamp: number;
|
|
509
555
|
ttl: number;
|
|
510
556
|
data: any;
|
|
511
557
|
}
|
|
512
|
-
declare class BaseStrategy<TVLInfo,
|
|
558
|
+
declare class BaseStrategy<TVLInfo, DepositActionInfo, WithdrawActionInfo = DepositActionInfo> extends CacheClass {
|
|
513
559
|
readonly config: IConfig;
|
|
514
560
|
readonly cache: Map<string, CacheData>;
|
|
515
|
-
|
|
561
|
+
private readonly _depositInputMode;
|
|
562
|
+
private readonly _withdrawInputMode;
|
|
563
|
+
constructor(config: IConfig, inputModes?: {
|
|
564
|
+
depositInputMode?: InputModeFromAction<DepositActionInfo>;
|
|
565
|
+
withdrawInputMode?: InputModeFromAction<WithdrawActionInfo>;
|
|
566
|
+
});
|
|
567
|
+
depositInputMode(): InputModeFromAction<DepositActionInfo>;
|
|
568
|
+
withdrawInputMode(): InputModeFromAction<WithdrawActionInfo>;
|
|
516
569
|
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<TVLInfo>;
|
|
517
570
|
getTVL(): Promise<TVLInfo>;
|
|
518
|
-
depositCall(amountInfo:
|
|
519
|
-
withdrawCall(amountInfo:
|
|
571
|
+
depositCall(amountInfo: DepositActionInfo, receiver: ContractAddr): Promise<Call[]>;
|
|
572
|
+
withdrawCall(amountInfo: WithdrawActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
520
573
|
getVaultPositions(): Promise<VaultPosition[]>;
|
|
521
|
-
netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number | NetAPYDetails>;
|
|
574
|
+
netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number | string | NetAPYDetails>;
|
|
522
575
|
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
523
576
|
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
577
|
+
getUserPositionCards(_input: UserPositionCardsInput): Promise<UserPositionCard[]>;
|
|
578
|
+
getMaxTVL(): Promise<Web3Number>;
|
|
579
|
+
protected formatTokenAmountForCard(amount: Web3Number, tokenInfo: TokenInfo): string;
|
|
580
|
+
protected formatPercentForCard(value: number): string;
|
|
581
|
+
protected formatUSDForCard(value: number): string;
|
|
582
|
+
protected getSubValueColorFromSignedNumber(value: number): UserPositionCardSubValueColor;
|
|
524
583
|
/**
|
|
525
584
|
* Calculate lifetime earnings for a user based on provided data from client
|
|
526
585
|
* Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
|
|
@@ -690,7 +749,7 @@ declare class AvnuWrapper {
|
|
|
690
749
|
getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number, excludeSources?: string[]): Promise<Quote>;
|
|
691
750
|
getSwapInfo(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount?: string, options?: AvnuOptions): Promise<SwapInfo>;
|
|
692
751
|
static buildZeroSwap(tokenToSell: ContractAddr, beneficiary: string, tokenToBuy?: ContractAddr): SwapInfo;
|
|
693
|
-
getSwapCallData(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string): Promise<bigint[][]>;
|
|
752
|
+
getSwapCallData(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, minAmount?: Web3Number): Promise<bigint[][]>;
|
|
694
753
|
}
|
|
695
754
|
|
|
696
755
|
declare class AutoCompounderSTRK {
|
|
@@ -1029,6 +1088,8 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
1029
1088
|
* regardless of quote asset configuration.
|
|
1030
1089
|
*/
|
|
1031
1090
|
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
1091
|
+
getMaxTVL(): Promise<Web3Number>;
|
|
1092
|
+
getUserPositionCards(input: UserPositionCardsInput): Promise<UserPositionCard[]>;
|
|
1032
1093
|
feeBasedAPY(timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<number>;
|
|
1033
1094
|
/**
|
|
1034
1095
|
* Calculates assets before and now in a given token of TVL per share to observe growth
|
|
@@ -1241,9 +1302,105 @@ declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmou
|
|
|
1241
1302
|
* Not implemented for Sensei Strategy yet.
|
|
1242
1303
|
*/
|
|
1243
1304
|
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
1305
|
+
getUserPositionCards(_input: UserPositionCardsInput): Promise<UserPositionCard[]>;
|
|
1244
1306
|
}
|
|
1245
1307
|
declare const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[];
|
|
1246
1308
|
|
|
1309
|
+
interface YoloVaultSettings {
|
|
1310
|
+
startDate: string;
|
|
1311
|
+
expiryDate: string;
|
|
1312
|
+
mainToken: TokenInfo;
|
|
1313
|
+
secondaryToken: TokenInfo;
|
|
1314
|
+
totalEpochs: number;
|
|
1315
|
+
minEpochDurationSeconds: number;
|
|
1316
|
+
spendingLevels: YoloSpendingLevel[];
|
|
1317
|
+
feeBps: number;
|
|
1318
|
+
/** When true, base token is ERC-4626 (e.g. vUSDC); amounts for TVL / user info use `convert_to_assets` into `baseUnderlying`. */
|
|
1319
|
+
isBaseERC4626?: boolean;
|
|
1320
|
+
/** When true, second token is ERC-4626 (e.g. xSTRK); amounts use `convert_to_assets` into `secondUnderlying`. */
|
|
1321
|
+
isSecondERC4626?: boolean;
|
|
1322
|
+
/** Required when `isBaseERC4626` is true (e.g. USDC). */
|
|
1323
|
+
baseUnderlying?: TokenInfo;
|
|
1324
|
+
/** Required when `isSecondERC4626` is true (e.g. STRK / WBTC for xSTRK / xWBTC). */
|
|
1325
|
+
secondUnderlying?: TokenInfo;
|
|
1326
|
+
}
|
|
1327
|
+
interface YoloSpendingLevel {
|
|
1328
|
+
minPrice?: number;
|
|
1329
|
+
maxPrice?: number;
|
|
1330
|
+
spendPercent: number;
|
|
1331
|
+
}
|
|
1332
|
+
interface UserYoloInfo {
|
|
1333
|
+
shares: bigint;
|
|
1334
|
+
claimable_second_tokens: bigint;
|
|
1335
|
+
base_token_balance: bigint;
|
|
1336
|
+
base_token_consumed: bigint;
|
|
1337
|
+
base_consumed_last_index: bigint;
|
|
1338
|
+
second_token_last_index: bigint;
|
|
1339
|
+
second_token_balance: bigint;
|
|
1340
|
+
}
|
|
1341
|
+
interface YoloVaultStatus {
|
|
1342
|
+
current_epoch: bigint;
|
|
1343
|
+
total_epochs: bigint;
|
|
1344
|
+
remaining_base: bigint;
|
|
1345
|
+
total_second_tokens: bigint;
|
|
1346
|
+
global_second_token_index: bigint;
|
|
1347
|
+
cumulative_spend_index: bigint;
|
|
1348
|
+
total_shares: bigint;
|
|
1349
|
+
base_token_assets_per_share: bigint;
|
|
1350
|
+
}
|
|
1351
|
+
interface YoloSettings {
|
|
1352
|
+
base_token: bigint;
|
|
1353
|
+
second_token: bigint;
|
|
1354
|
+
total_epochs: bigint;
|
|
1355
|
+
min_time_per_epoch: bigint;
|
|
1356
|
+
max_spend_units_per_epoch: bigint;
|
|
1357
|
+
base_token_assets_per_share: bigint;
|
|
1358
|
+
oracle: bigint;
|
|
1359
|
+
}
|
|
1360
|
+
type YoloErc4626RuntimeConfig = {
|
|
1361
|
+
isBaseERC4626: boolean;
|
|
1362
|
+
isSecondERC4626: boolean;
|
|
1363
|
+
baseUnderlying?: TokenInfo;
|
|
1364
|
+
secondUnderlying?: TokenInfo;
|
|
1365
|
+
};
|
|
1366
|
+
declare class YoLoVault extends BaseStrategy<DualTokenInfo, SingleActionAmount, DualActionAmount> {
|
|
1367
|
+
readonly address: ContractAddr;
|
|
1368
|
+
readonly metadata: IStrategyMetadata<YoloVaultSettings>;
|
|
1369
|
+
readonly pricer: PricerBase;
|
|
1370
|
+
/** Resolves to a `Contract` built from `provider.getClassAt` at the vault address (no checked-in vault ABI). */
|
|
1371
|
+
readonly contract: Promise<Contract>;
|
|
1372
|
+
readonly primaryToken: TokenInfo;
|
|
1373
|
+
readonly secondaryToken: TokenInfo;
|
|
1374
|
+
readonly erc4626: YoloErc4626RuntimeConfig;
|
|
1375
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<YoloVaultSettings>);
|
|
1376
|
+
/** Underlying (or base token) used for pricing / swap sell leg when base is ERC-4626. */
|
|
1377
|
+
tokenForPrimaryPricing(): TokenInfo;
|
|
1378
|
+
/** Underlying (or second token) for price ratios when second leg is ERC-4626 (e.g. STRK for xSTRK). */
|
|
1379
|
+
tokenForSecondaryPricing(): TokenInfo;
|
|
1380
|
+
private primaryAmountDecimals;
|
|
1381
|
+
private secondaryAmountDecimals;
|
|
1382
|
+
private convertWrapperSharesToUnderlying;
|
|
1383
|
+
private getNormalizedUserInfo;
|
|
1384
|
+
private resolveWithdrawRequest;
|
|
1385
|
+
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<DualTokenInfo>;
|
|
1386
|
+
getVaultPositions(): Promise<VaultPosition[]>;
|
|
1387
|
+
getTVL(): Promise<DualTokenInfo>;
|
|
1388
|
+
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
1389
|
+
getVaultStatus(): Promise<YoloVaultStatus>;
|
|
1390
|
+
matchInputAmounts(amountInfo: DualActionAmount, user: ContractAddr): Promise<DualActionAmount>;
|
|
1391
|
+
withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
1392
|
+
netAPY(): Promise<number | string | NetAPYDetails>;
|
|
1393
|
+
getSwapAmounts(spendUnits: Web3Number): Promise<{
|
|
1394
|
+
grossSpend: Web3Number;
|
|
1395
|
+
netSpend: Web3Number;
|
|
1396
|
+
isReadyForNextSwap: boolean;
|
|
1397
|
+
}>;
|
|
1398
|
+
getSettings: () => Promise<YoloSettings>;
|
|
1399
|
+
getMaxTVL(): Promise<Web3Number>;
|
|
1400
|
+
getUserPositionCards(input: UserPositionCardsInput): Promise<UserPositionCard[]>;
|
|
1401
|
+
}
|
|
1402
|
+
declare const YoloVaultStrategies: IStrategyMetadata<YoloVaultSettings>[];
|
|
1403
|
+
|
|
1247
1404
|
interface LeveledLogMethod {
|
|
1248
1405
|
(message: string, ...meta: any[]): void;
|
|
1249
1406
|
(message: any): void;
|
|
@@ -1383,6 +1540,11 @@ declare class HealthFactorMath {
|
|
|
1383
1540
|
static getHealthFactor(collateralAmount: Web3Number, collateralPrice: number, maxLTV: number, debtAmount: Web3Number, debtPrice: number): number;
|
|
1384
1541
|
static getMaxDebtAmountOnLooping(collateralAmount: Web3Number, collateralPrice: number, maxLTV: number, targetHF: number, debtPrice: number, debtTokenInfo: TokenInfo): Web3Number;
|
|
1385
1542
|
static getMaxDebtAmount(collateralAmount: Web3Number, collateralPrice: number, maxLTV: number, targetHF: number, debtPrice: number, debtTokenInfo: TokenInfo): Web3Number;
|
|
1543
|
+
static calculateDebtReductionAmountForWithdrawal: (debtAmount: Web3Number, collateralAmount: Web3Number, maxLtv: number, targetHF: number, withdrawalAmount: Web3Number, collateralPrice: number, debtPrice: number, collateralTokenInfo: TokenInfo, debtTokenInfo: TokenInfo) => {
|
|
1544
|
+
deltadebtAmountUnits: null;
|
|
1545
|
+
} | {
|
|
1546
|
+
deltadebtAmountUnits: Web3Number;
|
|
1547
|
+
};
|
|
1386
1548
|
}
|
|
1387
1549
|
|
|
1388
1550
|
type RequiredFields<T> = {
|
|
@@ -1869,6 +2031,7 @@ declare class VesuMultiplyAdapter extends BaseAdapter<VesuDepositParams, VesuWit
|
|
|
1869
2031
|
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
1870
2032
|
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
|
|
1871
2033
|
maxBorrowableAPY(): Promise<number>;
|
|
2034
|
+
private _computeMax;
|
|
1872
2035
|
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
1873
2036
|
maxWithdraw(): Promise<PositionInfo>;
|
|
1874
2037
|
protected _getDepositLeaf(): {
|
|
@@ -1958,574 +2121,22 @@ declare class VesuModifyPositionAdapter extends BaseAdapter<VesuModifyPositionDe
|
|
|
1958
2121
|
getDepositCall(params: VesuModifyPositionDepositParams): Promise<ManageCall[]>;
|
|
1959
2122
|
getWithdrawCall(params: VesuModifyPositionWithdrawParams): Promise<ManageCall[]>;
|
|
1960
2123
|
getHealthFactor(): Promise<number>;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
/**
|
|
1964
|
-
* TypeScript type definitions for Extended Exchange API
|
|
1965
|
-
* Based on Python SDK models from x10.perpetual
|
|
1966
|
-
*/
|
|
1967
|
-
declare enum OrderSide {
|
|
1968
|
-
BUY = "BUY",
|
|
1969
|
-
SELL = "SELL"
|
|
1970
|
-
}
|
|
1971
|
-
declare enum TimeInForce {
|
|
1972
|
-
GTT = "GTT",
|
|
1973
|
-
IOC = "IOC",
|
|
1974
|
-
FOK = "FOK"
|
|
1975
|
-
}
|
|
1976
|
-
declare enum OrderType {
|
|
1977
|
-
LIMIT = "LIMIT",
|
|
1978
|
-
CONDITIONAL = "CONDITIONAL",
|
|
1979
|
-
MARKET = "MARKET",
|
|
1980
|
-
TPSL = "TPSL"
|
|
1981
|
-
}
|
|
1982
|
-
declare enum OrderStatus {
|
|
1983
|
-
UNKNOWN = "UNKNOWN",
|
|
1984
|
-
NEW = "NEW",
|
|
1985
|
-
UNTRIGGERED = "UNTRIGGERED",
|
|
1986
|
-
PARTIALLY_FILLED = "PARTIALLY_FILLED",
|
|
1987
|
-
FILLED = "FILLED",
|
|
1988
|
-
CANCELLED = "CANCELLED",
|
|
1989
|
-
EXPIRED = "EXPIRED",
|
|
1990
|
-
REJECTED = "REJECTED"
|
|
1991
|
-
}
|
|
1992
|
-
declare enum OrderStatusReason {
|
|
1993
|
-
UNKNOWN = "UNKNOWN",
|
|
1994
|
-
NONE = "NONE",
|
|
1995
|
-
UNKNOWN_MARKET = "UNKNOWN_MARKET",
|
|
1996
|
-
DISABLED_MARKET = "DISABLED_MARKET",
|
|
1997
|
-
NOT_ENOUGH_FUNDS = "NOT_ENOUGH_FUNDS",
|
|
1998
|
-
NO_LIQUIDITY = "NO_LIQUIDITY",
|
|
1999
|
-
INVALID_FEE = "INVALID_FEE",
|
|
2000
|
-
INVALID_QTY = "INVALID_QTY",
|
|
2001
|
-
INVALID_PRICE = "INVALID_PRICE",
|
|
2002
|
-
INVALID_VALUE = "INVALID_VALUE",
|
|
2003
|
-
UNKNOWN_ACCOUNT = "UNKNOWN_ACCOUNT",
|
|
2004
|
-
SELF_TRADE_PROTECTION = "SELF_TRADE_PROTECTION",
|
|
2005
|
-
POST_ONLY_FAILED = "POST_ONLY_FAILED",
|
|
2006
|
-
REDUCE_ONLY_FAILED = "REDUCE_ONLY_FAILED",
|
|
2007
|
-
INVALID_EXPIRE_TIME = "INVALID_EXPIRE_TIME",
|
|
2008
|
-
POSITION_TPSL_CONFLICT = "POSITION_TPSL_CONFLICT",
|
|
2009
|
-
INVALID_LEVERAGE = "INVALID_LEVERAGE",
|
|
2010
|
-
PREV_ORDER_NOT_FOUND = "PREV_ORDER_NOT_FOUND",
|
|
2011
|
-
PREV_ORDER_TRIGGERED = "PREV_ORDER_TRIGGERED",
|
|
2012
|
-
TPSL_OTHER_SIDE_FILLED = "TPSL_OTHER_SIDE_FILLED",
|
|
2013
|
-
PREV_ORDER_CONFLICT = "PREV_ORDER_CONFLICT",
|
|
2014
|
-
ORDER_REPLACED = "ORDER_REPLACED",
|
|
2015
|
-
POST_ONLY_MODE = "POST_ONLY_MODE",
|
|
2016
|
-
REDUCE_ONLY_MODE = "REDUCE_ONLY_MODE",
|
|
2017
|
-
TRADING_OFF_MODE = "TRADING_OFF_MODE"
|
|
2018
|
-
}
|
|
2019
|
-
declare enum PositionSide {
|
|
2020
|
-
LONG = "LONG",
|
|
2021
|
-
SHORT = "SHORT"
|
|
2022
|
-
}
|
|
2023
|
-
declare enum ExitType {
|
|
2024
|
-
TRADE = "TRADE",
|
|
2025
|
-
LIQUIDATION = "LIQUIDATION",
|
|
2026
|
-
ADL = "ADL"
|
|
2027
|
-
}
|
|
2028
|
-
declare enum AssetOperationType {
|
|
2029
|
-
DEPOSIT = "DEPOSIT",
|
|
2030
|
-
WITHDRAWAL = "WITHDRAWAL",
|
|
2031
|
-
TRANSFER = "TRANSFER"
|
|
2032
|
-
}
|
|
2033
|
-
declare enum AssetOperationStatus {
|
|
2034
|
-
CREATED = "CREATED",
|
|
2035
|
-
IN_PROGRESS = "IN_PROGRESS",
|
|
2036
|
-
COMPLETED = "COMPLETED",
|
|
2037
|
-
REJECTED = "REJECTED"
|
|
2038
|
-
}
|
|
2039
|
-
interface SettlementSignature {
|
|
2040
|
-
r: string;
|
|
2041
|
-
s: string;
|
|
2042
|
-
}
|
|
2043
|
-
interface StarkSettlement {
|
|
2044
|
-
signature: SettlementSignature;
|
|
2045
|
-
stark_key: string;
|
|
2046
|
-
collateral_position: string;
|
|
2047
|
-
}
|
|
2048
|
-
interface StarkDebuggingOrderAmounts {
|
|
2049
|
-
collateral_amount: string;
|
|
2050
|
-
fee_amount: string;
|
|
2051
|
-
synthetic_amount: string;
|
|
2052
|
-
}
|
|
2053
|
-
interface PlacedOrder {
|
|
2054
|
-
id: number;
|
|
2055
|
-
external_id: string;
|
|
2056
|
-
}
|
|
2057
|
-
interface OpenOrder {
|
|
2058
|
-
id: number;
|
|
2059
|
-
account_id: number;
|
|
2060
|
-
external_id: string;
|
|
2061
|
-
market: string;
|
|
2062
|
-
type: OrderType;
|
|
2063
|
-
side: OrderSide;
|
|
2064
|
-
status: OrderStatus;
|
|
2065
|
-
status_reason?: OrderStatusReason;
|
|
2066
|
-
price: string;
|
|
2067
|
-
average_price?: string;
|
|
2068
|
-
qty: string;
|
|
2069
|
-
filled_qty?: string;
|
|
2070
|
-
reduce_only: boolean;
|
|
2071
|
-
post_only: boolean;
|
|
2072
|
-
payed_fee?: string;
|
|
2073
|
-
created_time: number;
|
|
2074
|
-
updated_time: number;
|
|
2075
|
-
expiry_time?: number;
|
|
2076
|
-
}
|
|
2077
|
-
interface Position {
|
|
2078
|
-
id: number;
|
|
2079
|
-
accountId: number;
|
|
2080
|
-
market: string;
|
|
2081
|
-
side: PositionSide;
|
|
2082
|
-
leverage: string;
|
|
2083
|
-
size: string;
|
|
2084
|
-
value: string;
|
|
2085
|
-
openPrice: string;
|
|
2086
|
-
markPrice: string;
|
|
2087
|
-
liquidationPrice?: string;
|
|
2088
|
-
unrealisedPnl: string;
|
|
2089
|
-
realisedPnl: string;
|
|
2090
|
-
tpPrice?: string;
|
|
2091
|
-
slPrice?: string;
|
|
2092
|
-
adl?: number;
|
|
2093
|
-
createdAt: number;
|
|
2094
|
-
updatedAt: number;
|
|
2095
|
-
}
|
|
2096
|
-
interface PositionHistory {
|
|
2097
|
-
id: number;
|
|
2098
|
-
account_id: number;
|
|
2099
|
-
market: string;
|
|
2100
|
-
side: PositionSide;
|
|
2101
|
-
leverage: string;
|
|
2102
|
-
size: string;
|
|
2103
|
-
open_price: string;
|
|
2104
|
-
exit_type?: ExitType;
|
|
2105
|
-
exit_price?: string;
|
|
2106
|
-
realised_pnl: string;
|
|
2107
|
-
created_time: number;
|
|
2108
|
-
closed_time?: number;
|
|
2109
|
-
}
|
|
2110
|
-
interface Balance {
|
|
2111
|
-
collateral_name: string;
|
|
2112
|
-
balance: string;
|
|
2113
|
-
equity: string;
|
|
2114
|
-
availableForTrade: string;
|
|
2115
|
-
availableForWithdrawal: string;
|
|
2116
|
-
unrealisedPnl: string;
|
|
2117
|
-
initialMargin: string;
|
|
2118
|
-
marginRatio: string;
|
|
2119
|
-
updatedTime: number;
|
|
2120
|
-
}
|
|
2121
|
-
interface RiskFactorConfig {
|
|
2122
|
-
upper_bound: string;
|
|
2123
|
-
risk_factor: string;
|
|
2124
|
-
}
|
|
2125
|
-
interface MarketStats {
|
|
2126
|
-
daily_volume: string;
|
|
2127
|
-
daily_volume_base: string;
|
|
2128
|
-
daily_price_change: string;
|
|
2129
|
-
daily_low: string;
|
|
2130
|
-
daily_high: string;
|
|
2131
|
-
last_price: string;
|
|
2132
|
-
ask_price: string;
|
|
2133
|
-
bid_price: string;
|
|
2134
|
-
mark_price: string;
|
|
2135
|
-
index_price: string;
|
|
2136
|
-
funding_rate: string;
|
|
2137
|
-
next_funding_rate: number;
|
|
2138
|
-
open_interest: string;
|
|
2139
|
-
open_interest_base: string;
|
|
2140
|
-
}
|
|
2141
|
-
interface TradingConfig {
|
|
2142
|
-
min_order_size: string;
|
|
2143
|
-
min_order_size_change: string;
|
|
2144
|
-
min_price_change: string;
|
|
2145
|
-
max_market_order_value: string;
|
|
2146
|
-
max_limit_order_value: string;
|
|
2147
|
-
max_position_value: string;
|
|
2148
|
-
max_leverage: string;
|
|
2149
|
-
max_num_orders: number;
|
|
2150
|
-
limit_price_cap: string;
|
|
2151
|
-
limit_price_floor: string;
|
|
2152
|
-
risk_factor_config: RiskFactorConfig[];
|
|
2153
|
-
}
|
|
2154
|
-
interface L2Config {
|
|
2155
|
-
type: string;
|
|
2156
|
-
collateral_id: string;
|
|
2157
|
-
collateral_resolution: number;
|
|
2158
|
-
synthetic_id: string;
|
|
2159
|
-
synthetic_resolution: number;
|
|
2160
|
-
}
|
|
2161
|
-
interface Market {
|
|
2162
|
-
name: string;
|
|
2163
|
-
asset_name: string;
|
|
2164
|
-
asset_precision: number;
|
|
2165
|
-
collateral_asset_name: string;
|
|
2166
|
-
collateral_asset_precision: number;
|
|
2167
|
-
active: boolean;
|
|
2168
|
-
market_stats: MarketStats;
|
|
2169
|
-
trading_config: TradingConfig;
|
|
2170
|
-
l2_config: L2Config;
|
|
2171
|
-
}
|
|
2172
|
-
interface AssetOperation {
|
|
2173
|
-
id: string;
|
|
2174
|
-
type: AssetOperationType;
|
|
2175
|
-
status: AssetOperationStatus;
|
|
2176
|
-
amount: string;
|
|
2177
|
-
asset: string;
|
|
2178
|
-
created_time: number;
|
|
2179
|
-
updated_time: number;
|
|
2180
|
-
description?: string;
|
|
2181
|
-
transactionHash?: string;
|
|
2182
|
-
}
|
|
2183
|
-
interface CreateOrderRequest {
|
|
2184
|
-
market_name: string;
|
|
2185
|
-
amount: string;
|
|
2186
|
-
price: string;
|
|
2187
|
-
side: OrderSide;
|
|
2188
|
-
post_only?: boolean;
|
|
2189
|
-
reduce_only?: boolean;
|
|
2190
|
-
previous_order_id?: number;
|
|
2191
|
-
external_id?: string;
|
|
2192
|
-
time_in_force?: TimeInForce;
|
|
2193
|
-
}
|
|
2194
|
-
interface WithdrawRequest {
|
|
2195
|
-
amount: string;
|
|
2196
|
-
asset?: string;
|
|
2197
|
-
}
|
|
2198
|
-
interface SignedWithdrawRequest {
|
|
2199
|
-
recipient: string;
|
|
2200
|
-
position_id: number;
|
|
2201
|
-
amount: number;
|
|
2202
|
-
expiration: number;
|
|
2203
|
-
salt: number;
|
|
2204
|
-
}
|
|
2205
|
-
interface CancelOrderRequest {
|
|
2206
|
-
order_id: number;
|
|
2207
|
-
}
|
|
2208
|
-
interface ApiResponse<T> {
|
|
2209
|
-
success: boolean;
|
|
2210
|
-
message: string;
|
|
2211
|
-
data: T;
|
|
2212
|
-
}
|
|
2213
|
-
interface ExtendedApiResponse<T> {
|
|
2214
|
-
status: 'OK' | 'ERROR';
|
|
2215
|
-
message: string;
|
|
2216
|
-
data: T;
|
|
2217
|
-
}
|
|
2218
|
-
interface ExtendedWrapperConfig {
|
|
2219
|
-
readUrl: string;
|
|
2220
|
-
writeUrl: string;
|
|
2221
|
-
apiKey?: string;
|
|
2222
|
-
timeout?: number;
|
|
2223
|
-
retries?: number;
|
|
2224
|
-
}
|
|
2225
|
-
interface UpdateLeverageRequest {
|
|
2226
|
-
leverage: string;
|
|
2227
|
-
market: string;
|
|
2228
|
-
}
|
|
2229
|
-
interface FundingRate {
|
|
2230
|
-
m: string;
|
|
2231
|
-
f: string;
|
|
2232
|
-
t: number;
|
|
2233
|
-
}
|
|
2234
|
-
interface FundingPayment {
|
|
2235
|
-
id: number;
|
|
2236
|
-
accountId?: number;
|
|
2237
|
-
account_id?: number;
|
|
2238
|
-
market: string;
|
|
2239
|
-
positionId?: number;
|
|
2240
|
-
position_id?: number;
|
|
2241
|
-
side: PositionSide;
|
|
2242
|
-
size: string;
|
|
2243
|
-
value: string;
|
|
2244
|
-
markPrice?: string;
|
|
2245
|
-
mark_price?: string;
|
|
2246
|
-
fundingFee?: string;
|
|
2247
|
-
funding_fee?: string;
|
|
2248
|
-
fundingRate?: string;
|
|
2249
|
-
funding_rate?: string;
|
|
2250
|
-
paidTime?: number;
|
|
2251
|
-
paid_time?: number;
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2254
|
-
/**
|
|
2255
|
-
* ExtendedWrapper - TypeScript wrapper for Extended Exchange API
|
|
2256
|
-
* Provides a clean interface to interact with the Extended Exchange trading API
|
|
2257
|
-
*/
|
|
2258
|
-
|
|
2259
|
-
declare class ExtendedWrapper {
|
|
2260
|
-
private readUrl;
|
|
2261
|
-
private writeUrl;
|
|
2262
|
-
private apiKey?;
|
|
2263
|
-
private timeout;
|
|
2264
|
-
private retries;
|
|
2265
|
-
/** Per-market rules from GET /markets (tradingConfig); retained for process lifetime (no TTL). */
|
|
2266
|
-
private marketTradingRulesCache;
|
|
2267
|
-
private marketTradingRulesInflight;
|
|
2268
|
-
constructor(config: ExtendedWrapperConfig);
|
|
2269
|
-
/**
|
|
2270
|
-
* Make HTTP request with retry logic and error handling
|
|
2271
|
-
*/
|
|
2272
|
-
private makeRequest;
|
|
2273
|
-
private resolveTradingRules;
|
|
2274
|
-
/**
|
|
2275
|
-
* Create a new order on Extended Exchange
|
|
2276
|
-
*/
|
|
2277
|
-
createOrder(request: CreateOrderRequest): Promise<ExtendedApiResponse<PlacedOrder>>;
|
|
2278
|
-
/**
|
|
2279
|
-
* Get all markets
|
|
2280
|
-
*/
|
|
2281
|
-
getMarkets(marketNames?: string): Promise<ExtendedApiResponse<Market[]>>;
|
|
2282
|
-
/**
|
|
2283
|
-
*
|
|
2284
|
-
* @param orderId - The ID of the order to get
|
|
2285
|
-
* @returns The order
|
|
2286
|
-
*/
|
|
2287
|
-
getOrderByOrderId(orderId: string): Promise<ExtendedApiResponse<OpenOrder>>;
|
|
2288
|
-
/**
|
|
2289
|
-
* Get market statistics for a specific market
|
|
2290
|
-
*/
|
|
2291
|
-
getMarketStatistics(marketName: string): Promise<ExtendedApiResponse<MarketStats>>;
|
|
2292
|
-
/**
|
|
2293
|
-
* Get current trading positions
|
|
2294
|
-
*/
|
|
2295
|
-
getPositions(marketNames?: string): Promise<ExtendedApiResponse<Position[]>>;
|
|
2296
|
-
/**
|
|
2297
|
-
* Get account balance and holdings
|
|
2298
|
-
*/
|
|
2299
|
-
getHoldings(): Promise<ExtendedApiResponse<Balance>>;
|
|
2300
|
-
/**
|
|
2301
|
-
* Initiate a withdrawal from Extended Exchange
|
|
2302
|
-
* Returns data as number | string to preserve precision for large integers
|
|
2303
|
-
*/
|
|
2304
|
-
withdraw(request: WithdrawRequest): Promise<ExtendedApiResponse<number | string>>;
|
|
2305
|
-
/**
|
|
2306
|
-
* Create and sign a withdrawal request hash
|
|
2307
|
-
*/
|
|
2308
|
-
signWithdrawalRequest(request: SignedWithdrawRequest): Promise<ExtendedApiResponse<{
|
|
2309
|
-
withdraw_request_hash: string;
|
|
2310
|
-
signature: {
|
|
2311
|
-
r: string;
|
|
2312
|
-
s: string;
|
|
2313
|
-
};
|
|
2314
|
-
}>>;
|
|
2315
|
-
/**
|
|
2316
|
-
* Cancel an existing order
|
|
2317
|
-
*/
|
|
2318
|
-
cancelOrder(request: CancelOrderRequest): Promise<ExtendedApiResponse<{}>>;
|
|
2319
|
-
/**
|
|
2320
|
-
* Get all open orders
|
|
2321
|
-
*/
|
|
2322
|
-
getOpenOrders(marketName?: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
|
|
2323
|
-
/**
|
|
2324
|
-
* Update leverage on the market
|
|
2325
|
-
* @param request
|
|
2326
|
-
* @returns
|
|
2327
|
-
*/
|
|
2328
|
-
updateLeverage(request: UpdateLeverageRequest): Promise<ExtendedApiResponse<{}>>;
|
|
2329
|
-
/**
|
|
2330
|
-
* Get asset operations with optional filtering
|
|
2331
|
-
*/
|
|
2332
|
-
getAssetOperations(options?: {
|
|
2333
|
-
id?: number;
|
|
2334
|
-
operationsType?: AssetOperationType[];
|
|
2335
|
-
operationsStatus?: AssetOperationStatus[];
|
|
2336
|
-
startTime?: number;
|
|
2337
|
-
endTime?: number;
|
|
2338
|
-
cursor?: number;
|
|
2339
|
-
limit?: number;
|
|
2340
|
-
}): Promise<ExtendedApiResponse<AssetOperation[]>>;
|
|
2341
|
-
/**
|
|
2342
|
-
* Health check endpoint
|
|
2343
|
-
*/
|
|
2344
|
-
healthCheck(): Promise<ExtendedApiResponse<MarketStats>>;
|
|
2345
|
-
/**
|
|
2346
|
-
* Convenience method to create a buy order
|
|
2347
|
-
*/
|
|
2348
|
-
createBuyOrder(marketName: string, amount: string, price: string, options?: {
|
|
2349
|
-
post_only?: boolean;
|
|
2350
|
-
reduce_only?: boolean;
|
|
2351
|
-
previous_order_id?: number;
|
|
2352
|
-
external_id?: string;
|
|
2353
|
-
time_in_force?: TimeInForce;
|
|
2354
|
-
}): Promise<ExtendedApiResponse<PlacedOrder>>;
|
|
2355
|
-
/**
|
|
2356
|
-
* Get order by ID
|
|
2357
|
-
* @param orderId - The ID of the order to get
|
|
2358
|
-
* @returns The order
|
|
2359
|
-
*/
|
|
2360
|
-
getOrderById(orderId: number): Promise<ExtendedApiResponse<OpenOrder>>;
|
|
2361
|
-
/**
|
|
2362
|
-
* Convenience method to create a sell order
|
|
2363
|
-
*/
|
|
2364
|
-
createSellOrder(marketName: string, amount: string, price: string, options?: {
|
|
2365
|
-
post_only?: boolean;
|
|
2366
|
-
reduce_only?: boolean;
|
|
2367
|
-
previous_order_id?: number;
|
|
2368
|
-
external_id?: string;
|
|
2369
|
-
time_in_force?: TimeInForce;
|
|
2370
|
-
}): Promise<ExtendedApiResponse<PlacedOrder>>;
|
|
2371
|
-
/**
|
|
2372
|
-
* Get positions for a specific market
|
|
2373
|
-
*/
|
|
2374
|
-
getPositionsForMarket(marketName: string): Promise<ExtendedApiResponse<Position[]>>;
|
|
2375
2124
|
/**
|
|
2376
|
-
*
|
|
2125
|
+
* Simulates a deposit of `depositAmount` collateral and returns how much
|
|
2126
|
+
* debt (STRK) would be incrementally borrowed to reach the target LTV.
|
|
2127
|
+
* Used upstream to size the AVNU swap call in the same transaction batch.
|
|
2377
2128
|
*/
|
|
2378
|
-
|
|
2129
|
+
getExpectedDepositDebtDelta(depositAmount: Web3Number): Promise<Web3Number>;
|
|
2379
2130
|
/**
|
|
2380
|
-
*
|
|
2131
|
+
* Simulates a withdrawal of `withdrawAmount` collateral and returns the
|
|
2132
|
+
* incremental debt delta needed to keep the target health factor.
|
|
2133
|
+
* Positive means borrow, negative means repay.
|
|
2381
2134
|
*/
|
|
2382
|
-
|
|
2383
|
-
/**
|
|
2384
|
-
* Get order history for a specific market
|
|
2385
|
-
* @param marketName - The name of the market to get order history for
|
|
2386
|
-
* @returns The order history for the specified market
|
|
2387
|
-
*/
|
|
2388
|
-
getOrderHistory(marketName: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
|
|
2389
|
-
/**
|
|
2390
|
-
* Withdraw USDC (convenience method)
|
|
2391
|
-
* Returns data as number | string to preserve precision for large integers
|
|
2392
|
-
*/
|
|
2393
|
-
withdrawUSDC(amount: string): Promise<ExtendedApiResponse<number | string>>;
|
|
2394
|
-
/**
|
|
2395
|
-
* Get funding rates for a specific market
|
|
2396
|
-
* @param marketName - The name of the market to get funding rates for
|
|
2397
|
-
* @returns The funding rates for the specified market
|
|
2398
|
-
*/
|
|
2399
|
-
getFundingRates(marketName: string, side: string, startTime?: number, endTime?: number): Promise<ExtendedApiResponse<FundingRate[]>>;
|
|
2400
|
-
/**
|
|
2401
|
-
* Get funding payments for a specific market.
|
|
2402
|
-
*/
|
|
2403
|
-
getUserFundingPayments(marketName: string, side: string, startTime: number, limit?: number, cursor?: number): Promise<ExtendedApiResponse<FundingPayment[]>>;
|
|
2404
|
-
}
|
|
2405
|
-
|
|
2406
|
-
interface AvnuAdapterConfig extends BaseAdapterConfig {
|
|
2407
|
-
baseUrl: string;
|
|
2408
|
-
avnuContract: ContractAddr;
|
|
2409
|
-
slippage: number;
|
|
2410
|
-
minimumExtendedPriceDifferenceForSwapOpen: number;
|
|
2411
|
-
maximumExtendedPriceDifferenceForSwapClosing: number;
|
|
2412
|
-
}
|
|
2413
|
-
declare class AvnuAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
2414
|
-
readonly config: AvnuAdapterConfig;
|
|
2415
|
-
protected avnuWrapper: AvnuWrapper;
|
|
2416
|
-
lastSwapPriceInfo: SwapPriceInfo | null;
|
|
2417
|
-
private _depositApproveProofReadableId;
|
|
2418
|
-
private _depositSwapProofReadableId;
|
|
2419
|
-
private _withdrawApproveProofReadableId;
|
|
2420
|
-
private _withdrawSwapProofReadableId;
|
|
2421
|
-
private buildSwapLeafConfigs;
|
|
2422
|
-
private buildSwapCalls;
|
|
2423
|
-
constructor(config: AvnuAdapterConfig);
|
|
2424
|
-
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
2425
|
-
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
|
|
2426
|
-
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
2427
|
-
maxWithdraw(): Promise<PositionInfo>;
|
|
2428
|
-
protected _getDepositLeaf(): {
|
|
2429
|
-
target: ContractAddr;
|
|
2430
|
-
method: string;
|
|
2431
|
-
packedArguments: bigint[];
|
|
2432
|
-
sanitizer: ContractAddr;
|
|
2433
|
-
id: string;
|
|
2434
|
-
}[];
|
|
2435
|
-
protected _getWithdrawLeaf(): {
|
|
2436
|
-
target: ContractAddr;
|
|
2437
|
-
method: string;
|
|
2438
|
-
packedArguments: bigint[];
|
|
2439
|
-
sanitizer: ContractAddr;
|
|
2440
|
-
id: string;
|
|
2441
|
-
}[];
|
|
2442
|
-
protected _getLegacySwapLeaf(): {
|
|
2443
|
-
target: ContractAddr;
|
|
2444
|
-
method: string;
|
|
2445
|
-
packedArguments: bigint[];
|
|
2446
|
-
sanitizer: ContractAddr;
|
|
2447
|
-
id: string;
|
|
2448
|
-
}[];
|
|
2449
|
-
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
2450
|
-
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
2451
|
-
getSwapCallData(quote: Quote): Promise<bigint[][]>;
|
|
2452
|
-
getHealthFactor(): Promise<number>;
|
|
2453
|
-
fetchQuoteWithRetry(params: Record<string, any>, retries?: number): Promise<any>;
|
|
2454
|
-
}
|
|
2455
|
-
|
|
2456
|
-
interface ExtendedAdapterConfig extends BaseAdapterConfig {
|
|
2457
|
-
vaultIdExtended: number;
|
|
2458
|
-
extendedContract: ContractAddr;
|
|
2459
|
-
extendedBackendReadUrl: string;
|
|
2460
|
-
extendedBackendWriteUrl: string;
|
|
2461
|
-
extendedTimeout: number;
|
|
2462
|
-
extendedRetries: number;
|
|
2463
|
-
extendedBaseUrl: string;
|
|
2464
|
-
extendedMarketName: string;
|
|
2465
|
-
extendedPrecision: number;
|
|
2466
|
-
avnuAdapter: AvnuAdapter;
|
|
2467
|
-
retryDelayForOrderStatus: number;
|
|
2468
|
-
minimumExtendedMovementAmount: number;
|
|
2469
|
-
}
|
|
2470
|
-
declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
2471
|
-
readonly config: ExtendedAdapterConfig;
|
|
2472
|
-
readonly client: ExtendedWrapper;
|
|
2473
|
-
readonly usdcToken: TokenInfo;
|
|
2474
|
-
readonly retryDelayForOrderStatus: number;
|
|
2475
|
-
readonly minimumExtendedMovementAmount: number;
|
|
2476
|
-
constructor(config: ExtendedAdapterConfig);
|
|
2477
|
-
private _depositApproveProofReadableId;
|
|
2478
|
-
private _depositCallProofReadableId;
|
|
2479
|
-
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
2480
|
-
getFundingRates(side: string, startTime?: number, endTime?: number): Promise<{
|
|
2481
|
-
success: boolean;
|
|
2482
|
-
data: FundingRate[];
|
|
2483
|
-
}>;
|
|
2484
|
-
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
2485
|
-
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
2486
|
-
maxWithdraw(): Promise<PositionInfo>;
|
|
2487
|
-
protected _getDepositLeaf(): {
|
|
2488
|
-
target: ContractAddr;
|
|
2489
|
-
method: string;
|
|
2490
|
-
packedArguments: bigint[];
|
|
2491
|
-
sanitizer: ContractAddr;
|
|
2492
|
-
id: string;
|
|
2493
|
-
}[];
|
|
2494
|
-
protected _getWithdrawLeaf(): {
|
|
2495
|
-
target: ContractAddr;
|
|
2496
|
-
method: string;
|
|
2497
|
-
packedArguments: bigint[];
|
|
2498
|
-
sanitizer: ContractAddr;
|
|
2499
|
-
id: string;
|
|
2500
|
-
}[];
|
|
2501
|
-
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
2502
|
-
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
2503
|
-
withdrawFromExtended(amount: Web3Number): Promise<{
|
|
2504
|
-
status: boolean;
|
|
2505
|
-
receivedTxnHash: boolean;
|
|
2506
|
-
}>;
|
|
2507
|
-
getHealthFactor(): Promise<number>;
|
|
2508
|
-
getExtendedDepositAmount(): Promise<Balance | undefined>;
|
|
2509
|
-
setLeverage(leverage: string, marketName: string): Promise<boolean>;
|
|
2510
|
-
getAllOpenPositions(): Promise<Position[] | null>;
|
|
2511
|
-
getOrderStatus(orderId: string, marketName: string): Promise<OpenOrder | null>;
|
|
2512
|
-
fetchOrderBookFromExtended(): Promise<{
|
|
2513
|
-
status: boolean;
|
|
2514
|
-
bid: Web3Number;
|
|
2515
|
-
ask: Web3Number;
|
|
2516
|
-
}>;
|
|
2517
|
-
createOrder(leverage: string, btcAmount: number, side: OrderSide, attempt?: number, maxAttempts?: number): Promise<{
|
|
2518
|
-
position_id: string;
|
|
2519
|
-
btc_exposure: string;
|
|
2520
|
-
} | null>;
|
|
2521
|
-
createExtendedPositon(client: ExtendedWrapper, marketName: string, amount: string, price: string, side: OrderSide): Promise<{
|
|
2522
|
-
position_id: string;
|
|
2523
|
-
} | null>;
|
|
2524
|
-
getDepositOrWithdrawalStatus(orderId: number | string, // for deposits, send txn hash as string
|
|
2525
|
-
operationsType: AssetOperationType): Promise<boolean>;
|
|
2135
|
+
getExpectedWithdrawDebtDelta(withdrawAmount: Web3Number): Promise<Web3Number>;
|
|
2526
2136
|
}
|
|
2527
2137
|
|
|
2528
2138
|
declare const SIMPLE_SANITIZER: ContractAddr;
|
|
2139
|
+
declare const SVK_SIMPLE_SANITIZER: ContractAddr;
|
|
2529
2140
|
declare const EXTENDED_SANITIZER: ContractAddr;
|
|
2530
2141
|
declare const AVNU_LEGACY_SANITIZER: ContractAddr;
|
|
2531
2142
|
declare const SIMPLE_SANITIZER_V2: ContractAddr;
|
|
@@ -2585,6 +2196,62 @@ declare class TokenTransferAdapter extends BaseAdapter<DepositParams, WithdrawPa
|
|
|
2585
2196
|
getHealthFactor(): Promise<number>;
|
|
2586
2197
|
}
|
|
2587
2198
|
|
|
2199
|
+
interface AvnuDepositParams extends DepositParams {
|
|
2200
|
+
minAmount?: Web3Number;
|
|
2201
|
+
}
|
|
2202
|
+
interface AvnuWithdrawParams extends WithdrawParams {
|
|
2203
|
+
minAmount?: Web3Number;
|
|
2204
|
+
}
|
|
2205
|
+
interface AvnuAdapterConfig extends BaseAdapterConfig {
|
|
2206
|
+
baseUrl: string;
|
|
2207
|
+
avnuContract: ContractAddr;
|
|
2208
|
+
slippage: number;
|
|
2209
|
+
minimumExtendedPriceDifferenceForSwapOpen: number;
|
|
2210
|
+
maximumExtendedPriceDifferenceForSwapClosing: number;
|
|
2211
|
+
}
|
|
2212
|
+
declare class AvnuAdapter extends BaseAdapter<AvnuDepositParams, AvnuWithdrawParams> {
|
|
2213
|
+
readonly config: AvnuAdapterConfig;
|
|
2214
|
+
protected avnuWrapper: AvnuWrapper;
|
|
2215
|
+
lastSwapPriceInfo: SwapPriceInfo | null;
|
|
2216
|
+
private _depositApproveProofReadableId;
|
|
2217
|
+
private _depositSwapProofReadableId;
|
|
2218
|
+
private _withdrawApproveProofReadableId;
|
|
2219
|
+
private _withdrawSwapProofReadableId;
|
|
2220
|
+
private buildSwapLeafConfigs;
|
|
2221
|
+
private buildSwapCalls;
|
|
2222
|
+
constructor(config: AvnuAdapterConfig);
|
|
2223
|
+
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
2224
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
|
|
2225
|
+
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
2226
|
+
maxWithdraw(): Promise<PositionInfo>;
|
|
2227
|
+
protected _getDepositLeaf(): {
|
|
2228
|
+
target: ContractAddr;
|
|
2229
|
+
method: string;
|
|
2230
|
+
packedArguments: bigint[];
|
|
2231
|
+
sanitizer: ContractAddr;
|
|
2232
|
+
id: string;
|
|
2233
|
+
}[];
|
|
2234
|
+
protected _getWithdrawLeaf(): {
|
|
2235
|
+
target: ContractAddr;
|
|
2236
|
+
method: string;
|
|
2237
|
+
packedArguments: bigint[];
|
|
2238
|
+
sanitizer: ContractAddr;
|
|
2239
|
+
id: string;
|
|
2240
|
+
}[];
|
|
2241
|
+
protected _getLegacySwapLeaf(): {
|
|
2242
|
+
target: ContractAddr;
|
|
2243
|
+
method: string;
|
|
2244
|
+
packedArguments: bigint[];
|
|
2245
|
+
sanitizer: ContractAddr;
|
|
2246
|
+
id: string;
|
|
2247
|
+
}[];
|
|
2248
|
+
getDepositCall(params: AvnuDepositParams): Promise<ManageCall[]>;
|
|
2249
|
+
getWithdrawCall(params: AvnuWithdrawParams): Promise<ManageCall[]>;
|
|
2250
|
+
getSwapCallData(quote: Quote): Promise<bigint[][]>;
|
|
2251
|
+
getHealthFactor(): Promise<number>;
|
|
2252
|
+
fetchQuoteWithRetry(params: Record<string, any>, retries?: number): Promise<any>;
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2588
2255
|
/** Public Troves strategies feed (APY + metadata). Override in config for tests. */
|
|
2589
2256
|
declare const DEFAULT_TROVES_STRATEGIES_API = "https://app.troves.fi/api/strategies";
|
|
2590
2257
|
interface SvkTrovesAdapterConfig extends BaseAdapterConfig {
|
|
@@ -2604,6 +2271,11 @@ interface SvkTrovesAdapterConfig extends BaseAdapterConfig {
|
|
|
2604
2271
|
positionOwner?: ContractAddr;
|
|
2605
2272
|
/** Optional APY endpoint (defaults to {@link DEFAULT_TROVES_STRATEGIES_API}). */
|
|
2606
2273
|
trovesStrategiesApiUrl?: string;
|
|
2274
|
+
/**
|
|
2275
|
+
* Optional redeem request NFT contract address. When provided, pending assets are calculated
|
|
2276
|
+
* using `getPendingAssetsFromOwnerNFTMethod` instead of `due_assets_from_owner`.
|
|
2277
|
+
*/
|
|
2278
|
+
redeemRequestNFT?: ContractAddr;
|
|
2607
2279
|
}
|
|
2608
2280
|
/**
|
|
2609
2281
|
* Universal adapter for **Starknet Vault Kit (SVK)** style Troves strategies:
|
|
@@ -2630,6 +2302,17 @@ declare class SvkTrovesAdapter extends BaseAdapter<DepositParams, WithdrawParams
|
|
|
2630
2302
|
private _withdrawCallProofReadableId;
|
|
2631
2303
|
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
2632
2304
|
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
|
|
2305
|
+
getPendingAssetsFromOwner(owner?: ContractAddr, decimals?: number): Promise<Web3Number>;
|
|
2306
|
+
/**
|
|
2307
|
+
* Get pending assets from owner by scanning redeem request NFTs.
|
|
2308
|
+
* This method iterates backwards through NFT IDs to find all pending redemptions for a specific owner.
|
|
2309
|
+
*
|
|
2310
|
+
* @param redeemRequestNFT - The redeem request NFT contract address
|
|
2311
|
+
* @param owner - The owner address to check for pending redemptions (defaults to positionOwner)
|
|
2312
|
+
* @param decimals - Token decimals for conversion (defaults to baseToken decimals)
|
|
2313
|
+
* @returns Total pending assets from all NFTs owned by the specified address
|
|
2314
|
+
*/
|
|
2315
|
+
getPendingAssetsFromOwnerNFTMethod(redeemRequestNFT: ContractAddr, owner?: ContractAddr, decimals?: number): Promise<Web3Number>;
|
|
2633
2316
|
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
2634
2317
|
maxWithdraw(): Promise<PositionInfo>;
|
|
2635
2318
|
protected _getDepositLeaf(): {
|
|
@@ -2658,186 +2341,6 @@ declare enum LSTPriceType {
|
|
|
2658
2341
|
AVNU_PRICE = "AVNU_PRICE"
|
|
2659
2342
|
}
|
|
2660
2343
|
|
|
2661
|
-
interface UniversalManageCall {
|
|
2662
|
-
proofs: string[];
|
|
2663
|
-
manageCall: ManageCall;
|
|
2664
|
-
step: UNIVERSAL_MANAGE_IDS;
|
|
2665
|
-
}
|
|
2666
|
-
interface UniversalStrategySettings {
|
|
2667
|
-
vaultAddress: ContractAddr;
|
|
2668
|
-
manager: ContractAddr;
|
|
2669
|
-
vaultAllocator: ContractAddr;
|
|
2670
|
-
redeemRequestNFT: ContractAddr;
|
|
2671
|
-
aumOracle: ContractAddr;
|
|
2672
|
-
redemptionRouter?: ContractAddr;
|
|
2673
|
-
leafAdapters: LeafAdapterFn<any>[];
|
|
2674
|
-
adapters: {
|
|
2675
|
-
id: string;
|
|
2676
|
-
adapter: BaseAdapter<DepositParams, WithdrawParams>;
|
|
2677
|
-
}[];
|
|
2678
|
-
targetHealthFactor: number;
|
|
2679
|
-
minHealthFactor: number;
|
|
2680
|
-
}
|
|
2681
|
-
declare enum AUMTypes {
|
|
2682
|
-
FINALISED = "finalised",
|
|
2683
|
-
DEFISPRING = "defispring"
|
|
2684
|
-
}
|
|
2685
|
-
declare enum PositionTypeAvnuExtended {
|
|
2686
|
-
OPEN = "open",
|
|
2687
|
-
CLOSE = "close"
|
|
2688
|
-
}
|
|
2689
|
-
declare class UniversalStrategy<S extends UniversalStrategySettings> extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
2690
|
-
/** Contract address of the strategy */
|
|
2691
|
-
readonly address: ContractAddr;
|
|
2692
|
-
/** Pricer instance for token price calculations */
|
|
2693
|
-
readonly pricer: PricerBase;
|
|
2694
|
-
/** Metadata containing strategy information */
|
|
2695
|
-
readonly metadata: IStrategyMetadata<S>;
|
|
2696
|
-
/** Contract instance for interacting with the strategy */
|
|
2697
|
-
readonly contract: Contract;
|
|
2698
|
-
readonly managerContract: Contract;
|
|
2699
|
-
merkleTree: StandardMerkleTree | undefined;
|
|
2700
|
-
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
|
|
2701
|
-
getMerkleTree(): StandardMerkleTree;
|
|
2702
|
-
getMerkleRoot(): string;
|
|
2703
|
-
getProofs<T>(id: string): {
|
|
2704
|
-
proofs: string[];
|
|
2705
|
-
callConstructor: GenerateCallFn<T>;
|
|
2706
|
-
};
|
|
2707
|
-
getAdapter(id: string): BaseAdapter<any, any>;
|
|
2708
|
-
asset(): TokenInfo;
|
|
2709
|
-
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
2710
|
-
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
2711
|
-
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<{
|
|
2712
|
-
tokenInfo: TokenInfo;
|
|
2713
|
-
amount: Web3Number;
|
|
2714
|
-
usdValue: number;
|
|
2715
|
-
}>;
|
|
2716
|
-
getVesuAPYs(): Promise<{
|
|
2717
|
-
baseAPYs: number[];
|
|
2718
|
-
rewardAPYs: number[];
|
|
2719
|
-
positions: VaultPosition[];
|
|
2720
|
-
}>;
|
|
2721
|
-
/**
|
|
2722
|
-
* Calculates the weighted average APY across all pools based on USD value.
|
|
2723
|
-
* @returns {Promise<number>} The weighted average APY across all pools
|
|
2724
|
-
*/
|
|
2725
|
-
netAPY(): Promise<{
|
|
2726
|
-
net: number;
|
|
2727
|
-
splits: {
|
|
2728
|
-
apy: number;
|
|
2729
|
-
id: string;
|
|
2730
|
-
}[];
|
|
2731
|
-
}>;
|
|
2732
|
-
protected returnNetAPY(baseAPYs: number[], rewardAPYs: number[], weights: number[], prevAUMUSD: Web3Number): Promise<{
|
|
2733
|
-
net: number;
|
|
2734
|
-
splits: {
|
|
2735
|
-
apy: number;
|
|
2736
|
-
id: string;
|
|
2737
|
-
}[];
|
|
2738
|
-
}>;
|
|
2739
|
-
protected getUnusedBalanceAPY(): Promise<{
|
|
2740
|
-
apy: number;
|
|
2741
|
-
weight: number;
|
|
2742
|
-
}>;
|
|
2743
|
-
private computeAPY;
|
|
2744
|
-
/**
|
|
2745
|
-
* Calculates user realized APY based on trueSharesBasedAPY method.
|
|
2746
|
-
* Returns the APY as a number.
|
|
2747
|
-
*/
|
|
2748
|
-
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
2749
|
-
/**
|
|
2750
|
-
* Calculates the total TVL of the strategy.
|
|
2751
|
-
* @returns Object containing the total amount in token units and USD value
|
|
2752
|
-
*/
|
|
2753
|
-
getTVL(): Promise<{
|
|
2754
|
-
tokenInfo: TokenInfo;
|
|
2755
|
-
amount: Web3Number;
|
|
2756
|
-
usdValue: number;
|
|
2757
|
-
}>;
|
|
2758
|
-
getUnusedBalance(): Promise<SingleTokenInfo>;
|
|
2759
|
-
protected getVesuAUM(adapter: VesuAdapter, _priceType?: LSTPriceType): Promise<Web3Number>;
|
|
2760
|
-
getPrevAUM(): Promise<Web3Number>;
|
|
2761
|
-
getAUM(unrealizedAUM?: boolean): Promise<{
|
|
2762
|
-
net: SingleTokenInfo;
|
|
2763
|
-
prevAum: Web3Number;
|
|
2764
|
-
splits: {
|
|
2765
|
-
id: string;
|
|
2766
|
-
aum: Web3Number;
|
|
2767
|
-
}[];
|
|
2768
|
-
}>;
|
|
2769
|
-
protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
|
|
2770
|
-
getVesuAdapters(): VesuAdapter[];
|
|
2771
|
-
getVesuPositions(blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
|
|
2772
|
-
getVaultPositions(): Promise<VaultPosition[]>;
|
|
2773
|
-
getSetManagerCall(strategist: ContractAddr, root?: string): Call;
|
|
2774
|
-
getManageCall(proofIds: string[], manageCalls: ManageCall[]): Call;
|
|
2775
|
-
getVesuModifyPositionCalls(params: {
|
|
2776
|
-
isLeg1: boolean;
|
|
2777
|
-
isDeposit: boolean;
|
|
2778
|
-
depositAmount: Web3Number;
|
|
2779
|
-
debtAmount: Web3Number;
|
|
2780
|
-
}): UniversalManageCall[];
|
|
2781
|
-
getTag(): string;
|
|
2782
|
-
/**
|
|
2783
|
-
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
2784
|
-
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
2785
|
-
*/
|
|
2786
|
-
getLSTAPR(address: ContractAddr): Promise<number>;
|
|
2787
|
-
getVesuHealthFactors(blockNumber?: BlockIdentifier): Promise<number[]>;
|
|
2788
|
-
computeRebalanceConditionAndReturnCalls(): Promise<Call[]>;
|
|
2789
|
-
private getNewHealthFactor;
|
|
2790
|
-
/**
|
|
2791
|
-
*
|
|
2792
|
-
* @param vesuAdapter
|
|
2793
|
-
* @param currentHf
|
|
2794
|
-
* @param isDeposit if true, attempt by adding collateral, else by repaying
|
|
2795
|
-
* @returns
|
|
2796
|
-
*/
|
|
2797
|
-
private getLegRebalanceAmount;
|
|
2798
|
-
getVesuModifyPositionCall(params: {
|
|
2799
|
-
isDeposit: boolean;
|
|
2800
|
-
leg1DepositAmount: Web3Number;
|
|
2801
|
-
}): Promise<Call>;
|
|
2802
|
-
getBringLiquidityCall(params: {
|
|
2803
|
-
amount: Web3Number;
|
|
2804
|
-
}): Promise<Call>;
|
|
2805
|
-
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
2806
|
-
getHarvestCall(): Promise<{
|
|
2807
|
-
call: Call;
|
|
2808
|
-
reward: Web3Number;
|
|
2809
|
-
tokenInfo: TokenInfo;
|
|
2810
|
-
}>;
|
|
2811
|
-
getRebalanceCall(params: {
|
|
2812
|
-
isLeg1toLeg2: boolean;
|
|
2813
|
-
amount: Web3Number;
|
|
2814
|
-
}): Promise<Call>;
|
|
2815
|
-
}
|
|
2816
|
-
declare enum UNIVERSAL_MANAGE_IDS {
|
|
2817
|
-
FLASH_LOAN = "flash_loan_init",
|
|
2818
|
-
VESU_LEG1 = "vesu_leg1",
|
|
2819
|
-
VESU_LEG2 = "vesu_leg2",
|
|
2820
|
-
APPROVE_TOKEN1 = "approve_token1",
|
|
2821
|
-
APPROVE_TOKEN2 = "approve_token2",
|
|
2822
|
-
APPROVE_BRING_LIQUIDITY = "approve_bring_liquidity",
|
|
2823
|
-
BRING_LIQUIDITY = "bring_liquidity",
|
|
2824
|
-
DEFISPRING_REWARDS = "defispring_rewards",
|
|
2825
|
-
APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
|
|
2826
|
-
AVNU_SWAP_REWARDS = "avnu_swap_rewards"
|
|
2827
|
-
}
|
|
2828
|
-
declare enum UNIVERSAL_ADAPTERS {
|
|
2829
|
-
COMMON = "common_adapter",
|
|
2830
|
-
VESU_LEG1 = "vesu_leg1_adapter",
|
|
2831
|
-
VESU_LEG2 = "vesu_leg2_adapter"
|
|
2832
|
-
}
|
|
2833
|
-
declare function getContractDetails(settings: UniversalStrategySettings & {
|
|
2834
|
-
aumOracle?: ContractAddr;
|
|
2835
|
-
}): {
|
|
2836
|
-
address: ContractAddr;
|
|
2837
|
-
name: string;
|
|
2838
|
-
}[];
|
|
2839
|
-
declare const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[];
|
|
2840
|
-
|
|
2841
2344
|
/**
|
|
2842
2345
|
* Base class for all SVK (Starknet Vault Kit) strategies.
|
|
2843
2346
|
* Contains common functions that are shared across all SVK strategies.
|
|
@@ -2873,7 +2376,7 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
|
|
|
2873
2376
|
*/
|
|
2874
2377
|
protected buildManageCallFromAdapter(adapter: {
|
|
2875
2378
|
getProofs: (isDeposit: boolean, tree: any) => any;
|
|
2876
|
-
}, isDeposit: boolean, amount: Web3Number): Promise<Call>;
|
|
2379
|
+
}, isDeposit: boolean, amount: Web3Number, additionalParams?: Record<string, any>): Promise<Call>;
|
|
2877
2380
|
/**
|
|
2878
2381
|
* Bridges liquidity from the vault allocator back to the vault.
|
|
2879
2382
|
* Note: This function is common for any SVK strategy.
|
|
@@ -2929,42 +2432,67 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
|
|
|
2929
2432
|
id: string;
|
|
2930
2433
|
}[];
|
|
2931
2434
|
}>;
|
|
2435
|
+
getTVL(): Promise<SingleTokenInfo>;
|
|
2932
2436
|
getPrevAUM(): Promise<Web3Number>;
|
|
2933
2437
|
maxDepositables(): Promise<PositionInfo[]>;
|
|
2934
2438
|
maxWithdrawables(): Promise<PositionInfo[]>;
|
|
2935
2439
|
}
|
|
2936
2440
|
|
|
2937
|
-
interface
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2441
|
+
interface UniversalManageCall {
|
|
2442
|
+
proofs: string[];
|
|
2443
|
+
manageCall: ManageCall;
|
|
2444
|
+
step: UNIVERSAL_MANAGE_IDS;
|
|
2445
|
+
}
|
|
2446
|
+
interface UniversalStrategySettings {
|
|
2447
|
+
vaultAddress: ContractAddr;
|
|
2448
|
+
manager: ContractAddr;
|
|
2449
|
+
vaultAllocator: ContractAddr;
|
|
2450
|
+
redeemRequestNFT: ContractAddr;
|
|
2451
|
+
aumOracle: ContractAddr;
|
|
2452
|
+
redemptionRouter?: ContractAddr;
|
|
2453
|
+
leafAdapters: LeafAdapterFn<any>[];
|
|
2454
|
+
adapters: {
|
|
2455
|
+
id: string;
|
|
2456
|
+
adapter: BaseAdapter<DepositParams, WithdrawParams>;
|
|
2457
|
+
}[];
|
|
2941
2458
|
targetHealthFactor: number;
|
|
2942
2459
|
minHealthFactor: number;
|
|
2943
|
-
aumOracle: ContractAddr;
|
|
2944
2460
|
}
|
|
2945
|
-
declare
|
|
2946
|
-
|
|
2461
|
+
declare enum AUMTypes {
|
|
2462
|
+
FINALISED = "finalised",
|
|
2463
|
+
DEFISPRING = "defispring",
|
|
2464
|
+
BTCFI = "btcfi"
|
|
2465
|
+
}
|
|
2466
|
+
declare enum PositionTypeAvnuExtended {
|
|
2467
|
+
OPEN = "open",
|
|
2468
|
+
CLOSE = "close"
|
|
2469
|
+
}
|
|
2470
|
+
declare class UniversalStrategy<S extends UniversalStrategySettings> extends SVKStrategy<S> {
|
|
2947
2471
|
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2472
|
+
getMerkleTree(): StandardMerkleTree;
|
|
2473
|
+
getMerkleRoot(): string;
|
|
2474
|
+
getProofs<T>(id: string): {
|
|
2475
|
+
proofs: string[];
|
|
2476
|
+
callConstructor: GenerateCallFn<T>;
|
|
2477
|
+
};
|
|
2478
|
+
getAdapter(id: string): BaseAdapter<any, any>;
|
|
2479
|
+
asset(): TokenInfo;
|
|
2480
|
+
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
2481
|
+
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
2482
|
+
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<{
|
|
2483
|
+
tokenInfo: TokenInfo;
|
|
2484
|
+
amount: Web3Number;
|
|
2485
|
+
usdValue: number;
|
|
2486
|
+
}>;
|
|
2487
|
+
getVesuAPYs(): Promise<{
|
|
2488
|
+
baseAPYs: number[];
|
|
2489
|
+
rewardAPYs: number[];
|
|
2490
|
+
positions: VaultPosition[];
|
|
2491
|
+
}>;
|
|
2957
2492
|
/**
|
|
2958
|
-
*
|
|
2959
|
-
*
|
|
2960
|
-
* @param params
|
|
2493
|
+
* Calculates the weighted average APY across all pools based on USD value.
|
|
2494
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
2961
2495
|
*/
|
|
2962
|
-
getFundManagementCall(params: {
|
|
2963
|
-
isDeposit: boolean;
|
|
2964
|
-
leg1DepositAmount: Web3Number;
|
|
2965
|
-
}): Promise<Call[] | null>;
|
|
2966
|
-
getLSTUnderlyingTokenInfo(): TokenInfo;
|
|
2967
|
-
getLSTAPR(_address: ContractAddr): Promise<number>;
|
|
2968
2496
|
netAPY(): Promise<{
|
|
2969
2497
|
net: number;
|
|
2970
2498
|
splits: {
|
|
@@ -2972,1461 +2500,314 @@ declare class UniversalLstMultiplierStrategy<S extends HyperLSTStrategySettings>
|
|
|
2972
2500
|
id: string;
|
|
2973
2501
|
}[];
|
|
2974
2502
|
}>;
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2503
|
+
protected returnNetAPY(baseAPYs: number[], rewardAPYs: number[], weights: number[], prevAUMUSD: Web3Number): Promise<{
|
|
2504
|
+
net: number;
|
|
2505
|
+
splits: {
|
|
2506
|
+
apy: number;
|
|
2507
|
+
id: string;
|
|
2508
|
+
}[];
|
|
2509
|
+
}>;
|
|
2978
2510
|
protected getUnusedBalanceAPY(): Promise<{
|
|
2979
2511
|
apy: number;
|
|
2980
2512
|
weight: number;
|
|
2981
2513
|
}>;
|
|
2514
|
+
private computeAPY;
|
|
2515
|
+
/**
|
|
2516
|
+
* Calculates user realized APY based on trueSharesBasedAPY method.
|
|
2517
|
+
* Returns the APY as a number.
|
|
2518
|
+
*/
|
|
2519
|
+
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
2520
|
+
getUserPositionCards(input: UserPositionCardsInput): Promise<UserPositionCard[]>;
|
|
2521
|
+
/**
|
|
2522
|
+
* Calculates the total TVL of the strategy.
|
|
2523
|
+
* @returns Object containing the total amount in token units and USD value
|
|
2524
|
+
*/
|
|
2525
|
+
getTVL(): Promise<{
|
|
2526
|
+
tokenInfo: TokenInfo;
|
|
2527
|
+
amount: Web3Number;
|
|
2528
|
+
usdValue: number;
|
|
2529
|
+
}>;
|
|
2530
|
+
getUnusedBalance(): Promise<SingleTokenInfo>;
|
|
2531
|
+
protected getVesuAUM(adapter: VesuAdapter, _priceType?: LSTPriceType): Promise<Web3Number>;
|
|
2532
|
+
getPrevAUM(): Promise<Web3Number>;
|
|
2982
2533
|
getAUM(unrealizedAUM?: boolean): Promise<{
|
|
2983
2534
|
net: SingleTokenInfo;
|
|
2984
2535
|
prevAum: Web3Number;
|
|
2985
|
-
splits:
|
|
2536
|
+
splits: {
|
|
2537
|
+
id: string;
|
|
2538
|
+
aum: Web3Number;
|
|
2539
|
+
}[];
|
|
2986
2540
|
}>;
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
splits: PositionInfo[];
|
|
2991
|
-
}>;
|
|
2992
|
-
getUserUnrealizedGains(user: ContractAddr): Promise<{
|
|
2993
|
-
unrealizedGains: Web3Number;
|
|
2994
|
-
userShare: number;
|
|
2995
|
-
tokenInfo: TokenInfo;
|
|
2996
|
-
}>;
|
|
2997
|
-
}
|
|
2998
|
-
declare const AUDIT_URL = "https://docs.troves.fi/p/security#starknet-vault-kit";
|
|
2999
|
-
declare function getFAQs(lstSymbol: string, underlyingSymbol: string, isLST: boolean): FAQ[];
|
|
3000
|
-
declare const _riskFactor: RiskFactor[];
|
|
3001
|
-
declare function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string): string[];
|
|
3002
|
-
declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
|
|
3003
|
-
|
|
3004
|
-
/**
|
|
3005
|
-
* Snapshot of a single Vesu pool's position: collateral, debt, and their prices.
|
|
3006
|
-
*/
|
|
3007
|
-
interface VesuPoolState {
|
|
3008
|
-
poolId: ContractAddr;
|
|
3009
|
-
collateralToken: TokenInfo;
|
|
3010
|
-
debtToken: TokenInfo;
|
|
3011
|
-
collateralAmount: Web3Number;
|
|
3012
|
-
collateralUsdValue: number;
|
|
3013
|
-
debtAmount: Web3Number;
|
|
3014
|
-
debtUsdValue: number;
|
|
3015
|
-
collateralPrice: number;
|
|
3016
|
-
debtPrice: number;
|
|
3017
|
-
}
|
|
3018
|
-
/**
|
|
3019
|
-
* Snapshot of a single Extended exchange open position.
|
|
3020
|
-
*/
|
|
3021
|
-
interface ExtendedPositionState {
|
|
3022
|
-
instrument: string;
|
|
3023
|
-
side: string;
|
|
3024
|
-
size: Web3Number;
|
|
3025
|
-
valueUsd: Web3Number;
|
|
3026
|
-
leverage: string;
|
|
3027
|
-
}
|
|
3028
|
-
/**
|
|
3029
|
-
* Snapshot of the Extended exchange account-level balance.
|
|
3030
|
-
*/
|
|
3031
|
-
interface ExtendedBalanceState {
|
|
3032
|
-
equity: Web3Number;
|
|
3033
|
-
availableForTrade: Web3Number;
|
|
3034
|
-
availableForWithdrawal: Web3Number;
|
|
3035
|
-
unrealisedPnl: Web3Number;
|
|
3036
|
-
balance: Web3Number;
|
|
3037
|
-
/**
|
|
3038
|
-
* Funds in transit to/from Extended.
|
|
3039
|
-
* Positive = deposit in transit (funds left wallet, not yet credited on Extended).
|
|
3040
|
-
* Negative = withdrawal in transit (funds left Extended, not yet received in wallet).
|
|
3041
|
-
*/
|
|
3042
|
-
pendingDeposit: Web3Number;
|
|
3043
|
-
}
|
|
3044
|
-
/**
|
|
3045
|
-
* Generic token balance with USD valuation.
|
|
3046
|
-
*/
|
|
3047
|
-
interface TokenBalance {
|
|
3048
|
-
token: TokenInfo;
|
|
3049
|
-
amount: Web3Number;
|
|
3050
|
-
usdValue: number;
|
|
3051
|
-
}
|
|
3052
|
-
/**
|
|
3053
|
-
* Per-position exposure change on the Extended exchange.
|
|
3054
|
-
* Positive delta = increase position size, negative = reduce.
|
|
3055
|
-
*/
|
|
3056
|
-
interface ExtendedPositionDelta {
|
|
3057
|
-
instrument: string;
|
|
3058
|
-
delta: Web3Number;
|
|
3059
|
-
}
|
|
3060
|
-
/**
|
|
3061
|
-
* Per-pool position change on Vesu.
|
|
3062
|
-
* debtDelta: positive = borrow more, negative = repay.
|
|
3063
|
-
* collateralDelta: positive = add collateral, negative = remove.
|
|
3064
|
-
*/
|
|
3065
|
-
interface VesuPoolDelta {
|
|
3066
|
-
poolId: ContractAddr;
|
|
3067
|
-
collateralToken: TokenInfo;
|
|
3068
|
-
debtToken: TokenInfo;
|
|
3069
|
-
debtDelta: Web3Number;
|
|
3070
|
-
collateralDelta: Web3Number;
|
|
3071
|
-
collateralPrice: number;
|
|
3072
|
-
debtPrice: number;
|
|
3073
|
-
}
|
|
3074
|
-
/**
|
|
3075
|
-
* Enumerates all possible fund-routing paths used during execution.
|
|
3076
|
-
*/
|
|
3077
|
-
declare enum RouteType {
|
|
3078
|
-
/** Deposit USDC from operator wallet directly to Extended exchange */
|
|
3079
|
-
WALLET_TO_EXTENDED = "WALLET_TO_EXTENDED",
|
|
3080
|
-
/** USDC from vault allocator → deposit to Extended (via manager) */
|
|
3081
|
-
VA_TO_EXTENDED = "VA_TO_EXTENDED",
|
|
3082
|
-
/** Withdraw from Extended exchange → operator wallet */
|
|
3083
|
-
EXTENDED_TO_WALLET = "EXTENDED_TO_WALLET",
|
|
3084
|
-
/** Swap USDC → BTC to deposit to Vesu */
|
|
3085
|
-
AVNU_DEPOSIT_SWAP = "AVNU_DEPOSIT_SWAP",
|
|
3086
|
-
/** Increase leverage on Vesu i.e. deposit on vesu, borrow, in one go to create lever */
|
|
3087
|
-
VESU_MULTIPLY_INCREASE_LEVER = "VESU_MULTIPLY_INCREASE_LEVER",
|
|
3088
|
-
/** Decrease leverage on Vesu i.e. withdraw from vesu, repay, in one go to reduce leverage */
|
|
3089
|
-
VESU_MULTIPLY_DECREASE_LEVER = "VESU_MULTIPLY_DECREASE_LEVER",
|
|
3090
|
-
/** Swap BTC → USDC to withdraw from Vesu */
|
|
3091
|
-
AVNU_WITHDRAW_SWAP = "AVNU_WITHDRAW_SWAP",
|
|
3092
|
-
/** Borrow additional USDC from Vesu (when wallet + VA insufficient for Extended) */
|
|
3093
|
-
VESU_BORROW = "VESU_BORROW",
|
|
3094
|
-
/** Repay USDC debt to Vesu (debtDelta < 0) */
|
|
3095
|
-
VESU_REPAY = "VESU_REPAY",
|
|
3096
|
-
/** Transfer USDC from operator wallet to vault allocator */
|
|
3097
|
-
WALLET_TO_VA = "WALLET_TO_VA",
|
|
3098
|
-
/** Realize PnL on Extended exchange */
|
|
3099
|
-
REALISE_PNL = "REALISE_PNL",
|
|
3100
|
-
/** Increase leverage on Extended exchange i.e. deposit on extended, in one go to create lever */
|
|
3101
|
-
EXTENDED_INCREASE_LEVER = "EXTENDED_INCREASE_LEVER",
|
|
3102
|
-
/** Decrease leverage on Extended exchange i.e. withdraw from extended, in one go to reduce leverage */
|
|
3103
|
-
EXTENDED_DECREASE_LEVER = "EXTENDED_DECREASE_LEVER",
|
|
3104
|
-
/** Increase leverage on Extended exchange to max leverage (e.g. 4x from 3x) */
|
|
3105
|
-
CRISIS_INCREASE_EXTENDED_MAX_LEVERAGE = "CRISIS_INCREASE_EXTENDER_MAX_LEVERAGE",
|
|
3106
|
-
/** Undo max leverage on Extended exchange to reduce leverage (e.g. 4x to 3x) */
|
|
3107
|
-
CRISIS_UNDO_EXTENDED_MAX_LEVERAGE = "CRISIS_UNDO_EXTENDED_MAX_LEVERAGE",
|
|
3108
|
-
/** Borrow beyyond target HF (e.g. 1.2 from 1.4) */
|
|
3109
|
-
CRISIS_BORROW_BEYOND_TARGET_HF = "CRISIS_BORROW_BEYOND_TARGET_HF",
|
|
3110
|
-
/** Bring liquidity from vault allocator to vault contract (for user withdrawals) */
|
|
3111
|
-
BRING_LIQUIDITY = "BRING_LIQUIDITY",
|
|
3112
|
-
RETURN_TO_WAIT = "RETURN_TO_WAIT"
|
|
3113
|
-
}
|
|
3114
|
-
/** Common fields shared by every route variant */
|
|
3115
|
-
interface RouteBase {
|
|
3116
|
-
/** Execution order — lower values execute first */
|
|
3117
|
-
priority: number;
|
|
3118
|
-
}
|
|
3119
|
-
/** Simple fund-transfer routes: WALLET_TO_EXTENDED, VA_TO_EXTENDED, EXTENDED_TO_WALLET, WALLET_TO_VA */
|
|
3120
|
-
interface TransferRoute extends RouteBase {
|
|
3121
|
-
type: RouteType.WALLET_TO_EXTENDED | RouteType.VA_TO_EXTENDED | RouteType.EXTENDED_TO_WALLET | RouteType.WALLET_TO_VA;
|
|
3122
|
-
/** Amount to transfer */
|
|
3123
|
-
amount: Web3Number;
|
|
3124
|
-
}
|
|
3125
|
-
/** AVNU swap routes: AVNU_DEPOSIT_SWAP (USDC→BTC), AVNU_WITHDRAW_SWAP (BTC→USDC) */
|
|
3126
|
-
interface SwapRoute extends RouteBase {
|
|
3127
|
-
type: RouteType.AVNU_DEPOSIT_SWAP | RouteType.AVNU_WITHDRAW_SWAP;
|
|
3128
|
-
/** Source token symbol */
|
|
3129
|
-
fromToken: string;
|
|
3130
|
-
/** Source amount */
|
|
3131
|
-
fromAmount: Web3Number;
|
|
3132
|
-
/** Destination token symbol */
|
|
3133
|
-
toToken: string;
|
|
3134
|
-
/** Exact output amount (if known; otherwise undefined means best-effort) */
|
|
3135
|
-
toAmount?: Web3Number;
|
|
3136
|
-
}
|
|
3137
|
-
/** Vesu multiply lever routes: deposit+borrow or withdraw+repay in one go */
|
|
3138
|
-
interface VesuMultiplyRoute extends RouteBase {
|
|
3139
|
-
type: RouteType.VESU_MULTIPLY_INCREASE_LEVER | RouteType.VESU_MULTIPLY_DECREASE_LEVER;
|
|
3140
|
-
/** Pool to interact with */
|
|
3141
|
-
poolId: ContractAddr;
|
|
3142
|
-
/** Collateral token info */
|
|
3143
|
-
collateralToken: TokenInfo;
|
|
3144
|
-
/** Collateral amount delta (positive = deposit, negative = withdraw) */
|
|
3145
|
-
marginAmount: Web3Number;
|
|
3146
|
-
swappedCollateralAmount: Web3Number;
|
|
3147
|
-
/** Debt token info */
|
|
3148
|
-
debtToken: TokenInfo;
|
|
3149
|
-
/** Debt amount delta (positive = borrow, negative = repay) */
|
|
3150
|
-
debtAmount: Web3Number;
|
|
3151
|
-
}
|
|
3152
|
-
/** Vesu single-side borrow / repay routes */
|
|
3153
|
-
interface VesuDebtRoute extends RouteBase {
|
|
3154
|
-
type: RouteType.VESU_BORROW | RouteType.VESU_REPAY;
|
|
3155
|
-
/** Pool to interact with */
|
|
3156
|
-
poolId: ContractAddr;
|
|
3157
|
-
/** Amount to borrow (positive) or repay (negative) */
|
|
3158
|
-
amount: Web3Number;
|
|
3159
|
-
/** Collateral token info */
|
|
3160
|
-
collateralToken: TokenInfo;
|
|
3161
|
-
/** Debt token info */
|
|
3162
|
-
debtToken: TokenInfo;
|
|
3163
|
-
}
|
|
3164
|
-
/** Realise PnL on Extended exchange */
|
|
3165
|
-
interface RealisePnlRoute extends RouteBase {
|
|
3166
|
-
type: RouteType.REALISE_PNL;
|
|
3167
|
-
/** Amount of PnL to realise (the shortfall beyond available-to-withdraw) */
|
|
3168
|
-
amount: Web3Number;
|
|
3169
|
-
/** Extended instrument name (e.g. "BTC-USD") */
|
|
3170
|
-
instrument: string;
|
|
3171
|
-
}
|
|
3172
|
-
/** Increase / decrease leverage on Extended exchange */
|
|
3173
|
-
interface ExtendedLeverRoute extends RouteBase {
|
|
3174
|
-
type: RouteType.EXTENDED_INCREASE_LEVER | RouteType.EXTENDED_DECREASE_LEVER;
|
|
3175
|
-
/** Change in exposure denominated in the exposure token */
|
|
3176
|
-
amount: Web3Number;
|
|
3177
|
-
/** Extended instrument name (e.g. "BTC-USD") */
|
|
3178
|
-
instrument: string;
|
|
3179
|
-
}
|
|
3180
|
-
/** Crisis: temporarily increase / undo max leverage on Extended — no args for now */
|
|
3181
|
-
interface CrisisExtendedLeverRoute extends RouteBase {
|
|
3182
|
-
type: RouteType.CRISIS_INCREASE_EXTENDED_MAX_LEVERAGE | RouteType.CRISIS_UNDO_EXTENDED_MAX_LEVERAGE;
|
|
3183
|
-
}
|
|
3184
|
-
/** Crisis: borrow beyond the normal target HF */
|
|
3185
|
-
interface CrisisBorrowRoute extends RouteBase {
|
|
3186
|
-
type: RouteType.CRISIS_BORROW_BEYOND_TARGET_HF;
|
|
3187
|
-
/** Pool to borrow from */
|
|
3188
|
-
poolId: ContractAddr;
|
|
3189
|
-
/** Token being borrowed */
|
|
3190
|
-
token: string;
|
|
3191
|
-
/** Amount to borrow */
|
|
3192
|
-
amount: Web3Number;
|
|
3193
|
-
}
|
|
3194
|
-
/** Bring liquidity from vault allocator to vault contract for user withdrawals */
|
|
3195
|
-
interface BringLiquidityRoute extends RouteBase {
|
|
3196
|
-
type: RouteType.BRING_LIQUIDITY;
|
|
3197
|
-
/** Amount to bring */
|
|
3198
|
-
amount: Web3Number;
|
|
3199
|
-
}
|
|
3200
|
-
/** Control routes: RETURN_TO_WAIT (stop execution, resume in next cycle) */
|
|
3201
|
-
interface WaitRoute extends RouteBase {
|
|
3202
|
-
type: RouteType.RETURN_TO_WAIT;
|
|
3203
|
-
}
|
|
3204
|
-
/**
|
|
3205
|
-
* A single step in the execution plan produced by the solver.
|
|
3206
|
-
* Discriminated union keyed on `type` — each variant carries only
|
|
3207
|
-
* the metadata that specific route needs.
|
|
3208
|
-
*/
|
|
3209
|
-
type ExecutionRoute = TransferRoute | SwapRoute | VesuMultiplyRoute | VesuDebtRoute | RealisePnlRoute | ExtendedLeverRoute | CrisisExtendedLeverRoute | CrisisBorrowRoute | BringLiquidityRoute | WaitRoute;
|
|
3210
|
-
/**
|
|
3211
|
-
* Broad category of a detected case. Multiple categories may apply simultaneously.
|
|
3212
|
-
*/
|
|
3213
|
-
declare enum CaseCategory {
|
|
3214
|
-
LTV_REBALANCE = "LTV_REBALANCE",
|
|
3215
|
-
NEW_DEPOSITS = "NEW_DEPOSITS",
|
|
3216
|
-
WITHDRAWAL = "WITHDRAWAL",
|
|
3217
|
-
EXPOSURE_IMBALANCE = "EXPOSURE_IMBALANCE",
|
|
3218
|
-
MARGIN_CRISIS = "MARGIN_CRISIS"
|
|
3219
|
-
}
|
|
3220
|
-
/**
|
|
3221
|
-
* Specific case IDs corresponding to the situations defined in cases.json.
|
|
3222
|
-
*/
|
|
3223
|
-
declare enum CaseId {
|
|
3224
|
-
MANAGE_LTV = "MANAGE_LTV",
|
|
3225
|
-
/** @deprecated use MANAGE_LTV */ LTV_VESU_LOW_TO_EXTENDED = "LTV_VESU_LOW_TO_EXTENDED",
|
|
3226
|
-
/** @deprecated use MANAGE_LTV */ LTV_EXTENDED_PROFITABLE_AVAILABLE = "LTV_EXTENDED_PROFITABLE_AVAILABLE",
|
|
3227
|
-
/** @deprecated use MANAGE_LTV */ LTV_EXTENDED_PROFITABLE_REALIZE = "LTV_EXTENDED_PROFITABLE_REALIZE",
|
|
3228
|
-
/** @deprecated use MANAGE_LTV */ LTV_VESU_HIGH_USE_VA_OR_WALLET = "LTV_VESU_HIGH_USE_VA_OR_WALLET",
|
|
3229
|
-
/** @deprecated use MANAGE_LTV */ LTV_EXTENDED_HIGH_USE_VA_OR_WALLET = "LTV_EXTENDED_HIGH_USE_VA_OR_WALLET",
|
|
3230
|
-
DEPOSIT_FRESH_VAULT = "DEPOSIT_FRESH_VAULT",
|
|
3231
|
-
DEPOSIT_EXTENDED_AVAILABLE = "DEPOSIT_EXTENDED_AVAILABLE",
|
|
3232
|
-
DEPOSIT_VESU_BORROW_CAPACITY = "DEPOSIT_VESU_BORROW_CAPACITY",
|
|
3233
|
-
DEPOSIT_COMBINATION = "DEPOSIT_COMBINATION",
|
|
3234
|
-
WITHDRAWAL_SIMPLE = "WITHDRAWAL_SIMPLE",
|
|
3235
|
-
MARGIN_CRISIS_EXTENDED = "MARGIN_CRISIS_EXTENDED",
|
|
3236
|
-
MARGIN_CRISIS_VESU = "MARGIN_CRISIS_VESU",
|
|
3237
|
-
IMBALANCE_EXTENDED_EXCESS_SHORT_NO_FUNDS = "IMBALANCE_EXTENDED_EXCESS_SHORT_NO_FUNDS",
|
|
3238
|
-
IMBALANCE_EXTENDED_EXCESS_SHORT_HAS_FUNDS = "IMBALANCE_EXTENDED_EXCESS_SHORT_HAS_FUNDS",
|
|
3239
|
-
IMBALANCE_VESU_EXCESS_LONG_NO_FUNDS = "IMBALANCE_VESU_EXCESS_LONG_NO_FUNDS",
|
|
3240
|
-
IMBALANCE_VESU_EXCESS_LONG_HAS_FUNDS = "IMBALANCE_VESU_EXCESS_LONG_HAS_FUNDS"
|
|
3241
|
-
}
|
|
3242
|
-
/**
|
|
3243
|
-
* A detected case describing the current system state and the
|
|
3244
|
-
* high-level steps required to resolve it.
|
|
3245
|
-
*/
|
|
3246
|
-
interface SolveCase {
|
|
3247
|
-
id: CaseId;
|
|
3248
|
-
category: CaseCategory;
|
|
3249
|
-
title: string;
|
|
3250
|
-
description: string;
|
|
3251
|
-
/** High-level steps describing what needs to happen for this case */
|
|
3252
|
-
steps: string[];
|
|
3253
|
-
}
|
|
3254
|
-
/** Decimal places for rounding collateral / exposure deltas in token terms (e.g. BTC) */
|
|
3255
|
-
declare const COLLATERAL_PRECISION = 4;
|
|
3256
|
-
/**
|
|
3257
|
-
* A single detected case with its metadata, amounts, and the execution
|
|
3258
|
-
* routes that belong to this case.
|
|
3259
|
-
*/
|
|
3260
|
-
interface SolveCaseEntry {
|
|
3261
|
-
case: SolveCase;
|
|
3262
|
-
additionalArgs: {
|
|
3263
|
-
amount?: Web3Number;
|
|
3264
|
-
};
|
|
3265
|
-
routes: ExecutionRoute[];
|
|
3266
|
-
}
|
|
3267
|
-
/**
|
|
3268
|
-
* Maps each CaseId to the RouteTypes that are relevant for resolving it.
|
|
3269
|
-
* Used to filter the global route list into per-case route subsets.
|
|
3270
|
-
*/
|
|
3271
|
-
declare const CASE_ROUTE_TYPES: Record<CaseId, RouteType[]>;
|
|
3272
|
-
/**
|
|
3273
|
-
* Complete output from the solver describing all needed state changes.
|
|
3274
|
-
*
|
|
3275
|
-
* - cases: detected cases describing the system state and needed actions.
|
|
3276
|
-
* - extendedDeposit: positive = deposit USDC into Extended, negative = withdraw.
|
|
3277
|
-
* - extendedPositionDeltas: per-instrument exposure changes (with instrument id).
|
|
3278
|
-
* - vesuDeltas: per-pool debt & collateral changes (with pool id and token pair).
|
|
3279
|
-
* - vesuAllocationUsd: USDC directed to Vesu side (negative = unwind from Vesu).
|
|
3280
|
-
* - extendedAllocationUsd: USDC directed to Extended side (negative = withdraw from Extended).
|
|
3281
|
-
* - bringLiquidityAmount: amount VA should send via bringLiquidity to the vault
|
|
3282
|
-
* (= withdrawAmount input; 0 during investment cycles).
|
|
3283
|
-
*/
|
|
3284
|
-
interface SolveResult {
|
|
3285
|
-
/** Detected cases describing the current situation, amounts, and per-case routes */
|
|
3286
|
-
cases: SolveCaseEntry[];
|
|
3287
|
-
extendedDeposit: Web3Number;
|
|
3288
|
-
extendedPositionDeltas: ExtendedPositionDelta[];
|
|
3289
|
-
vesuDepositAmount: Web3Number;
|
|
3290
|
-
vesuDeltas: VesuPoolDelta[];
|
|
3291
|
-
vesuAllocationUsd: Web3Number;
|
|
3292
|
-
extendedAllocationUsd: Web3Number;
|
|
3293
|
-
bringLiquidityAmount: Web3Number;
|
|
3294
|
-
/**
|
|
3295
|
-
* Net pending deposit for Extended.
|
|
3296
|
-
* Positive = deposit in transit (wallet → Extended), negative = withdrawal in transit.
|
|
3297
|
-
* Used by ExecutionService to avoid double-sending transfers.
|
|
3298
|
-
*/
|
|
3299
|
-
pendingDeposit: Web3Number;
|
|
3300
|
-
}
|
|
3301
|
-
interface StateManagerConfig {
|
|
3302
|
-
pricer: PricerBase;
|
|
3303
|
-
networkConfig: IConfig;
|
|
3304
|
-
vesuAdapters: VesuMultiplyAdapter[];
|
|
3305
|
-
extendedAdapter: ExtendedAdapter;
|
|
3306
|
-
vaultAllocator: ContractAddr;
|
|
3307
|
-
walletAddress: string;
|
|
3308
|
-
/** Strategy / vault token — idle balance in the vault allocator is denominated in this asset */
|
|
3309
|
-
assetToken: TokenInfo;
|
|
3310
|
-
/**
|
|
3311
|
-
* Native USDC (Starknet) — operator wallet stablecoin balance is always read for this token,
|
|
3312
|
-
* independent of {@link assetToken} (e.g. when the strategy vault uses another asset).
|
|
3313
|
-
*/
|
|
3314
|
-
usdcToken: TokenInfo;
|
|
3315
|
-
/** Collateral token (e.g. WBTC) for wallet balance checks */
|
|
3316
|
-
collateralToken: TokenInfo;
|
|
3317
|
-
limitBalanceBufferFactor: number;
|
|
3318
|
-
}
|
|
3319
|
-
/**
|
|
3320
|
-
* Returns a short human-readable summary of a route's key fields for logging.
|
|
3321
|
-
*/
|
|
3322
|
-
declare function routeSummary(r: ExecutionRoute): string;
|
|
3323
|
-
/**
|
|
3324
|
-
* Single source of truth for all mutable state during a solve() call.
|
|
3325
|
-
*
|
|
3326
|
-
* Stores **raw** snapshots from refresh (no safety buffer applied in fields).
|
|
3327
|
-
* Buffer {@link limitBalanceBufferFactor} is applied only in **getters** used
|
|
3328
|
-
* during solve (caps, diagnostics). **Spend / add** methods mutate balances
|
|
3329
|
-
* in **raw** USD only (no buffer on debits or credits).
|
|
3330
|
-
*
|
|
3331
|
-
* **Extended deposits** ({@link SolveBudget.addToExtAvailTrade}): while account equity is
|
|
3332
|
-
* below required margin (Σ position value ÷ Extended leverage), incoming USDC is credited
|
|
3333
|
-
* only to **balance** and **equity**. Only the excess is credited to **availableForWithdrawal**
|
|
3334
|
-
* and **availableForTrade**, matching “margin first, then free collateral”.
|
|
3335
|
-
*/
|
|
3336
|
-
declare class SolveBudget {
|
|
3337
|
-
private unusedBalance;
|
|
3338
|
-
private walletBalance;
|
|
3339
|
-
/**
|
|
3340
|
-
* Idle non-stable {@link StateManagerConfig.assetToken} in the vault allocator.
|
|
3341
|
-
* Null when asset and USDC are the same token (VA idle stablecoin is only in {@link vaultUsdcBalance}).
|
|
3342
|
-
*/
|
|
3343
|
-
private vaultAssetBalance;
|
|
3344
|
-
/** Idle {@link StateManagerConfig.usdcToken} in the vault allocator (including when it is also the strategy asset). */
|
|
3345
|
-
private vaultUsdcBalance;
|
|
3346
|
-
private extendedPositions;
|
|
3347
|
-
private extendedBalance;
|
|
3348
|
-
private vesuPoolStates;
|
|
3349
|
-
private vesuPerPoolDebtDeltasToBorrow;
|
|
3350
|
-
private shouldVesuRebalance;
|
|
3351
|
-
readonly assetToken: TokenInfo;
|
|
3352
|
-
readonly usdcToken: TokenInfo;
|
|
3353
|
-
constructor(state: {
|
|
3354
|
-
assetToken: TokenInfo;
|
|
3355
|
-
usdcToken: TokenInfo;
|
|
3356
|
-
unusedBalance: TokenBalance[];
|
|
3357
|
-
walletBalance: TokenBalance | null;
|
|
3358
|
-
vaultAssetBalance: TokenBalance | null;
|
|
3359
|
-
vaultUsdcBalance: TokenBalance | null;
|
|
3360
|
-
extendedPositions: ExtendedPositionState[];
|
|
3361
|
-
extendedBalance: ExtendedBalanceState | null;
|
|
3362
|
-
vesuPoolStates: VesuPoolState[];
|
|
3363
|
-
});
|
|
3364
|
-
/** `1 - limitBalanceBufferFactor` — multiplier applied to raw notionals for “usable” USD. */
|
|
3365
|
-
private _usableFraction;
|
|
3366
|
-
/**
|
|
3367
|
-
* Raw USD notional for a token row. USDC (and configured {@link usdcToken}) uses 1:1 from amount;
|
|
3368
|
-
* non-stable assets (e.g. WBTC in VA) use {@link TokenBalance.usdValue} from the pricer at refresh.
|
|
3369
|
-
*/
|
|
3370
|
-
private _rawTokenUsd;
|
|
3371
|
-
/** Apply safety buffer to a raw USD scalar. */
|
|
3372
|
-
bufferedUsd(rawUsd: number): number;
|
|
3373
|
-
/** Convert a buffered “usable” USD amount to raw nominal USD (inverse of {@link bufferedUsd}). */
|
|
3374
|
-
rawUsdFromBuffered(bufferedUsd: number): number;
|
|
3375
|
-
/** Buffered USD notional for one token balance row. */
|
|
3376
|
-
bufferedTokenUsd(tb: TokenBalance | null | undefined): number;
|
|
3377
|
-
logStateSummary(): {
|
|
3378
|
-
unusedBalances: {
|
|
3379
|
-
token: string;
|
|
3380
|
-
amount: number;
|
|
3381
|
-
}[];
|
|
3382
|
-
walletBalance: {
|
|
3383
|
-
token: string;
|
|
3384
|
-
amount: number;
|
|
3385
|
-
} | undefined;
|
|
3386
|
-
vaultAssetBalance: {
|
|
3387
|
-
token: string;
|
|
3388
|
-
amount: number;
|
|
3389
|
-
} | undefined;
|
|
3390
|
-
vaultUsdcBalance: {
|
|
3391
|
-
token: string;
|
|
3392
|
-
amount: number;
|
|
3393
|
-
} | undefined;
|
|
3394
|
-
vesuPoolStates: {
|
|
3395
|
-
poolId: ContractAddr;
|
|
3396
|
-
collateralAmount: number;
|
|
3397
|
-
debtAmount: number;
|
|
3398
|
-
}[];
|
|
3399
|
-
vesuBorrowCapacity: number;
|
|
3400
|
-
vesuRebalance: boolean[];
|
|
3401
|
-
vesuPerPoolDebtDeltasToBorrow: number[];
|
|
3402
|
-
extendedBalance: number | undefined;
|
|
3403
|
-
extendedEquity: number | undefined;
|
|
3404
|
-
extendedAvailableForTrade: number | undefined;
|
|
3405
|
-
extendedAvailableForWithdrawal: number | undefined;
|
|
3406
|
-
extendedUnrealisedPnl: number | undefined;
|
|
3407
|
-
extendedPendingDeposit: number | undefined;
|
|
3408
|
-
extendedPositions: {
|
|
3409
|
-
instrument: string;
|
|
3410
|
-
size: number;
|
|
3411
|
-
valueUsd: number;
|
|
3412
|
-
}[];
|
|
3413
|
-
};
|
|
3414
|
-
/**
|
|
3415
|
-
* Initialise derived views for a solve cycle. Mutates only when pending
|
|
3416
|
-
* withdrawal from Extended is in transit (credits wallet raw balance).
|
|
3417
|
-
*/
|
|
3418
|
-
initBudget(): void;
|
|
3419
|
-
/**
|
|
3420
|
-
* Apply a safety buffer to all liquid balances (VA, wallet, extended trade/withdraw/upnl,
|
|
3421
|
-
* unused balances). Call after withdrawal classification but before LTV/deposit classifiers
|
|
3422
|
-
* so that withdrawal uses full raw amounts while subsequent classifiers see buffered values.
|
|
3423
|
-
*/
|
|
3424
|
-
applyBuffer(factor: number): void;
|
|
3425
|
-
get vesuPoolState(): VesuPoolState;
|
|
3426
|
-
/** Buffered VA USD: non-stable asset slot (if any) + USDC slot. */
|
|
3427
|
-
get vaUsd(): number;
|
|
3428
|
-
/** Buffered USD in VA strategy-asset bucket only. */
|
|
3429
|
-
get vaAssetUsd(): number;
|
|
3430
|
-
/** Buffered USD in VA USDC bucket (includes full VA idle when asset === USDC). */
|
|
3431
|
-
get vaUsdcUsd(): number;
|
|
3432
|
-
get walletUsd(): number;
|
|
3433
|
-
get vaWalletUsd(): number;
|
|
3434
|
-
get extAvailWithdraw(): number;
|
|
3435
|
-
get extAvailUpnl(): number;
|
|
3436
|
-
/**
|
|
3437
|
-
* Buffered Extended available-for-trade plus positive {@link ExtendedBalanceState.pendingDeposit}
|
|
3438
|
-
* (deposit in transit is usable the same way as the pre-buffer implementation).
|
|
3439
|
-
*/
|
|
3440
|
-
get extAvailTrade(): number;
|
|
3441
|
-
get extPendingDeposit(): number;
|
|
3442
|
-
/**
|
|
3443
|
-
* Aggregate positive per-pool borrow headroom (USD). Repay/borrow routes update
|
|
3444
|
-
* {@link vesuPerPoolDebtDeltasToBorrow}; no separate counter.
|
|
3445
|
-
*/
|
|
3446
|
-
get vesuBorrowCapacity(): number;
|
|
3447
|
-
/** Diagnostic: buffered idle + positive debt delta + buffered Extended afT + in-flight deposit. */
|
|
3448
|
-
get totalUnused(): number;
|
|
3449
|
-
/** Sum of buffered USD across merged unused-balance rows (VA + wallet). */
|
|
3450
|
-
get unusedBalancesBufferedUsdSum(): number;
|
|
3451
|
-
/** Read-only snapshot view for validation / logging. */
|
|
3452
|
-
get unusedBalanceRows(): readonly TokenBalance[];
|
|
3453
|
-
/** Read-only Vesu pool view for solve computations. */
|
|
3454
|
-
get vesuPools(): readonly VesuPoolState[];
|
|
3455
|
-
/** Read-only Extended positions view for solve computations. */
|
|
3456
|
-
get extendedPositionsView(): readonly ExtendedPositionState[];
|
|
3457
|
-
/** Read-only Extended balance view for diagnostics / margin checks. */
|
|
3458
|
-
get extendedBalanceView(): ExtendedBalanceState | null;
|
|
3459
|
-
/** Current debt deltas per pool (positive=borrow, negative=repay). */
|
|
3460
|
-
get vesuDebtDeltas(): readonly Web3Number[];
|
|
3461
|
-
/** Per-pool rebalance flags derived from target HF checks. */
|
|
3462
|
-
get vesuRebalanceFlags(): readonly boolean[];
|
|
3463
|
-
/** Raw USD in VA (USDC slot + non-stable asset slot when distinct); spend caps when executing transfers. */
|
|
3464
|
-
private _vaRawUsd;
|
|
3465
|
-
/** VA liquidity usable for repay / {@link spendVaRawUsd} (matches nominal balances after any {@link applyBuffer} scaling). */
|
|
3466
|
-
get vaRawUsd(): number;
|
|
3467
|
-
private _walletRawUsd;
|
|
3468
|
-
/** Remove up to `usd` notional from a token balance, scaling token amount proportionally. */
|
|
3469
|
-
private _deductUsdFromTokenBalance;
|
|
3470
|
-
/** Add USD notional; infers price from current amount/usd when possible, else 1:1. */
|
|
3471
|
-
private _addUsdToTokenBalance;
|
|
3472
|
-
/**
|
|
3473
|
-
* Rebuilds {@link unusedBalance} from vault + wallet snapshots (same merge as refresh).
|
|
3474
|
-
*/
|
|
3475
|
-
private _recomputeUnusedBalance;
|
|
3476
|
-
/**
|
|
3477
|
-
* Spend VA **raw** USD (up to {@link vaRawUsd}). Prefer {@link vaultUsdcBalance} when present, then {@link vaultAssetBalance}.
|
|
3478
|
-
*/
|
|
3479
|
-
spendVA(rawDesired: number): number;
|
|
3480
|
-
/**
|
|
3481
|
-
* Spend nominal/raw USD from VA (e.g. Vesu repay, on-chain USDC). Does not apply the safety buffer to the cap.
|
|
3482
|
-
*/
|
|
3483
|
-
spendVaRawUsd(rawUsdDesired: number): number;
|
|
3484
|
-
/**
|
|
3485
|
-
* Add **raw nominal USD** to VA (borrow proceeds, wallet→VA in raw USDC, etc.).
|
|
3486
|
-
*/
|
|
3487
|
-
addToVA(rawUsd: number): void;
|
|
3488
|
-
spendWallet(rawDesired: number): number;
|
|
3489
|
-
/** Add **raw nominal USD** to the operator wallet balance (e.g. Extended→wallet withdrawal). */
|
|
3490
|
-
addToWallet(rawUsd: number): void;
|
|
3491
|
-
spendVAWallet(rawDesired: number): number;
|
|
3492
|
-
private _updateExtAvailWithdraw;
|
|
3493
|
-
private _updateExtAvailUpnl;
|
|
3494
|
-
spendExtAvailTrade(rawDesired: number): number;
|
|
3495
|
-
spendExtAvailTradeToEquityOnly(rawDesired: number): number;
|
|
3496
|
-
spendExtAvailWithdraw(rawDesired: number): number;
|
|
3497
|
-
spendExtAvailUpnl(rawDesired: number): number;
|
|
3498
|
-
/**
|
|
3499
|
-
* Withdraw from Extended **withdrawal bucket only** to operator wallet (planning).
|
|
3500
|
-
* Used when VA must be funded from Extended and withdraw should be exhausted before unrealised PnL.
|
|
3501
|
-
*/
|
|
3502
|
-
spendAvailWithdrawToWallet(rawDesired: number): number;
|
|
3503
|
-
/**
|
|
3504
|
-
* Required Extended equity (USD) for current open positions: total notional ÷ strategy leverage.
|
|
3505
|
-
* Same basis as {@link ExtendedSVKVesuStateManager._classifyLtvExtended} margin check.
|
|
3506
|
-
*/
|
|
3507
|
-
private _extendedMarginRequirementUsd;
|
|
3508
|
-
/** How much more equity is needed before deposits should increase withdraw / trade availability. */
|
|
3509
|
-
private _extendedEquityShortfallUsd;
|
|
3510
|
-
/**
|
|
3511
|
-
* Credits a USDC inflow on Extended. Fills margin shortfall (balance+equity only) first;
|
|
3512
|
-
* any remainder is credited across balance, equity, availableForWithdrawal, and availableForTrade.
|
|
3513
|
-
*/
|
|
3514
|
-
addToExtAvailTrade(rawUsd: number): void;
|
|
3515
|
-
spendVesuBorrowCapacity(desired: number): {
|
|
3516
|
-
used: number;
|
|
3517
|
-
spendsByPool: Omit<VesuDebtRoute, 'priority' | 'type'>[];
|
|
3518
|
-
};
|
|
3519
|
-
repayVesuBorrowCapacity(desired: number): {
|
|
3520
|
-
used: number;
|
|
3521
|
-
spendsByPool: Omit<VesuDebtRoute, 'priority' | 'type'>[];
|
|
3522
|
-
};
|
|
3523
|
-
/** Update a Vesu pool's collateral and debt after a lever / borrow / repay route. */
|
|
3524
|
-
applyVesuDelta(poolId: ContractAddr, collToken: TokenInfo, debtToken: TokenInfo, collDelta: Web3Number, debtDelta: Web3Number): void;
|
|
3525
|
-
/**
|
|
3526
|
-
* Update Extended position size after a lever route; sync {@link ExtendedPositionState.valueUsd}
|
|
3527
|
-
* and margin buckets (released USD on decrease, locked USD on increase).
|
|
3528
|
-
*
|
|
3529
|
-
* @param collateralPriceUsd BTC collateral price for notional / margin math; if omitted, uses
|
|
3530
|
-
* existing valueUsd / |size| or the first Vesu pool collateral price.
|
|
3531
|
-
*/
|
|
3532
|
-
applyExtendedExposureDelta(instrument: string, sizeDelta: Web3Number, collateralPriceUsd?: number): void;
|
|
3533
|
-
/** Pull margin for larger Extended exposure from liquid buckets, then balance/equity. */
|
|
3534
|
-
private _lockExtendedMarginUsd;
|
|
3535
|
-
/**
|
|
3536
|
-
* For each Vesu pool, computes the debt delta needed to bring the position
|
|
3537
|
-
* back to the target health factor.
|
|
3538
|
-
*
|
|
3539
|
-
* Positive = can borrow more, negative = need to repay.
|
|
3540
|
-
*/
|
|
3541
|
-
private _computeperPoolDebtDeltasToBorrow;
|
|
3542
|
-
}
|
|
3543
|
-
declare function createSolveBudgetFromRawState(params: {
|
|
3544
|
-
assetToken: TokenInfo;
|
|
3545
|
-
usdcToken: TokenInfo;
|
|
3546
|
-
unusedBalance: TokenBalance[];
|
|
3547
|
-
walletBalance: TokenBalance | null;
|
|
3548
|
-
vaultAssetBalance: TokenBalance | null;
|
|
3549
|
-
vaultUsdcBalance: TokenBalance | null;
|
|
3550
|
-
extendedPositions: ExtendedPositionState[];
|
|
3551
|
-
extendedBalance: ExtendedBalanceState | null;
|
|
3552
|
-
vesuPoolStates: VesuPoolState[];
|
|
3553
|
-
limitBalanceBufferFactor?: number;
|
|
3554
|
-
}): SolveBudget;
|
|
3555
|
-
/**
|
|
3556
|
-
* Reads all on-chain / off-chain state for the Extended + SVK + Vesu strategy,
|
|
3557
|
-
* then solves for the optimal rebalancing deltas.
|
|
3558
|
-
*
|
|
3559
|
-
* Usage:
|
|
3560
|
-
* const manager = new ExtendedSVKVesuStateManager(config);
|
|
3561
|
-
* const result = await manager.solve();
|
|
3562
|
-
*/
|
|
3563
|
-
declare class ExtendedSVKVesuStateManager {
|
|
3564
|
-
private readonly _config;
|
|
3565
|
-
private readonly _tag;
|
|
3566
|
-
/** Single mutable state holder — initialised by _refresh(), budget by initBudget(). */
|
|
3567
|
-
private _budget;
|
|
3568
|
-
constructor(config: StateManagerConfig);
|
|
3569
|
-
/**
|
|
3570
|
-
* Main entry point. Refreshes all state, then computes and returns
|
|
3571
|
-
* the optimal deltas for rebalancing the strategy.
|
|
3572
|
-
*
|
|
3573
|
-
* @param withdrawAmount — amount (in vault asset, e.g. USDC) the user wants
|
|
3574
|
-
* to withdraw. When > 0 the solver shrinks protocol allocations so that the
|
|
3575
|
-
* vault allocator ends up with enough balance to execute bringLiquidity.
|
|
3576
|
-
* Pass 0 (default) for normal investment / rebalancing cycles.
|
|
3577
|
-
*/
|
|
3578
|
-
solve(withdrawAmount?: Web3Number): Promise<SolveResult | null>;
|
|
3579
|
-
/**
|
|
3580
|
-
* Reads all on-chain and off-chain state in parallel and stores
|
|
3581
|
-
* results in private instance variables.
|
|
3582
|
-
*/
|
|
3583
|
-
private _refresh;
|
|
3584
|
-
/** True when strategy asset and USDC share one token — VA idle balance is tracked as USDC, not as asset. */
|
|
3585
|
-
private _vaultAssetAndUsdcAreSameToken;
|
|
3586
|
-
/**
|
|
3587
|
-
* Reads idle {@link StateManagerConfig.assetToken} in the vault allocator when it differs from USDC.
|
|
3588
|
-
* When asset and USDC are the same token, returns null (that balance is reported via {@link _fetchVaultAllocatorUsdcBalanceIfDistinct} only).
|
|
3589
|
-
*/
|
|
3590
|
-
private _fetchVaultAllocatorAssetBalance;
|
|
3591
|
-
/**
|
|
3592
|
-
* Reads {@link StateManagerConfig.usdcToken} idle in the vault allocator (always — distinct asset or USDC-as-asset).
|
|
3593
|
-
*/
|
|
3594
|
-
private _fetchVaultAllocatorUsdcBalanceIfDistinct;
|
|
3595
|
-
/**
|
|
3596
|
-
* Merges vault-allocator asset (if any), vault-allocator USDC, and operator wallet
|
|
3597
|
-
* balances into entries keyed by token address.
|
|
3598
|
-
*/
|
|
3599
|
-
private _computeUnusedBalances;
|
|
3600
|
-
/**
|
|
3601
|
-
* Reads the operator wallet balance for {@link StateManagerConfig.usdcToken} only
|
|
3602
|
-
* (wallet stablecoin is always USDC, regardless of strategy {@link StateManagerConfig.assetToken}).
|
|
3603
|
-
*/
|
|
3604
|
-
private _fetchWalletBalances;
|
|
3605
|
-
/**
|
|
3606
|
-
* Reads the Extended exchange account-level balance (equity, available for
|
|
3607
|
-
* trade/withdrawal, etc.). Returns null if the API call fails.
|
|
3608
|
-
*/
|
|
3609
|
-
private _fetchExtendedBalance;
|
|
3610
|
-
/**
|
|
3611
|
-
* Computes the net pending deposit by subtracting pending withdrawals from
|
|
3612
|
-
* pending deposits. Uses the Extended exchange asset operations API.
|
|
3613
|
-
*
|
|
3614
|
-
* Positive = deposit in transit (wallet → Extended).
|
|
3615
|
-
* Negative = withdrawal in transit (Extended → wallet).
|
|
3616
|
-
*/
|
|
3617
|
-
private _fetchPendingDeposit;
|
|
3618
|
-
/**
|
|
3619
|
-
* Reads all open positions on the Extended exchange. Each position
|
|
3620
|
-
* includes instrument, side, size, USD value, and leverage.
|
|
3621
|
-
*/
|
|
3622
|
-
private _fetchExtendedPositions;
|
|
3623
|
-
/**
|
|
3624
|
-
* Reads a single Vesu pool's position data: collateral amount/price,
|
|
3625
|
-
* debt amount/price.
|
|
3626
|
-
*/
|
|
3627
|
-
private _fetchSingleVesuPoolState;
|
|
3628
|
-
/**
|
|
3629
|
-
* Reads all Vesu pool states in parallel (one per configured adapter).
|
|
3630
|
-
*/
|
|
3631
|
-
private _fetchAllVesuPoolStates;
|
|
3632
|
-
/**
|
|
3633
|
-
* Validates that all critical refreshed state is present and contains
|
|
3634
|
-
* finite, sensible values. Throws on invalid state.
|
|
3635
|
-
*/
|
|
3636
|
-
private _validateRefreshedState;
|
|
3637
|
-
private _validateTokenBalanceOrThrow;
|
|
3638
|
-
private _validateVesuPoolPricesOrThrow;
|
|
3639
|
-
private _validateExtendedBalanceOrThrow;
|
|
3640
|
-
private _assertPositiveFinite;
|
|
3641
|
-
/**
|
|
3642
|
-
* Computes total distributable capital by combining idle vault balance
|
|
3643
|
-
* and Extended available balance, then adjusting for aggregate debt
|
|
3644
|
-
* delta and any pending withdrawal.
|
|
3645
|
-
*
|
|
3646
|
-
* When withdrawAmount > 0 the distributable pool shrinks, forcing the
|
|
3647
|
-
* allocation split to produce smaller (or negative) allocations — which
|
|
3648
|
-
* in turn causes protocol positions to unwind and free capital for the
|
|
3649
|
-
* vault allocator to execute bringLiquidity.
|
|
3650
|
-
*/
|
|
3651
|
-
private _computeDistributableAmount;
|
|
3652
|
-
/**
|
|
3653
|
-
* Total investable = vault allocator balance + Extended available-for-trade +
|
|
3654
|
-
* buffered unrealised PnL, matching `deposit_cases_extended_vesu.xlsx`:
|
|
3655
|
-
* `(VA + wallet + EXT_WITH_AVL + EXT_UPNL) * (1 − buffer)`.
|
|
3656
|
-
* Positive {@link ExtendedBalanceState.pendingDeposit} stays on the afT leg only (see {@link SolveBudget.extAvailTrade}).
|
|
3657
|
-
*/
|
|
3658
|
-
private _computeTotalInvestableAmount;
|
|
3659
|
-
private _sumDebtDeltas;
|
|
3660
|
-
/**
|
|
3661
|
-
* Splits distributable capital between Vesu and Extended using leverage
|
|
3662
|
-
* ratios and existing exposure to match delta-neutral targets.
|
|
3663
|
-
*
|
|
3664
|
-
* Formula (from existing strategy):
|
|
3665
|
-
* ExtendedAlloc = (vL * distributable + vesuExposure - extendedExposure) / (vL + eL)
|
|
3666
|
-
* VesuAlloc = distributable - ExtendedAlloc
|
|
3667
|
-
*/
|
|
3668
|
-
private _computeAllocationSplit;
|
|
3669
|
-
private _hasNoVesuAdapters;
|
|
3670
|
-
/**
|
|
3671
|
-
* Distributes the total Vesu USD allocation across pools proportionally
|
|
3672
|
-
* by existing collateral value, then converts each share to collateral
|
|
3673
|
-
* token units.
|
|
3674
|
-
*/
|
|
3675
|
-
private _computePerPoolCollateralDeltas;
|
|
3676
|
-
/**
|
|
3677
|
-
* Determines how much of the total Vesu allocation goes to a single pool.
|
|
3678
|
-
* Single-pool or zero-total cases get the entire allocation.
|
|
3679
|
-
* Multi-pool cases split proportionally by current collateral USD value.
|
|
3680
|
-
*/
|
|
3681
|
-
private _computePoolCollateralShare;
|
|
3682
|
-
/**
|
|
3683
|
-
* Computes per-position exposure deltas for delta neutrality.
|
|
3684
|
-
* Target: total Extended short exposure = total projected Vesu collateral
|
|
3685
|
-
* exposure (current + collateral deltas).
|
|
3686
|
-
*/
|
|
3687
|
-
private _computeExtendedPositionDeltas;
|
|
3688
|
-
/**
|
|
3689
|
-
* Target Extended exposure = sum of (current collateral + collateralDelta)
|
|
3690
|
-
* * price, across all Vesu pools.
|
|
3691
|
-
*/
|
|
3692
|
-
private _computeTargetExtendedExposure;
|
|
3693
|
-
private _hasNoExtendedPositions;
|
|
3694
|
-
/**
|
|
3695
|
-
* Creates a single-element delta array for the default instrument
|
|
3696
|
-
* when no Extended positions currently exist.
|
|
3697
|
-
*/
|
|
3698
|
-
private _singleInstrumentDelta;
|
|
3699
|
-
/**
|
|
3700
|
-
* Distributes a total exposure delta proportionally across existing
|
|
3701
|
-
* positions by their current USD value share.
|
|
3702
|
-
*/
|
|
3703
|
-
private _distributeExposureDeltaAcrossPositions;
|
|
3704
|
-
/**
|
|
3705
|
-
* Returns the fraction (0–1) of total Extended exposure held by
|
|
3706
|
-
* a single position. Returns 1 when there is only one position
|
|
3707
|
-
* or when total exposure is zero.
|
|
3708
|
-
*/
|
|
3709
|
-
private _positionExposureShareFraction;
|
|
3710
|
-
/**
|
|
3711
|
-
* Net deposit change = allocation target − currently available for trade.
|
|
3712
|
-
* Positive = need to deposit more, negative = can withdraw excess.
|
|
3713
|
-
*/
|
|
3714
|
-
private _computeExtendedDepositDelta;
|
|
3715
|
-
private _computeVesuDepositAmount;
|
|
3716
|
-
/**
|
|
3717
|
-
* The wallet is a pass-through for USDC flows between the vault allocator
|
|
3718
|
-
* and the Extended exchange.
|
|
3719
|
-
*
|
|
3720
|
-
* Positive = vault allocator → wallet → Extended (deposit)
|
|
3721
|
-
* Negative = Extended → wallet → vault allocator (withdrawal)
|
|
3722
|
-
*/
|
|
3723
|
-
private _deriveWalletDelta;
|
|
3724
|
-
/**
|
|
3725
|
-
* The bringLiquidity amount is the USDC that the vault allocator must
|
|
3726
|
-
* transfer back to the vault contract for the user's withdrawal.
|
|
3727
|
-
* Equals the withdrawAmount passed into solve(); 0 during investment cycles.
|
|
3728
|
-
*/
|
|
3729
|
-
private _computeBringLiquidityAmount;
|
|
3730
|
-
private _buildVesuRepayRoutes;
|
|
3731
|
-
private _buildVesuBorrowRoutes;
|
|
3732
|
-
private _getWalletToVARoute;
|
|
3733
|
-
private _getWalletToEXTENDEDRoute;
|
|
3734
|
-
private _getVAToEXTENDEDRoute;
|
|
3735
|
-
private _getExtendedToWalletRoute;
|
|
3736
|
-
private _getWALLETToVARoute;
|
|
3737
|
-
private _getUpnlRoute;
|
|
3738
|
-
/**
|
|
3739
|
-
* 1. Withdrawal — source funds in priority order:
|
|
3740
|
-
* 1) VA balance 2) Wallet 3) Vesu borrow capacity
|
|
3741
|
-
* 4) Extended available-for-withdrawal + unrealised PnL
|
|
3742
|
-
* 5) Unwind positions on both sides (freed funds handled next cycle)
|
|
3743
|
-
*/
|
|
3744
|
-
private _classifyWithdrawal;
|
|
3745
|
-
/**
|
|
3746
|
-
* 2a. LTV Rebalance — Vesu side
|
|
3747
|
-
*
|
|
3748
|
-
* Triggered when vesuPerPoolDebtDeltasToBorrow sum is negative (high LTV, needs repayment).
|
|
3749
|
-
* Sources funds to VA so the subsequent deposit classifier can build the correct lever routes.
|
|
3750
|
-
*
|
|
3751
|
-
* Priority: 1) VA + Wallet (no routes) 2) Extended available-for-withdrawal
|
|
3752
|
-
* 3) Extended uPnL 4) Margin crisis (future)
|
|
3753
|
-
*
|
|
3754
|
-
* Design: accumulate all ext-to-wallet moves, add transfer routes at the end (principle #3).
|
|
3755
|
-
*/
|
|
3756
|
-
/**
|
|
3757
|
-
* Unified LTV / exposure classifier: `rebalance()` drives both LTV (debt, margin,
|
|
3758
|
-
* funding) and Vesu↔Extended position alignment. There is no separate imbalance pass.
|
|
3759
|
-
* Computes both Vesu repay and Extended margin needs,
|
|
3760
|
-
* then builds all routes in a single pass with no duplicate transfers.
|
|
3761
|
-
*
|
|
3762
|
-
* Vesu repay priority: VA > Wallet > ExtAvl > ExtUpnl
|
|
3763
|
-
* Extended margin priority: Wallet > VA > VesuBorrow
|
|
3764
|
-
* Shared sources consumed by Vesu first (higher priority).
|
|
3765
|
-
*/
|
|
3766
|
-
private _classifyLTV;
|
|
3767
|
-
private _ltvRebalanceInputsFromBudget;
|
|
3768
|
-
private _isLtvRebalanceNoop;
|
|
3769
|
-
/**
|
|
3770
|
-
* Turn pure rebalance() deltas into execution routes.
|
|
3771
|
-
* Order: Vesu multiply decrease → Extended decrease → aggregated transfers
|
|
3772
|
-
* (REALISE_PNL, EXTENDED_TO_WALLET + WAIT, WALLET_TO_VA, VESU_BORROW, VESU_REPAY, VA_TO_EXTENDED),
|
|
3773
|
-
* then Vesu multiply increase and Extended increase (need VA / Extended funded first).
|
|
3774
|
-
*/
|
|
3775
|
-
private _buildLtvRoutesFromRebalanceDeltas;
|
|
3776
|
-
/**
|
|
3777
|
-
* LTV_EXTENDED_PROFITABLE_AVAILABLE:
|
|
3778
|
-
* Extended has enough available-to-withdraw → withdraw, move to VA, repay Vesu.
|
|
3779
|
-
* Routes: [EXTENDED_TO_WALLET, WALLET_TO_VA, VESU_REPAY]
|
|
3780
|
-
*/
|
|
3781
|
-
/**
|
|
3782
|
-
* LTV_EXTENDED_PROFITABLE_REALIZE:
|
|
3783
|
-
* Extended has unrealised PnL → realise it first, then withdraw + repay.
|
|
3784
|
-
* Routes: [REALISE_PNL, EXTENDED_TO_WALLET, WALLET_TO_VA, VESU_REPAY]
|
|
3785
|
-
*/
|
|
3786
|
-
/**
|
|
3787
|
-
* MARGIN_CRISIS_VESU:
|
|
3788
|
-
* Neither VA/Wallet nor Extended withdrawal covers the shortfall.
|
|
3789
|
-
* Temporarily increase Extended leverage to free margin, withdraw to VA, then
|
|
3790
|
-
* decrease Vesu lever to bring LTV back in range.
|
|
3791
|
-
* Routes: [CRISIS_INCREASE_EXTENDED_MAX_LEVERAGE, EXTENDED_TO_WALLET, WALLET_TO_VA,
|
|
3792
|
-
* VESU_MULTIPLY_DECREASE_LEVER, EXTENDED_DECREASE_LEVER, CRISIS_UNDO_EXTENDED_MAX_LEVERAGE]
|
|
3793
|
-
*/
|
|
3794
|
-
/**
|
|
3795
|
-
* LTV_EXTENDED_HIGH_USE_VA_OR_WALLET:
|
|
3796
|
-
* VA/Wallet has funds → route them to Extended.
|
|
3797
|
-
* Routes: [VA_TO_EXTENDED, WALLET_TO_EXTENDED] (wallet-first, then VA for remainder)
|
|
3798
|
-
*/
|
|
3799
|
-
/**
|
|
3800
|
-
* LTV_VESU_LOW_TO_EXTENDED:
|
|
3801
|
-
* Borrow USDC from Vesu, route through VA to Extended.
|
|
3802
|
-
* Routes: [VESU_BORROW, VA_TO_EXTENDED]
|
|
3803
|
-
*/
|
|
3804
|
-
/**
|
|
3805
|
-
* MARGIN_CRISIS_EXTENDED:
|
|
3806
|
-
* Borrow beyond target HF on Vesu to free USDC, deposit to Extended,
|
|
3807
|
-
* then decrease Vesu/Extended lever, undo crisis leverage.
|
|
3808
|
-
* Routes: [CRISIS_BORROW_BEYOND_TARGET_HF, VA_TO_EXTENDED,
|
|
3809
|
-
* VESU_MULTIPLY_DECREASE_LEVER, EXTENDED_DECREASE_LEVER,
|
|
3810
|
-
* CRISIS_UNDO_EXTENDED_MAX_LEVERAGE]
|
|
3811
|
-
*/
|
|
3812
|
-
private _rebalanceFunds;
|
|
3813
|
-
private _scaleVesuPoolDeltasByFactor;
|
|
3814
|
-
/**
|
|
3815
|
-
* 3. New Deposits / Excess Funds
|
|
3816
|
-
*
|
|
3817
|
-
* Computes how much exposure to create on Vesu and Extended, then
|
|
3818
|
-
* distributes available funds using shortest-path priority chains:
|
|
3819
|
-
* Extended margin: Wallet → VA → Vesu borrow
|
|
3820
|
-
* Vesu margin: VA → Wallet → Extended
|
|
3821
|
-
*/
|
|
3822
|
-
/**
|
|
3823
|
-
* 3. New Deposits / Excess Funds
|
|
3824
|
-
*
|
|
3825
|
-
* Computes allocation split between Vesu and Extended, then sources
|
|
3826
|
-
* funds and creates lever-increase routes.
|
|
3827
|
-
*
|
|
3828
|
-
* Order: {@link _rebalanceFunds} first → project VA / Extended liquid after the same funding
|
|
3829
|
-
* routes (wallet→VA, borrow→VA, VA→Extended, Extended→wallet→VA) → ideal Vesu/Extended deltas
|
|
3830
|
-
* from distributable split → cap common BTC by min(Vesu fundable, Extended fundable) → scale
|
|
3831
|
-
* Vesu deltas and recompute Extended deltas so both sides stay matched.
|
|
3832
|
-
*
|
|
3833
|
-
* Fund flow (single pass — avoid VA→Extended then Extended→wallet round-trips):
|
|
3834
|
-
* 1) Treat Vesu borrow headroom that the multiply route will consume as covering
|
|
3835
|
-
* part of the Vesu USDC need (no standalone VESU_BORROW for that slice). Cap
|
|
3836
|
-
* standalone VESU_BORROW→VA→Extended by remaining headroom.
|
|
3837
|
-
* 2) Cover Extended deposit delta: REALISE_PNL first, then withdrawal→avail-trade,
|
|
3838
|
-
* then wallet→Extended, then VA→Extended only up to VA surplus above the USDC
|
|
3839
|
-
* that must remain for Vesu (after step 1), then borrow→VA→Extended.
|
|
3840
|
-
* 3) Cover Vesu VA shortfall: wallet→VA, Extended withdrawal→wallet→VA, REALISE_PNL,
|
|
3841
|
-
* then combined Extended→wallet→VA for the remainder.
|
|
3842
|
-
* 4) RETURN_TO_WAIT when needed; then AVNU + VESU_MULTIPLY + EXTENDED_INCREASE.
|
|
3843
|
-
*/
|
|
3844
|
-
/**
|
|
3845
|
-
* @param skipAvnuDepositSwap Omit AVNU before Vesu multiply when LTV cases already ran this cycle
|
|
3846
|
-
* (matrix tests expect deposit routes without that step).
|
|
3847
|
-
*/
|
|
3848
|
-
private _classifyDeposits;
|
|
3849
|
-
/** 4. Exposure Imbalance */
|
|
3850
|
-
/**
|
|
3851
|
-
* IMBALANCE_EXTENDED_EXCESS_SHORT_HAS_FUNDS:
|
|
3852
|
-
* Extended has too much short exposure vs Vesu. Use VA/Wallet funds to
|
|
3853
|
-
* add Vesu collateral and reduce Extended exposure.
|
|
3854
|
-
*
|
|
3855
|
-
* The new Vesu collateral covers part of the imbalance; the remaining
|
|
3856
|
-
* gap is closed by reducing Extended short exposure.
|
|
3857
|
-
*
|
|
3858
|
-
* Routes: [AVNU_DEPOSIT_SWAP, VESU_MULTIPLY_INCREASE_LEVER, EXTENDED_DECREASE_LEVER]
|
|
3859
|
-
*/
|
|
3860
|
-
/**
|
|
3861
|
-
* IMBALANCE_EXTENDED_EXCESS_SHORT_NO_FUNDS:
|
|
3862
|
-
* No available funds to add Vesu collateral → reduce Extended exposure
|
|
3863
|
-
* by the full imbalance amount.
|
|
3864
|
-
* Routes: [EXTENDED_DECREASE_LEVER]
|
|
3865
|
-
*/
|
|
3866
|
-
private _buildImbalanceExtExcessShortNoFundsRoutes;
|
|
3867
|
-
/**
|
|
3868
|
-
* IMBALANCE_VESU_EXCESS_LONG_HAS_FUNDS:
|
|
3869
|
-
* Vesu has too much long exposure vs Extended. Deposit funds on Extended
|
|
3870
|
-
* to increase short exposure, and decrease Vesu lever for the remainder.
|
|
3871
|
-
*
|
|
3872
|
-
* Routes: [WALLET_TO_EXTENDED / VA_TO_EXTENDED, EXTENDED_INCREASE_LEVER,
|
|
3873
|
-
* VESU_MULTIPLY_DECREASE_LEVER]
|
|
3874
|
-
*/
|
|
3875
|
-
/**
|
|
3876
|
-
* IMBALANCE_VESU_EXCESS_LONG_NO_FUNDS:
|
|
3877
|
-
* No funds to increase Extended → decrease Vesu lever by the full imbalance.
|
|
3878
|
-
* Routes: [VESU_MULTIPLY_DECREASE_LEVER]
|
|
3879
|
-
*/
|
|
3880
|
-
/**
|
|
3881
|
-
* Classifies the current state into actionable cases. Each case carries
|
|
3882
|
-
* its own execution routes with amounts and state info.
|
|
3883
|
-
*/
|
|
3884
|
-
private _classifyCases;
|
|
3885
|
-
private _totalVesuCollateral;
|
|
3886
|
-
private _totalVesuCollateralUsd;
|
|
3887
|
-
private _totalExtendedExposure;
|
|
3888
|
-
private _totalExtendedExposureUsd;
|
|
3889
|
-
private _logSolveResult;
|
|
3890
|
-
}
|
|
3891
|
-
|
|
3892
|
-
/**
|
|
3893
|
-
* Transaction metadata that SDK generates and risk engine stores in DB.
|
|
3894
|
-
* This metadata is used to track transaction lifecycle without coupling SDK to DB.
|
|
3895
|
-
*/
|
|
3896
|
-
interface TransactionMetadata {
|
|
3897
|
-
protocolFrom: string;
|
|
3898
|
-
protocolTo: string;
|
|
3899
|
-
transactionType: 'DEPOSIT' | 'WITHDRAWAL' | 'NONE';
|
|
3900
|
-
usdAmount: string;
|
|
3901
|
-
status: 'COMPLETED' | 'FAILED' | 'PENDING';
|
|
3902
|
-
cycleType: CycleType;
|
|
3903
|
-
}
|
|
3904
|
-
declare enum CycleType {
|
|
3905
|
-
INVESTMENT = "INVESTMENT",
|
|
3906
|
-
REBALANCE_PRICE_DROP = "REBALANCE_PRICE_DROP",
|
|
3907
|
-
REBALANCE_PRICE_RISE = "REBALANCE_PRICE_RISE",
|
|
3908
|
-
WITHDRAWAL = "WITHDRAWAL",
|
|
3909
|
-
DELTA_NEUTRAL_ADJUSTMENT = "DELTA_NEUTRAL_ADJUSTMENT"
|
|
3910
|
-
}
|
|
3911
|
-
/**
|
|
3912
|
-
* Enhanced return type for operations that generate transactions.
|
|
3913
|
-
* Includes both the calls (for execution) and metadata (for DB storage).
|
|
3914
|
-
*/
|
|
3915
|
-
interface TransactionResult<T = any> {
|
|
3916
|
-
calls: Call[];
|
|
3917
|
-
status: boolean;
|
|
3918
|
-
transactionMetadata: TransactionMetadata;
|
|
3919
|
-
}
|
|
3920
|
-
/**
|
|
3921
|
-
* Key lifecycle event types emitted during execution.
|
|
3922
|
-
* Used by callers (e.g. risk engine) to hook into the execution pipeline
|
|
3923
|
-
* and persist state to DB, send alerts, etc.
|
|
3924
|
-
*/
|
|
3925
|
-
declare enum ExecutionEventType {
|
|
3926
|
-
/** Execution started — tx sent on-chain or order placed on exchange */
|
|
3927
|
-
INITIATED = "INITIATED",
|
|
3928
|
-
/** Execution completed successfully — tx confirmed / order filled */
|
|
3929
|
-
SUCCESS = "SUCCESS",
|
|
3930
|
-
/** Execution failed — tx reverted / order rejected / timeout */
|
|
3931
|
-
FAILURE = "FAILURE"
|
|
3932
|
-
}
|
|
3933
|
-
/**
|
|
3934
|
-
* Metadata payload accompanying each execution lifecycle event.
|
|
3935
|
-
* Contains relevant identifiers, prices, and contextual information.
|
|
3936
|
-
*/
|
|
3937
|
-
interface ExecutionEventMetadata {
|
|
3938
|
-
/** Route type string (e.g. RouteType value) */
|
|
3939
|
-
routeType?: string;
|
|
3940
|
-
/** Human-readable route summary */
|
|
3941
|
-
routeSummary?: string;
|
|
3942
|
-
/** On-chain transaction hash (when available) */
|
|
3943
|
-
txHash?: string;
|
|
3944
|
-
/** Exchange order ID (for off-chain orders) */
|
|
3945
|
-
orderId?: string;
|
|
3946
|
-
/** Amount involved in the operation */
|
|
3947
|
-
amount?: string;
|
|
3948
|
-
/** Protocol name */
|
|
3949
|
-
protocol?: string;
|
|
3950
|
-
/** Actual execution price (for exchange orders) */
|
|
3951
|
-
executionPrice?: number;
|
|
3952
|
-
/** Limit price that was set */
|
|
3953
|
-
limitPrice?: number;
|
|
3954
|
-
/** Error message on failure */
|
|
3955
|
-
error?: string;
|
|
3956
|
-
/** On-chain calls that were built */
|
|
3957
|
-
calls?: Call[];
|
|
3958
|
-
/** Extensible: any extra metadata */
|
|
3959
|
-
[key: string]: any;
|
|
3960
|
-
}
|
|
3961
|
-
/**
|
|
3962
|
-
* Callback invoked on key execution lifecycle events.
|
|
3963
|
-
* Callers can use this to save to DB, send notifications, log, etc.
|
|
3964
|
-
*/
|
|
3965
|
-
type ExecutionCallback = (eventType: ExecutionEventType, metadata: ExecutionEventMetadata) => void | Promise<void>;
|
|
3966
|
-
|
|
3967
|
-
interface ExecutionConfig {
|
|
3968
|
-
networkConfig: IConfig;
|
|
3969
|
-
pricer: PricerBase;
|
|
3970
|
-
vesuMultiplyAdapter: VesuMultiplyAdapter;
|
|
3971
|
-
vesuModifyPositionAdapter: VesuModifyPositionAdapter;
|
|
3972
|
-
extendedAdapter: ExtendedAdapter;
|
|
3973
|
-
avnuAdapter: AvnuAdapter;
|
|
3974
|
-
usdcTransferAdapter: TokenTransferAdapter;
|
|
3975
|
-
vaultAllocator: ContractAddr;
|
|
3976
|
-
walletAddress: string;
|
|
3977
|
-
wbtcToken: TokenInfo;
|
|
3978
|
-
usdcToken: TokenInfo;
|
|
3979
|
-
/**
|
|
3980
|
-
* Returns the strategy's merkle tree (built from all leaf adapters).
|
|
3981
|
-
* Used to generate proofs for adapter manage calls.
|
|
3982
|
-
*/
|
|
3983
|
-
getMerkleTree: () => StandardMerkleTree;
|
|
3984
|
-
/**
|
|
3985
|
-
* Combines merkle proofs and ManageCall[] into a single on-chain Call
|
|
3986
|
-
* that invokes `manage_vault_with_merkle_verification` on the manager contract.
|
|
3987
|
-
*/
|
|
3988
|
-
getManageCall: (proofs: string[][], manageCalls: ManageCall[]) => Call;
|
|
3989
|
-
/**
|
|
3990
|
-
* Callback to get the bring-liquidity call from the strategy.
|
|
3991
|
-
*/
|
|
3992
|
-
getBringLiquidityCall: (params: {
|
|
3993
|
-
amount: Web3Number;
|
|
3994
|
-
}) => Promise<Call>;
|
|
3995
|
-
/**
|
|
3996
|
-
* Optional callback invoked on key execution lifecycle events.
|
|
3997
|
-
* Use to persist state to DB, send alerts, etc.
|
|
3998
|
-
*/
|
|
3999
|
-
onExecutionEvent?: ExecutionCallback;
|
|
4000
|
-
/**
|
|
4001
|
-
* Acceptable slippage for Extended limit orders in basis points.
|
|
4002
|
-
* E.g. 10 = 0.1%. Default: 10 (0.1%).
|
|
4003
|
-
* For BUY orders: limitPrice = midPrice * (1 + slippage)
|
|
4004
|
-
* For SELL orders: limitPrice = midPrice * (1 - slippage)
|
|
4005
|
-
*/
|
|
4006
|
-
extendedAcceptableSlippageBps?: number;
|
|
4007
|
-
/**
|
|
4008
|
-
* Maximum acceptable price divergence between Extended and Vesu
|
|
4009
|
-
* execution prices in basis points. Default: 50 (0.5%).
|
|
4010
|
-
*
|
|
4011
|
-
* During increase exposure (extended SHORT + vesu LONG):
|
|
4012
|
-
* (extendedPrice - vesuPrice) / vesuPrice must be > -maxDivergence
|
|
4013
|
-
* During decrease exposure (extended BUY + vesu decrease):
|
|
4014
|
-
* (extendedPrice - vesuPrice) / vesuPrice must be < +maxDivergence
|
|
4015
|
-
*/
|
|
4016
|
-
maxPriceDivergenceBps?: number;
|
|
4017
|
-
/**
|
|
4018
|
-
* Max time (ms) to wait for Extended limit order fill in coordinated
|
|
4019
|
-
* dual-exchange mode. Default: 3000 (3 seconds).
|
|
4020
|
-
*/
|
|
4021
|
-
extendedFillTimeoutMs?: number;
|
|
4022
|
-
}
|
|
4023
|
-
/**
|
|
4024
|
-
* Processes a {@link SolveResult} and translates each case's {@link ExecutionRoute}s into
|
|
4025
|
-
* concrete on-chain transaction calls (batched) or off-chain API operations.
|
|
4026
|
-
*
|
|
4027
|
-
* Key design principles:
|
|
4028
|
-
*
|
|
4029
|
-
* 1. **Case-based execution**: Cases are processed sequentially. Within each
|
|
4030
|
-
* case, routes execute in priority order.
|
|
4031
|
-
*
|
|
4032
|
-
* 2. **RETURN_TO_WAIT**: When encountered, all pending on-chain calls are
|
|
4033
|
-
* flushed and execution halts. The remaining routes will be re-computed
|
|
4034
|
-
* in the next solve cycle once async operations (bridge, deposit credit) settle.
|
|
4035
|
-
*
|
|
4036
|
-
* 3. **On-chain batching**: Consecutive on-chain routes (Starknet calls) are
|
|
4037
|
-
* accumulated into a single multicall batch. Off-chain routes (Extended API)
|
|
4038
|
-
* flush the batch, execute independently, then resume accumulation.
|
|
4039
|
-
*
|
|
4040
|
-
* 4. **pendingDeposit awareness**: Transfers to Extended are reduced by any
|
|
4041
|
-
* amount already in transit, avoiding double-sends.
|
|
4042
|
-
*
|
|
4043
|
-
* 5. **AVNU buffer**: Swap amounts use a 0.1% buffer to account for slippage.
|
|
4044
|
-
*
|
|
4045
|
-
* Usage:
|
|
4046
|
-
* const executor = new ExecutionService(config);
|
|
4047
|
-
* const results = await executor.execute(solveResult);
|
|
4048
|
-
*/
|
|
4049
|
-
declare class ExecutionService {
|
|
4050
|
-
private readonly _config;
|
|
4051
|
-
private readonly _tag;
|
|
4052
|
-
private readonly _tokenSymbols;
|
|
4053
|
-
private readonly _tokenDecimals;
|
|
4054
|
-
private readonly _poolNames;
|
|
4055
|
-
/**
|
|
4056
|
-
* Remaining pending deposit budget (consumed during execution to avoid double-sends).
|
|
4057
|
-
* Initialised from SolveResult.pendingDeposit at the start of execute().
|
|
4058
|
-
*/
|
|
4059
|
-
private _pendingDepositRemaining;
|
|
4060
|
-
/**
|
|
4061
|
-
* Starknet account used for on-chain estimation in coordinated mode.
|
|
4062
|
-
* Set at the start of execute() and valid for the duration of the call.
|
|
4063
|
-
*/
|
|
4064
|
-
private _account;
|
|
4065
|
-
constructor(config: ExecutionConfig);
|
|
4066
|
-
/**
|
|
4067
|
-
* Emits a lifecycle event via the configured callback (if present).
|
|
4068
|
-
* Safe to call even when no callback is configured.
|
|
4069
|
-
*/
|
|
4070
|
-
private _emitEvent;
|
|
4071
|
-
private _getProofGroupsForManageCalls;
|
|
4072
|
-
/**
|
|
4073
|
-
* Builds a single manage call (manage_vault_with_merkle_verification) for an adapter.
|
|
4074
|
-
*
|
|
4075
|
-
* Pattern:
|
|
4076
|
-
* 1. Calls adapter.getDepositCall / getWithdrawCall to get ManageCall[]
|
|
4077
|
-
* 2. Gets merkle proofs for the adapter's leaves
|
|
4078
|
-
* 3. Combines via getManageCall into a single on-chain Call
|
|
4079
|
-
*
|
|
4080
|
-
* Use this for any VA-routed operation that needs merkle proof verification.
|
|
4081
|
-
*/
|
|
4082
|
-
private _buildAdapterManageCall;
|
|
4083
|
-
private _getExtendedMidPrice;
|
|
4084
|
-
/**
|
|
4085
|
-
* Executes a limit order on Extended with acceptable slippage from mid spot price.
|
|
4086
|
-
*
|
|
4087
|
-
* Flow:
|
|
4088
|
-
* 1. Set leverage on the market
|
|
4089
|
-
* 2. Fetch orderbook → compute mid price
|
|
4090
|
-
* 3. Apply configured slippage to derive limit price
|
|
4091
|
-
* 4. Place IOC limit order at that price
|
|
4092
|
-
* 5. Poll for fill status with retries
|
|
4093
|
-
*
|
|
4094
|
-
* Returns execution details including the fill price, or null on failure.
|
|
4095
|
-
*/
|
|
4096
|
-
private _executeExtendedLimitOrder;
|
|
4097
|
-
private _fetchExtendedOrderStatusWithRetries;
|
|
4098
|
-
private _cancelExtendedOrderIfOpen;
|
|
4099
|
-
private _executeExtendedLimitOrderWithRecovery;
|
|
4100
|
-
/** ExecutionRoute types that change BTC exposure (on-chain or off-chain). */
|
|
4101
|
-
private static readonly EXPOSURE_CHANGING_ROUTES;
|
|
4102
|
-
/** ExecutionRoute types that correspond to increasing delta-neutral exposure. */
|
|
4103
|
-
private static readonly INCREASE_EXPOSURE_ROUTES;
|
|
4104
|
-
/** On-chain route types that change BTC exposure (Vesu side). */
|
|
4105
|
-
private static readonly ON_CHAIN_EXPOSURE_ROUTES;
|
|
4106
|
-
/** Off-chain Extended route types that change BTC exposure. */
|
|
4107
|
-
private static readonly EXTENDED_EXPOSURE_ROUTES;
|
|
4108
|
-
/**
|
|
4109
|
-
* Validates that the price divergence between Extended (orderbook mid) and
|
|
4110
|
-
* AVNU (actual on-chain swap price) is within acceptable limits.
|
|
4111
|
-
*
|
|
4112
|
-
* Mirrors the check from `checkPriceDifferenceBetweenAvnuAndExtended` in the
|
|
4113
|
-
* strategy — see investmentOrchestrator.ts for the call-site pattern.
|
|
4114
|
-
*
|
|
4115
|
-
* For OPEN (increasing exposure): we SELL on Extended (short) and BUY on AVNU (long).
|
|
4116
|
-
* → Extended price should not be too far below AVNU price.
|
|
4117
|
-
* → (extendedMid − avnuPrice) / avnuPrice must be > −maxDivergence
|
|
4118
|
-
*
|
|
4119
|
-
* For CLOSE (decreasing exposure): we BUY on Extended (close short) and SELL on AVNU.
|
|
4120
|
-
* → Extended price should not be too far above AVNU price.
|
|
4121
|
-
* → (extendedMid − avnuPrice) / avnuPrice must be < +maxDivergence
|
|
4122
|
-
*
|
|
4123
|
-
* @param isIncreasingExposure true when opening/increasing delta-neutral position
|
|
4124
|
-
* @throws if divergence exceeds configured maxPriceDivergenceBps
|
|
4125
|
-
*/
|
|
4126
|
-
private _validatePriceDivergence;
|
|
4127
|
-
/**
|
|
4128
|
-
* Computes the net weighted execution price (USDC per BTC) across all adapters
|
|
4129
|
-
* that have a stored SwapPriceInfo from the most recent call build.
|
|
4130
|
-
*
|
|
4131
|
-
* For deposit (USDC→BTC): price = sum(USDC sold) / sum(BTC bought)
|
|
4132
|
-
* For withdraw (BTC→USDC): price = sum(USDC bought) / sum(BTC sold)
|
|
4133
|
-
* @returns no-swap means, logic is fine and explicit no swap is needed
|
|
4134
|
-
*/
|
|
4135
|
-
private _getNetExecutionPrice;
|
|
4136
|
-
/** Clears cached swap price info on all adapters to prevent stale data across cycles. */
|
|
4137
|
-
private _clearAdapterPriceInfo;
|
|
4138
|
-
/**
|
|
4139
|
-
* Main entry point: takes a SolveResult and executes all cases in order,
|
|
4140
|
-
* building the necessary transaction calls.
|
|
4141
|
-
*
|
|
4142
|
-
* - Cases are processed sequentially.
|
|
4143
|
-
* - Within a case, on-chain calls are batched; off-chain calls flush the batch.
|
|
4144
|
-
* - Dual-exchange exposure cases use the coordinated path (construct → estimate → fill Extended → send on-chain).
|
|
4145
|
-
* - RETURN_TO_WAIT halts execution for the current case and all subsequent cases.
|
|
4146
|
-
* - Execution stops on the first route failure.
|
|
4147
|
-
*
|
|
4148
|
-
* @param account Starknet account used for on-chain fee estimation in coordinated mode.
|
|
4149
|
-
* @returns Ordered list of TransactionResults (one per batch/off-chain op).
|
|
4150
|
-
*/
|
|
4151
|
-
execute(solveResult: SolveResult, account: Account): Promise<TransactionResult[]>;
|
|
4152
|
-
/**
|
|
4153
|
-
* Executes a single case's routes.
|
|
4154
|
-
*
|
|
4155
|
-
* First splits routes at the first RETURN_TO_WAIT into an "active window"
|
|
4156
|
-
* (routes that will execute this cycle). If the active window contains both
|
|
4157
|
-
* on-chain and off-chain exposure routes, delegates to the coordinated
|
|
4158
|
-
* dual-exchange path. Otherwise, uses the standard route-by-route flow.
|
|
4159
|
-
*/
|
|
4160
|
-
private _executeCase;
|
|
4161
|
-
/**
|
|
4162
|
-
* Standard route-by-route execution for non-coordinated cases.
|
|
4163
|
-
*
|
|
4164
|
-
* On-chain routes are accumulated into a Call[] batch. When an off-chain
|
|
4165
|
-
* route or RETURN_TO_WAIT is encountered, the batch is flushed first.
|
|
4166
|
-
*/
|
|
4167
|
-
private _executeStandardCase;
|
|
4168
|
-
/**
|
|
4169
|
-
* Coordinated execution for cases that touch both Vesu (on-chain) and
|
|
4170
|
-
* Extended (off-chain) exposure in the same case.
|
|
4171
|
-
*
|
|
4172
|
-
* Flow:
|
|
4173
|
-
* 1. Partition active routes into on-chain vs Extended
|
|
4174
|
-
* 2. Construct all on-chain calls in parallel
|
|
4175
|
-
* 3. Estimate on-chain batch (dry-run via account.estimateInvokeFee)
|
|
4176
|
-
* 4. Validate price divergence between Extended and AVNU
|
|
4177
|
-
* 5. Race Extended limit order fill against timeout
|
|
4178
|
-
* 6. If filled → return Extended result + on-chain batch
|
|
4179
|
-
* If timeout/failure → drop everything
|
|
4180
|
-
*
|
|
4181
|
-
* // TODO: If Extended fills but the orchestrator's on-chain multicall later
|
|
4182
|
-
* // reverts, we have an unhedged Extended position. The orchestrator should
|
|
4183
|
-
* // catch the on-chain failure, re-solve with updated state to recompute
|
|
4184
|
-
* // necessary on-chain calls, and retry. This recovery is non-trivial and
|
|
4185
|
-
* // should be implemented as a follow-up.
|
|
4186
|
-
*/
|
|
4187
|
-
private _executeCoordinatedCase;
|
|
4188
|
-
/** Returns true if the route produces Starknet Call objects (on-chain tx). */
|
|
4189
|
-
private _isOnChainRoute;
|
|
4190
|
-
/** Checks whether any route in the list is a RETURN_TO_WAIT sentinel. */
|
|
4191
|
-
private _caseHitReturnToWait;
|
|
4192
|
-
/**
|
|
4193
|
-
* Returns true when the active window contains both on-chain exposure
|
|
4194
|
-
* routes (Vesu/AVNU) and off-chain Extended exposure routes — meaning
|
|
4195
|
-
* both exchanges participate in the same exposure change and should be
|
|
4196
|
-
* executed via the coordinated (fill-or-abort) path.
|
|
4197
|
-
*/
|
|
4198
|
-
private _isDualExchangeCase;
|
|
4199
|
-
/** Dispatches an on-chain route to the appropriate call builder. */
|
|
4200
|
-
private _buildOnChainCalls;
|
|
4201
|
-
/**
|
|
4202
|
-
* WALLET_TO_EXTENDED: Deposit USDC from operator wallet directly to Extended.
|
|
4203
|
-
*
|
|
4204
|
-
* Builds raw approve + deposit calls (NOT through the manager/merkle system)
|
|
4205
|
-
* because the wallet interacts with Extended directly, not via vault allocator.
|
|
4206
|
-
*
|
|
4207
|
-
* Adjusts amount by pending deposit to avoid double-sending.
|
|
4208
|
-
*/
|
|
4209
|
-
private _buildWalletToExtendedCalls;
|
|
4210
|
-
/**
|
|
4211
|
-
* VA_TO_EXTENDED: Deposit USDC from vault allocator to Extended.
|
|
4212
|
-
*
|
|
4213
|
-
* Uses the extended adapter's getDepositCall to build ManageCalls,
|
|
4214
|
-
* then wraps them in a merkle-verified manage call through the manager contract.
|
|
4215
|
-
*
|
|
4216
|
-
* Adjusts amount by pending deposit to avoid double-sending.
|
|
4217
|
-
*/
|
|
4218
|
-
private _buildVAToExtendedCalls;
|
|
4219
|
-
/**
|
|
4220
|
-
* WALLET_TO_VA: Transfer USDC from operator wallet to vault allocator.
|
|
4221
|
-
* Caps amount by actual wallet balance.
|
|
4222
|
-
*/
|
|
4223
|
-
private _buildWalletToVACalls;
|
|
4224
|
-
/**
|
|
4225
|
-
* AVNU_DEPOSIT_SWAP: Standalone USDC → BTC swap via AVNU.
|
|
4226
|
-
*
|
|
4227
|
-
* Uses avnu adapter's getDepositCall to build swap ManageCalls,
|
|
4228
|
-
* then wraps in a merkle-verified manage call.
|
|
4229
|
-
* Applies 0.1% buffer so downstream Vesu deposit has sufficient BTC.
|
|
4230
|
-
*/
|
|
4231
|
-
private _buildAvnuDepositSwapCalls;
|
|
4232
|
-
/**
|
|
4233
|
-
* AVNU_WITHDRAW_SWAP: Standalone BTC → USDC swap via AVNU.
|
|
4234
|
-
*
|
|
4235
|
-
* Uses avnu adapter's getWithdrawCall to build swap ManageCalls,
|
|
4236
|
-
* then wraps in a merkle-verified manage call.
|
|
4237
|
-
* Applies 0.1% buffer so Vesu-returned BTC is sufficient for the swap.
|
|
4238
|
-
*/
|
|
4239
|
-
private _buildAvnuWithdrawSwapCalls;
|
|
4240
|
-
/**
|
|
4241
|
-
* VESU_MULTIPLY_INCREASE_LEVER: Compound operation.
|
|
4242
|
-
* 1. AVNU swap USDC → BTC (with 0.1% buffer on collateral amount)
|
|
4243
|
-
* 2. Vesu multiply deposit — add BTC as collateral (triggers flash-loan leverage)
|
|
4244
|
-
*
|
|
4245
|
-
* Both steps go through the merkle-verified manager contract via their respective adapters.
|
|
4246
|
-
*/
|
|
4247
|
-
private _buildVesuIncreaseLeverCalls;
|
|
4248
|
-
/**
|
|
4249
|
-
* VESU_MULTIPLY_DECREASE_LEVER: Compound operation.
|
|
4250
|
-
* 1. Vesu multiply withdraw — reduce BTC collateral (repays proportional debt via flash-loan)
|
|
4251
|
-
* 2. AVNU swap BTC → USDC (with 0.1% buffer to account for slippage)
|
|
4252
|
-
*
|
|
4253
|
-
* Both steps go through the merkle-verified manager contract via their respective adapters.
|
|
4254
|
-
*/
|
|
4255
|
-
private _buildVesuDecreaseLeverCalls;
|
|
4256
|
-
private _validateVesuDebtRoute;
|
|
4257
|
-
/**
|
|
4258
|
-
* VESU_BORROW: Borrow additional USDC from Vesu.
|
|
4259
|
-
*/
|
|
4260
|
-
private _buildVesuBorrowCalls;
|
|
4261
|
-
/**
|
|
4262
|
-
* VESU_REPAY: Repay USDC debt to Vesu.
|
|
4263
|
-
*/
|
|
4264
|
-
private _buildVesuRepayCalls;
|
|
4265
|
-
/** BRING_LIQUIDITY: Transfer from VA to vault contract for user withdrawals. */
|
|
4266
|
-
private _buildBringLiquidityCalls;
|
|
4267
|
-
/**
|
|
4268
|
-
* CRISIS_BORROW_BEYOND_TARGET_HF: Borrow beyond normal target HF.
|
|
4269
|
-
* TODO: Implement crisis borrow flow when needed.
|
|
4270
|
-
*/
|
|
4271
|
-
private _buildCrisisBorrowCalls;
|
|
4272
|
-
/** Dispatches an off-chain route to the appropriate executor. */
|
|
4273
|
-
private _executeOffChainRoute;
|
|
4274
|
-
/**
|
|
4275
|
-
* EXTENDED_TO_WALLET: Withdraw from Extended exchange to operator wallet.
|
|
4276
|
-
*
|
|
4277
|
-
* This initiates the off-chain withdrawal API call. When followed by
|
|
4278
|
-
* RETURN_TO_WAIT, the executor will halt and the next solve cycle picks up
|
|
4279
|
-
* once the withdrawal settles and wallet balance is updated.
|
|
4280
|
-
*
|
|
4281
|
-
* If a pending withdrawal is already in transit (pendingDeposit < 0),
|
|
4282
|
-
* the amount is reduced accordingly.
|
|
4283
|
-
*/
|
|
4284
|
-
private _executeExtendedToWallet;
|
|
4285
|
-
/**
|
|
4286
|
-
* REALISE_PNL: Converts unrealised PnL to realised by closing a portion
|
|
4287
|
-
* of the short position and immediately reopening it.
|
|
4288
|
-
*
|
|
4289
|
-
* Uses {@link calculatePositionToCloseToWithdrawAmount} to determine the
|
|
4290
|
-
* minimal position size to close so that the required amount becomes
|
|
4291
|
-
* available for withdrawal.
|
|
4292
|
-
*
|
|
4293
|
-
* Both close and reopen orders use limit pricing via _executeExtendedLimitOrder.
|
|
4294
|
-
*
|
|
4295
|
-
* Steps:
|
|
4296
|
-
* 1. Close portion of short position (BUY limit order) → realises PnL
|
|
4297
|
-
* 2. Immediately reopen same size (SELL limit order) → maintains exposure
|
|
4298
|
-
*/
|
|
4299
|
-
private _executeRealisePnl;
|
|
4300
|
-
/**
|
|
4301
|
-
* EXTENDED_INCREASE_LEVER: Create a SHORT sell limit order on Extended to
|
|
4302
|
-
* increase delta-neutral exposure.
|
|
4303
|
-
*
|
|
4304
|
-
* Uses limit pricing: limitPrice = midPrice * (1 - slippage) to prevent
|
|
4305
|
-
* selling at unfavourable rates.
|
|
4306
|
-
*
|
|
4307
|
-
* Validates price divergence between Extended and Vesu before execution.
|
|
4308
|
-
*/
|
|
4309
|
-
private _executeExtendedIncreaseLever;
|
|
2541
|
+
protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
|
|
2542
|
+
getVesuMultiplyAdapter(): VesuMultiplyAdapter;
|
|
2543
|
+
getVesuModifyPositionAdapter(): VesuModifyPositionAdapter;
|
|
4310
2544
|
/**
|
|
4311
|
-
*
|
|
4312
|
-
*
|
|
4313
|
-
*
|
|
4314
|
-
* Uses limit pricing: limitPrice = midPrice * (1 + slippage) to prevent
|
|
4315
|
-
* buying at unfavourable rates.
|
|
4316
|
-
*
|
|
4317
|
-
* Validates price divergence between Extended and Vesu before execution.
|
|
2545
|
+
* Legacy helper for retired Evergreen flows. New integrations should use
|
|
2546
|
+
* getVesuMultiplyAdapter / getVesuModifyPositionAdapter and BaseAdapter deposit/withdraw leaves.
|
|
4318
2547
|
*/
|
|
4319
|
-
|
|
2548
|
+
getVesuAdapters(): VesuAdapter[];
|
|
2549
|
+
getVesuPositions(blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
|
|
2550
|
+
getVaultPositions(): Promise<VaultPosition[]>;
|
|
2551
|
+
getSetManagerCall(strategist: ContractAddr, root?: string): Call;
|
|
4320
2552
|
/**
|
|
4321
|
-
*
|
|
4322
|
-
*
|
|
2553
|
+
* Compatibility helper: SVKStrategy's `getManageCall` expects proof-groups.
|
|
2554
|
+
* We derive proof-groups from each manageCall's `proofReadableId`.
|
|
4323
2555
|
*/
|
|
4324
|
-
|
|
2556
|
+
protected getManageCallFromManageCalls(manageCalls: ManageCall[]): Call;
|
|
2557
|
+
getVesuModifyPositionCalls(params: {
|
|
2558
|
+
isLeg1: boolean;
|
|
2559
|
+
isDeposit: boolean;
|
|
2560
|
+
depositAmount: Web3Number;
|
|
2561
|
+
debtAmount: Web3Number;
|
|
2562
|
+
}): UniversalManageCall[];
|
|
2563
|
+
getTag(): string;
|
|
4325
2564
|
/**
|
|
4326
|
-
*
|
|
4327
|
-
*
|
|
2565
|
+
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
2566
|
+
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
4328
2567
|
*/
|
|
4329
|
-
|
|
2568
|
+
getLSTAPR(address: ContractAddr): Promise<number>;
|
|
2569
|
+
getVesuHealthFactors(blockNumber?: BlockIdentifier): Promise<number[]>;
|
|
2570
|
+
computeRebalanceConditionAndReturnCalls(): Promise<Call[]>;
|
|
2571
|
+
private getNewHealthFactor;
|
|
4330
2572
|
/**
|
|
4331
|
-
* Adjusts a deposit-to-Extended amount by the remaining pending deposit
|
|
4332
|
-
* budget. If pending deposit > 0, those funds are already in transit and
|
|
4333
|
-
* shouldn't be re-sent.
|
|
4334
2573
|
*
|
|
4335
|
-
*
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
* Applies a 0.1% buffer (AVNU_BUFFER_FACTOR) to an amount.
|
|
4340
|
-
* This ensures the downstream consumer (Vesu deposit or AVNU swap)
|
|
4341
|
-
* always has sufficient tokens despite minor slippage.
|
|
4342
|
-
*/
|
|
4343
|
-
private _applyAvnuBuffer;
|
|
4344
|
-
/**
|
|
4345
|
-
* Creates a TransactionResult for a batch of on-chain calls.
|
|
4346
|
-
* The caller is expected to send all calls in a single multicall transaction.
|
|
2574
|
+
* @param vesuAdapter
|
|
2575
|
+
* @param currentHf
|
|
2576
|
+
* @param isDeposit if true, attempt by adding collateral, else by repaying
|
|
2577
|
+
* @returns
|
|
4347
2578
|
*/
|
|
4348
|
-
private
|
|
4349
|
-
|
|
4350
|
-
|
|
2579
|
+
private getLegRebalanceAmount;
|
|
2580
|
+
getVesuModifyPositionCall(params: {
|
|
2581
|
+
isDeposit: boolean;
|
|
2582
|
+
leg1DepositAmount: Web3Number;
|
|
2583
|
+
}): Promise<Call>;
|
|
2584
|
+
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
2585
|
+
getHarvestCall(): Promise<{
|
|
2586
|
+
call: Call;
|
|
2587
|
+
reward: Web3Number;
|
|
2588
|
+
tokenInfo: TokenInfo;
|
|
2589
|
+
}>;
|
|
2590
|
+
getRebalanceCall(params: {
|
|
2591
|
+
isLeg1toLeg2: boolean;
|
|
2592
|
+
amount: Web3Number;
|
|
2593
|
+
}): Promise<Call>;
|
|
2594
|
+
}
|
|
2595
|
+
declare enum UNIVERSAL_MANAGE_IDS {
|
|
2596
|
+
FLASH_LOAN = "flash_loan_init",
|
|
2597
|
+
VESU_LEG1 = "vesu_leg1",
|
|
2598
|
+
VESU_LEG2 = "vesu_leg2",
|
|
2599
|
+
APPROVE_TOKEN1 = "approve_token1",
|
|
2600
|
+
APPROVE_TOKEN2 = "approve_token2",
|
|
2601
|
+
APPROVE_BRING_LIQUIDITY = "approve_bring_liquidity",
|
|
2602
|
+
BRING_LIQUIDITY = "bring_liquidity",
|
|
2603
|
+
DEFISPRING_REWARDS = "defispring_rewards",
|
|
2604
|
+
APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
|
|
2605
|
+
AVNU_SWAP_REWARDS = "avnu_swap_rewards"
|
|
2606
|
+
}
|
|
2607
|
+
declare enum UNIVERSAL_ADAPTER_IDS {
|
|
2608
|
+
VESU_MULTIPLY = "vesu_multiply",
|
|
2609
|
+
VESU_MODIFY = "vesu_modify",
|
|
2610
|
+
AVNU = "avnu"
|
|
4351
2611
|
}
|
|
2612
|
+
declare function getContractDetails(settings: UniversalStrategySettings & {
|
|
2613
|
+
aumOracle?: ContractAddr;
|
|
2614
|
+
}): {
|
|
2615
|
+
address: ContractAddr;
|
|
2616
|
+
name: string;
|
|
2617
|
+
}[];
|
|
2618
|
+
declare const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[];
|
|
4352
2619
|
|
|
4353
|
-
interface
|
|
2620
|
+
interface HyperLSTStrategySettings extends UniversalStrategySettings {
|
|
2621
|
+
borrowable_assets: {
|
|
2622
|
+
tokenInfo: TokenInfo;
|
|
2623
|
+
poolId: ContractAddr;
|
|
2624
|
+
}[];
|
|
4354
2625
|
underlyingToken: TokenInfo;
|
|
4355
|
-
borrowable_assets: TokenInfo[];
|
|
4356
|
-
targetHealthFactor: number;
|
|
4357
2626
|
quoteAmountToFetchPrice: Web3Number;
|
|
2627
|
+
targetHealthFactor: number;
|
|
4358
2628
|
minHealthFactor: number;
|
|
4359
2629
|
aumOracle: ContractAddr;
|
|
4360
|
-
|
|
4361
|
-
|
|
2630
|
+
adapterIds?: {
|
|
2631
|
+
/** VesuMultiplyAdapter for underlying-matched debt (first matching borrowable pool) */
|
|
2632
|
+
primaryMultiply: string;
|
|
2633
|
+
multiply: Record<string, string>;
|
|
2634
|
+
modify: Record<string, string>;
|
|
2635
|
+
};
|
|
4362
2636
|
}
|
|
4363
|
-
declare class
|
|
4364
|
-
|
|
4365
|
-
usdcToken: TokenInfo;
|
|
4366
|
-
readonly stateManager: ExtendedSVKVesuStateManager;
|
|
2637
|
+
declare class UniversalLstMultiplierStrategy<S extends HyperLSTStrategySettings> extends SVKStrategy<S> {
|
|
2638
|
+
private quoteAmountToFetchPrice;
|
|
4367
2639
|
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
|
|
2640
|
+
getTag(): string;
|
|
2641
|
+
private getAdapterById;
|
|
2642
|
+
getVesuMultiplyAdapterByKey(key: string): VesuMultiplyAdapter;
|
|
2643
|
+
getVesuSameTokenAdapter(): VesuMultiplyAdapter;
|
|
2644
|
+
getVesuMultiplyAdapters(): VesuMultiplyAdapter[];
|
|
2645
|
+
getRewardsAUM(_prevAum: Web3Number): Promise<Web3Number>;
|
|
2646
|
+
getLSTAvnuRate(): Promise<number>;
|
|
2647
|
+
getLSTExchangeRate(): Promise<number>;
|
|
2648
|
+
private _getMinOutputAmountLSTBuy;
|
|
2649
|
+
private _getMinOutputAmountLSTSell;
|
|
4368
2650
|
/**
|
|
4369
|
-
*
|
|
4370
|
-
*
|
|
2651
|
+
* Uses vesu's multiple call to create leverage on LST
|
|
2652
|
+
* Deposit amount is in LST
|
|
2653
|
+
* @param params
|
|
4371
2654
|
*/
|
|
4372
|
-
|
|
2655
|
+
getFundManagementCall(params: {
|
|
2656
|
+
isDeposit: boolean;
|
|
2657
|
+
leg1DepositAmount: Web3Number;
|
|
2658
|
+
}): Promise<Call[] | null>;
|
|
2659
|
+
getLSTUnderlyingTokenInfo(): TokenInfo;
|
|
2660
|
+
getLSTAPR(_address: ContractAddr): Promise<number>;
|
|
2661
|
+
netAPY(): Promise<{
|
|
2662
|
+
net: number;
|
|
2663
|
+
splits: {
|
|
2664
|
+
apy: number;
|
|
2665
|
+
id: string;
|
|
2666
|
+
}[];
|
|
2667
|
+
}>;
|
|
2668
|
+
maxNewDeposits(params?: {
|
|
2669
|
+
isAPYComputation: boolean;
|
|
2670
|
+
}): Promise<number>;
|
|
2671
|
+
protected getUnusedBalanceAPY(): Promise<{
|
|
2672
|
+
apy: number;
|
|
2673
|
+
weight: number;
|
|
2674
|
+
}>;
|
|
2675
|
+
getAUM(unrealizedAUM?: boolean): Promise<{
|
|
2676
|
+
net: SingleTokenInfo;
|
|
2677
|
+
prevAum: Web3Number;
|
|
2678
|
+
splits: PositionInfo[];
|
|
2679
|
+
}>;
|
|
2680
|
+
getTVLUnrealized(): Promise<{
|
|
2681
|
+
net: SingleTokenInfo;
|
|
2682
|
+
prevAum: Web3Number;
|
|
2683
|
+
splits: PositionInfo[];
|
|
2684
|
+
}>;
|
|
2685
|
+
getUserUnrealizedGains(user: ContractAddr): Promise<{
|
|
2686
|
+
unrealizedGains: Web3Number;
|
|
2687
|
+
userShare: number;
|
|
2688
|
+
tokenInfo: TokenInfo;
|
|
2689
|
+
}>;
|
|
2690
|
+
}
|
|
2691
|
+
declare const AUDIT_URL = "https://docs.troves.fi/p/security#starknet-vault-kit";
|
|
2692
|
+
declare function getFAQs(lstSymbol: string, underlyingSymbol: string, isLST: boolean): FAQ[];
|
|
2693
|
+
declare const _riskFactor: RiskFactor[];
|
|
2694
|
+
declare function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string): string[];
|
|
2695
|
+
declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
|
|
2696
|
+
|
|
2697
|
+
interface BoostedxSTRKCarryStrategySettings extends UniversalStrategySettings {
|
|
2698
|
+
depositToken: TokenInfo;
|
|
2699
|
+
debtToken: TokenInfo;
|
|
2700
|
+
lstHyperToken: TokenInfo;
|
|
2701
|
+
vesuPoolId: ContractAddr;
|
|
2702
|
+
maxLTV: number;
|
|
2703
|
+
targetLTV: number;
|
|
2704
|
+
hyperLstVaultAddress: ContractAddr;
|
|
2705
|
+
hyperLstRedeemNFT: ContractAddr;
|
|
2706
|
+
trovesStrategyId: string;
|
|
2707
|
+
hasBtcFiRewards: boolean;
|
|
2708
|
+
adapterIds?: {
|
|
2709
|
+
vesu: string;
|
|
2710
|
+
avnu: string;
|
|
2711
|
+
hyper: string;
|
|
2712
|
+
transfer: string;
|
|
2713
|
+
};
|
|
2714
|
+
}
|
|
2715
|
+
declare class BoostedxSTRKCarryStrategy<S extends BoostedxSTRKCarryStrategySettings> extends SVKStrategy<S> {
|
|
2716
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
|
|
4373
2717
|
getTag(): string;
|
|
2718
|
+
private getAdapterById;
|
|
2719
|
+
private getTruePriceForToken;
|
|
2720
|
+
getMinOutputAmountLSTBuy(amountInUnderlying: Web3Number): Promise<Web3Number>;
|
|
2721
|
+
getMinOutputAmountLSTSell(amountInLST: Web3Number): Promise<Web3Number>;
|
|
2722
|
+
getVesuModifyPositionCall(params: {
|
|
2723
|
+
isDeposit: boolean;
|
|
2724
|
+
leg1DepositAmount: Web3Number;
|
|
2725
|
+
debtAmount?: Web3Number;
|
|
2726
|
+
}): Promise<Call>;
|
|
2727
|
+
getVesuPositions(): Promise<VaultPosition[]>;
|
|
2728
|
+
getVesuHealthFactor(blockNumber?: BlockIdentifier): Promise<number>;
|
|
2729
|
+
getModifyHyperPositionCall(params: {
|
|
2730
|
+
isDeposit: boolean;
|
|
2731
|
+
amount: Web3Number;
|
|
2732
|
+
}): Promise<Call>;
|
|
2733
|
+
getAvnuSwapCall(params: {
|
|
2734
|
+
isDeposit: boolean;
|
|
2735
|
+
amount: Web3Number;
|
|
2736
|
+
minAmount?: Web3Number;
|
|
2737
|
+
}): Promise<Call>;
|
|
4374
2738
|
/**
|
|
4375
|
-
*
|
|
4376
|
-
*
|
|
2739
|
+
* Returns the deposit token balance sitting idle inside the vault contract itself.
|
|
2740
|
+
* This balance can offset the required liquidity during withdrawal processing.
|
|
4377
2741
|
*/
|
|
4378
|
-
|
|
4379
|
-
collateralPrice: PriceInfo;
|
|
4380
|
-
debtPrice: PriceInfo;
|
|
4381
|
-
}>;
|
|
4382
|
-
getVesuMultiplyAdapter(): Promise<VesuMultiplyAdapter>;
|
|
4383
|
-
getVesuModifyPositionAdapter(): Promise<VesuModifyPositionAdapter>;
|
|
4384
|
-
getUsdcTransferAdapter(): Promise<TokenTransferAdapter>;
|
|
4385
|
-
getAvnuAdapter(): Promise<AvnuAdapter>;
|
|
4386
|
-
getExtendedAdapter(): Promise<ExtendedAdapter>;
|
|
2742
|
+
getUnusedBalanceVault(): Promise<Web3Number>;
|
|
4387
2743
|
/**
|
|
4388
|
-
*
|
|
4389
|
-
*
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
*
|
|
4394
|
-
*
|
|
2744
|
+
* Returns the current borrow token balance sitting unused in the vault allocator.
|
|
2745
|
+
* This covers borrow token from prior borrow cycles that hasn't been swapped yet.
|
|
2746
|
+
*/
|
|
2747
|
+
getUnusedDebt(): Promise<Web3Number>;
|
|
2748
|
+
/**
|
|
2749
|
+
* Returns the LST balance sitting in the vault allocator.
|
|
2750
|
+
* This is non-zero when the previous cycle's request_redeem on the HyperPosition
|
|
2751
|
+
* has been settled — the redeemed LST lands here and is ready to be swapped.
|
|
4395
2752
|
*/
|
|
4396
|
-
|
|
4397
|
-
onExecutionEvent?: ExecutionCallback;
|
|
4398
|
-
extendedAcceptableSlippageBps?: number;
|
|
4399
|
-
maxPriceDivergenceBps?: number;
|
|
4400
|
-
}): Promise<ExecutionService>;
|
|
2753
|
+
getLstInVaultAllocator(): Promise<Web3Number>;
|
|
4401
2754
|
/**
|
|
4402
|
-
*
|
|
4403
|
-
*
|
|
4404
|
-
*
|
|
4405
|
-
* and per-position breakdowns.
|
|
2755
|
+
* Simulates depositing `depositAmount` on Vesu and returns the
|
|
2756
|
+
* incremental borrow token that would be borrowed. Needed to size the AVNU swap
|
|
2757
|
+
* call that is batched together with the Vesu call in the same transaction.
|
|
4406
2758
|
*/
|
|
2759
|
+
computeVesuDepositBorrowAmount(depositAmount: Web3Number): Promise<Web3Number>;
|
|
2760
|
+
computeVesuWithdrawDebtDelta(withdrawAmount: Web3Number): Promise<Web3Number>;
|
|
2761
|
+
getPendingHyperAssets(): Promise<Web3Number>;
|
|
2762
|
+
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<{
|
|
2763
|
+
tokenInfo: TokenInfo;
|
|
2764
|
+
amount: Web3Number;
|
|
2765
|
+
usdValue: number;
|
|
2766
|
+
}>;
|
|
4407
2767
|
getAUM(): Promise<{
|
|
4408
2768
|
net: SingleTokenInfo;
|
|
4409
2769
|
prevAum: Web3Number;
|
|
4410
2770
|
splits: PositionInfo[];
|
|
4411
2771
|
}>;
|
|
4412
2772
|
/**
|
|
4413
|
-
*
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
2773
|
+
* Get Vesu APYs for collateral and debt positions
|
|
2774
|
+
*/
|
|
2775
|
+
getVesuAPYs(): Promise<{
|
|
2776
|
+
baseAPYs: number[];
|
|
2777
|
+
rewardAPYs: number[];
|
|
2778
|
+
positions: VaultPosition[];
|
|
2779
|
+
}>;
|
|
2780
|
+
/**
|
|
2781
|
+
* Get APY from the Hyper LST vault position
|
|
2782
|
+
*/
|
|
2783
|
+
getHyperVaultAPY(): Promise<{
|
|
2784
|
+
apy: number;
|
|
2785
|
+
weight: number;
|
|
2786
|
+
}>;
|
|
2787
|
+
/**
|
|
2788
|
+
* Get APY for unused balance (idle funds in vault allocator)
|
|
2789
|
+
*/
|
|
2790
|
+
protected getUnusedBalanceAPY(): Promise<{
|
|
2791
|
+
apy: number;
|
|
2792
|
+
weight: number;
|
|
2793
|
+
}>;
|
|
2794
|
+
/**
|
|
2795
|
+
* Compute weighted APY from individual APYs, weights, and total AUM
|
|
4417
2796
|
*/
|
|
4418
|
-
|
|
2797
|
+
private computeAPY;
|
|
4419
2798
|
/**
|
|
4420
|
-
*
|
|
4421
|
-
* [0] Vesu health factor (maxLTV / actualLTV) — higher is safer.
|
|
4422
|
-
* [1] Extended margin ratio (as percentage) — higher means more margin available.
|
|
2799
|
+
* Calculate net APY from base and reward APYs
|
|
4423
2800
|
*/
|
|
4424
|
-
|
|
2801
|
+
protected returnNetAPY(baseAPYs: number[], rewardAPYs: number[], weights: number[], totalWeightUSD: number): Promise<{
|
|
2802
|
+
net: number;
|
|
2803
|
+
splits: {
|
|
2804
|
+
apy: number;
|
|
2805
|
+
id: string;
|
|
2806
|
+
}[];
|
|
2807
|
+
}>;
|
|
4425
2808
|
/**
|
|
4426
|
-
*
|
|
4427
|
-
*
|
|
4428
|
-
* position APY, weighted by their respective USD values.
|
|
4429
|
-
* Also returns per-position APY splits.
|
|
2809
|
+
* Calculate net APY across all positions (Vesu, Hyper vault, unused balance)
|
|
2810
|
+
* weighted by USD value
|
|
4430
2811
|
*/
|
|
4431
2812
|
netAPY(): Promise<{
|
|
4432
2813
|
net: number;
|
|
@@ -4436,477 +2817,16 @@ declare class VesuExtendedMultiplierStrategy<S extends VesuExtendedStrategySetti
|
|
|
4436
2817
|
}[];
|
|
4437
2818
|
}>;
|
|
4438
2819
|
/**
|
|
4439
|
-
*
|
|
4440
|
-
*
|
|
2820
|
+
* Calculate future rewards (e.g. BTCFI rewards) contribution to AUM
|
|
2821
|
+
* Similar to universal-strategy.tsx approach
|
|
4441
2822
|
*/
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
}[]>;
|
|
2823
|
+
protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
|
|
2824
|
+
getFundManagementCall(params: {
|
|
2825
|
+
isDeposit: boolean;
|
|
2826
|
+
leg1DepositAmount: Web3Number;
|
|
2827
|
+
}): Promise<Call[] | null>;
|
|
4447
2828
|
}
|
|
4448
|
-
declare const
|
|
4449
|
-
|
|
4450
|
-
declare const AddressesConfig: {
|
|
4451
|
-
readonly tokens: {
|
|
4452
|
-
readonly USDC: {
|
|
4453
|
-
readonly address: "0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8";
|
|
4454
|
-
readonly decimals: 6;
|
|
4455
|
-
};
|
|
4456
|
-
readonly WBTC: {
|
|
4457
|
-
readonly address: "0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac";
|
|
4458
|
-
readonly decimals: 8;
|
|
4459
|
-
};
|
|
4460
|
-
};
|
|
4461
|
-
readonly contracts: {
|
|
4462
|
-
readonly EXTENDED: "0x062da0780fae50d68cecaa5a051606dc21217ba290969b302db4dd99d2e9b470";
|
|
4463
|
-
readonly MULTIPLY: "0x07964760e90baa28841ec94714151e03fbc13321797e68a874e88f27c9d58513";
|
|
4464
|
-
};
|
|
4465
|
-
readonly wallet: {
|
|
4466
|
-
readonly address: string;
|
|
4467
|
-
};
|
|
4468
|
-
};
|
|
4469
|
-
declare const ExtendedConfig: {
|
|
4470
|
-
readonly baseUrl: string;
|
|
4471
|
-
readonly marketName: "BTC-USD";
|
|
4472
|
-
readonly maintenanceMargin: 0.01;
|
|
4473
|
-
readonly precision: 5;
|
|
4474
|
-
readonly fees: number;
|
|
4475
|
-
readonly minPositionSize: 0.0001;
|
|
4476
|
-
};
|
|
4477
|
-
declare const VesuConfig: {
|
|
4478
|
-
readonly poolId: "0x02eef0c13b10b487ea5916b54c0a7f98ec43fb3048f60fdeedaf5b08f6f88aaf";
|
|
4479
|
-
readonly maxLtv: 0.8428;
|
|
4480
|
-
readonly maxLiquidationRatio: 0.86;
|
|
4481
|
-
readonly targetHealthFactor: number;
|
|
4482
|
-
readonly ekubo: {
|
|
4483
|
-
readonly endpoint: "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_FROM_ADDRESS}}/{{TOKEN_TO_ADDRESS}}";
|
|
4484
|
-
readonly priceMaxSlippage: number;
|
|
4485
|
-
};
|
|
4486
|
-
readonly avnu: {
|
|
4487
|
-
readonly api: "https://starknet.api.avnu.fi/swap/v2/quotes";
|
|
4488
|
-
};
|
|
4489
|
-
readonly targetLtv: 0.61;
|
|
4490
|
-
readonly minDebtForVesuRebalacing: number;
|
|
4491
|
-
};
|
|
4492
|
-
declare const AbisConfig: {
|
|
4493
|
-
readonly vesu: {
|
|
4494
|
-
readonly multiply: ({
|
|
4495
|
-
type: string;
|
|
4496
|
-
name: string;
|
|
4497
|
-
interface_name: string;
|
|
4498
|
-
members?: undefined;
|
|
4499
|
-
items?: undefined;
|
|
4500
|
-
variants?: undefined;
|
|
4501
|
-
inputs?: undefined;
|
|
4502
|
-
kind?: undefined;
|
|
4503
|
-
} | {
|
|
4504
|
-
type: string;
|
|
4505
|
-
name: string;
|
|
4506
|
-
members: {
|
|
4507
|
-
name: string;
|
|
4508
|
-
type: string;
|
|
4509
|
-
}[];
|
|
4510
|
-
interface_name?: undefined;
|
|
4511
|
-
items?: undefined;
|
|
4512
|
-
variants?: undefined;
|
|
4513
|
-
inputs?: undefined;
|
|
4514
|
-
kind?: undefined;
|
|
4515
|
-
} | {
|
|
4516
|
-
type: string;
|
|
4517
|
-
name: string;
|
|
4518
|
-
items: {
|
|
4519
|
-
type: string;
|
|
4520
|
-
name: string;
|
|
4521
|
-
inputs: {
|
|
4522
|
-
name: string;
|
|
4523
|
-
type: string;
|
|
4524
|
-
}[];
|
|
4525
|
-
outputs: {
|
|
4526
|
-
type: string;
|
|
4527
|
-
}[];
|
|
4528
|
-
state_mutability: string;
|
|
4529
|
-
}[];
|
|
4530
|
-
interface_name?: undefined;
|
|
4531
|
-
members?: undefined;
|
|
4532
|
-
variants?: undefined;
|
|
4533
|
-
inputs?: undefined;
|
|
4534
|
-
kind?: undefined;
|
|
4535
|
-
} | {
|
|
4536
|
-
type: string;
|
|
4537
|
-
name: string;
|
|
4538
|
-
variants: {
|
|
4539
|
-
name: string;
|
|
4540
|
-
type: string;
|
|
4541
|
-
}[];
|
|
4542
|
-
interface_name?: undefined;
|
|
4543
|
-
members?: undefined;
|
|
4544
|
-
items?: undefined;
|
|
4545
|
-
inputs?: undefined;
|
|
4546
|
-
kind?: undefined;
|
|
4547
|
-
} | {
|
|
4548
|
-
type: string;
|
|
4549
|
-
name: string;
|
|
4550
|
-
inputs: {
|
|
4551
|
-
name: string;
|
|
4552
|
-
type: string;
|
|
4553
|
-
}[];
|
|
4554
|
-
interface_name?: undefined;
|
|
4555
|
-
members?: undefined;
|
|
4556
|
-
items?: undefined;
|
|
4557
|
-
variants?: undefined;
|
|
4558
|
-
kind?: undefined;
|
|
4559
|
-
} | {
|
|
4560
|
-
type: string;
|
|
4561
|
-
name: string;
|
|
4562
|
-
kind: string;
|
|
4563
|
-
members: {
|
|
4564
|
-
name: string;
|
|
4565
|
-
type: string;
|
|
4566
|
-
kind: string;
|
|
4567
|
-
}[];
|
|
4568
|
-
interface_name?: undefined;
|
|
4569
|
-
items?: undefined;
|
|
4570
|
-
variants?: undefined;
|
|
4571
|
-
inputs?: undefined;
|
|
4572
|
-
} | {
|
|
4573
|
-
type: string;
|
|
4574
|
-
name: string;
|
|
4575
|
-
kind: string;
|
|
4576
|
-
variants: {
|
|
4577
|
-
name: string;
|
|
4578
|
-
type: string;
|
|
4579
|
-
kind: string;
|
|
4580
|
-
}[];
|
|
4581
|
-
interface_name?: undefined;
|
|
4582
|
-
members?: undefined;
|
|
4583
|
-
items?: undefined;
|
|
4584
|
-
inputs?: undefined;
|
|
4585
|
-
})[];
|
|
4586
|
-
readonly pool: ({
|
|
4587
|
-
type: string;
|
|
4588
|
-
name: string;
|
|
4589
|
-
interface_name: string;
|
|
4590
|
-
members?: undefined;
|
|
4591
|
-
variants?: undefined;
|
|
4592
|
-
items?: undefined;
|
|
4593
|
-
inputs?: undefined;
|
|
4594
|
-
kind?: undefined;
|
|
4595
|
-
} | {
|
|
4596
|
-
type: string;
|
|
4597
|
-
name: string;
|
|
4598
|
-
members: {
|
|
4599
|
-
name: string;
|
|
4600
|
-
type: string;
|
|
4601
|
-
}[];
|
|
4602
|
-
interface_name?: undefined;
|
|
4603
|
-
variants?: undefined;
|
|
4604
|
-
items?: undefined;
|
|
4605
|
-
inputs?: undefined;
|
|
4606
|
-
kind?: undefined;
|
|
4607
|
-
} | {
|
|
4608
|
-
type: string;
|
|
4609
|
-
name: string;
|
|
4610
|
-
variants: {
|
|
4611
|
-
name: string;
|
|
4612
|
-
type: string;
|
|
4613
|
-
}[];
|
|
4614
|
-
interface_name?: undefined;
|
|
4615
|
-
members?: undefined;
|
|
4616
|
-
items?: undefined;
|
|
4617
|
-
inputs?: undefined;
|
|
4618
|
-
kind?: undefined;
|
|
4619
|
-
} | {
|
|
4620
|
-
type: string;
|
|
4621
|
-
name: string;
|
|
4622
|
-
items: {
|
|
4623
|
-
type: string;
|
|
4624
|
-
name: string;
|
|
4625
|
-
inputs: {
|
|
4626
|
-
name: string;
|
|
4627
|
-
type: string;
|
|
4628
|
-
}[];
|
|
4629
|
-
outputs: {
|
|
4630
|
-
type: string;
|
|
4631
|
-
}[];
|
|
4632
|
-
state_mutability: string;
|
|
4633
|
-
}[];
|
|
4634
|
-
interface_name?: undefined;
|
|
4635
|
-
members?: undefined;
|
|
4636
|
-
variants?: undefined;
|
|
4637
|
-
inputs?: undefined;
|
|
4638
|
-
kind?: undefined;
|
|
4639
|
-
} | {
|
|
4640
|
-
type: string;
|
|
4641
|
-
name: string;
|
|
4642
|
-
inputs: {
|
|
4643
|
-
name: string;
|
|
4644
|
-
type: string;
|
|
4645
|
-
}[];
|
|
4646
|
-
interface_name?: undefined;
|
|
4647
|
-
members?: undefined;
|
|
4648
|
-
variants?: undefined;
|
|
4649
|
-
items?: undefined;
|
|
4650
|
-
kind?: undefined;
|
|
4651
|
-
} | {
|
|
4652
|
-
type: string;
|
|
4653
|
-
name: string;
|
|
4654
|
-
kind: string;
|
|
4655
|
-
members: {
|
|
4656
|
-
name: string;
|
|
4657
|
-
type: string;
|
|
4658
|
-
kind: string;
|
|
4659
|
-
}[];
|
|
4660
|
-
interface_name?: undefined;
|
|
4661
|
-
variants?: undefined;
|
|
4662
|
-
items?: undefined;
|
|
4663
|
-
inputs?: undefined;
|
|
4664
|
-
} | {
|
|
4665
|
-
type: string;
|
|
4666
|
-
name: string;
|
|
4667
|
-
kind: string;
|
|
4668
|
-
variants: {
|
|
4669
|
-
name: string;
|
|
4670
|
-
type: string;
|
|
4671
|
-
kind: string;
|
|
4672
|
-
}[];
|
|
4673
|
-
interface_name?: undefined;
|
|
4674
|
-
members?: undefined;
|
|
4675
|
-
items?: undefined;
|
|
4676
|
-
inputs?: undefined;
|
|
4677
|
-
})[];
|
|
4678
|
-
};
|
|
4679
|
-
readonly extended: {
|
|
4680
|
-
readonly contract: ({
|
|
4681
|
-
type: string;
|
|
4682
|
-
name: string;
|
|
4683
|
-
interface_name: string;
|
|
4684
|
-
members?: undefined;
|
|
4685
|
-
variants?: undefined;
|
|
4686
|
-
items?: undefined;
|
|
4687
|
-
inputs?: undefined;
|
|
4688
|
-
kind?: undefined;
|
|
4689
|
-
} | {
|
|
4690
|
-
type: string;
|
|
4691
|
-
name: string;
|
|
4692
|
-
members: {
|
|
4693
|
-
name: string;
|
|
4694
|
-
type: string;
|
|
4695
|
-
}[];
|
|
4696
|
-
interface_name?: undefined;
|
|
4697
|
-
variants?: undefined;
|
|
4698
|
-
items?: undefined;
|
|
4699
|
-
inputs?: undefined;
|
|
4700
|
-
kind?: undefined;
|
|
4701
|
-
} | {
|
|
4702
|
-
type: string;
|
|
4703
|
-
name: string;
|
|
4704
|
-
variants: {
|
|
4705
|
-
name: string;
|
|
4706
|
-
type: string;
|
|
4707
|
-
}[];
|
|
4708
|
-
interface_name?: undefined;
|
|
4709
|
-
members?: undefined;
|
|
4710
|
-
items?: undefined;
|
|
4711
|
-
inputs?: undefined;
|
|
4712
|
-
kind?: undefined;
|
|
4713
|
-
} | {
|
|
4714
|
-
type: string;
|
|
4715
|
-
name: string;
|
|
4716
|
-
items: {
|
|
4717
|
-
type: string;
|
|
4718
|
-
name: string;
|
|
4719
|
-
inputs: {
|
|
4720
|
-
name: string;
|
|
4721
|
-
type: string;
|
|
4722
|
-
}[];
|
|
4723
|
-
outputs: {
|
|
4724
|
-
type: string;
|
|
4725
|
-
}[];
|
|
4726
|
-
state_mutability: string;
|
|
4727
|
-
}[];
|
|
4728
|
-
interface_name?: undefined;
|
|
4729
|
-
members?: undefined;
|
|
4730
|
-
variants?: undefined;
|
|
4731
|
-
inputs?: undefined;
|
|
4732
|
-
kind?: undefined;
|
|
4733
|
-
} | {
|
|
4734
|
-
type: string;
|
|
4735
|
-
name: string;
|
|
4736
|
-
inputs: {
|
|
4737
|
-
name: string;
|
|
4738
|
-
type: string;
|
|
4739
|
-
}[];
|
|
4740
|
-
interface_name?: undefined;
|
|
4741
|
-
members?: undefined;
|
|
4742
|
-
variants?: undefined;
|
|
4743
|
-
items?: undefined;
|
|
4744
|
-
kind?: undefined;
|
|
4745
|
-
} | {
|
|
4746
|
-
type: string;
|
|
4747
|
-
name: string;
|
|
4748
|
-
kind: string;
|
|
4749
|
-
members: {
|
|
4750
|
-
name: string;
|
|
4751
|
-
type: string;
|
|
4752
|
-
kind: string;
|
|
4753
|
-
}[];
|
|
4754
|
-
interface_name?: undefined;
|
|
4755
|
-
variants?: undefined;
|
|
4756
|
-
items?: undefined;
|
|
4757
|
-
inputs?: undefined;
|
|
4758
|
-
} | {
|
|
4759
|
-
type: string;
|
|
4760
|
-
name: string;
|
|
4761
|
-
kind: string;
|
|
4762
|
-
variants: {
|
|
4763
|
-
name: string;
|
|
4764
|
-
type: string;
|
|
4765
|
-
kind: string;
|
|
4766
|
-
}[];
|
|
4767
|
-
interface_name?: undefined;
|
|
4768
|
-
members?: undefined;
|
|
4769
|
-
items?: undefined;
|
|
4770
|
-
inputs?: undefined;
|
|
4771
|
-
})[];
|
|
4772
|
-
};
|
|
4773
|
-
};
|
|
4774
|
-
|
|
4775
|
-
/**
|
|
4776
|
-
* Function to return formatted amount to BigInt
|
|
4777
|
-
* Converts a decimal amount to the proper format for blockchain transactions
|
|
4778
|
-
* @param {number} amount - The decimal amount to convert
|
|
4779
|
-
* @param {number} fromTokenDecimals - The decimal precision of the token
|
|
4780
|
-
* @returns {string} The formatted amount as a hexadecimal string
|
|
4781
|
-
*/
|
|
4782
|
-
declare const returnFormattedAmount: (amount: number, toTokenDecimals: number) => string;
|
|
4783
|
-
/**
|
|
4784
|
-
* calculates the amount to distribute to Extended and Vesu
|
|
4785
|
-
* Determines how much to allocate to each platform based on leverage calculations
|
|
4786
|
-
* @param {number} amount - The total amount to distribute
|
|
4787
|
-
* @returns {object} Object containing avnu_amount, extended_amount, and extended_leverage
|
|
4788
|
-
*/
|
|
4789
|
-
declare const calculateAmountDistribution: (amountToInvest: number, collateralPrice: number, // in usd
|
|
4790
|
-
collateralUnits: Web3Number, // existing collateral in vesu (e.g. BTC)
|
|
4791
|
-
extendedExposureUsd: Web3Number) => {
|
|
4792
|
-
vesuAmount: Web3Number;
|
|
4793
|
-
extendedAmount: Web3Number;
|
|
4794
|
-
extendedLeverage: number;
|
|
4795
|
-
vesuLeverage: number;
|
|
4796
|
-
};
|
|
4797
|
-
/**
|
|
4798
|
-
* calculate the amount distribution for withdrawal
|
|
4799
|
-
* @param amount - The amount to withdraw
|
|
4800
|
-
* @param client - The client
|
|
4801
|
-
* @param marketName - The market name
|
|
4802
|
-
* @returns {object} Object containing avnu_amount and extended_amount
|
|
4803
|
-
*/
|
|
4804
|
-
declare const calculateAmountDistributionForWithdrawal: (amountInUsdc: Web3Number, collateralPrice: number, collateralUnits: Web3Number, extendedPosition: Position[] | null) => Promise<{
|
|
4805
|
-
vesu_amount: Web3Number;
|
|
4806
|
-
extended_amount: Web3Number;
|
|
4807
|
-
extended_leverage: number;
|
|
4808
|
-
vesu_leverage: number;
|
|
4809
|
-
} | null>;
|
|
4810
|
-
/**
|
|
4811
|
-
* calculate the leverage required for Avnu
|
|
4812
|
-
* calculates the optimal leverage for Avnu based on LTV ratios and price drop protection
|
|
4813
|
-
* @returns {number} The calculated leverage value
|
|
4814
|
-
*/
|
|
4815
|
-
declare const calculateVesuLeverage: () => number;
|
|
4816
|
-
/**
|
|
4817
|
-
* calculate leverage for extended
|
|
4818
|
-
* calculates the maximum safe leverage for Extended based on maintenance margin and price drop protection
|
|
4819
|
-
* @returns {number} The calculated leverage value
|
|
4820
|
-
*/
|
|
4821
|
-
declare const calculateExtendedLevergae: () => number;
|
|
4822
|
-
/**
|
|
4823
|
-
* calculates the debt amount for leverage operations
|
|
4824
|
-
* Determines how much debt to add or remove based on collateral changes and target health factor
|
|
4825
|
-
* @param {Web3Number} collateralAmount - Current collateral amount
|
|
4826
|
-
* @param {Web3Number} debtAmount - Current debt amount
|
|
4827
|
-
* @param {number} debtPrice - Current price of the debt token
|
|
4828
|
-
* @param {number} maxLtv - Maximum loan-to-value ratio (default: MAX_LTV_BTC_USDC)
|
|
4829
|
-
* @param {number} addedAmount - Amount being added to collateral
|
|
4830
|
-
* @param {number} collateralPrice - Current price of the collateral token
|
|
4831
|
-
* @param {boolean} isDeposit - Whether this is a deposit (true) or withdrawal (false)
|
|
4832
|
-
* @returns {object} Object containing deltadebtAmountUnits and isIncrease flag
|
|
4833
|
-
*/
|
|
4834
|
-
declare const calculateDebtAmount: (collateralAmount: Web3Number, debtAmount: Web3Number, debtPrice: number, maxLtv: number | undefined, addedAmount: Web3Number, // this is in btc
|
|
4835
|
-
collateralPrice: number, isDeposit: boolean, targetLtv?: number) => {
|
|
4836
|
-
deltadebtAmountUnits: Web3Number;
|
|
4837
|
-
isIncrease: boolean;
|
|
4838
|
-
} | {
|
|
4839
|
-
deltadebtAmountUnits: null;
|
|
4840
|
-
isIncrease: null;
|
|
4841
|
-
};
|
|
4842
|
-
/**
|
|
4843
|
-
* calculate the debt amount to be repaid for withdrawal
|
|
4844
|
-
* @param debtAmount in debt units
|
|
4845
|
-
* @param collateralAmount in collateral units
|
|
4846
|
-
* @param maxLtv in percentage
|
|
4847
|
-
* @param withdrawalAmount in collateral units
|
|
4848
|
-
* @param collateralPrice in usd
|
|
4849
|
-
* @param debtPrice in usd
|
|
4850
|
-
* @returns deltadebtAmountUnits in debt units
|
|
4851
|
-
* isIncrease: true if the debt amount is increasing, false if it is decreasing
|
|
4852
|
-
*/
|
|
4853
|
-
declare const calculateDebtReductionAmountForWithdrawal: (debtAmount: Web3Number, collateralAmount: Web3Number, maxLtv: number | undefined, withdrawalAmount: Web3Number, collateralPrice: number, debtPrice: number, usdcDecimals: number) => {
|
|
4854
|
-
deltadebtAmountUnits: string;
|
|
4855
|
-
} | {
|
|
4856
|
-
deltadebtAmountUnits: null;
|
|
4857
|
-
};
|
|
4858
|
-
/**
|
|
4859
|
-
* calculate the amount to deposit on extended when incurring losses
|
|
4860
|
-
* @param client - The client
|
|
4861
|
-
* @returns The amount to deposit on extended when incurring losses
|
|
4862
|
-
*/
|
|
4863
|
-
declare const calculateAmountDepositOnExtendedWhenIncurringLosses: (client: ExtendedWrapper) => Promise<Web3Number | null>;
|
|
4864
|
-
/**
|
|
4865
|
-
* calculate the amount of collateral to deposit to maintain the ltv
|
|
4866
|
-
* The formula is:
|
|
4867
|
-
* ((debt * debtPrice * targetHF) - (collateral * collateralPrice * ltv)) / ltv
|
|
4868
|
-
* @param collateralAmount in collateral units
|
|
4869
|
-
* @param debtAmount in debt units
|
|
4870
|
-
* @param debtPrice in usd
|
|
4871
|
-
* @param maxLtv
|
|
4872
|
-
* @param collateralPrice in usd
|
|
4873
|
-
* @param targetHF
|
|
4874
|
-
* @returns deltaCollateralAmountUnits in collateral units
|
|
4875
|
-
* null if there is an error
|
|
4876
|
-
*/
|
|
4877
|
-
declare const calculateWBTCAmountToMaintainLTV: (collateralAmount: Web3Number, debtAmount: Web3Number, debtPrice: number, maxLtv: number | undefined, collateralPrice: number) => {
|
|
4878
|
-
deltaCollateralAmountUnits: Web3Number;
|
|
4879
|
-
} | {
|
|
4880
|
-
deltaCollateralAmountUnits: null;
|
|
4881
|
-
};
|
|
4882
|
-
declare const calculateExposureDelta: (exposure_extended: number, exposure_vesu: number) => number;
|
|
4883
|
-
/**
|
|
4884
|
-
* calculate the delta percentage between the current btc price and the last btc price
|
|
4885
|
-
* @param {number} btcPrice - The current btc price
|
|
4886
|
-
* @param {number} lastBtcPrice - The last btc price
|
|
4887
|
-
* @returns {number} The delta percentage
|
|
4888
|
-
*/
|
|
4889
|
-
declare const calculateBTCPriceDelta: (btcPrice: number, lastBtcPrice: number) => number;
|
|
4890
|
-
declare const calculateVesUPositionSizeGivenExtended: (extendedPositonSize: number, extendedHoldingAmount: Web3Number, collateralAmount: Web3Number, extendedBtcPrice: number) => {
|
|
4891
|
-
vesuAmountInBTC: Web3Number;
|
|
4892
|
-
extendedAmountInBTC: Web3Number;
|
|
4893
|
-
};
|
|
4894
|
-
/**
|
|
4895
|
-
* calculate the debt amount to be repaid to maintain the ltv
|
|
4896
|
-
* @param maxLtv - The maximum ltv
|
|
4897
|
-
* @param existingVesuCollateral - The existing vesu collateral
|
|
4898
|
-
* @param existingVesuDebt - The existing vesu debt
|
|
4899
|
-
* @param collateralPrice - The collateral price
|
|
4900
|
-
* @param debtPrice - The debt price
|
|
4901
|
-
* @param targetHf - The target hf
|
|
4902
|
-
* @@dev returns negative to represent debt to be repaid
|
|
4903
|
-
* @returns The debt amount to be repaid
|
|
4904
|
-
*/
|
|
4905
|
-
declare const calculateDeltaDebtAmount: (existingVesuCollateral: Web3Number, existingVesuDebt: Web3Number, debtPrice: number, collateralPrice: number) => {
|
|
4906
|
-
deltaDebt: Web3Number;
|
|
4907
|
-
shouldRebalance: boolean;
|
|
4908
|
-
};
|
|
4909
|
-
declare const calculatePositionToCloseToWithdrawAmount: (extendedBalance: Balance, extendedPositions: Position, amountToWithdraw: Web3Number) => Promise<Web3Number>;
|
|
2829
|
+
declare const BoostedxSTRKCarryStrategies: IStrategyMetadata<BoostedxSTRKCarryStrategySettings>[];
|
|
4910
2830
|
|
|
4911
2831
|
/**
|
|
4912
2832
|
* Filter option definition
|
|
@@ -4932,7 +2852,9 @@ declare enum StrategyType {
|
|
|
4932
2852
|
UNIVERSAL = "universal",
|
|
4933
2853
|
HYPER_LST = "hyper-lst",
|
|
4934
2854
|
VESU_REBALANCE = "vesu-rebalance",
|
|
4935
|
-
SENSEI = "sensei"
|
|
2855
|
+
SENSEI = "sensei",
|
|
2856
|
+
YOLO_VAULT = "yolo-vault",
|
|
2857
|
+
BOOSTEDXSTRKCARRY = "boostedxstrkcarry"
|
|
4936
2858
|
}
|
|
4937
2859
|
/**
|
|
4938
2860
|
* Strategy metadata extracted from IStrategyMetadata
|
|
@@ -4983,10 +2905,12 @@ declare enum FactoryStrategyType {
|
|
|
4983
2905
|
EKUBO_CL = "EKUBO_CL",
|
|
4984
2906
|
HYPER_LST = "HYPER_LST",
|
|
4985
2907
|
VESU_REBALANCE = "VESU_REBALANCE",
|
|
4986
|
-
SENSEI = "SENSEI"
|
|
2908
|
+
SENSEI = "SENSEI",
|
|
2909
|
+
YOLO_VAULT = "YOLO_VAULT"
|
|
4987
2910
|
}
|
|
4988
2911
|
declare function createUniversalStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<UniversalStrategySettings>): UniversalStrategy<UniversalStrategySettings>;
|
|
4989
2912
|
declare function createEkuboCLStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>): EkuboCLVault;
|
|
2913
|
+
declare function createYoloVaultStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<YoloVaultSettings>): YoLoVault;
|
|
4990
2914
|
declare function createHyperLSTStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<HyperLSTStrategySettings>): UniversalLstMultiplierStrategy<HyperLSTStrategySettings>;
|
|
4991
2915
|
declare function createVesuRebalanceStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>): VesuRebalance;
|
|
4992
2916
|
declare function createSenseiStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>): SenseiVault;
|
|
@@ -4997,7 +2921,7 @@ declare function getStrategyTypeFromMetadata(metadata: IStrategyMetadata<any>):
|
|
|
4997
2921
|
/**
|
|
4998
2922
|
* Generic factory function that creates SDK strategy instances based on type
|
|
4999
2923
|
*/
|
|
5000
|
-
declare function createStrategy(type: FactoryStrategyType, config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<any>): EkuboCLVault | VesuRebalance | SenseiVault | UniversalStrategy<UniversalStrategySettings> | UniversalLstMultiplierStrategy<HyperLSTStrategySettings>;
|
|
2924
|
+
declare function createStrategy(type: FactoryStrategyType, config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<any>): EkuboCLVault | VesuRebalance | SenseiVault | YoLoVault | UniversalStrategy<UniversalStrategySettings> | UniversalLstMultiplierStrategy<HyperLSTStrategySettings>;
|
|
5001
2925
|
|
|
5002
2926
|
interface EkuboRouteNode {
|
|
5003
2927
|
pool_key: {
|
|
@@ -5204,6 +3128,16 @@ declare class Midas {
|
|
|
5204
3128
|
} | number>;
|
|
5205
3129
|
}
|
|
5206
3130
|
|
|
3131
|
+
declare class EkuboPricer extends PricerBase {
|
|
3132
|
+
EKUBO_PRICE_FETCHER_ADDRESS: string;
|
|
3133
|
+
readonly contract: Contract;
|
|
3134
|
+
private readonly USDC_ADDRESS;
|
|
3135
|
+
private readonly USDC_DECIMALS;
|
|
3136
|
+
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
3137
|
+
private div2Power128;
|
|
3138
|
+
getPrice(tokenAddr: string, blockIdentifier?: BlockIdentifier): Promise<PriceInfo>;
|
|
3139
|
+
}
|
|
3140
|
+
|
|
5207
3141
|
declare class TelegramNotif {
|
|
5208
3142
|
private subscribers;
|
|
5209
3143
|
readonly bot: TelegramBot;
|
|
@@ -5356,4 +3290,4 @@ declare class PasswordJsonCryptoUtil {
|
|
|
5356
3290
|
decrypt(encryptedData: string, password: string): any;
|
|
5357
3291
|
}
|
|
5358
3292
|
|
|
5359
|
-
export { type APYInfo, APYType, AUDIT_URL, AUMTypes, AVNU_EXCHANGE, AVNU_EXCHANGE_FOR_LEGACY_USDC, AVNU_LEGACY_SANITIZER, AVNU_MIDDLEWARE, AVNU_QUOTE_URL,
|
|
3293
|
+
export { type APYInfo, APYType, AUDIT_URL, AUMTypes, AVNU_EXCHANGE, AVNU_EXCHANGE_FOR_LEGACY_USDC, AVNU_LEGACY_SANITIZER, AVNU_MIDDLEWARE, AVNU_QUOTE_URL, type AccessControlInfo, AccessControlType, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type AmountInfo, type AmountsInfo, type ApproveCallParams, AuditStatus, AutoCompounderSTRK, AvnuAdapter, type AvnuAdapterConfig, type AvnuDepositParams, type AvnuSwapCallParams, type AvnuWithdrawParams, AvnuWrapper, BaseAdapter, type BaseAdapterConfig, BaseStrategy, BoostedxSTRKCarryStrategies, BoostedxSTRKCarryStrategy, type BoostedxSTRKCarryStrategySettings, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, DEFAULT_TROVES_STRATEGIES_API, type DecreaseLeverParams, Deployer, type DepositParams, type DualActionAmount, type DualTokenInfo, ERC20, EXTENDED_CONTRACT, EXTENDED_SANITIZER, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, EkuboPricer, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FactoryStrategyType, FatalError, type FilterOption, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HealthFactorMath, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type ICurator, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, type InputModeFromAction, InstantWithdrawalVault, LSTAPRService, LSTPriceType, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type LoggerConfig, type LoggerLevel, type ManageCall, MarginType, Midas, MyNumber, type NetAPYDetails, type NetAPYSplit, Network, PRICE_ROUTER, type ParsedStarknetCall, PasswordJsonCryptoUtil, type PositionAPY, type PositionAmount, type PositionInfo, PositionTypeAvnuExtended, Pragma, type PriceInfo, Pricer, PricerBase, PricerFromApi, PricerLST, PricerRedis, Protocols, type RedemptionInfo, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SVK_SIMPLE_SANITIZER, type SecurityMetadata, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, type SourceCodeInfo, SourceCodeType, StandardMerkleTree, type StandardMerkleTreeData, StarknetCallParser, type StarknetCallParserOptions, Store, type StoreConfig, type StrategyAlert, type StrategyApyHistoryUIConfig, type StrategyCapabilities, type StrategyFilterMetadata, type StrategyInputMode, StrategyLiveStatus, type StrategyMetadata, type StrategyRegistryEntry, type StrategySettings, StrategyTag, StrategyType, type SupportedPosition, SvkTrovesAdapter, type SvkTrovesAdapterConfig, type Swap, type SwapInfo, type SwapPriceInfo, TRANSFER_SANITIZER, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo, TokenMarketData, TokenTransferAdapter, type TokenTransferAdapterConfig, UNIVERSAL_ADAPTER_IDS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, UnwrapLabsCurator, type UserPositionCard, type UserPositionCardSubValueColor, type UserPositionCardsInput, type UserYoloInfo, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VaultType, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, type VesuDefiSpringRewardsCallParams, type VesuDepositParams, type VesuModifyDelegationCallParams, VesuModifyPositionAdapter, type VesuModifyPositionAdapterConfig, type VesuModifyPositionCallParams, type VesuModifyPositionDepositParams, type VesuModifyPositionWithdrawParams, VesuMultiplyAdapter, type VesuMultiplyAdapterConfig, type VesuMultiplyCallParams, VesuPoolMetadata, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, VesuSupplyOnlyAdapter, type VesuSupplyOnlyAdapterConfig, type VesuWithdrawParams, Web3Number, type WithdrawParams, YoLoVault, type YoloSettings, type YoloSpendingLevel, type YoloVaultSettings, type YoloVaultStatus, YoloVaultStrategies, ZkLend, _riskFactor, assert, buildStrategyRegistry, configureLogger, createEkuboCLStrategy, createHyperLSTStrategy, createSenseiStrategy, createStrategy, createUniversalStrategy, createVesuRebalanceStrategy, createYoloVaultStrategy, detectCapabilities, extensionMap, getAPIUsingHeadlessBrowser, getAllStrategyMetadata, getAllStrategyTags, getContractDetails, getDefaultStoreConfig, getFAQs, getFilterMetadata, getInvestmentSteps, getLiveStrategies, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getStrategiesByType, getStrategyTagDesciption, getStrategyTypeFromMetadata, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, isDualTokenStrategy, logger, toAmountsInfo, toBigInt };
|