@strkfarm/sdk 1.1.70 → 2.0.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.browser.global.js +67016 -59681
- package/dist/index.browser.mjs +29832 -23221
- package/dist/index.d.ts +2006 -787
- package/dist/index.js +25403 -18769
- package/dist/index.mjs +25333 -18739
- package/package.json +80 -76
- package/src/data/extended-deposit.abi.json +3613 -0
- package/src/data/universal-vault.abi.json +135 -20
- package/src/dataTypes/address.ts +7 -0
- package/src/global.ts +240 -193
- package/src/interfaces/common.tsx +26 -2
- package/src/modules/ExtendedWrapperSDk/index.ts +62 -0
- package/src/modules/ExtendedWrapperSDk/types.ts +311 -0
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +395 -0
- package/src/modules/avnu.ts +17 -4
- package/src/modules/ekubo-quoter.ts +99 -10
- package/src/modules/erc20.ts +67 -21
- package/src/modules/harvests.ts +16 -29
- package/src/modules/index.ts +5 -1
- package/src/modules/lst-apr.ts +36 -0
- package/src/modules/midas.ts +159 -0
- package/src/modules/pricer-from-api.ts +2 -2
- package/src/modules/pricer-lst.ts +1 -1
- package/src/modules/pricer.ts +3 -38
- package/src/modules/token-market-data.ts +202 -0
- package/src/node/deployer.ts +1 -36
- package/src/strategies/autoCompounderStrk.ts +1 -1
- package/src/strategies/base-strategy.ts +20 -3
- package/src/strategies/ekubo-cl-vault.tsx +123 -306
- package/src/strategies/index.ts +4 -1
- package/src/strategies/svk-strategy.ts +247 -0
- package/src/strategies/universal-adapters/adapter-optimizer.ts +65 -0
- package/src/strategies/universal-adapters/adapter-utils.ts +5 -1
- package/src/strategies/universal-adapters/avnu-adapter.ts +411 -0
- package/src/strategies/universal-adapters/baseAdapter.ts +181 -153
- package/src/strategies/universal-adapters/common-adapter.ts +98 -77
- package/src/strategies/universal-adapters/extended-adapter.ts +661 -0
- package/src/strategies/universal-adapters/index.ts +5 -1
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +109 -0
- package/src/strategies/universal-adapters/vesu-adapter.ts +220 -218
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +924 -0
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +58 -51
- package/src/strategies/universal-lst-muliplier-strategy.tsx +707 -774
- package/src/strategies/universal-strategy.tsx +1098 -1180
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +34 -0
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +77 -0
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +49 -0
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +376 -0
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +1134 -0
- package/src/strategies/vesu-rebalance.tsx +16 -19
- package/src/utils/health-factor-math.ts +11 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import * as starknet from 'starknet';
|
|
3
|
-
import { RpcProvider, BlockIdentifier, Contract,
|
|
3
|
+
import { RpcProvider, BlockIdentifier, Contract, Call, Account, CairoCustomEnum, Uint256, RawArgs } from 'starknet';
|
|
4
4
|
import React, { ReactNode } from 'react';
|
|
5
|
-
import { Quote, AvnuOptions } from '@avnu/avnu-sdk';
|
|
6
5
|
import { HexString, BytesLike } from '@ericnordelo/strk-merkle-tree/dist/bytes';
|
|
7
6
|
import { MultiProof } from '@ericnordelo/strk-merkle-tree/dist/core';
|
|
8
7
|
import { MerkleTreeImpl, MerkleTreeData } from '@ericnordelo/strk-merkle-tree/dist/merkletree';
|
|
9
8
|
import { MerkleTreeOptions } from '@ericnordelo/strk-merkle-tree/dist/options';
|
|
10
9
|
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 {
|
|
@@ -51,6 +51,7 @@ declare class ContractAddr {
|
|
|
51
51
|
static eqString(a: string, b: string): boolean;
|
|
52
52
|
toString(): string;
|
|
53
53
|
toBigInt(): bigint;
|
|
54
|
+
shortString(left?: number, right?: number): string;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
declare enum RiskType {
|
|
@@ -169,11 +170,16 @@ interface VaultPosition {
|
|
|
169
170
|
usdValue: number;
|
|
170
171
|
token: TokenInfo;
|
|
171
172
|
remarks: string;
|
|
173
|
+
protocol: IProtocol;
|
|
172
174
|
}
|
|
173
175
|
declare const Protocols: {
|
|
176
|
+
NONE: IProtocol;
|
|
174
177
|
VESU: IProtocol;
|
|
175
178
|
ENDUR: IProtocol;
|
|
176
179
|
EXTENDED: IProtocol;
|
|
180
|
+
EKUBO: IProtocol;
|
|
181
|
+
AVNU: IProtocol;
|
|
182
|
+
VAULT: IProtocol;
|
|
177
183
|
};
|
|
178
184
|
|
|
179
185
|
interface ILendingMetadata {
|
|
@@ -228,13 +234,6 @@ declare abstract class Initializable {
|
|
|
228
234
|
waitForInitilisation(): Promise<void>;
|
|
229
235
|
}
|
|
230
236
|
|
|
231
|
-
declare abstract class PricerBase {
|
|
232
|
-
readonly config: IConfig;
|
|
233
|
-
readonly tokens: TokenInfo[];
|
|
234
|
-
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
235
|
-
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
237
|
interface PriceInfo {
|
|
239
238
|
price: number;
|
|
240
239
|
timestamp: Date;
|
|
@@ -246,7 +245,7 @@ declare class Pricer extends PricerBase {
|
|
|
246
245
|
refreshInterval: number;
|
|
247
246
|
staleTime: number;
|
|
248
247
|
protected methodToUse: {
|
|
249
|
-
[tokenSymbol: string]: 'Ekubo' | 'Coinbase' | 'Coinmarketcap'
|
|
248
|
+
[tokenSymbol: string]: 'Ekubo' | 'Coinbase' | 'Coinmarketcap';
|
|
250
249
|
};
|
|
251
250
|
/**
|
|
252
251
|
* TOKENA and TOKENB are the two token names to get price of TokenA in terms of TokenB
|
|
@@ -264,130 +263,14 @@ declare class Pricer extends PricerBase {
|
|
|
264
263
|
_getPrice(token: TokenInfo, defaultMethod?: string): Promise<number>;
|
|
265
264
|
_getPriceCoinbase(token: TokenInfo): Promise<number>;
|
|
266
265
|
_getPriceCoinMarketCap(token: TokenInfo): Promise<number>;
|
|
267
|
-
_getAvnuPrice(token: TokenInfo, amountIn?: Web3Number, retry?: number): Promise<number>;
|
|
268
266
|
_getPriceEkubo(token: TokenInfo, amountIn?: Web3Number, retry?: number): Promise<number>;
|
|
269
267
|
}
|
|
270
268
|
|
|
271
|
-
declare class
|
|
272
|
-
|
|
273
|
-
readonly
|
|
274
|
-
constructor(provider: RpcProvider);
|
|
275
|
-
getPrice(tokenAddr: string): Promise<number>;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
declare class ZkLend extends ILending implements ILending {
|
|
279
|
-
readonly pricer: Pricer;
|
|
280
|
-
static readonly POOLS_URL = "https://app.zklend.com/api/pools";
|
|
281
|
-
private POSITION_URL;
|
|
282
|
-
constructor(config: IConfig, pricer: Pricer);
|
|
283
|
-
init(): Promise<void>;
|
|
284
|
-
/**
|
|
285
|
-
* @description Get the health factor of the user for given lending and debt tokens
|
|
286
|
-
* @param lending_tokens
|
|
287
|
-
* @param debt_tokens
|
|
288
|
-
* @param user
|
|
289
|
-
* @returns hf (e.g. returns 1.5 for 150% health factor)
|
|
290
|
-
*/
|
|
291
|
-
get_health_factor_tokenwise(lending_tokens: TokenInfo[], debt_tokens: TokenInfo[], user: ContractAddr): Promise<number>;
|
|
292
|
-
/**
|
|
293
|
-
* @description Get the health factor of the user
|
|
294
|
-
* - Considers all tokens for collateral and debt
|
|
295
|
-
*/
|
|
296
|
-
get_health_factor(user: ContractAddr): Promise<number>;
|
|
297
|
-
getPositionsSummary(user: ContractAddr): Promise<{
|
|
298
|
-
collateralUSD: number;
|
|
299
|
-
debtUSD: number;
|
|
300
|
-
}>;
|
|
301
|
-
/**
|
|
302
|
-
* @description Get the token-wise collateral and debt positions of the user
|
|
303
|
-
* @param user Contract address of the user
|
|
304
|
-
* @returns Promise<ILendingPosition[]>
|
|
305
|
-
*/
|
|
306
|
-
getPositions(user: ContractAddr): Promise<ILendingPosition[]>;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
declare class PricerFromApi extends PricerBase {
|
|
269
|
+
declare abstract class PricerBase {
|
|
270
|
+
readonly config: IConfig;
|
|
271
|
+
readonly tokens: TokenInfo[];
|
|
310
272
|
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
311
273
|
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
312
|
-
getPriceFromMyAPI(tokenSymbol: string): Promise<{
|
|
313
|
-
price: number;
|
|
314
|
-
timestamp: Date;
|
|
315
|
-
}>;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
declare class ERC20 {
|
|
319
|
-
readonly config: IConfig;
|
|
320
|
-
constructor(config: IConfig);
|
|
321
|
-
contract(addr: string | ContractAddr): Contract;
|
|
322
|
-
balanceOf(token: string | ContractAddr, address: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
|
|
323
|
-
allowance(token: string | ContractAddr, owner: string | ContractAddr, spender: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
interface Route {
|
|
327
|
-
token_from: string;
|
|
328
|
-
token_to: string;
|
|
329
|
-
exchange_address: string;
|
|
330
|
-
percent: number;
|
|
331
|
-
additional_swap_params: string[];
|
|
332
|
-
}
|
|
333
|
-
interface SwapInfo {
|
|
334
|
-
token_from_address: string;
|
|
335
|
-
token_from_amount: Uint256;
|
|
336
|
-
token_to_address: string;
|
|
337
|
-
token_to_amount: Uint256;
|
|
338
|
-
token_to_min_amount: Uint256;
|
|
339
|
-
beneficiary: string;
|
|
340
|
-
integrator_fee_amount_bps: number;
|
|
341
|
-
integrator_fee_recipient: string;
|
|
342
|
-
routes: Route[];
|
|
343
|
-
}
|
|
344
|
-
declare class AvnuWrapper {
|
|
345
|
-
getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number, excludeSources?: string[]): Promise<Quote>;
|
|
346
|
-
getSwapInfo(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount?: string, options?: AvnuOptions): Promise<SwapInfo>;
|
|
347
|
-
static buildZeroSwap(tokenToSell: ContractAddr, beneficiary: string, tokenToBuy?: ContractAddr): SwapInfo;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
declare class AutoCompounderSTRK {
|
|
351
|
-
readonly config: IConfig;
|
|
352
|
-
readonly addr: ContractAddr;
|
|
353
|
-
readonly pricer: Pricer;
|
|
354
|
-
private initialized;
|
|
355
|
-
contract: Contract | null;
|
|
356
|
-
readonly metadata: {
|
|
357
|
-
decimals: number;
|
|
358
|
-
underlying: {
|
|
359
|
-
address: ContractAddr;
|
|
360
|
-
name: string;
|
|
361
|
-
symbol: string;
|
|
362
|
-
};
|
|
363
|
-
name: string;
|
|
364
|
-
};
|
|
365
|
-
constructor(config: IConfig, pricer: Pricer);
|
|
366
|
-
init(): Promise<void>;
|
|
367
|
-
waitForInitilisation(): Promise<void>;
|
|
368
|
-
/** Returns shares of user */
|
|
369
|
-
balanceOf(user: ContractAddr): Promise<Web3Number>;
|
|
370
|
-
/** Returns underlying assets of user */
|
|
371
|
-
balanceOfUnderlying(user: ContractAddr): Promise<Web3Number>;
|
|
372
|
-
/** Returns usd value of assets */
|
|
373
|
-
usdBalanceOfUnderlying(user: ContractAddr): Promise<{
|
|
374
|
-
usd: Web3Number;
|
|
375
|
-
assets: Web3Number;
|
|
376
|
-
}>;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
interface HarvestInfo {
|
|
380
|
-
rewardsContract: ContractAddr;
|
|
381
|
-
token: ContractAddr;
|
|
382
|
-
startDate: Date;
|
|
383
|
-
endDate: Date;
|
|
384
|
-
claim: {
|
|
385
|
-
id: number;
|
|
386
|
-
amount: Web3Number;
|
|
387
|
-
claimee: ContractAddr;
|
|
388
|
-
};
|
|
389
|
-
actualReward: Web3Number;
|
|
390
|
-
proof: string[];
|
|
391
274
|
}
|
|
392
275
|
|
|
393
276
|
interface CacheData$1 {
|
|
@@ -402,251 +285,237 @@ declare class CacheClass {
|
|
|
402
285
|
isCacheValid(key: string): boolean;
|
|
403
286
|
}
|
|
404
287
|
|
|
405
|
-
interface
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
interface SingleTokenInfo extends SingleActionAmount {
|
|
410
|
-
usdValue: number;
|
|
288
|
+
interface LeveledLogMethod {
|
|
289
|
+
(message: string, ...meta: any[]): void;
|
|
290
|
+
(message: any): void;
|
|
411
291
|
}
|
|
412
|
-
interface
|
|
413
|
-
|
|
414
|
-
|
|
292
|
+
interface MyLogger {
|
|
293
|
+
error: LeveledLogMethod;
|
|
294
|
+
warn: LeveledLogMethod;
|
|
295
|
+
info: LeveledLogMethod;
|
|
296
|
+
verbose: LeveledLogMethod;
|
|
297
|
+
debug: LeveledLogMethod;
|
|
415
298
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
299
|
+
declare const logger: MyLogger;
|
|
300
|
+
|
|
301
|
+
interface LeafData {
|
|
302
|
+
id: bigint;
|
|
303
|
+
readableId: string;
|
|
304
|
+
data: bigint[];
|
|
420
305
|
}
|
|
421
|
-
interface
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
data: any;
|
|
306
|
+
interface StandardMerkleTreeData<T extends any> extends MerkleTreeData<T> {
|
|
307
|
+
format: 'standard-v1';
|
|
308
|
+
leafEncoding: ValueType[];
|
|
425
309
|
}
|
|
426
|
-
declare class
|
|
427
|
-
readonly
|
|
428
|
-
readonly
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
310
|
+
declare class StandardMerkleTree extends MerkleTreeImpl<LeafData> {
|
|
311
|
+
protected readonly tree: HexString[];
|
|
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>;
|
|
436
319
|
}
|
|
437
320
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
321
|
+
type RequiredFields<T> = {
|
|
322
|
+
[K in keyof T]-?: T[K];
|
|
323
|
+
};
|
|
324
|
+
type RequiredKeys<T> = {
|
|
325
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
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
|
+
};
|
|
448
337
|
}
|
|
449
|
-
interface
|
|
450
|
-
|
|
338
|
+
interface DepositParams {
|
|
339
|
+
amount: Web3Number;
|
|
451
340
|
}
|
|
452
|
-
interface
|
|
453
|
-
pool_id: ContractAddr;
|
|
454
|
-
pool_name: string | undefined;
|
|
455
|
-
max_weight: number;
|
|
456
|
-
current_weight: number;
|
|
457
|
-
v_token: ContractAddr;
|
|
341
|
+
interface WithdrawParams {
|
|
458
342
|
amount: Web3Number;
|
|
459
|
-
usdValue: Web3Number;
|
|
460
|
-
APY: {
|
|
461
|
-
baseApy: number;
|
|
462
|
-
defiSpringApy: number;
|
|
463
|
-
netApy: number;
|
|
464
|
-
};
|
|
465
|
-
currentUtilization: number;
|
|
466
|
-
maxUtilization: number;
|
|
467
343
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
344
|
+
type GenerateCallFn<T> = (params: T) => Promise<ManageCall[]>;
|
|
345
|
+
type AdapterLeafType<T> = {
|
|
346
|
+
leaves: LeafData[];
|
|
347
|
+
callConstructor: GenerateCallFn<T>;
|
|
348
|
+
};
|
|
349
|
+
type LeafAdapterFn<T> = () => AdapterLeafType<T>;
|
|
350
|
+
declare enum APYType {
|
|
351
|
+
BASE = "base",
|
|
352
|
+
REWARD = "reward",
|
|
353
|
+
LST = "lst"
|
|
354
|
+
}
|
|
355
|
+
interface SupportedPosition {
|
|
356
|
+
asset: TokenInfo;
|
|
357
|
+
isDebt: boolean;
|
|
358
|
+
}
|
|
359
|
+
interface BaseAdapterConfig {
|
|
360
|
+
baseToken: TokenInfo;
|
|
361
|
+
supportedPositions: SupportedPosition[];
|
|
362
|
+
networkConfig: IConfig;
|
|
363
|
+
pricer: PricerBase;
|
|
364
|
+
vaultAllocator: ContractAddr;
|
|
365
|
+
vaultAddress: ContractAddr;
|
|
366
|
+
}
|
|
367
|
+
type PositionAPY = {
|
|
368
|
+
apy: number;
|
|
369
|
+
type: APYType;
|
|
370
|
+
};
|
|
371
|
+
type PositionInfo = {
|
|
372
|
+
tokenInfo: TokenInfo;
|
|
373
|
+
amount: Web3Number;
|
|
374
|
+
usdValue: number;
|
|
375
|
+
remarks: string;
|
|
376
|
+
apy: PositionAPY;
|
|
377
|
+
protocol: IProtocol;
|
|
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);
|
|
498
388
|
/**
|
|
499
|
-
*
|
|
500
|
-
* @param assets - Amount of assets to withdraw
|
|
501
|
-
* @param receiver - Address that will receive the withdrawn assets
|
|
502
|
-
* @param owner - Address that owns the strategy tokens
|
|
503
|
-
* @returns Populated contract call for withdrawal
|
|
389
|
+
* Loop through all supported positions and return amount, usd value, remarks and apy for each
|
|
504
390
|
*/
|
|
505
|
-
|
|
391
|
+
getPositions(): Promise<PositionInfo[]>;
|
|
506
392
|
/**
|
|
507
|
-
*
|
|
508
|
-
* @returns The deposit token supported by this strategy
|
|
393
|
+
* Implemented by child adapters to compute APY for a given supported position
|
|
509
394
|
*/
|
|
510
|
-
|
|
395
|
+
protected abstract getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
511
396
|
/**
|
|
512
|
-
*
|
|
513
|
-
* @returns Number of decimals (same as the underlying token)
|
|
397
|
+
* Implemented by child adapters to fetch amount for a given supported position
|
|
514
398
|
*/
|
|
515
|
-
|
|
399
|
+
protected abstract getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
516
400
|
/**
|
|
517
|
-
*
|
|
518
|
-
* @param
|
|
519
|
-
* @returns Object containing the amount in token units and USD value
|
|
401
|
+
* Implemented by child adapters to calculate maximum deposit positions
|
|
402
|
+
* @param amount Optional amount in baseToken to deposit
|
|
520
403
|
*/
|
|
521
|
-
|
|
522
|
-
tokenInfo: TokenInfo;
|
|
523
|
-
amount: Web3Number;
|
|
524
|
-
usdValue: number;
|
|
525
|
-
}>;
|
|
404
|
+
abstract maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
526
405
|
/**
|
|
527
|
-
*
|
|
528
|
-
* @returns Object containing the total amount in token units and USD value
|
|
406
|
+
* Implemented by child adapters to calculate maximum withdraw positions
|
|
529
407
|
*/
|
|
530
|
-
|
|
531
|
-
tokenInfo: TokenInfo;
|
|
532
|
-
amount: Web3Number;
|
|
533
|
-
usdValue: number;
|
|
534
|
-
}>;
|
|
535
|
-
static getAllPossibleVerifiedPools(asset: ContractAddr): Promise<any>;
|
|
536
|
-
getPoolInfo(p: PoolProps, pools: any[], vesuPositions: any[], totalAssets: Web3Number, isErrorPositionsAPI: boolean, isErrorPoolsAPI: boolean): Promise<{
|
|
537
|
-
pool_id: ContractAddr;
|
|
538
|
-
pool_name: any;
|
|
539
|
-
max_weight: number;
|
|
540
|
-
current_weight: number;
|
|
541
|
-
v_token: ContractAddr;
|
|
542
|
-
amount: Web3Number;
|
|
543
|
-
usdValue: Web3Number;
|
|
544
|
-
APY: {
|
|
545
|
-
baseApy: number;
|
|
546
|
-
defiSpringApy: number;
|
|
547
|
-
netApy: number;
|
|
548
|
-
};
|
|
549
|
-
currentUtilization: number;
|
|
550
|
-
maxUtilization: number;
|
|
551
|
-
}>;
|
|
408
|
+
abstract maxWithdraw(): Promise<PositionInfo>;
|
|
552
409
|
/**
|
|
553
|
-
*
|
|
554
|
-
* 1. Contract's allowed pools
|
|
555
|
-
* 2. Vesu positions API for current positions
|
|
556
|
-
* 3. Vesu pools API for APY and utilization data
|
|
557
|
-
*
|
|
558
|
-
* @returns {Promise<{
|
|
559
|
-
* data: Array<PoolInfoFull>,
|
|
560
|
-
* isErrorPositionsAPI: boolean
|
|
561
|
-
* }>} Object containing:
|
|
562
|
-
* - data: Array of pool information including IDs, weights, amounts, APYs and utilization
|
|
563
|
-
* - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
|
|
410
|
+
* Uses pricer to convert an amount of an asset to USD value
|
|
564
411
|
*/
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
amount: Web3Number;
|
|
573
|
-
usdValue: Web3Number;
|
|
574
|
-
APY: {
|
|
575
|
-
baseApy: number;
|
|
576
|
-
defiSpringApy: number;
|
|
577
|
-
netApy: number;
|
|
578
|
-
};
|
|
579
|
-
currentUtilization: number;
|
|
580
|
-
maxUtilization: number;
|
|
581
|
-
}[];
|
|
582
|
-
isErrorPositionsAPI: boolean;
|
|
583
|
-
isErrorPoolsAPI: boolean;
|
|
584
|
-
isError: boolean;
|
|
585
|
-
}>;
|
|
586
|
-
getVesuPools(retry?: number): Promise<{
|
|
587
|
-
pools: any[];
|
|
588
|
-
isErrorPoolsAPI: boolean;
|
|
589
|
-
}>;
|
|
412
|
+
protected getUSDValue(asset: TokenInfo, amount: Web3Number): Promise<number>;
|
|
413
|
+
protected constructSimpleLeafData(params: {
|
|
414
|
+
id: string;
|
|
415
|
+
target: ContractAddr;
|
|
416
|
+
method: string;
|
|
417
|
+
packedArguments: bigint[];
|
|
418
|
+
}, sanitizer?: ContractAddr): LeafData;
|
|
590
419
|
/**
|
|
591
|
-
*
|
|
592
|
-
|
|
420
|
+
* Implementor must provide target/method/packedArguments/sanitizer for deposit leaf construction
|
|
421
|
+
*/
|
|
422
|
+
protected abstract _getDepositLeaf(): {
|
|
423
|
+
target: ContractAddr;
|
|
424
|
+
method: string;
|
|
425
|
+
packedArguments: bigint[];
|
|
426
|
+
sanitizer: ContractAddr;
|
|
427
|
+
id: string;
|
|
428
|
+
}[];
|
|
429
|
+
/**
|
|
430
|
+
* Implementor must provide target/method/packedArguments/sanitizer for withdraw leaf construction
|
|
593
431
|
*/
|
|
594
|
-
|
|
432
|
+
protected abstract _getWithdrawLeaf(): {
|
|
433
|
+
target: ContractAddr;
|
|
434
|
+
method: string;
|
|
435
|
+
packedArguments: bigint[];
|
|
436
|
+
sanitizer: ContractAddr;
|
|
437
|
+
id: string;
|
|
438
|
+
}[];
|
|
595
439
|
/**
|
|
596
|
-
*
|
|
597
|
-
* @returns {Promise<number>} The weighted average APY across all pools
|
|
440
|
+
* Returns deposit leaf adapter using configured proof id
|
|
598
441
|
*/
|
|
599
|
-
|
|
442
|
+
getDepositLeaf(): AdapterLeafType<DepositParams>;
|
|
600
443
|
/**
|
|
601
|
-
*
|
|
602
|
-
* The algorithm:
|
|
603
|
-
* 1. Sorts pools by APY (highest first)
|
|
604
|
-
* 2. Calculates target amounts based on max weights
|
|
605
|
-
* 3. For each pool that needs more funds:
|
|
606
|
-
* - Takes funds from lowest APY pools that are over their target
|
|
607
|
-
* 4. Validates that total assets remain constant
|
|
608
|
-
*
|
|
609
|
-
* @returns {Promise<{
|
|
610
|
-
* changes: Change[],
|
|
611
|
-
* finalPools: PoolInfoFull[],
|
|
612
|
-
* isAnyPoolOverMaxWeight: boolean
|
|
613
|
-
* }>} Object containing:
|
|
614
|
-
* - changes: Array of position changes
|
|
615
|
-
* - finalPools: Array of pool information after rebalance
|
|
616
|
-
* @throws Error if rebalance is not possible while maintaining constraints
|
|
444
|
+
* Returns withdraw leaf adapter using configured proof id
|
|
617
445
|
*/
|
|
618
|
-
|
|
619
|
-
changes: never[];
|
|
620
|
-
finalPools: never[];
|
|
621
|
-
isAnyPoolOverMaxWeight?: undefined;
|
|
622
|
-
} | {
|
|
623
|
-
changes: Change[];
|
|
624
|
-
finalPools: PoolInfoFull[];
|
|
625
|
-
isAnyPoolOverMaxWeight: boolean;
|
|
626
|
-
}>;
|
|
446
|
+
getWithdrawLeaf(): AdapterLeafType<WithdrawParams>;
|
|
627
447
|
/**
|
|
628
|
-
*
|
|
629
|
-
* @param
|
|
630
|
-
* @returns Populated contract call for rebalance
|
|
448
|
+
* Implementor must provide deposit call
|
|
449
|
+
* @param params
|
|
631
450
|
*/
|
|
632
|
-
|
|
633
|
-
getInvestmentFlows(pools: PoolInfoFull[]): Promise<IInvestmentFlow[]>;
|
|
634
|
-
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
635
|
-
harvest(acc: Account): Promise<starknet.Call[]>;
|
|
451
|
+
abstract getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
636
452
|
/**
|
|
637
|
-
*
|
|
638
|
-
* @param
|
|
639
|
-
* @returns {Promise<Array<{ vToken: ContractAddr, fee: Web3Number }>>} Array of fees deducted in different vTokens
|
|
453
|
+
* Implementor must provide withdraw call
|
|
454
|
+
* @param params
|
|
640
455
|
*/
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
456
|
+
abstract getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
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>;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
interface FlashloanCallParams {
|
|
466
|
+
amount: Web3Number;
|
|
467
|
+
data: bigint[];
|
|
468
|
+
}
|
|
469
|
+
interface ApproveCallParams {
|
|
470
|
+
amount: Web3Number;
|
|
471
|
+
}
|
|
472
|
+
interface AvnuSwapCallParams {
|
|
473
|
+
props: SwapInfo;
|
|
474
|
+
}
|
|
475
|
+
interface CommonAdapterConfig {
|
|
476
|
+
id: string;
|
|
477
|
+
vaultAddress: ContractAddr;
|
|
478
|
+
vaultAllocator: ContractAddr;
|
|
479
|
+
manager: ContractAddr;
|
|
480
|
+
asset: ContractAddr;
|
|
481
|
+
}
|
|
482
|
+
declare class CommonAdapter {
|
|
483
|
+
config: CommonAdapterConfig;
|
|
484
|
+
constructor(config: CommonAdapterConfig);
|
|
485
|
+
protected constructSimpleLeafData(params: {
|
|
486
|
+
id: string;
|
|
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>;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
interface HarvestInfo {
|
|
507
|
+
rewardsContract: ContractAddr;
|
|
508
|
+
token: ContractAddr;
|
|
509
|
+
startDate: Date;
|
|
510
|
+
endDate: Date;
|
|
511
|
+
claim: {
|
|
512
|
+
id: number;
|
|
513
|
+
amount: Web3Number;
|
|
514
|
+
claimee: ContractAddr;
|
|
515
|
+
};
|
|
516
|
+
actualReward: Web3Number;
|
|
517
|
+
proof: string[];
|
|
645
518
|
}
|
|
646
|
-
/**
|
|
647
|
-
* Represents the Vesu Rebalance Strategies.
|
|
648
|
-
*/
|
|
649
|
-
declare const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[];
|
|
650
519
|
|
|
651
520
|
interface EkuboPoolKey {
|
|
652
521
|
token0: ContractAddr;
|
|
@@ -728,7 +597,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
728
597
|
* Calculates assets before and now in a given token of TVL per share to observe growth
|
|
729
598
|
* @returns {Promise<number>} The weighted average APY across all pools
|
|
730
599
|
*/
|
|
731
|
-
netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<
|
|
600
|
+
netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: '24h' | '7d' | '30d' | '3m'): Promise<APYInfo>;
|
|
732
601
|
getHarvestRewardShares(fromBlock: number, toBlock: number): Promise<Web3Number>;
|
|
733
602
|
balanceOf(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<Web3Number>;
|
|
734
603
|
getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<DualTokenInfo>;
|
|
@@ -783,7 +652,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
783
652
|
usdValue: number;
|
|
784
653
|
};
|
|
785
654
|
}>;
|
|
786
|
-
getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null, maxIterations?: number, priceRatioPrecision?: number
|
|
655
|
+
getSwapInfoToHandleUnused(considerRebalance?: boolean, newBounds?: EkuboBounds | null, maxIterations?: number, priceRatioPrecision?: number): Promise<SwapInfo>;
|
|
787
656
|
assertValidBounds(bounds: EkuboBounds): void;
|
|
788
657
|
assertValidAmounts(expectedAmounts: any, token0Bal: Web3Number, token1Bal: Web3Number): void;
|
|
789
658
|
getSwapParams(expectedAmounts: any, poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number): {
|
|
@@ -803,7 +672,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
803
672
|
* @returns {Promise<SwapInfo>}
|
|
804
673
|
*
|
|
805
674
|
*/
|
|
806
|
-
getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds, maxIterations?: number, priceRatioPrecision?: number
|
|
675
|
+
getSwapInfoGivenAmounts(poolKey: EkuboPoolKey, token0Bal: Web3Number, token1Bal: Web3Number, bounds: EkuboBounds, maxIterations?: number, priceRatioPrecision?: number): Promise<SwapInfo>;
|
|
807
676
|
/**
|
|
808
677
|
* Attempts to rebalance the vault by iteratively adjusting swap amounts if initial attempt fails.
|
|
809
678
|
* Uses binary search approach to find optimal swap amount.
|
|
@@ -814,16 +683,10 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
814
683
|
* @param retry - Current retry attempt number (default 0)
|
|
815
684
|
* @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
|
|
816
685
|
* @param isToken0Deficit - Whether token0 balance needs increasing (default true)
|
|
817
|
-
* @param MAX_RETRIES - Maximum number of retries (default 40)
|
|
818
|
-
* @param sameErrorCount - For certain errors, we just retry with same amount again. This is the count of such retries (default { count: 0, error: null })
|
|
819
|
-
* @param MAX_SAME_ERROR_COUNT - For certain errors, we just retry with same amount again. This limits such retries (default 10)
|
|
820
686
|
* @returns Array of contract calls needed for rebalancing
|
|
821
|
-
* @throws Error if max retries reached without successful rebalance
|
|
687
|
+
* @throws Error if max retries reached without successful rebalance
|
|
822
688
|
*/
|
|
823
|
-
rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint, MAX_RETRIES?: number
|
|
824
|
-
count: number;
|
|
825
|
-
error: null | string;
|
|
826
|
-
}, MAX_SAME_ERROR_COUNT?: number): Promise<Call[]>;
|
|
689
|
+
rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint, MAX_RETRIES?: number): Promise<Call[]>;
|
|
827
690
|
static tickToi129(tick: number): {
|
|
828
691
|
mag: number;
|
|
829
692
|
sign: number;
|
|
@@ -842,8 +705,7 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
842
705
|
amount0: Web3Number;
|
|
843
706
|
amount1: Web3Number;
|
|
844
707
|
}>;
|
|
845
|
-
|
|
846
|
-
harvest(acc: Account, maxIterations?: number, priceRatioPrecision?: number, minRewardAmount?: Web3Number): Promise<Call[]>;
|
|
708
|
+
harvest(acc: Account, maxIterations?: number, priceRatioPrecision?: number): Promise<Call[]>;
|
|
847
709
|
/**
|
|
848
710
|
* @description This funciton requires atleast one of the pool tokens to be reward token
|
|
849
711
|
* i.e. STRK.
|
|
@@ -892,175 +754,9 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
892
754
|
*/
|
|
893
755
|
declare const EkuboCLVaultStrategies: IStrategyMetadata<CLVaultStrategySettings>[];
|
|
894
756
|
|
|
895
|
-
interface
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
targetHfBps: number;
|
|
899
|
-
feeBps: number;
|
|
900
|
-
}
|
|
901
|
-
declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
902
|
-
readonly address: ContractAddr;
|
|
903
|
-
readonly metadata: IStrategyMetadata<SenseiVaultSettings>;
|
|
904
|
-
readonly pricer: PricerBase;
|
|
905
|
-
readonly contract: Contract;
|
|
906
|
-
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>);
|
|
907
|
-
getUserTVL(user: ContractAddr): Promise<SingleTokenInfo>;
|
|
908
|
-
getTVL(): Promise<SingleTokenInfo>;
|
|
909
|
-
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
910
|
-
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
911
|
-
getPositionInfo(): Promise<{
|
|
912
|
-
collateralXSTRK: Web3Number;
|
|
913
|
-
collateralUSDValue: Web3Number;
|
|
914
|
-
debtSTRK: Web3Number;
|
|
915
|
-
debtUSDValue: Web3Number;
|
|
916
|
-
xSTRKPrice: number;
|
|
917
|
-
collateralInSTRK: number;
|
|
918
|
-
}>;
|
|
919
|
-
getSecondaryTokenPriceRelativeToMain(retry?: number): Promise<number>;
|
|
920
|
-
getSettings: () => Promise<starknet.CallResult>;
|
|
921
|
-
}
|
|
922
|
-
declare const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[];
|
|
923
|
-
|
|
924
|
-
interface LeveledLogMethod {
|
|
925
|
-
(message: string, ...meta: any[]): void;
|
|
926
|
-
(message: any): void;
|
|
927
|
-
}
|
|
928
|
-
interface MyLogger {
|
|
929
|
-
error: LeveledLogMethod;
|
|
930
|
-
warn: LeveledLogMethod;
|
|
931
|
-
info: LeveledLogMethod;
|
|
932
|
-
verbose: LeveledLogMethod;
|
|
933
|
-
debug: LeveledLogMethod;
|
|
934
|
-
}
|
|
935
|
-
declare const logger: MyLogger;
|
|
936
|
-
|
|
937
|
-
interface LeafData {
|
|
938
|
-
id: bigint;
|
|
939
|
-
readableId: string;
|
|
940
|
-
data: bigint[];
|
|
941
|
-
}
|
|
942
|
-
interface StandardMerkleTreeData<T extends any> extends MerkleTreeData<T> {
|
|
943
|
-
format: 'standard-v1';
|
|
944
|
-
leafEncoding: ValueType[];
|
|
945
|
-
}
|
|
946
|
-
declare class StandardMerkleTree extends MerkleTreeImpl<LeafData> {
|
|
947
|
-
protected readonly tree: HexString[];
|
|
948
|
-
protected readonly values: StandardMerkleTreeData<LeafData>['values'];
|
|
949
|
-
protected readonly leafEncoding: ValueType[];
|
|
950
|
-
protected constructor(tree: HexString[], values: StandardMerkleTreeData<LeafData>['values'], leafEncoding: ValueType[]);
|
|
951
|
-
static of(values: LeafData[], leafEncoding?: ValueType[], options?: MerkleTreeOptions): StandardMerkleTree;
|
|
952
|
-
static verify<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], leaf: T, proof: BytesLike[]): boolean;
|
|
953
|
-
static verifyMultiProof<T extends any[]>(root: BytesLike, leafEncoding: ValueType[], multiproof: MultiProof<BytesLike, T>): boolean;
|
|
954
|
-
dump(): StandardMerkleTreeData<LeafData>;
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
type RequiredFields<T> = {
|
|
958
|
-
[K in keyof T]-?: T[K];
|
|
959
|
-
};
|
|
960
|
-
type RequiredKeys<T> = {
|
|
961
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
962
|
-
}[keyof T];
|
|
963
|
-
declare function assert(condition: boolean, message: string): void;
|
|
964
|
-
declare function getTrovesEndpoint(): string;
|
|
965
|
-
|
|
966
|
-
interface ManageCall {
|
|
967
|
-
sanitizer: ContractAddr;
|
|
968
|
-
call: {
|
|
969
|
-
contractAddress: ContractAddr;
|
|
970
|
-
selector: string;
|
|
971
|
-
calldata: bigint[];
|
|
972
|
-
};
|
|
973
|
-
}
|
|
974
|
-
type GenerateCallFn<T> = (params: T) => ManageCall;
|
|
975
|
-
type AdapterLeafType<T> = {
|
|
976
|
-
leaf: LeafData;
|
|
977
|
-
callConstructor: GenerateCallFn<T>;
|
|
978
|
-
};
|
|
979
|
-
type LeafAdapterFn<T> = () => AdapterLeafType<T>;
|
|
980
|
-
declare enum APYType {
|
|
981
|
-
BASE = "base",
|
|
982
|
-
REWARD = "reward",
|
|
983
|
-
LST = "lst"
|
|
984
|
-
}
|
|
985
|
-
interface SupportedPosition {
|
|
986
|
-
asset: TokenInfo;
|
|
987
|
-
isDebt: boolean;
|
|
988
|
-
}
|
|
989
|
-
interface BaseAdapterConfig {
|
|
990
|
-
baseToken: TokenInfo;
|
|
991
|
-
supportedPositions: SupportedPosition[];
|
|
992
|
-
networkConfig: IConfig;
|
|
993
|
-
pricer: PricerBase;
|
|
994
|
-
vaultAllocator: ContractAddr;
|
|
995
|
-
vaultAddress: ContractAddr;
|
|
996
|
-
}
|
|
997
|
-
type PositionAPY = {
|
|
998
|
-
apy: number;
|
|
999
|
-
type: APYType;
|
|
1000
|
-
};
|
|
1001
|
-
type PositionInfo = {
|
|
1002
|
-
amount: Web3Number;
|
|
1003
|
-
usdValue: number;
|
|
1004
|
-
remarks?: string;
|
|
1005
|
-
apy: PositionAPY;
|
|
1006
|
-
};
|
|
1007
|
-
declare abstract class BaseAdapter extends CacheClass {
|
|
1008
|
-
constructor();
|
|
1009
|
-
protected constructSimpleLeafData(params: {
|
|
1010
|
-
id: string;
|
|
1011
|
-
target: ContractAddr;
|
|
1012
|
-
method: string;
|
|
1013
|
-
packedArguments: bigint[];
|
|
1014
|
-
}, sanitizer?: ContractAddr): LeafData;
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
interface FlashloanCallParams {
|
|
1018
|
-
amount: Web3Number;
|
|
1019
|
-
data: bigint[];
|
|
1020
|
-
}
|
|
1021
|
-
interface ApproveCallParams {
|
|
1022
|
-
amount: Web3Number;
|
|
1023
|
-
}
|
|
1024
|
-
interface AvnuSwapCallParams {
|
|
1025
|
-
props: SwapInfo;
|
|
1026
|
-
}
|
|
1027
|
-
interface CommonAdapterConfig {
|
|
1028
|
-
id: string;
|
|
1029
|
-
vaultAddress: ContractAddr;
|
|
1030
|
-
vaultAllocator: ContractAddr;
|
|
1031
|
-
manager: ContractAddr;
|
|
1032
|
-
asset: ContractAddr;
|
|
1033
|
-
}
|
|
1034
|
-
declare class CommonAdapter extends BaseAdapter {
|
|
1035
|
-
config: CommonAdapterConfig;
|
|
1036
|
-
constructor(config: CommonAdapterConfig);
|
|
1037
|
-
getFlashloanAdapter(): AdapterLeafType<FlashloanCallParams>;
|
|
1038
|
-
getFlashloanCall(params: FlashloanCallParams): ManageCall;
|
|
1039
|
-
getApproveAdapter(token: ContractAddr, spender: ContractAddr, id: string): () => AdapterLeafType<ApproveCallParams>;
|
|
1040
|
-
getApproveCall(token: ContractAddr, spender: ContractAddr): (params: ApproveCallParams) => {
|
|
1041
|
-
sanitizer: ContractAddr;
|
|
1042
|
-
call: {
|
|
1043
|
-
contractAddress: ContractAddr;
|
|
1044
|
-
selector: string;
|
|
1045
|
-
calldata: bigint[];
|
|
1046
|
-
};
|
|
1047
|
-
};
|
|
1048
|
-
getBringLiquidityAdapter(id: string): () => AdapterLeafType<ApproveCallParams>;
|
|
1049
|
-
getBringLiquidityCall(): (params: ApproveCallParams) => {
|
|
1050
|
-
sanitizer: ContractAddr;
|
|
1051
|
-
call: {
|
|
1052
|
-
contractAddress: ContractAddr;
|
|
1053
|
-
selector: string;
|
|
1054
|
-
calldata: bigint[];
|
|
1055
|
-
};
|
|
1056
|
-
};
|
|
1057
|
-
getAvnuAdapter(fromToken: ContractAddr, toToken: ContractAddr, id: string, isMiddleware: boolean): () => AdapterLeafType<AvnuSwapCallParams>;
|
|
1058
|
-
getAvnuCall(fromToken: ContractAddr, toToken: ContractAddr, isMiddleware: boolean): GenerateCallFn<AvnuSwapCallParams>;
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
interface VesuPoolsInfo {
|
|
1062
|
-
pools: any[];
|
|
1063
|
-
isErrorPoolsAPI: boolean;
|
|
757
|
+
interface VesuPoolsInfo {
|
|
758
|
+
pools: any[];
|
|
759
|
+
isErrorPoolsAPI: boolean;
|
|
1064
760
|
}
|
|
1065
761
|
declare enum VesuAmountType {
|
|
1066
762
|
Delta = 0,
|
|
@@ -1155,6 +851,7 @@ declare const VesuPools: {
|
|
|
1155
851
|
Genesis: ContractAddr;
|
|
1156
852
|
Re7xSTRK: ContractAddr;
|
|
1157
853
|
Re7xBTC: ContractAddr;
|
|
854
|
+
Re7USDCPrime: ContractAddr;
|
|
1158
855
|
};
|
|
1159
856
|
declare const extensionMap: {
|
|
1160
857
|
[key: string]: ContractAddr;
|
|
@@ -1163,44 +860,14 @@ declare function getVesuSingletonAddress(vesuPool: ContractAddr): {
|
|
|
1163
860
|
addr: ContractAddr;
|
|
1164
861
|
isV2: boolean;
|
|
1165
862
|
};
|
|
1166
|
-
declare class VesuAdapter extends
|
|
863
|
+
declare class VesuAdapter extends CacheClass {
|
|
1167
864
|
VESU_MULTIPLY_V1: ContractAddr;
|
|
1168
865
|
VESU_MULTIPLY: ContractAddr;
|
|
1169
866
|
config: VesuAdapterConfig;
|
|
1170
867
|
networkConfig: IConfig | undefined;
|
|
1171
868
|
pricer: PricerBase | undefined;
|
|
1172
869
|
constructor(config: VesuAdapterConfig);
|
|
1173
|
-
getModifyPosition: () => AdapterLeafType<VesuModifyPositionCallParams>;
|
|
1174
|
-
static getDefaultModifyPositionCallParams(params: {
|
|
1175
|
-
collateralAmount: Web3Number;
|
|
1176
|
-
isAddCollateral: boolean;
|
|
1177
|
-
debtAmount: Web3Number;
|
|
1178
|
-
isBorrow: boolean;
|
|
1179
|
-
}): {
|
|
1180
|
-
collateralAmount: {
|
|
1181
|
-
amount_type: VesuAmountType;
|
|
1182
|
-
denomination: VesuAmountDenomination;
|
|
1183
|
-
value: {
|
|
1184
|
-
abs: Web3Number;
|
|
1185
|
-
is_negative: boolean;
|
|
1186
|
-
};
|
|
1187
|
-
};
|
|
1188
|
-
debtAmount: {
|
|
1189
|
-
amount_type: VesuAmountType;
|
|
1190
|
-
denomination: VesuAmountDenomination;
|
|
1191
|
-
value: {
|
|
1192
|
-
abs: Web3Number;
|
|
1193
|
-
is_negative: boolean;
|
|
1194
|
-
};
|
|
1195
|
-
};
|
|
1196
|
-
};
|
|
1197
|
-
getModifyPositionCall: (params: VesuModifyPositionCallParams) => ManageCall;
|
|
1198
|
-
getMultiplyAdapter: (id: string) => LeafAdapterFn<VesuMultiplyCallParams>;
|
|
1199
|
-
getMultiplyCall: (params: VesuMultiplyCallParams) => ManageCall;
|
|
1200
|
-
getVesuModifyDelegationAdapter: (id: string) => LeafAdapterFn<VesuModifyDelegationCallParams>;
|
|
1201
870
|
getVesuModifyDelegationCall: (params: VesuModifyDelegationCallParams) => ManageCall;
|
|
1202
|
-
getDefispringRewardsAdapter: (id: string) => () => AdapterLeafType<VesuDefiSpringRewardsCallParams>;
|
|
1203
|
-
getDefiSpringClaimCall: () => GenerateCallFn<VesuDefiSpringRewardsCallParams>;
|
|
1204
871
|
formatAmountTypeEnum(amountType: VesuAmountType): CairoCustomEnum;
|
|
1205
872
|
formatAmountDenominationEnum(denomination: VesuAmountDenomination): CairoCustomEnum;
|
|
1206
873
|
getVesuSingletonContract(config: IConfig, poolId: ContractAddr): {
|
|
@@ -1239,40 +906,1150 @@ declare class VesuAdapter extends BaseAdapter {
|
|
|
1239
906
|
getMaxUtilizationGivenRatePerSecond(interestRateConfig: InterestRateConfig, ratePerSecond: bigint, timeDelta: bigint, last_full_utilization_rate: bigint): bigint;
|
|
1240
907
|
}
|
|
1241
908
|
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
declare
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
909
|
+
interface VesuSupplyOnlyAdapterConfig extends BaseAdapterConfig {
|
|
910
|
+
vTokenContract: ContractAddr;
|
|
911
|
+
}
|
|
912
|
+
declare class VesuSupplyOnlyAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
913
|
+
readonly config: VesuSupplyOnlyAdapterConfig;
|
|
914
|
+
readonly tokenMarketData: TokenMarketData;
|
|
915
|
+
constructor(config: VesuSupplyOnlyAdapterConfig);
|
|
916
|
+
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
917
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
918
|
+
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
919
|
+
maxWithdraw(): Promise<PositionInfo>;
|
|
920
|
+
protected _getDepositLeaf(): {
|
|
921
|
+
target: ContractAddr;
|
|
922
|
+
method: string;
|
|
923
|
+
packedArguments: bigint[];
|
|
924
|
+
sanitizer: ContractAddr;
|
|
925
|
+
id: string;
|
|
926
|
+
}[];
|
|
927
|
+
protected _getWithdrawLeaf(): {
|
|
928
|
+
target: ContractAddr;
|
|
929
|
+
method: string;
|
|
930
|
+
packedArguments: bigint[];
|
|
931
|
+
sanitizer: ContractAddr;
|
|
1265
932
|
id: string;
|
|
1266
|
-
adapter: BaseAdapter;
|
|
1267
933
|
}[];
|
|
934
|
+
getDepositAdapter(): AdapterLeafType<DepositParams>;
|
|
935
|
+
getWithdrawAdapter(): AdapterLeafType<WithdrawParams>;
|
|
936
|
+
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
937
|
+
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
938
|
+
getHealthFactor(): Promise<number>;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
interface VesuMultiplyAdapterConfig extends BaseAdapterConfig {
|
|
942
|
+
poolId: ContractAddr;
|
|
943
|
+
collateral: TokenInfo;
|
|
944
|
+
debt: TokenInfo;
|
|
1268
945
|
targetHealthFactor: number;
|
|
1269
946
|
minHealthFactor: number;
|
|
947
|
+
quoteAmountToFetchPrice: Web3Number;
|
|
948
|
+
}
|
|
949
|
+
declare class VesuMultiplyAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
950
|
+
readonly config: VesuMultiplyAdapterConfig;
|
|
951
|
+
readonly vesuAdapter: VesuAdapter;
|
|
952
|
+
readonly tokenMarketData: TokenMarketData;
|
|
953
|
+
constructor(config: VesuMultiplyAdapterConfig);
|
|
954
|
+
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
955
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
956
|
+
maxBorrowableAPY(): Promise<number>;
|
|
957
|
+
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
958
|
+
maxWithdraw(): Promise<PositionInfo>;
|
|
959
|
+
protected _getDepositLeaf(): {
|
|
960
|
+
target: ContractAddr;
|
|
961
|
+
method: string;
|
|
962
|
+
packedArguments: bigint[];
|
|
963
|
+
sanitizer: ContractAddr;
|
|
964
|
+
id: string;
|
|
965
|
+
}[];
|
|
966
|
+
protected _getWithdrawLeaf(): {
|
|
967
|
+
target: ContractAddr;
|
|
968
|
+
method: string;
|
|
969
|
+
packedArguments: bigint[];
|
|
970
|
+
sanitizer: ContractAddr;
|
|
971
|
+
id: string;
|
|
972
|
+
}[];
|
|
973
|
+
getDepositAdapter(): AdapterLeafType<DepositParams>;
|
|
974
|
+
getWithdrawAdapter(): AdapterLeafType<WithdrawParams>;
|
|
975
|
+
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
976
|
+
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
977
|
+
private getMultiplyCallCalldata;
|
|
978
|
+
private getLeverParams;
|
|
979
|
+
private getWithdrawalCalldata;
|
|
980
|
+
formatMultiplyParams(isIncrease: boolean, params: IncreaseLeverParams | DecreaseLeverParams): {
|
|
981
|
+
action: CairoCustomEnum;
|
|
982
|
+
};
|
|
983
|
+
getHealthFactor(): Promise<number>;
|
|
984
|
+
getNetAPY(): Promise<number>;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* TypeScript type definitions for Extended Exchange API
|
|
989
|
+
* Based on Python SDK models from x10.perpetual
|
|
990
|
+
*/
|
|
991
|
+
declare enum OrderSide {
|
|
992
|
+
BUY = "BUY",
|
|
993
|
+
SELL = "SELL"
|
|
994
|
+
}
|
|
995
|
+
declare enum TimeInForce {
|
|
996
|
+
GTT = "GTT",
|
|
997
|
+
IOC = "IOC",
|
|
998
|
+
FOK = "FOK"
|
|
999
|
+
}
|
|
1000
|
+
declare enum OrderType {
|
|
1001
|
+
LIMIT = "LIMIT",
|
|
1002
|
+
CONDITIONAL = "CONDITIONAL",
|
|
1003
|
+
MARKET = "MARKET",
|
|
1004
|
+
TPSL = "TPSL"
|
|
1005
|
+
}
|
|
1006
|
+
declare enum OrderStatus {
|
|
1007
|
+
UNKNOWN = "UNKNOWN",
|
|
1008
|
+
NEW = "NEW",
|
|
1009
|
+
UNTRIGGERED = "UNTRIGGERED",
|
|
1010
|
+
PARTIALLY_FILLED = "PARTIALLY_FILLED",
|
|
1011
|
+
FILLED = "FILLED",
|
|
1012
|
+
CANCELLED = "CANCELLED",
|
|
1013
|
+
EXPIRED = "EXPIRED",
|
|
1014
|
+
REJECTED = "REJECTED"
|
|
1015
|
+
}
|
|
1016
|
+
declare enum OrderStatusReason {
|
|
1017
|
+
UNKNOWN = "UNKNOWN",
|
|
1018
|
+
NONE = "NONE",
|
|
1019
|
+
UNKNOWN_MARKET = "UNKNOWN_MARKET",
|
|
1020
|
+
DISABLED_MARKET = "DISABLED_MARKET",
|
|
1021
|
+
NOT_ENOUGH_FUNDS = "NOT_ENOUGH_FUNDS",
|
|
1022
|
+
NO_LIQUIDITY = "NO_LIQUIDITY",
|
|
1023
|
+
INVALID_FEE = "INVALID_FEE",
|
|
1024
|
+
INVALID_QTY = "INVALID_QTY",
|
|
1025
|
+
INVALID_PRICE = "INVALID_PRICE",
|
|
1026
|
+
INVALID_VALUE = "INVALID_VALUE",
|
|
1027
|
+
UNKNOWN_ACCOUNT = "UNKNOWN_ACCOUNT",
|
|
1028
|
+
SELF_TRADE_PROTECTION = "SELF_TRADE_PROTECTION",
|
|
1029
|
+
POST_ONLY_FAILED = "POST_ONLY_FAILED",
|
|
1030
|
+
REDUCE_ONLY_FAILED = "REDUCE_ONLY_FAILED",
|
|
1031
|
+
INVALID_EXPIRE_TIME = "INVALID_EXPIRE_TIME",
|
|
1032
|
+
POSITION_TPSL_CONFLICT = "POSITION_TPSL_CONFLICT",
|
|
1033
|
+
INVALID_LEVERAGE = "INVALID_LEVERAGE",
|
|
1034
|
+
PREV_ORDER_NOT_FOUND = "PREV_ORDER_NOT_FOUND",
|
|
1035
|
+
PREV_ORDER_TRIGGERED = "PREV_ORDER_TRIGGERED",
|
|
1036
|
+
TPSL_OTHER_SIDE_FILLED = "TPSL_OTHER_SIDE_FILLED",
|
|
1037
|
+
PREV_ORDER_CONFLICT = "PREV_ORDER_CONFLICT",
|
|
1038
|
+
ORDER_REPLACED = "ORDER_REPLACED",
|
|
1039
|
+
POST_ONLY_MODE = "POST_ONLY_MODE",
|
|
1040
|
+
REDUCE_ONLY_MODE = "REDUCE_ONLY_MODE",
|
|
1041
|
+
TRADING_OFF_MODE = "TRADING_OFF_MODE"
|
|
1042
|
+
}
|
|
1043
|
+
declare enum PositionSide {
|
|
1044
|
+
LONG = "LONG",
|
|
1045
|
+
SHORT = "SHORT"
|
|
1046
|
+
}
|
|
1047
|
+
declare enum ExitType {
|
|
1048
|
+
TRADE = "TRADE",
|
|
1049
|
+
LIQUIDATION = "LIQUIDATION",
|
|
1050
|
+
ADL = "ADL"
|
|
1051
|
+
}
|
|
1052
|
+
declare enum AssetOperationType {
|
|
1053
|
+
DEPOSIT = "DEPOSIT",
|
|
1054
|
+
WITHDRAWAL = "WITHDRAWAL",
|
|
1055
|
+
TRANSFER = "TRANSFER"
|
|
1056
|
+
}
|
|
1057
|
+
declare enum AssetOperationStatus {
|
|
1058
|
+
PENDING = "PENDING",
|
|
1059
|
+
COMPLETED = "COMPLETED",
|
|
1060
|
+
FAILED = "FAILED"
|
|
1061
|
+
}
|
|
1062
|
+
interface SettlementSignature {
|
|
1063
|
+
r: string;
|
|
1064
|
+
s: string;
|
|
1065
|
+
}
|
|
1066
|
+
interface StarkSettlement {
|
|
1067
|
+
signature: SettlementSignature;
|
|
1068
|
+
stark_key: string;
|
|
1069
|
+
collateral_position: string;
|
|
1070
|
+
}
|
|
1071
|
+
interface StarkDebuggingOrderAmounts {
|
|
1072
|
+
collateral_amount: string;
|
|
1073
|
+
fee_amount: string;
|
|
1074
|
+
synthetic_amount: string;
|
|
1075
|
+
}
|
|
1076
|
+
interface PlacedOrder {
|
|
1077
|
+
id: number;
|
|
1078
|
+
external_id: string;
|
|
1079
|
+
}
|
|
1080
|
+
interface OpenOrder {
|
|
1081
|
+
id: number;
|
|
1082
|
+
account_id: number;
|
|
1083
|
+
external_id: string;
|
|
1084
|
+
market: string;
|
|
1085
|
+
type: OrderType;
|
|
1086
|
+
side: OrderSide;
|
|
1087
|
+
status: OrderStatus;
|
|
1088
|
+
status_reason?: OrderStatusReason;
|
|
1089
|
+
price: string;
|
|
1090
|
+
average_price?: string;
|
|
1091
|
+
qty: string;
|
|
1092
|
+
filled_qty?: string;
|
|
1093
|
+
reduce_only: boolean;
|
|
1094
|
+
post_only: boolean;
|
|
1095
|
+
payed_fee?: string;
|
|
1096
|
+
created_time: number;
|
|
1097
|
+
updated_time: number;
|
|
1098
|
+
expiry_time?: number;
|
|
1099
|
+
}
|
|
1100
|
+
interface Position {
|
|
1101
|
+
id: number;
|
|
1102
|
+
accountId: number;
|
|
1103
|
+
market: string;
|
|
1104
|
+
side: PositionSide;
|
|
1105
|
+
leverage: string;
|
|
1106
|
+
size: string;
|
|
1107
|
+
value: string;
|
|
1108
|
+
openPrice: string;
|
|
1109
|
+
markPrice: string;
|
|
1110
|
+
liquidationPrice?: string;
|
|
1111
|
+
unrealisedPnl: string;
|
|
1112
|
+
realisedPnl: string;
|
|
1113
|
+
tpPrice?: string;
|
|
1114
|
+
slPrice?: string;
|
|
1115
|
+
adl?: number;
|
|
1116
|
+
createdAt: number;
|
|
1117
|
+
updatedAt: number;
|
|
1118
|
+
}
|
|
1119
|
+
interface PositionHistory {
|
|
1120
|
+
id: number;
|
|
1121
|
+
account_id: number;
|
|
1122
|
+
market: string;
|
|
1123
|
+
side: PositionSide;
|
|
1124
|
+
leverage: string;
|
|
1125
|
+
size: string;
|
|
1126
|
+
open_price: string;
|
|
1127
|
+
exit_type?: ExitType;
|
|
1128
|
+
exit_price?: string;
|
|
1129
|
+
realised_pnl: string;
|
|
1130
|
+
created_time: number;
|
|
1131
|
+
closed_time?: number;
|
|
1132
|
+
}
|
|
1133
|
+
interface Balance {
|
|
1134
|
+
collateral_name: string;
|
|
1135
|
+
balance: string;
|
|
1136
|
+
equity: string;
|
|
1137
|
+
availableForTrade: string;
|
|
1138
|
+
availableForWithdrawal: string;
|
|
1139
|
+
unrealisedPnl: string;
|
|
1140
|
+
initialMargin: string;
|
|
1141
|
+
marginRatio: string;
|
|
1142
|
+
updatedTime: number;
|
|
1143
|
+
}
|
|
1144
|
+
interface RiskFactorConfig {
|
|
1145
|
+
upper_bound: string;
|
|
1146
|
+
risk_factor: string;
|
|
1147
|
+
}
|
|
1148
|
+
interface MarketStats {
|
|
1149
|
+
daily_volume: string;
|
|
1150
|
+
daily_volume_base: string;
|
|
1151
|
+
daily_price_change: string;
|
|
1152
|
+
daily_low: string;
|
|
1153
|
+
daily_high: string;
|
|
1154
|
+
last_price: string;
|
|
1155
|
+
ask_price: string;
|
|
1156
|
+
bid_price: string;
|
|
1157
|
+
mark_price: string;
|
|
1158
|
+
index_price: string;
|
|
1159
|
+
funding_rate: string;
|
|
1160
|
+
next_funding_rate: number;
|
|
1161
|
+
open_interest: string;
|
|
1162
|
+
open_interest_base: string;
|
|
1163
|
+
}
|
|
1164
|
+
interface TradingConfig {
|
|
1165
|
+
min_order_size: string;
|
|
1166
|
+
min_order_size_change: string;
|
|
1167
|
+
min_price_change: string;
|
|
1168
|
+
max_market_order_value: string;
|
|
1169
|
+
max_limit_order_value: string;
|
|
1170
|
+
max_position_value: string;
|
|
1171
|
+
max_leverage: string;
|
|
1172
|
+
max_num_orders: number;
|
|
1173
|
+
limit_price_cap: string;
|
|
1174
|
+
limit_price_floor: string;
|
|
1175
|
+
risk_factor_config: RiskFactorConfig[];
|
|
1176
|
+
}
|
|
1177
|
+
interface L2Config {
|
|
1178
|
+
type: string;
|
|
1179
|
+
collateral_id: string;
|
|
1180
|
+
collateral_resolution: number;
|
|
1181
|
+
synthetic_id: string;
|
|
1182
|
+
synthetic_resolution: number;
|
|
1183
|
+
}
|
|
1184
|
+
interface Market {
|
|
1185
|
+
name: string;
|
|
1186
|
+
asset_name: string;
|
|
1187
|
+
asset_precision: number;
|
|
1188
|
+
collateral_asset_name: string;
|
|
1189
|
+
collateral_asset_precision: number;
|
|
1190
|
+
active: boolean;
|
|
1191
|
+
market_stats: MarketStats;
|
|
1192
|
+
trading_config: TradingConfig;
|
|
1193
|
+
l2_config: L2Config;
|
|
1194
|
+
}
|
|
1195
|
+
interface AssetOperation {
|
|
1196
|
+
id: number;
|
|
1197
|
+
type: AssetOperationType;
|
|
1198
|
+
status: AssetOperationStatus;
|
|
1199
|
+
amount: string;
|
|
1200
|
+
asset: string;
|
|
1201
|
+
created_time: number;
|
|
1202
|
+
updated_time: number;
|
|
1203
|
+
description?: string;
|
|
1204
|
+
transactionHash?: string;
|
|
1205
|
+
}
|
|
1206
|
+
interface CreateOrderRequest {
|
|
1207
|
+
market_name: string;
|
|
1208
|
+
amount: string;
|
|
1209
|
+
price: string;
|
|
1210
|
+
side: OrderSide;
|
|
1211
|
+
post_only?: boolean;
|
|
1212
|
+
previous_order_id?: number;
|
|
1213
|
+
external_id?: string;
|
|
1214
|
+
time_in_force?: TimeInForce;
|
|
1215
|
+
}
|
|
1216
|
+
interface WithdrawRequest {
|
|
1217
|
+
amount: string;
|
|
1218
|
+
asset?: string;
|
|
1219
|
+
}
|
|
1220
|
+
interface SignedWithdrawRequest {
|
|
1221
|
+
recipient: string;
|
|
1222
|
+
position_id: number;
|
|
1223
|
+
amount: number;
|
|
1224
|
+
expiration: number;
|
|
1225
|
+
salt: number;
|
|
1226
|
+
}
|
|
1227
|
+
interface CancelOrderRequest {
|
|
1228
|
+
order_id: number;
|
|
1229
|
+
}
|
|
1230
|
+
interface ApiResponse<T> {
|
|
1231
|
+
success: boolean;
|
|
1232
|
+
message: string;
|
|
1233
|
+
data: T;
|
|
1234
|
+
}
|
|
1235
|
+
interface ExtendedApiResponse<T> {
|
|
1236
|
+
status: 'OK' | 'ERROR';
|
|
1237
|
+
message: string;
|
|
1238
|
+
data: T;
|
|
1239
|
+
}
|
|
1240
|
+
interface ExtendedWrapperConfig {
|
|
1241
|
+
baseUrl: string;
|
|
1242
|
+
apiKey?: string;
|
|
1243
|
+
timeout?: number;
|
|
1244
|
+
retries?: number;
|
|
1245
|
+
}
|
|
1246
|
+
interface UpdateLeverageRequest {
|
|
1247
|
+
leverage: string;
|
|
1248
|
+
market: string;
|
|
1249
|
+
}
|
|
1250
|
+
interface FundingRate {
|
|
1251
|
+
m: string;
|
|
1252
|
+
f: string;
|
|
1253
|
+
t: number;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* ExtendedWrapper - TypeScript wrapper for Extended Exchange API
|
|
1258
|
+
* Provides a clean interface to interact with the Extended Exchange trading API
|
|
1259
|
+
*/
|
|
1260
|
+
|
|
1261
|
+
declare class ExtendedWrapper {
|
|
1262
|
+
private baseUrl;
|
|
1263
|
+
private apiKey?;
|
|
1264
|
+
private timeout;
|
|
1265
|
+
private retries;
|
|
1266
|
+
constructor(config: ExtendedWrapperConfig);
|
|
1267
|
+
/**
|
|
1268
|
+
* Make HTTP request with retry logic and error handling
|
|
1269
|
+
*/
|
|
1270
|
+
private makeRequest;
|
|
1271
|
+
/**
|
|
1272
|
+
* Create a new order on Extended Exchange
|
|
1273
|
+
*/
|
|
1274
|
+
createOrder(request: CreateOrderRequest): Promise<ExtendedApiResponse<PlacedOrder>>;
|
|
1275
|
+
/**
|
|
1276
|
+
* Get all markets
|
|
1277
|
+
*/
|
|
1278
|
+
getMarkets(marketNames?: string): Promise<ExtendedApiResponse<Market[]>>;
|
|
1279
|
+
/**
|
|
1280
|
+
*
|
|
1281
|
+
* @param orderId - The ID of the order to get
|
|
1282
|
+
* @returns The order
|
|
1283
|
+
*/
|
|
1284
|
+
getOrderByOrderId(orderId: string): Promise<ExtendedApiResponse<OpenOrder>>;
|
|
1285
|
+
/**
|
|
1286
|
+
* Get market statistics for a specific market
|
|
1287
|
+
*/
|
|
1288
|
+
getMarketStatistics(marketName: string): Promise<ExtendedApiResponse<MarketStats>>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Get current trading positions
|
|
1291
|
+
*/
|
|
1292
|
+
getPositions(marketNames?: string): Promise<ExtendedApiResponse<Position[]>>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Get account balance and holdings
|
|
1295
|
+
*/
|
|
1296
|
+
getHoldings(): Promise<ExtendedApiResponse<Balance>>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Initiate a withdrawal from Extended Exchange
|
|
1299
|
+
*/
|
|
1300
|
+
withdraw(request: WithdrawRequest): Promise<ExtendedApiResponse<number>>;
|
|
1301
|
+
/**
|
|
1302
|
+
* Create and sign a withdrawal request hash
|
|
1303
|
+
*/
|
|
1304
|
+
signWithdrawalRequest(request: SignedWithdrawRequest): Promise<ExtendedApiResponse<{
|
|
1305
|
+
withdraw_request_hash: string;
|
|
1306
|
+
signature: {
|
|
1307
|
+
r: string;
|
|
1308
|
+
s: string;
|
|
1309
|
+
};
|
|
1310
|
+
}>>;
|
|
1311
|
+
/**
|
|
1312
|
+
* Cancel an existing order
|
|
1313
|
+
*/
|
|
1314
|
+
cancelOrder(request: CancelOrderRequest): Promise<ExtendedApiResponse<{}>>;
|
|
1315
|
+
/**
|
|
1316
|
+
* Get all open orders
|
|
1317
|
+
*/
|
|
1318
|
+
getOpenOrders(marketName?: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
|
|
1319
|
+
/**
|
|
1320
|
+
* Update leverage on the market
|
|
1321
|
+
* @param request
|
|
1322
|
+
* @returns
|
|
1323
|
+
*/
|
|
1324
|
+
updateLeverage(request: UpdateLeverageRequest): Promise<ExtendedApiResponse<{}>>;
|
|
1325
|
+
/**
|
|
1326
|
+
* Get asset operations with optional filtering
|
|
1327
|
+
*/
|
|
1328
|
+
getAssetOperations(options?: {
|
|
1329
|
+
id?: number;
|
|
1330
|
+
operationsType?: AssetOperationType[];
|
|
1331
|
+
operationsStatus?: AssetOperationStatus[];
|
|
1332
|
+
startTime?: number;
|
|
1333
|
+
endTime?: number;
|
|
1334
|
+
cursor?: number;
|
|
1335
|
+
limit?: number;
|
|
1336
|
+
}): Promise<ExtendedApiResponse<AssetOperation[]>>;
|
|
1337
|
+
/**
|
|
1338
|
+
* Health check endpoint
|
|
1339
|
+
*/
|
|
1340
|
+
healthCheck(): Promise<ExtendedApiResponse<MarketStats>>;
|
|
1341
|
+
/**
|
|
1342
|
+
* Convenience method to create a buy order
|
|
1343
|
+
*/
|
|
1344
|
+
createBuyOrder(marketName: string, amount: string, price: string, options?: {
|
|
1345
|
+
postOnly?: boolean;
|
|
1346
|
+
previousOrderId?: number;
|
|
1347
|
+
externalId?: string;
|
|
1348
|
+
timeInForce?: TimeInForce;
|
|
1349
|
+
}): Promise<ExtendedApiResponse<PlacedOrder>>;
|
|
1350
|
+
/**
|
|
1351
|
+
* Get order by ID
|
|
1352
|
+
* @param orderId - The ID of the order to get
|
|
1353
|
+
* @returns The order
|
|
1354
|
+
*/
|
|
1355
|
+
getOrderById(orderId: number): Promise<ExtendedApiResponse<OpenOrder>>;
|
|
1356
|
+
/**
|
|
1357
|
+
* Convenience method to create a sell order
|
|
1358
|
+
*/
|
|
1359
|
+
createSellOrder(marketName: string, amount: string, price: string, options?: {
|
|
1360
|
+
postOnly?: boolean;
|
|
1361
|
+
previousOrderId?: number;
|
|
1362
|
+
externalId?: string;
|
|
1363
|
+
timeInForce?: TimeInForce;
|
|
1364
|
+
}): Promise<ExtendedApiResponse<PlacedOrder>>;
|
|
1365
|
+
/**
|
|
1366
|
+
* Get positions for a specific market
|
|
1367
|
+
*/
|
|
1368
|
+
getPositionsForMarket(marketName: string): Promise<ExtendedApiResponse<Position[]>>;
|
|
1369
|
+
/**
|
|
1370
|
+
* Get open orders for a specific market
|
|
1371
|
+
*/
|
|
1372
|
+
getOpenOrdersForMarket(marketName: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
|
|
1373
|
+
/**
|
|
1374
|
+
* Cancel order by ID (convenience method)
|
|
1375
|
+
*/
|
|
1376
|
+
cancelOrderById(orderId: number): Promise<ExtendedApiResponse<{}>>;
|
|
1377
|
+
/**
|
|
1378
|
+
* Get order history for a specific market
|
|
1379
|
+
* @param marketName - The name of the market to get order history for
|
|
1380
|
+
* @returns The order history for the specified market
|
|
1381
|
+
*/
|
|
1382
|
+
getOrderHistory(marketName: string): Promise<ExtendedApiResponse<OpenOrder[]>>;
|
|
1383
|
+
/**
|
|
1384
|
+
* Withdraw USDC (convenience method)
|
|
1385
|
+
*/
|
|
1386
|
+
withdrawUSDC(amount: string): Promise<ExtendedApiResponse<number>>;
|
|
1387
|
+
/**
|
|
1388
|
+
* Get funding rates for a specific market
|
|
1389
|
+
* @param marketName - The name of the market to get funding rates for
|
|
1390
|
+
* @returns The funding rates for the specified market
|
|
1391
|
+
*/
|
|
1392
|
+
getFundingRates(marketName: string, side: string): Promise<ExtendedApiResponse<FundingRate[]>>;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
interface Route {
|
|
1396
|
+
token_from: string;
|
|
1397
|
+
token_to: string;
|
|
1398
|
+
exchange_address: string;
|
|
1399
|
+
percent: number;
|
|
1400
|
+
additional_swap_params: string[];
|
|
1401
|
+
}
|
|
1402
|
+
interface SwapInfo {
|
|
1403
|
+
token_from_address: string;
|
|
1404
|
+
token_from_amount: Uint256;
|
|
1405
|
+
token_to_address: string;
|
|
1406
|
+
token_to_amount: Uint256;
|
|
1407
|
+
token_to_min_amount: Uint256;
|
|
1408
|
+
beneficiary: string;
|
|
1409
|
+
integrator_fee_amount_bps: number;
|
|
1410
|
+
integrator_fee_recipient: string;
|
|
1411
|
+
routes: Route[];
|
|
1412
|
+
}
|
|
1413
|
+
declare class AvnuWrapper {
|
|
1414
|
+
getQuotes(fromToken: string, toToken: string, amountWei: string, taker: string, retry?: number, excludeSources?: string[]): Promise<Quote>;
|
|
1415
|
+
getSwapInfo(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string, integratorFeeBps: number, integratorFeeRecipient: string, minAmount?: string, options?: AvnuOptions): Promise<SwapInfo>;
|
|
1416
|
+
static buildZeroSwap(tokenToSell: ContractAddr, beneficiary: string, tokenToBuy?: ContractAddr): SwapInfo;
|
|
1417
|
+
getSwapCallData(quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>, taker: string): Promise<bigint[][]>;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
interface AvnuAdapterConfig extends BaseAdapterConfig {
|
|
1421
|
+
baseUrl: string;
|
|
1422
|
+
avnuContract: ContractAddr;
|
|
1423
|
+
slippage: number;
|
|
1424
|
+
}
|
|
1425
|
+
declare class AvnuAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
1426
|
+
readonly config: AvnuAdapterConfig;
|
|
1427
|
+
protected avnuWrapper: AvnuWrapper;
|
|
1428
|
+
constructor(config: AvnuAdapterConfig);
|
|
1429
|
+
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
1430
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
1431
|
+
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
1432
|
+
maxWithdraw(): Promise<PositionInfo>;
|
|
1433
|
+
protected _getDepositLeaf(): {
|
|
1434
|
+
target: ContractAddr;
|
|
1435
|
+
method: string;
|
|
1436
|
+
packedArguments: bigint[];
|
|
1437
|
+
sanitizer: ContractAddr;
|
|
1438
|
+
id: string;
|
|
1439
|
+
}[];
|
|
1440
|
+
protected _getWithdrawLeaf(): {
|
|
1441
|
+
target: ContractAddr;
|
|
1442
|
+
method: string;
|
|
1443
|
+
packedArguments: bigint[];
|
|
1444
|
+
sanitizer: ContractAddr;
|
|
1445
|
+
id: string;
|
|
1446
|
+
}[];
|
|
1447
|
+
protected _getLegacySwapLeaf(): {
|
|
1448
|
+
target: ContractAddr;
|
|
1449
|
+
method: string;
|
|
1450
|
+
packedArguments: bigint[];
|
|
1451
|
+
sanitizer: ContractAddr;
|
|
1452
|
+
id: string;
|
|
1453
|
+
}[];
|
|
1454
|
+
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
1455
|
+
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
1456
|
+
getSwapCallData(quote: Quote): Promise<bigint[][]>;
|
|
1457
|
+
getHealthFactor(): Promise<number>;
|
|
1458
|
+
fetchQuoteWithRetry(params: Record<string, any>, retries?: number): Promise<any>;
|
|
1459
|
+
getQuotesAvnu(from_token_address: string, to_token_address: string, amount: number, //amount in btc units
|
|
1460
|
+
takerAddress: string, toTokenDecimals: number, usdcToBtc: boolean, maxIterations?: number, tolerance?: number): Promise<Quote | null>;
|
|
1461
|
+
getPriceOfToken(tokenAddress: string, retries?: number): Promise<number | null>;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
interface ExtendedAdapterConfig extends BaseAdapterConfig {
|
|
1465
|
+
vaultIdExtended: number;
|
|
1466
|
+
extendedContract: ContractAddr;
|
|
1467
|
+
extendedBackendUrl: string;
|
|
1468
|
+
extendedApiKey: string;
|
|
1469
|
+
extendedTimeout: number;
|
|
1470
|
+
extendedRetries: number;
|
|
1471
|
+
extendedBaseUrl: string;
|
|
1472
|
+
extendedMarketName: string;
|
|
1473
|
+
extendedPrecision: number;
|
|
1474
|
+
avnuAdapter: AvnuAdapter;
|
|
1475
|
+
}
|
|
1476
|
+
declare class ExtendedAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
1477
|
+
readonly config: ExtendedAdapterConfig;
|
|
1478
|
+
readonly client: ExtendedWrapper;
|
|
1479
|
+
constructor(config: ExtendedAdapterConfig);
|
|
1480
|
+
protected getAPY(supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
1481
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
1482
|
+
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
1483
|
+
maxWithdraw(): Promise<PositionInfo>;
|
|
1484
|
+
protected _getDepositLeaf(): {
|
|
1485
|
+
target: ContractAddr;
|
|
1486
|
+
method: string;
|
|
1487
|
+
packedArguments: bigint[];
|
|
1488
|
+
sanitizer: ContractAddr;
|
|
1489
|
+
id: string;
|
|
1490
|
+
}[];
|
|
1491
|
+
getSwapFromLegacyLeaf(): AdapterLeafType<DepositParams>;
|
|
1492
|
+
protected _getSwapFromLegacyLeaf(): {
|
|
1493
|
+
target: ContractAddr;
|
|
1494
|
+
method: string;
|
|
1495
|
+
packedArguments: bigint[];
|
|
1496
|
+
sanitizer: ContractAddr;
|
|
1497
|
+
id: string;
|
|
1498
|
+
}[];
|
|
1499
|
+
protected _getWithdrawLeaf(): {
|
|
1500
|
+
target: ContractAddr;
|
|
1501
|
+
method: string;
|
|
1502
|
+
packedArguments: bigint[];
|
|
1503
|
+
sanitizer: ContractAddr;
|
|
1504
|
+
id: string;
|
|
1505
|
+
}[];
|
|
1506
|
+
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
1507
|
+
getProofsForFromLegacySwap<T>(tree: StandardMerkleTree): {
|
|
1508
|
+
proofs: string[][];
|
|
1509
|
+
callConstructor: GenerateCallFn<DepositParams> | GenerateCallFn<WithdrawParams>;
|
|
1510
|
+
};
|
|
1511
|
+
getSwapFromLegacyCall(params: DepositParams): Promise<ManageCall[]>;
|
|
1512
|
+
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
1513
|
+
withdrawFromExtended(amount: Web3Number): Promise<boolean>;
|
|
1514
|
+
getHealthFactor(): Promise<number>;
|
|
1515
|
+
getExtendedDepositAmount(): Promise<Balance | undefined>;
|
|
1516
|
+
setLeverage(leverage: string, marketName: string): Promise<boolean>;
|
|
1517
|
+
getAllOpenPositions(): Promise<Position[] | null>;
|
|
1518
|
+
getOrderHistory(marketName: string): Promise<OpenOrder[] | null>;
|
|
1519
|
+
getOrderStatus(orderId: string, marketName: string): Promise<OpenOrder | null>;
|
|
1520
|
+
fetchOrderBookBTCUSDC(): Promise<{
|
|
1521
|
+
status: boolean;
|
|
1522
|
+
bid: Web3Number;
|
|
1523
|
+
ask: Web3Number;
|
|
1524
|
+
}>;
|
|
1525
|
+
createOrder(leverage: string, btcAmount: number, side: OrderSide, attempt?: number, maxAttempts?: number): Promise<{
|
|
1526
|
+
position_id: string;
|
|
1527
|
+
btc_exposure: string;
|
|
1528
|
+
} | null>;
|
|
1529
|
+
createExtendedPositon(client: ExtendedWrapper, marketName: string, amount: string, price: string, side: OrderSide): Promise<{
|
|
1530
|
+
position_id: string;
|
|
1531
|
+
} | null>;
|
|
1532
|
+
getDepositOrWithdrawalStatus(orderId: number | string, operationsType: AssetOperationType): Promise<boolean>;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
declare const SIMPLE_SANITIZER: ContractAddr;
|
|
1536
|
+
declare const EXTENDED_SANITIZER: ContractAddr;
|
|
1537
|
+
declare const AVNU_LEGACY_SANITIZER: ContractAddr;
|
|
1538
|
+
declare const SIMPLE_SANITIZER_V2: ContractAddr;
|
|
1539
|
+
declare const VESU_V2_MODIFY_POSITION_SANITIZER: ContractAddr;
|
|
1540
|
+
declare const SIMPLE_SANITIZER_VESU_V1_DELEGATIONS: ContractAddr;
|
|
1541
|
+
declare const PRICE_ROUTER: ContractAddr;
|
|
1542
|
+
declare const AVNU_MIDDLEWARE: ContractAddr;
|
|
1543
|
+
declare const AVNU_EXCHANGE: ContractAddr;
|
|
1544
|
+
declare const AVNU_EXCHANGE_FOR_LEGACY_USDC: ContractAddr;
|
|
1545
|
+
declare const AVNU_QUOTE_URL = "https://starknet.api.avnu.fi/swap/v3/quotes";
|
|
1546
|
+
declare const EXTENDED_CONTRACT: ContractAddr;
|
|
1547
|
+
declare const VESU_SINGLETON: ContractAddr;
|
|
1548
|
+
declare function toBigInt(value: string | number): bigint;
|
|
1549
|
+
|
|
1550
|
+
interface UnusedBalanceAdapterConfig extends BaseAdapterConfig {
|
|
1551
|
+
}
|
|
1552
|
+
declare class UnusedBalanceAdapter extends BaseAdapter<DepositParams, WithdrawParams> {
|
|
1553
|
+
readonly config: UnusedBalanceAdapterConfig;
|
|
1554
|
+
readonly tokenMarketData: TokenMarketData;
|
|
1555
|
+
constructor(config: UnusedBalanceAdapterConfig);
|
|
1556
|
+
protected getAPY(_supportedPosition: SupportedPosition): Promise<PositionAPY>;
|
|
1557
|
+
protected getPosition(supportedPosition: SupportedPosition): Promise<PositionAmount>;
|
|
1558
|
+
maxDeposit(amount?: Web3Number): Promise<PositionInfo>;
|
|
1559
|
+
maxWithdraw(): Promise<PositionInfo>;
|
|
1560
|
+
protected _getDepositLeaf(): {
|
|
1561
|
+
target: ContractAddr;
|
|
1562
|
+
method: string;
|
|
1563
|
+
packedArguments: bigint[];
|
|
1564
|
+
sanitizer: ContractAddr;
|
|
1565
|
+
id: string;
|
|
1566
|
+
}[];
|
|
1567
|
+
protected _getWithdrawLeaf(): {
|
|
1568
|
+
target: ContractAddr;
|
|
1569
|
+
method: string;
|
|
1570
|
+
packedArguments: bigint[];
|
|
1571
|
+
sanitizer: ContractAddr;
|
|
1572
|
+
id: string;
|
|
1573
|
+
}[];
|
|
1574
|
+
getHealthFactor(): Promise<number>;
|
|
1575
|
+
getDepositCall(params: DepositParams): Promise<ManageCall[]>;
|
|
1576
|
+
getWithdrawCall(params: WithdrawParams): Promise<ManageCall[]>;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
interface SingleActionAmount {
|
|
1580
|
+
tokenInfo: TokenInfo;
|
|
1581
|
+
amount: Web3Number;
|
|
1582
|
+
}
|
|
1583
|
+
interface SingleTokenInfo extends SingleActionAmount {
|
|
1584
|
+
usdValue: number;
|
|
1585
|
+
}
|
|
1586
|
+
interface APYInfo {
|
|
1587
|
+
net: number;
|
|
1588
|
+
splits: {
|
|
1589
|
+
apy: number;
|
|
1590
|
+
id: string;
|
|
1591
|
+
}[];
|
|
1592
|
+
}
|
|
1593
|
+
interface DualActionAmount {
|
|
1594
|
+
token0: SingleActionAmount;
|
|
1595
|
+
token1: SingleActionAmount;
|
|
1596
|
+
}
|
|
1597
|
+
interface DualTokenInfo {
|
|
1598
|
+
usdValue: number;
|
|
1599
|
+
token0: SingleTokenInfo;
|
|
1600
|
+
token1: SingleTokenInfo;
|
|
1601
|
+
}
|
|
1602
|
+
interface CacheData {
|
|
1603
|
+
timestamp: number;
|
|
1604
|
+
ttl: number;
|
|
1605
|
+
data: any;
|
|
1606
|
+
}
|
|
1607
|
+
declare class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
|
|
1608
|
+
readonly config: IConfig;
|
|
1609
|
+
readonly cache: Map<string, CacheData>;
|
|
1610
|
+
constructor(config: IConfig);
|
|
1611
|
+
getUserTVL(user: ContractAddr): Promise<TVLInfo>;
|
|
1612
|
+
getTVL(): Promise<TVLInfo>;
|
|
1613
|
+
depositCall(amountInfo: ActionInfo, receiver: ContractAddr): Promise<Call[]>;
|
|
1614
|
+
withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
1615
|
+
getVaultPositions(): Promise<VaultPosition[]>;
|
|
1616
|
+
getUnusedBalance(): Promise<SingleTokenInfo>;
|
|
1617
|
+
netAPY(): Promise<APYInfo>;
|
|
1618
|
+
getAUM(): Promise<{
|
|
1619
|
+
net: SingleTokenInfo;
|
|
1620
|
+
prevAum: Web3Number;
|
|
1621
|
+
splits: PositionInfo[];
|
|
1622
|
+
}>;
|
|
1623
|
+
getHealthFactors(): Promise<number[]>;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
/**
|
|
1627
|
+
* TokenMarketData class that combines LST APR and Midas modules
|
|
1628
|
+
* to provide unified APY, price, and TVL functions for tokens
|
|
1629
|
+
*/
|
|
1630
|
+
declare class TokenMarketData {
|
|
1631
|
+
private pricer;
|
|
1632
|
+
private config;
|
|
1633
|
+
constructor(pricer: PricerBase, config: IConfig);
|
|
1634
|
+
/**
|
|
1635
|
+
* Get APY for a token
|
|
1636
|
+
* - If it's an LST token, returns LST APY
|
|
1637
|
+
* - If it's a Midas token, returns Midas APY
|
|
1638
|
+
* - Otherwise returns 0
|
|
1639
|
+
* @param tokenInfo The token to get APY for
|
|
1640
|
+
* @returns APY in absolute terms (not percentage)
|
|
1641
|
+
*/
|
|
1642
|
+
getAPY(tokenInfo: TokenInfo): Promise<number>;
|
|
1643
|
+
/**
|
|
1644
|
+
* Get price for a token using the pricer module
|
|
1645
|
+
* @param tokenInfo The token to get price for
|
|
1646
|
+
* @returns Price as a number
|
|
1647
|
+
* @throws Error if price is 0 or unavailable
|
|
1648
|
+
*/
|
|
1649
|
+
getPrice(tokenInfo: TokenInfo): Promise<number>;
|
|
1650
|
+
/**
|
|
1651
|
+
* Get true price for a token
|
|
1652
|
+
* - For LST tokens: Uses convert_to_assets to get true exchange rate
|
|
1653
|
+
* - For Midas tokens: Uses Midas price API
|
|
1654
|
+
* - For other tokens: Falls back to regular pricer
|
|
1655
|
+
* @param tokenInfo The token to get true price for
|
|
1656
|
+
* @returns True price as a number
|
|
1657
|
+
* @throws Error if price is 0 or unavailable
|
|
1658
|
+
*/
|
|
1659
|
+
getTruePrice(tokenInfo: TokenInfo): Promise<number>;
|
|
1660
|
+
/**
|
|
1661
|
+
* Get TVL for a token
|
|
1662
|
+
* - If it's a Midas token, returns Midas TVL data
|
|
1663
|
+
* - Otherwise returns 0
|
|
1664
|
+
* @param tokenInfo The token to get TVL for
|
|
1665
|
+
* @returns TVL as SingleTokenInfo or 0
|
|
1666
|
+
*/
|
|
1667
|
+
getTVL(tokenInfo: TokenInfo): Promise<SingleTokenInfo>;
|
|
1668
|
+
/**
|
|
1669
|
+
* Check if a token is supported for APY data
|
|
1670
|
+
* @param tokenInfo The token to check
|
|
1671
|
+
* @returns True if the token has APY data available
|
|
1672
|
+
*/
|
|
1673
|
+
isAPYSupported(tokenInfo: TokenInfo): boolean;
|
|
1674
|
+
/**
|
|
1675
|
+
* Check if a token is supported for TVL data
|
|
1676
|
+
* @param tokenInfo The token to check
|
|
1677
|
+
* @returns True if the token has TVL data available
|
|
1678
|
+
*/
|
|
1679
|
+
isTVLSupported(tokenInfo: TokenInfo): boolean;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
declare class Pragma {
|
|
1683
|
+
contractAddr: string;
|
|
1684
|
+
readonly contract: Contract;
|
|
1685
|
+
constructor(provider: RpcProvider);
|
|
1686
|
+
getPrice(tokenAddr: string): Promise<number>;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
declare class ZkLend extends ILending implements ILending {
|
|
1690
|
+
readonly pricer: Pricer;
|
|
1691
|
+
static readonly POOLS_URL = "https://app.zklend.com/api/pools";
|
|
1692
|
+
private POSITION_URL;
|
|
1693
|
+
constructor(config: IConfig, pricer: Pricer);
|
|
1694
|
+
init(): Promise<void>;
|
|
1695
|
+
/**
|
|
1696
|
+
* @description Get the health factor of the user for given lending and debt tokens
|
|
1697
|
+
* @param lending_tokens
|
|
1698
|
+
* @param debt_tokens
|
|
1699
|
+
* @param user
|
|
1700
|
+
* @returns hf (e.g. returns 1.5 for 150% health factor)
|
|
1701
|
+
*/
|
|
1702
|
+
get_health_factor_tokenwise(lending_tokens: TokenInfo[], debt_tokens: TokenInfo[], user: ContractAddr): Promise<number>;
|
|
1703
|
+
/**
|
|
1704
|
+
* @description Get the health factor of the user
|
|
1705
|
+
* - Considers all tokens for collateral and debt
|
|
1706
|
+
*/
|
|
1707
|
+
get_health_factor(user: ContractAddr): Promise<number>;
|
|
1708
|
+
getPositionsSummary(user: ContractAddr): Promise<{
|
|
1709
|
+
collateralUSD: number;
|
|
1710
|
+
debtUSD: number;
|
|
1711
|
+
}>;
|
|
1712
|
+
/**
|
|
1713
|
+
* @description Get the token-wise collateral and debt positions of the user
|
|
1714
|
+
* @param user Contract address of the user
|
|
1715
|
+
* @returns Promise<ILendingPosition[]>
|
|
1716
|
+
*/
|
|
1717
|
+
getPositions(user: ContractAddr): Promise<ILendingPosition[]>;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
declare class PricerFromApi extends PricerBase {
|
|
1721
|
+
constructor(config: IConfig, tokens: TokenInfo[]);
|
|
1722
|
+
getPrice(tokenSymbol: string): Promise<PriceInfo>;
|
|
1723
|
+
getPriceFromMyAPI(tokenSymbol: string): Promise<{
|
|
1724
|
+
price: number;
|
|
1725
|
+
timestamp: Date;
|
|
1726
|
+
}>;
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
declare class ERC20 {
|
|
1730
|
+
readonly config: IConfig;
|
|
1731
|
+
constructor(config: IConfig);
|
|
1732
|
+
contract(addr: string | ContractAddr): Contract;
|
|
1733
|
+
balanceOf(token: string | ContractAddr, address: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
|
|
1734
|
+
allowance(token: string | ContractAddr, owner: string | ContractAddr, spender: string | ContractAddr, tokenDecimals: number): Promise<Web3Number>;
|
|
1735
|
+
transfer(token: string | ContractAddr, to: string | ContractAddr, amount: Web3Number): starknet.Call;
|
|
1736
|
+
approve(token: string | ContractAddr, spender: string | ContractAddr, amount: Web3Number): starknet.Call;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
declare class AutoCompounderSTRK {
|
|
1740
|
+
readonly config: IConfig;
|
|
1741
|
+
readonly addr: ContractAddr;
|
|
1742
|
+
readonly pricer: Pricer;
|
|
1743
|
+
private initialized;
|
|
1744
|
+
contract: Contract | null;
|
|
1745
|
+
readonly metadata: {
|
|
1746
|
+
decimals: number;
|
|
1747
|
+
underlying: {
|
|
1748
|
+
address: ContractAddr;
|
|
1749
|
+
name: string;
|
|
1750
|
+
symbol: string;
|
|
1751
|
+
};
|
|
1752
|
+
name: string;
|
|
1753
|
+
};
|
|
1754
|
+
constructor(config: IConfig, pricer: Pricer);
|
|
1755
|
+
init(): Promise<void>;
|
|
1756
|
+
waitForInitilisation(): Promise<void>;
|
|
1757
|
+
/** Returns shares of user */
|
|
1758
|
+
balanceOf(user: ContractAddr): Promise<Web3Number>;
|
|
1759
|
+
/** Returns underlying assets of user */
|
|
1760
|
+
balanceOfUnderlying(user: ContractAddr): Promise<Web3Number>;
|
|
1761
|
+
/** Returns usd value of assets */
|
|
1762
|
+
usdBalanceOfUnderlying(user: ContractAddr): Promise<{
|
|
1763
|
+
usd: Web3Number;
|
|
1764
|
+
assets: Web3Number;
|
|
1765
|
+
}>;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
interface PoolProps {
|
|
1769
|
+
pool_id: ContractAddr;
|
|
1770
|
+
max_weight: number;
|
|
1771
|
+
v_token: ContractAddr;
|
|
1772
|
+
}
|
|
1773
|
+
interface Change {
|
|
1774
|
+
pool_id: ContractAddr;
|
|
1775
|
+
changeAmt: Web3Number;
|
|
1776
|
+
finalAmt: Web3Number;
|
|
1777
|
+
isDeposit: boolean;
|
|
1778
|
+
}
|
|
1779
|
+
interface VesuRebalanceSettings {
|
|
1780
|
+
feeBps: number;
|
|
1781
|
+
}
|
|
1782
|
+
interface PoolInfoFull {
|
|
1783
|
+
pool_id: ContractAddr;
|
|
1784
|
+
pool_name: string | undefined;
|
|
1785
|
+
max_weight: number;
|
|
1786
|
+
current_weight: number;
|
|
1787
|
+
v_token: ContractAddr;
|
|
1788
|
+
amount: Web3Number;
|
|
1789
|
+
usdValue: Web3Number;
|
|
1790
|
+
APY: {
|
|
1791
|
+
baseApy: number;
|
|
1792
|
+
defiSpringApy: number;
|
|
1793
|
+
netApy: number;
|
|
1794
|
+
};
|
|
1795
|
+
currentUtilization: number;
|
|
1796
|
+
maxUtilization: number;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Represents a VesuRebalance strategy.
|
|
1800
|
+
* This class implements an automated rebalancing strategy for Vesu pools,
|
|
1801
|
+
* managing deposits and withdrawals while optimizing yield through STRK rewards.
|
|
1802
|
+
*/
|
|
1803
|
+
declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
1804
|
+
/** Contract address of the strategy */
|
|
1805
|
+
readonly address: ContractAddr;
|
|
1806
|
+
/** Pricer instance for token price calculations */
|
|
1807
|
+
readonly pricer: PricerBase;
|
|
1808
|
+
/** Metadata containing strategy information */
|
|
1809
|
+
readonly metadata: IStrategyMetadata<VesuRebalanceSettings>;
|
|
1810
|
+
/** Contract instance for interacting with the strategy */
|
|
1811
|
+
readonly contract: Contract;
|
|
1812
|
+
readonly BASE_WEIGHT = 10000;
|
|
1813
|
+
/**
|
|
1814
|
+
* Creates a new VesuRebalance strategy instance.
|
|
1815
|
+
* @param config - Configuration object containing provider and other settings
|
|
1816
|
+
* @param pricer - Pricer instance for token price calculations
|
|
1817
|
+
* @param metadata - Strategy metadata including deposit tokens and address
|
|
1818
|
+
* @throws {Error} If more than one deposit token is specified
|
|
1819
|
+
*/
|
|
1820
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<VesuRebalanceSettings>);
|
|
1821
|
+
/**
|
|
1822
|
+
* Creates a deposit call to the strategy contract.
|
|
1823
|
+
* @param assets - Amount of assets to deposit
|
|
1824
|
+
* @param receiver - Address that will receive the strategy tokens
|
|
1825
|
+
* @returns Populated contract call for deposit
|
|
1826
|
+
*/
|
|
1827
|
+
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<starknet.Call[]>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Creates a withdrawal call to the strategy contract.
|
|
1830
|
+
* @param assets - Amount of assets to withdraw
|
|
1831
|
+
* @param receiver - Address that will receive the withdrawn assets
|
|
1832
|
+
* @param owner - Address that owns the strategy tokens
|
|
1833
|
+
* @returns Populated contract call for withdrawal
|
|
1834
|
+
*/
|
|
1835
|
+
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<starknet.Call[]>;
|
|
1836
|
+
/**
|
|
1837
|
+
* Returns the underlying asset token of the strategy.
|
|
1838
|
+
* @returns The deposit token supported by this strategy
|
|
1839
|
+
*/
|
|
1840
|
+
asset(): TokenInfo;
|
|
1841
|
+
/**
|
|
1842
|
+
* Returns the number of decimals used by the strategy token.
|
|
1843
|
+
* @returns Number of decimals (same as the underlying token)
|
|
1844
|
+
*/
|
|
1845
|
+
decimals(): number;
|
|
1846
|
+
/**
|
|
1847
|
+
* Calculates the Total Value Locked (TVL) for a specific user.
|
|
1848
|
+
* @param user - Address of the user
|
|
1849
|
+
* @returns Object containing the amount in token units and USD value
|
|
1850
|
+
*/
|
|
1851
|
+
getUserTVL(user: ContractAddr): Promise<{
|
|
1852
|
+
tokenInfo: TokenInfo;
|
|
1853
|
+
amount: Web3Number;
|
|
1854
|
+
usdValue: number;
|
|
1855
|
+
}>;
|
|
1856
|
+
/**
|
|
1857
|
+
* Calculates the total TVL of the strategy.
|
|
1858
|
+
* @returns Object containing the total amount in token units and USD value
|
|
1859
|
+
*/
|
|
1860
|
+
getTVL(): Promise<{
|
|
1861
|
+
tokenInfo: TokenInfo;
|
|
1862
|
+
amount: Web3Number;
|
|
1863
|
+
usdValue: number;
|
|
1864
|
+
}>;
|
|
1865
|
+
static getAllPossibleVerifiedPools(asset: ContractAddr): Promise<any>;
|
|
1866
|
+
getPoolInfo(p: PoolProps, pools: any[], vesuPositions: any[], totalAssets: Web3Number, isErrorPositionsAPI: boolean, isErrorPoolsAPI: boolean): Promise<{
|
|
1867
|
+
pool_id: ContractAddr;
|
|
1868
|
+
pool_name: any;
|
|
1869
|
+
max_weight: number;
|
|
1870
|
+
current_weight: number;
|
|
1871
|
+
v_token: ContractAddr;
|
|
1872
|
+
amount: Web3Number;
|
|
1873
|
+
usdValue: Web3Number;
|
|
1874
|
+
APY: {
|
|
1875
|
+
baseApy: number;
|
|
1876
|
+
defiSpringApy: number;
|
|
1877
|
+
netApy: number;
|
|
1878
|
+
};
|
|
1879
|
+
currentUtilization: number;
|
|
1880
|
+
maxUtilization: number;
|
|
1881
|
+
}>;
|
|
1882
|
+
/**
|
|
1883
|
+
* Retrieves the list of allowed pools and their detailed information from multiple sources:
|
|
1884
|
+
* 1. Contract's allowed pools
|
|
1885
|
+
* 2. Vesu positions API for current positions
|
|
1886
|
+
* 3. Vesu pools API for APY and utilization data
|
|
1887
|
+
*
|
|
1888
|
+
* @returns {Promise<{
|
|
1889
|
+
* data: Array<PoolInfoFull>,
|
|
1890
|
+
* isErrorPositionsAPI: boolean
|
|
1891
|
+
* }>} Object containing:
|
|
1892
|
+
* - data: Array of pool information including IDs, weights, amounts, APYs and utilization
|
|
1893
|
+
* - isErrorPositionsAPI: Boolean indicating if there was an error fetching position data
|
|
1894
|
+
*/
|
|
1895
|
+
getPools(): Promise<{
|
|
1896
|
+
data: {
|
|
1897
|
+
pool_id: ContractAddr;
|
|
1898
|
+
pool_name: any;
|
|
1899
|
+
max_weight: number;
|
|
1900
|
+
current_weight: number;
|
|
1901
|
+
v_token: ContractAddr;
|
|
1902
|
+
amount: Web3Number;
|
|
1903
|
+
usdValue: Web3Number;
|
|
1904
|
+
APY: {
|
|
1905
|
+
baseApy: number;
|
|
1906
|
+
defiSpringApy: number;
|
|
1907
|
+
netApy: number;
|
|
1908
|
+
};
|
|
1909
|
+
currentUtilization: number;
|
|
1910
|
+
maxUtilization: number;
|
|
1911
|
+
}[];
|
|
1912
|
+
isErrorPositionsAPI: boolean;
|
|
1913
|
+
isErrorPoolsAPI: boolean;
|
|
1914
|
+
isError: boolean;
|
|
1915
|
+
}>;
|
|
1916
|
+
getVesuPools(retry?: number): Promise<{
|
|
1917
|
+
pools: any[];
|
|
1918
|
+
isErrorPoolsAPI: boolean;
|
|
1919
|
+
}>;
|
|
1920
|
+
/**
|
|
1921
|
+
* Calculates the weighted average APY across all pools based on USD value.
|
|
1922
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
1923
|
+
*/
|
|
1924
|
+
netAPY(): Promise<APYInfo>;
|
|
1925
|
+
/**
|
|
1926
|
+
* Calculates the weighted average APY across all pools based on USD value.
|
|
1927
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
1928
|
+
*/
|
|
1929
|
+
netAPYGivenPools(pools: PoolInfoFull[]): Promise<number>;
|
|
1930
|
+
/**
|
|
1931
|
+
* Calculates optimal position changes to maximize APY while respecting max weights.
|
|
1932
|
+
* The algorithm:
|
|
1933
|
+
* 1. Sorts pools by APY (highest first)
|
|
1934
|
+
* 2. Calculates target amounts based on max weights
|
|
1935
|
+
* 3. For each pool that needs more funds:
|
|
1936
|
+
* - Takes funds from lowest APY pools that are over their target
|
|
1937
|
+
* 4. Validates that total assets remain constant
|
|
1938
|
+
*
|
|
1939
|
+
* @returns {Promise<{
|
|
1940
|
+
* changes: Change[],
|
|
1941
|
+
* finalPools: PoolInfoFull[],
|
|
1942
|
+
* isAnyPoolOverMaxWeight: boolean
|
|
1943
|
+
* }>} Object containing:
|
|
1944
|
+
* - changes: Array of position changes
|
|
1945
|
+
* - finalPools: Array of pool information after rebalance
|
|
1946
|
+
* @throws Error if rebalance is not possible while maintaining constraints
|
|
1947
|
+
*/
|
|
1948
|
+
getRebalancedPositions(_pools?: PoolInfoFull[]): Promise<{
|
|
1949
|
+
changes: never[];
|
|
1950
|
+
finalPools: never[];
|
|
1951
|
+
isAnyPoolOverMaxWeight?: undefined;
|
|
1952
|
+
} | {
|
|
1953
|
+
changes: Change[];
|
|
1954
|
+
finalPools: PoolInfoFull[];
|
|
1955
|
+
isAnyPoolOverMaxWeight: boolean;
|
|
1956
|
+
}>;
|
|
1957
|
+
/**
|
|
1958
|
+
* Creates a rebalance Call object for the strategy contract
|
|
1959
|
+
* @param pools - Array of pool information including IDs, weights, amounts, APYs and utilization
|
|
1960
|
+
* @returns Populated contract call for rebalance
|
|
1961
|
+
*/
|
|
1962
|
+
getRebalanceCall(pools: Awaited<ReturnType<typeof this.getRebalancedPositions>>["changes"], isOverWeightAdjustment: boolean): Promise<starknet.Call | null>;
|
|
1963
|
+
getInvestmentFlows(pools: PoolInfoFull[]): Promise<IInvestmentFlow[]>;
|
|
1964
|
+
harvest(acc: Account, endpoint?: string): Promise<starknet.Call[]>;
|
|
1965
|
+
/**
|
|
1966
|
+
* Calculates the fees deducted in different vTokens based on the current and previous state.
|
|
1967
|
+
* @param previousTotalSupply - The total supply of the strategy token before the transaction
|
|
1968
|
+
* @returns {Promise<Array<{ vToken: ContractAddr, fee: Web3Number }>>} Array of fees deducted in different vTokens
|
|
1969
|
+
*/
|
|
1970
|
+
getFee(allowedPools: Array<PoolInfoFull>): Promise<Array<{
|
|
1971
|
+
vToken: ContractAddr;
|
|
1972
|
+
fee: Web3Number;
|
|
1973
|
+
}>>;
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* Represents the Vesu Rebalance Strategies.
|
|
1977
|
+
*/
|
|
1978
|
+
declare const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[];
|
|
1979
|
+
|
|
1980
|
+
interface SenseiVaultSettings {
|
|
1981
|
+
mainToken: TokenInfo;
|
|
1982
|
+
secondaryToken: TokenInfo;
|
|
1983
|
+
targetHfBps: number;
|
|
1984
|
+
feeBps: number;
|
|
1985
|
+
}
|
|
1986
|
+
declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
1987
|
+
readonly address: ContractAddr;
|
|
1988
|
+
readonly metadata: IStrategyMetadata<SenseiVaultSettings>;
|
|
1989
|
+
readonly pricer: PricerBase;
|
|
1990
|
+
readonly contract: Contract;
|
|
1991
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<SenseiVaultSettings>);
|
|
1992
|
+
getUserTVL(user: ContractAddr): Promise<SingleTokenInfo>;
|
|
1993
|
+
getTVL(): Promise<SingleTokenInfo>;
|
|
1994
|
+
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
1995
|
+
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
1996
|
+
getPositionInfo(): Promise<{
|
|
1997
|
+
collateralXSTRK: Web3Number;
|
|
1998
|
+
collateralUSDValue: Web3Number;
|
|
1999
|
+
debtSTRK: Web3Number;
|
|
2000
|
+
debtUSDValue: Web3Number;
|
|
2001
|
+
xSTRKPrice: number;
|
|
2002
|
+
collateralInSTRK: number;
|
|
2003
|
+
}>;
|
|
2004
|
+
getSecondaryTokenPriceRelativeToMain(retry?: number): Promise<number>;
|
|
2005
|
+
getSettings: () => Promise<starknet.CallResult>;
|
|
2006
|
+
}
|
|
2007
|
+
declare const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[];
|
|
2008
|
+
|
|
2009
|
+
interface UniversalManageCall {
|
|
2010
|
+
proofs: string[];
|
|
2011
|
+
manageCall: ManageCall;
|
|
2012
|
+
step: UNIVERSAL_MANAGE_IDS;
|
|
2013
|
+
}
|
|
2014
|
+
interface UniversalStrategySettings {
|
|
2015
|
+
vaultAddress: ContractAddr;
|
|
2016
|
+
manager: ContractAddr;
|
|
2017
|
+
vaultAllocator: ContractAddr;
|
|
2018
|
+
redeemRequestNFT: ContractAddr;
|
|
2019
|
+
leafAdapters: LeafAdapterFn<any>[];
|
|
2020
|
+
adapters: {
|
|
2021
|
+
id: string;
|
|
2022
|
+
adapter: BaseAdapter<DepositParams, WithdrawParams>;
|
|
2023
|
+
}[];
|
|
1270
2024
|
}
|
|
1271
2025
|
declare enum AUMTypes {
|
|
1272
2026
|
FINALISED = "finalised",
|
|
1273
2027
|
DEFISPRING = "defispring"
|
|
1274
2028
|
}
|
|
1275
|
-
declare
|
|
2029
|
+
declare enum UNIVERSAL_MANAGE_IDS {
|
|
2030
|
+
FLASH_LOAN = "flash_loan_init",
|
|
2031
|
+
VESU_LEG1 = "vesu_leg1",
|
|
2032
|
+
VESU_LEG2 = "vesu_leg2",
|
|
2033
|
+
APPROVE_TOKEN1 = "approve_token1",
|
|
2034
|
+
APPROVE_TOKEN2 = "approve_token2",
|
|
2035
|
+
APPROVE_BRING_LIQUIDITY = "approve_bring_liquidity",
|
|
2036
|
+
BRING_LIQUIDITY = "bring_liquidity",
|
|
2037
|
+
DEFISPRING_REWARDS = "defispring_rewards",
|
|
2038
|
+
APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
|
|
2039
|
+
AVNU_SWAP_REWARDS = "avnu_swap_rewards"
|
|
2040
|
+
}
|
|
2041
|
+
declare function getContractDetails(settings: UniversalStrategySettings & {
|
|
2042
|
+
aumOracle?: ContractAddr;
|
|
2043
|
+
}): {
|
|
2044
|
+
address: ContractAddr;
|
|
2045
|
+
name: string;
|
|
2046
|
+
}[];
|
|
2047
|
+
|
|
2048
|
+
/**
|
|
2049
|
+
* Base class for all SVK (Starknet Vault Kit) strategies.
|
|
2050
|
+
* Contains common functions that are shared across all SVK strategies.
|
|
2051
|
+
*/
|
|
2052
|
+
declare abstract class SVKStrategy<S extends UniversalStrategySettings> extends BaseStrategy<SingleTokenInfo, SingleActionAmount> {
|
|
1276
2053
|
/** Contract address of the strategy */
|
|
1277
2054
|
readonly address: ContractAddr;
|
|
1278
2055
|
/** Pricer instance for token price calculations */
|
|
@@ -1281,38 +2058,63 @@ declare class UniversalStrategy<S extends UniversalStrategySettings> extends Bas
|
|
|
1281
2058
|
readonly metadata: IStrategyMetadata<S>;
|
|
1282
2059
|
/** Contract instance for interacting with the strategy */
|
|
1283
2060
|
readonly contract: Contract;
|
|
2061
|
+
/** Manager contract instance for merkle verification */
|
|
1284
2062
|
readonly managerContract: Contract;
|
|
2063
|
+
/** Cached merkle tree instance */
|
|
1285
2064
|
merkleTree: StandardMerkleTree | undefined;
|
|
1286
2065
|
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
proofs: string[];
|
|
1291
|
-
callConstructor: GenerateCallFn<T>;
|
|
1292
|
-
};
|
|
1293
|
-
getAdapter(id: string): BaseAdapter;
|
|
2066
|
+
/**
|
|
2067
|
+
* Returns the asset token for this strategy
|
|
2068
|
+
*/
|
|
1294
2069
|
asset(): TokenInfo;
|
|
1295
|
-
depositCall(amountInfo: SingleActionAmount, receiver: ContractAddr): Promise<Call[]>;
|
|
1296
|
-
withdrawCall(amountInfo: SingleActionAmount, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]>;
|
|
1297
2070
|
/**
|
|
1298
|
-
*
|
|
1299
|
-
*
|
|
1300
|
-
* @returns Object containing the amount in token units and USD value
|
|
2071
|
+
* Returns the unused balance in the vault allocator.
|
|
2072
|
+
* Note: This function is common for any SVK strategy.
|
|
1301
2073
|
*/
|
|
1302
|
-
|
|
1303
|
-
|
|
2074
|
+
getUnusedBalance(): Promise<SingleTokenInfo>;
|
|
2075
|
+
/**
|
|
2076
|
+
* Bridges liquidity from the vault allocator back to the vault.
|
|
2077
|
+
* Note: This function is common for any SVK strategy.
|
|
2078
|
+
*/
|
|
2079
|
+
getBringLiquidityCall(params: {
|
|
1304
2080
|
amount: Web3Number;
|
|
1305
|
-
|
|
1306
|
-
}>;
|
|
1307
|
-
getVesuAPYs(): Promise<{
|
|
1308
|
-
baseAPYs: number[];
|
|
1309
|
-
rewardAPYs: number[];
|
|
1310
|
-
positions: VaultPosition[];
|
|
1311
|
-
}>;
|
|
2081
|
+
}): Promise<Call>;
|
|
1312
2082
|
/**
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
2083
|
+
* Gets all leaves from all leaf adapters.
|
|
2084
|
+
* Note: This function is common for any SVK strategy.
|
|
2085
|
+
*/
|
|
2086
|
+
getAllLeaves(): LeafData[];
|
|
2087
|
+
/**
|
|
2088
|
+
* Builds and caches the merkle tree from all leaf adapters.
|
|
2089
|
+
* Note: This function is common for any SVK strategy.
|
|
2090
|
+
*/
|
|
2091
|
+
getMerkleTree(): StandardMerkleTree;
|
|
2092
|
+
/**
|
|
2093
|
+
* Gets the merkle root of the tree.
|
|
2094
|
+
* Note: This function is common for any SVK strategy.
|
|
2095
|
+
*/
|
|
2096
|
+
getMerkleRoot(): string;
|
|
2097
|
+
/**
|
|
2098
|
+
* Combines proofs and manage calls into a single Starknet call.
|
|
2099
|
+
* Note: This function is common for any SVK strategy.
|
|
2100
|
+
*/
|
|
2101
|
+
getManageCall(proofGroups: string[][], manageCalls: ManageCall[]): Call;
|
|
2102
|
+
/**
|
|
2103
|
+
* Creates a call to set the merkle root on the manager contract.
|
|
2104
|
+
* Note: This function is common for any SVK strategy.
|
|
2105
|
+
*/
|
|
2106
|
+
getSetManagerCall(strategist: ContractAddr, root?: string): Call;
|
|
2107
|
+
/**
|
|
2108
|
+
* Returns a tag for logging purposes.
|
|
2109
|
+
* Should be overridden by subclasses to provide strategy-specific tags.
|
|
2110
|
+
*/
|
|
2111
|
+
abstract getTag(): string;
|
|
2112
|
+
/**
|
|
2113
|
+
* Returns the positions in the vault.
|
|
2114
|
+
* @returns An array of VaultPosition objects representing the positions in the vault.
|
|
1315
2115
|
*/
|
|
2116
|
+
getVaultPositions(): Promise<VaultPosition[]>;
|
|
2117
|
+
getHealthFactors(): Promise<number[]>;
|
|
1316
2118
|
netAPY(): Promise<{
|
|
1317
2119
|
net: number;
|
|
1318
2120
|
splits: {
|
|
@@ -1320,210 +2122,555 @@ declare class UniversalStrategy<S extends UniversalStrategySettings> extends Bas
|
|
|
1320
2122
|
id: string;
|
|
1321
2123
|
}[];
|
|
1322
2124
|
}>;
|
|
1323
|
-
protected returnNetAPY(baseAPYs: number[], rewardAPYs: number[], weights: number[], prevAUMUSD: Web3Number): Promise<{
|
|
1324
|
-
net: number;
|
|
1325
|
-
splits: {
|
|
1326
|
-
apy: number;
|
|
1327
|
-
id: string;
|
|
1328
|
-
}[];
|
|
1329
|
-
}>;
|
|
1330
|
-
protected getUnusedBalanceAPY(): Promise<{
|
|
1331
|
-
apy: number;
|
|
1332
|
-
weight: number;
|
|
1333
|
-
}>;
|
|
1334
|
-
private computeAPY;
|
|
1335
|
-
/**
|
|
1336
|
-
* Calculates the total TVL of the strategy.
|
|
1337
|
-
* @returns Object containing the total amount in token units and USD value
|
|
1338
|
-
*/
|
|
1339
|
-
getTVL(): Promise<{
|
|
1340
|
-
tokenInfo: TokenInfo;
|
|
1341
|
-
amount: Web3Number;
|
|
1342
|
-
usdValue: number;
|
|
1343
|
-
}>;
|
|
1344
|
-
getUnusedBalance(): Promise<SingleTokenInfo>;
|
|
1345
|
-
protected getVesuAUM(adapter: VesuAdapter): Promise<Web3Number>;
|
|
1346
2125
|
getPrevAUM(): Promise<Web3Number>;
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
prevAum: Web3Number;
|
|
1350
|
-
splits: {
|
|
1351
|
-
id: string;
|
|
1352
|
-
aum: Web3Number;
|
|
1353
|
-
}[];
|
|
1354
|
-
}>;
|
|
1355
|
-
protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
|
|
1356
|
-
getVesuAdapters(): VesuAdapter[];
|
|
1357
|
-
getVesuPositions(blockNumber?: BlockIdentifier): Promise<VaultPosition[]>;
|
|
1358
|
-
getVaultPositions(): Promise<VaultPosition[]>;
|
|
1359
|
-
getSetManagerCall(strategist: ContractAddr, root?: string): Call;
|
|
1360
|
-
getManageCall(proofIds: string[], manageCalls: ManageCall[]): Call;
|
|
1361
|
-
getVesuModifyPositionCalls(params: {
|
|
1362
|
-
isLeg1: boolean;
|
|
1363
|
-
isDeposit: boolean;
|
|
1364
|
-
depositAmount: Web3Number;
|
|
1365
|
-
debtAmount: Web3Number;
|
|
1366
|
-
}): UniversalManageCall[];
|
|
1367
|
-
getTag(): string;
|
|
1368
|
-
/**
|
|
1369
|
-
* Gets LST APR for the strategy's underlying asset from Endur API
|
|
1370
|
-
* @returns Promise<number> The LST APR (not divided by 1e18)
|
|
1371
|
-
*/
|
|
1372
|
-
getLSTAPR(address: ContractAddr): Promise<number>;
|
|
1373
|
-
getVesuHealthFactors(blockNumber?: BlockIdentifier): Promise<number[]>;
|
|
1374
|
-
computeRebalanceConditionAndReturnCalls(): Promise<Call[]>;
|
|
1375
|
-
private getNewHealthFactor;
|
|
1376
|
-
/**
|
|
1377
|
-
*
|
|
1378
|
-
* @param vesuAdapter
|
|
1379
|
-
* @param currentHf
|
|
1380
|
-
* @param isDeposit if true, attempt by adding collateral, else by repaying
|
|
1381
|
-
* @returns
|
|
1382
|
-
*/
|
|
1383
|
-
private getLegRebalanceAmount;
|
|
1384
|
-
getVesuModifyPositionCall(params: {
|
|
1385
|
-
isDeposit: boolean;
|
|
1386
|
-
leg1DepositAmount: Web3Number;
|
|
1387
|
-
}): Promise<Call>;
|
|
1388
|
-
getBringLiquidityCall(params: {
|
|
1389
|
-
amount: Web3Number;
|
|
1390
|
-
}): Promise<Call>;
|
|
1391
|
-
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
1392
|
-
getHarvestCall(): Promise<{
|
|
1393
|
-
call: Call;
|
|
1394
|
-
reward: Web3Number;
|
|
1395
|
-
tokenInfo: TokenInfo;
|
|
1396
|
-
}>;
|
|
1397
|
-
getRebalanceCall(params: {
|
|
1398
|
-
isLeg1toLeg2: boolean;
|
|
1399
|
-
amount: Web3Number;
|
|
1400
|
-
}): Promise<Call>;
|
|
1401
|
-
}
|
|
1402
|
-
declare enum UNIVERSAL_MANAGE_IDS {
|
|
1403
|
-
FLASH_LOAN = "flash_loan_init",
|
|
1404
|
-
VESU_LEG1 = "vesu_leg1",
|
|
1405
|
-
VESU_LEG2 = "vesu_leg2",
|
|
1406
|
-
APPROVE_TOKEN1 = "approve_token1",
|
|
1407
|
-
APPROVE_TOKEN2 = "approve_token2",
|
|
1408
|
-
APPROVE_BRING_LIQUIDITY = "approve_bring_liquidity",
|
|
1409
|
-
BRING_LIQUIDITY = "bring_liquidity",
|
|
1410
|
-
DEFISPRING_REWARDS = "defispring_rewards",
|
|
1411
|
-
APPROVE_SWAP_TOKEN1 = "approve_swap_token1",
|
|
1412
|
-
AVNU_SWAP_REWARDS = "avnu_swap_rewards"
|
|
1413
|
-
}
|
|
1414
|
-
declare enum UNIVERSAL_ADAPTERS {
|
|
1415
|
-
COMMON = "common_adapter",
|
|
1416
|
-
VESU_LEG1 = "vesu_leg1_adapter",
|
|
1417
|
-
VESU_LEG2 = "vesu_leg2_adapter"
|
|
2126
|
+
maxDepositables(): Promise<PositionInfo[]>;
|
|
2127
|
+
maxWithdrawables(): Promise<PositionInfo[]>;
|
|
1418
2128
|
}
|
|
1419
|
-
declare function getContractDetails(settings: UniversalStrategySettings): {
|
|
1420
|
-
address: ContractAddr;
|
|
1421
|
-
name: string;
|
|
1422
|
-
}[];
|
|
1423
|
-
declare const UniversalStrategies: IStrategyMetadata<UniversalStrategySettings>[];
|
|
1424
2129
|
|
|
1425
2130
|
interface HyperLSTStrategySettings extends UniversalStrategySettings {
|
|
1426
2131
|
borrowable_assets: TokenInfo[];
|
|
1427
2132
|
underlyingToken: TokenInfo;
|
|
2133
|
+
quoteAmountToFetchPrice: Web3Number;
|
|
2134
|
+
targetHealthFactor: number;
|
|
2135
|
+
minHealthFactor: number;
|
|
2136
|
+
aumOracle: ContractAddr;
|
|
1428
2137
|
}
|
|
1429
|
-
declare class UniversalLstMultiplierStrategy extends
|
|
2138
|
+
declare class UniversalLstMultiplierStrategy<S extends HyperLSTStrategySettings> extends SVKStrategy<S> {
|
|
1430
2139
|
private quoteAmountToFetchPrice;
|
|
1431
|
-
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<
|
|
1432
|
-
asset(): TokenInfo;
|
|
2140
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
|
|
1433
2141
|
getTag(): string;
|
|
1434
|
-
getVesuSameTokenAdapter():
|
|
1435
|
-
getVesuAdapters():
|
|
1436
|
-
protected getRewardsAUM(prevAum: Web3Number): Promise<Web3Number>;
|
|
1437
|
-
getLSTDexPrice(): Promise<number>;
|
|
1438
|
-
getAvnuSwapMultiplyCall(params: {
|
|
1439
|
-
isDeposit: boolean;
|
|
1440
|
-
leg1DepositAmount: Web3Number;
|
|
1441
|
-
}): Promise<{
|
|
1442
|
-
call: Call | undefined;
|
|
1443
|
-
vesuAdapter: VesuAdapter;
|
|
1444
|
-
}>;
|
|
1445
|
-
_getAvnuDepositSwapLegCall(params: {
|
|
1446
|
-
isDeposit: boolean;
|
|
1447
|
-
leg1DepositAmount: Web3Number;
|
|
1448
|
-
minHF: number;
|
|
1449
|
-
vesuAdapter: VesuAdapter;
|
|
1450
|
-
}): Promise<Call | undefined>;
|
|
1451
|
-
getLSTMultiplierRebalanceCall(): Promise<{
|
|
1452
|
-
shouldRebalance: boolean;
|
|
1453
|
-
manageCalls: {
|
|
1454
|
-
vesuAdapter: VesuAdapter;
|
|
1455
|
-
manageCall: Call;
|
|
1456
|
-
}[];
|
|
1457
|
-
}>;
|
|
1458
|
-
_getLSTMultiplierRebalanceCall(vesuAdapter: VesuAdapter): Promise<{
|
|
1459
|
-
shouldRebalance: boolean;
|
|
1460
|
-
manageCall: Call | undefined;
|
|
1461
|
-
}>;
|
|
1462
|
-
protected getVesuAUM(adapter: VesuAdapter): Promise<Web3Number>;
|
|
1463
|
-
private _getMinOutputAmountLSTBuy;
|
|
1464
|
-
private _getMinOutputAmountLSTSell;
|
|
2142
|
+
getVesuSameTokenAdapter(): VesuMultiplyAdapter;
|
|
2143
|
+
getVesuAdapters(): VesuMultiplyAdapter[];
|
|
1465
2144
|
/**
|
|
1466
2145
|
* Uses vesu's multiple call to create leverage on LST
|
|
1467
2146
|
* Deposit amount is in LST
|
|
1468
2147
|
* @param params
|
|
1469
2148
|
*/
|
|
1470
|
-
|
|
2149
|
+
getFundManagementCall(params: {
|
|
1471
2150
|
isDeposit: boolean;
|
|
1472
2151
|
leg1DepositAmount: Web3Number;
|
|
1473
|
-
|
|
1474
|
-
}): Promise<Call[]>;
|
|
2152
|
+
}): Promise<Call[] | null>;
|
|
1475
2153
|
getLSTUnderlyingTokenInfo(): TokenInfo;
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
maxBorrowables: {
|
|
1481
|
-
amount: Web3Number;
|
|
1482
|
-
dexSwappableAmount: Web3Number;
|
|
1483
|
-
maxBorrowableAmount: Web3Number;
|
|
1484
|
-
borrowableAsset: TokenInfo;
|
|
1485
|
-
}[];
|
|
2154
|
+
getAUM(): Promise<{
|
|
2155
|
+
net: SingleTokenInfo;
|
|
2156
|
+
prevAum: Web3Number;
|
|
2157
|
+
splits: PositionInfo[];
|
|
1486
2158
|
}>;
|
|
1487
|
-
|
|
1488
|
-
|
|
2159
|
+
}
|
|
2160
|
+
declare const AUDIT_URL = "https://docs.troves.fi/p/security#starknet-vault-kit";
|
|
2161
|
+
declare function getFAQs(lstSymbol: string, underlyingSymbol: string, isLST: boolean): FAQ[];
|
|
2162
|
+
declare const _riskFactor: RiskFactor[];
|
|
2163
|
+
declare function getInvestmentSteps(lstSymbol: string, underlyingSymbol: string): string[];
|
|
2164
|
+
declare const HyperLSTStrategies: IStrategyMetadata<HyperLSTStrategySettings>[];
|
|
2165
|
+
|
|
2166
|
+
declare abstract class Operations {
|
|
2167
|
+
abstract shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<Call[]>;
|
|
2168
|
+
abstract shouldInvest(): Promise<{
|
|
2169
|
+
shouldInvest: boolean;
|
|
2170
|
+
vesuAmount: Web3Number;
|
|
2171
|
+
extendedAmount: Web3Number;
|
|
2172
|
+
extendedLeverage: number;
|
|
2173
|
+
vesuLeverage: number;
|
|
2174
|
+
}>;
|
|
2175
|
+
abstract moveAssets(params: {
|
|
2176
|
+
from: string;
|
|
2177
|
+
to: string;
|
|
1489
2178
|
amount: Web3Number;
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
2179
|
+
}, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<{
|
|
2180
|
+
calls: Call[];
|
|
2181
|
+
status: boolean;
|
|
1493
2182
|
}>;
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
*/
|
|
1498
|
-
getLSTAPR(_address: ContractAddr): Promise<number>;
|
|
1499
|
-
netAPY(): Promise<{
|
|
1500
|
-
net: number;
|
|
1501
|
-
splits: {
|
|
1502
|
-
apy: number;
|
|
1503
|
-
id: string;
|
|
1504
|
-
}[];
|
|
2183
|
+
abstract handleDeposit(): Promise<{
|
|
2184
|
+
extendedAmountInBTC: Web3Number;
|
|
2185
|
+
calls: Call[];
|
|
1505
2186
|
}>;
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
protected getUnusedBalanceAPY(): Promise<{
|
|
1510
|
-
apy: number;
|
|
1511
|
-
weight: number;
|
|
2187
|
+
abstract handleWithdraw(amount: Web3Number): Promise<{
|
|
2188
|
+
calls: Call[];
|
|
2189
|
+
status: boolean;
|
|
1512
2190
|
}>;
|
|
1513
|
-
getLSTExchangeRate(): Promise<number>;
|
|
1514
|
-
/**
|
|
1515
|
-
*
|
|
1516
|
-
* @param params marginAmount is in LST, debtAmount is in underlying
|
|
1517
|
-
*/
|
|
1518
|
-
getModifyLeverCall(params: {
|
|
1519
|
-
marginAmount: Web3Number;
|
|
1520
|
-
debtAmount: Web3Number;
|
|
1521
|
-
lstDexPriceInUnderlying: number;
|
|
1522
|
-
isIncrease: boolean;
|
|
1523
|
-
maxEkuboPriceImpact: number;
|
|
1524
|
-
}): Promise<Call[]>;
|
|
1525
2191
|
}
|
|
1526
|
-
|
|
2192
|
+
|
|
2193
|
+
interface VesuExtendedStrategySettings extends UniversalStrategySettings {
|
|
2194
|
+
underlyingToken: TokenInfo;
|
|
2195
|
+
borrowable_assets: TokenInfo[];
|
|
2196
|
+
targetHealthFactor: number;
|
|
2197
|
+
quoteAmountToFetchPrice: Web3Number;
|
|
2198
|
+
minHealthFactor: number;
|
|
2199
|
+
aumOracle: ContractAddr;
|
|
2200
|
+
minimumWBTCDifferenceForAvnuSwap: number;
|
|
2201
|
+
}
|
|
2202
|
+
declare class VesuExtendedMultiplierStrategy<S extends VesuExtendedStrategySettings> extends SVKStrategy<S> implements Operations {
|
|
2203
|
+
constructor(config: IConfig, pricer: PricerBase, metadata: IStrategyMetadata<S>);
|
|
2204
|
+
getTag(): string;
|
|
2205
|
+
getAssetPrices(): Promise<{
|
|
2206
|
+
collateralPrice: PriceInfo;
|
|
2207
|
+
debtPrice: PriceInfo;
|
|
2208
|
+
}>;
|
|
2209
|
+
getUnusedBalanceUSDCE(): Promise<SingleTokenInfo>;
|
|
2210
|
+
getUnusedBalanceWBTC(): Promise<SingleTokenInfo>;
|
|
2211
|
+
getVesuAdapter(): Promise<VesuMultiplyAdapter | null>;
|
|
2212
|
+
getAvnuAdapter(): Promise<AvnuAdapter | null>;
|
|
2213
|
+
getExtendedAdapter(): Promise<ExtendedAdapter | null>;
|
|
2214
|
+
moveAssetsToVaultAllocator(amount: Web3Number, extendedAdapter: ExtendedAdapter): Promise<Call[]>;
|
|
2215
|
+
shouldInvest(): Promise<{
|
|
2216
|
+
shouldInvest: boolean;
|
|
2217
|
+
vesuAmount: Web3Number;
|
|
2218
|
+
extendedAmount: Web3Number;
|
|
2219
|
+
extendedLeverage: number;
|
|
2220
|
+
collateralPrice: number;
|
|
2221
|
+
debtPrice: number;
|
|
2222
|
+
vesuLeverage: number;
|
|
2223
|
+
}>;
|
|
2224
|
+
shouldMoveAssets(extendedAmount: Web3Number, vesuAmount: Web3Number): Promise<Call[]>;
|
|
2225
|
+
moveAssets(params: {
|
|
2226
|
+
amount: Web3Number;
|
|
2227
|
+
from: string;
|
|
2228
|
+
to: string;
|
|
2229
|
+
}, extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter): Promise<{
|
|
2230
|
+
calls: Call[];
|
|
2231
|
+
status: boolean;
|
|
2232
|
+
}>;
|
|
2233
|
+
handleDeposit(): Promise<{
|
|
2234
|
+
extendedAmountInBTC: Web3Number;
|
|
2235
|
+
calls: Call[];
|
|
2236
|
+
}>;
|
|
2237
|
+
checkPriceDifferenceBetweenAvnuAndExtended(extendedAdapter: ExtendedAdapter, vesuAdapter: VesuMultiplyAdapter, avnuAdapter: AvnuAdapter): Promise<boolean>;
|
|
2238
|
+
handleWithdraw(amount: Web3Number): Promise<{
|
|
2239
|
+
calls: Call[];
|
|
2240
|
+
status: boolean;
|
|
2241
|
+
}>;
|
|
2242
|
+
getAUM(): Promise<{
|
|
2243
|
+
net: SingleTokenInfo;
|
|
2244
|
+
prevAum: Web3Number;
|
|
2245
|
+
splits: PositionInfo[];
|
|
2246
|
+
}>;
|
|
2247
|
+
}
|
|
2248
|
+
declare const VesuExtendedTestStrategies: (extendedBackendUrl: string, extendedApiKey: string, vaultIdExtended: number) => IStrategyMetadata<VesuExtendedStrategySettings>[];
|
|
2249
|
+
|
|
2250
|
+
declare const AddressesConfig: {
|
|
2251
|
+
readonly tokens: {
|
|
2252
|
+
readonly USDC: {
|
|
2253
|
+
readonly address: "0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8";
|
|
2254
|
+
readonly decimals: 6;
|
|
2255
|
+
};
|
|
2256
|
+
readonly WBTC: {
|
|
2257
|
+
readonly address: "0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac";
|
|
2258
|
+
readonly decimals: 8;
|
|
2259
|
+
};
|
|
2260
|
+
};
|
|
2261
|
+
readonly contracts: {
|
|
2262
|
+
readonly EXTENDED: "0x062da0780fae50d68cecaa5a051606dc21217ba290969b302db4dd99d2e9b470";
|
|
2263
|
+
readonly MULTIPLY: "0x07964760e90baa28841ec94714151e03fbc13321797e68a874e88f27c9d58513";
|
|
2264
|
+
};
|
|
2265
|
+
readonly wallet: {
|
|
2266
|
+
readonly address: string;
|
|
2267
|
+
};
|
|
2268
|
+
};
|
|
2269
|
+
declare const ExtendedConfig: {
|
|
2270
|
+
readonly baseUrl: string;
|
|
2271
|
+
readonly marketName: "BTC-USD";
|
|
2272
|
+
readonly maintenanceMargin: 0.01;
|
|
2273
|
+
readonly precision: 5;
|
|
2274
|
+
readonly fees: number;
|
|
2275
|
+
readonly minPositionSize: 0.0001;
|
|
2276
|
+
};
|
|
2277
|
+
declare const VesuConfig: {
|
|
2278
|
+
readonly poolId: "0x02eef0c13b10b487ea5916b54c0a7f98ec43fb3048f60fdeedaf5b08f6f88aaf";
|
|
2279
|
+
readonly maxLtv: 0.8428;
|
|
2280
|
+
readonly maxLiquidationRatio: 0.86;
|
|
2281
|
+
readonly targetHealthFactor: number;
|
|
2282
|
+
readonly ekubo: {
|
|
2283
|
+
readonly endpoint: "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_FROM_ADDRESS}}/{{TOKEN_TO_ADDRESS}}";
|
|
2284
|
+
readonly priceMaxSlippage: number;
|
|
2285
|
+
};
|
|
2286
|
+
readonly avnu: {
|
|
2287
|
+
readonly api: "https://starknet.api.avnu.fi/swap/v2/quotes";
|
|
2288
|
+
};
|
|
2289
|
+
readonly minDebtForVesuRebalacing: number;
|
|
2290
|
+
};
|
|
2291
|
+
declare const AbisConfig: {
|
|
2292
|
+
readonly vesu: {
|
|
2293
|
+
readonly multiply: ({
|
|
2294
|
+
type: string;
|
|
2295
|
+
name: string;
|
|
2296
|
+
interface_name: string;
|
|
2297
|
+
members?: undefined;
|
|
2298
|
+
items?: undefined;
|
|
2299
|
+
variants?: undefined;
|
|
2300
|
+
inputs?: undefined;
|
|
2301
|
+
kind?: undefined;
|
|
2302
|
+
} | {
|
|
2303
|
+
type: string;
|
|
2304
|
+
name: string;
|
|
2305
|
+
members: {
|
|
2306
|
+
name: string;
|
|
2307
|
+
type: string;
|
|
2308
|
+
}[];
|
|
2309
|
+
interface_name?: undefined;
|
|
2310
|
+
items?: undefined;
|
|
2311
|
+
variants?: undefined;
|
|
2312
|
+
inputs?: undefined;
|
|
2313
|
+
kind?: undefined;
|
|
2314
|
+
} | {
|
|
2315
|
+
type: string;
|
|
2316
|
+
name: string;
|
|
2317
|
+
items: {
|
|
2318
|
+
type: string;
|
|
2319
|
+
name: string;
|
|
2320
|
+
inputs: {
|
|
2321
|
+
name: string;
|
|
2322
|
+
type: string;
|
|
2323
|
+
}[];
|
|
2324
|
+
outputs: {
|
|
2325
|
+
type: string;
|
|
2326
|
+
}[];
|
|
2327
|
+
state_mutability: string;
|
|
2328
|
+
}[];
|
|
2329
|
+
interface_name?: undefined;
|
|
2330
|
+
members?: undefined;
|
|
2331
|
+
variants?: undefined;
|
|
2332
|
+
inputs?: undefined;
|
|
2333
|
+
kind?: undefined;
|
|
2334
|
+
} | {
|
|
2335
|
+
type: string;
|
|
2336
|
+
name: string;
|
|
2337
|
+
variants: {
|
|
2338
|
+
name: string;
|
|
2339
|
+
type: string;
|
|
2340
|
+
}[];
|
|
2341
|
+
interface_name?: undefined;
|
|
2342
|
+
members?: undefined;
|
|
2343
|
+
items?: undefined;
|
|
2344
|
+
inputs?: undefined;
|
|
2345
|
+
kind?: undefined;
|
|
2346
|
+
} | {
|
|
2347
|
+
type: string;
|
|
2348
|
+
name: string;
|
|
2349
|
+
inputs: {
|
|
2350
|
+
name: string;
|
|
2351
|
+
type: string;
|
|
2352
|
+
}[];
|
|
2353
|
+
interface_name?: undefined;
|
|
2354
|
+
members?: undefined;
|
|
2355
|
+
items?: undefined;
|
|
2356
|
+
variants?: undefined;
|
|
2357
|
+
kind?: undefined;
|
|
2358
|
+
} | {
|
|
2359
|
+
type: string;
|
|
2360
|
+
name: string;
|
|
2361
|
+
kind: string;
|
|
2362
|
+
members: {
|
|
2363
|
+
name: string;
|
|
2364
|
+
type: string;
|
|
2365
|
+
kind: string;
|
|
2366
|
+
}[];
|
|
2367
|
+
interface_name?: undefined;
|
|
2368
|
+
items?: undefined;
|
|
2369
|
+
variants?: undefined;
|
|
2370
|
+
inputs?: undefined;
|
|
2371
|
+
} | {
|
|
2372
|
+
type: string;
|
|
2373
|
+
name: string;
|
|
2374
|
+
kind: string;
|
|
2375
|
+
variants: {
|
|
2376
|
+
name: string;
|
|
2377
|
+
type: string;
|
|
2378
|
+
kind: string;
|
|
2379
|
+
}[];
|
|
2380
|
+
interface_name?: undefined;
|
|
2381
|
+
members?: undefined;
|
|
2382
|
+
items?: undefined;
|
|
2383
|
+
inputs?: undefined;
|
|
2384
|
+
})[];
|
|
2385
|
+
readonly pool: ({
|
|
2386
|
+
type: string;
|
|
2387
|
+
name: string;
|
|
2388
|
+
interface_name: string;
|
|
2389
|
+
members?: undefined;
|
|
2390
|
+
variants?: undefined;
|
|
2391
|
+
items?: undefined;
|
|
2392
|
+
inputs?: undefined;
|
|
2393
|
+
kind?: undefined;
|
|
2394
|
+
} | {
|
|
2395
|
+
type: string;
|
|
2396
|
+
name: string;
|
|
2397
|
+
members: {
|
|
2398
|
+
name: string;
|
|
2399
|
+
type: string;
|
|
2400
|
+
}[];
|
|
2401
|
+
interface_name?: undefined;
|
|
2402
|
+
variants?: undefined;
|
|
2403
|
+
items?: undefined;
|
|
2404
|
+
inputs?: undefined;
|
|
2405
|
+
kind?: undefined;
|
|
2406
|
+
} | {
|
|
2407
|
+
type: string;
|
|
2408
|
+
name: string;
|
|
2409
|
+
variants: {
|
|
2410
|
+
name: string;
|
|
2411
|
+
type: string;
|
|
2412
|
+
}[];
|
|
2413
|
+
interface_name?: undefined;
|
|
2414
|
+
members?: undefined;
|
|
2415
|
+
items?: undefined;
|
|
2416
|
+
inputs?: undefined;
|
|
2417
|
+
kind?: undefined;
|
|
2418
|
+
} | {
|
|
2419
|
+
type: string;
|
|
2420
|
+
name: string;
|
|
2421
|
+
items: {
|
|
2422
|
+
type: string;
|
|
2423
|
+
name: string;
|
|
2424
|
+
inputs: {
|
|
2425
|
+
name: string;
|
|
2426
|
+
type: string;
|
|
2427
|
+
}[];
|
|
2428
|
+
outputs: {
|
|
2429
|
+
type: string;
|
|
2430
|
+
}[];
|
|
2431
|
+
state_mutability: string;
|
|
2432
|
+
}[];
|
|
2433
|
+
interface_name?: undefined;
|
|
2434
|
+
members?: undefined;
|
|
2435
|
+
variants?: undefined;
|
|
2436
|
+
inputs?: undefined;
|
|
2437
|
+
kind?: undefined;
|
|
2438
|
+
} | {
|
|
2439
|
+
type: string;
|
|
2440
|
+
name: string;
|
|
2441
|
+
inputs: {
|
|
2442
|
+
name: string;
|
|
2443
|
+
type: string;
|
|
2444
|
+
}[];
|
|
2445
|
+
interface_name?: undefined;
|
|
2446
|
+
members?: undefined;
|
|
2447
|
+
variants?: undefined;
|
|
2448
|
+
items?: undefined;
|
|
2449
|
+
kind?: undefined;
|
|
2450
|
+
} | {
|
|
2451
|
+
type: string;
|
|
2452
|
+
name: string;
|
|
2453
|
+
kind: string;
|
|
2454
|
+
members: {
|
|
2455
|
+
name: string;
|
|
2456
|
+
type: string;
|
|
2457
|
+
kind: string;
|
|
2458
|
+
}[];
|
|
2459
|
+
interface_name?: undefined;
|
|
2460
|
+
variants?: undefined;
|
|
2461
|
+
items?: undefined;
|
|
2462
|
+
inputs?: undefined;
|
|
2463
|
+
} | {
|
|
2464
|
+
type: string;
|
|
2465
|
+
name: string;
|
|
2466
|
+
kind: string;
|
|
2467
|
+
variants: {
|
|
2468
|
+
name: string;
|
|
2469
|
+
type: string;
|
|
2470
|
+
kind: string;
|
|
2471
|
+
}[];
|
|
2472
|
+
interface_name?: undefined;
|
|
2473
|
+
members?: undefined;
|
|
2474
|
+
items?: undefined;
|
|
2475
|
+
inputs?: undefined;
|
|
2476
|
+
})[];
|
|
2477
|
+
};
|
|
2478
|
+
readonly extended: {
|
|
2479
|
+
readonly contract: ({
|
|
2480
|
+
type: string;
|
|
2481
|
+
name: string;
|
|
2482
|
+
interface_name: string;
|
|
2483
|
+
members?: undefined;
|
|
2484
|
+
variants?: undefined;
|
|
2485
|
+
items?: undefined;
|
|
2486
|
+
inputs?: undefined;
|
|
2487
|
+
kind?: undefined;
|
|
2488
|
+
} | {
|
|
2489
|
+
type: string;
|
|
2490
|
+
name: string;
|
|
2491
|
+
members: {
|
|
2492
|
+
name: string;
|
|
2493
|
+
type: string;
|
|
2494
|
+
}[];
|
|
2495
|
+
interface_name?: undefined;
|
|
2496
|
+
variants?: undefined;
|
|
2497
|
+
items?: undefined;
|
|
2498
|
+
inputs?: undefined;
|
|
2499
|
+
kind?: undefined;
|
|
2500
|
+
} | {
|
|
2501
|
+
type: string;
|
|
2502
|
+
name: string;
|
|
2503
|
+
variants: {
|
|
2504
|
+
name: string;
|
|
2505
|
+
type: string;
|
|
2506
|
+
}[];
|
|
2507
|
+
interface_name?: undefined;
|
|
2508
|
+
members?: undefined;
|
|
2509
|
+
items?: undefined;
|
|
2510
|
+
inputs?: undefined;
|
|
2511
|
+
kind?: undefined;
|
|
2512
|
+
} | {
|
|
2513
|
+
type: string;
|
|
2514
|
+
name: string;
|
|
2515
|
+
items: {
|
|
2516
|
+
type: string;
|
|
2517
|
+
name: string;
|
|
2518
|
+
inputs: {
|
|
2519
|
+
name: string;
|
|
2520
|
+
type: string;
|
|
2521
|
+
}[];
|
|
2522
|
+
outputs: {
|
|
2523
|
+
type: string;
|
|
2524
|
+
}[];
|
|
2525
|
+
state_mutability: string;
|
|
2526
|
+
}[];
|
|
2527
|
+
interface_name?: undefined;
|
|
2528
|
+
members?: undefined;
|
|
2529
|
+
variants?: undefined;
|
|
2530
|
+
inputs?: undefined;
|
|
2531
|
+
kind?: undefined;
|
|
2532
|
+
} | {
|
|
2533
|
+
type: string;
|
|
2534
|
+
name: string;
|
|
2535
|
+
inputs: {
|
|
2536
|
+
name: string;
|
|
2537
|
+
type: string;
|
|
2538
|
+
}[];
|
|
2539
|
+
interface_name?: undefined;
|
|
2540
|
+
members?: undefined;
|
|
2541
|
+
variants?: undefined;
|
|
2542
|
+
items?: undefined;
|
|
2543
|
+
kind?: undefined;
|
|
2544
|
+
} | {
|
|
2545
|
+
type: string;
|
|
2546
|
+
name: string;
|
|
2547
|
+
kind: string;
|
|
2548
|
+
members: {
|
|
2549
|
+
name: string;
|
|
2550
|
+
type: string;
|
|
2551
|
+
kind: string;
|
|
2552
|
+
}[];
|
|
2553
|
+
interface_name?: undefined;
|
|
2554
|
+
variants?: undefined;
|
|
2555
|
+
items?: undefined;
|
|
2556
|
+
inputs?: undefined;
|
|
2557
|
+
} | {
|
|
2558
|
+
type: string;
|
|
2559
|
+
name: string;
|
|
2560
|
+
kind: string;
|
|
2561
|
+
variants: {
|
|
2562
|
+
name: string;
|
|
2563
|
+
type: string;
|
|
2564
|
+
kind: string;
|
|
2565
|
+
}[];
|
|
2566
|
+
interface_name?: undefined;
|
|
2567
|
+
members?: undefined;
|
|
2568
|
+
items?: undefined;
|
|
2569
|
+
inputs?: undefined;
|
|
2570
|
+
})[];
|
|
2571
|
+
};
|
|
2572
|
+
};
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* Function to return formatted amount to BigInt
|
|
2576
|
+
* Converts a decimal amount to the proper format for blockchain transactions
|
|
2577
|
+
* @param {number} amount - The decimal amount to convert
|
|
2578
|
+
* @param {number} fromTokenDecimals - The decimal precision of the token
|
|
2579
|
+
* @returns {string} The formatted amount as a hexadecimal string
|
|
2580
|
+
*/
|
|
2581
|
+
declare const returnFormattedAmount: (amount: number, toTokenDecimals: number) => string;
|
|
2582
|
+
/**
|
|
2583
|
+
* calculates the amount to distribute to Extend and Vesu
|
|
2584
|
+
* Determines how much to allocate to each platform based on leverage calculations
|
|
2585
|
+
* @param {number} amount - The total amount to distribute
|
|
2586
|
+
* @returns {object} Object containing avnu_amount, extended_amount, and extended_leverage
|
|
2587
|
+
*/
|
|
2588
|
+
declare const calculateAmountDistribution: (amount: number, client: ExtendedWrapper, marketName: string, collateralPrice: number, debtPrice: number, collateralUnits: Web3Number, extendedPosition: Position[] | null) => Promise<{
|
|
2589
|
+
vesu_amount: Web3Number;
|
|
2590
|
+
extended_amount: Web3Number;
|
|
2591
|
+
extended_leverage: number;
|
|
2592
|
+
vesu_leverage: number;
|
|
2593
|
+
}>;
|
|
2594
|
+
/**
|
|
2595
|
+
* calculate the amount distribution for withdrawal
|
|
2596
|
+
* @param amount - The amount to withdraw
|
|
2597
|
+
* @param client - The client
|
|
2598
|
+
* @param marketName - The market name
|
|
2599
|
+
* @returns {object} Object containing avnu_amount and extended_amount
|
|
2600
|
+
*/
|
|
2601
|
+
declare const calculateAmountDistributionForWithdrawal: (amountInUsdc: Web3Number, collateralPrice: number, collateralUnits: Web3Number, extendedPosition: Position[] | null) => Promise<{
|
|
2602
|
+
vesu_amount: Web3Number;
|
|
2603
|
+
extended_amount: Web3Number;
|
|
2604
|
+
extended_leverage: number;
|
|
2605
|
+
vesu_leverage: number;
|
|
2606
|
+
} | null>;
|
|
2607
|
+
/**
|
|
2608
|
+
* calculate the leverage required for Avnu
|
|
2609
|
+
* calculates the optimal leverage for Avnu based on LTV ratios and price drop protection
|
|
2610
|
+
* @returns {number} The calculated leverage value
|
|
2611
|
+
*/
|
|
2612
|
+
declare const calculateVesuLeverage: () => number;
|
|
2613
|
+
/**
|
|
2614
|
+
* calculate leverage for extended
|
|
2615
|
+
* calculates the maximum safe leverage for Extended based on maintenance margin and price drop protection
|
|
2616
|
+
* @returns {number} The calculated leverage value
|
|
2617
|
+
*/
|
|
2618
|
+
declare const calculateExtendedLevergae: () => number;
|
|
2619
|
+
/**
|
|
2620
|
+
* calculates the debt amount for leverage operations
|
|
2621
|
+
* Determines how much debt to add or remove based on collateral changes and target health factor
|
|
2622
|
+
* @param {Web3Number} collateralAmount - Current collateral amount
|
|
2623
|
+
* @param {Web3Number} debtAmount - Current debt amount
|
|
2624
|
+
* @param {number} debtPrice - Current price of the debt token
|
|
2625
|
+
* @param {number} maxLtv - Maximum loan-to-value ratio (default: MAX_LTV_BTC_USDC)
|
|
2626
|
+
* @param {number} addedAmount - Amount being added to collateral
|
|
2627
|
+
* @param {number} collateralPrice - Current price of the collateral token
|
|
2628
|
+
* @param {boolean} isDeposit - Whether this is a deposit (true) or withdrawal (false)
|
|
2629
|
+
* @returns {object} Object containing deltadebtAmountUnits and isIncrease flag
|
|
2630
|
+
*/
|
|
2631
|
+
declare const calculateDebtAmount: (collateralAmount: Web3Number, debtAmount: Web3Number, debtPrice: number, maxLtv: number | undefined, addedAmount: Web3Number, // this is in btc
|
|
2632
|
+
collateralPrice: number, isDeposit: boolean) => {
|
|
2633
|
+
deltadebtAmountUnits: Web3Number;
|
|
2634
|
+
isIncrease: boolean;
|
|
2635
|
+
} | {
|
|
2636
|
+
deltadebtAmountUnits: null;
|
|
2637
|
+
isIncrease: null;
|
|
2638
|
+
};
|
|
2639
|
+
/**
|
|
2640
|
+
* calculate the debt amount to be repaid for withdrawal
|
|
2641
|
+
* @param debtAmount in debt units
|
|
2642
|
+
* @param collateralAmount in collateral units
|
|
2643
|
+
* @param maxLtv in percentage
|
|
2644
|
+
* @param withdrawalAmount in collateral units
|
|
2645
|
+
* @param collateralPrice in usd
|
|
2646
|
+
* @param debtPrice in usd
|
|
2647
|
+
* @returns deltadebtAmountUnits in debt units
|
|
2648
|
+
* isIncrease: true if the debt amount is increasing, false if it is decreasing
|
|
2649
|
+
*/
|
|
2650
|
+
declare const calculateDebtReductionAmountForWithdrawal: (debtAmount: Web3Number, collateralAmount: Web3Number, maxLtv: number | undefined, withdrawalAmount: Web3Number, collateralPrice: number, debtPrice: number, usdcDecimals: number) => {
|
|
2651
|
+
deltadebtAmountUnits: string;
|
|
2652
|
+
} | {
|
|
2653
|
+
deltadebtAmountUnits: null;
|
|
2654
|
+
};
|
|
2655
|
+
/**
|
|
2656
|
+
* calculate the amount to deposit on extended when incurring losses
|
|
2657
|
+
* @param client - The client
|
|
2658
|
+
* @returns The amount to deposit on extended when incurring losses
|
|
2659
|
+
*/
|
|
2660
|
+
declare const calculateAmountDepositOnExtendedWhenIncurringLosses: (client: ExtendedWrapper) => Promise<Web3Number | null>;
|
|
2661
|
+
declare const calculateExposureDelta: (exposure_extended: number, exposure_vesu: number) => number;
|
|
2662
|
+
/**
|
|
2663
|
+
* calculate the delta percentage between the current btc price and the last btc price
|
|
2664
|
+
* @param {number} btcPrice - The current btc price
|
|
2665
|
+
* @param {number} lastBtcPrice - The last btc price
|
|
2666
|
+
* @returns {number} The delta percentage
|
|
2667
|
+
*/
|
|
2668
|
+
declare const calculateBTCPriceDelta: (btcPrice: number, lastBtcPrice: number) => number;
|
|
2669
|
+
declare const calculateVesUPositionSizeGivenExtended: (extendedPositonValue: number, extendedHoldingAmount: Web3Number, collateralAmount: Web3Number, collateralPrice: number) => {
|
|
2670
|
+
vesuAmountInUsd: string;
|
|
2671
|
+
vesuAmountInBTC: Web3Number;
|
|
2672
|
+
extendedAmountInBTC: Web3Number;
|
|
2673
|
+
};
|
|
1527
2674
|
|
|
1528
2675
|
interface EkuboRouteNode {
|
|
1529
2676
|
pool_key: {
|
|
@@ -1549,7 +2696,8 @@ interface EkuboQuote {
|
|
|
1549
2696
|
declare class EkuboQuoter {
|
|
1550
2697
|
private readonly config;
|
|
1551
2698
|
ENDPOINT: string;
|
|
1552
|
-
|
|
2699
|
+
tokenMarketData: TokenMarketData;
|
|
2700
|
+
constructor(config: IConfig, pricer: PricerBase);
|
|
1553
2701
|
/**
|
|
1554
2702
|
*
|
|
1555
2703
|
* @param fromToken
|
|
@@ -1558,6 +2706,9 @@ declare class EkuboQuoter {
|
|
|
1558
2706
|
* @returns
|
|
1559
2707
|
*/
|
|
1560
2708
|
getQuote(fromToken: string, toToken: string, amount: Web3Number, retry?: number): Promise<EkuboQuote>;
|
|
2709
|
+
getDexPrice(baseToken: TokenInfo, quoteToken: TokenInfo, amount: Web3Number): Promise<number>;
|
|
2710
|
+
getLSTTrueExchangeRate(baseToken: TokenInfo, quoteToken: TokenInfo, amount: Web3Number): Promise<number>;
|
|
2711
|
+
getSwapLimitAmount(fromToken: TokenInfo, toToken: TokenInfo, amount: Web3Number, max_slippage?: number): Promise<Web3Number>;
|
|
1561
2712
|
/**
|
|
1562
2713
|
* Formats Ekubo response for Vesu multiple use
|
|
1563
2714
|
* @param quote
|
|
@@ -1618,6 +2769,9 @@ declare class LSTAPRService {
|
|
|
1618
2769
|
private static cache;
|
|
1619
2770
|
private static cacheTimestamp;
|
|
1620
2771
|
private static readonly CACHE_DURATION;
|
|
2772
|
+
static lstMapping: Record<string, TokenInfo>;
|
|
2773
|
+
static isLST(address: ContractAddr): boolean;
|
|
2774
|
+
static getUnderlyingFromLST(lstAddress: ContractAddr): TokenInfo;
|
|
1621
2775
|
/**
|
|
1622
2776
|
* Fetches LST stats from Endur API with caching
|
|
1623
2777
|
* @returns Promise<LSTStats[]> Array of LST statistics
|
|
@@ -1646,6 +2800,73 @@ declare class LSTAPRService {
|
|
|
1646
2800
|
static clearCache(): void;
|
|
1647
2801
|
}
|
|
1648
2802
|
|
|
2803
|
+
/**
|
|
2804
|
+
* Midas module for interacting with Midas API
|
|
2805
|
+
* Provides functions to get APY, price, and TVL data for Midas tokens
|
|
2806
|
+
*/
|
|
2807
|
+
declare class Midas {
|
|
2808
|
+
private static readonly CONTRACT_TO_SYMBOL;
|
|
2809
|
+
private static readonly BASE_URL;
|
|
2810
|
+
/**
|
|
2811
|
+
* Check if a contract address is supported by Midas
|
|
2812
|
+
* @param contractAddr The contract address to check
|
|
2813
|
+
* @returns True if the contract address is supported
|
|
2814
|
+
*/
|
|
2815
|
+
static isSupported(contractAddr: ContractAddr): boolean;
|
|
2816
|
+
/**
|
|
2817
|
+
* Get the Midas symbol for a given contract address
|
|
2818
|
+
* @param contractAddr The contract address to look up
|
|
2819
|
+
* @returns The Midas symbol for the contract
|
|
2820
|
+
* @throws Error if contract address is not found
|
|
2821
|
+
*/
|
|
2822
|
+
static getSymbolFromContract(contractAddr: ContractAddr): string;
|
|
2823
|
+
/**
|
|
2824
|
+
* Get APY data for all Midas tokens
|
|
2825
|
+
* @returns Object with token symbols as keys and APY values as numbers
|
|
2826
|
+
* @throws Error if API request fails
|
|
2827
|
+
*/
|
|
2828
|
+
static getAPYs(): Promise<Record<string, number>>;
|
|
2829
|
+
/**
|
|
2830
|
+
* Get APY for a specific token by contract address
|
|
2831
|
+
* @param contractAddr The contract address of the token
|
|
2832
|
+
* @returns The APY value for the token
|
|
2833
|
+
* @throws Error if contract address not found or API request fails
|
|
2834
|
+
*/
|
|
2835
|
+
static getAPY(contractAddr: ContractAddr): Promise<number>;
|
|
2836
|
+
/**
|
|
2837
|
+
* Get price data for a specific token
|
|
2838
|
+
* @param contractAddr The contract address of the token
|
|
2839
|
+
* @param timestampFrom Optional start timestamp (defaults to 30 days ago)
|
|
2840
|
+
* @param timestampTo Optional end timestamp (defaults to now)
|
|
2841
|
+
* @param environment Environment (defaults to 'mainnet')
|
|
2842
|
+
* @returns The latest price for the token
|
|
2843
|
+
* @throws Error if contract address not found or API request fails
|
|
2844
|
+
*/
|
|
2845
|
+
static getPrice(contractAddr: ContractAddr, timestampFrom?: number, timestampTo?: number, environment?: string): Promise<number>;
|
|
2846
|
+
/**
|
|
2847
|
+
* Get TVL data for all tokens
|
|
2848
|
+
* @param environment Environment (defaults to 'mainnet')
|
|
2849
|
+
* @returns Object with TVL data including totalTvl and tokenTvl
|
|
2850
|
+
* @throws Error if API request fails
|
|
2851
|
+
*/
|
|
2852
|
+
static getTVLData(environment?: string): Promise<{
|
|
2853
|
+
lastUpdatedAt: string;
|
|
2854
|
+
totalTvl: number;
|
|
2855
|
+
tokenTvl: Record<string, any>;
|
|
2856
|
+
}>;
|
|
2857
|
+
/**
|
|
2858
|
+
* Get TVL for a specific token by contract address
|
|
2859
|
+
* @param contractAddr The contract address of the token
|
|
2860
|
+
* @param environment Environment (defaults to 'mainnet')
|
|
2861
|
+
* @returns The TVL data for the token (USD and native amounts)
|
|
2862
|
+
* @throws Error if contract address not found or API request fails
|
|
2863
|
+
*/
|
|
2864
|
+
static getTVL(contractAddr: ContractAddr, environment?: string): Promise<{
|
|
2865
|
+
usd: number;
|
|
2866
|
+
native: number;
|
|
2867
|
+
} | number>;
|
|
2868
|
+
}
|
|
2869
|
+
|
|
1649
2870
|
declare class TelegramNotif {
|
|
1650
2871
|
private subscribers;
|
|
1651
2872
|
readonly bot: TelegramBot;
|
|
@@ -1709,7 +2930,6 @@ declare function executeDeployCalls(contractsInfo: DeployContractResult[], acc:
|
|
|
1709
2930
|
declare function executeTransactions(calls: Call[], acc: Account, provider: RpcProvider, remarks?: string): Promise<{
|
|
1710
2931
|
transaction_hash: string;
|
|
1711
2932
|
}>;
|
|
1712
|
-
declare function myWaitForTransaction(transaction_hash: string, provider: RpcProvider, retry?: number): Promise<boolean>;
|
|
1713
2933
|
declare const Deployer: {
|
|
1714
2934
|
getAccount: typeof getAccount;
|
|
1715
2935
|
myDeclare: typeof myDeclare;
|
|
@@ -1717,7 +2937,6 @@ declare const Deployer: {
|
|
|
1717
2937
|
prepareMultiDeployContracts: typeof prepareMultiDeployContracts;
|
|
1718
2938
|
executeDeployCalls: typeof executeDeployCalls;
|
|
1719
2939
|
executeTransactions: typeof executeTransactions;
|
|
1720
|
-
myWaitForTransaction: typeof myWaitForTransaction;
|
|
1721
2940
|
};
|
|
1722
2941
|
|
|
1723
2942
|
/**
|
|
@@ -1798,4 +3017,4 @@ declare class PasswordJsonCryptoUtil {
|
|
|
1798
3017
|
decrypt(encryptedData: string, password: string): any;
|
|
1799
3018
|
}
|
|
1800
3019
|
|
|
1801
|
-
export { APYType, AUMTypes, AVNU_EXCHANGE, AVNU_MIDDLEWARE, type AccountInfo, type AdapterLeafType, type AllAccountsStore, type ApproveCallParams, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type CLVaultStrategySettings, CommonAdapter, type CommonAdapterConfig, ContractAddr, type DecreaseLeverParams, Deployer, type DualActionAmount, type DualTokenInfo, ERC20, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type GenerateCallFn, Global, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, LSTAPRService, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, Network, PRICE_ROUTER, PasswordJsonCryptoUtil, type PositionAPY, type PositionInfo, Pragma, type PriceInfo, Pricer, PricerFromApi, PricerLST, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, Store, type StoreConfig, type SupportedPosition, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, type TokenAmount, type TokenInfo,
|
|
3020
|
+
export { type APYInfo, APYType, AUDIT_URL, AUMTypes, AVNU_EXCHANGE, AVNU_EXCHANGE_FOR_LEGACY_USDC, AVNU_LEGACY_SANITIZER, AVNU_MIDDLEWARE, AVNU_QUOTE_URL, AbisConfig, type AccountInfo, type AdapterLeafType, AddressesConfig, type AllAccountsStore, type ApiResponse, type ApproveCallParams, type AssetOperation, AssetOperationStatus, AssetOperationType, AutoCompounderSTRK, type AvnuSwapCallParams, AvnuWrapper, type Balance, BaseAdapter, type BaseAdapterConfig, BaseStrategy, type CLVaultStrategySettings, type CancelOrderRequest, CommonAdapter, type CommonAdapterConfig, ContractAddr, type CreateOrderRequest, type DecreaseLeverParams, Deployer, type DepositParams, type DualActionAmount, type DualTokenInfo, ERC20, EXTENDED_CONTRACT, EXTENDED_SANITIZER, type EkuboBounds, EkuboCLVault, EkuboCLVaultStrategies, type EkuboPoolKey, type EkuboQuote, EkuboQuoter, type EkuboRouteNode, type EkuboSplit, ExitType, ExtendedAdapter, type ExtendedAdapterConfig, type ExtendedApiResponse, ExtendedConfig, ExtendedWrapper, type ExtendedWrapperConfig, type FAQ, FatalError, type FlashloanCallParams, FlowChartColors, type FundingRate, type GenerateCallFn, Global, HyperLSTStrategies, type HyperLSTStrategySettings, type IConfig, type IInvestmentFlow, ILending, type ILendingMetadata, type ILendingPosition, type IProtocol, type IStrategyMetadata, type IncreaseLeverParams, Initializable, type L2Config, LSTAPRService, type LSTStats, type LeafAdapterFn, type LeafData, type LendingToken, type ManageCall, MarginType, type Market, type MarketStats, Midas, Network, type OpenOrder, OrderSide, OrderStatus, OrderStatusReason, OrderType, PRICE_ROUTER, PasswordJsonCryptoUtil, type PlacedOrder, type Position, type PositionAPY, type PositionAmount, type PositionHistory, type PositionInfo, PositionSide, Pragma, type PriceInfo, Pricer, PricerBase, PricerFromApi, PricerLST, PricerRedis, Protocols, type RequiredFields, type RequiredKeys, type RequiredStoreConfig, type RiskFactor, type RiskFactorConfig, RiskType, type Route, type RouteNode, SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, SenseiStrategies, SenseiVault, type SenseiVaultSettings, type SettlementSignature, type SignedWithdrawRequest, type SingleActionAmount, type SingleTokenInfo, StandardMerkleTree, type StandardMerkleTreeData, type StarkDebuggingOrderAmounts, type StarkSettlement, Store, type StoreConfig, type SupportedPosition, type Swap, type SwapInfo, TelegramGroupNotif, TelegramNotif, TimeInForce, type TokenAmount, type TokenInfo, TokenMarketData, type TradingConfig, UNIVERSAL_MANAGE_IDS, UniversalLstMultiplierStrategy, type UniversalManageCall, type UniversalStrategySettings, UnusedBalanceAdapter, type UnusedBalanceAdapterConfig, type UpdateLeverageRequest, VESU_SINGLETON, VESU_V2_MODIFY_POSITION_SANITIZER, type VaultPosition, VesuAdapter, type VesuAdapterConfig, type VesuAmount, VesuAmountDenomination, VesuAmountType, VesuConfig, type VesuDefiSpringRewardsCallParams, VesuExtendedMultiplierStrategy, type VesuExtendedStrategySettings, VesuExtendedTestStrategies, type VesuModifyDelegationCallParams, type VesuModifyPositionCallParams, VesuMultiplyAdapter, type VesuMultiplyAdapterConfig, type VesuMultiplyCallParams, VesuPools, VesuRebalance, type VesuRebalanceSettings, VesuRebalanceStrategies, VesuSupplyOnlyAdapter, type VesuSupplyOnlyAdapterConfig, Web3Number, type WithdrawParams, type WithdrawRequest, ZkLend, _riskFactor, assert, calculateAmountDepositOnExtendedWhenIncurringLosses, calculateAmountDistribution, calculateAmountDistributionForWithdrawal, calculateBTCPriceDelta, calculateDebtAmount, calculateDebtReductionAmountForWithdrawal, calculateExposureDelta, calculateExtendedLevergae, calculateVesUPositionSizeGivenExtended, calculateVesuLeverage, extensionMap, getAPIUsingHeadlessBrowser, getContractDetails, getDefaultStoreConfig, getFAQs, getInvestmentSteps, getMainnetConfig, getNoRiskTags, getRiskColor, getRiskExplaination, getTrovesEndpoint, getVesuSingletonAddress, highlightTextWithLinks, type i257, logger, returnFormattedAmount, toBigInt };
|