@strkfarm/sdk 2.0.0-dev.26 → 2.0.0-dev.28
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 +190 -36
- package/dist/cli.mjs +188 -34
- package/dist/index.browser.global.js +79130 -49354
- package/dist/index.browser.mjs +18039 -11431
- package/dist/index.d.ts +2869 -898
- package/dist/index.js +19036 -12207
- package/dist/index.mjs +18942 -12158
- package/package.json +1 -1
- package/src/data/avnu.abi.json +840 -0
- package/src/data/ekubo-price-fethcer.abi.json +265 -0
- package/src/dataTypes/_bignumber.ts +13 -4
- package/src/dataTypes/index.ts +3 -2
- package/src/dataTypes/mynumber.ts +141 -0
- package/src/global.ts +76 -41
- package/src/index.browser.ts +2 -1
- package/src/interfaces/common.tsx +167 -2
- package/src/modules/ExtendedWrapperSDk/types.ts +26 -4
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +110 -67
- package/src/modules/apollo-client-config.ts +28 -0
- package/src/modules/avnu.ts +4 -4
- package/src/modules/ekubo-pricer.ts +79 -0
- package/src/modules/ekubo-quoter.ts +46 -30
- package/src/modules/erc20.ts +17 -0
- package/src/modules/harvests.ts +43 -29
- package/src/modules/pragma.ts +23 -8
- package/src/modules/pricer-from-api.ts +156 -15
- package/src/modules/pricer-lst.ts +1 -1
- package/src/modules/pricer.ts +40 -4
- package/src/modules/pricerBase.ts +2 -1
- package/src/node/deployer.ts +36 -1
- package/src/node/pricer-redis.ts +2 -1
- package/src/strategies/base-strategy.ts +78 -10
- package/src/strategies/ekubo-cl-vault.tsx +906 -347
- package/src/strategies/factory.ts +159 -0
- package/src/strategies/index.ts +6 -1
- package/src/strategies/registry.ts +239 -0
- package/src/strategies/sensei.ts +335 -7
- package/src/strategies/svk-strategy.ts +97 -27
- package/src/strategies/types.ts +4 -0
- package/src/strategies/universal-adapters/adapter-utils.ts +2 -1
- package/src/strategies/universal-adapters/avnu-adapter.ts +177 -268
- package/src/strategies/universal-adapters/baseAdapter.ts +263 -251
- package/src/strategies/universal-adapters/common-adapter.ts +206 -203
- package/src/strategies/universal-adapters/extended-adapter.ts +155 -336
- package/src/strategies/universal-adapters/index.ts +9 -8
- package/src/strategies/universal-adapters/token-transfer-adapter.ts +200 -0
- package/src/strategies/universal-adapters/usdc<>usdce-adapter.ts +200 -0
- package/src/strategies/universal-adapters/vesu-adapter.ts +110 -75
- package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +476 -0
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +762 -844
- package/src/strategies/universal-adapters/vesu-position-common.ts +251 -0
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +18 -3
- package/src/strategies/universal-lst-muliplier-strategy.tsx +396 -204
- package/src/strategies/universal-strategy.tsx +1426 -1178
- package/src/strategies/vesu-extended-strategy/services/executionService.ts +2251 -0
- package/src/strategies/vesu-extended-strategy/services/extended-vesu-state-manager.ts +2941 -0
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +12 -1
- package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +52 -0
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +1 -0
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +3 -1
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +158 -124
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +377 -1781
- package/src/strategies/vesu-rebalance.tsx +255 -152
- package/src/utils/health-factor-math.ts +4 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/logger.browser.ts +22 -4
- package/src/utils/logger.node.ts +259 -24
- package/src/utils/starknet-call-parser.ts +1036 -0
- package/src/utils/strategy-utils.ts +61 -0
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
1
|
import * as starknet from 'starknet';
|
|
3
|
-
import { RpcProvider, BlockIdentifier, Contract,
|
|
2
|
+
import { RpcProvider, BlockIdentifier, Call, Contract, Uint256, Account, CairoCustomEnum, RawArgs } from 'starknet';
|
|
3
|
+
import BigNumber from 'bignumber.js';
|
|
4
4
|
import React, { ReactNode } from 'react';
|
|
5
|
+
import { Quote, AvnuOptions } from '@avnu/avnu-sdk';
|
|
5
6
|
import { HexString, BytesLike } from '@ericnordelo/strk-merkle-tree/dist/bytes';
|
|
6
7
|
import { MultiProof } from '@ericnordelo/strk-merkle-tree/dist/core';
|
|
7
8
|
import { MerkleTreeImpl, MerkleTreeData } from '@ericnordelo/strk-merkle-tree/dist/merkletree';
|
|
8
9
|
import { MerkleTreeOptions } from '@ericnordelo/strk-merkle-tree/dist/options';
|
|
9
10
|
import { ValueType } from '@ericnordelo/strk-merkle-tree/dist/serde';
|
|
10
|
-
import { Quote, AvnuOptions } from '@avnu/avnu-sdk';
|
|
11
11
|
import TelegramBot from 'node-telegram-bot-api';
|
|
12
12
|
|
|
13
13
|
declare class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
|
|
@@ -27,10 +27,12 @@ declare class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
|
|
|
27
27
|
minimum(value: string | number | T): T;
|
|
28
28
|
maximum(value: string | number | T): T;
|
|
29
29
|
abs(): T;
|
|
30
|
+
toFixedRoundDown(dp?: number): string;
|
|
30
31
|
toI129(): {
|
|
31
32
|
mag: bigint;
|
|
32
33
|
sign: 0 | 1;
|
|
33
34
|
};
|
|
35
|
+
toUint256(): starknet.Uint256;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
declare class Web3Number extends _Web3Number<Web3Number> {
|
|
@@ -54,6 +56,33 @@ declare class ContractAddr {
|
|
|
54
56
|
shortString(left?: number, right?: number): string;
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
declare const customInspectSymbol: unique symbol;
|
|
60
|
+
declare class MyNumber {
|
|
61
|
+
bigNumber: BigNumber;
|
|
62
|
+
decimals: number;
|
|
63
|
+
constructor(bigNumber: string, decimals: number);
|
|
64
|
+
static fromEther(num: string, decimals: number): MyNumber;
|
|
65
|
+
static fromZero(): MyNumber;
|
|
66
|
+
toString(): string;
|
|
67
|
+
toEtherStr(): string;
|
|
68
|
+
toFixedStr(decimals: number): string;
|
|
69
|
+
toEtherToFixedDecimals(decimals: number): string;
|
|
70
|
+
isZero(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param amountEther in token terms without decimal e.g. 1 for 1 STRK
|
|
74
|
+
* @param command BigNumber compare funds. e.g. gte, gt, lt
|
|
75
|
+
* @returns
|
|
76
|
+
* @dev Add more commands as needed
|
|
77
|
+
*/
|
|
78
|
+
compare(amountEther: string, command: "gte" | "gt" | "lt"): boolean;
|
|
79
|
+
operate(command: "div" | "plus" | "mul", value: string | number): MyNumber;
|
|
80
|
+
subtract(value: MyNumber): MyNumber;
|
|
81
|
+
static min(a: MyNumber, b: MyNumber): MyNumber;
|
|
82
|
+
static max(a: MyNumber, b: MyNumber): MyNumber;
|
|
83
|
+
[customInspectSymbol](depth: any, inspectOptions: any, inspect: any): string;
|
|
84
|
+
}
|
|
85
|
+
|
|
57
86
|
declare enum RiskType {
|
|
58
87
|
MARKET_RISK = "Market Risk",
|
|
59
88
|
IMPERMANENT_LOSS = "Impermanent Loss Risk",
|
|
@@ -97,6 +126,56 @@ interface IProtocol {
|
|
|
97
126
|
name: string;
|
|
98
127
|
logo: string;
|
|
99
128
|
}
|
|
129
|
+
declare enum StrategyTag {
|
|
130
|
+
META_VAULT = "Meta Vaults",
|
|
131
|
+
LEVERED = "Maxx",
|
|
132
|
+
AUTOMATED_LP = "Ekubo",
|
|
133
|
+
BTC = "BTC"
|
|
134
|
+
}
|
|
135
|
+
declare enum VaultType {
|
|
136
|
+
LOOPING = "Looping",
|
|
137
|
+
META_VAULT = "Meta Vault",
|
|
138
|
+
DELTA_NEUTRAL = "Delta Neutral",
|
|
139
|
+
AUTOMATED_LP = "Automated LP"
|
|
140
|
+
}
|
|
141
|
+
declare enum AuditStatus {
|
|
142
|
+
AUDITED = "Audited",
|
|
143
|
+
NOT_AUDITED = "Not Audited"
|
|
144
|
+
}
|
|
145
|
+
declare enum SourceCodeType {
|
|
146
|
+
OPEN_SOURCE = "Open Source",
|
|
147
|
+
CLOSED_SOURCE = "Closed Source"
|
|
148
|
+
}
|
|
149
|
+
declare enum AccessControlType {
|
|
150
|
+
MULTISIG_ACCOUNT = "Multisig Account",
|
|
151
|
+
STANDARD_ACCOUNT = "Standard Account"
|
|
152
|
+
}
|
|
153
|
+
declare enum InstantWithdrawalVault {
|
|
154
|
+
YES = "Yes",
|
|
155
|
+
NO = "No"
|
|
156
|
+
}
|
|
157
|
+
interface SourceCodeInfo {
|
|
158
|
+
type: SourceCodeType;
|
|
159
|
+
contractLink: string;
|
|
160
|
+
}
|
|
161
|
+
interface AccessControlInfo {
|
|
162
|
+
type: AccessControlType;
|
|
163
|
+
addresses: ContractAddr[];
|
|
164
|
+
timeLock: string;
|
|
165
|
+
}
|
|
166
|
+
interface SecurityMetadata {
|
|
167
|
+
auditStatus: AuditStatus;
|
|
168
|
+
sourceCode: SourceCodeInfo;
|
|
169
|
+
accessControl: AccessControlInfo;
|
|
170
|
+
}
|
|
171
|
+
interface RedemptionInfo {
|
|
172
|
+
instantWithdrawalVault: InstantWithdrawalVault;
|
|
173
|
+
redemptionsInfo: {
|
|
174
|
+
title: string;
|
|
175
|
+
description: string;
|
|
176
|
+
}[];
|
|
177
|
+
alerts: StrategyAlert[];
|
|
178
|
+
}
|
|
100
179
|
declare enum FlowChartColors {
|
|
101
180
|
Green = "purple",
|
|
102
181
|
Blue = "#35484f",
|
|
@@ -106,26 +185,62 @@ interface FAQ {
|
|
|
106
185
|
question: string | React.ReactNode;
|
|
107
186
|
answer: string | React.ReactNode;
|
|
108
187
|
}
|
|
188
|
+
declare enum StrategyLiveStatus {
|
|
189
|
+
ACTIVE = "Active",
|
|
190
|
+
NEW = "New",
|
|
191
|
+
COMING_SOON = "Coming Soon",
|
|
192
|
+
DEPRECATED = "Deprecated",// active but not recommended
|
|
193
|
+
RETIRED = "Retired",// not active anymore
|
|
194
|
+
HOT = "Hot & New \uD83D\uDD25"
|
|
195
|
+
}
|
|
196
|
+
interface StrategyAlert {
|
|
197
|
+
type: "warning" | "info";
|
|
198
|
+
text: string | React.ReactNode;
|
|
199
|
+
tab: "all" | "deposit" | "withdraw";
|
|
200
|
+
}
|
|
201
|
+
interface StrategySettings {
|
|
202
|
+
maxTVL?: Web3Number;
|
|
203
|
+
liveStatus?: StrategyLiveStatus;
|
|
204
|
+
isPaused?: boolean;
|
|
205
|
+
isInMaintenance?: boolean;
|
|
206
|
+
isAudited: boolean;
|
|
207
|
+
isInstantWithdrawal?: boolean;
|
|
208
|
+
hideHarvestInfo?: boolean;
|
|
209
|
+
is_promoted?: boolean;
|
|
210
|
+
isTransactionHistDisabled?: boolean;
|
|
211
|
+
quoteToken: TokenInfo;
|
|
212
|
+
hideNetEarnings?: boolean;
|
|
213
|
+
showWithdrawalWarningModal?: boolean;
|
|
214
|
+
alerts?: StrategyAlert[];
|
|
215
|
+
tags?: StrategyTag[];
|
|
216
|
+
}
|
|
109
217
|
/**
|
|
110
218
|
* @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
|
|
111
219
|
* @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
|
|
220
|
+
* @property security - Security-related metadata including audit status, source code information, and access control details.
|
|
221
|
+
* @property redemptionInfo - Redemption information including instant withdrawal availability and expected redemption times.
|
|
112
222
|
*/
|
|
113
223
|
interface IStrategyMetadata<T> {
|
|
224
|
+
id: string;
|
|
114
225
|
name: string;
|
|
115
226
|
description: string | React.ReactNode;
|
|
116
227
|
address: ContractAddr;
|
|
117
228
|
launchBlock: number;
|
|
118
229
|
type: "ERC4626" | "ERC721" | "Other";
|
|
230
|
+
vaultType: {
|
|
231
|
+
type: VaultType;
|
|
232
|
+
description: string;
|
|
233
|
+
};
|
|
119
234
|
depositTokens: TokenInfo[];
|
|
120
235
|
protocols: IProtocol[];
|
|
121
236
|
auditUrl?: string;
|
|
122
|
-
maxTVL: Web3Number;
|
|
123
237
|
risk: {
|
|
124
238
|
riskFactor: RiskFactor[];
|
|
125
239
|
netRisk: number;
|
|
126
240
|
notARisks: RiskType[];
|
|
127
241
|
};
|
|
128
242
|
apyMethodology?: string;
|
|
243
|
+
realizedAPYMethodology?: string;
|
|
129
244
|
additionalInfo: T;
|
|
130
245
|
contractDetails: {
|
|
131
246
|
address: ContractAddr;
|
|
@@ -145,6 +260,36 @@ interface IStrategyMetadata<T> {
|
|
|
145
260
|
logo: string;
|
|
146
261
|
};
|
|
147
262
|
isPreview?: boolean;
|
|
263
|
+
tags?: StrategyTag[];
|
|
264
|
+
security: SecurityMetadata;
|
|
265
|
+
redemptionInfo: RedemptionInfo;
|
|
266
|
+
usualTimeToEarnings: null | string;
|
|
267
|
+
usualTimeToEarningsDescription: null | string;
|
|
268
|
+
discontinuationInfo?: {
|
|
269
|
+
date?: Date;
|
|
270
|
+
reason?: React.ReactNode | string;
|
|
271
|
+
info?: React.ReactNode | string;
|
|
272
|
+
};
|
|
273
|
+
settings?: StrategySettings;
|
|
274
|
+
actions?: Array<{
|
|
275
|
+
name?: string;
|
|
276
|
+
pool?: {
|
|
277
|
+
protocol?: {
|
|
278
|
+
name: string;
|
|
279
|
+
logo: string;
|
|
280
|
+
};
|
|
281
|
+
pool?: {
|
|
282
|
+
name: string;
|
|
283
|
+
logos?: string[];
|
|
284
|
+
};
|
|
285
|
+
apr?: number;
|
|
286
|
+
borrow?: {
|
|
287
|
+
apr?: number;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
amount?: string | number;
|
|
291
|
+
isDeposit?: boolean;
|
|
292
|
+
}>;
|
|
148
293
|
}
|
|
149
294
|
interface IInvestmentFlow {
|
|
150
295
|
id?: string;
|
|
@@ -157,6 +302,8 @@ interface IInvestmentFlow {
|
|
|
157
302
|
style?: any;
|
|
158
303
|
}
|
|
159
304
|
declare function getMainnetConfig(rpcUrl?: string, blockIdentifier?: BlockIdentifier): IConfig;
|
|
305
|
+
declare const getStrategyTagDesciption: (tag: StrategyTag) => string;
|
|
306
|
+
declare const getAllStrategyTags: () => StrategyTag[];
|
|
160
307
|
declare const getRiskExplaination: (riskType: RiskType) => "The risk of the market moving against the position." | "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them." | "The risk of losing funds due to the position being liquidated." | "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position." | "The risk of the oracle being manipulated or incorrect." | "The risk of the smart contract being vulnerable to attacks." | "The risk of technical issues e.g. backend failure." | "The risk of the counterparty defaulting e.g. bad debt on lending platforms." | "The risk of a token losing its peg to the underlying asset, leading to potential losses for holders.";
|
|
161
308
|
declare const getRiskColor: (risk: RiskFactor) => "light_green_2" | "yellow" | "red";
|
|
162
309
|
declare const getNoRiskTags: (risks: RiskFactor[]) => RiskType[];
|
|
@@ -172,6 +319,27 @@ interface VaultPosition {
|
|
|
172
319
|
remarks: string;
|
|
173
320
|
protocol: IProtocol;
|
|
174
321
|
}
|
|
322
|
+
interface AmountInfo {
|
|
323
|
+
amount: Web3Number;
|
|
324
|
+
usdValue: number;
|
|
325
|
+
tokenInfo: TokenInfo;
|
|
326
|
+
}
|
|
327
|
+
interface AmountsInfo {
|
|
328
|
+
usdValue: number;
|
|
329
|
+
amounts: AmountInfo[];
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Strategy capabilities interface
|
|
333
|
+
* Describes what optional methods a strategy instance supports
|
|
334
|
+
*/
|
|
335
|
+
interface StrategyCapabilities {
|
|
336
|
+
hasMatchInputAmounts: boolean;
|
|
337
|
+
hasNetAPY: boolean;
|
|
338
|
+
hasGetInvestmentFlows: boolean;
|
|
339
|
+
hasGetPendingRewards: boolean;
|
|
340
|
+
hasHarvest: boolean;
|
|
341
|
+
hasRebalance: boolean;
|
|
342
|
+
}
|
|
175
343
|
declare const Protocols: {
|
|
176
344
|
NONE: IProtocol;
|
|
177
345
|
VESU: IProtocol;
|
|
@@ -245,7 +413,7 @@ declare class Pricer extends PricerBase {
|
|
|
245
413
|
refreshInterval: number;
|
|
246
414
|
staleTime: number;
|
|
247
415
|
protected methodToUse: {
|
|
248
|
-
[tokenSymbol: string]: 'Ekubo' | 'Coinbase' | 'Coinmarketcap';
|
|
416
|
+
[tokenSymbol: string]: 'Ekubo' | 'Coinbase' | 'Coinmarketcap' | 'Avnu';
|
|
249
417
|
};
|
|
250
418
|
/**
|
|
251
419
|
* TOKENA and TOKENB are the two token names to get price of TokenA in terms of TokenB
|
|
@@ -258,11 +426,12 @@ declare class Pricer extends PricerBase {
|
|
|
258
426
|
start(): void;
|
|
259
427
|
isStale(timestamp: Date, tokenName: string): boolean;
|
|
260
428
|
assertNotStale(timestamp: Date, tokenName: string): void;
|
|
261
|
-
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
429
|
+
getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
|
|
262
430
|
protected _loadPrices(onUpdate?: (tokenSymbol: string) => void): void;
|
|
263
431
|
_getPrice(token: TokenInfo, defaultMethod?: string): Promise<number>;
|
|
264
432
|
_getPriceCoinbase(token: TokenInfo): Promise<number>;
|
|
265
433
|
_getPriceCoinMarketCap(token: TokenInfo): Promise<number>;
|
|
434
|
+
_getAvnuPrice(token: TokenInfo, amountIn?: Web3Number, retry?: number): Promise<number>;
|
|
266
435
|
_getPriceEkubo(token: TokenInfo, amountIn?: Web3Number, retry?: number): Promise<number>;
|
|
267
436
|
}
|
|
268
437
|
|
|
@@ -270,7 +439,7 @@ declare abstract class PricerBase {
|
|
|
270
439
|
readonly config: IConfig;
|
|
271
440
|
readonly tokens: TokenInfo[];
|
|
272
441
|
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
273
|
-
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
442
|
+
getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
|
|
274
443
|
}
|
|
275
444
|
|
|
276
445
|
interface CacheData$1 {
|
|
@@ -285,291 +454,314 @@ declare class CacheClass {
|
|
|
285
454
|
isCacheValid(key: string): boolean;
|
|
286
455
|
}
|
|
287
456
|
|
|
288
|
-
interface
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
457
|
+
interface HarvestInfo {
|
|
458
|
+
rewardsContract: ContractAddr;
|
|
459
|
+
token: ContractAddr;
|
|
460
|
+
startDate: Date;
|
|
461
|
+
endDate: Date;
|
|
462
|
+
claim: {
|
|
463
|
+
id: number;
|
|
464
|
+
amount: Web3Number;
|
|
465
|
+
claimee: ContractAddr;
|
|
466
|
+
};
|
|
467
|
+
actualReward: Web3Number;
|
|
468
|
+
proof: string[];
|
|
298
469
|
}
|
|
299
|
-
declare const logger: MyLogger;
|
|
300
470
|
|
|
301
|
-
interface
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
data: bigint[];
|
|
305
|
-
}
|
|
306
|
-
interface StandardMerkleTreeData<T extends any> extends MerkleTreeData<T> {
|
|
307
|
-
format: 'standard-v1';
|
|
308
|
-
leafEncoding: ValueType[];
|
|
471
|
+
interface SingleActionAmount {
|
|
472
|
+
tokenInfo: TokenInfo;
|
|
473
|
+
amount: Web3Number;
|
|
309
474
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
protected readonly values: StandardMerkleTreeData<LeafData>['values'];
|
|
313
|
-
protected readonly leafEncoding: ValueType[];
|
|
314
|
-
protected constructor(tree: HexString[], values: StandardMerkleTreeData<LeafData>['values'], leafEncoding: ValueType[]);
|
|
315
|
-
static of(values: LeafData[], leafEncoding?: ValueType[], options?: MerkleTreeOptions): StandardMerkleTree;
|
|
316
|
-
static verify<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], leaf: T, proof: BytesLike[]): boolean;
|
|
317
|
-
static verifyMultiProof<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], multiproof: MultiProof<BytesLike, T>): boolean;
|
|
318
|
-
dump(): StandardMerkleTreeData<LeafData>;
|
|
475
|
+
interface SingleTokenInfo extends SingleActionAmount {
|
|
476
|
+
usdValue: number;
|
|
319
477
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
[
|
|
326
|
-
}[keyof T];
|
|
327
|
-
declare function assert(condition: boolean, message: string): void;
|
|
328
|
-
declare function getTrovesEndpoint(): string;
|
|
329
|
-
|
|
330
|
-
interface ManageCall {
|
|
331
|
-
sanitizer: ContractAddr;
|
|
332
|
-
call: {
|
|
333
|
-
contractAddress: ContractAddr;
|
|
334
|
-
selector: string;
|
|
335
|
-
calldata: bigint[];
|
|
336
|
-
};
|
|
478
|
+
interface APYInfo {
|
|
479
|
+
net: number;
|
|
480
|
+
splits: {
|
|
481
|
+
apy: number;
|
|
482
|
+
id: string;
|
|
483
|
+
}[];
|
|
337
484
|
}
|
|
338
|
-
interface
|
|
339
|
-
|
|
485
|
+
interface DualActionAmount {
|
|
486
|
+
token0: SingleActionAmount;
|
|
487
|
+
token1: SingleActionAmount;
|
|
340
488
|
}
|
|
341
|
-
interface
|
|
342
|
-
|
|
489
|
+
interface DualTokenInfo {
|
|
490
|
+
usdValue: number;
|
|
491
|
+
token0: SingleTokenInfo;
|
|
492
|
+
token1: SingleTokenInfo;
|
|
343
493
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
callConstructor: GenerateCallFn<T>;
|
|
348
|
-
};
|
|
349
|
-
type LeafAdapterFn<T> = () => AdapterLeafType<T>;
|
|
350
|
-
declare enum APYType {
|
|
351
|
-
BASE = "base",
|
|
352
|
-
REWARD = "reward",
|
|
353
|
-
LST = "lst"
|
|
494
|
+
interface NetAPYSplit {
|
|
495
|
+
apy: number;
|
|
496
|
+
id: string;
|
|
354
497
|
}
|
|
355
|
-
interface
|
|
356
|
-
|
|
357
|
-
|
|
498
|
+
interface NetAPYDetails {
|
|
499
|
+
net: number;
|
|
500
|
+
splits: NetAPYSplit[];
|
|
358
501
|
}
|
|
359
|
-
interface
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
pricer: PricerBase;
|
|
364
|
-
vaultAllocator: ContractAddr;
|
|
365
|
-
vaultAddress: ContractAddr;
|
|
502
|
+
interface CacheData {
|
|
503
|
+
timestamp: number;
|
|
504
|
+
ttl: number;
|
|
505
|
+
data: any;
|
|
366
506
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
type PositionAmount = {
|
|
380
|
-
amount: Web3Number;
|
|
381
|
-
remarks: string;
|
|
382
|
-
};
|
|
383
|
-
declare abstract class BaseAdapter<DepositParams, WithdrawParams> extends CacheClass {
|
|
384
|
-
readonly name: string;
|
|
385
|
-
readonly config: BaseAdapterConfig;
|
|
386
|
-
readonly protocol: IProtocol;
|
|
387
|
-
constructor(config: BaseAdapterConfig, name: string, protocol: IProtocol);
|
|
507
|
+
declare class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
|
|
508
|
+
readonly config: IConfig;
|
|
509
|
+
readonly cache: Map<string, CacheData>;
|
|
510
|
+
constructor(config: IConfig);
|
|
511
|
+
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<TVLInfo>;
|
|
512
|
+
getTVL(): Promise<TVLInfo>;
|
|
513
|
+
depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Promise<Call[]>;
|
|
514
|
+
withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
515
|
+
getVaultPositions(): Promise<VaultPosition[]>;
|
|
516
|
+
netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number | NetAPYDetails>;
|
|
517
|
+
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
518
|
+
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
388
519
|
/**
|
|
389
|
-
*
|
|
520
|
+
* Calculate lifetime earnings for a user based on provided data from client
|
|
521
|
+
* Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
|
|
522
|
+
*
|
|
523
|
+
* @param userTVL - The user's current TVL (SingleTokenInfo with amount, usdValue, tokenInfo)
|
|
524
|
+
* @param investmentFlows - Array of investment flow transactions from client
|
|
525
|
+
* @returns Object containing lifetime earnings, current value, and total deposits/withdrawals
|
|
390
526
|
*/
|
|
391
|
-
|
|
527
|
+
getLifetimeEarnings(userTVL: SingleTokenInfo, investmentFlows: Array<{
|
|
528
|
+
amount: string;
|
|
529
|
+
type: string;
|
|
530
|
+
timestamp: number;
|
|
531
|
+
tx_hash: string;
|
|
532
|
+
}>): {
|
|
533
|
+
tokenInfo: SingleTokenInfo;
|
|
534
|
+
lifetimeEarnings: Web3Number;
|
|
535
|
+
currentValue: Web3Number;
|
|
536
|
+
totalDeposits: Web3Number;
|
|
537
|
+
totalWithdrawals: Web3Number;
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* TokenMarketData class that combines LST APR and Midas modules
|
|
543
|
+
* to provide unified APY, price, and TVL functions for tokens
|
|
544
|
+
*/
|
|
545
|
+
declare class TokenMarketData {
|
|
546
|
+
private pricer;
|
|
547
|
+
private config;
|
|
548
|
+
constructor(pricer: PricerBase, config: IConfig);
|
|
392
549
|
/**
|
|
393
|
-
*
|
|
550
|
+
* Get APY for a token
|
|
551
|
+
* - If it's an LST token, returns LST APY
|
|
552
|
+
* - If it's a Midas token, returns Midas APY
|
|
553
|
+
* - Otherwise returns 0
|
|
554
|
+
* @param tokenInfo The token to get APY for
|
|
555
|
+
* @returns APY in absolute terms (not percentage)
|
|
394
556
|
*/
|
|
395
|
-
|
|
557
|
+
getAPY(tokenInfo: TokenInfo): Promise<number>;
|
|
396
558
|
/**
|
|
397
|
-
*
|
|
559
|
+
* Get price for a token using the pricer module
|
|
560
|
+
* @param tokenInfo The token to get price for
|
|
561
|
+
* @returns Price as a number
|
|
562
|
+
* @throws Error if price is 0 or unavailable
|
|
398
563
|
*/
|
|
399
|
-
|
|
564
|
+
getPrice(tokenInfo: TokenInfo): Promise<number>;
|
|
400
565
|
/**
|
|
401
|
-
*
|
|
402
|
-
*
|
|
566
|
+
* Get true price for a token
|
|
567
|
+
* - For LST tokens: Uses convert_to_assets to get true exchange rate
|
|
568
|
+
* - For Midas tokens: Uses Midas price API
|
|
569
|
+
* - For other tokens: Falls back to regular pricer
|
|
570
|
+
* @param tokenInfo The token to get true price for
|
|
571
|
+
* @returns True price as a number
|
|
572
|
+
* @throws Error if price is 0 or unavailable
|
|
403
573
|
*/
|
|
404
|
-
|
|
574
|
+
getTruePrice(tokenInfo: TokenInfo): Promise<number>;
|
|
405
575
|
/**
|
|
406
|
-
*
|
|
576
|
+
* Get TVL for a token
|
|
577
|
+
* - If it's a Midas token, returns Midas TVL data
|
|
578
|
+
* - Otherwise returns 0
|
|
579
|
+
* @param tokenInfo The token to get TVL for
|
|
580
|
+
* @returns TVL as SingleTokenInfo or 0
|
|
407
581
|
*/
|
|
408
|
-
|
|
582
|
+
getTVL(tokenInfo: TokenInfo): Promise<SingleTokenInfo>;
|
|
409
583
|
/**
|
|
410
|
-
*
|
|
584
|
+
* Check if a token is supported for APY data
|
|
585
|
+
* @param tokenInfo The token to check
|
|
586
|
+
* @returns True if the token has APY data available
|
|
411
587
|
*/
|
|
412
|
-
|
|
413
|
-
protected constructSimpleLeafData(params: {
|
|
414
|
-
id: string;
|
|
415
|
-
target: ContractAddr;
|
|
416
|
-
method: string;
|
|
417
|
-
packedArguments: bigint[];
|
|
418
|
-
}, sanitizer?: ContractAddr): LeafData;
|
|
588
|
+
isAPYSupported(tokenInfo: TokenInfo): boolean;
|
|
419
589
|
/**
|
|
420
|
-
*
|
|
590
|
+
* Check if a token is supported for TVL data
|
|
591
|
+
* @param tokenInfo The token to check
|
|
592
|
+
* @returns True if the token has TVL data available
|
|
421
593
|
*/
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
594
|
+
isTVLSupported(tokenInfo: TokenInfo): boolean;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
declare class Pragma extends PricerBase {
|
|
598
|
+
contractAddr: string;
|
|
599
|
+
readonly contract: Contract;
|
|
600
|
+
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
601
|
+
getPrice(tokenAddr: string, blockIdentifier?: BlockIdentifier): Promise<PriceInfo>;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
declare class ZkLend extends ILending implements ILending {
|
|
605
|
+
readonly pricer: Pricer;
|
|
606
|
+
static readonly POOLS_URL = "https://app.zklend.com/api/pools";
|
|
607
|
+
private POSITION_URL;
|
|
608
|
+
constructor(config: IConfig, pricer: Pricer);
|
|
609
|
+
init(): Promise<void>;
|
|
429
610
|
/**
|
|
430
|
-
*
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
packedArguments: bigint[];
|
|
436
|
-
sanitizer: ContractAddr;
|
|
437
|
-
id: string;
|
|
438
|
-
}[];
|
|
439
|
-
/**
|
|
440
|
-
* Returns deposit leaf adapter using configured proof id
|
|
611
|
+
* @description Get the health factor of the user for given lending and debt tokens
|
|
612
|
+
* @param lending_tokens
|
|
613
|
+
* @param debt_tokens
|
|
614
|
+
* @param user
|
|
615
|
+
* @returns hf (e.g. returns 1.5 for 150% health factor)
|
|
441
616
|
*/
|
|
442
|
-
|
|
617
|
+
get_health_factor_tokenwise(lending_tokens: TokenInfo[], debt_tokens: TokenInfo[], user: ContractAddr): Promise<number>;
|
|
443
618
|
/**
|
|
444
|
-
*
|
|
619
|
+
* @description Get the health factor of the user
|
|
620
|
+
* - Considers all tokens for collateral and debt
|
|
445
621
|
*/
|
|
446
|
-
|
|
622
|
+
get_health_factor(user: ContractAddr): Promise<number>;
|
|
623
|
+
getPositionsSummary(user: ContractAddr): Promise<{
|
|
624
|
+
collateralUSD: number;
|
|
625
|
+
debtUSD: number;
|
|
626
|
+
}>;
|
|
447
627
|
/**
|
|
448
|
-
*
|
|
449
|
-
* @param
|
|
628
|
+
* @description Get the token-wise collateral and debt positions of the user
|
|
629
|
+
* @param user Contract address of the user
|
|
630
|
+
* @returns Promise<ILendingPosition[]>
|
|
450
631
|
*/
|
|
451
|
-
|
|
632
|
+
getPositions(user: ContractAddr): Promise<ILendingPosition[]>;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
declare class PricerFromApi extends PricerBase {
|
|
636
|
+
private apolloClient;
|
|
637
|
+
private pragma;
|
|
638
|
+
private ekuboPricer;
|
|
639
|
+
private readonly PRAGMA_SUPPORTED_TOKENS;
|
|
640
|
+
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
641
|
+
getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
|
|
642
|
+
getPriceFromMyAPI(tokenSymbol: string): Promise<{
|
|
643
|
+
price: number;
|
|
644
|
+
timestamp: Date;
|
|
645
|
+
}>;
|
|
452
646
|
/**
|
|
453
|
-
*
|
|
454
|
-
* @param
|
|
647
|
+
* Fetches historical price for a token at a specific block number
|
|
648
|
+
* @param tokenSymbol - The token symbol to get price for
|
|
649
|
+
* @param blockNumber - The block number to query
|
|
650
|
+
* @returns PriceInfo with price at the closest block <= blockNumber
|
|
455
651
|
*/
|
|
456
|
-
|
|
457
|
-
getProofs<T>(isDeposit: boolean, tree: StandardMerkleTree): {
|
|
458
|
-
proofs: string[][];
|
|
459
|
-
callConstructor: GenerateCallFn<DepositParams> | GenerateCallFn<WithdrawParams>;
|
|
460
|
-
};
|
|
461
|
-
getNetAPY(): Promise<number>;
|
|
462
|
-
abstract getHealthFactor(): Promise<number>;
|
|
652
|
+
getHistoricalPrice(tokenSymbol: string, blockNumber: BlockIdentifier): Promise<PriceInfo>;
|
|
463
653
|
}
|
|
464
654
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
655
|
+
declare class ERC20 {
|
|
656
|
+
readonly config: IConfig;
|
|
657
|
+
constructor(config: IConfig);
|
|
658
|
+
contract(addr: string | ContractAddr): Contract;
|
|
659
|
+
balanceOf(token: string | ContractAddr, address: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
|
|
660
|
+
allowance(token: string | ContractAddr, owner: string | ContractAddr, spender: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
|
|
661
|
+
transfer(token: string | ContractAddr, to: string | ContractAddr, amount: Web3Number): starknet.Call;
|
|
662
|
+
transferFrom(token: string | ContractAddr, from: string | ContractAddr, to: string | ContractAddr, amount: Web3Number): starknet.Call;
|
|
663
|
+
approve(token: string | ContractAddr, spender: string | ContractAddr, amount: Web3Number): starknet.Call;
|
|
471
664
|
}
|
|
472
|
-
|
|
473
|
-
|
|
665
|
+
|
|
666
|
+
interface Route {
|
|
667
|
+
token_from: string;
|
|
668
|
+
token_to: string;
|
|
669
|
+
exchange_address: string;
|
|
670
|
+
percent: number;
|
|
671
|
+
additional_swap_params: string[];
|
|
474
672
|
}
|
|
475
|
-
interface
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
673
|
+
interface SwapInfo {
|
|
674
|
+
token_from_address: string;
|
|
675
|
+
token_from_amount: Uint256;
|
|
676
|
+
token_to_address: string;
|
|
677
|
+
token_to_amount: Uint256;
|
|
678
|
+
token_to_min_amount: Uint256;
|
|
679
|
+
beneficiary: string;
|
|
680
|
+
integrator_fee_amount_bps: number;
|
|
681
|
+
integrator_fee_recipient: string;
|
|
682
|
+
routes: Route[];
|
|
481
683
|
}
|
|
482
|
-
declare class
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
target: ContractAddr;
|
|
488
|
-
method: string;
|
|
489
|
-
packedArguments: bigint[];
|
|
490
|
-
}, sanitizer?: ContractAddr): LeafData;
|
|
491
|
-
getFlashloanAdapter(): Promise<AdapterLeafType<FlashloanCallParams>>;
|
|
492
|
-
getFlashloanCall(params: FlashloanCallParams): Promise<ManageCall[]>;
|
|
493
|
-
getBringLiquidityAdapter(id: string): () => AdapterLeafType<ApproveCallParams>;
|
|
494
|
-
getApproveAdapter(token: ContractAddr, spender: ContractAddr, id: string): () => AdapterLeafType<ApproveCallParams>;
|
|
495
|
-
getApproveCall(token: ContractAddr, spender: ContractAddr): (params: ApproveCallParams) => Promise<{
|
|
496
|
-
sanitizer: ContractAddr;
|
|
497
|
-
call: {
|
|
498
|
-
contractAddress: ContractAddr;
|
|
499
|
-
selector: string;
|
|
500
|
-
calldata: bigint[];
|
|
501
|
-
};
|
|
502
|
-
}[]>;
|
|
503
|
-
getBringLiquidityCall(): GenerateCallFn<ApproveCallParams>;
|
|
684
|
+
declare class AvnuWrapper {
|
|
685
|
+
getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number, excludeSources?: string[]): Promise<Quote>;
|
|
686
|
+
getSwapInfo(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount?: string, options?: AvnuOptions): Promise<SwapInfo>;
|
|
687
|
+
static buildZeroSwap(tokenToSell: ContractAddr, beneficiary: string, tokenToBuy?: ContractAddr): SwapInfo;
|
|
688
|
+
getSwapCallData(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string): Promise<bigint[][]>;
|
|
504
689
|
}
|
|
505
690
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
691
|
+
declare class AutoCompounderSTRK {
|
|
692
|
+
readonly config: IConfig;
|
|
693
|
+
readonly addr: ContractAddr;
|
|
694
|
+
readonly pricer: Pricer;
|
|
695
|
+
private initialized;
|
|
696
|
+
contract: Contract | null;
|
|
697
|
+
readonly metadata: {
|
|
698
|
+
decimals: number;
|
|
699
|
+
underlying: {
|
|
700
|
+
address: ContractAddr;
|
|
701
|
+
name: string;
|
|
702
|
+
symbol: string;
|
|
703
|
+
};
|
|
704
|
+
name: string;
|
|
515
705
|
};
|
|
516
|
-
|
|
517
|
-
|
|
706
|
+
constructor(config: IConfig, pricer: Pricer);
|
|
707
|
+
init(): Promise<void>;
|
|
708
|
+
waitForInitilisation(): Promise<void>;
|
|
709
|
+
/** Returns shares of user */
|
|
710
|
+
balanceOf(user: ContractAddr): Promise<Web3Number>;
|
|
711
|
+
/** Returns underlying assets of user */
|
|
712
|
+
balanceOfUnderlying(user: ContractAddr): Promise<Web3Number>;
|
|
713
|
+
/** Returns usd value of assets */
|
|
714
|
+
usdBalanceOfUnderlying(user: ContractAddr): Promise<{
|
|
715
|
+
usd: Web3Number;
|
|
716
|
+
assets: Web3Number;
|
|
717
|
+
}>;
|
|
518
718
|
}
|
|
519
719
|
|
|
520
|
-
interface
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
tick_spacing: string;
|
|
525
|
-
extension: string;
|
|
720
|
+
interface PoolProps {
|
|
721
|
+
pool_id: ContractAddr;
|
|
722
|
+
max_weight: number;
|
|
723
|
+
v_token: ContractAddr;
|
|
526
724
|
}
|
|
527
|
-
interface
|
|
528
|
-
|
|
529
|
-
|
|
725
|
+
interface Change {
|
|
726
|
+
pool_id: ContractAddr;
|
|
727
|
+
changeAmt: Web3Number;
|
|
728
|
+
finalAmt: Web3Number;
|
|
729
|
+
isDeposit: boolean;
|
|
530
730
|
}
|
|
531
|
-
interface
|
|
532
|
-
|
|
533
|
-
|
|
731
|
+
interface VesuRebalanceSettings {
|
|
732
|
+
feeBps: number;
|
|
733
|
+
}
|
|
734
|
+
interface PoolInfoFull {
|
|
735
|
+
pool_id: ContractAddr;
|
|
736
|
+
pool_name: string | undefined;
|
|
737
|
+
max_weight: number;
|
|
738
|
+
current_weight: number;
|
|
739
|
+
v_token: ContractAddr;
|
|
534
740
|
amount: Web3Number;
|
|
741
|
+
usdValue: Web3Number;
|
|
742
|
+
APY: {
|
|
743
|
+
baseApy: number;
|
|
744
|
+
defiSpringApy: number;
|
|
745
|
+
netApy: number;
|
|
746
|
+
};
|
|
747
|
+
currentUtilization: number;
|
|
748
|
+
maxUtilization: number;
|
|
535
749
|
}
|
|
536
750
|
/**
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
* @property newBounds.lower - relative to the current tick
|
|
541
|
-
* @property newBounds.upper - relative to the current tick
|
|
751
|
+
* Represents a VesuRebalance strategy.
|
|
752
|
+
* This class implements an automated rebalancing strategy for Vesu pools,
|
|
753
|
+
* managing deposits and withdrawals while optimizing yield through STRK rewards.
|
|
542
754
|
*/
|
|
543
|
-
|
|
544
|
-
newBounds: {
|
|
545
|
-
lower: number;
|
|
546
|
-
upper: number;
|
|
547
|
-
} | string;
|
|
548
|
-
lstContract?: ContractAddr;
|
|
549
|
-
truePrice?: number;
|
|
550
|
-
feeBps: number;
|
|
551
|
-
rebalanceConditions: {
|
|
552
|
-
minWaitHours: number;
|
|
553
|
-
direction: "any" | "uponly";
|
|
554
|
-
customShouldRebalance: (currentPoolPrice: number) => Promise<boolean>;
|
|
555
|
-
};
|
|
556
|
-
quoteAsset: TokenInfo;
|
|
557
|
-
}
|
|
558
|
-
declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
|
|
755
|
+
declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
559
756
|
/** Contract address of the strategy */
|
|
560
757
|
readonly address: ContractAddr;
|
|
561
758
|
/** Pricer instance for token price calculations */
|
|
562
759
|
readonly pricer: PricerBase;
|
|
563
760
|
/** Metadata containing strategy information */
|
|
564
|
-
readonly metadata: IStrategyMetadata<
|
|
761
|
+
readonly metadata: IStrategyMetadata<VesuRebalanceSettings>;
|
|
565
762
|
/** Contract instance for interacting with the strategy */
|
|
566
763
|
readonly contract: Contract;
|
|
567
764
|
readonly BASE_WEIGHT = 10000;
|
|
568
|
-
readonly ekuboPositionsContract: Contract;
|
|
569
|
-
readonly ekuboMathContract: Contract;
|
|
570
|
-
readonly lstContract: Contract | null;
|
|
571
|
-
poolKey: EkuboPoolKey | undefined;
|
|
572
|
-
readonly avnu: AvnuWrapper;
|
|
573
765
|
/**
|
|
574
766
|
* Creates a new VesuRebalance strategy instance.
|
|
575
767
|
* @param config - Configuration object containing provider and other settings
|
|
@@ -577,40 +769,280 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
577
769
|
* @param metadata - Strategy metadata including deposit tokens and address
|
|
578
770
|
* @throws {Error} If more than one deposit token is specified
|
|
579
771
|
*/
|
|
580
|
-
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<
|
|
581
|
-
matchInputAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
|
|
582
|
-
/** Returns minimum amounts give given two amounts based on what can be added for liq */
|
|
583
|
-
getMinDepositAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
|
|
584
|
-
depositCall(amountInfo: DualActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
585
|
-
tokensToShares(amountInfo: DualActionAmount): Promise<Web3Number>;
|
|
586
|
-
withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
587
|
-
rebalanceCall(newBounds: EkuboBounds, swapParams: SwapInfo): Call[];
|
|
588
|
-
handleUnusedCall(swapParams: SwapInfo): Call[];
|
|
589
|
-
handleFeesCall(): Call[];
|
|
590
|
-
getFeeHistory(timePeriod?: '24h' | '7d' | '30d' | '3m'): Promise<{
|
|
591
|
-
summary: DualTokenInfo;
|
|
592
|
-
history: FeeHistory[];
|
|
593
|
-
}>;
|
|
594
|
-
netSharesBasedTrueAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
595
|
-
feeBasedAPY(timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<number>;
|
|
772
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>);
|
|
596
773
|
/**
|
|
597
|
-
*
|
|
598
|
-
* @
|
|
774
|
+
* Creates a deposit call to the strategy contract.
|
|
775
|
+
* @param assets - Amount of assets to deposit
|
|
776
|
+
* @param receiver - Address that will receive the strategy tokens
|
|
777
|
+
* @returns Populated contract call for deposit
|
|
599
778
|
*/
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
779
|
+
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<starknet.Call[]>;
|
|
780
|
+
/**
|
|
781
|
+
* Creates a withdrawal call to the strategy contract.
|
|
782
|
+
* @param assets - Amount of assets to withdraw
|
|
783
|
+
* @param receiver - Address that will receive the withdrawn assets
|
|
784
|
+
* @param owner - Address that owns the strategy tokens
|
|
785
|
+
* @returns Populated contract call for withdrawal
|
|
786
|
+
*/
|
|
787
|
+
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<starknet.Call[]>;
|
|
788
|
+
/**
|
|
789
|
+
* Returns the underlying asset token of the strategy.
|
|
790
|
+
* @returns The deposit token supported by this strategy
|
|
791
|
+
*/
|
|
792
|
+
asset(): TokenInfo;
|
|
793
|
+
/**
|
|
794
|
+
* Returns the number of decimals used by the strategy token.
|
|
795
|
+
* @returns Number of decimals (same as the underlying token)
|
|
796
|
+
*/
|
|
797
|
+
decimals(): number;
|
|
798
|
+
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<{
|
|
799
|
+
tokenInfo: TokenInfo;
|
|
800
|
+
amount: Web3Number;
|
|
801
|
+
usdValue: number;
|
|
802
|
+
}>;
|
|
803
|
+
/**
|
|
804
|
+
* Calculates user realized APY based on trueSharesBasedAPY method.
|
|
805
|
+
* Returns the APY as a number.
|
|
806
|
+
*/
|
|
807
|
+
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
808
|
+
/**
|
|
809
|
+
* Calculates the total TVL of the strategy.
|
|
810
|
+
* @returns Object containing the total amount in token units and USD value
|
|
811
|
+
*/
|
|
812
|
+
getTVL(): Promise<{
|
|
813
|
+
tokenInfo: TokenInfo;
|
|
814
|
+
amount: Web3Number;
|
|
815
|
+
usdValue: number;
|
|
816
|
+
}>;
|
|
817
|
+
static getAllPossibleVerifiedPools(asset: ContractAddr): Promise<any>;
|
|
818
|
+
getPoolInfo(p: PoolProps, pools: any[], vesuPositions: any[], totalAssets: Web3Number, isErrorPositionsAPI: boolean, isErrorPoolsAPI: boolean): Promise<{
|
|
819
|
+
pool_id: ContractAddr;
|
|
820
|
+
pool_name: any;
|
|
821
|
+
max_weight: number;
|
|
822
|
+
current_weight: number;
|
|
823
|
+
v_token: ContractAddr;
|
|
824
|
+
amount: Web3Number;
|
|
825
|
+
usdValue: Web3Number;
|
|
826
|
+
APY: {
|
|
827
|
+
baseApy: number;
|
|
828
|
+
defiSpringApy: number;
|
|
829
|
+
netApy: number;
|
|
830
|
+
};
|
|
831
|
+
currentUtilization: number;
|
|
832
|
+
maxUtilization: number;
|
|
833
|
+
}>;
|
|
834
|
+
/**
|
|
835
|
+
* Retrieves the list of allowed pools and their detailed information from multiple sources:
|
|
836
|
+
* 1. Contract's allowed pools
|
|
837
|
+
* 2. Vesu positions API for current positions
|
|
838
|
+
* 3. Vesu pools API for APY and utilization data
|
|
839
|
+
*
|
|
840
|
+
* @returns {Promise<{
|
|
841
|
+
* data: Array<PoolInfoFull>,
|
|
842
|
+
* isErrorPositionsAPI: boolean
|
|
843
|
+
* }>} Object containing:
|
|
844
|
+
* - data: Array of pool information including IDs, weights, amounts, APYs and utilization
|
|
845
|
+
* - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
|
|
846
|
+
*/
|
|
847
|
+
getPools(): Promise<{
|
|
848
|
+
data: {
|
|
849
|
+
pool_id: ContractAddr;
|
|
850
|
+
pool_name: any;
|
|
851
|
+
max_weight: number;
|
|
852
|
+
current_weight: number;
|
|
853
|
+
v_token: ContractAddr;
|
|
854
|
+
amount: Web3Number;
|
|
855
|
+
usdValue: Web3Number;
|
|
856
|
+
APY: {
|
|
857
|
+
baseApy: number;
|
|
858
|
+
defiSpringApy: number;
|
|
859
|
+
netApy: number;
|
|
860
|
+
};
|
|
861
|
+
currentUtilization: number;
|
|
862
|
+
maxUtilization: number;
|
|
863
|
+
}[];
|
|
864
|
+
isErrorPositionsAPI: boolean;
|
|
865
|
+
isErrorPoolsAPI: boolean;
|
|
866
|
+
isError: boolean;
|
|
867
|
+
}>;
|
|
868
|
+
getVesuPools(retry?: number): Promise<{
|
|
869
|
+
pools: any[];
|
|
870
|
+
isErrorPoolsAPI: boolean;
|
|
871
|
+
}>;
|
|
872
|
+
/**
|
|
873
|
+
* Calculates the weighted average APY across all pools based on USD value.
|
|
874
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
875
|
+
*/
|
|
876
|
+
netAPY(): Promise<APYInfo>;
|
|
877
|
+
/**
|
|
878
|
+
* Calculates the weighted average APY across all pools based on USD value.
|
|
879
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
880
|
+
*/
|
|
881
|
+
netAPYGivenPools(pools: PoolInfoFull[]): Promise<number>;
|
|
882
|
+
/**
|
|
883
|
+
* Calculates optimal position changes to maximize APY while respecting max weights.
|
|
884
|
+
* The algorithm:
|
|
885
|
+
* 1. Sorts pools by APY (highest first)
|
|
886
|
+
* 2. Calculates target amounts based on max weights
|
|
887
|
+
* 3. For each pool that needs more funds:
|
|
888
|
+
* - Takes funds from lowest APY pools that are over their target
|
|
889
|
+
* 4. Validates that total assets remain constant
|
|
890
|
+
*
|
|
891
|
+
* @returns {Promise<{
|
|
892
|
+
* changes: Change[],
|
|
893
|
+
* finalPools: PoolInfoFull[],
|
|
894
|
+
* isAnyPoolOverMaxWeight: boolean
|
|
895
|
+
* }>} Object containing:
|
|
896
|
+
* - changes: Array of position changes
|
|
897
|
+
* - finalPools: Array of pool information after rebalance
|
|
898
|
+
* @throws Error if rebalance is not possible while maintaining constraints
|
|
899
|
+
*/
|
|
900
|
+
getRebalancedPositions(_pools?: PoolInfoFull[]): Promise<{
|
|
901
|
+
changes: never[];
|
|
902
|
+
finalPools: never[];
|
|
903
|
+
isAnyPoolOverMaxWeight?: undefined;
|
|
904
|
+
} | {
|
|
905
|
+
changes: Change[];
|
|
906
|
+
finalPools: PoolInfoFull[];
|
|
907
|
+
isAnyPoolOverMaxWeight: boolean;
|
|
908
|
+
}>;
|
|
909
|
+
/**
|
|
910
|
+
* Creates a rebalance Call object for the strategy contract
|
|
911
|
+
* @param pools - Array of pool information including IDs, weights, amounts, APYs and utilization
|
|
912
|
+
* @returns Populated contract call for rebalance
|
|
913
|
+
*/
|
|
914
|
+
getRebalanceCall(pools: Awaited<ReturnType<typeof this.getRebalancedPositions>>["changes"], isOverWeightAdjustment: boolean): Promise<starknet.Call | null>;
|
|
915
|
+
getInvestmentFlows(pools: PoolInfoFull[]): Promise<IInvestmentFlow[]>;
|
|
916
|
+
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
917
|
+
harvest(acc: Account): Promise<starknet.Call[]>;
|
|
918
|
+
/**
|
|
919
|
+
* Calculates the fees deducted in different vTokens based on the current and previous state.
|
|
920
|
+
* @param previousTotalSupply - The total supply of the strategy token before the transaction
|
|
921
|
+
* @returns {Promise<Array<{ vToken: ContractAddr, fee: Web3Number }>>} Array of fees deducted in different vTokens
|
|
922
|
+
*/
|
|
923
|
+
getFee(allowedPools: Array<PoolInfoFull>): Promise<Array<{
|
|
924
|
+
vToken: ContractAddr;
|
|
925
|
+
fee: Web3Number;
|
|
926
|
+
}>>;
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Represents the Vesu Rebalance Strategies.
|
|
930
|
+
*/
|
|
931
|
+
declare const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[];
|
|
932
|
+
|
|
933
|
+
interface EkuboPoolKey {
|
|
934
|
+
token0: ContractAddr;
|
|
935
|
+
token1: ContractAddr;
|
|
936
|
+
fee: string;
|
|
937
|
+
tick_spacing: string;
|
|
938
|
+
extension: string;
|
|
939
|
+
}
|
|
940
|
+
interface EkuboBounds {
|
|
941
|
+
lowerTick: bigint;
|
|
942
|
+
upperTick: bigint;
|
|
943
|
+
}
|
|
944
|
+
interface FeeHistory {
|
|
945
|
+
date: string;
|
|
946
|
+
tokenInfo: TokenInfo;
|
|
947
|
+
amount: Web3Number;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Settings for the CLVaultStrategy
|
|
951
|
+
*
|
|
952
|
+
* @property newBounds - The new bounds for the strategy
|
|
953
|
+
* @property newBounds.lower - relative to the current tick
|
|
954
|
+
* @property newBounds.upper - relative to the current tick
|
|
955
|
+
*/
|
|
956
|
+
interface CLVaultStrategySettings {
|
|
957
|
+
newBounds: {
|
|
958
|
+
lower: number;
|
|
959
|
+
upper: number;
|
|
960
|
+
} | string;
|
|
961
|
+
lstContract?: ContractAddr;
|
|
962
|
+
truePrice?: number;
|
|
963
|
+
feeBps: number;
|
|
964
|
+
rebalanceConditions: {
|
|
965
|
+
minWaitHours: number;
|
|
966
|
+
direction: "any" | "uponly";
|
|
967
|
+
customShouldRebalance: (currentPoolPrice: number) => Promise<boolean>;
|
|
968
|
+
};
|
|
969
|
+
quoteAsset: TokenInfo;
|
|
970
|
+
}
|
|
971
|
+
declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount> {
|
|
972
|
+
/** Contract address of the strategy */
|
|
973
|
+
readonly address: ContractAddr;
|
|
974
|
+
/** Pricer instance for token price calculations */
|
|
975
|
+
readonly pricer: PricerBase;
|
|
976
|
+
/** Metadata containing strategy information */
|
|
977
|
+
readonly metadata: IStrategyMetadata<CLVaultStrategySettings>;
|
|
978
|
+
/** Contract instance for interacting with the strategy */
|
|
979
|
+
readonly contract: Contract;
|
|
980
|
+
readonly BASE_WEIGHT = 10000;
|
|
981
|
+
readonly ekuboPositionsContract: Contract;
|
|
982
|
+
readonly ekuboMathContract: Contract;
|
|
983
|
+
readonly lstContract: Contract | null;
|
|
984
|
+
poolKey: EkuboPoolKey | undefined;
|
|
985
|
+
readonly avnu: AvnuWrapper;
|
|
986
|
+
/**
|
|
987
|
+
* Creates a new VesuRebalance strategy instance.
|
|
988
|
+
* @param config - Configuration object containing provider and other settings
|
|
989
|
+
* @param pricer - Pricer instance for token price calculations
|
|
990
|
+
* @param metadata - Strategy metadata including deposit tokens and address
|
|
991
|
+
* @throws {Error} If more than one deposit token is specified
|
|
992
|
+
*/
|
|
993
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>);
|
|
994
|
+
matchInputAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
|
|
995
|
+
/** Returns minimum amounts give given two amounts based on what can be added for liq */
|
|
996
|
+
getMinDepositAmounts(amountInfo: DualActionAmount): Promise<DualActionAmount>;
|
|
997
|
+
depositCall(amountInfo: DualActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
998
|
+
tokensToShares(amountInfo: DualActionAmount): Promise<Web3Number>;
|
|
999
|
+
withdrawCall(amountInfo: DualActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
1000
|
+
rebalanceCall(newBounds: EkuboBounds, swapParams: SwapInfo): Call[];
|
|
1001
|
+
handleUnusedCall(swapParams: SwapInfo): Call[];
|
|
1002
|
+
handleFeesCall(): Call[];
|
|
1003
|
+
getFeeHistory(timePeriod?: '24h' | '7d' | '30d' | '3m' | '6m', range?: {
|
|
1004
|
+
startTimestamp?: number;
|
|
1005
|
+
endTimestamp?: number;
|
|
1006
|
+
}): Promise<{
|
|
1007
|
+
summary: DualTokenInfo;
|
|
1008
|
+
history: FeeHistory[];
|
|
1009
|
+
}>;
|
|
1010
|
+
netSharesBasedTrueAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Calculate lifetime earnings for a user
|
|
1013
|
+
* Not yet implemented for Ekubo CL Vault strategy
|
|
1014
|
+
*/
|
|
1015
|
+
getLifetimeEarnings(userTVL: SingleTokenInfo, investmentFlows: Array<{
|
|
1016
|
+
amount: string;
|
|
1017
|
+
type: string;
|
|
1018
|
+
timestamp: number;
|
|
1019
|
+
tx_hash: string;
|
|
1020
|
+
}>): any;
|
|
1021
|
+
/**
|
|
1022
|
+
* Calculates realized APY based on TVL per share growth, always valued in USDC.
|
|
1023
|
+
* This is a vault-level metric (same for all users) and works for all strategies,
|
|
1024
|
+
* regardless of quote asset configuration.
|
|
1025
|
+
*/
|
|
1026
|
+
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
1027
|
+
feeBasedAPY(timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<number>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Calculates assets before and now in a given token of TVL per share to observe growth
|
|
1030
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
1031
|
+
*/
|
|
1032
|
+
netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<number>;
|
|
1033
|
+
getHarvestRewardShares(fromBlock: number, toBlock: number): Promise<Web3Number>;
|
|
1034
|
+
balanceOf(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<Web3Number>;
|
|
1035
|
+
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<DualTokenInfo>;
|
|
1036
|
+
_getTVL(blockIdentifier?: BlockIdentifier): Promise<{
|
|
1037
|
+
amount0: Web3Number;
|
|
1038
|
+
amount1: Web3Number;
|
|
1039
|
+
}>;
|
|
1040
|
+
totalSupply(blockIdentifier?: BlockIdentifier): Promise<Web3Number>;
|
|
1041
|
+
assertValidDepositTokens(poolKey: EkuboPoolKey): void;
|
|
1042
|
+
getTVL(blockIdentifier?: BlockIdentifier): Promise<DualTokenInfo>;
|
|
1043
|
+
getUncollectedFees(): Promise<DualTokenInfo>;
|
|
1044
|
+
getCurrentNFTID(): Promise<number>;
|
|
1045
|
+
truePrice(): Promise<number>;
|
|
614
1046
|
getCurrentPrice(blockIdentifier?: BlockIdentifier): Promise<{
|
|
615
1047
|
price: number;
|
|
616
1048
|
tick: number;
|
|
@@ -652,7 +1084,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
652
1084
|
usdValue: number;
|
|
653
1085
|
};
|
|
654
1086
|
}>;
|
|
655
|
-
getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null, maxIterations?: number, priceRatioPrecision?: number): Promise<SwapInfo>;
|
|
1087
|
+
getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null, maxIterations?: number, priceRatioPrecision?: number, getQuoteCallback?: (tokenToSell: string, tokenToBuy: string, amountWei: string, beneficiary: string) => Promise<Quote>): Promise<SwapInfo>;
|
|
656
1088
|
assertValidBounds(bounds: EkuboBounds): void;
|
|
657
1089
|
assertValidAmounts(expectedAmounts: any, token0Bal: Web3Number, token1Bal: Web3Number): void;
|
|
658
1090
|
getSwapParams(expectedAmounts: any, poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number): {
|
|
@@ -672,7 +1104,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
672
1104
|
* @returns {Promise<SwapInfo>}
|
|
673
1105
|
*
|
|
674
1106
|
*/
|
|
675
|
-
getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds, maxIterations?: number, priceRatioPrecision?: number): Promise<SwapInfo>;
|
|
1107
|
+
getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds, maxIterations?: number, priceRatioPrecision?: number, getQuoteCallback?: (tokenToSell: string, tokenToBuy: string, amountWei: string, beneficiary: string) => Promise<Quote>): Promise<SwapInfo>;
|
|
676
1108
|
/**
|
|
677
1109
|
* Attempts to rebalance the vault by iteratively adjusting swap amounts if initial attempt fails.
|
|
678
1110
|
* Uses binary search approach to find optimal swap amount.
|
|
@@ -683,10 +1115,16 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
683
1115
|
* @param retry - Current retry attempt number (default 0)
|
|
684
1116
|
* @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
|
|
685
1117
|
* @param isToken0Deficit - Whether token0 balance needs increasing (default true)
|
|
1118
|
+
* @param MAX_RETRIES - Maximum number of retries (default 40)
|
|
1119
|
+
* @param sameErrorCount - For certain errors, we just retry with same amount again. This is the count of such retries (default { count: 0, error: null })
|
|
1120
|
+
* @param MAX_SAME_ERROR_COUNT - For certain errors, we just retry with same amount again. This limits such retries (default 10)
|
|
686
1121
|
* @returns Array of contract calls needed for rebalancing
|
|
687
|
-
* @throws Error if max retries reached without successful rebalance
|
|
1122
|
+
* @throws Error if max retries reached without successful rebalance or max same errors reached
|
|
688
1123
|
*/
|
|
689
|
-
rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint, MAX_RETRIES?: number
|
|
1124
|
+
rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint, MAX_RETRIES?: number, sameErrorCount?: {
|
|
1125
|
+
count: number;
|
|
1126
|
+
error: null | string;
|
|
1127
|
+
}, MAX_SAME_ERROR_COUNT?: number): Promise<Call[]>;
|
|
690
1128
|
static tickToi129(tick: number): {
|
|
691
1129
|
mag: number;
|
|
692
1130
|
sign: number;
|
|
@@ -705,7 +1143,8 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
705
1143
|
amount0: Web3Number;
|
|
706
1144
|
amount1: Web3Number;
|
|
707
1145
|
}>;
|
|
708
|
-
|
|
1146
|
+
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
1147
|
+
harvest(acc: Account, maxIterations?: number, priceRatioPrecision?: number, minRewardAmount?: Web3Number): Promise<Call[]>;
|
|
709
1148
|
/**
|
|
710
1149
|
* @description This funciton requires atleast one of the pool tokens to be reward token
|
|
711
1150
|
* i.e. STRK.
|
|
@@ -754,13 +1193,387 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
754
1193
|
*/
|
|
755
1194
|
declare const EkuboCLVaultStrategies: IStrategyMetadata<CLVaultStrategySettings>[];
|
|
756
1195
|
|
|
757
|
-
interface
|
|
758
|
-
|
|
759
|
-
|
|
1196
|
+
interface SenseiVaultSettings {
|
|
1197
|
+
mainToken: TokenInfo;
|
|
1198
|
+
secondaryToken: TokenInfo;
|
|
1199
|
+
targetHfBps: number;
|
|
1200
|
+
feeBps: number;
|
|
760
1201
|
}
|
|
761
|
-
declare
|
|
762
|
-
|
|
763
|
-
|
|
1202
|
+
declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
1203
|
+
readonly address: ContractAddr;
|
|
1204
|
+
readonly metadata: IStrategyMetadata<SenseiVaultSettings>;
|
|
1205
|
+
readonly pricer: PricerBase;
|
|
1206
|
+
readonly contract: Contract;
|
|
1207
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>);
|
|
1208
|
+
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<SingleTokenInfo>;
|
|
1209
|
+
getTVL(): Promise<SingleTokenInfo>;
|
|
1210
|
+
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
1211
|
+
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
1212
|
+
getPositionInfo(): Promise<{
|
|
1213
|
+
collateralXSTRK: Web3Number;
|
|
1214
|
+
collateralUSDValue: Web3Number;
|
|
1215
|
+
debtSTRK: Web3Number;
|
|
1216
|
+
debtUSDValue: Web3Number;
|
|
1217
|
+
xSTRKPrice: number;
|
|
1218
|
+
collateralInSTRK: number;
|
|
1219
|
+
}>;
|
|
1220
|
+
getSecondaryTokenPriceRelativeToMain(retry?: number): Promise<number>;
|
|
1221
|
+
getSettings: () => Promise<starknet.CallResult>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Calculate lifetime earnings for a user
|
|
1224
|
+
* Not yet implemented for Sensei Vault strategy
|
|
1225
|
+
*/
|
|
1226
|
+
getLifetimeEarnings(userTVL: SingleTokenInfo, investmentFlows: Array<{
|
|
1227
|
+
amount: string;
|
|
1228
|
+
type: string;
|
|
1229
|
+
timestamp: number;
|
|
1230
|
+
tx_hash: string;
|
|
1231
|
+
}>): any;
|
|
1232
|
+
netAPY(): Promise<number>;
|
|
1233
|
+
/**
|
|
1234
|
+
* Calculates user realized APY based on position growth accounting for deposits and withdrawals.
|
|
1235
|
+
* Returns the APY as a number.
|
|
1236
|
+
* Not implemented for Sensei Strategy yet.
|
|
1237
|
+
*/
|
|
1238
|
+
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
1239
|
+
}
|
|
1240
|
+
declare const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[];
|
|
1241
|
+
|
|
1242
|
+
interface LeveledLogMethod {
|
|
1243
|
+
(message: string, ...meta: any[]): void;
|
|
1244
|
+
(message: any): void;
|
|
1245
|
+
}
|
|
1246
|
+
type LoggerLevel = "error" | "warn" | "info" | "verbose" | "debug";
|
|
1247
|
+
interface LoggerConfig {
|
|
1248
|
+
level?: LoggerLevel;
|
|
1249
|
+
consoleLevel?: LoggerLevel;
|
|
1250
|
+
fileLevel?: LoggerLevel;
|
|
1251
|
+
filePath?: string;
|
|
1252
|
+
enableConsole?: boolean;
|
|
1253
|
+
enableFile?: boolean;
|
|
1254
|
+
colorizeConsole?: boolean;
|
|
1255
|
+
shortErrorsInConsole?: boolean;
|
|
1256
|
+
emitConfigLog?: boolean;
|
|
1257
|
+
}
|
|
1258
|
+
interface MyLogger {
|
|
1259
|
+
error: LeveledLogMethod;
|
|
1260
|
+
warn: LeveledLogMethod;
|
|
1261
|
+
info: LeveledLogMethod;
|
|
1262
|
+
verbose: LeveledLogMethod;
|
|
1263
|
+
debug: LeveledLogMethod;
|
|
1264
|
+
}
|
|
1265
|
+
declare const logger: MyLogger;
|
|
1266
|
+
declare function configureLogger(_config?: LoggerConfig): MyLogger;
|
|
1267
|
+
|
|
1268
|
+
interface LeafData {
|
|
1269
|
+
id: bigint;
|
|
1270
|
+
readableId: string;
|
|
1271
|
+
data: bigint[];
|
|
1272
|
+
}
|
|
1273
|
+
interface StandardMerkleTreeData<T extends any> extends MerkleTreeData<T> {
|
|
1274
|
+
format: 'standard-v1';
|
|
1275
|
+
leafEncoding: ValueType[];
|
|
1276
|
+
}
|
|
1277
|
+
declare class StandardMerkleTree extends MerkleTreeImpl<LeafData> {
|
|
1278
|
+
protected readonly tree: HexString[];
|
|
1279
|
+
protected readonly values: StandardMerkleTreeData<LeafData>['values'];
|
|
1280
|
+
protected readonly leafEncoding: ValueType[];
|
|
1281
|
+
protected constructor(tree: HexString[], values: StandardMerkleTreeData<LeafData>['values'], leafEncoding: ValueType[]);
|
|
1282
|
+
static of(values: LeafData[], leafEncoding?: ValueType[], options?: MerkleTreeOptions): StandardMerkleTree;
|
|
1283
|
+
static verify<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], leaf: T, proof: BytesLike[]): boolean;
|
|
1284
|
+
static verifyMultiProof<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], multiproof: MultiProof<BytesLike, T>): boolean;
|
|
1285
|
+
dump(): StandardMerkleTreeData<LeafData>;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* Convert SDK TVL info (SingleTokenInfo or DualTokenInfo) to client AmountsInfo format
|
|
1290
|
+
*/
|
|
1291
|
+
declare function toAmountsInfo(tvlInfo: SingleTokenInfo | DualTokenInfo): Omit<AmountsInfo, "amounts"> & {
|
|
1292
|
+
amounts: Array<{
|
|
1293
|
+
amount: Web3Number;
|
|
1294
|
+
tokenInfo: TokenInfo;
|
|
1295
|
+
}>;
|
|
1296
|
+
};
|
|
1297
|
+
/**
|
|
1298
|
+
* Detect what capabilities a strategy instance has
|
|
1299
|
+
*/
|
|
1300
|
+
declare function detectCapabilities(strategy: BaseStrategy<any, any>): StrategyCapabilities;
|
|
1301
|
+
/**
|
|
1302
|
+
* Check if a strategy is a dual-token strategy
|
|
1303
|
+
*/
|
|
1304
|
+
declare function isDualTokenStrategy(strategy: BaseStrategy<any, any>): boolean;
|
|
1305
|
+
|
|
1306
|
+
type ParsedStarknetCall = {
|
|
1307
|
+
target: string;
|
|
1308
|
+
method: string;
|
|
1309
|
+
selector?: string;
|
|
1310
|
+
sanitizer?: string;
|
|
1311
|
+
decodedArgs: unknown;
|
|
1312
|
+
rawCalldata: string[];
|
|
1313
|
+
parserUsed: string;
|
|
1314
|
+
parseError?: string;
|
|
1315
|
+
};
|
|
1316
|
+
type StarknetCallParserOptions = {
|
|
1317
|
+
tokenSymbols?: Record<string, string>;
|
|
1318
|
+
tokenDecimals?: Record<string, number>;
|
|
1319
|
+
poolNames?: Record<string, string>;
|
|
1320
|
+
};
|
|
1321
|
+
/**
|
|
1322
|
+
* Integration guide for new methods/protocols:
|
|
1323
|
+
* 1) Add method name to METHOD_BY_SELECTOR if it comes from ManageCall selector.
|
|
1324
|
+
* 2) Add a decoder in METHOD_DECODERS with a focused decode* method.
|
|
1325
|
+
* 3) Keep decoder output concise and operator-friendly.
|
|
1326
|
+
* 4) Prefer existing primitives (ContractAddr, uint256, Web3Number where needed).
|
|
1327
|
+
* 5) Add/extend tests in test/starknet-call-parser.test.ts for parse + log behavior.
|
|
1328
|
+
*/
|
|
1329
|
+
declare class StarknetCallParser {
|
|
1330
|
+
private static readonly METHOD_DECODERS;
|
|
1331
|
+
private static readonly METHOD_BY_SELECTOR;
|
|
1332
|
+
static parseManageCall(manageCall: ManageCall, options?: StarknetCallParserOptions): ParsedStarknetCall;
|
|
1333
|
+
static parseManageCalls(manageCalls: ManageCall[], options?: StarknetCallParserOptions): ParsedStarknetCall[];
|
|
1334
|
+
static parseCall(call: Call, options?: StarknetCallParserOptions): ParsedStarknetCall;
|
|
1335
|
+
static parseCalls(calls: Call[], options?: StarknetCallParserOptions): ParsedStarknetCall[];
|
|
1336
|
+
static logManageCalls(context: string, manageCalls: ManageCall[], options?: StarknetCallParserOptions): void;
|
|
1337
|
+
static logCalls(context: string, calls: Call[], options?: StarknetCallParserOptions): void;
|
|
1338
|
+
static logCallsSummary(context: string, calls: Call[], options?: StarknetCallParserOptions, sink?: (message: string) => void): void;
|
|
1339
|
+
static logManageCallsSummary(context: string, manageCalls: ManageCall[], options?: StarknetCallParserOptions, sink?: (message: string) => void): void;
|
|
1340
|
+
static formatCallsSummary(context: string, calls: Call[], options?: StarknetCallParserOptions): string;
|
|
1341
|
+
static formatManageCallsSummary(context: string, manageCalls: ManageCall[], options?: StarknetCallParserOptions): string;
|
|
1342
|
+
static buildTokenSymbolLookup(tokens: TokenInfo[]): Record<string, string>;
|
|
1343
|
+
static buildPoolNameLookup(pools: {
|
|
1344
|
+
poolId: string | bigint;
|
|
1345
|
+
name: string;
|
|
1346
|
+
}[]): Record<string, string>;
|
|
1347
|
+
static buildTokenDecimalsLookup(tokens: TokenInfo[]): Record<string, number>;
|
|
1348
|
+
private static parseRaw;
|
|
1349
|
+
private static enrichDecodedArgs;
|
|
1350
|
+
private static toStringCalldata;
|
|
1351
|
+
private static toBigInt;
|
|
1352
|
+
private static decodeApprove;
|
|
1353
|
+
private static decodeBringLiquidity;
|
|
1354
|
+
private static decodeFlashLoan;
|
|
1355
|
+
private static decodeModifyDelegation;
|
|
1356
|
+
private static parseVesuAmount;
|
|
1357
|
+
private static decodeModifyPosition;
|
|
1358
|
+
private static decodeModifyLever;
|
|
1359
|
+
private static decodeMultiRouteSwap;
|
|
1360
|
+
private static decodeManageVaultWithMerkleVerification;
|
|
1361
|
+
private static toCallSummary;
|
|
1362
|
+
private static pickKeyFields;
|
|
1363
|
+
private static u256FromParts;
|
|
1364
|
+
private static toSelectorHex;
|
|
1365
|
+
private static parseSwapArray;
|
|
1366
|
+
private static toPoolIdKey;
|
|
1367
|
+
private static toAssetLabel;
|
|
1368
|
+
private static toHumanAmount;
|
|
1369
|
+
private static toHumanAmountIfDecimals;
|
|
1370
|
+
private static normalizeHex;
|
|
1371
|
+
private static toAddressHex;
|
|
1372
|
+
private static addressToString;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
type RequiredFields<T> = {
|
|
1376
|
+
[K in keyof T]-?: T[K];
|
|
1377
|
+
};
|
|
1378
|
+
type RequiredKeys<T> = {
|
|
1379
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
1380
|
+
}[keyof T];
|
|
1381
|
+
declare function assert(condition: boolean, message: string): void;
|
|
1382
|
+
declare function getTrovesEndpoint(): string;
|
|
1383
|
+
|
|
1384
|
+
interface ManageCall {
|
|
1385
|
+
proofReadableId: string;
|
|
1386
|
+
sanitizer: ContractAddr;
|
|
1387
|
+
call: {
|
|
1388
|
+
contractAddress: ContractAddr;
|
|
1389
|
+
selector: string;
|
|
1390
|
+
calldata: bigint[];
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
interface SwapPriceInfo {
|
|
1394
|
+
source: 'avnu' | 'ekubo';
|
|
1395
|
+
fromTokenSymbol: string;
|
|
1396
|
+
toTokenSymbol: string;
|
|
1397
|
+
fromAmount: number;
|
|
1398
|
+
toAmount: number;
|
|
1399
|
+
effectivePrice: number;
|
|
1400
|
+
}
|
|
1401
|
+
interface DepositParams {
|
|
1402
|
+
amount: Web3Number;
|
|
1403
|
+
}
|
|
1404
|
+
interface WithdrawParams {
|
|
1405
|
+
amount: Web3Number;
|
|
1406
|
+
}
|
|
1407
|
+
type GenerateCallFn<T> = (params: T) => Promise<ManageCall[]>;
|
|
1408
|
+
type AdapterLeafType<T> = {
|
|
1409
|
+
leaves: LeafData[];
|
|
1410
|
+
callConstructor: GenerateCallFn<T>;
|
|
1411
|
+
};
|
|
1412
|
+
type LeafAdapterFn<T> = () => AdapterLeafType<T>;
|
|
1413
|
+
declare enum APYType {
|
|
1414
|
+
BASE = "base",
|
|
1415
|
+
REWARD = "reward",
|
|
1416
|
+
LST = "lst"
|
|
1417
|
+
}
|
|
1418
|
+
interface SupportedPosition {
|
|
1419
|
+
asset: TokenInfo;
|
|
1420
|
+
isDebt: boolean;
|
|
1421
|
+
}
|
|
1422
|
+
interface BaseAdapterConfig {
|
|
1423
|
+
baseToken: TokenInfo;
|
|
1424
|
+
supportedPositions: SupportedPosition[];
|
|
1425
|
+
networkConfig: IConfig;
|
|
1426
|
+
pricer: PricerBase;
|
|
1427
|
+
vaultAllocator: ContractAddr;
|
|
1428
|
+
vaultAddress: ContractAddr;
|
|
1429
|
+
}
|
|
1430
|
+
type PositionAPY = {
|
|
1431
|
+
apy: number;
|
|
1432
|
+
type: APYType;
|
|
1433
|
+
};
|
|
1434
|
+
type PositionInfo = {
|
|
1435
|
+
tokenInfo: TokenInfo;
|
|
1436
|
+
amount: Web3Number;
|
|
1437
|
+
usdValue: number;
|
|
1438
|
+
remarks: string;
|
|
1439
|
+
apy: PositionAPY;
|
|
1440
|
+
protocol: IProtocol;
|
|
1441
|
+
};
|
|
1442
|
+
type PositionAmount = {
|
|
1443
|
+
amount: Web3Number;
|
|
1444
|
+
remarks: string;
|
|
1445
|
+
};
|
|
1446
|
+
declare abstract class BaseAdapter<DepositParams, WithdrawParams> extends CacheClass {
|
|
1447
|
+
readonly name: string;
|
|
1448
|
+
readonly config: BaseAdapterConfig;
|
|
1449
|
+
readonly protocol: IProtocol;
|
|
1450
|
+
constructor(config: BaseAdapterConfig, name: string, protocol: IProtocol);
|
|
1451
|
+
/**
|
|
1452
|
+
* Loop through all supported positions and return amount, usd value, remarks and apy for each
|
|
1453
|
+
*/
|
|
1454
|
+
getPositions(): Promise<PositionInfo[]>;
|
|
1455
|
+
/**
|
|
1456
|
+
* Implemented by child adapters to compute APY for a given supported position
|
|
1457
|
+
*/
|
|
1458
|
+
protected abstract getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
1459
|
+
/**
|
|
1460
|
+
* Implemented by child adapters to fetch amount for a given supported position
|
|
1461
|
+
*/
|
|
1462
|
+
protected abstract getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
|
|
1463
|
+
/**
|
|
1464
|
+
* Implemented by child adapters to calculate maximum deposit positions
|
|
1465
|
+
* @param amount Optional amount in baseToken to deposit
|
|
1466
|
+
*/
|
|
1467
|
+
abstract maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
1468
|
+
/**
|
|
1469
|
+
* Implemented by child adapters to calculate maximum withdraw positions
|
|
1470
|
+
*/
|
|
1471
|
+
abstract maxWithdraw(): Promise<PositionInfo>;
|
|
1472
|
+
/**
|
|
1473
|
+
* Uses pricer to convert an amount of an asset to USD value
|
|
1474
|
+
*/
|
|
1475
|
+
protected getUSDValue(asset: TokenInfo, amount: Web3Number): Promise<number>;
|
|
1476
|
+
protected constructSimpleLeafData(params: {
|
|
1477
|
+
id: string;
|
|
1478
|
+
target: ContractAddr;
|
|
1479
|
+
method: string;
|
|
1480
|
+
packedArguments: bigint[];
|
|
1481
|
+
}, sanitizer?: ContractAddr): LeafData;
|
|
1482
|
+
/**
|
|
1483
|
+
* Implementor must provide target/method/packedArguments/sanitizer for deposit leaf construction
|
|
1484
|
+
*/
|
|
1485
|
+
protected abstract _getDepositLeaf(): {
|
|
1486
|
+
target: ContractAddr;
|
|
1487
|
+
method: string;
|
|
1488
|
+
packedArguments: bigint[];
|
|
1489
|
+
sanitizer: ContractAddr;
|
|
1490
|
+
id: string;
|
|
1491
|
+
}[];
|
|
1492
|
+
/**
|
|
1493
|
+
* Implementor must provide target/method/packedArguments/sanitizer for withdraw leaf construction
|
|
1494
|
+
*/
|
|
1495
|
+
protected abstract _getWithdrawLeaf(): {
|
|
1496
|
+
target: ContractAddr;
|
|
1497
|
+
method: string;
|
|
1498
|
+
packedArguments: bigint[];
|
|
1499
|
+
sanitizer: ContractAddr;
|
|
1500
|
+
id: string;
|
|
1501
|
+
}[];
|
|
1502
|
+
/**
|
|
1503
|
+
* Returns deposit leaf adapter using configured proof id
|
|
1504
|
+
*/
|
|
1505
|
+
getDepositLeaf(): AdapterLeafType<DepositParams>;
|
|
1506
|
+
/**
|
|
1507
|
+
* Returns withdraw leaf adapter using configured proof id
|
|
1508
|
+
*/
|
|
1509
|
+
getWithdrawLeaf(): AdapterLeafType<WithdrawParams>;
|
|
1510
|
+
/**
|
|
1511
|
+
* Implementor must provide deposit call
|
|
1512
|
+
* @param params
|
|
1513
|
+
*/
|
|
1514
|
+
abstract getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
1515
|
+
/**
|
|
1516
|
+
* Implementor must provide withdraw call
|
|
1517
|
+
* @param params
|
|
1518
|
+
*/
|
|
1519
|
+
abstract getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
1520
|
+
getProofs<T>(isDeposit: boolean, tree: StandardMerkleTree): {
|
|
1521
|
+
proofs: string[][];
|
|
1522
|
+
callConstructor: GenerateCallFn<DepositParams> | GenerateCallFn<WithdrawParams>;
|
|
1523
|
+
};
|
|
1524
|
+
getNetAPY(): Promise<number>;
|
|
1525
|
+
abstract getHealthFactor(): Promise<number>;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
interface FlashloanCallParams {
|
|
1529
|
+
amount: Web3Number;
|
|
1530
|
+
data: bigint[];
|
|
1531
|
+
}
|
|
1532
|
+
interface ApproveCallParams {
|
|
1533
|
+
amount: Web3Number;
|
|
1534
|
+
}
|
|
1535
|
+
interface AvnuSwapCallParams {
|
|
1536
|
+
props: SwapInfo;
|
|
1537
|
+
}
|
|
1538
|
+
interface CommonAdapterConfig {
|
|
1539
|
+
id: string;
|
|
1540
|
+
vaultAddress: ContractAddr;
|
|
1541
|
+
vaultAllocator: ContractAddr;
|
|
1542
|
+
manager: ContractAddr;
|
|
1543
|
+
asset: ContractAddr;
|
|
1544
|
+
}
|
|
1545
|
+
declare class CommonAdapter {
|
|
1546
|
+
config: CommonAdapterConfig;
|
|
1547
|
+
constructor(config: CommonAdapterConfig);
|
|
1548
|
+
protected constructSimpleLeafData(params: {
|
|
1549
|
+
id: string;
|
|
1550
|
+
target: ContractAddr;
|
|
1551
|
+
method: string;
|
|
1552
|
+
packedArguments: bigint[];
|
|
1553
|
+
}, sanitizer?: ContractAddr): LeafData;
|
|
1554
|
+
getFlashloanAdapter(): Promise<AdapterLeafType<FlashloanCallParams>>;
|
|
1555
|
+
getFlashloanCall(params: FlashloanCallParams): Promise<ManageCall[]>;
|
|
1556
|
+
getBringLiquidityAdapter(id: string): () => AdapterLeafType<ApproveCallParams>;
|
|
1557
|
+
getApproveAdapter(token: ContractAddr, spender: ContractAddr, id: string): () => AdapterLeafType<ApproveCallParams>;
|
|
1558
|
+
getApproveCall(token: ContractAddr, spender: ContractAddr, proofReadableId: string): (params: ApproveCallParams) => Promise<{
|
|
1559
|
+
proofReadableId: string;
|
|
1560
|
+
sanitizer: ContractAddr;
|
|
1561
|
+
call: {
|
|
1562
|
+
contractAddress: ContractAddr;
|
|
1563
|
+
selector: string;
|
|
1564
|
+
calldata: bigint[];
|
|
1565
|
+
};
|
|
1566
|
+
}[]>;
|
|
1567
|
+
getBringLiquidityCall(proofReadableId: string): GenerateCallFn<ApproveCallParams>;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
interface VesuPoolsInfo {
|
|
1571
|
+
pools: any[];
|
|
1572
|
+
isErrorPoolsAPI: boolean;
|
|
1573
|
+
}
|
|
1574
|
+
declare enum VesuAmountType {
|
|
1575
|
+
Delta = 0,
|
|
1576
|
+
Target = 1
|
|
764
1577
|
}
|
|
765
1578
|
declare enum VesuAmountDenomination {
|
|
766
1579
|
Native = 0,
|
|
@@ -852,6 +1665,28 @@ declare const VesuPools: {
|
|
|
852
1665
|
Re7xSTRK: ContractAddr;
|
|
853
1666
|
Re7xBTC: ContractAddr;
|
|
854
1667
|
Re7USDCPrime: ContractAddr;
|
|
1668
|
+
Prime: ContractAddr;
|
|
1669
|
+
Re7STRK: ContractAddr;
|
|
1670
|
+
};
|
|
1671
|
+
declare const VesuPoolMetadata: {
|
|
1672
|
+
[VesuPools.Genesis.address]: {
|
|
1673
|
+
name: string;
|
|
1674
|
+
};
|
|
1675
|
+
[VesuPools.Re7xSTRK.address]: {
|
|
1676
|
+
name: string;
|
|
1677
|
+
};
|
|
1678
|
+
[VesuPools.Re7xBTC.address]: {
|
|
1679
|
+
name: string;
|
|
1680
|
+
};
|
|
1681
|
+
[VesuPools.Prime.address]: {
|
|
1682
|
+
name: string;
|
|
1683
|
+
};
|
|
1684
|
+
[VesuPools.Re7STRK.address]: {
|
|
1685
|
+
name: string;
|
|
1686
|
+
};
|
|
1687
|
+
[VesuPools.Re7USDCPrime.address]: {
|
|
1688
|
+
name: string;
|
|
1689
|
+
};
|
|
855
1690
|
};
|
|
856
1691
|
declare const extensionMap: {
|
|
857
1692
|
[key: string]: ContractAddr;
|
|
@@ -863,11 +1698,42 @@ declare function getVesuSingletonAddress(vesuPool: ContractAddr): {
|
|
|
863
1698
|
declare class VesuAdapter extends CacheClass {
|
|
864
1699
|
VESU_MULTIPLY_V1: ContractAddr;
|
|
865
1700
|
VESU_MULTIPLY: ContractAddr;
|
|
1701
|
+
VESU_WITHDRAW_SWAP_FIXED_MULTIPLIER: ContractAddr;
|
|
866
1702
|
config: VesuAdapterConfig;
|
|
867
1703
|
networkConfig: IConfig | undefined;
|
|
868
1704
|
pricer: PricerBase | undefined;
|
|
869
1705
|
constructor(config: VesuAdapterConfig);
|
|
870
|
-
|
|
1706
|
+
static getDefaultModifyPositionCallParams(params: {
|
|
1707
|
+
collateralAmount: Web3Number;
|
|
1708
|
+
isAddCollateral: boolean;
|
|
1709
|
+
debtAmount: Web3Number;
|
|
1710
|
+
isBorrow: boolean;
|
|
1711
|
+
}): {
|
|
1712
|
+
collateralAmount: {
|
|
1713
|
+
amount_type: VesuAmountType;
|
|
1714
|
+
denomination: VesuAmountDenomination;
|
|
1715
|
+
value: {
|
|
1716
|
+
abs: Web3Number;
|
|
1717
|
+
is_negative: boolean;
|
|
1718
|
+
};
|
|
1719
|
+
};
|
|
1720
|
+
debtAmount: {
|
|
1721
|
+
amount_type: VesuAmountType;
|
|
1722
|
+
denomination: VesuAmountDenomination;
|
|
1723
|
+
value: {
|
|
1724
|
+
abs: Web3Number;
|
|
1725
|
+
is_negative: boolean;
|
|
1726
|
+
};
|
|
1727
|
+
};
|
|
1728
|
+
};
|
|
1729
|
+
getVesuModifyDelegationCall: (delegatee: ContractAddr) => (params: VesuModifyDelegationCallParams) => {
|
|
1730
|
+
sanitizer: ContractAddr;
|
|
1731
|
+
call: {
|
|
1732
|
+
contractAddress: ContractAddr;
|
|
1733
|
+
selector: string;
|
|
1734
|
+
calldata: bigint[];
|
|
1735
|
+
};
|
|
1736
|
+
};
|
|
871
1737
|
formatAmountTypeEnum(amountType: VesuAmountType): CairoCustomEnum;
|
|
872
1738
|
formatAmountDenominationEnum(denomination: VesuAmountDenomination): CairoCustomEnum;
|
|
873
1739
|
getVesuSingletonContract(config: IConfig, poolId: ContractAddr): {
|
|
@@ -876,7 +1742,11 @@ declare class VesuAdapter extends CacheClass {
|
|
|
876
1742
|
};
|
|
877
1743
|
getDebtCap(config: IConfig): Promise<Web3Number>;
|
|
878
1744
|
getCurrentDebtUtilisationAmount(config: IConfig): Promise<Web3Number>;
|
|
879
|
-
getMaxBorrowableByInterestRate(config: IConfig, asset: TokenInfo, maxBorrowAPY: number): Promise<
|
|
1745
|
+
getMaxBorrowableByInterestRate(config: IConfig, asset: TokenInfo, maxBorrowAPY: number): Promise<{
|
|
1746
|
+
maxDebtToHave: Web3Number;
|
|
1747
|
+
currentDebt: Web3Number;
|
|
1748
|
+
totalSupply: Web3Number;
|
|
1749
|
+
}>;
|
|
880
1750
|
getLTVConfig(config: IConfig, blockNumber?: BlockIdentifier): Promise<number>;
|
|
881
1751
|
getPositions(config: IConfig, blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
|
|
882
1752
|
getCollateralization(config: IConfig, blockNumber?: BlockIdentifier): Promise<Omit<VaultPosition, 'amount'>[]>;
|
|
@@ -913,6 +1783,9 @@ declare class VesuSupplyOnlyAdapter extends BaseAdapter<DepositParams, WithdrawP
|
|
|
913
1783
|
readonly config: VesuSupplyOnlyAdapterConfig;
|
|
914
1784
|
readonly tokenMarketData: TokenMarketData;
|
|
915
1785
|
constructor(config: VesuSupplyOnlyAdapterConfig);
|
|
1786
|
+
private _depositApproveProofReadableId;
|
|
1787
|
+
private _depositCallProofReadableId;
|
|
1788
|
+
private _withdrawCallProofReadableId;
|
|
916
1789
|
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
917
1790
|
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
918
1791
|
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
@@ -938,23 +1811,50 @@ declare class VesuSupplyOnlyAdapter extends BaseAdapter<DepositParams, WithdrawP
|
|
|
938
1811
|
getHealthFactor(): Promise<number>;
|
|
939
1812
|
}
|
|
940
1813
|
|
|
1814
|
+
interface VesuDepositParams {
|
|
1815
|
+
amount: Web3Number;
|
|
1816
|
+
marginSwap?: {
|
|
1817
|
+
marginToken: TokenInfo;
|
|
1818
|
+
};
|
|
1819
|
+
leverSwap?: {
|
|
1820
|
+
exactOutput?: Web3Number;
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
interface VesuWithdrawParams {
|
|
1824
|
+
amount: Web3Number;
|
|
1825
|
+
withdrawSwap?: {
|
|
1826
|
+
outputToken: TokenInfo;
|
|
1827
|
+
};
|
|
1828
|
+
}
|
|
941
1829
|
interface VesuMultiplyAdapterConfig extends BaseAdapterConfig {
|
|
942
1830
|
poolId: ContractAddr;
|
|
943
1831
|
collateral: TokenInfo;
|
|
944
1832
|
debt: TokenInfo;
|
|
1833
|
+
marginToken: TokenInfo;
|
|
945
1834
|
targetHealthFactor: number;
|
|
946
1835
|
minHealthFactor: number;
|
|
947
1836
|
quoteAmountToFetchPrice: Web3Number;
|
|
948
1837
|
minimumVesuMovementAmount: number;
|
|
1838
|
+
maxSlippage?: number;
|
|
949
1839
|
}
|
|
950
|
-
declare class VesuMultiplyAdapter extends BaseAdapter<
|
|
1840
|
+
declare class VesuMultiplyAdapter extends BaseAdapter<VesuDepositParams, VesuWithdrawParams> {
|
|
951
1841
|
readonly config: VesuMultiplyAdapterConfig;
|
|
952
|
-
readonly
|
|
1842
|
+
readonly _vesuAdapter: VesuAdapter;
|
|
953
1843
|
readonly tokenMarketData: TokenMarketData;
|
|
954
1844
|
readonly minimumVesuMovementAmount: number;
|
|
1845
|
+
lastSwapPriceInfo: SwapPriceInfo | null;
|
|
1846
|
+
maxSlippage: number;
|
|
955
1847
|
constructor(config: VesuMultiplyAdapterConfig);
|
|
1848
|
+
private _getMultiplyContract;
|
|
1849
|
+
private _buildDelegationWrappedCalls;
|
|
1850
|
+
private _getDepositProofReadableIds;
|
|
1851
|
+
private _getWithdrawProofReadableIds;
|
|
1852
|
+
private _buildZeroAmountSwapsWithWeights;
|
|
1853
|
+
private _fetchPositionAndPrices;
|
|
1854
|
+
private _computeTargetDebtDelta;
|
|
1855
|
+
private _getPositionCommonContext;
|
|
956
1856
|
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
957
|
-
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
1857
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
|
|
958
1858
|
maxBorrowableAPY(): Promise<number>;
|
|
959
1859
|
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
960
1860
|
maxWithdraw(): Promise<PositionInfo>;
|
|
@@ -972,18 +1872,79 @@ declare class VesuMultiplyAdapter extends BaseAdapter<DepositParams, WithdrawPar
|
|
|
972
1872
|
sanitizer: ContractAddr;
|
|
973
1873
|
id: string;
|
|
974
1874
|
}[];
|
|
975
|
-
getDepositAdapter(): AdapterLeafType<
|
|
976
|
-
getWithdrawAdapter(): AdapterLeafType<
|
|
977
|
-
getDepositCall(params:
|
|
978
|
-
getWithdrawCall(params:
|
|
979
|
-
private
|
|
980
|
-
private
|
|
981
|
-
private
|
|
1875
|
+
getDepositAdapter(approveToken?: TokenInfo): AdapterLeafType<VesuDepositParams>;
|
|
1876
|
+
getWithdrawAdapter(): AdapterLeafType<VesuWithdrawParams>;
|
|
1877
|
+
getDepositCall(params: VesuDepositParams): Promise<ManageCall[]>;
|
|
1878
|
+
getWithdrawCall(params: VesuWithdrawParams): Promise<ManageCall[]>;
|
|
1879
|
+
private _getIncreaseCalldata;
|
|
1880
|
+
private _buildDecreaseLikeCalldata;
|
|
1881
|
+
private _getDecreaseCalldata;
|
|
982
1882
|
formatMultiplyParams(isIncrease: boolean, params: IncreaseLeverParams | DecreaseLeverParams): {
|
|
983
1883
|
action: CairoCustomEnum;
|
|
984
1884
|
};
|
|
985
1885
|
getHealthFactor(): Promise<number>;
|
|
986
|
-
getNetAPY(): Promise<number>;
|
|
1886
|
+
getNetAPY(): Promise<number>;
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
interface VesuModifyPositionDepositParams {
|
|
1890
|
+
amount: Web3Number;
|
|
1891
|
+
debtAmount?: Web3Number;
|
|
1892
|
+
}
|
|
1893
|
+
interface VesuModifyPositionWithdrawParams {
|
|
1894
|
+
amount: Web3Number;
|
|
1895
|
+
debtAmount?: Web3Number;
|
|
1896
|
+
}
|
|
1897
|
+
interface VesuModifyPositionAdapterConfig extends BaseAdapterConfig {
|
|
1898
|
+
poolId: ContractAddr;
|
|
1899
|
+
collateral: TokenInfo;
|
|
1900
|
+
debt: TokenInfo;
|
|
1901
|
+
targetLtv: number;
|
|
1902
|
+
maxLtv: number;
|
|
1903
|
+
}
|
|
1904
|
+
declare class VesuModifyPositionAdapter extends BaseAdapter<VesuModifyPositionDepositParams, VesuModifyPositionWithdrawParams> {
|
|
1905
|
+
readonly config: VesuModifyPositionAdapterConfig;
|
|
1906
|
+
readonly _vesuAdapter: VesuAdapter;
|
|
1907
|
+
private readonly _tokenMarketData;
|
|
1908
|
+
constructor(config: VesuModifyPositionAdapterConfig);
|
|
1909
|
+
private _prepareVesuAdapter;
|
|
1910
|
+
private _getTargetHealthFactor;
|
|
1911
|
+
private _getPositionCommonContext;
|
|
1912
|
+
private _getEffectiveMaxLtv;
|
|
1913
|
+
private _toSigned;
|
|
1914
|
+
private _depositApproveProofReadableId;
|
|
1915
|
+
private _depositModifyProofReadableId;
|
|
1916
|
+
private _withdrawApproveProofReadableId;
|
|
1917
|
+
private _withdrawModifyProofReadableId;
|
|
1918
|
+
private _clampWithdrawCollateral;
|
|
1919
|
+
private _clampRepayDebt;
|
|
1920
|
+
private _normalizeDebtAmountFromHelper;
|
|
1921
|
+
private _getState;
|
|
1922
|
+
private _buildDefaultDepositDeltas;
|
|
1923
|
+
private _buildDefaultWithdrawDeltas;
|
|
1924
|
+
private _amountStruct;
|
|
1925
|
+
private _getModifyPositionCall;
|
|
1926
|
+
private _getApproveCall;
|
|
1927
|
+
protected getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
1928
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
1929
|
+
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
1930
|
+
maxWithdraw(): Promise<PositionInfo>;
|
|
1931
|
+
protected _getDepositLeaf(): {
|
|
1932
|
+
target: ContractAddr;
|
|
1933
|
+
method: string;
|
|
1934
|
+
packedArguments: bigint[];
|
|
1935
|
+
sanitizer: ContractAddr;
|
|
1936
|
+
id: string;
|
|
1937
|
+
}[];
|
|
1938
|
+
protected _getWithdrawLeaf(): {
|
|
1939
|
+
target: ContractAddr;
|
|
1940
|
+
method: string;
|
|
1941
|
+
packedArguments: bigint[];
|
|
1942
|
+
sanitizer: ContractAddr;
|
|
1943
|
+
id: string;
|
|
1944
|
+
}[];
|
|
1945
|
+
getDepositCall(params: VesuModifyPositionDepositParams): Promise<ManageCall[]>;
|
|
1946
|
+
getWithdrawCall(params: VesuModifyPositionWithdrawParams): Promise<ManageCall[]>;
|
|
1947
|
+
getHealthFactor(): Promise<number>;
|
|
987
1948
|
}
|
|
988
1949
|
|
|
989
1950
|
/**
|
|
@@ -1057,9 +2018,10 @@ declare enum AssetOperationType {
|
|
|
1057
2018
|
TRANSFER = "TRANSFER"
|
|
1058
2019
|
}
|
|
1059
2020
|
declare enum AssetOperationStatus {
|
|
1060
|
-
|
|
2021
|
+
CREATED = "CREATED",
|
|
2022
|
+
IN_PROGRESS = "IN_PROGRESS",
|
|
1061
2023
|
COMPLETED = "COMPLETED",
|
|
1062
|
-
|
|
2024
|
+
REJECTED = "REJECTED"
|
|
1063
2025
|
}
|
|
1064
2026
|
interface SettlementSignature {
|
|
1065
2027
|
r: string;
|
|
@@ -1240,7 +2202,8 @@ interface ExtendedApiResponse<T> {
|
|
|
1240
2202
|
data: T;
|
|
1241
2203
|
}
|
|
1242
2204
|
interface ExtendedWrapperConfig {
|
|
1243
|
-
|
|
2205
|
+
readUrl: string;
|
|
2206
|
+
writeUrl: string;
|
|
1244
2207
|
apiKey?: string;
|
|
1245
2208
|
timeout?: number;
|
|
1246
2209
|
retries?: number;
|
|
@@ -1254,6 +2217,25 @@ interface FundingRate {
|
|
|
1254
2217
|
f: string;
|
|
1255
2218
|
t: number;
|
|
1256
2219
|
}
|
|
2220
|
+
interface FundingPayment {
|
|
2221
|
+
id: number;
|
|
2222
|
+
accountId?: number;
|
|
2223
|
+
account_id?: number;
|
|
2224
|
+
market: string;
|
|
2225
|
+
positionId?: number;
|
|
2226
|
+
position_id?: number;
|
|
2227
|
+
side: PositionSide;
|
|
2228
|
+
size: string;
|
|
2229
|
+
value: string;
|
|
2230
|
+
markPrice?: string;
|
|
2231
|
+
mark_price?: string;
|
|
2232
|
+
fundingFee?: string;
|
|
2233
|
+
funding_fee?: string;
|
|
2234
|
+
fundingRate?: string;
|
|
2235
|
+
funding_rate?: string;
|
|
2236
|
+
paidTime?: number;
|
|
2237
|
+
paid_time?: number;
|
|
2238
|
+
}
|
|
1257
2239
|
|
|
1258
2240
|
/**
|
|
1259
2241
|
* ExtendedWrapper - TypeScript wrapper for Extended Exchange API
|
|
@@ -1261,7 +2243,8 @@ interface FundingRate {
|
|
|
1261
2243
|
*/
|
|
1262
2244
|
|
|
1263
2245
|
declare class ExtendedWrapper {
|
|
1264
|
-
private
|
|
2246
|
+
private readUrl;
|
|
2247
|
+
private writeUrl;
|
|
1265
2248
|
private apiKey?;
|
|
1266
2249
|
private timeout;
|
|
1267
2250
|
private retries;
|
|
@@ -1279,10 +2262,10 @@ declare class ExtendedWrapper {
|
|
|
1279
2262
|
*/
|
|
1280
2263
|
getMarkets(marketNames?: string): Promise<ExtendedApiResponse<Market[]>>;
|
|
1281
2264
|
/**
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
2265
|
+
*
|
|
2266
|
+
* @param orderId - The ID of the order to get
|
|
2267
|
+
* @returns The order
|
|
2268
|
+
*/
|
|
1286
2269
|
getOrderByOrderId(orderId: string): Promise<ExtendedApiResponse<OpenOrder>>;
|
|
1287
2270
|
/**
|
|
1288
2271
|
* Get market statistics for a specific market
|
|
@@ -1346,21 +2329,23 @@ declare class ExtendedWrapper {
|
|
|
1346
2329
|
*/
|
|
1347
2330
|
createBuyOrder(marketName: string, amount: string, price: string, options?: {
|
|
1348
2331
|
postOnly?: boolean;
|
|
2332
|
+
reduceOnly?: boolean;
|
|
1349
2333
|
previousOrderId?: number;
|
|
1350
2334
|
externalId?: string;
|
|
1351
2335
|
timeInForce?: TimeInForce;
|
|
1352
2336
|
}): Promise<ExtendedApiResponse<PlacedOrder>>;
|
|
1353
2337
|
/**
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
2338
|
+
* Get order by ID
|
|
2339
|
+
* @param orderId - The ID of the order to get
|
|
2340
|
+
* @returns The order
|
|
2341
|
+
*/
|
|
1358
2342
|
getOrderById(orderId: number): Promise<ExtendedApiResponse<OpenOrder>>;
|
|
1359
2343
|
/**
|
|
1360
2344
|
* Convenience method to create a sell order
|
|
1361
2345
|
*/
|
|
1362
2346
|
createSellOrder(marketName: string, amount: string, price: string, options?: {
|
|
1363
2347
|
postOnly?: boolean;
|
|
2348
|
+
reduceOnly?: boolean;
|
|
1364
2349
|
previousOrderId?: number;
|
|
1365
2350
|
externalId?: string;
|
|
1366
2351
|
timeInForce?: TimeInForce;
|
|
@@ -1393,32 +2378,11 @@ declare class ExtendedWrapper {
|
|
|
1393
2378
|
* @param marketName - The name of the market to get funding rates for
|
|
1394
2379
|
* @returns The funding rates for the specified market
|
|
1395
2380
|
*/
|
|
1396
|
-
getFundingRates(marketName: string, side: string, startTime
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
token_to: string;
|
|
1402
|
-
exchange_address: string;
|
|
1403
|
-
percent: number;
|
|
1404
|
-
additional_swap_params: string[];
|
|
1405
|
-
}
|
|
1406
|
-
interface SwapInfo {
|
|
1407
|
-
token_from_address: string;
|
|
1408
|
-
token_from_amount: Uint256;
|
|
1409
|
-
token_to_address: string;
|
|
1410
|
-
token_to_amount: Uint256;
|
|
1411
|
-
token_to_min_amount: Uint256;
|
|
1412
|
-
beneficiary: string;
|
|
1413
|
-
integrator_fee_amount_bps: number;
|
|
1414
|
-
integrator_fee_recipient: string;
|
|
1415
|
-
routes: Route[];
|
|
1416
|
-
}
|
|
1417
|
-
declare class AvnuWrapper {
|
|
1418
|
-
getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number, excludeSources?: string[]): Promise<Quote>;
|
|
1419
|
-
getSwapInfo(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount?: string, options?: AvnuOptions): Promise<SwapInfo>;
|
|
1420
|
-
static buildZeroSwap(tokenToSell: ContractAddr, beneficiary: string, tokenToBuy?: ContractAddr): SwapInfo;
|
|
1421
|
-
getSwapCallData(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string): Promise<bigint[][]>;
|
|
2381
|
+
getFundingRates(marketName: string, side: string, startTime?: number, endTime?: number): Promise<ExtendedApiResponse<FundingRate[]>>;
|
|
2382
|
+
/**
|
|
2383
|
+
* Get funding payments for a specific market.
|
|
2384
|
+
*/
|
|
2385
|
+
getUserFundingPayments(marketName: string, side: string, startTime: number, limit?: number, cursor?: number): Promise<ExtendedApiResponse<FundingPayment[]>>;
|
|
1422
2386
|
}
|
|
1423
2387
|
|
|
1424
2388
|
interface AvnuAdapterConfig extends BaseAdapterConfig {
|
|
@@ -1431,9 +2395,16 @@ interface AvnuAdapterConfig extends BaseAdapterConfig {
|
|
|
1431
2395
|
declare class AvnuAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
1432
2396
|
readonly config: AvnuAdapterConfig;
|
|
1433
2397
|
protected avnuWrapper: AvnuWrapper;
|
|
2398
|
+
lastSwapPriceInfo: SwapPriceInfo | null;
|
|
2399
|
+
private _depositApproveProofReadableId;
|
|
2400
|
+
private _depositSwapProofReadableId;
|
|
2401
|
+
private _withdrawApproveProofReadableId;
|
|
2402
|
+
private _withdrawSwapProofReadableId;
|
|
2403
|
+
private buildSwapLeafConfigs;
|
|
2404
|
+
private buildSwapCalls;
|
|
1434
2405
|
constructor(config: AvnuAdapterConfig);
|
|
1435
2406
|
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
1436
|
-
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
2407
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
|
|
1437
2408
|
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
1438
2409
|
maxWithdraw(): Promise<PositionInfo>;
|
|
1439
2410
|
protected _getDepositLeaf(): {
|
|
@@ -1462,9 +2433,6 @@ declare class AvnuAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
|
1462
2433
|
getSwapCallData(quote: Quote): Promise<bigint[][]>;
|
|
1463
2434
|
getHealthFactor(): Promise<number>;
|
|
1464
2435
|
fetchQuoteWithRetry(params: Record<string, any>, retries?: number): Promise<any>;
|
|
1465
|
-
getQuotesAvnu(from_token_address: string, to_token_address: string, amount: number, //amount in btc units
|
|
1466
|
-
takerAddress: string, toTokenDecimals: number, usdcToBtc: boolean, maxIterations?: number, tolerance?: number): Promise<Quote | null>;
|
|
1467
|
-
getPriceOfToken(tokenAddress: string, retries?: number): Promise<number | null>;
|
|
1468
2436
|
}
|
|
1469
2437
|
|
|
1470
2438
|
interface ExtendedAdapterConfig extends BaseAdapterConfig {
|
|
@@ -1484,9 +2452,12 @@ interface ExtendedAdapterConfig extends BaseAdapterConfig {
|
|
|
1484
2452
|
declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
1485
2453
|
readonly config: ExtendedAdapterConfig;
|
|
1486
2454
|
readonly client: ExtendedWrapper;
|
|
2455
|
+
readonly usdceToken: TokenInfo;
|
|
1487
2456
|
readonly retryDelayForOrderStatus: number;
|
|
1488
2457
|
readonly minimumExtendedMovementAmount: number;
|
|
1489
2458
|
constructor(config: ExtendedAdapterConfig);
|
|
2459
|
+
private _depositApproveProofReadableId;
|
|
2460
|
+
private _depositCallProofReadableId;
|
|
1490
2461
|
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
1491
2462
|
getFundingRates(side: string, startTime?: number, endTime?: number): Promise<{
|
|
1492
2463
|
success: boolean;
|
|
@@ -1502,14 +2473,6 @@ declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams>
|
|
|
1502
2473
|
sanitizer: ContractAddr;
|
|
1503
2474
|
id: string;
|
|
1504
2475
|
}[];
|
|
1505
|
-
getSwapFromLegacyLeaf(): AdapterLeafType<DepositParams>;
|
|
1506
|
-
protected _getSwapFromLegacyLeaf(): {
|
|
1507
|
-
target: ContractAddr;
|
|
1508
|
-
method: string;
|
|
1509
|
-
packedArguments: bigint[];
|
|
1510
|
-
sanitizer: ContractAddr;
|
|
1511
|
-
id: string;
|
|
1512
|
-
}[];
|
|
1513
2476
|
protected _getWithdrawLeaf(): {
|
|
1514
2477
|
target: ContractAddr;
|
|
1515
2478
|
method: string;
|
|
@@ -1518,11 +2481,6 @@ declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams>
|
|
|
1518
2481
|
id: string;
|
|
1519
2482
|
}[];
|
|
1520
2483
|
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
1521
|
-
getProofsForFromLegacySwap<T>(tree: StandardMerkleTree): {
|
|
1522
|
-
proofs: string[][];
|
|
1523
|
-
callConstructor: GenerateCallFn<DepositParams> | GenerateCallFn<WithdrawParams>;
|
|
1524
|
-
};
|
|
1525
|
-
getSwapFromLegacyCall(params: DepositParams): Promise<ManageCall[]>;
|
|
1526
2484
|
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
1527
2485
|
withdrawFromExtended(amount: Web3Number): Promise<{
|
|
1528
2486
|
status: boolean;
|
|
@@ -1532,9 +2490,8 @@ declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams>
|
|
|
1532
2490
|
getExtendedDepositAmount(): Promise<Balance | undefined>;
|
|
1533
2491
|
setLeverage(leverage: string, marketName: string): Promise<boolean>;
|
|
1534
2492
|
getAllOpenPositions(): Promise<Position[] | null>;
|
|
1535
|
-
getOrderHistory(marketName: string): Promise<OpenOrder[] | null>;
|
|
1536
2493
|
getOrderStatus(orderId: string, marketName: string): Promise<OpenOrder | null>;
|
|
1537
|
-
|
|
2494
|
+
fetchOrderBookFromExtended(): Promise<{
|
|
1538
2495
|
status: boolean;
|
|
1539
2496
|
bid: Web3Number;
|
|
1540
2497
|
ask: Web3Number;
|
|
@@ -1563,14 +2520,30 @@ declare const AVNU_EXCHANGE_FOR_LEGACY_USDC: ContractAddr;
|
|
|
1563
2520
|
declare const AVNU_QUOTE_URL = "https://starknet.api.avnu.fi/swap/v3/quotes";
|
|
1564
2521
|
declare const EXTENDED_CONTRACT: ContractAddr;
|
|
1565
2522
|
declare const VESU_SINGLETON: ContractAddr;
|
|
2523
|
+
declare const TRANSFER_SANITIZER: ContractAddr;
|
|
1566
2524
|
declare function toBigInt(value: string | number): bigint;
|
|
1567
2525
|
|
|
1568
|
-
interface
|
|
2526
|
+
interface TokenTransferAdapterConfig extends BaseAdapterConfig {
|
|
2527
|
+
/** Address that funds are sent FROM during deposit (and returned TO during withdraw) */
|
|
2528
|
+
fromAddress: ContractAddr;
|
|
2529
|
+
/** Address that funds are sent TO during deposit (and pulled FROM during withdraw) */
|
|
2530
|
+
toAddress: ContractAddr;
|
|
1569
2531
|
}
|
|
1570
|
-
|
|
1571
|
-
|
|
2532
|
+
/**
|
|
2533
|
+
* Adapter for transferring a single token between two fixed addresses.
|
|
2534
|
+
*
|
|
2535
|
+
* Deposit: transfers baseToken from `fromAddress` → `toAddress`
|
|
2536
|
+
* Withdraw: transfers baseToken from `toAddress` → `fromAddress` (requires toAddress to approve fromAddress/VA)
|
|
2537
|
+
*
|
|
2538
|
+
* Proof IDs are derived from `tr_<symbol>_<toAddrShort>` to be unique per token+destination pair.
|
|
2539
|
+
*/
|
|
2540
|
+
declare class TokenTransferAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
2541
|
+
readonly config: TokenTransferAdapterConfig;
|
|
1572
2542
|
readonly tokenMarketData: TokenMarketData;
|
|
1573
|
-
constructor(config:
|
|
2543
|
+
constructor(config: TokenTransferAdapterConfig);
|
|
2544
|
+
private _idBase;
|
|
2545
|
+
private _depositCallProofReadableId;
|
|
2546
|
+
private _withdrawCallProofReadableId;
|
|
1574
2547
|
protected getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
1575
2548
|
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
1576
2549
|
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
@@ -1589,464 +2562,170 @@ declare class UnusedBalanceAdapter extends BaseAdapter<DepositParams, WithdrawPa
|
|
|
1589
2562
|
sanitizer: ContractAddr;
|
|
1590
2563
|
id: string;
|
|
1591
2564
|
}[];
|
|
1592
|
-
getHealthFactor(): Promise<number>;
|
|
1593
2565
|
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
1594
2566
|
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
2567
|
+
getHealthFactor(): Promise<number>;
|
|
1595
2568
|
}
|
|
1596
2569
|
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
}
|
|
1601
|
-
interface SingleTokenInfo extends SingleActionAmount {
|
|
1602
|
-
usdValue: number;
|
|
1603
|
-
}
|
|
1604
|
-
interface APYInfo {
|
|
1605
|
-
net: number;
|
|
1606
|
-
splits: {
|
|
1607
|
-
apy: number;
|
|
1608
|
-
id: string;
|
|
1609
|
-
}[];
|
|
1610
|
-
}
|
|
1611
|
-
interface DualActionAmount {
|
|
1612
|
-
token0: SingleActionAmount;
|
|
1613
|
-
token1: SingleActionAmount;
|
|
1614
|
-
}
|
|
1615
|
-
interface DualTokenInfo {
|
|
1616
|
-
usdValue: number;
|
|
1617
|
-
token0: SingleTokenInfo;
|
|
1618
|
-
token1: SingleTokenInfo;
|
|
1619
|
-
}
|
|
1620
|
-
interface CacheData {
|
|
1621
|
-
timestamp: number;
|
|
1622
|
-
ttl: number;
|
|
1623
|
-
data: any;
|
|
1624
|
-
}
|
|
1625
|
-
declare class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
|
|
1626
|
-
readonly config: IConfig;
|
|
1627
|
-
readonly cache: Map<string, CacheData>;
|
|
1628
|
-
constructor(config: IConfig);
|
|
1629
|
-
getUserTVL(user: ContractAddr): Promise<TVLInfo>;
|
|
1630
|
-
getTVL(): Promise<TVLInfo>;
|
|
1631
|
-
depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Promise<Call[]>;
|
|
1632
|
-
withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
1633
|
-
getVaultPositions(): Promise<VaultPosition[]>;
|
|
1634
|
-
getUnusedBalance(): Promise<SingleTokenInfo>;
|
|
1635
|
-
netAPY(): Promise<APYInfo>;
|
|
1636
|
-
getAUM(): Promise<{
|
|
1637
|
-
net: SingleTokenInfo;
|
|
1638
|
-
prevAum: Web3Number;
|
|
1639
|
-
splits: PositionInfo[];
|
|
1640
|
-
}>;
|
|
1641
|
-
getHealthFactors(): Promise<number[]>;
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
/**
|
|
1645
|
-
* TokenMarketData class that combines LST APR and Midas modules
|
|
1646
|
-
* to provide unified APY, price, and TVL functions for tokens
|
|
1647
|
-
*/
|
|
1648
|
-
declare class TokenMarketData {
|
|
1649
|
-
private pricer;
|
|
1650
|
-
private config;
|
|
1651
|
-
constructor(pricer: PricerBase, config: IConfig);
|
|
1652
|
-
/**
|
|
1653
|
-
* Get APY for a token
|
|
1654
|
-
* - If it's an LST token, returns LST APY
|
|
1655
|
-
* - If it's a Midas token, returns Midas APY
|
|
1656
|
-
* - Otherwise returns 0
|
|
1657
|
-
* @param tokenInfo The token to get APY for
|
|
1658
|
-
* @returns APY in absolute terms (not percentage)
|
|
1659
|
-
*/
|
|
1660
|
-
getAPY(tokenInfo: TokenInfo): Promise<number>;
|
|
1661
|
-
/**
|
|
1662
|
-
* Get price for a token using the pricer module
|
|
1663
|
-
* @param tokenInfo The token to get price for
|
|
1664
|
-
* @returns Price as a number
|
|
1665
|
-
* @throws Error if price is 0 or unavailable
|
|
1666
|
-
*/
|
|
1667
|
-
getPrice(tokenInfo: TokenInfo): Promise<number>;
|
|
1668
|
-
/**
|
|
1669
|
-
* Get true price for a token
|
|
1670
|
-
* - For LST tokens: Uses convert_to_assets to get true exchange rate
|
|
1671
|
-
* - For Midas tokens: Uses Midas price API
|
|
1672
|
-
* - For other tokens: Falls back to regular pricer
|
|
1673
|
-
* @param tokenInfo The token to get true price for
|
|
1674
|
-
* @returns True price as a number
|
|
1675
|
-
* @throws Error if price is 0 or unavailable
|
|
1676
|
-
*/
|
|
1677
|
-
getTruePrice(tokenInfo: TokenInfo): Promise<number>;
|
|
1678
|
-
/**
|
|
1679
|
-
* Get TVL for a token
|
|
1680
|
-
* - If it's a Midas token, returns Midas TVL data
|
|
1681
|
-
* - Otherwise returns 0
|
|
1682
|
-
* @param tokenInfo The token to get TVL for
|
|
1683
|
-
* @returns TVL as SingleTokenInfo or 0
|
|
1684
|
-
*/
|
|
1685
|
-
getTVL(tokenInfo: TokenInfo): Promise<SingleTokenInfo>;
|
|
1686
|
-
/**
|
|
1687
|
-
* Check if a token is supported for APY data
|
|
1688
|
-
* @param tokenInfo The token to check
|
|
1689
|
-
* @returns True if the token has APY data available
|
|
1690
|
-
*/
|
|
1691
|
-
isAPYSupported(tokenInfo: TokenInfo): boolean;
|
|
1692
|
-
/**
|
|
1693
|
-
* Check if a token is supported for TVL data
|
|
1694
|
-
* @param tokenInfo The token to check
|
|
1695
|
-
* @returns True if the token has TVL data available
|
|
1696
|
-
*/
|
|
1697
|
-
isTVLSupported(tokenInfo: TokenInfo): boolean;
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
declare class Pragma {
|
|
1701
|
-
contractAddr: string;
|
|
1702
|
-
readonly contract: Contract;
|
|
1703
|
-
constructor(provider: RpcProvider);
|
|
1704
|
-
getPrice(tokenAddr: string): Promise<number>;
|
|
1705
|
-
}
|
|
1706
|
-
|
|
1707
|
-
declare class ZkLend extends ILending implements ILending {
|
|
1708
|
-
readonly pricer: Pricer;
|
|
1709
|
-
static readonly POOLS_URL = "https://app.zklend.com/api/pools";
|
|
1710
|
-
private POSITION_URL;
|
|
1711
|
-
constructor(config: IConfig, pricer: Pricer);
|
|
1712
|
-
init(): Promise<void>;
|
|
1713
|
-
/**
|
|
1714
|
-
* @description Get the health factor of the user for given lending and debt tokens
|
|
1715
|
-
* @param lending_tokens
|
|
1716
|
-
* @param debt_tokens
|
|
1717
|
-
* @param user
|
|
1718
|
-
* @returns hf (e.g. returns 1.5 for 150% health factor)
|
|
1719
|
-
*/
|
|
1720
|
-
get_health_factor_tokenwise(lending_tokens: TokenInfo[], debt_tokens: TokenInfo[], user: ContractAddr): Promise<number>;
|
|
1721
|
-
/**
|
|
1722
|
-
* @description Get the health factor of the user
|
|
1723
|
-
* - Considers all tokens for collateral and debt
|
|
1724
|
-
*/
|
|
1725
|
-
get_health_factor(user: ContractAddr): Promise<number>;
|
|
1726
|
-
getPositionsSummary(user: ContractAddr): Promise<{
|
|
1727
|
-
collateralUSD: number;
|
|
1728
|
-
debtUSD: number;
|
|
1729
|
-
}>;
|
|
1730
|
-
/**
|
|
1731
|
-
* @description Get the token-wise collateral and debt positions of the user
|
|
1732
|
-
* @param user Contract address of the user
|
|
1733
|
-
* @returns Promise<ILendingPosition[]>
|
|
1734
|
-
*/
|
|
1735
|
-
getPositions(user: ContractAddr): Promise<ILendingPosition[]>;
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
declare class PricerFromApi extends PricerBase {
|
|
1739
|
-
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
1740
|
-
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
1741
|
-
getPriceFromMyAPI(tokenSymbol: string): Promise<{
|
|
1742
|
-
price: number;
|
|
1743
|
-
timestamp: Date;
|
|
1744
|
-
}>;
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
declare class ERC20 {
|
|
1748
|
-
readonly config: IConfig;
|
|
1749
|
-
constructor(config: IConfig);
|
|
1750
|
-
contract(addr: string | ContractAddr): Contract;
|
|
1751
|
-
balanceOf(token: string | ContractAddr, address: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
|
|
1752
|
-
allowance(token: string | ContractAddr, owner: string | ContractAddr, spender: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
|
|
1753
|
-
transfer(token: string | ContractAddr, to: string | ContractAddr, amount: Web3Number): starknet.Call;
|
|
1754
|
-
approve(token: string | ContractAddr, spender: string | ContractAddr, amount: Web3Number): starknet.Call;
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
declare class AutoCompounderSTRK {
|
|
1758
|
-
readonly config: IConfig;
|
|
1759
|
-
readonly addr: ContractAddr;
|
|
1760
|
-
readonly pricer: Pricer;
|
|
1761
|
-
private initialized;
|
|
1762
|
-
contract: Contract | null;
|
|
1763
|
-
readonly metadata: {
|
|
1764
|
-
decimals: number;
|
|
1765
|
-
underlying: {
|
|
1766
|
-
address: ContractAddr;
|
|
1767
|
-
name: string;
|
|
1768
|
-
symbol: string;
|
|
1769
|
-
};
|
|
1770
|
-
name: string;
|
|
1771
|
-
};
|
|
1772
|
-
constructor(config: IConfig, pricer: Pricer);
|
|
1773
|
-
init(): Promise<void>;
|
|
1774
|
-
waitForInitilisation(): Promise<void>;
|
|
1775
|
-
/** Returns shares of user */
|
|
1776
|
-
balanceOf(user: ContractAddr): Promise<Web3Number>;
|
|
1777
|
-
/** Returns underlying assets of user */
|
|
1778
|
-
balanceOfUnderlying(user: ContractAddr): Promise<Web3Number>;
|
|
1779
|
-
/** Returns usd value of assets */
|
|
1780
|
-
usdBalanceOfUnderlying(user: ContractAddr): Promise<{
|
|
1781
|
-
usd: Web3Number;
|
|
1782
|
-
assets: Web3Number;
|
|
1783
|
-
}>;
|
|
2570
|
+
declare enum LSTPriceType {
|
|
2571
|
+
ENDUR_PRICE = "ENDUR_PRICE",
|
|
2572
|
+
AVNU_PRICE = "AVNU_PRICE"
|
|
1784
2573
|
}
|
|
1785
2574
|
|
|
1786
|
-
interface
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
}
|
|
1791
|
-
interface Change {
|
|
1792
|
-
pool_id: ContractAddr;
|
|
1793
|
-
changeAmt: Web3Number;
|
|
1794
|
-
finalAmt: Web3Number;
|
|
1795
|
-
isDeposit: boolean;
|
|
2575
|
+
interface UniversalManageCall {
|
|
2576
|
+
proofs: string[];
|
|
2577
|
+
manageCall: ManageCall;
|
|
2578
|
+
step: UNIVERSAL_MANAGE_IDS;
|
|
1796
2579
|
}
|
|
1797
|
-
interface
|
|
1798
|
-
|
|
2580
|
+
interface UniversalStrategySettings {
|
|
2581
|
+
vaultAddress: ContractAddr;
|
|
2582
|
+
manager: ContractAddr;
|
|
2583
|
+
vaultAllocator: ContractAddr;
|
|
2584
|
+
redeemRequestNFT: ContractAddr;
|
|
2585
|
+
aumOracle: ContractAddr;
|
|
2586
|
+
redemptionRouter?: ContractAddr;
|
|
2587
|
+
leafAdapters: LeafAdapterFn<any>[];
|
|
2588
|
+
adapters: {
|
|
2589
|
+
id: string;
|
|
2590
|
+
adapter: BaseAdapter<DepositParams, WithdrawParams>;
|
|
2591
|
+
}[];
|
|
2592
|
+
targetHealthFactor: number;
|
|
2593
|
+
minHealthFactor: number;
|
|
1799
2594
|
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
max_weight: number;
|
|
1804
|
-
current_weight: number;
|
|
1805
|
-
v_token: ContractAddr;
|
|
1806
|
-
amount: Web3Number;
|
|
1807
|
-
usdValue: Web3Number;
|
|
1808
|
-
APY: {
|
|
1809
|
-
baseApy: number;
|
|
1810
|
-
defiSpringApy: number;
|
|
1811
|
-
netApy: number;
|
|
1812
|
-
};
|
|
1813
|
-
currentUtilization: number;
|
|
1814
|
-
maxUtilization: number;
|
|
2595
|
+
declare enum AUMTypes {
|
|
2596
|
+
FINALISED = "finalised",
|
|
2597
|
+
DEFISPRING = "defispring"
|
|
1815
2598
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
2599
|
+
declare enum PositionTypeAvnuExtended {
|
|
2600
|
+
OPEN = "open",
|
|
2601
|
+
CLOSE = "close"
|
|
2602
|
+
}
|
|
2603
|
+
declare class UniversalStrategy<S extends UniversalStrategySettings> extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
1822
2604
|
/** Contract address of the strategy */
|
|
1823
2605
|
readonly address: ContractAddr;
|
|
1824
2606
|
/** Pricer instance for token price calculations */
|
|
1825
2607
|
readonly pricer: PricerBase;
|
|
1826
2608
|
/** Metadata containing strategy information */
|
|
1827
|
-
readonly metadata: IStrategyMetadata<
|
|
2609
|
+
readonly metadata: IStrategyMetadata<S>;
|
|
1828
2610
|
/** Contract instance for interacting with the strategy */
|
|
1829
2611
|
readonly contract: Contract;
|
|
1830
|
-
readonly
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
* Creates a deposit call to the strategy contract.
|
|
1841
|
-
* @param assets - Amount of assets to deposit
|
|
1842
|
-
* @param receiver - Address that will receive the strategy tokens
|
|
1843
|
-
* @returns Populated contract call for deposit
|
|
1844
|
-
*/
|
|
1845
|
-
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<starknet.Call[]>;
|
|
1846
|
-
/**
|
|
1847
|
-
* Creates a withdrawal call to the strategy contract.
|
|
1848
|
-
* @param assets - Amount of assets to withdraw
|
|
1849
|
-
* @param receiver - Address that will receive the withdrawn assets
|
|
1850
|
-
* @param owner - Address that owns the strategy tokens
|
|
1851
|
-
* @returns Populated contract call for withdrawal
|
|
1852
|
-
*/
|
|
1853
|
-
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<starknet.Call[]>;
|
|
1854
|
-
/**
|
|
1855
|
-
* Returns the underlying asset token of the strategy.
|
|
1856
|
-
* @returns The deposit token supported by this strategy
|
|
1857
|
-
*/
|
|
2612
|
+
readonly managerContract: Contract;
|
|
2613
|
+
merkleTree: StandardMerkleTree | undefined;
|
|
2614
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
|
|
2615
|
+
getMerkleTree(): StandardMerkleTree;
|
|
2616
|
+
getMerkleRoot(): string;
|
|
2617
|
+
getProofs<T>(id: string): {
|
|
2618
|
+
proofs: string[];
|
|
2619
|
+
callConstructor: GenerateCallFn<T>;
|
|
2620
|
+
};
|
|
2621
|
+
getAdapter(id: string): BaseAdapter<any, any>;
|
|
1858
2622
|
asset(): TokenInfo;
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
*/
|
|
1863
|
-
decimals(): number;
|
|
1864
|
-
/**
|
|
1865
|
-
* Calculates the Total Value Locked (TVL) for a specific user.
|
|
1866
|
-
* @param user - Address of the user
|
|
1867
|
-
* @returns Object containing the amount in token units and USD value
|
|
1868
|
-
*/
|
|
1869
|
-
getUserTVL(user: ContractAddr): Promise<{
|
|
1870
|
-
tokenInfo: TokenInfo;
|
|
1871
|
-
amount: Web3Number;
|
|
1872
|
-
usdValue: number;
|
|
1873
|
-
}>;
|
|
1874
|
-
/**
|
|
1875
|
-
* Calculates the total TVL of the strategy.
|
|
1876
|
-
* @returns Object containing the total amount in token units and USD value
|
|
1877
|
-
*/
|
|
1878
|
-
getTVL(): Promise<{
|
|
2623
|
+
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
2624
|
+
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
2625
|
+
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<{
|
|
1879
2626
|
tokenInfo: TokenInfo;
|
|
1880
2627
|
amount: Web3Number;
|
|
1881
2628
|
usdValue: number;
|
|
1882
2629
|
}>;
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
max_weight: number;
|
|
1888
|
-
current_weight: number;
|
|
1889
|
-
v_token: ContractAddr;
|
|
1890
|
-
amount: Web3Number;
|
|
1891
|
-
usdValue: Web3Number;
|
|
1892
|
-
APY: {
|
|
1893
|
-
baseApy: number;
|
|
1894
|
-
defiSpringApy: number;
|
|
1895
|
-
netApy: number;
|
|
1896
|
-
};
|
|
1897
|
-
currentUtilization: number;
|
|
1898
|
-
maxUtilization: number;
|
|
2630
|
+
getVesuAPYs(): Promise<{
|
|
2631
|
+
baseAPYs: number[];
|
|
2632
|
+
rewardAPYs: number[];
|
|
2633
|
+
positions: VaultPosition[];
|
|
1899
2634
|
}>;
|
|
1900
2635
|
/**
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
* 2. Vesu positions API for current positions
|
|
1904
|
-
* 3. Vesu pools API for APY and utilization data
|
|
1905
|
-
*
|
|
1906
|
-
* @returns {Promise<{
|
|
1907
|
-
* data: Array<PoolInfoFull>,
|
|
1908
|
-
* isErrorPositionsAPI: boolean
|
|
1909
|
-
* }>} Object containing:
|
|
1910
|
-
* - data: Array of pool information including IDs, weights, amounts, APYs and utilization
|
|
1911
|
-
* - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
|
|
2636
|
+
* Calculates the weighted average APY across all pools based on USD value.
|
|
2637
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
1912
2638
|
*/
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
current_weight: number;
|
|
1919
|
-
v_token: ContractAddr;
|
|
1920
|
-
amount: Web3Number;
|
|
1921
|
-
usdValue: Web3Number;
|
|
1922
|
-
APY: {
|
|
1923
|
-
baseApy: number;
|
|
1924
|
-
defiSpringApy: number;
|
|
1925
|
-
netApy: number;
|
|
1926
|
-
};
|
|
1927
|
-
currentUtilization: number;
|
|
1928
|
-
maxUtilization: number;
|
|
2639
|
+
netAPY(): Promise<{
|
|
2640
|
+
net: number;
|
|
2641
|
+
splits: {
|
|
2642
|
+
apy: number;
|
|
2643
|
+
id: string;
|
|
1929
2644
|
}[];
|
|
1930
|
-
isErrorPositionsAPI: boolean;
|
|
1931
|
-
isErrorPoolsAPI: boolean;
|
|
1932
|
-
isError: boolean;
|
|
1933
2645
|
}>;
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
2646
|
+
protected returnNetAPY(baseAPYs: number[], rewardAPYs: number[], weights: number[], prevAUMUSD: Web3Number): Promise<{
|
|
2647
|
+
net: number;
|
|
2648
|
+
splits: {
|
|
2649
|
+
apy: number;
|
|
2650
|
+
id: string;
|
|
2651
|
+
}[];
|
|
1937
2652
|
}>;
|
|
2653
|
+
protected getUnusedBalanceAPY(): Promise<{
|
|
2654
|
+
apy: number;
|
|
2655
|
+
weight: number;
|
|
2656
|
+
}>;
|
|
2657
|
+
private computeAPY;
|
|
1938
2658
|
/**
|
|
1939
|
-
* Calculates
|
|
1940
|
-
*
|
|
1941
|
-
*/
|
|
1942
|
-
netAPY(): Promise<APYInfo>;
|
|
1943
|
-
/**
|
|
1944
|
-
* Calculates the weighted average APY across all pools based on USD value.
|
|
1945
|
-
* @returns {Promise<number>} The weighted average APY across all pools
|
|
2659
|
+
* Calculates user realized APY based on trueSharesBasedAPY method.
|
|
2660
|
+
* Returns the APY as a number.
|
|
1946
2661
|
*/
|
|
1947
|
-
|
|
2662
|
+
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
1948
2663
|
/**
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
*
|
|
1957
|
-
* @returns {Promise<{
|
|
1958
|
-
* changes: Change[],
|
|
1959
|
-
* finalPools: PoolInfoFull[],
|
|
1960
|
-
* isAnyPoolOverMaxWeight: boolean
|
|
1961
|
-
* }>} Object containing:
|
|
1962
|
-
* - changes: Array of position changes
|
|
1963
|
-
* - finalPools: Array of pool information after rebalance
|
|
1964
|
-
* @throws Error if rebalance is not possible while maintaining constraints
|
|
1965
|
-
*/
|
|
1966
|
-
getRebalancedPositions(_pools?: PoolInfoFull[]): Promise<{
|
|
1967
|
-
changes: never[];
|
|
1968
|
-
finalPools: never[];
|
|
1969
|
-
isAnyPoolOverMaxWeight?: undefined;
|
|
1970
|
-
} | {
|
|
1971
|
-
changes: Change[];
|
|
1972
|
-
finalPools: PoolInfoFull[];
|
|
1973
|
-
isAnyPoolOverMaxWeight: boolean;
|
|
2664
|
+
* Calculates the total TVL of the strategy.
|
|
2665
|
+
* @returns Object containing the total amount in token units and USD value
|
|
2666
|
+
*/
|
|
2667
|
+
getTVL(): Promise<{
|
|
2668
|
+
tokenInfo: TokenInfo;
|
|
2669
|
+
amount: Web3Number;
|
|
2670
|
+
usdValue: number;
|
|
1974
2671
|
}>;
|
|
2672
|
+
getUnusedBalance(): Promise<SingleTokenInfo>;
|
|
2673
|
+
protected getVesuAUM(adapter: VesuAdapter, _priceType?: LSTPriceType): Promise<Web3Number>;
|
|
2674
|
+
getPrevAUM(): Promise<Web3Number>;
|
|
2675
|
+
getAUM(unrealizedAUM?: boolean): Promise<{
|
|
2676
|
+
net: SingleTokenInfo;
|
|
2677
|
+
prevAum: Web3Number;
|
|
2678
|
+
splits: {
|
|
2679
|
+
id: string;
|
|
2680
|
+
aum: Web3Number;
|
|
2681
|
+
}[];
|
|
2682
|
+
}>;
|
|
2683
|
+
protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
|
|
2684
|
+
getVesuAdapters(): VesuAdapter[];
|
|
2685
|
+
getVesuPositions(blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
|
|
2686
|
+
getVaultPositions(): Promise<VaultPosition[]>;
|
|
2687
|
+
getSetManagerCall(strategist: ContractAddr, root?: string): Call;
|
|
2688
|
+
getManageCall(proofIds: string[], manageCalls: ManageCall[]): Call;
|
|
2689
|
+
getVesuModifyPositionCalls(params: {
|
|
2690
|
+
isLeg1: boolean;
|
|
2691
|
+
isDeposit: boolean;
|
|
2692
|
+
depositAmount: Web3Number;
|
|
2693
|
+
debtAmount: Web3Number;
|
|
2694
|
+
}): UniversalManageCall[];
|
|
2695
|
+
getTag(): string;
|
|
1975
2696
|
/**
|
|
1976
|
-
*
|
|
1977
|
-
* @
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
/**
|
|
1984
|
-
*
|
|
1985
|
-
* @param
|
|
1986
|
-
* @
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
}
|
|
2004
|
-
declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
2005
|
-
readonly address: ContractAddr;
|
|
2006
|
-
readonly metadata: IStrategyMetadata<SenseiVaultSettings>;
|
|
2007
|
-
readonly pricer: PricerBase;
|
|
2008
|
-
readonly contract: Contract;
|
|
2009
|
-
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>);
|
|
2010
|
-
getUserTVL(user: ContractAddr): Promise<SingleTokenInfo>;
|
|
2011
|
-
getTVL(): Promise<SingleTokenInfo>;
|
|
2012
|
-
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
2013
|
-
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
2014
|
-
getPositionInfo(): Promise<{
|
|
2015
|
-
collateralXSTRK: Web3Number;
|
|
2016
|
-
collateralUSDValue: Web3Number;
|
|
2017
|
-
debtSTRK: Web3Number;
|
|
2018
|
-
debtUSDValue: Web3Number;
|
|
2019
|
-
xSTRKPrice: number;
|
|
2020
|
-
collateralInSTRK: number;
|
|
2697
|
+
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
2698
|
+
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
2699
|
+
*/
|
|
2700
|
+
getLSTAPR(address: ContractAddr): Promise<number>;
|
|
2701
|
+
getVesuHealthFactors(blockNumber?: BlockIdentifier): Promise<number[]>;
|
|
2702
|
+
computeRebalanceConditionAndReturnCalls(): Promise<Call[]>;
|
|
2703
|
+
private getNewHealthFactor;
|
|
2704
|
+
/**
|
|
2705
|
+
*
|
|
2706
|
+
* @param vesuAdapter
|
|
2707
|
+
* @param currentHf
|
|
2708
|
+
* @param isDeposit if true, attempt by adding collateral, else by repaying
|
|
2709
|
+
* @returns
|
|
2710
|
+
*/
|
|
2711
|
+
private getLegRebalanceAmount;
|
|
2712
|
+
getVesuModifyPositionCall(params: {
|
|
2713
|
+
isDeposit: boolean;
|
|
2714
|
+
leg1DepositAmount: Web3Number;
|
|
2715
|
+
}): Promise<Call>;
|
|
2716
|
+
getBringLiquidityCall(params: {
|
|
2717
|
+
amount: Web3Number;
|
|
2718
|
+
}): Promise<Call>;
|
|
2719
|
+
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
2720
|
+
getHarvestCall(): Promise<{
|
|
2721
|
+
call: Call;
|
|
2722
|
+
reward: Web3Number;
|
|
2723
|
+
tokenInfo: TokenInfo;
|
|
2021
2724
|
}>;
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
interface UniversalManageCall {
|
|
2028
|
-
proofs: string[];
|
|
2029
|
-
manageCall: ManageCall;
|
|
2030
|
-
step: UNIVERSAL_MANAGE_IDS;
|
|
2031
|
-
}
|
|
2032
|
-
interface UniversalStrategySettings {
|
|
2033
|
-
vaultAddress: ContractAddr;
|
|
2034
|
-
manager: ContractAddr;
|
|
2035
|
-
vaultAllocator: ContractAddr;
|
|
2036
|
-
redeemRequestNFT: ContractAddr;
|
|
2037
|
-
leafAdapters: LeafAdapterFn<any>[];
|
|
2038
|
-
adapters: {
|
|
2039
|
-
id: string;
|
|
2040
|
-
adapter: BaseAdapter<DepositParams, WithdrawParams>;
|
|
2041
|
-
}[];
|
|
2042
|
-
}
|
|
2043
|
-
declare enum AUMTypes {
|
|
2044
|
-
FINALISED = "finalised",
|
|
2045
|
-
DEFISPRING = "defispring"
|
|
2046
|
-
}
|
|
2047
|
-
declare enum PositionTypeAvnuExtended {
|
|
2048
|
-
OPEN = "open",
|
|
2049
|
-
CLOSE = "close"
|
|
2725
|
+
getRebalanceCall(params: {
|
|
2726
|
+
isLeg1toLeg2: boolean;
|
|
2727
|
+
amount: Web3Number;
|
|
2728
|
+
}): Promise<Call>;
|
|
2050
2729
|
}
|
|
2051
2730
|
declare enum UNIVERSAL_MANAGE_IDS {
|
|
2052
2731
|
FLASH_LOAN = "flash_loan_init",
|
|
@@ -2060,12 +2739,18 @@ declare enum UNIVERSAL_MANAGE_IDS {
|
|
|
2060
2739
|
APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
|
|
2061
2740
|
AVNU_SWAP_REWARDS = "avnu_swap_rewards"
|
|
2062
2741
|
}
|
|
2742
|
+
declare enum UNIVERSAL_ADAPTERS {
|
|
2743
|
+
COMMON = "common_adapter",
|
|
2744
|
+
VESU_LEG1 = "vesu_leg1_adapter",
|
|
2745
|
+
VESU_LEG2 = "vesu_leg2_adapter"
|
|
2746
|
+
}
|
|
2063
2747
|
declare function getContractDetails(settings: UniversalStrategySettings & {
|
|
2064
2748
|
aumOracle?: ContractAddr;
|
|
2065
2749
|
}): {
|
|
2066
2750
|
address: ContractAddr;
|
|
2067
2751
|
name: string;
|
|
2068
2752
|
}[];
|
|
2753
|
+
declare const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[];
|
|
2069
2754
|
|
|
2070
2755
|
/**
|
|
2071
2756
|
* Base class for all SVK (Starknet Vault Kit) strategies.
|
|
@@ -2089,11 +2774,20 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
|
|
|
2089
2774
|
* Returns the asset token for this strategy
|
|
2090
2775
|
*/
|
|
2091
2776
|
asset(): TokenInfo;
|
|
2777
|
+
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
2778
|
+
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
2092
2779
|
/**
|
|
2093
2780
|
* Returns the unused balance in the vault allocator.
|
|
2094
2781
|
* Note: This function is common for any SVK strategy.
|
|
2095
2782
|
*/
|
|
2096
2783
|
getUnusedBalance(): Promise<SingleTokenInfo>;
|
|
2784
|
+
/**
|
|
2785
|
+
* Builds a manage call from an adapter's proof tree.
|
|
2786
|
+
* DRY helper for the repeated getProofs → getManageCall pattern.
|
|
2787
|
+
*/
|
|
2788
|
+
protected buildManageCallFromAdapter(adapter: {
|
|
2789
|
+
getProofs: (isDeposit: boolean, tree: any) => any;
|
|
2790
|
+
}, isDeposit: boolean, amount: Web3Number): Promise<Call>;
|
|
2097
2791
|
/**
|
|
2098
2792
|
* Bridges liquidity from the vault allocator back to the vault.
|
|
2099
2793
|
* Note: This function is common for any SVK strategy.
|
|
@@ -2101,6 +2795,11 @@ declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends
|
|
|
2101
2795
|
getBringLiquidityCall(params: {
|
|
2102
2796
|
amount: Web3Number;
|
|
2103
2797
|
}): Promise<Call>;
|
|
2798
|
+
/**
|
|
2799
|
+
* Resolves ordered merkle proofs from emitted manage calls.
|
|
2800
|
+
* This ensures only runtime-required proofs are passed to manager calls.
|
|
2801
|
+
*/
|
|
2802
|
+
protected getProofGroupsForManageCalls(manageCalls: ManageCall[]): string[][];
|
|
2104
2803
|
/**
|
|
2105
2804
|
* Gets all leaves from all leaf adapters.
|
|
2106
2805
|
* Note: This function is common for any SVK strategy.
|
|
@@ -2163,27 +2862,791 @@ declare class UniversalLstMultiplierStrategy<S extends HyperLSTStrategySettings>
|
|
|
2163
2862
|
getTag(): string;
|
|
2164
2863
|
getVesuSameTokenAdapter(): VesuMultiplyAdapter;
|
|
2165
2864
|
getVesuAdapters(): VesuMultiplyAdapter[];
|
|
2865
|
+
getRewardsAUM(_prevAum: Web3Number): Promise<Web3Number>;
|
|
2866
|
+
getLSTDexPrice(): Promise<number>;
|
|
2867
|
+
getLSTAvnuRate(): Promise<number>;
|
|
2868
|
+
getLSTExchangeRate(): Promise<number>;
|
|
2869
|
+
private _getMinOutputAmountLSTBuy;
|
|
2870
|
+
private _getMinOutputAmountLSTSell;
|
|
2871
|
+
/**
|
|
2872
|
+
* Uses vesu's multiple call to create leverage on LST
|
|
2873
|
+
* Deposit amount is in LST
|
|
2874
|
+
* @param params
|
|
2875
|
+
*/
|
|
2876
|
+
getFundManagementCall(params: {
|
|
2877
|
+
isDeposit: boolean;
|
|
2878
|
+
leg1DepositAmount: Web3Number;
|
|
2879
|
+
}): Promise<Call[] | null>;
|
|
2880
|
+
getLSTUnderlyingTokenInfo(): TokenInfo;
|
|
2881
|
+
getLSTAPR(_address: ContractAddr): Promise<number>;
|
|
2882
|
+
netAPY(): Promise<{
|
|
2883
|
+
net: number;
|
|
2884
|
+
splits: {
|
|
2885
|
+
apy: number;
|
|
2886
|
+
id: string;
|
|
2887
|
+
}[];
|
|
2888
|
+
}>;
|
|
2889
|
+
maxNewDeposits(params?: {
|
|
2890
|
+
isAPYComputation: boolean;
|
|
2891
|
+
}): Promise<number>;
|
|
2892
|
+
protected getUnusedBalanceAPY(): Promise<{
|
|
2893
|
+
apy: number;
|
|
2894
|
+
weight: number;
|
|
2895
|
+
}>;
|
|
2896
|
+
getAUM(unrealizedAUM?: boolean): Promise<{
|
|
2897
|
+
net: SingleTokenInfo;
|
|
2898
|
+
prevAum: Web3Number;
|
|
2899
|
+
splits: PositionInfo[];
|
|
2900
|
+
}>;
|
|
2901
|
+
getTVLUnrealized(): Promise<{
|
|
2902
|
+
net: SingleTokenInfo;
|
|
2903
|
+
prevAum: Web3Number;
|
|
2904
|
+
splits: PositionInfo[];
|
|
2905
|
+
}>;
|
|
2906
|
+
getUserUnrealizedGains(user: ContractAddr): Promise<{
|
|
2907
|
+
unrealizedGains: Web3Number;
|
|
2908
|
+
userShare: number;
|
|
2909
|
+
tokenInfo: TokenInfo;
|
|
2910
|
+
}>;
|
|
2911
|
+
}
|
|
2912
|
+
declare const AUDIT_URL = "https://docs.troves.fi/p/security#starknet-vault-kit";
|
|
2913
|
+
declare function getFAQs(lstSymbol: string, underlyingSymbol: string, isLST: boolean): FAQ[];
|
|
2914
|
+
declare const _riskFactor: RiskFactor[];
|
|
2915
|
+
declare function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string): string[];
|
|
2916
|
+
declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
|
|
2917
|
+
|
|
2918
|
+
/**
|
|
2919
|
+
* Snapshot of a single Vesu pool's position: collateral, debt, and their prices.
|
|
2920
|
+
*/
|
|
2921
|
+
interface VesuPoolState {
|
|
2922
|
+
poolId: ContractAddr;
|
|
2923
|
+
collateralToken: TokenInfo;
|
|
2924
|
+
debtToken: TokenInfo;
|
|
2925
|
+
collateralAmount: Web3Number;
|
|
2926
|
+
collateralUsdValue: number;
|
|
2927
|
+
debtAmount: Web3Number;
|
|
2928
|
+
debtUsdValue: number;
|
|
2929
|
+
collateralPrice: number;
|
|
2930
|
+
debtPrice: number;
|
|
2931
|
+
}
|
|
2932
|
+
/**
|
|
2933
|
+
* Snapshot of a single Extended exchange open position.
|
|
2934
|
+
*/
|
|
2935
|
+
interface ExtendedPositionState {
|
|
2936
|
+
instrument: string;
|
|
2937
|
+
side: string;
|
|
2938
|
+
size: Web3Number;
|
|
2939
|
+
valueUsd: Web3Number;
|
|
2940
|
+
leverage: string;
|
|
2941
|
+
}
|
|
2942
|
+
/**
|
|
2943
|
+
* Snapshot of the Extended exchange account-level balance.
|
|
2944
|
+
*/
|
|
2945
|
+
interface ExtendedBalanceState {
|
|
2946
|
+
equity: Web3Number;
|
|
2947
|
+
availableForTrade: Web3Number;
|
|
2948
|
+
availableForWithdrawal: Web3Number;
|
|
2949
|
+
unrealisedPnl: Web3Number;
|
|
2950
|
+
balance: Web3Number;
|
|
2951
|
+
/**
|
|
2952
|
+
* Funds in transit to/from Extended.
|
|
2953
|
+
* Positive = deposit in transit (funds left wallet, not yet credited on Extended).
|
|
2954
|
+
* Negative = withdrawal in transit (funds left Extended, not yet received in wallet).
|
|
2955
|
+
*/
|
|
2956
|
+
pendingDeposit: Web3Number;
|
|
2957
|
+
}
|
|
2958
|
+
/**
|
|
2959
|
+
* Generic token balance with USD valuation.
|
|
2960
|
+
*/
|
|
2961
|
+
interface TokenBalance {
|
|
2962
|
+
token: TokenInfo;
|
|
2963
|
+
amount: Web3Number;
|
|
2964
|
+
usdValue: number;
|
|
2965
|
+
}
|
|
2966
|
+
/**
|
|
2967
|
+
* Per-position exposure change on the Extended exchange.
|
|
2968
|
+
* Positive delta = increase position size, negative = reduce.
|
|
2969
|
+
*/
|
|
2970
|
+
interface ExtendedPositionDelta {
|
|
2971
|
+
instrument: string;
|
|
2972
|
+
delta: Web3Number;
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* Per-pool position change on Vesu.
|
|
2976
|
+
* debtDelta: positive = borrow more, negative = repay.
|
|
2977
|
+
* collateralDelta: positive = add collateral, negative = remove.
|
|
2978
|
+
*/
|
|
2979
|
+
interface VesuPoolDelta {
|
|
2980
|
+
poolId: ContractAddr;
|
|
2981
|
+
collateralToken: TokenInfo;
|
|
2982
|
+
debtToken: TokenInfo;
|
|
2983
|
+
debtDelta: Web3Number;
|
|
2984
|
+
collateralDelta: Web3Number;
|
|
2985
|
+
collateralPrice: number;
|
|
2986
|
+
debtPrice: number;
|
|
2987
|
+
}
|
|
2988
|
+
/**
|
|
2989
|
+
* Enumerates all possible fund-routing paths used during execution.
|
|
2990
|
+
*/
|
|
2991
|
+
declare enum RouteType {
|
|
2992
|
+
/** P1: Deposit USDC.e from operator wallet directly to Extended exchange */
|
|
2993
|
+
WALLET_TO_EXTENDED = "WALLET_TO_EXTENDED",
|
|
2994
|
+
/** P2: USDC from vault allocator → swap to USDC.e → deposit to Extended */
|
|
2995
|
+
VA_TO_EXTENDED = "VA_TO_EXTENDED",
|
|
2996
|
+
/** Withdraw from Extended exchange → operator wallet */
|
|
2997
|
+
EXTENDED_TO_WALLET = "EXTENDED_TO_WALLET",
|
|
2998
|
+
/** Swap USDC → BTC to deposit to Vesu */
|
|
2999
|
+
AVNU_DEPOSIT_SWAP = "AVNU_DEPOSIT_SWAP",
|
|
3000
|
+
/** Increase leverage on Vesu i.e. deposit on vesu, borrow, in one go to create lever */
|
|
3001
|
+
VESU_MULTIPLY_INCREASE_LEVER = "VESU_MULTIPLY_INCREASE_LEVER",
|
|
3002
|
+
/** Decrease leverage on Vesu i.e. withdraw from vesu, repay, in one go to reduce leverage */
|
|
3003
|
+
VESU_MULTIPLY_DECREASE_LEVER = "VESU_MULTIPLY_DECREASE_LEVER",
|
|
3004
|
+
/** Swap BTC → USDC to withdraw from Vesu */
|
|
3005
|
+
AVNU_WITHDRAW_SWAP = "AVNU_WITHDRAW_SWAP",
|
|
3006
|
+
/** Borrow additional USDC from Vesu (when wallet + VA insufficient for Extended) */
|
|
3007
|
+
VESU_BORROW = "VESU_BORROW",
|
|
3008
|
+
/** Repay USDC debt to Vesu (debtDelta < 0) */
|
|
3009
|
+
VESU_REPAY = "VESU_REPAY",
|
|
3010
|
+
/** Transfer USDC.e from operator wallet to vault allocator */
|
|
3011
|
+
WALLET_TO_VA = "WALLET_TO_VA",
|
|
3012
|
+
/** Realize PnL on Extended exchange */
|
|
3013
|
+
REALISE_PNL = "REALISE_PNL",
|
|
3014
|
+
/** Increase leverage on Extended exchange i.e. deposit on extended, in one go to create lever */
|
|
3015
|
+
EXTENDED_INCREASE_LEVER = "EXTENDED_INCREASE_LEVER",
|
|
3016
|
+
/** Decrease leverage on Extended exchange i.e. withdraw from extended, in one go to reduce leverage */
|
|
3017
|
+
EXTENDED_DECREASE_LEVER = "EXTENDED_DECREASE_LEVER",
|
|
3018
|
+
/** Increase leverage on Extended exchange to max leverage (e.g. 4x from 3x) */
|
|
3019
|
+
CRISIS_INCREASE_EXTENDED_MAX_LEVERAGE = "CRISIS_INCREASE_EXTENDER_MAX_LEVERAGE",
|
|
3020
|
+
/** Undo max leverage on Extended exchange to reduce leverage (e.g. 4x to 3x) */
|
|
3021
|
+
CRISIS_UNDO_EXTENDED_MAX_LEVERAGE = "CRISIS_UNDO_EXTENDED_MAX_LEVERAGE",
|
|
3022
|
+
/** Borrow beyyond target HF (e.g. 1.2 from 1.4) */
|
|
3023
|
+
CRISIS_BORROW_BEYOND_TARGET_HF = "CRISIS_BORROW_BEYOND_TARGET_HF",
|
|
3024
|
+
/** Bring liquidity from vault allocator to vault contract (for user withdrawals) */
|
|
3025
|
+
BRING_LIQUIDITY = "BRING_LIQUIDITY",
|
|
3026
|
+
RETURN_TO_WAIT = "RETURN_TO_WAIT"
|
|
3027
|
+
}
|
|
3028
|
+
/** Common fields shared by every route variant */
|
|
3029
|
+
interface RouteBase {
|
|
3030
|
+
/** Execution order — lower values execute first */
|
|
3031
|
+
priority: number;
|
|
3032
|
+
}
|
|
3033
|
+
/** Simple fund-transfer routes: WALLET_TO_EXTENDED, VA_TO_EXTENDED, EXTENDED_TO_WALLET, WALLET_TO_VA */
|
|
3034
|
+
interface TransferRoute extends RouteBase {
|
|
3035
|
+
type: RouteType.WALLET_TO_EXTENDED | RouteType.VA_TO_EXTENDED | RouteType.EXTENDED_TO_WALLET | RouteType.WALLET_TO_VA;
|
|
3036
|
+
/** Amount to transfer */
|
|
3037
|
+
amount: Web3Number;
|
|
3038
|
+
}
|
|
3039
|
+
/** AVNU swap routes: AVNU_DEPOSIT_SWAP (USDC→BTC), AVNU_WITHDRAW_SWAP (BTC→USDC) */
|
|
3040
|
+
interface SwapRoute extends RouteBase {
|
|
3041
|
+
type: RouteType.AVNU_DEPOSIT_SWAP | RouteType.AVNU_WITHDRAW_SWAP;
|
|
3042
|
+
/** Source token symbol */
|
|
3043
|
+
fromToken: string;
|
|
3044
|
+
/** Source amount */
|
|
3045
|
+
fromAmount: Web3Number;
|
|
3046
|
+
/** Destination token symbol */
|
|
3047
|
+
toToken: string;
|
|
3048
|
+
/** Exact output amount (if known; otherwise undefined means best-effort) */
|
|
3049
|
+
toAmount?: Web3Number;
|
|
3050
|
+
}
|
|
3051
|
+
/** Vesu multiply lever routes: deposit+borrow or withdraw+repay in one go */
|
|
3052
|
+
interface VesuMultiplyRoute extends RouteBase {
|
|
3053
|
+
type: RouteType.VESU_MULTIPLY_INCREASE_LEVER | RouteType.VESU_MULTIPLY_DECREASE_LEVER;
|
|
3054
|
+
/** Pool to interact with */
|
|
3055
|
+
poolId: ContractAddr;
|
|
3056
|
+
/** Collateral token info */
|
|
3057
|
+
collateralToken: TokenInfo;
|
|
3058
|
+
/** Collateral amount delta (positive = deposit, negative = withdraw) */
|
|
3059
|
+
marginAmount: Web3Number;
|
|
3060
|
+
swappedCollateralAmount: Web3Number;
|
|
3061
|
+
/** Debt token info */
|
|
3062
|
+
debtToken: TokenInfo;
|
|
3063
|
+
/** Debt amount delta (positive = borrow, negative = repay) */
|
|
3064
|
+
debtAmount: Web3Number;
|
|
3065
|
+
}
|
|
3066
|
+
/** Vesu single-side borrow / repay routes */
|
|
3067
|
+
interface VesuDebtRoute extends RouteBase {
|
|
3068
|
+
type: RouteType.VESU_BORROW | RouteType.VESU_REPAY;
|
|
3069
|
+
/** Pool to interact with */
|
|
3070
|
+
poolId: ContractAddr;
|
|
3071
|
+
/** Amount to borrow (positive) or repay (negative) */
|
|
3072
|
+
amount: Web3Number;
|
|
3073
|
+
/** Collateral token info */
|
|
3074
|
+
collateralToken: TokenInfo;
|
|
3075
|
+
/** Debt token info */
|
|
3076
|
+
debtToken: TokenInfo;
|
|
3077
|
+
}
|
|
3078
|
+
/** Realise PnL on Extended exchange */
|
|
3079
|
+
interface RealisePnlRoute extends RouteBase {
|
|
3080
|
+
type: RouteType.REALISE_PNL;
|
|
3081
|
+
/** Amount of PnL to realise (the shortfall beyond available-to-withdraw) */
|
|
3082
|
+
amount: Web3Number;
|
|
3083
|
+
/** Extended instrument name (e.g. "BTC-USD") */
|
|
3084
|
+
instrument: string;
|
|
3085
|
+
}
|
|
3086
|
+
/** Increase / decrease leverage on Extended exchange */
|
|
3087
|
+
interface ExtendedLeverRoute extends RouteBase {
|
|
3088
|
+
type: RouteType.EXTENDED_INCREASE_LEVER | RouteType.EXTENDED_DECREASE_LEVER;
|
|
3089
|
+
/** Change in exposure denominated in the exposure token */
|
|
3090
|
+
amount: Web3Number;
|
|
3091
|
+
/** Extended instrument name (e.g. "BTC-USD") */
|
|
3092
|
+
instrument: string;
|
|
3093
|
+
}
|
|
3094
|
+
/** Crisis: temporarily increase / undo max leverage on Extended — no args for now */
|
|
3095
|
+
interface CrisisExtendedLeverRoute extends RouteBase {
|
|
3096
|
+
type: RouteType.CRISIS_INCREASE_EXTENDED_MAX_LEVERAGE | RouteType.CRISIS_UNDO_EXTENDED_MAX_LEVERAGE;
|
|
3097
|
+
}
|
|
3098
|
+
/** Crisis: borrow beyond the normal target HF */
|
|
3099
|
+
interface CrisisBorrowRoute extends RouteBase {
|
|
3100
|
+
type: RouteType.CRISIS_BORROW_BEYOND_TARGET_HF;
|
|
3101
|
+
/** Pool to borrow from */
|
|
3102
|
+
poolId: ContractAddr;
|
|
3103
|
+
/** Token being borrowed */
|
|
3104
|
+
token: string;
|
|
3105
|
+
/** Amount to borrow */
|
|
3106
|
+
amount: Web3Number;
|
|
3107
|
+
}
|
|
3108
|
+
/** Bring liquidity from vault allocator to vault contract for user withdrawals */
|
|
3109
|
+
interface BringLiquidityRoute extends RouteBase {
|
|
3110
|
+
type: RouteType.BRING_LIQUIDITY;
|
|
3111
|
+
/** Amount to bring */
|
|
3112
|
+
amount: Web3Number;
|
|
3113
|
+
}
|
|
3114
|
+
/** Control routes: RETURN_TO_WAIT (stop execution, resume in next cycle) */
|
|
3115
|
+
interface WaitRoute extends RouteBase {
|
|
3116
|
+
type: RouteType.RETURN_TO_WAIT;
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* A single step in the execution plan produced by the solver.
|
|
3120
|
+
* Discriminated union keyed on `type` — each variant carries only
|
|
3121
|
+
* the metadata that specific route needs.
|
|
3122
|
+
*/
|
|
3123
|
+
type ExecutionRoute = TransferRoute | SwapRoute | VesuMultiplyRoute | VesuDebtRoute | RealisePnlRoute | ExtendedLeverRoute | CrisisExtendedLeverRoute | CrisisBorrowRoute | BringLiquidityRoute | WaitRoute;
|
|
3124
|
+
/**
|
|
3125
|
+
* Broad category of a detected case. Multiple categories may apply simultaneously.
|
|
3126
|
+
*/
|
|
3127
|
+
declare enum CaseCategory {
|
|
3128
|
+
LTV_REBALANCE = "LTV_REBALANCE",
|
|
3129
|
+
NEW_DEPOSITS = "NEW_DEPOSITS",
|
|
3130
|
+
WITHDRAWAL = "WITHDRAWAL",
|
|
3131
|
+
EXPOSURE_IMBALANCE = "EXPOSURE_IMBALANCE",
|
|
3132
|
+
MARGIN_CRISIS = "MARGIN_CRISIS"
|
|
3133
|
+
}
|
|
3134
|
+
/**
|
|
3135
|
+
* Specific case IDs corresponding to the situations defined in cases.json.
|
|
3136
|
+
*/
|
|
3137
|
+
declare enum CaseId {
|
|
3138
|
+
LTV_VESU_LOW_TO_EXTENDED = "LTV_VESU_LOW_TO_EXTENDED",
|
|
3139
|
+
LTV_EXTENDED_PROFITABLE_AVAILABLE = "LTV_EXTENDED_PROFITABLE_AVAILABLE",
|
|
3140
|
+
LTV_EXTENDED_PROFITABLE_REALIZE = "LTV_EXTENDED_PROFITABLE_REALIZE",
|
|
3141
|
+
LTV_VESU_HIGH_USE_VA_OR_WALLET = "LTV_VESU_HIGH_USE_VA_OR_WALLET",
|
|
3142
|
+
LTV_EXTENDED_HIGH_USE_VA_OR_WALLET = "LTV_EXTENDED_HIGH_USE_VA_OR_WALLET",
|
|
3143
|
+
DEPOSIT_FRESH_VAULT = "DEPOSIT_FRESH_VAULT",
|
|
3144
|
+
DEPOSIT_EXTENDED_AVAILABLE = "DEPOSIT_EXTENDED_AVAILABLE",
|
|
3145
|
+
DEPOSIT_VESU_BORROW_CAPACITY = "DEPOSIT_VESU_BORROW_CAPACITY",
|
|
3146
|
+
DEPOSIT_COMBINATION = "DEPOSIT_COMBINATION",
|
|
3147
|
+
WITHDRAWAL_SIMPLE = "WITHDRAWAL_SIMPLE",
|
|
3148
|
+
MARGIN_CRISIS_EXTENDED = "MARGIN_CRISIS_EXTENDED",
|
|
3149
|
+
MARGIN_CRISIS_VESU = "MARGIN_CRISIS_VESU",
|
|
3150
|
+
IMBALANCE_EXTENDED_EXCESS_SHORT_NO_FUNDS = "IMBALANCE_EXTENDED_EXCESS_SHORT_NO_FUNDS",
|
|
3151
|
+
IMBALANCE_EXTENDED_EXCESS_SHORT_HAS_FUNDS = "IMBALANCE_EXTENDED_EXCESS_SHORT_HAS_FUNDS",
|
|
3152
|
+
IMBALANCE_VESU_EXCESS_LONG_NO_FUNDS = "IMBALANCE_VESU_EXCESS_LONG_NO_FUNDS",
|
|
3153
|
+
IMBALANCE_VESU_EXCESS_LONG_HAS_FUNDS = "IMBALANCE_VESU_EXCESS_LONG_HAS_FUNDS"
|
|
3154
|
+
}
|
|
3155
|
+
/**
|
|
3156
|
+
* A detected case describing the current system state and the
|
|
3157
|
+
* high-level steps required to resolve it.
|
|
3158
|
+
*/
|
|
3159
|
+
interface SolveCase {
|
|
3160
|
+
id: CaseId;
|
|
3161
|
+
category: CaseCategory;
|
|
3162
|
+
title: string;
|
|
3163
|
+
description: string;
|
|
3164
|
+
/** High-level steps describing what needs to happen for this case */
|
|
3165
|
+
steps: string[];
|
|
3166
|
+
}
|
|
3167
|
+
/**
|
|
3168
|
+
* A single detected case with its metadata, amounts, and the execution
|
|
3169
|
+
* routes that belong to this case.
|
|
3170
|
+
*/
|
|
3171
|
+
interface SolveCaseEntry {
|
|
3172
|
+
case: SolveCase;
|
|
3173
|
+
additionalArgs: {
|
|
3174
|
+
amount?: Web3Number;
|
|
3175
|
+
};
|
|
3176
|
+
routes: ExecutionRoute[];
|
|
3177
|
+
}
|
|
3178
|
+
/**
|
|
3179
|
+
* Maps each CaseId to the RouteTypes that are relevant for resolving it.
|
|
3180
|
+
* Used to filter the global route list into per-case route subsets.
|
|
3181
|
+
*/
|
|
3182
|
+
declare const CASE_ROUTE_TYPES: Record<CaseId, RouteType[]>;
|
|
3183
|
+
/**
|
|
3184
|
+
* Complete output from the solver describing all needed state changes.
|
|
3185
|
+
*
|
|
3186
|
+
* - cases: detected cases describing the system state and needed actions.
|
|
3187
|
+
* - extendedDeposit: positive = deposit USDC into Extended, negative = withdraw.
|
|
3188
|
+
* - extendedPositionDeltas: per-instrument exposure changes (with instrument id).
|
|
3189
|
+
* - vesuDeltas: per-pool debt & collateral changes (with pool id and token pair).
|
|
3190
|
+
* - vesuAllocationUsd: USDC directed to Vesu side (negative = unwind from Vesu).
|
|
3191
|
+
* - extendedAllocationUsd: USDC directed to Extended side (negative = withdraw from Extended).
|
|
3192
|
+
* - bringLiquidityAmount: amount VA should send via bringLiquidity to the vault
|
|
3193
|
+
* (= withdrawAmount input; 0 during investment cycles).
|
|
3194
|
+
*/
|
|
3195
|
+
interface SolveResult {
|
|
3196
|
+
/** Detected cases describing the current situation, amounts, and per-case routes */
|
|
3197
|
+
cases: SolveCaseEntry[];
|
|
3198
|
+
extendedDeposit: Web3Number;
|
|
3199
|
+
extendedPositionDeltas: ExtendedPositionDelta[];
|
|
3200
|
+
vesuDepositAmount: Web3Number;
|
|
3201
|
+
vesuDeltas: VesuPoolDelta[];
|
|
3202
|
+
vesuAllocationUsd: Web3Number;
|
|
3203
|
+
extendedAllocationUsd: Web3Number;
|
|
3204
|
+
bringLiquidityAmount: Web3Number;
|
|
3205
|
+
/**
|
|
3206
|
+
* Net pending deposit for Extended.
|
|
3207
|
+
* Positive = deposit in transit (wallet → Extended), negative = withdrawal in transit.
|
|
3208
|
+
* Used by ExecutionService to avoid double-sending transfers.
|
|
3209
|
+
*/
|
|
3210
|
+
pendingDeposit: Web3Number;
|
|
3211
|
+
}
|
|
3212
|
+
interface StateManagerConfig {
|
|
3213
|
+
pricer: PricerBase;
|
|
3214
|
+
networkConfig: IConfig;
|
|
3215
|
+
vesuAdapters: VesuMultiplyAdapter[];
|
|
3216
|
+
extendedAdapter: ExtendedAdapter;
|
|
3217
|
+
vaultAllocator: ContractAddr;
|
|
3218
|
+
walletAddress: string;
|
|
3219
|
+
assetToken: TokenInfo;
|
|
3220
|
+
/** USDC.e token for wallet balance checks during route computation */
|
|
3221
|
+
usdceToken: TokenInfo;
|
|
3222
|
+
/** Collateral token (e.g. WBTC) for wallet balance checks */
|
|
3223
|
+
collateralToken: TokenInfo;
|
|
3224
|
+
limitBalanceBufferFactor: number;
|
|
3225
|
+
}
|
|
3226
|
+
/**
|
|
3227
|
+
* Returns a short human-readable summary of a route's key fields for logging.
|
|
3228
|
+
*/
|
|
3229
|
+
declare function routeSummary(r: ExecutionRoute): string;
|
|
3230
|
+
/**
|
|
3231
|
+
* Single source of truth for all mutable state during a solve() call.
|
|
3232
|
+
*
|
|
3233
|
+
* Holds both the refreshed on-chain/off-chain state snapshots AND the
|
|
3234
|
+
* budget-tracking values consumed by sub-classifiers. Spend methods
|
|
3235
|
+
* automatically keep `totalUnused` in sync. State-mutation methods
|
|
3236
|
+
* (`applyVesuDelta`, `applyExtendedExposureDelta`, `applyExtendedBalanceChange`)
|
|
3237
|
+
* update the underlying snapshots so that downstream classifiers always
|
|
3238
|
+
* see the most up-to-date picture.
|
|
3239
|
+
*/
|
|
3240
|
+
declare class SolveBudget {
|
|
3241
|
+
unusedBalance: TokenBalance[];
|
|
3242
|
+
walletBalance: TokenBalance | null;
|
|
3243
|
+
vaultBalance: TokenBalance | null;
|
|
3244
|
+
extendedPositions: ExtendedPositionState[];
|
|
3245
|
+
extendedBalance: ExtendedBalanceState | null;
|
|
3246
|
+
vesuPoolStates: VesuPoolState[];
|
|
3247
|
+
vesuPerPoolDebtDeltasToBorrow: Web3Number[];
|
|
3248
|
+
shouldVesuRebalance: boolean[];
|
|
3249
|
+
private _vaUsd;
|
|
3250
|
+
private _walletUsd;
|
|
3251
|
+
private _extAvailWithdraw;
|
|
3252
|
+
private _extAvailUpnl;
|
|
3253
|
+
private _extAvailTrade;
|
|
3254
|
+
private _extPendingDeposit;
|
|
3255
|
+
private _vesuBorrowCapacity;
|
|
3256
|
+
private _totalUnused;
|
|
3257
|
+
constructor(state: {
|
|
3258
|
+
limitBalanceBufferFactor: number;
|
|
3259
|
+
unusedBalance: TokenBalance[];
|
|
3260
|
+
walletBalance: TokenBalance | null;
|
|
3261
|
+
vaultBalance: TokenBalance | null;
|
|
3262
|
+
extendedPositions: ExtendedPositionState[];
|
|
3263
|
+
extendedBalance: ExtendedBalanceState | null;
|
|
3264
|
+
vesuPoolStates: VesuPoolState[];
|
|
3265
|
+
});
|
|
3266
|
+
/**
|
|
3267
|
+
* Initialise budget-tracking values from the current state snapshot.
|
|
3268
|
+
* Must be called after state is populated and debt deltas are computed.
|
|
3269
|
+
*
|
|
3270
|
+
* Accounts for pendingDeposit:
|
|
3271
|
+
* - pendingDeposit > 0: funds in transit TO Extended → increase effective Extended available-for-trade
|
|
3272
|
+
* - pendingDeposit < 0: funds in transit FROM Extended → increase effective wallet balance
|
|
3273
|
+
*/
|
|
3274
|
+
initBudget(): void;
|
|
3275
|
+
get vaUsd(): number;
|
|
3276
|
+
get walletUsd(): number;
|
|
3277
|
+
get vaWalletUsd(): number;
|
|
3278
|
+
get extAvailWithdraw(): number;
|
|
3279
|
+
get extAvailUpnl(): number;
|
|
3280
|
+
get extAvailTrade(): number;
|
|
3281
|
+
get vesuBorrowCapacity(): number;
|
|
3282
|
+
get totalUnused(): number;
|
|
3283
|
+
get extPendingDeposit(): number;
|
|
3284
|
+
spendVA(desired: number): number;
|
|
3285
|
+
addToVA(amount: number): void;
|
|
3286
|
+
spendWallet(desired: number): number;
|
|
3287
|
+
addToWallet(amount: number): void;
|
|
3288
|
+
spendVAWallet(desired: number): number;
|
|
3289
|
+
private _updateExtAvailWithdraw;
|
|
3290
|
+
private _updateExtAvailUpnl;
|
|
3291
|
+
spendExtAvailTrade(desired: number): number;
|
|
3292
|
+
spendExtAvailUpnl(desired: number): number;
|
|
3293
|
+
addToExtAvailTrade(amount: number): void;
|
|
3294
|
+
spendVesuBorrowCapacity(desired: number): {
|
|
3295
|
+
used: number;
|
|
3296
|
+
spendsByPool: Omit<VesuDebtRoute, 'priority' | 'type'>[];
|
|
3297
|
+
};
|
|
3298
|
+
repayVesuBorrowCapacity(desired: number): {
|
|
3299
|
+
used: number;
|
|
3300
|
+
spendsByPool: Omit<VesuDebtRoute, 'priority' | 'type'>[];
|
|
3301
|
+
};
|
|
3302
|
+
/** Update a Vesu pool's collateral and debt after a lever / borrow / repay route. */
|
|
3303
|
+
applyVesuDelta(poolId: ContractAddr, collToken: TokenInfo, debtToken: TokenInfo, collDelta: Web3Number, debtDelta: Web3Number): void;
|
|
3304
|
+
/** Update an Extended position's size after a lever route. Creates the position if new. */
|
|
3305
|
+
applyExtendedExposureDelta(instrument: string, sizeDelta: Web3Number): void;
|
|
3306
|
+
/**
|
|
3307
|
+
* For each Vesu pool, computes the debt delta needed to bring the position
|
|
3308
|
+
* back to the target health factor.
|
|
3309
|
+
*
|
|
3310
|
+
* Positive = can borrow more, negative = need to repay.
|
|
3311
|
+
*/
|
|
3312
|
+
private _computeperPoolDebtDeltasToBorrow;
|
|
3313
|
+
}
|
|
3314
|
+
/**
|
|
3315
|
+
* Reads all on-chain / off-chain state for the Extended + SVK + Vesu strategy,
|
|
3316
|
+
* then solves for the optimal rebalancing deltas.
|
|
3317
|
+
*
|
|
3318
|
+
* Usage:
|
|
3319
|
+
* const manager = new ExtendedSVKVesuStateManager(config);
|
|
3320
|
+
* const result = await manager.solve();
|
|
3321
|
+
*/
|
|
3322
|
+
declare class ExtendedSVKVesuStateManager {
|
|
3323
|
+
private readonly _config;
|
|
3324
|
+
private readonly _tag;
|
|
3325
|
+
/** Single mutable state holder — initialised by _refresh(), budget by initBudget(). */
|
|
3326
|
+
private _budget;
|
|
3327
|
+
constructor(config: StateManagerConfig);
|
|
3328
|
+
/**
|
|
3329
|
+
* Main entry point. Refreshes all state, then computes and returns
|
|
3330
|
+
* the optimal deltas for rebalancing the strategy.
|
|
3331
|
+
*
|
|
3332
|
+
* @param withdrawAmount — amount (in vault asset, e.g. USDC) the user wants
|
|
3333
|
+
* to withdraw. When > 0 the solver shrinks protocol allocations so that the
|
|
3334
|
+
* vault allocator ends up with enough balance to execute bringLiquidity.
|
|
3335
|
+
* Pass 0 (default) for normal investment / rebalancing cycles.
|
|
3336
|
+
*/
|
|
3337
|
+
solve(withdrawAmount?: Web3Number): Promise<SolveResult | null>;
|
|
3338
|
+
/**
|
|
3339
|
+
* Reads all on-chain and off-chain state in parallel and stores
|
|
3340
|
+
* results in private instance variables.
|
|
3341
|
+
*/
|
|
3342
|
+
private _refresh;
|
|
3343
|
+
/**
|
|
3344
|
+
* Reads the asset-token balance sitting idle in the vault allocator contract.
|
|
3345
|
+
*/
|
|
3346
|
+
private _fetchVaultAllocatorBalance;
|
|
3347
|
+
/**
|
|
3348
|
+
* Merges the vault-allocator balance and wallet balances into a
|
|
3349
|
+
* deduplicated array of TokenBalance entries keyed by token address.
|
|
3350
|
+
*
|
|
3351
|
+
* e.g. VA has USDC, wallet has USDC + USDC.e → returns
|
|
3352
|
+
* [{ token: USDC, amount: VA+wallet, usdValue: … },
|
|
3353
|
+
* { token: USDC.e, amount: wallet, usdValue: … }]
|
|
3354
|
+
*/
|
|
3355
|
+
private _computeUnusedBalances;
|
|
3356
|
+
/**
|
|
3357
|
+
* Reads the operator wallet's balances for the asset token (USDC.e) and
|
|
3358
|
+
* USDC.e (needed for route computation — P1 vs P2 decision for Extended deposits).
|
|
3359
|
+
*/
|
|
3360
|
+
private _fetchWalletBalances;
|
|
3361
|
+
/**
|
|
3362
|
+
* Reads the Extended exchange account-level balance (equity, available for
|
|
3363
|
+
* trade/withdrawal, etc.). Returns null if the API call fails.
|
|
3364
|
+
*/
|
|
3365
|
+
private _fetchExtendedBalance;
|
|
3366
|
+
/**
|
|
3367
|
+
* Computes the net pending deposit by subtracting pending withdrawals from
|
|
3368
|
+
* pending deposits. Uses the Extended exchange asset operations API.
|
|
3369
|
+
*
|
|
3370
|
+
* Positive = deposit in transit (wallet → Extended).
|
|
3371
|
+
* Negative = withdrawal in transit (Extended → wallet).
|
|
3372
|
+
*/
|
|
3373
|
+
private _fetchPendingDeposit;
|
|
3374
|
+
/**
|
|
3375
|
+
* Reads all open positions on the Extended exchange. Each position
|
|
3376
|
+
* includes instrument, side, size, USD value, and leverage.
|
|
3377
|
+
*/
|
|
3378
|
+
private _fetchExtendedPositions;
|
|
3379
|
+
/**
|
|
3380
|
+
* Reads a single Vesu pool's position data: collateral amount/price,
|
|
3381
|
+
* debt amount/price.
|
|
3382
|
+
*/
|
|
3383
|
+
private _fetchSingleVesuPoolState;
|
|
3384
|
+
/**
|
|
3385
|
+
* Reads all Vesu pool states in parallel (one per configured adapter).
|
|
3386
|
+
*/
|
|
3387
|
+
private _fetchAllVesuPoolStates;
|
|
3388
|
+
/**
|
|
3389
|
+
* Validates that all critical refreshed state is present and contains
|
|
3390
|
+
* finite, sensible values. Throws on invalid state.
|
|
3391
|
+
*/
|
|
3392
|
+
private _validateRefreshedState;
|
|
3393
|
+
private _validateTokenBalanceOrThrow;
|
|
3394
|
+
private _validateVesuPoolPricesOrThrow;
|
|
3395
|
+
private _validateExtendedBalanceOrThrow;
|
|
3396
|
+
private _assertPositiveFinite;
|
|
3397
|
+
/**
|
|
3398
|
+
* Computes total distributable capital by combining idle vault balance
|
|
3399
|
+
* and Extended available balance, then adjusting for aggregate debt
|
|
3400
|
+
* delta and any pending withdrawal.
|
|
3401
|
+
*
|
|
3402
|
+
* When withdrawAmount > 0 the distributable pool shrinks, forcing the
|
|
3403
|
+
* allocation split to produce smaller (or negative) allocations — which
|
|
3404
|
+
* in turn causes protocol positions to unwind and free capital for the
|
|
3405
|
+
* vault allocator to execute bringLiquidity.
|
|
3406
|
+
*/
|
|
3407
|
+
private _computeDistributableAmount;
|
|
3408
|
+
/**
|
|
3409
|
+
* Total investable = vault allocator balance + Extended available-for-trade,
|
|
3410
|
+
* both reduced by the configured buffer percentage.
|
|
3411
|
+
*/
|
|
3412
|
+
private _computeTotalInvestableAmount;
|
|
3413
|
+
private _sumDebtDeltas;
|
|
3414
|
+
/**
|
|
3415
|
+
* Splits distributable capital between Vesu and Extended using leverage
|
|
3416
|
+
* ratios and existing exposure to match delta-neutral targets.
|
|
3417
|
+
*
|
|
3418
|
+
* Formula (from existing strategy):
|
|
3419
|
+
* ExtendedAlloc = (vL * distributable + vesuExposure - extendedExposure) / (vL + eL)
|
|
3420
|
+
* VesuAlloc = distributable - ExtendedAlloc
|
|
3421
|
+
*/
|
|
3422
|
+
private _computeAllocationSplit;
|
|
3423
|
+
private _hasNoVesuAdapters;
|
|
3424
|
+
/**
|
|
3425
|
+
* Distributes the total Vesu USD allocation across pools proportionally
|
|
3426
|
+
* by existing collateral value, then converts each share to collateral
|
|
3427
|
+
* token units.
|
|
3428
|
+
*/
|
|
3429
|
+
private _computePerPoolCollateralDeltas;
|
|
3430
|
+
/**
|
|
3431
|
+
* Determines how much of the total Vesu allocation goes to a single pool.
|
|
3432
|
+
* Single-pool or zero-total cases get the entire allocation.
|
|
3433
|
+
* Multi-pool cases split proportionally by current collateral USD value.
|
|
3434
|
+
*/
|
|
3435
|
+
private _computePoolCollateralShare;
|
|
3436
|
+
/**
|
|
3437
|
+
* Computes per-position exposure deltas for delta neutrality.
|
|
3438
|
+
* Target: total Extended short exposure = total projected Vesu collateral
|
|
3439
|
+
* exposure (current + collateral deltas).
|
|
3440
|
+
*/
|
|
3441
|
+
private _computeExtendedPositionDeltas;
|
|
3442
|
+
/**
|
|
3443
|
+
* Target Extended exposure = sum of (current collateral + collateralDelta)
|
|
3444
|
+
* * price, across all Vesu pools.
|
|
3445
|
+
*/
|
|
3446
|
+
private _computeTargetExtendedExposure;
|
|
3447
|
+
private _hasNoExtendedPositions;
|
|
3448
|
+
/**
|
|
3449
|
+
* Creates a single-element delta array for the default instrument
|
|
3450
|
+
* when no Extended positions currently exist.
|
|
3451
|
+
*/
|
|
3452
|
+
private _singleInstrumentDelta;
|
|
3453
|
+
/**
|
|
3454
|
+
* Distributes a total exposure delta proportionally across existing
|
|
3455
|
+
* positions by their current USD value share.
|
|
3456
|
+
*/
|
|
3457
|
+
private _distributeExposureDeltaAcrossPositions;
|
|
3458
|
+
/**
|
|
3459
|
+
* Returns the fraction (0–1) of total Extended exposure held by
|
|
3460
|
+
* a single position. Returns 1 when there is only one position
|
|
3461
|
+
* or when total exposure is zero.
|
|
3462
|
+
*/
|
|
3463
|
+
private _positionExposureShareFraction;
|
|
3464
|
+
/**
|
|
3465
|
+
* Net deposit change = allocation target − currently available for trade.
|
|
3466
|
+
* Positive = need to deposit more, negative = can withdraw excess.
|
|
3467
|
+
*/
|
|
3468
|
+
private _computeExtendedDepositDelta;
|
|
3469
|
+
private _computeVesuDepositAmount;
|
|
3470
|
+
/**
|
|
3471
|
+
* The wallet is a pass-through for USDC flows between the vault allocator
|
|
3472
|
+
* and the Extended exchange.
|
|
3473
|
+
*
|
|
3474
|
+
* Positive = vault allocator → wallet → Extended (deposit)
|
|
3475
|
+
* Negative = Extended → wallet → vault allocator (withdrawal)
|
|
3476
|
+
*/
|
|
3477
|
+
private _deriveWalletDelta;
|
|
3478
|
+
/**
|
|
3479
|
+
* The bringLiquidity amount is the USDC that the vault allocator must
|
|
3480
|
+
* transfer back to the vault contract for the user's withdrawal.
|
|
3481
|
+
* Equals the withdrawAmount passed into solve(); 0 during investment cycles.
|
|
3482
|
+
*/
|
|
3483
|
+
private _computeBringLiquidityAmount;
|
|
3484
|
+
private _buildVesuRepayRoutes;
|
|
3485
|
+
private _buildVesuBorrowRoutes;
|
|
3486
|
+
private _getWalletToVARoute;
|
|
3487
|
+
private _getWalletToEXTENDEDRoute;
|
|
3488
|
+
private _getVAToEXTENDEDRoute;
|
|
3489
|
+
private _getExtendedToWalletRoute;
|
|
3490
|
+
private _getWALLETToVARoute;
|
|
3491
|
+
private _getUpnlRoute;
|
|
3492
|
+
/**
|
|
3493
|
+
* 1. Withdrawal — source funds in priority order:
|
|
3494
|
+
* 1) VA balance 2) Wallet 3) Vesu borrow capacity
|
|
3495
|
+
* 4) Extended available-for-withdrawal + unrealised PnL
|
|
3496
|
+
* 5) Unwind positions on both sides (freed funds handled next cycle)
|
|
3497
|
+
*/
|
|
3498
|
+
private _classifyWithdrawal;
|
|
3499
|
+
/**
|
|
3500
|
+
* 2a. LTV Rebalance — Vesu side
|
|
3501
|
+
*
|
|
3502
|
+
* Triggered when vesuPerPoolDebtDeltasToBorrow sum is negative (high LTV, needs repayment).
|
|
3503
|
+
* Sources funds to VA so the subsequent deposit classifier can build the correct lever routes.
|
|
3504
|
+
*
|
|
3505
|
+
* Priority: 1) VA + Wallet (no routes) 2) Extended available-for-withdrawal
|
|
3506
|
+
* 3) Extended uPnL 4) Margin crisis (future)
|
|
3507
|
+
*
|
|
3508
|
+
* Design: accumulate all ext-to-wallet moves, add transfer routes at the end (principle #3).
|
|
3509
|
+
*/
|
|
3510
|
+
private _classifyLtvVesu;
|
|
3511
|
+
/**
|
|
3512
|
+
* LTV_EXTENDED_PROFITABLE_AVAILABLE:
|
|
3513
|
+
* Extended has enough available-to-withdraw → withdraw, move to VA, repay Vesu.
|
|
3514
|
+
* Routes: [EXTENDED_TO_WALLET, WALLET_TO_VA, VESU_REPAY]
|
|
3515
|
+
*/
|
|
3516
|
+
/**
|
|
3517
|
+
* LTV_EXTENDED_PROFITABLE_REALIZE:
|
|
3518
|
+
* Extended has unrealised PnL → realise it first, then withdraw + repay.
|
|
3519
|
+
* Routes: [REALISE_PNL, EXTENDED_TO_WALLET, WALLET_TO_VA, VESU_REPAY]
|
|
3520
|
+
*/
|
|
3521
|
+
/**
|
|
3522
|
+
* MARGIN_CRISIS_VESU:
|
|
3523
|
+
* Neither VA/Wallet nor Extended withdrawal covers the shortfall.
|
|
3524
|
+
* Temporarily increase Extended leverage to free margin, withdraw to VA, then
|
|
3525
|
+
* decrease Vesu lever to bring LTV back in range.
|
|
3526
|
+
* Routes: [CRISIS_INCREASE_EXTENDED_MAX_LEVERAGE, EXTENDED_TO_WALLET, WALLET_TO_VA,
|
|
3527
|
+
* VESU_MULTIPLY_DECREASE_LEVER, EXTENDED_DECREASE_LEVER, CRISIS_UNDO_EXTENDED_MAX_LEVERAGE]
|
|
3528
|
+
*/
|
|
3529
|
+
/** 2b. LTV Rebalance — Extended side */
|
|
3530
|
+
/**
|
|
3531
|
+
* 2b. LTV Rebalance — Extended side
|
|
3532
|
+
*
|
|
3533
|
+
* Triggered when Extended equity is below the required margin for current positions.
|
|
3534
|
+
* Sources funds to Extended via VA/Wallet or Vesu borrow.
|
|
3535
|
+
*
|
|
3536
|
+
* Priority: 1) VA/Wallet → Extended 2) Vesu borrow → VA → Extended
|
|
3537
|
+
*/
|
|
3538
|
+
private _classifyLtvExtended;
|
|
3539
|
+
/**
|
|
3540
|
+
* LTV_EXTENDED_HIGH_USE_VA_OR_WALLET:
|
|
3541
|
+
* VA/Wallet has funds → route them to Extended.
|
|
3542
|
+
* Routes: [VA_TO_EXTENDED, WALLET_TO_EXTENDED] (wallet-first, then VA for remainder)
|
|
3543
|
+
*/
|
|
3544
|
+
/**
|
|
3545
|
+
* LTV_VESU_LOW_TO_EXTENDED:
|
|
3546
|
+
* Borrow USDC from Vesu, route through VA to Extended.
|
|
3547
|
+
* Routes: [VESU_BORROW, VA_TO_EXTENDED]
|
|
3548
|
+
*/
|
|
3549
|
+
/**
|
|
3550
|
+
* MARGIN_CRISIS_EXTENDED:
|
|
3551
|
+
* Borrow beyond target HF on Vesu to free USDC, deposit to Extended,
|
|
3552
|
+
* then decrease Vesu/Extended lever, undo crisis leverage.
|
|
3553
|
+
* Routes: [CRISIS_BORROW_BEYOND_TARGET_HF, VA_TO_EXTENDED,
|
|
3554
|
+
* VESU_MULTIPLY_DECREASE_LEVER, EXTENDED_DECREASE_LEVER,
|
|
3555
|
+
* CRISIS_UNDO_EXTENDED_MAX_LEVERAGE]
|
|
3556
|
+
*/
|
|
3557
|
+
/**
|
|
3558
|
+
* 3. New Deposits / Excess Funds
|
|
3559
|
+
*
|
|
3560
|
+
* Computes how much exposure to create on Vesu and Extended, then
|
|
3561
|
+
* distributes available funds using shortest-path priority chains:
|
|
3562
|
+
* Extended margin: Wallet → VA → Vesu borrow
|
|
3563
|
+
* Vesu margin: VA → Wallet → Extended
|
|
3564
|
+
*/
|
|
2166
3565
|
/**
|
|
2167
|
-
*
|
|
2168
|
-
*
|
|
2169
|
-
*
|
|
3566
|
+
* 3. New Deposits / Excess Funds
|
|
3567
|
+
*
|
|
3568
|
+
* Computes allocation split between Vesu and Extended, then sources
|
|
3569
|
+
* funds and creates lever-increase routes.
|
|
3570
|
+
*
|
|
3571
|
+
* Fund flow (principle #3 — accumulate transfers, defer wait):
|
|
3572
|
+
* Phase A: fund Extended (wallet→ext, VA→ext, vesu-borrow→VA→ext)
|
|
3573
|
+
* Phase B: fund Vesu VA shortfall (wallet→VA, ext→wallet + wallet→VA)
|
|
3574
|
+
* Phase C: RETURN_TO_WAIT (if any transfer to Extended occurred)
|
|
3575
|
+
* Phase D: lever routes (VESU_MULTIPLY, EXTENDED_INCREASE) near each other (#4)
|
|
2170
3576
|
*/
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
3577
|
+
private _classifyDeposits;
|
|
3578
|
+
/** 4. Exposure Imbalance */
|
|
3579
|
+
/**
|
|
3580
|
+
* IMBALANCE_EXTENDED_EXCESS_SHORT_HAS_FUNDS:
|
|
3581
|
+
* Extended has too much short exposure vs Vesu. Use VA/Wallet funds to
|
|
3582
|
+
* add Vesu collateral and reduce Extended exposure.
|
|
3583
|
+
*
|
|
3584
|
+
* The new Vesu collateral covers part of the imbalance; the remaining
|
|
3585
|
+
* gap is closed by reducing Extended short exposure.
|
|
3586
|
+
*
|
|
3587
|
+
* Routes: [AVNU_DEPOSIT_SWAP, VESU_MULTIPLY_INCREASE_LEVER, EXTENDED_DECREASE_LEVER]
|
|
3588
|
+
*/
|
|
3589
|
+
/**
|
|
3590
|
+
* IMBALANCE_EXTENDED_EXCESS_SHORT_NO_FUNDS:
|
|
3591
|
+
* No available funds to add Vesu collateral → reduce Extended exposure
|
|
3592
|
+
* by the full imbalance amount.
|
|
3593
|
+
* Routes: [EXTENDED_DECREASE_LEVER]
|
|
3594
|
+
*/
|
|
3595
|
+
private _buildImbalanceExtExcessShortNoFundsRoutes;
|
|
3596
|
+
/**
|
|
3597
|
+
* IMBALANCE_VESU_EXCESS_LONG_HAS_FUNDS:
|
|
3598
|
+
* Vesu has too much long exposure vs Extended. Deposit funds on Extended
|
|
3599
|
+
* to increase short exposure, and decrease Vesu lever for the remainder.
|
|
3600
|
+
*
|
|
3601
|
+
* Routes: [WALLET_TO_EXTENDED / VA_TO_EXTENDED, EXTENDED_INCREASE_LEVER,
|
|
3602
|
+
* VESU_MULTIPLY_DECREASE_LEVER]
|
|
3603
|
+
*/
|
|
3604
|
+
/**
|
|
3605
|
+
* IMBALANCE_VESU_EXCESS_LONG_NO_FUNDS:
|
|
3606
|
+
* No funds to increase Extended → decrease Vesu lever by the full imbalance.
|
|
3607
|
+
* Routes: [VESU_MULTIPLY_DECREASE_LEVER]
|
|
3608
|
+
*/
|
|
3609
|
+
/**
|
|
3610
|
+
* Classifies the current state into actionable cases. Each case carries
|
|
3611
|
+
* its own execution routes with amounts and state info.
|
|
3612
|
+
*/
|
|
3613
|
+
private _classifyCases;
|
|
3614
|
+
private _totalVesuCollateral;
|
|
3615
|
+
private _totalVesuCollateralUsd;
|
|
3616
|
+
private _totalExtendedExposure;
|
|
3617
|
+
private _totalExtendedExposureUsd;
|
|
3618
|
+
private _logSolveResult;
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3621
|
+
declare class UsdcToUsdceAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
3622
|
+
readonly config: BaseAdapterConfig;
|
|
3623
|
+
private _approveProofReadableId;
|
|
3624
|
+
private _swapProofReadableId;
|
|
3625
|
+
private buildSwapLeafConfigs;
|
|
3626
|
+
private buildSwapCalls;
|
|
3627
|
+
constructor(config: BaseAdapterConfig);
|
|
3628
|
+
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
3629
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount | null>;
|
|
3630
|
+
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
3631
|
+
maxWithdraw(): Promise<PositionInfo>;
|
|
3632
|
+
protected _getDepositLeaf(): {
|
|
3633
|
+
target: ContractAddr;
|
|
3634
|
+
method: string;
|
|
3635
|
+
packedArguments: bigint[];
|
|
3636
|
+
sanitizer: ContractAddr;
|
|
3637
|
+
id: string;
|
|
3638
|
+
}[];
|
|
3639
|
+
protected _getWithdrawLeaf(): {
|
|
3640
|
+
target: ContractAddr;
|
|
3641
|
+
method: string;
|
|
3642
|
+
packedArguments: bigint[];
|
|
3643
|
+
sanitizer: ContractAddr;
|
|
3644
|
+
id: string;
|
|
3645
|
+
}[];
|
|
3646
|
+
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
3647
|
+
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
3648
|
+
getHealthFactor(): Promise<number>;
|
|
2181
3649
|
}
|
|
2182
|
-
declare const AUDIT_URL = "https://docs.troves.fi/p/security#starknet-vault-kit";
|
|
2183
|
-
declare function getFAQs(lstSymbol: string, underlyingSymbol: string, isLST: boolean): FAQ[];
|
|
2184
|
-
declare const _riskFactor: RiskFactor[];
|
|
2185
|
-
declare function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string): string[];
|
|
2186
|
-
declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
|
|
2187
3650
|
|
|
2188
3651
|
/**
|
|
2189
3652
|
* Transaction metadata that SDK generates and risk engine stores in DB.
|
|
@@ -2213,39 +3676,438 @@ interface TransactionResult<T = any> {
|
|
|
2213
3676
|
status: boolean;
|
|
2214
3677
|
transactionMetadata: TransactionMetadata;
|
|
2215
3678
|
}
|
|
3679
|
+
/**
|
|
3680
|
+
* Key lifecycle event types emitted during execution.
|
|
3681
|
+
* Used by callers (e.g. risk engine) to hook into the execution pipeline
|
|
3682
|
+
* and persist state to DB, send alerts, etc.
|
|
3683
|
+
*/
|
|
3684
|
+
declare enum ExecutionEventType {
|
|
3685
|
+
/** Execution started — tx sent on-chain or order placed on exchange */
|
|
3686
|
+
INITIATED = "INITIATED",
|
|
3687
|
+
/** Execution completed successfully — tx confirmed / order filled */
|
|
3688
|
+
SUCCESS = "SUCCESS",
|
|
3689
|
+
/** Execution failed — tx reverted / order rejected / timeout */
|
|
3690
|
+
FAILURE = "FAILURE"
|
|
3691
|
+
}
|
|
3692
|
+
/**
|
|
3693
|
+
* Metadata payload accompanying each execution lifecycle event.
|
|
3694
|
+
* Contains relevant identifiers, prices, and contextual information.
|
|
3695
|
+
*/
|
|
3696
|
+
interface ExecutionEventMetadata {
|
|
3697
|
+
/** Route type string (e.g. RouteType value) */
|
|
3698
|
+
routeType?: string;
|
|
3699
|
+
/** Human-readable route summary */
|
|
3700
|
+
routeSummary?: string;
|
|
3701
|
+
/** On-chain transaction hash (when available) */
|
|
3702
|
+
txHash?: string;
|
|
3703
|
+
/** Exchange order ID (for off-chain orders) */
|
|
3704
|
+
orderId?: string;
|
|
3705
|
+
/** Amount involved in the operation */
|
|
3706
|
+
amount?: string;
|
|
3707
|
+
/** Protocol name */
|
|
3708
|
+
protocol?: string;
|
|
3709
|
+
/** Actual execution price (for exchange orders) */
|
|
3710
|
+
executionPrice?: number;
|
|
3711
|
+
/** Limit price that was set */
|
|
3712
|
+
limitPrice?: number;
|
|
3713
|
+
/** Error message on failure */
|
|
3714
|
+
error?: string;
|
|
3715
|
+
/** On-chain calls that were built */
|
|
3716
|
+
calls?: Call[];
|
|
3717
|
+
/** Extensible: any extra metadata */
|
|
3718
|
+
[key: string]: any;
|
|
3719
|
+
}
|
|
3720
|
+
/**
|
|
3721
|
+
* Callback invoked on key execution lifecycle events.
|
|
3722
|
+
* Callers can use this to save to DB, send notifications, log, etc.
|
|
3723
|
+
*/
|
|
3724
|
+
type ExecutionCallback = (eventType: ExecutionEventType, metadata: ExecutionEventMetadata) => void | Promise<void>;
|
|
2216
3725
|
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
3726
|
+
interface ExecutionConfig {
|
|
3727
|
+
networkConfig: IConfig;
|
|
3728
|
+
pricer: PricerBase;
|
|
3729
|
+
vesuAdapter: VesuMultiplyAdapter;
|
|
3730
|
+
vesuModifyPositionAdapter: VesuModifyPositionAdapter;
|
|
3731
|
+
extendedAdapter: ExtendedAdapter;
|
|
3732
|
+
avnuAdapter: AvnuAdapter;
|
|
3733
|
+
usdcToUsdceAdapter: UsdcToUsdceAdapter;
|
|
3734
|
+
usdceTransferAdapter: TokenTransferAdapter;
|
|
3735
|
+
vaultAllocator: ContractAddr;
|
|
3736
|
+
walletAddress: string;
|
|
3737
|
+
wbtcToken: TokenInfo;
|
|
3738
|
+
usdcToken: TokenInfo;
|
|
3739
|
+
usdceToken: TokenInfo;
|
|
2227
3740
|
/**
|
|
2228
|
-
*
|
|
2229
|
-
*
|
|
3741
|
+
* Returns the strategy's merkle tree (built from all leaf adapters).
|
|
3742
|
+
* Used to generate proofs for adapter manage calls.
|
|
2230
3743
|
*/
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
3744
|
+
getMerkleTree: () => StandardMerkleTree;
|
|
3745
|
+
/**
|
|
3746
|
+
* Combines merkle proofs and ManageCall[] into a single on-chain Call
|
|
3747
|
+
* that invokes `manage_vault_with_merkle_verification` on the manager contract.
|
|
3748
|
+
*/
|
|
3749
|
+
getManageCall: (proofs: string[][], manageCalls: ManageCall[]) => Call;
|
|
3750
|
+
/**
|
|
3751
|
+
* Callback to get the bring-liquidity call from the strategy.
|
|
3752
|
+
*/
|
|
3753
|
+
getBringLiquidityCall: (params: {
|
|
2234
3754
|
amount: Web3Number;
|
|
2235
|
-
|
|
2236
|
-
}, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<TransactionResult>;
|
|
3755
|
+
}) => Promise<Call>;
|
|
2237
3756
|
/**
|
|
2238
|
-
*
|
|
2239
|
-
*
|
|
3757
|
+
* Optional callback invoked on key execution lifecycle events.
|
|
3758
|
+
* Use to persist state to DB, send alerts, etc.
|
|
2240
3759
|
*/
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
3760
|
+
onExecutionEvent?: ExecutionCallback;
|
|
3761
|
+
/**
|
|
3762
|
+
* Acceptable slippage for Extended limit orders in basis points.
|
|
3763
|
+
* E.g. 10 = 0.1%. Default: 10 (0.1%).
|
|
3764
|
+
* For BUY orders: limitPrice = midPrice * (1 + slippage)
|
|
3765
|
+
* For SELL orders: limitPrice = midPrice * (1 - slippage)
|
|
3766
|
+
*/
|
|
3767
|
+
extendedAcceptableSlippageBps?: number;
|
|
3768
|
+
/**
|
|
3769
|
+
* Maximum acceptable price divergence between Extended and Vesu
|
|
3770
|
+
* execution prices in basis points. Default: 50 (0.5%).
|
|
3771
|
+
*
|
|
3772
|
+
* During increase exposure (extended SHORT + vesu LONG):
|
|
3773
|
+
* (extendedPrice - vesuPrice) / vesuPrice must be > -maxDivergence
|
|
3774
|
+
* During decrease exposure (extended BUY + vesu decrease):
|
|
3775
|
+
* (extendedPrice - vesuPrice) / vesuPrice must be < +maxDivergence
|
|
3776
|
+
*/
|
|
3777
|
+
maxPriceDivergenceBps?: number;
|
|
3778
|
+
/**
|
|
3779
|
+
* Max time (ms) to wait for Extended limit order fill in coordinated
|
|
3780
|
+
* dual-exchange mode. Default: 3000 (3 seconds).
|
|
3781
|
+
*/
|
|
3782
|
+
extendedFillTimeoutMs?: number;
|
|
3783
|
+
}
|
|
3784
|
+
/**
|
|
3785
|
+
* Processes a {@link SolveResult} and translates each case's {@link ExecutionRoute}s into
|
|
3786
|
+
* concrete on-chain transaction calls (batched) or off-chain API operations.
|
|
3787
|
+
*
|
|
3788
|
+
* Key design principles:
|
|
3789
|
+
*
|
|
3790
|
+
* 1. **Case-based execution**: Cases are processed sequentially. Within each
|
|
3791
|
+
* case, routes execute in priority order.
|
|
3792
|
+
*
|
|
3793
|
+
* 2. **RETURN_TO_WAIT**: When encountered, all pending on-chain calls are
|
|
3794
|
+
* flushed and execution halts. The remaining routes will be re-computed
|
|
3795
|
+
* in the next solve cycle once async operations (bridge, deposit credit) settle.
|
|
3796
|
+
*
|
|
3797
|
+
* 3. **On-chain batching**: Consecutive on-chain routes (Starknet calls) are
|
|
3798
|
+
* accumulated into a single multicall batch. Off-chain routes (Extended API)
|
|
3799
|
+
* flush the batch, execute independently, then resume accumulation.
|
|
3800
|
+
*
|
|
3801
|
+
* 4. **pendingDeposit awareness**: Transfers to Extended are reduced by any
|
|
3802
|
+
* amount already in transit, avoiding double-sends.
|
|
3803
|
+
*
|
|
3804
|
+
* 5. **AVNU buffer**: Swap amounts use a 0.1% buffer to account for slippage.
|
|
3805
|
+
*
|
|
3806
|
+
* Usage:
|
|
3807
|
+
* const executor = new ExecutionService(config);
|
|
3808
|
+
* const results = await executor.execute(solveResult);
|
|
3809
|
+
*/
|
|
3810
|
+
declare class ExecutionService {
|
|
3811
|
+
private readonly _config;
|
|
3812
|
+
private readonly _tag;
|
|
3813
|
+
private readonly _tokenSymbols;
|
|
3814
|
+
private readonly _tokenDecimals;
|
|
3815
|
+
private readonly _poolNames;
|
|
3816
|
+
/**
|
|
3817
|
+
* Remaining pending deposit budget (consumed during execution to avoid double-sends).
|
|
3818
|
+
* Initialised from SolveResult.pendingDeposit at the start of execute().
|
|
3819
|
+
*/
|
|
3820
|
+
private _pendingDepositRemaining;
|
|
3821
|
+
/**
|
|
3822
|
+
* Starknet account used for on-chain estimation in coordinated mode.
|
|
3823
|
+
* Set at the start of execute() and valid for the duration of the call.
|
|
3824
|
+
*/
|
|
3825
|
+
private _account;
|
|
3826
|
+
constructor(config: ExecutionConfig);
|
|
3827
|
+
/**
|
|
3828
|
+
* Emits a lifecycle event via the configured callback (if present).
|
|
3829
|
+
* Safe to call even when no callback is configured.
|
|
3830
|
+
*/
|
|
3831
|
+
private _emitEvent;
|
|
3832
|
+
private _getProofGroupsForManageCalls;
|
|
3833
|
+
/**
|
|
3834
|
+
* Builds a single manage call (manage_vault_with_merkle_verification) for an adapter.
|
|
3835
|
+
*
|
|
3836
|
+
* Pattern:
|
|
3837
|
+
* 1. Calls adapter.getDepositCall / getWithdrawCall to get ManageCall[]
|
|
3838
|
+
* 2. Gets merkle proofs for the adapter's leaves
|
|
3839
|
+
* 3. Combines via getManageCall into a single on-chain Call
|
|
3840
|
+
*
|
|
3841
|
+
* Use this for any VA-routed operation that needs merkle proof verification.
|
|
3842
|
+
*/
|
|
3843
|
+
private _buildAdapterManageCall;
|
|
3844
|
+
private _getExtendedMidPrice;
|
|
3845
|
+
/**
|
|
3846
|
+
* Executes a limit order on Extended with acceptable slippage from mid spot price.
|
|
3847
|
+
*
|
|
3848
|
+
* Flow:
|
|
3849
|
+
* 1. Set leverage on the market
|
|
3850
|
+
* 2. Fetch orderbook → compute mid price
|
|
3851
|
+
* 3. Apply configured slippage to derive limit price
|
|
3852
|
+
* 4. Place IOC limit order at that price
|
|
3853
|
+
* 5. Poll for fill status with retries
|
|
3854
|
+
*
|
|
3855
|
+
* Returns execution details including the fill price, or null on failure.
|
|
3856
|
+
*/
|
|
3857
|
+
private _executeExtendedLimitOrder;
|
|
3858
|
+
private _fetchExtendedOrderStatusWithRetries;
|
|
3859
|
+
private _cancelExtendedOrderIfOpen;
|
|
3860
|
+
private _executeExtendedLimitOrderWithRecovery;
|
|
3861
|
+
/** ExecutionRoute types that change BTC exposure (on-chain or off-chain). */
|
|
3862
|
+
private static readonly EXPOSURE_CHANGING_ROUTES;
|
|
3863
|
+
/** ExecutionRoute types that correspond to increasing delta-neutral exposure. */
|
|
3864
|
+
private static readonly INCREASE_EXPOSURE_ROUTES;
|
|
3865
|
+
/** On-chain route types that change BTC exposure (Vesu side). */
|
|
3866
|
+
private static readonly ON_CHAIN_EXPOSURE_ROUTES;
|
|
3867
|
+
/** Off-chain Extended route types that change BTC exposure. */
|
|
3868
|
+
private static readonly EXTENDED_EXPOSURE_ROUTES;
|
|
3869
|
+
/**
|
|
3870
|
+
* Validates that the price divergence between Extended (orderbook mid) and
|
|
3871
|
+
* AVNU (actual on-chain swap price) is within acceptable limits.
|
|
3872
|
+
*
|
|
3873
|
+
* Mirrors the check from `checkPriceDifferenceBetweenAvnuAndExtended` in the
|
|
3874
|
+
* strategy — see investmentOrchestrator.ts for the call-site pattern.
|
|
3875
|
+
*
|
|
3876
|
+
* For OPEN (increasing exposure): we SELL on Extended (short) and BUY on AVNU (long).
|
|
3877
|
+
* → Extended price should not be too far below AVNU price.
|
|
3878
|
+
* → (extendedMid − avnuPrice) / avnuPrice must be > −maxDivergence
|
|
3879
|
+
*
|
|
3880
|
+
* For CLOSE (decreasing exposure): we BUY on Extended (close short) and SELL on AVNU.
|
|
3881
|
+
* → Extended price should not be too far above AVNU price.
|
|
3882
|
+
* → (extendedMid − avnuPrice) / avnuPrice must be < +maxDivergence
|
|
3883
|
+
*
|
|
3884
|
+
* @param isIncreasingExposure true when opening/increasing delta-neutral position
|
|
3885
|
+
* @throws if divergence exceeds configured maxPriceDivergenceBps
|
|
3886
|
+
*/
|
|
3887
|
+
private _validatePriceDivergence;
|
|
3888
|
+
/**
|
|
3889
|
+
* Computes the net weighted execution price (USDC per BTC) across all adapters
|
|
3890
|
+
* that have a stored SwapPriceInfo from the most recent call build.
|
|
3891
|
+
*
|
|
3892
|
+
* For deposit (USDC→BTC): price = sum(USDC sold) / sum(BTC bought)
|
|
3893
|
+
* For withdraw (BTC→USDC): price = sum(USDC bought) / sum(BTC sold)
|
|
3894
|
+
*/
|
|
3895
|
+
private _getNetExecutionPrice;
|
|
3896
|
+
/** Clears cached swap price info on all adapters to prevent stale data across cycles. */
|
|
3897
|
+
private _clearAdapterPriceInfo;
|
|
3898
|
+
/**
|
|
3899
|
+
* Main entry point: takes a SolveResult and executes all cases in order,
|
|
3900
|
+
* building the necessary transaction calls.
|
|
3901
|
+
*
|
|
3902
|
+
* - Cases are processed sequentially.
|
|
3903
|
+
* - Within a case, on-chain calls are batched; off-chain calls flush the batch.
|
|
3904
|
+
* - Dual-exchange exposure cases use the coordinated path (construct → estimate → fill Extended → send on-chain).
|
|
3905
|
+
* - RETURN_TO_WAIT halts execution for the current case and all subsequent cases.
|
|
3906
|
+
* - Execution stops on the first route failure.
|
|
3907
|
+
*
|
|
3908
|
+
* @param account Starknet account used for on-chain fee estimation in coordinated mode.
|
|
3909
|
+
* @returns Ordered list of TransactionResults (one per batch/off-chain op).
|
|
3910
|
+
*/
|
|
3911
|
+
execute(solveResult: SolveResult, account: Account): Promise<TransactionResult[]>;
|
|
3912
|
+
/**
|
|
3913
|
+
* Executes a single case's routes.
|
|
3914
|
+
*
|
|
3915
|
+
* First splits routes at the first RETURN_TO_WAIT into an "active window"
|
|
3916
|
+
* (routes that will execute this cycle). If the active window contains both
|
|
3917
|
+
* on-chain and off-chain exposure routes, delegates to the coordinated
|
|
3918
|
+
* dual-exchange path. Otherwise, uses the standard route-by-route flow.
|
|
3919
|
+
*/
|
|
3920
|
+
private _executeCase;
|
|
3921
|
+
/**
|
|
3922
|
+
* Standard route-by-route execution for non-coordinated cases.
|
|
3923
|
+
*
|
|
3924
|
+
* On-chain routes are accumulated into a Call[] batch. When an off-chain
|
|
3925
|
+
* route or RETURN_TO_WAIT is encountered, the batch is flushed first.
|
|
3926
|
+
*/
|
|
3927
|
+
private _executeStandardCase;
|
|
3928
|
+
/**
|
|
3929
|
+
* Coordinated execution for cases that touch both Vesu (on-chain) and
|
|
3930
|
+
* Extended (off-chain) exposure in the same case.
|
|
3931
|
+
*
|
|
3932
|
+
* Flow:
|
|
3933
|
+
* 1. Partition active routes into on-chain vs Extended
|
|
3934
|
+
* 2. Construct all on-chain calls in parallel
|
|
3935
|
+
* 3. Estimate on-chain batch (dry-run via account.estimateInvokeFee)
|
|
3936
|
+
* 4. Validate price divergence between Extended and AVNU
|
|
3937
|
+
* 5. Race Extended limit order fill against timeout
|
|
3938
|
+
* 6. If filled → return Extended result + on-chain batch
|
|
3939
|
+
* If timeout/failure → drop everything
|
|
3940
|
+
*
|
|
3941
|
+
* // TODO: If Extended fills but the orchestrator's on-chain multicall later
|
|
3942
|
+
* // reverts, we have an unhedged Extended position. The orchestrator should
|
|
3943
|
+
* // catch the on-chain failure, re-solve with updated state to recompute
|
|
3944
|
+
* // necessary on-chain calls, and retry. This recovery is non-trivial and
|
|
3945
|
+
* // should be implemented as a follow-up.
|
|
3946
|
+
*/
|
|
3947
|
+
private _executeCoordinatedCase;
|
|
3948
|
+
/** Returns true if the route produces Starknet Call objects (on-chain tx). */
|
|
3949
|
+
private _isOnChainRoute;
|
|
3950
|
+
/** Checks whether any route in the list is a RETURN_TO_WAIT sentinel. */
|
|
3951
|
+
private _caseHitReturnToWait;
|
|
3952
|
+
/**
|
|
3953
|
+
* Returns true when the active window contains both on-chain exposure
|
|
3954
|
+
* routes (Vesu/AVNU) and off-chain Extended exposure routes — meaning
|
|
3955
|
+
* both exchanges participate in the same exposure change and should be
|
|
3956
|
+
* executed via the coordinated (fill-or-abort) path.
|
|
3957
|
+
*/
|
|
3958
|
+
private _isDualExchangeCase;
|
|
3959
|
+
/** Dispatches an on-chain route to the appropriate call builder. */
|
|
3960
|
+
private _buildOnChainCalls;
|
|
3961
|
+
/**
|
|
3962
|
+
* WALLET_TO_EXTENDED: Deposit USDC.e from operator wallet directly to Extended.
|
|
3963
|
+
*
|
|
3964
|
+
* Builds raw approve + deposit calls (NOT through the manager/merkle system)
|
|
3965
|
+
* because the wallet interacts with Extended directly, not via vault allocator.
|
|
3966
|
+
*
|
|
3967
|
+
* Adjusts amount by pending deposit to avoid double-sending.
|
|
3968
|
+
*/
|
|
3969
|
+
private _buildWalletToExtendedCalls;
|
|
3970
|
+
/**
|
|
3971
|
+
* VA_TO_EXTENDED: Deposit USDC.e from vault allocator to Extended.
|
|
3972
|
+
*
|
|
3973
|
+
* Uses the extended adapter's getDepositCall to build ManageCalls,
|
|
3974
|
+
* then wraps them in a merkle-verified manage call through the manager contract.
|
|
3975
|
+
*
|
|
3976
|
+
* Adjusts amount by pending deposit to avoid double-sending.
|
|
3977
|
+
*/
|
|
3978
|
+
private _buildVAToExtendedCalls;
|
|
3979
|
+
/**
|
|
3980
|
+
* WALLET_TO_VA: Transfer USDC.e from operator wallet to vault allocator.
|
|
3981
|
+
* Caps amount by actual wallet balance.
|
|
3982
|
+
*/
|
|
3983
|
+
private _buildWalletToVACalls;
|
|
3984
|
+
/**
|
|
3985
|
+
* AVNU_DEPOSIT_SWAP: Standalone USDC → BTC swap via AVNU.
|
|
3986
|
+
*
|
|
3987
|
+
* Uses avnu adapter's getDepositCall to build swap ManageCalls,
|
|
3988
|
+
* then wraps in a merkle-verified manage call.
|
|
3989
|
+
* Applies 0.1% buffer so downstream Vesu deposit has sufficient BTC.
|
|
3990
|
+
*/
|
|
3991
|
+
private _buildAvnuDepositSwapCalls;
|
|
3992
|
+
/**
|
|
3993
|
+
* AVNU_WITHDRAW_SWAP: Standalone BTC → USDC swap via AVNU.
|
|
3994
|
+
*
|
|
3995
|
+
* Uses avnu adapter's getWithdrawCall to build swap ManageCalls,
|
|
3996
|
+
* then wraps in a merkle-verified manage call.
|
|
3997
|
+
* Applies 0.1% buffer so Vesu-returned BTC is sufficient for the swap.
|
|
3998
|
+
*/
|
|
3999
|
+
private _buildAvnuWithdrawSwapCalls;
|
|
4000
|
+
/**
|
|
4001
|
+
* VESU_MULTIPLY_INCREASE_LEVER: Compound operation.
|
|
4002
|
+
* 1. AVNU swap USDC → BTC (with 0.1% buffer on collateral amount)
|
|
4003
|
+
* 2. Vesu multiply deposit — add BTC as collateral (triggers flash-loan leverage)
|
|
4004
|
+
*
|
|
4005
|
+
* Both steps go through the merkle-verified manager contract via their respective adapters.
|
|
4006
|
+
*/
|
|
4007
|
+
private _buildVesuIncreaseLeverCalls;
|
|
4008
|
+
/**
|
|
4009
|
+
* VESU_MULTIPLY_DECREASE_LEVER: Compound operation.
|
|
4010
|
+
* 1. Vesu multiply withdraw — reduce BTC collateral (repays proportional debt via flash-loan)
|
|
4011
|
+
* 2. AVNU swap BTC → USDC (with 0.1% buffer to account for slippage)
|
|
4012
|
+
*
|
|
4013
|
+
* Both steps go through the merkle-verified manager contract via their respective adapters.
|
|
4014
|
+
*/
|
|
4015
|
+
private _buildVesuDecreaseLeverCalls;
|
|
4016
|
+
private _validateVesuDebtRoute;
|
|
4017
|
+
/**
|
|
4018
|
+
* VESU_BORROW: Borrow additional USDC from Vesu.
|
|
4019
|
+
*/
|
|
4020
|
+
private _buildVesuBorrowCalls;
|
|
4021
|
+
/**
|
|
4022
|
+
* VESU_REPAY: Repay USDC debt to Vesu.
|
|
4023
|
+
*/
|
|
4024
|
+
private _buildVesuRepayCalls;
|
|
4025
|
+
/** BRING_LIQUIDITY: Transfer from VA to vault contract for user withdrawals. */
|
|
4026
|
+
private _buildBringLiquidityCalls;
|
|
4027
|
+
/**
|
|
4028
|
+
* CRISIS_BORROW_BEYOND_TARGET_HF: Borrow beyond normal target HF.
|
|
4029
|
+
* TODO: Implement crisis borrow flow when needed.
|
|
4030
|
+
*/
|
|
4031
|
+
private _buildCrisisBorrowCalls;
|
|
4032
|
+
/** Dispatches an off-chain route to the appropriate executor. */
|
|
4033
|
+
private _executeOffChainRoute;
|
|
4034
|
+
/**
|
|
4035
|
+
* EXTENDED_TO_WALLET: Withdraw from Extended exchange to operator wallet.
|
|
4036
|
+
*
|
|
4037
|
+
* This initiates the off-chain withdrawal API call. When followed by
|
|
4038
|
+
* RETURN_TO_WAIT, the executor will halt and the next solve cycle picks up
|
|
4039
|
+
* once the withdrawal settles and wallet balance is updated.
|
|
4040
|
+
*
|
|
4041
|
+
* If a pending withdrawal is already in transit (pendingDeposit < 0),
|
|
4042
|
+
* the amount is reduced accordingly.
|
|
4043
|
+
*/
|
|
4044
|
+
private _executeExtendedToWallet;
|
|
4045
|
+
/**
|
|
4046
|
+
* REALISE_PNL: Converts unrealised PnL to realised by closing a portion
|
|
4047
|
+
* of the short position and immediately reopening it.
|
|
4048
|
+
*
|
|
4049
|
+
* Uses {@link calculatePositionToCloseToWithdrawAmount} to determine the
|
|
4050
|
+
* minimal position size to close so that the required amount becomes
|
|
4051
|
+
* available for withdrawal.
|
|
4052
|
+
*
|
|
4053
|
+
* Both close and reopen orders use limit pricing via _executeExtendedLimitOrder.
|
|
4054
|
+
*
|
|
4055
|
+
* Steps:
|
|
4056
|
+
* 1. Close portion of short position (BUY limit order) → realises PnL
|
|
4057
|
+
* 2. Immediately reopen same size (SELL limit order) → maintains exposure
|
|
4058
|
+
*/
|
|
4059
|
+
private _executeRealisePnl;
|
|
4060
|
+
/**
|
|
4061
|
+
* EXTENDED_INCREASE_LEVER: Create a SHORT sell limit order on Extended to
|
|
4062
|
+
* increase delta-neutral exposure.
|
|
4063
|
+
*
|
|
4064
|
+
* Uses limit pricing: limitPrice = midPrice * (1 - slippage) to prevent
|
|
4065
|
+
* selling at unfavourable rates.
|
|
4066
|
+
*
|
|
4067
|
+
* Validates price divergence between Extended and Vesu before execution.
|
|
4068
|
+
*/
|
|
4069
|
+
private _executeExtendedIncreaseLever;
|
|
4070
|
+
/**
|
|
4071
|
+
* EXTENDED_DECREASE_LEVER: Close portion of SHORT position on Extended
|
|
4072
|
+
* by placing a BUY limit order.
|
|
4073
|
+
*
|
|
4074
|
+
* Uses limit pricing: limitPrice = midPrice * (1 + slippage) to prevent
|
|
4075
|
+
* buying at unfavourable rates.
|
|
4076
|
+
*
|
|
4077
|
+
* Validates price divergence between Extended and Vesu before execution.
|
|
4078
|
+
*/
|
|
4079
|
+
private _executeExtendedDecreaseLever;
|
|
4080
|
+
/**
|
|
4081
|
+
* CRISIS_INCREASE_EXTENDED_MAX_LEVERAGE: Temporarily increase Extended
|
|
4082
|
+
* leverage to the crisis maximum (e.g. 4x) to free margin.
|
|
4083
|
+
*/
|
|
4084
|
+
private _executeCrisisIncreaseLeverage;
|
|
4085
|
+
/**
|
|
4086
|
+
* CRISIS_UNDO_EXTENDED_MAX_LEVERAGE: Revert Extended leverage back to
|
|
4087
|
+
* the normal calculated level.
|
|
4088
|
+
*/
|
|
4089
|
+
private _executeCrisisUndoLeverage;
|
|
4090
|
+
/**
|
|
4091
|
+
* Adjusts a deposit-to-Extended amount by the remaining pending deposit
|
|
4092
|
+
* budget. If pending deposit > 0, those funds are already in transit and
|
|
4093
|
+
* shouldn't be re-sent.
|
|
4094
|
+
*
|
|
4095
|
+
* Mutates `_pendingDepositRemaining` as the budget is consumed.
|
|
4096
|
+
*/
|
|
4097
|
+
private _consumePendingDeposit;
|
|
4098
|
+
/**
|
|
4099
|
+
* Applies a 0.1% buffer (AVNU_BUFFER_FACTOR) to an amount.
|
|
4100
|
+
* This ensures the downstream consumer (Vesu deposit or AVNU swap)
|
|
4101
|
+
* always has sufficient tokens despite minor slippage.
|
|
4102
|
+
*/
|
|
4103
|
+
private _applyAvnuBuffer;
|
|
2244
4104
|
/**
|
|
2245
|
-
*
|
|
2246
|
-
*
|
|
4105
|
+
* Creates a TransactionResult for a batch of on-chain calls.
|
|
4106
|
+
* The caller is expected to send all calls in a single multicall transaction.
|
|
2247
4107
|
*/
|
|
2248
|
-
|
|
4108
|
+
private _onChainBatchResult;
|
|
4109
|
+
private _successResult;
|
|
4110
|
+
private _failureResult;
|
|
2249
4111
|
}
|
|
2250
4112
|
|
|
2251
4113
|
interface VesuExtendedStrategySettings extends UniversalStrategySettings {
|
|
@@ -2258,80 +4120,76 @@ interface VesuExtendedStrategySettings extends UniversalStrategySettings {
|
|
|
2258
4120
|
minimumWBTCDifferenceForAvnuSwap: number;
|
|
2259
4121
|
walletAddress: string;
|
|
2260
4122
|
}
|
|
2261
|
-
declare class VesuExtendedMultiplierStrategy<S extends VesuExtendedStrategySettings> extends SVKStrategy<S>
|
|
4123
|
+
declare class VesuExtendedMultiplierStrategy<S extends VesuExtendedStrategySettings> extends SVKStrategy<S> {
|
|
4124
|
+
wbtcToken: TokenInfo;
|
|
4125
|
+
usdcToken: TokenInfo;
|
|
4126
|
+
usdceToken: TokenInfo;
|
|
4127
|
+
readonly stateManager: ExtendedSVKVesuStateManager;
|
|
2262
4128
|
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
|
|
4129
|
+
/**
|
|
4130
|
+
* Extracts the required adapters from metadata and constructs the
|
|
4131
|
+
* state manager used by shouldInvest / handleWithdraw.
|
|
4132
|
+
*/
|
|
4133
|
+
private _initializeStateManager;
|
|
2263
4134
|
getTag(): string;
|
|
4135
|
+
/**
|
|
4136
|
+
* Fetches current WBTC (collateral) and USDC (debt) prices from the pricer.
|
|
4137
|
+
* Validates that both prices are finite and positive, throwing if not.
|
|
4138
|
+
*/
|
|
2264
4139
|
getAssetPrices(): Promise<{
|
|
2265
4140
|
collateralPrice: PriceInfo;
|
|
2266
4141
|
debtPrice: PriceInfo;
|
|
2267
4142
|
}>;
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
getAvnuAdapter(): Promise<AvnuAdapter
|
|
2272
|
-
getExtendedAdapter(): Promise<ExtendedAdapter
|
|
2273
|
-
|
|
2274
|
-
calls: Call[];
|
|
2275
|
-
status: boolean;
|
|
2276
|
-
}>;
|
|
2277
|
-
shouldInvest(): Promise<{
|
|
2278
|
-
shouldInvest: boolean;
|
|
2279
|
-
vesuAmount: Web3Number;
|
|
2280
|
-
extendedAmount: Web3Number;
|
|
2281
|
-
extendedLeverage: number;
|
|
2282
|
-
collateralPrice: number;
|
|
2283
|
-
debtPrice: number;
|
|
2284
|
-
vesuLeverage: number;
|
|
2285
|
-
debtAmountToBeRepaid: Web3Number;
|
|
2286
|
-
}>;
|
|
2287
|
-
shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<TransactionResult[]>;
|
|
4143
|
+
getVesuAdapter(): Promise<VesuMultiplyAdapter>;
|
|
4144
|
+
getVesuModifyPositionAdapter(): Promise<VesuModifyPositionAdapter>;
|
|
4145
|
+
getUsdceTransferAdapter(): Promise<TokenTransferAdapter>;
|
|
4146
|
+
getAvnuAdapter(): Promise<AvnuAdapter>;
|
|
4147
|
+
getExtendedAdapter(): Promise<ExtendedAdapter>;
|
|
4148
|
+
getUsdcToUsdceAdapter(): Promise<UsdcToUsdceAdapter>;
|
|
2288
4149
|
/**
|
|
2289
|
-
*
|
|
4150
|
+
* Creates an ExecutionService wired to this strategy's adapters and config.
|
|
4151
|
+
* Use with `stateManager.solve()` to get a SolveResult, then pass it to
|
|
4152
|
+
* `executionService.execute(solveResult)` for execution.
|
|
4153
|
+
*
|
|
4154
|
+
* @param onExecutionEvent - Optional callback for execution lifecycle events (DB persistence, alerts, etc.)
|
|
4155
|
+
* @param extendedAcceptableSlippageBps - Slippage for Extended limit orders (default: 10 = 0.1%)
|
|
4156
|
+
* @param maxPriceDivergenceBps - Max price divergence between Extended and AVNU (default: 50 = 0.5%)
|
|
2290
4157
|
*/
|
|
2291
|
-
|
|
4158
|
+
createExecutionService(opts?: {
|
|
4159
|
+
onExecutionEvent?: ExecutionCallback;
|
|
4160
|
+
extendedAcceptableSlippageBps?: number;
|
|
4161
|
+
maxPriceDivergenceBps?: number;
|
|
4162
|
+
}): Promise<ExecutionService>;
|
|
2292
4163
|
/**
|
|
2293
|
-
*
|
|
2294
|
-
*
|
|
2295
|
-
*
|
|
2296
|
-
*
|
|
2297
|
-
* @returns The transaction result
|
|
2298
|
-
* If Extended amount is greater than amount of withdrawal from extended, then we need to open a long position
|
|
2299
|
-
* so that the amount of withdrawal from extended is fullfilled
|
|
4164
|
+
* Calculates the total Assets Under Management across all adapters.
|
|
4165
|
+
* Aggregates position values from every adapter, converts to the vault's
|
|
4166
|
+
* base asset, and returns the net AUM along with the previous AUM snapshot
|
|
4167
|
+
* and per-position breakdowns.
|
|
2300
4168
|
*/
|
|
2301
|
-
moveAssets(params: {
|
|
2302
|
-
amount: Web3Number;
|
|
2303
|
-
from: string;
|
|
2304
|
-
to: string;
|
|
2305
|
-
cycleType: CycleType;
|
|
2306
|
-
}, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<TransactionResult>;
|
|
2307
|
-
handleDeposit(): Promise<TransactionResult>;
|
|
2308
|
-
/**
|
|
2309
|
-
* Check if the price difference between avnu and extended is within the acceptable range to enhance the position size or close the position
|
|
2310
|
-
* @param extendedAdapter - the extended adapter
|
|
2311
|
-
* @param vesuAdapter - the vesu adapter
|
|
2312
|
-
* @param avnuAdapter - the avnu adapter
|
|
2313
|
-
* @param positionType - the position type (open or close)
|
|
2314
|
-
* @returns true if the price difference is within the acceptable range, false otherwise
|
|
2315
|
-
*/
|
|
2316
|
-
checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter, avnuAdapter: AvnuAdapter, positionType: PositionTypeAvnuExtended): Promise<boolean>;
|
|
2317
|
-
/**
|
|
2318
|
-
* Handle the withdrawal of assets from the vault
|
|
2319
|
-
* @param amount - the amount to withdraw in USDC
|
|
2320
|
-
* @returns the calls to be executed and the status of the calls generated along with the metadata for the calls
|
|
2321
|
-
*/
|
|
2322
|
-
handleWithdraw(amount: Web3Number): Promise<TransactionResult[]>;
|
|
2323
4169
|
getAUM(): Promise<{
|
|
2324
4170
|
net: SingleTokenInfo;
|
|
2325
4171
|
prevAum: Web3Number;
|
|
2326
4172
|
splits: PositionInfo[];
|
|
2327
4173
|
}>;
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
4174
|
+
/**
|
|
4175
|
+
* Computes the maximum additional USDC that can be borrowed from Vesu
|
|
4176
|
+
* while keeping the strategy profitable. Uses the Extended funding rate
|
|
4177
|
+
* and Vesu supply APY to derive a break-even borrow APY, then queries
|
|
4178
|
+
* Vesu for the max borrowable amount at that rate.
|
|
4179
|
+
*/
|
|
2333
4180
|
getMaxBorrowableAmount(): Promise<Web3Number>;
|
|
4181
|
+
/**
|
|
4182
|
+
* Returns the current health metrics for the strategy:
|
|
4183
|
+
* [0] Vesu health factor (maxLTV / actualLTV) — higher is safer.
|
|
4184
|
+
* [1] Extended margin ratio (as percentage) — higher means more margin available.
|
|
4185
|
+
*/
|
|
2334
4186
|
getVesuHealthFactors(): Promise<number[]>;
|
|
4187
|
+
/**
|
|
4188
|
+
* Calculates the weighted net APY of the strategy across all positions.
|
|
4189
|
+
* Combines Vesu supply APY (scaled by 0.1 performance fee) and Extended
|
|
4190
|
+
* position APY, weighted by their respective USD values.
|
|
4191
|
+
* Also returns per-position APY splits.
|
|
4192
|
+
*/
|
|
2335
4193
|
netAPY(): Promise<{
|
|
2336
4194
|
net: number;
|
|
2337
4195
|
splits: {
|
|
@@ -2339,6 +4197,10 @@ declare class VesuExtendedMultiplierStrategy<S extends VesuExtendedStrategySetti
|
|
|
2339
4197
|
id: string;
|
|
2340
4198
|
}[];
|
|
2341
4199
|
}>;
|
|
4200
|
+
/**
|
|
4201
|
+
* Fetches the operator wallet's current holdings for USDC.e, USDC, and WBTC,
|
|
4202
|
+
* returning each token's balance and USD value.
|
|
4203
|
+
*/
|
|
2342
4204
|
getWalletHoldings(): Promise<{
|
|
2343
4205
|
tokenInfo: TokenInfo;
|
|
2344
4206
|
amount: Web3Number;
|
|
@@ -2386,6 +4248,7 @@ declare const VesuConfig: {
|
|
|
2386
4248
|
readonly avnu: {
|
|
2387
4249
|
readonly api: "https://starknet.api.avnu.fi/swap/v2/quotes";
|
|
2388
4250
|
};
|
|
4251
|
+
readonly targetLtv: 0.61;
|
|
2389
4252
|
readonly minDebtForVesuRebalacing: number;
|
|
2390
4253
|
};
|
|
2391
4254
|
declare const AbisConfig: {
|
|
@@ -2680,17 +4543,19 @@ declare const AbisConfig: {
|
|
|
2680
4543
|
*/
|
|
2681
4544
|
declare const returnFormattedAmount: (amount: number, toTokenDecimals: number) => string;
|
|
2682
4545
|
/**
|
|
2683
|
-
* calculates the amount to distribute to
|
|
4546
|
+
* calculates the amount to distribute to Extended and Vesu
|
|
2684
4547
|
* Determines how much to allocate to each platform based on leverage calculations
|
|
2685
4548
|
* @param {number} amount - The total amount to distribute
|
|
2686
4549
|
* @returns {object} Object containing avnu_amount, extended_amount, and extended_leverage
|
|
2687
4550
|
*/
|
|
2688
|
-
declare const calculateAmountDistribution: (
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
4551
|
+
declare const calculateAmountDistribution: (amountToInvest: number, collateralPrice: number, // in usd
|
|
4552
|
+
collateralUnits: Web3Number, // existing collateral in vesu (e.g. BTC)
|
|
4553
|
+
extendedExposureUsd: Web3Number) => {
|
|
4554
|
+
vesuAmount: Web3Number;
|
|
4555
|
+
extendedAmount: Web3Number;
|
|
4556
|
+
extendedLeverage: number;
|
|
4557
|
+
vesuLeverage: number;
|
|
4558
|
+
};
|
|
2694
4559
|
/**
|
|
2695
4560
|
* calculate the amount distribution for withdrawal
|
|
2696
4561
|
* @param amount - The amount to withdraw
|
|
@@ -2729,7 +4594,7 @@ declare const calculateExtendedLevergae: () => number;
|
|
|
2729
4594
|
* @returns {object} Object containing deltadebtAmountUnits and isIncrease flag
|
|
2730
4595
|
*/
|
|
2731
4596
|
declare const calculateDebtAmount: (collateralAmount: Web3Number, debtAmount: Web3Number, debtPrice: number, maxLtv: number | undefined, addedAmount: Web3Number, // this is in btc
|
|
2732
|
-
collateralPrice: number, isDeposit: boolean) => {
|
|
4597
|
+
collateralPrice: number, isDeposit: boolean, targetLtv?: number) => {
|
|
2733
4598
|
deltadebtAmountUnits: Web3Number;
|
|
2734
4599
|
isIncrease: boolean;
|
|
2735
4600
|
} | {
|
|
@@ -2771,7 +4636,7 @@ declare const calculateAmountDepositOnExtendedWhenIncurringLosses: (client: Exte
|
|
|
2771
4636
|
* @returns deltaCollateralAmountUnits in collateral units
|
|
2772
4637
|
* null if there is an error
|
|
2773
4638
|
*/
|
|
2774
|
-
declare const calculateWBTCAmountToMaintainLTV: (collateralAmount: Web3Number, debtAmount: Web3Number, debtPrice: number, maxLtv: number | undefined, collateralPrice: number
|
|
4639
|
+
declare const calculateWBTCAmountToMaintainLTV: (collateralAmount: Web3Number, debtAmount: Web3Number, debtPrice: number, maxLtv: number | undefined, collateralPrice: number) => {
|
|
2775
4640
|
deltaCollateralAmountUnits: Web3Number;
|
|
2776
4641
|
} | {
|
|
2777
4642
|
deltaCollateralAmountUnits: null;
|
|
@@ -2784,8 +4649,7 @@ declare const calculateExposureDelta: (exposure_extended: number, exposure_vesu:
|
|
|
2784
4649
|
* @returns {number} The delta percentage
|
|
2785
4650
|
*/
|
|
2786
4651
|
declare const calculateBTCPriceDelta: (btcPrice: number, lastBtcPrice: number) => number;
|
|
2787
|
-
declare const calculateVesUPositionSizeGivenExtended: (
|
|
2788
|
-
vesuAmountInUsd: string;
|
|
4652
|
+
declare const calculateVesUPositionSizeGivenExtended: (extendedPositonSize: number, extendedHoldingAmount: Web3Number, collateralAmount: Web3Number, extendedBtcPrice: number) => {
|
|
2789
4653
|
vesuAmountInBTC: Web3Number;
|
|
2790
4654
|
extendedAmountInBTC: Web3Number;
|
|
2791
4655
|
};
|
|
@@ -2797,11 +4661,106 @@ declare const calculateVesUPositionSizeGivenExtended: (extendedPositonValue: num
|
|
|
2797
4661
|
* @param collateralPrice - The collateral price
|
|
2798
4662
|
* @param debtPrice - The debt price
|
|
2799
4663
|
* @param targetHf - The target hf
|
|
4664
|
+
* @@dev returns negative to represent debt to be repaid
|
|
2800
4665
|
* @returns The debt amount to be repaid
|
|
2801
4666
|
*/
|
|
2802
|
-
declare const calculateDeltaDebtAmount: (
|
|
4667
|
+
declare const calculateDeltaDebtAmount: (existingVesuCollateral: Web3Number, existingVesuDebt: Web3Number, debtPrice: number, collateralPrice: number) => {
|
|
4668
|
+
deltaDebt: Web3Number;
|
|
4669
|
+
shouldRebalance: boolean;
|
|
4670
|
+
};
|
|
2803
4671
|
declare const calculatePositionToCloseToWithdrawAmount: (extendedBalance: Balance, extendedPositions: Position, amountToWithdraw: Web3Number) => Promise<Web3Number>;
|
|
2804
4672
|
|
|
4673
|
+
/**
|
|
4674
|
+
* Filter option definition
|
|
4675
|
+
*/
|
|
4676
|
+
interface FilterOption {
|
|
4677
|
+
id: string;
|
|
4678
|
+
label: string;
|
|
4679
|
+
icon?: string;
|
|
4680
|
+
}
|
|
4681
|
+
/**
|
|
4682
|
+
* Strategy filter metadata - defines what filters are available
|
|
4683
|
+
*/
|
|
4684
|
+
interface StrategyFilterMetadata {
|
|
4685
|
+
assets: FilterOption[];
|
|
4686
|
+
protocols: FilterOption[];
|
|
4687
|
+
quickFilters: FilterOption[];
|
|
4688
|
+
}
|
|
4689
|
+
/**
|
|
4690
|
+
* Strategy type enum
|
|
4691
|
+
*/
|
|
4692
|
+
declare enum StrategyType {
|
|
4693
|
+
EKUBO_CL = "ekubo",
|
|
4694
|
+
UNIVERSAL = "universal",
|
|
4695
|
+
HYPER_LST = "hyper-lst",
|
|
4696
|
+
VESU_REBALANCE = "vesu-rebalance",
|
|
4697
|
+
SENSEI = "sensei"
|
|
4698
|
+
}
|
|
4699
|
+
/**
|
|
4700
|
+
* Strategy metadata extracted from IStrategyMetadata
|
|
4701
|
+
*/
|
|
4702
|
+
interface StrategyMetadata {
|
|
4703
|
+
id: string;
|
|
4704
|
+
name: string;
|
|
4705
|
+
type: StrategyType;
|
|
4706
|
+
assets: string[];
|
|
4707
|
+
protocols: string[];
|
|
4708
|
+
tags: string[];
|
|
4709
|
+
curator?: {
|
|
4710
|
+
name: string;
|
|
4711
|
+
logo: string;
|
|
4712
|
+
};
|
|
4713
|
+
isRetired: boolean;
|
|
4714
|
+
}
|
|
4715
|
+
/**
|
|
4716
|
+
* Strategy registry entry
|
|
4717
|
+
*/
|
|
4718
|
+
interface StrategyRegistryEntry<T = any> {
|
|
4719
|
+
metadata: IStrategyMetadata<T>;
|
|
4720
|
+
type: StrategyType;
|
|
4721
|
+
}
|
|
4722
|
+
/**
|
|
4723
|
+
* Build strategy registry from SDK strategies
|
|
4724
|
+
*/
|
|
4725
|
+
declare function buildStrategyRegistry(): StrategyRegistryEntry[];
|
|
4726
|
+
/**
|
|
4727
|
+
* Get all strategy metadata from registry
|
|
4728
|
+
*/
|
|
4729
|
+
declare function getAllStrategyMetadata(): StrategyMetadata[];
|
|
4730
|
+
/**
|
|
4731
|
+
* Get filter metadata - defines available filters and their options
|
|
4732
|
+
*/
|
|
4733
|
+
declare function getFilterMetadata(): StrategyFilterMetadata;
|
|
4734
|
+
/**
|
|
4735
|
+
* Get live strategies (filter out retired)
|
|
4736
|
+
*/
|
|
4737
|
+
declare function getLiveStrategies(): StrategyRegistryEntry[];
|
|
4738
|
+
/**
|
|
4739
|
+
* Get strategies by type
|
|
4740
|
+
*/
|
|
4741
|
+
declare function getStrategiesByType(type: StrategyType): StrategyRegistryEntry[];
|
|
4742
|
+
|
|
4743
|
+
declare enum FactoryStrategyType {
|
|
4744
|
+
UNIVERSAL = "UNIVERSAL",
|
|
4745
|
+
EKUBO_CL = "EKUBO_CL",
|
|
4746
|
+
HYPER_LST = "HYPER_LST",
|
|
4747
|
+
VESU_REBALANCE = "VESU_REBALANCE",
|
|
4748
|
+
SENSEI = "SENSEI"
|
|
4749
|
+
}
|
|
4750
|
+
declare function createUniversalStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<UniversalStrategySettings>): UniversalStrategy<UniversalStrategySettings>;
|
|
4751
|
+
declare function createEkuboCLStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<CLVaultStrategySettings>): EkuboCLVault;
|
|
4752
|
+
declare function createHyperLSTStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<HyperLSTStrategySettings>): UniversalLstMultiplierStrategy<HyperLSTStrategySettings>;
|
|
4753
|
+
declare function createVesuRebalanceStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>): VesuRebalance;
|
|
4754
|
+
declare function createSenseiStrategy(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>): SenseiVault;
|
|
4755
|
+
/**
|
|
4756
|
+
* Determines the strategy type from metadata by inspecting the additionalInfo structure
|
|
4757
|
+
*/
|
|
4758
|
+
declare function getStrategyTypeFromMetadata(metadata: IStrategyMetadata<any>): FactoryStrategyType;
|
|
4759
|
+
/**
|
|
4760
|
+
* Generic factory function that creates SDK strategy instances based on type
|
|
4761
|
+
*/
|
|
4762
|
+
declare function createStrategy(type: FactoryStrategyType, config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<any>): EkuboCLVault | VesuRebalance | SenseiVault | UniversalStrategy<UniversalStrategySettings> | UniversalLstMultiplierStrategy<HyperLSTStrategySettings>;
|
|
4763
|
+
|
|
2805
4764
|
interface EkuboRouteNode {
|
|
2806
4765
|
pool_key: {
|
|
2807
4766
|
token0: string;
|
|
@@ -2828,14 +4787,23 @@ declare class EkuboQuoter {
|
|
|
2828
4787
|
ENDPOINT: string;
|
|
2829
4788
|
tokenMarketData: TokenMarketData;
|
|
2830
4789
|
constructor(config: IConfig, pricer: PricerBase);
|
|
4790
|
+
private _callQuoterApi;
|
|
2831
4791
|
/**
|
|
2832
|
-
*
|
|
2833
|
-
* @param fromToken
|
|
2834
|
-
* @param toToken
|
|
2835
|
-
* @param
|
|
2836
|
-
* @returns
|
|
4792
|
+
* Given exactly `inputAmount` of `fromToken`, how much `toToken` do I receive?
|
|
4793
|
+
* @param fromToken - address of the token being sold
|
|
4794
|
+
* @param toToken - address of the token being bought
|
|
4795
|
+
* @param inputAmount - must be positive (the amount of fromToken to sell)
|
|
4796
|
+
* @returns EkuboQuote where `total_calculated` is the output amount (positive)
|
|
4797
|
+
*/
|
|
4798
|
+
getQuoteExactInput(fromToken: string, toToken: string, inputAmount: Web3Number): Promise<EkuboQuote>;
|
|
4799
|
+
/**
|
|
4800
|
+
* To receive exactly `outputAmount` of `toToken`, how much `fromToken` must I provide?
|
|
4801
|
+
* @param fromToken - address of the token being sold
|
|
4802
|
+
* @param toToken - address of the token being bought
|
|
4803
|
+
* @param outputAmount - must be positive (the desired amount of toToken to receive)
|
|
4804
|
+
* @returns EkuboQuote where `total_calculated` is the required input amount (negative per Ekubo convention)
|
|
2837
4805
|
*/
|
|
2838
|
-
|
|
4806
|
+
getQuoteExactOutput(fromToken: string, toToken: string, outputAmount: Web3Number): Promise<EkuboQuote>;
|
|
2839
4807
|
getDexPrice(baseToken: TokenInfo, quoteToken: TokenInfo, amount: Web3Number): Promise<number>;
|
|
2840
4808
|
getLSTTrueExchangeRate(baseToken: TokenInfo, quoteToken: TokenInfo, amount: Web3Number): Promise<number>;
|
|
2841
4809
|
getSwapLimitAmount(fromToken: TokenInfo, toToken: TokenInfo, amount: Web3Number, max_slippage?: number): Promise<Web3Number>;
|
|
@@ -2865,6 +4833,7 @@ declare class Global {
|
|
|
2865
4833
|
static getDefaultTokens(): TokenInfo[];
|
|
2866
4834
|
static getTokens(): Promise<TokenInfo[]>;
|
|
2867
4835
|
static assert(condition: any, message: string): void;
|
|
4836
|
+
static getTokenInfoFromName(tokenName: string): Promise<TokenInfo>;
|
|
2868
4837
|
static getTokenInfoFromAddr(addr: ContractAddr): Promise<TokenInfo>;
|
|
2869
4838
|
static setGlobalCache(key: string, data: any, ttl?: number): void;
|
|
2870
4839
|
static getGlobalCache<T>(key: string): T | null;
|
|
@@ -3033,7 +5002,7 @@ declare class PricerRedis extends Pricer {
|
|
|
3033
5002
|
/** sets current local price in redis */
|
|
3034
5003
|
private _setRedisPrices;
|
|
3035
5004
|
/** Returns price from redis */
|
|
3036
|
-
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
5005
|
+
getPrice(tokenSymbol: string, blockNumber?: BlockIdentifier): Promise<PriceInfo>;
|
|
3037
5006
|
}
|
|
3038
5007
|
|
|
3039
5008
|
declare function getAPIUsingHeadlessBrowser(url: string): Promise<any>;
|
|
@@ -3060,6 +5029,7 @@ declare function executeDeployCalls(contractsInfo: DeployContractResult[], acc:
|
|
|
3060
5029
|
declare function executeTransactions(calls: Call[], acc: Account, provider: RpcProvider, remarks?: string): Promise<{
|
|
3061
5030
|
transaction_hash: string;
|
|
3062
5031
|
}>;
|
|
5032
|
+
declare function myWaitForTransaction(transaction_hash: string, provider: RpcProvider, retry?: number): Promise<boolean>;
|
|
3063
5033
|
declare const Deployer: {
|
|
3064
5034
|
getAccount: typeof getAccount;
|
|
3065
5035
|
myDeclare: typeof myDeclare;
|
|
@@ -3067,6 +5037,7 @@ declare const Deployer: {
|
|
|
3067
5037
|
prepareMultiDeployContracts: typeof prepareMultiDeployContracts;
|
|
3068
5038
|
executeDeployCalls: typeof executeDeployCalls;
|
|
3069
5039
|
executeTransactions: typeof executeTransactions;
|
|
5040
|
+
myWaitForTransaction: typeof myWaitForTransaction;
|
|
3070
5041
|
};
|
|
3071
5042
|
|
|
3072
5043
|
/**
|
|
@@ -3147,4 +5118,4 @@ declare class PasswordJsonCryptoUtil {
|
|
|
3147
5118
|
decrypt(encryptedData: string, password: string): any;
|
|
3148
5119
|
}
|
|
3149
5120
|
|
|
3150
|
-
export { type APYInfo, APYType, AUDIT_URL, AUMTypes, AVNU_EXCHANGE, AVNU_EXCHANGE_FOR_LEGACY_USDC, AVNU_LEGACY_SANITIZER, AVNU_MIDDLEWARE, AVNU_QUOTE_URL, AbisConfig, type AccountInfo, type AdapterLeafType, AddressesConfig, type AllAccountsStore, type ApiResponse, type ApproveCallParams, type AssetOperation, AssetOperationStatus, AssetOperationType, AutoCompounderSTRK, AvnuAdapter, type AvnuAdapterConfig, type AvnuSwapCallParams, AvnuWrapper, type Balance, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type CLVaultStrategySettings, type CancelOrderRequest, CommonAdapter, type CommonAdapterConfig, ContractAddr, type CreateOrderRequest, CycleType, type DecreaseLeverParams, Deployer, type DepositParams, type DualActionAmount, type DualTokenInfo, ERC20, EXTENDED_CONTRACT, EXTENDED_SANITIZER, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, ExitType, ExtendedAdapter, type ExtendedAdapterConfig, type ExtendedApiResponse, ExtendedConfig, ExtendedWrapper, type ExtendedWrapperConfig, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type FundingRate, type GenerateCallFn, Global, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, type L2Config, LSTAPRService, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, type Market, type MarketStats, Midas, Network, type OpenOrder, OrderSide, OrderStatus, OrderStatusReason, OrderType, PRICE_ROUTER, PasswordJsonCryptoUtil, type PlacedOrder, type Position, type PositionAPY, type PositionAmount, type PositionHistory, type PositionInfo, PositionSide, PositionTypeAvnuExtended, Pragma, type PriceInfo, Pricer, PricerBase, PricerFromApi, PricerLST, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, type RiskFactorConfig, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SettlementSignature, type SignedWithdrawRequest, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, type StarkDebuggingOrderAmounts, type StarkSettlement, Store, type StoreConfig, type SupportedPosition, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, TimeInForce, type TokenAmount, type TokenInfo, TokenMarketData, type TradingConfig, type TransactionMetadata, type TransactionResult, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall,
|
|
5121
|
+
export { type APYInfo, APYType, AUDIT_URL, AUMTypes, AVNU_EXCHANGE, AVNU_EXCHANGE_FOR_LEGACY_USDC, AVNU_LEGACY_SANITIZER, AVNU_MIDDLEWARE, AVNU_QUOTE_URL, AbisConfig, type AccessControlInfo, AccessControlType, type AccountInfo, type AdapterLeafType, AddressesConfig, type AllAccountsStore, type AmountInfo, type AmountsInfo, type ApiResponse, type ApproveCallParams, type AssetOperation, AssetOperationStatus, AssetOperationType, AuditStatus, AutoCompounderSTRK, AvnuAdapter, type AvnuAdapterConfig, type AvnuSwapCallParams, AvnuWrapper, type Balance, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type BringLiquidityRoute, CASE_ROUTE_TYPES, type CLVaultStrategySettings, type CancelOrderRequest, CaseCategory, CaseId, CommonAdapter, type CommonAdapterConfig, ContractAddr, type CreateOrderRequest, type CrisisBorrowRoute, type CrisisExtendedLeverRoute, CycleType, type DecreaseLeverParams, Deployer, type DepositParams, type DualActionAmount, type DualTokenInfo, ERC20, EXTENDED_CONTRACT, EXTENDED_SANITIZER, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type ExecutionCallback, type ExecutionConfig, type ExecutionEventMetadata, ExecutionEventType, type ExecutionRoute, ExecutionService, ExitType, ExtendedAdapter, type ExtendedAdapterConfig, type ExtendedApiResponse, type ExtendedBalanceState, ExtendedConfig, type ExtendedLeverRoute, type ExtendedPositionDelta, type ExtendedPositionState, ExtendedSVKVesuStateManager, ExtendedWrapper, type ExtendedWrapperConfig, type FAQ, FactoryStrategyType, FatalError, type FilterOption, type FlashloanCallParams, FlowChartColors, type FundingPayment, type FundingRate, type GenerateCallFn, Global, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, InstantWithdrawalVault, type L2Config, LSTAPRService, LSTPriceType, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type LoggerConfig, type LoggerLevel, type ManageCall, MarginType, type Market, type MarketStats, Midas, MyNumber, type NetAPYDetails, type NetAPYSplit, Network, type OpenOrder, OrderSide, OrderStatus, OrderStatusReason, OrderType, PRICE_ROUTER, type ParsedStarknetCall, PasswordJsonCryptoUtil, type PlacedOrder, type Position, type PositionAPY, type PositionAmount, type PositionHistory, type PositionInfo, PositionSide, PositionTypeAvnuExtended, Pragma, type PriceInfo, Pricer, PricerBase, PricerFromApi, PricerLST, PricerRedis, Protocols, type RealisePnlRoute, type RedemptionInfo, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, type RiskFactorConfig, RiskType, type Route, type RouteNode, RouteType, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, type SecurityMetadata, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SettlementSignature, type SignedWithdrawRequest, type SingleActionAmount, type SingleTokenInfo, SolveBudget, type SolveCase, type SolveCaseEntry, type SolveResult, type SourceCodeInfo, SourceCodeType, StandardMerkleTree, type StandardMerkleTreeData, type StarkDebuggingOrderAmounts, type StarkSettlement, StarknetCallParser, type StarknetCallParserOptions, type StateManagerConfig, Store, type StoreConfig, type StrategyAlert, type StrategyCapabilities, type StrategyFilterMetadata, StrategyLiveStatus, type StrategyMetadata, type StrategyRegistryEntry, type StrategySettings, StrategyTag, StrategyType, type SupportedPosition, type Swap, type SwapInfo, type SwapPriceInfo, type SwapRoute, TRANSFER_SANITIZER, TelegramGroupNotif, TelegramNotif, TimeInForce, type TokenAmount, type TokenBalance, type TokenInfo, TokenMarketData, TokenTransferAdapter, type TokenTransferAdapterConfig, type TradingConfig, type TransactionMetadata, type TransactionResult, type TransferRoute, UNIVERSAL_ADAPTERS, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, UniversalStrategies, UniversalStrategy, type UniversalStrategySettings, type UpdateLeverageRequest, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VaultType, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, VesuConfig, type VesuDebtRoute, type VesuDefiSpringRewardsCallParams, type VesuDepositParams, VesuExtendedMultiplierStrategy, type VesuExtendedStrategySettings, VesuExtendedTestStrategies, type VesuModifyDelegationCallParams, VesuModifyPositionAdapter, type VesuModifyPositionAdapterConfig, type VesuModifyPositionCallParams, type VesuModifyPositionDepositParams, type VesuModifyPositionWithdrawParams, VesuMultiplyAdapter, type VesuMultiplyAdapterConfig, type VesuMultiplyCallParams, type VesuMultiplyRoute, type VesuPoolDelta, VesuPoolMetadata, type VesuPoolState, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, VesuSupplyOnlyAdapter, type VesuSupplyOnlyAdapterConfig, type VesuWithdrawParams, type WaitRoute, Web3Number, type WithdrawParams, type WithdrawRequest, ZkLend, _riskFactor, assert, buildStrategyRegistry, calculateAmountDepositOnExtendedWhenIncurringLosses, calculateAmountDistribution, calculateAmountDistributionForWithdrawal, calculateBTCPriceDelta, calculateDebtAmount, calculateDebtReductionAmountForWithdrawal, calculateDeltaDebtAmount, calculateExposureDelta, calculateExtendedLevergae, calculatePositionToCloseToWithdrawAmount, calculateVesUPositionSizeGivenExtended, calculateVesuLeverage, calculateWBTCAmountToMaintainLTV, configureLogger, createEkuboCLStrategy, createHyperLSTStrategy, createSenseiStrategy, createStrategy, createUniversalStrategy, createVesuRebalanceStrategy, 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, returnFormattedAmount, routeSummary, toAmountsInfo, toBigInt };
|