import { BN } from '@coral-xyz/anchor';
import { OpenOrders } from '@project-serum/serum';
import { PublicKey } from '@solana/web3.js';
import { I80F48 } from '../numbers/I80F48';
import { BankForHealth, TokenIndex } from './bank';
import { Group } from './group';
import { HealthType, MangoAccount, PerpPosition, Serum3Orders } from './mangoAccount';
import { PerpMarket, PerpOrderSide } from './perp';
import { MarketIndex, Serum3Market, Serum3Side } from './serum3';
export declare class HealthCache {
    tokenInfos: TokenInfo[];
    serum3Infos: Serum3Info[];
    perpInfos: PerpInfo[];
    constructor(tokenInfos: TokenInfo[], serum3Infos: Serum3Info[], perpInfos: PerpInfo[]);
    static fromMangoAccount(group: Group, mangoAccount: MangoAccount): HealthCache;
    computeSerum3Reservations(healthType: HealthType | undefined): {
        tokenMaxReserved: TokenMaxReserved[];
        serum3Reserved: Serum3Reserved[];
    };
    effectiveTokenBalances(healthType: HealthType | undefined): TokenBalance[];
    effectiveTokenBalancesInternal(healthType: HealthType | undefined, ignoreNegativePerp: boolean): TokenBalance[];
    effectiveTokenBalancesInternalDisplay(group: Group, healthType: HealthType | undefined, ignoreNegativePerp: boolean): TokenBalanceDisplay[];
    healthSum(healthType: HealthType, tokenBalances: TokenBalance[]): I80F48;
    healthContributionPerAssetUi(group: Group, healthType: HealthType): {
        asset: string;
        contribution: number;
        contributionDetails: {
            spotUi: number;
            perpMarketContributions: {
                market: string;
                contributionUi: number;
            }[];
        } | undefined;
    }[];
    health(healthType: HealthType): I80F48;
    perpMaxSettle(settleTokenIndex: TokenIndex): I80F48;
    healthAssetsAndLiabsStableAssets(healthType: HealthType): {
        assets: I80F48;
        liabs: I80F48;
    };
    healthAssetsAndLiabsStableLiabs(healthType: HealthType): {
        assets: I80F48;
        liabs: I80F48;
    };
    healthAssetsAndLiabs(healthType: HealthType | undefined, stableAssets: boolean): {
        assets: I80F48;
        liabs: 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;
    private static scanRightUntilLessThan;
    private static findMaximum;
    static binaryApproximationSearch(left: I80F48, leftValue: I80F48, right: I80F48, targetValue: I80F48, minStep: I80F48, fun: (I80F48: any) => I80F48, options?: {
        maxIterations?: number;
        targetError?: number;
    }): I80F48;
    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;
    getPerpPositionLiquidationPrice(group: Group, mangoAccount: MangoAccount, perpPosition: PerpPosition): I80F48 | null;
}
export declare class Prices {
    oracle: I80F48;
    stable: I80F48;
    constructor(oracle: I80F48, stable: I80F48);
    liab(healthType: HealthType | undefined): I80F48;
    asset(healthType: HealthType | undefined): I80F48;
}
export declare class TokenInfo {
    tokenIndex: TokenIndex;
    maintAssetWeight: I80F48;
    initAssetWeight: I80F48;
    initScaledAssetWeight: I80F48;
    maintLiabWeight: I80F48;
    initLiabWeight: I80F48;
    initScaledLiabWeight: I80F48;
    prices: Prices;
    balanceSpot: I80F48;
    constructor(tokenIndex: TokenIndex, maintAssetWeight: I80F48, initAssetWeight: I80F48, initScaledAssetWeight: I80F48, maintLiabWeight: I80F48, initLiabWeight: I80F48, initScaledLiabWeight: I80F48, prices: Prices, balanceSpot: I80F48);
    static fromBank(bank: BankForHealth, nativeBalance?: I80F48): TokenInfo;
    assetWeight(healthType: HealthType | undefined): I80F48;
    assetWeightedPrice(healthType: HealthType | undefined): I80F48;
    liabWeight(healthType: HealthType | undefined): I80F48;
    liabWeightedPrice(healthType: HealthType | undefined): I80F48;
    healthContribution(healthType: HealthType | undefined, balance: I80F48): I80F48;
    toString(balance: I80F48): string;
}
declare class TokenBalance {
    spotAndPerp: I80F48;
    constructor(spotAndPerp: I80F48);
}
declare class TokenBalanceDisplay {
    spotAndPerp: I80F48;
    spotUi: number;
    perpMarketContributions: {
        market: string;
        contributionUi: number;
    }[];
    constructor(spotAndPerp: I80F48, spotUi: number, perpMarketContributions: {
        market: string;
        contributionUi: number;
    }[]);
}
declare class TokenMaxReserved {
    maxSerumReserved: I80F48;
    constructor(maxSerumReserved: I80F48);
}
export declare class Serum3Reserved {
    allReservedAsBase: I80F48;
    allReservedAsQuote: I80F48;
    constructor(allReservedAsBase: I80F48, allReservedAsQuote: I80F48);
}
export declare class Serum3Info {
    reservedBase: I80F48;
    reservedQuote: I80F48;
    reservedBaseAsQuoteLowestAsk: I80F48;
    reservedQuoteAsBaseHighestBid: I80F48;
    baseInfoIndex: number;
    quoteInfoIndex: number;
    marketIndex: MarketIndex;
    constructor(reservedBase: I80F48, reservedQuote: I80F48, reservedBaseAsQuoteLowestAsk: I80F48, reservedQuoteAsBaseHighestBid: I80F48, baseInfoIndex: number, quoteInfoIndex: number, marketIndex: MarketIndex);
    static emptyFromSerum3Market(serum3Market: Serum3Market, baseEntryIndex: number, quoteEntryIndex: number): Serum3Info;
    static fromOoModifyingTokenInfos(serumAccount: Serum3Orders, baseInfoIndex: number, baseInfo: TokenInfo, quoteInfoIndex: number, quoteInfo: TokenInfo, marketIndex: MarketIndex, oo: OpenOrders): Serum3Info;
    healthContribution(healthType: HealthType | undefined, tokenInfos: TokenInfo[], tokenBalances: TokenBalance[], tokenMaxReserved: TokenMaxReserved[], marketReserved: Serum3Reserved): I80F48;
    toString(tokenInfos: TokenInfo[], tokenBalances: TokenBalance[], tokenMaxReserved: TokenMaxReserved[], marketReserved: Serum3Reserved): string;
}
export declare class PerpInfo {
    perpMarketIndex: number;
    settleTokenIndex: TokenIndex;
    maintBaseAssetWeight: I80F48;
    initBaseAssetWeight: I80F48;
    maintBaseLiabWeight: I80F48;
    initBaseLiabWeight: I80F48;
    maintOverallAssetWeight: I80F48;
    initOverallAssetWeight: I80F48;
    baseLotSize: BN;
    baseLots: BN;
    bidsBaseLots: BN;
    asksBaseLots: BN;
    quote: I80F48;
    basePrices: Prices;
    hasOpenOrders: boolean;
    constructor(perpMarketIndex: number, settleTokenIndex: TokenIndex, maintBaseAssetWeight: I80F48, initBaseAssetWeight: I80F48, maintBaseLiabWeight: I80F48, initBaseLiabWeight: I80F48, maintOverallAssetWeight: I80F48, initOverallAssetWeight: I80F48, baseLotSize: BN, baseLots: BN, bidsBaseLots: BN, asksBaseLots: BN, quote: I80F48, basePrices: Prices, hasOpenOrders: boolean);
    static fromPerpPosition(perpMarket: PerpMarket, perpPosition: PerpPosition): PerpInfo;
    healthContribution(healthType: HealthType, settleToken: TokenInfo): I80F48;
    healthUnsettledPnl(healthType: HealthType | undefined): I80F48;
    weighHealthContributionSettle(unweighted: I80F48, healthType: HealthType, settleToken: TokenInfo): I80F48;
    weighHealthContributionOverall(unweighted: I80F48, healthType: HealthType | undefined): I80F48;
    unweightedHealthUnsettledPnl(healthType: HealthType | undefined): I80F48;
    static emptyFromPerpMarket(perpMarket: PerpMarket): PerpInfo;
    toString(): string;
}
export {};
