import { BN } from '@project-serum/anchor'; import { OpenOrders } from '@project-serum/serum'; import { PublicKey } from '@solana/web3.js'; import { I80F48, I80F48Dto } from '../numbers/I80F48.js'; import { TokenIndex, BankForHealth } from './bank.js'; import { G as Group, M as MangoAccount, H as HealthType, t as MarketIndex, S as Serum3Market, m as PerpMarket, o as PerpOrderSide, P as PerpPosition, d as Serum3Side } from '../client-239cde3c.js'; import 'big.js'; import 'bn.js'; import '../utils.js'; import '@project-serum/serum/lib/market'; import '../types.js'; import './oracle.js'; import '@switchboard-xyz/sbv2-lite'; import '../clientIxParamBuilder.js'; import '../ids.js'; import '../mango_v4.js'; declare class HealthCache { tokenInfos: TokenInfo[]; serum3Infos: Serum3Info[]; perpInfos: PerpInfo[]; constructor(tokenInfos: TokenInfo[], serum3Infos: Serum3Info[], perpInfos: PerpInfo[]); static fromMangoAccount(group: Group, mangoAccount: MangoAccount): HealthCache; static fromDto(dto: any): HealthCache; computeSerum3Reservations(healthType: HealthType): { tokenMaxReserved: I80F48[]; serum3Reserved: Serum3Reserved[]; }; health(healthType: HealthType): I80F48; perpSettleHealth(): I80F48; assets(healthType?: HealthType): I80F48; liabs(healthType?: HealthType): I80F48; healthRatio(healthType: HealthType): I80F48; findTokenInfoIndex(tokenIndex: TokenIndex): number; getOrCreateTokenInfoIndex(bank: BankForHealth): number; simHealthRatioWithTokenPositionChanges(group: Group, nativeTokenChanges: { nativeTokenAmount: I80F48; mintPk: PublicKey; }[], healthType?: HealthType): I80F48; findSerum3InfoIndex(marketIndex: MarketIndex): number; getOrCreateSerum3InfoIndex(baseBank: BankForHealth, quoteBank: BankForHealth, serum3Market: Serum3Market): number; adjustSerum3Reserved(baseBank: BankForHealth, quoteBank: BankForHealth, serum3Market: Serum3Market, reservedBaseChange: I80F48, freeBaseChange: I80F48, reservedQuoteChange: I80F48, freeQuoteChange: I80F48): void; simHealthRatioWithSerum3BidChanges(baseBank: BankForHealth, quoteBank: BankForHealth, bidNativeQuoteAmount: I80F48, serum3Market: Serum3Market, healthType?: HealthType): I80F48; simHealthRatioWithSerum3AskChanges(baseBank: BankForHealth, quoteBank: BankForHealth, askNativeBaseAmount: I80F48, serum3Market: Serum3Market, healthType?: HealthType): I80F48; findPerpInfoIndex(perpMarketIndex: number): number; getOrCreatePerpInfoIndex(perpMarket: PerpMarket): number; adjustPerpInfo(perpInfoIndex: number, price: I80F48, side: PerpOrderSide, newOrderBaseLots: BN): void; simHealthRatioWithPerpOrderChanges(perpMarket: PerpMarket, existingPerpPosition: PerpPosition, side: PerpOrderSide, baseLots: BN, price: I80F48, healthType?: HealthType): I80F48; logHealthCache(debug: string): void; private static scanRightUntilLessThan; private static findMaximum; private static binaryApproximationSearch; getMaxSwapSource(sourceBank: BankForHealth, targetBank: BankForHealth, price: I80F48): I80F48; getMaxSwapSourceForHealthRatio(sourceBank: BankForHealth, targetBank: BankForHealth, price: I80F48, minRatio: I80F48): I80F48; getMaxSwapSourceForHealth(sourceBank: BankForHealth, targetBank: BankForHealth, price: I80F48, minHealth: I80F48): I80F48; getMaxSwapSourceForHealthFn(sourceBank: BankForHealth, targetBank: BankForHealth, price: I80F48, minFnValue: I80F48, targetFn: (cache: any) => I80F48): I80F48; getMaxSerum3OrderForHealthRatio(baseBank: BankForHealth, quoteBank: BankForHealth, serum3Market: Serum3Market, side: Serum3Side, minRatio: I80F48): I80F48; getMaxPerpForHealthRatio(perpMarket: PerpMarket, price: any, side: PerpOrderSide, minRatio: I80F48): I80F48; } declare class Prices { oracle: I80F48; stable: I80F48; constructor(oracle: I80F48, stable: I80F48); liab(healthType: HealthType | undefined): I80F48; asset(healthType: HealthType | undefined): I80F48; } declare class TokenInfo { tokenIndex: TokenIndex; maintAssetWeight: I80F48; initAssetWeight: I80F48; initScaledAssetWeight: I80F48; maintLiabWeight: I80F48; initLiabWeight: I80F48; initScaledLiabWeight: I80F48; prices: Prices; balanceNative: I80F48; constructor(tokenIndex: TokenIndex, maintAssetWeight: I80F48, initAssetWeight: I80F48, initScaledAssetWeight: I80F48, maintLiabWeight: I80F48, initLiabWeight: I80F48, initScaledLiabWeight: I80F48, prices: Prices, balanceNative: I80F48); static fromDto(dto: TokenInfoDto): TokenInfo; static fromBank(bank: BankForHealth, nativeBalance?: I80F48): TokenInfo; assetWeight(healthType: HealthType): I80F48; liabWeight(healthType: HealthType): I80F48; healthContribution(healthType?: HealthType): I80F48; toString(): string; } declare class Serum3Reserved { allReservedAsBase: I80F48; allReservedAsQuote: I80F48; constructor(allReservedAsBase: I80F48, allReservedAsQuote: I80F48); } declare class Serum3Info { reservedBase: I80F48; reservedQuote: I80F48; baseIndex: number; quoteIndex: number; marketIndex: MarketIndex; constructor(reservedBase: I80F48, reservedQuote: I80F48, baseIndex: number, quoteIndex: number, marketIndex: MarketIndex); static fromDto(dto: Serum3InfoDto): Serum3Info; static emptyFromSerum3Market(serum3Market: Serum3Market, baseEntryIndex: number, quoteEntryIndex: number): Serum3Info; static fromOoModifyingTokenInfos(baseIndex: number, baseInfo: TokenInfo, quoteIndex: number, quoteInfo: TokenInfo, marketIndex: MarketIndex, oo: OpenOrders): Serum3Info; healthContribution(healthType: HealthType | undefined, tokenInfos: TokenInfo[], tokenMaxReserved: I80F48[], marketReserved: Serum3Reserved): I80F48; toString(tokenInfos: TokenInfo[], tokenMaxReserved: I80F48[], marketReserved: Serum3Reserved): string; } declare class PerpInfo { perpMarketIndex: number; maintBaseAssetWeight: I80F48; initBaseAssetWeight: I80F48; maintBaseLiabWeight: I80F48; initBaseLiabWeight: I80F48; maintOverallAssetWeight: I80F48; initOverallAssetWeight: I80F48; baseLotSize: BN; baseLots: BN; bidsBaseLots: BN; asksBaseLots: BN; quote: I80F48; prices: Prices; hasOpenOrders: boolean; constructor(perpMarketIndex: number, maintBaseAssetWeight: I80F48, initBaseAssetWeight: I80F48, maintBaseLiabWeight: I80F48, initBaseLiabWeight: I80F48, maintOverallAssetWeight: I80F48, initOverallAssetWeight: I80F48, baseLotSize: BN, baseLots: BN, bidsBaseLots: BN, asksBaseLots: BN, quote: I80F48, prices: Prices, hasOpenOrders: boolean); static fromDto(dto: PerpInfoDto): PerpInfo; static fromPerpPosition(perpMarket: PerpMarket, perpPosition: PerpPosition): PerpInfo; healthContribution(healthType: HealthType | undefined): I80F48; unweightedHealthContribution(healthType: HealthType | undefined): I80F48; static emptyFromPerpMarket(perpMarket: PerpMarket): PerpInfo; toString(): string; } declare class HealthCacheDto { tokenInfos: TokenInfoDto[]; serum3Infos: Serum3InfoDto[]; perpInfos: PerpInfoDto[]; } declare class TokenInfoDto { tokenIndex: number; maintAssetWeight: I80F48Dto; initAssetWeight: I80F48Dto; initScaledAssetWeight: I80F48Dto; maintLiabWeight: I80F48Dto; initLiabWeight: I80F48Dto; initScaledLiabWeight: I80F48Dto; prices: { oracle: I80F48Dto; stable: I80F48Dto; }; balanceNative: I80F48Dto; constructor(tokenIndex: number, maintAssetWeight: I80F48Dto, initAssetWeight: I80F48Dto, initScaledAssetWeight: I80F48Dto, maintLiabWeight: I80F48Dto, initLiabWeight: I80F48Dto, initScaledLiabWeight: I80F48Dto, prices: { oracle: I80F48Dto; stable: I80F48Dto; }, balanceNative: I80F48Dto); } declare class Serum3InfoDto { reservedBase: I80F48Dto; reservedQuote: I80F48Dto; baseIndex: number; quoteIndex: number; marketIndex: number; constructor(reservedBase: I80F48Dto, reservedQuote: I80F48Dto, baseIndex: number, quoteIndex: number); } declare class PerpInfoDto { perpMarketIndex: number; maintBaseAssetWeight: I80F48Dto; initBaseAssetWeight: I80F48Dto; maintBaseLiabWeight: I80F48Dto; initBaseLiabWeight: I80F48Dto; maintOverallAssetWeight: I80F48Dto; initOverallAssetWeight: I80F48Dto; baseLotSize: BN; baseLots: BN; bidsBaseLots: BN; asksBaseLots: BN; quote: I80F48Dto; prices: { oracle: I80F48Dto; stable: I80F48Dto; }; hasOpenOrders: boolean; } export { HealthCache, HealthCacheDto, PerpInfo, PerpInfoDto, Prices, Serum3Info, Serum3InfoDto, Serum3Reserved, TokenInfo, TokenInfoDto };