import { Address, Instruction, Slot, TransactionSigner, Rpc, GetMinimumBalanceForRentExemptionApi, Option, GetProgramAccountsApi, GetAccountInfoApi, GetMultipleAccountsApi } from '@solana/kit';
import Decimal from 'decimal.js';
import { AllOracleAccounts, MarketWithAddress, ReserveKind, TokenOracleData } from '../utils';
import { FeeCalculation, Fees, ReserveDataType, ReserveRewardYield } from './shared';
import { Reserve, WithdrawTicket } from '../@codegen/klend/accounts';
import { ReserveConfig, UpdateConfigModeKind } from '../@codegen/klend/types';
import { ConfigUpdater, PriorityOrderedConfigUpdater } from './configItems';
import { ActionType } from './action';
import { BorrowCapsAndCounters, KaminoMarket } from './market';
import { KaminoPrices } from '@kamino-finance/kliquidity-sdk';
import { RewardInfo } from '@kamino-finance/farms-sdk';
import { KaminoCdnData } from './cdnClient';
export type KaminoReserveRpcApi = GetProgramAccountsApi & GetAccountInfoApi & GetMultipleAccountsApi;
export declare const DEFAULT_RECENT_SLOT_DURATION_MS = 400;
export declare class KaminoReserve {
    state: Reserve;
    address: Address;
    symbol: string;
    tokenOraclePrice: TokenOracleData;
    stats: ReserveDataType;
    private farmData;
    private rpc;
    private readonly recentSlotDurationMs;
    private metadata?;
    private reserveKind;
    private scaledUiAmountMultiplier;
    constructor(state: Reserve, address: Address, tokenOraclePrice: TokenOracleData, connection: Rpc<KaminoReserveRpcApi>, recentSlotDurationMs: number, scaledUiAmountMultiplier?: Decimal);
    static initialize(address: Address, state: Reserve, tokenOraclePrice: TokenOracleData, rpc: Rpc<KaminoReserveRpcApi>, recentSlotDurationMs: number, cdnResourcesData?: KaminoCdnData, scaledUiAmountMultiplier?: Decimal): KaminoReserve;
    /**
     * Construct a KaminoReserve from raw on-chain account data.
     * Use this when you have raw bytes from a WebSocket notification and
     * an existing oracle price (e.g. from a cached price query).
     *
     * Throws if the data does not match the Reserve discriminator.
     */
    static fromAccountData(reserveAddress: Address, data: Buffer | Uint8Array, tokenOraclePrice: TokenOracleData, rpc: Rpc<KaminoReserveRpcApi>, recentSlotDurationMs: number, cdnResourcesData?: KaminoCdnData): KaminoReserve;
    static initializeFromAddress(address: Address, rpc: Rpc<KaminoReserveRpcApi>, recentSlotDurationMs: number, reserveState?: Reserve, oracleAccounts?: AllOracleAccounts, scaledUiAmountMultiplier?: Decimal): Promise<KaminoReserve>;
    static createReserveKind(state: Reserve): ReserveKind;
    /**
     * @returns the scaledUiAmount multiplier for this reserve's liquidity mint.
     * Returns 1 for mints without the ScaledUiAmountConfig extension.
     */
    getScaledUiAmountMultiplier(): Decimal;
    /**
     * @returns the parsed token symbol of the reserve
     */
    getTokenSymbol(): string;
    /**
     * @returns list of logo names and human readable oracle descriptions
     */
    getOracleMetadata(): Promise<[string, string][]>;
    /**
     * @returns the total borrowed amount of the reserve in lamports
     */
    getBorrowedAmount(): Decimal;
    /**
     * @returns the available liquidity amount of the reserve in lamports
     */
    getLiquidityAvailableAmount(): Decimal;
    /** @returns the total amount of ctokens queued for withdrawal */
    getQueuedCTokens(): Decimal;
    /** @returns the total amount of liquidity queued for withdrawal */
    getQueuedLiquidityAmount(slot: Slot): Decimal;
    /** @returns the the part of reserve liquidity available for *non-priority* purposes (e.g. borrowing, regular withdrawals) */
    getFreelyAvailableLiquidityAmount(slot: Slot): Decimal;
    /**
     *
     * @returns the last cached price stored in the reserve in USD
     */
    getReserveMarketPrice(): Decimal;
    /**
     * @returns the current market price of the reserve in USD
     */
    getOracleMarketPrice(): Decimal;
    /**
     * @returns the total accumulated protocol fees of the reserve
     */
    getAccumulatedProtocolFees(): Decimal;
    /**
     * @returns the total accumulated referrer fees of the reserve
     */
    getAccumulatedReferrerFees(): Decimal;
    /**
     * @returns the total pending referrer fees of the reserve
     */
    getPendingReferrerFees(): Decimal;
    getScaledBorrowedAmount(): Decimal;
    getScaledLiquidityAvailableAmount(): Decimal;
    getScaledTotalSupply(): Decimal;
    getScaledAccumulatedProtocolFees(): Decimal;
    getScaledAccumulatedReferrerFees(): Decimal;
    getScaledPendingReferrerFees(): Decimal;
    /**
     *
     * @returns the flash loan fee percentage of the reserve
     */
    getFlashLoanFee: () => Decimal;
    /**
     *
     * @returns the origination fee percentage of the reserve
     */
    getBorrowFee: () => Decimal;
    /**
     *
     * @returns the fixed interest rate allocated to the host
     */
    getFixedHostInterestRate: () => Decimal;
    /**
     * Use getEstimatedTotalSupply() for the most accurate value
     * @returns the stale total liquidity supply of the reserve from the last refresh
     */
    getTotalSupply(): Decimal;
    /**
     * Calculates the total liquidity supply of the reserve
     */
    getEstimatedTotalSupply(slot: Slot, referralFeeBps: number): Decimal;
    /**
     * Use getEstimatedCumulativeBorrowRate() for the most accurate value
     * @returns the stale cumulative borrow rate of the reserve from the last refresh
     */
    getCumulativeBorrowRate(): Decimal;
    /**
     * @Returns estimated cumulative borrow rate of the reserve
     */
    getEstimatedCumulativeBorrowRate(currentSlot: Slot, referralFeeBps: number): Decimal;
    /**
     * Mirrors on-chain `Reserve::calculate_future_cumulative_borrow_rate`.
     * Projects the cumulative borrow rate to a future slot.
     */
    calculateFutureCumulativeBorrowRate(futureSlot: Slot): Decimal;
    /**
     * Use getEstimatedCollateralExchangeRate() for the most accurate value
     * @returns the stale exchange rate between the collateral tokens and the liquidity - this is a decimal number scaled by 1e18
     */
    getCollateralExchangeRate(): Decimal;
    /**
     *
     * @returns the estimated exchange rate between the collateral tokens and the liquidity - this is a decimal number scaled by 1e18
     */
    getEstimatedCollateralExchangeRate(slot: Slot, referralFeeBps: number): Decimal;
    /**
     * Computes the amount of liquidity tokens that corresponds to a given amount of cTokens
     * @param cTokens - the amount of cTokens to convert to liquidity tokens
     * @param exchangeRate - the exchange rate to use. If not provided, the estimated exchange rate will be used
     * @param slot - the slot to use to estimate exchange rate. If exchangeRate is provided, this parameter is ignored, if exchangeRate is not provided this parameter is required
     * @param referralFeeBps - the referral fee percentage to use for the estimated exchange rate. Defaults to 0. If exchangeRate is provided, this parameter is ignored.
     * @returns the amount of liquidity tokens that corresponds to the given amount of cTokens
     */
    cTokensToLiquidity(cTokens: Decimal, slot: Slot, exchangeRate?: Decimal, referralFeeBps?: number): Decimal;
    /**
     * Computes the amount of liquidity tokens that corresponds to a given amount of cTokens
     * @param cTokens - the amount of cTokens to convert to liquidity tokens
     * @param exchangeRate - the exchange rate to use
     * @returns the amount of liquidity tokens that corresponds to the given amount of cTokens
     */
    static cTokensToLiquidity(cTokens: Decimal, exchangeRate: Decimal): Decimal;
    /**
     * Computes the amount of cTokens that corresponds to a given amount of liquidity
     * @param liquidity - the amount of liquidity to convert to cTokens
     * @param exchangeRate - the exchange rate to use. If not provided, the estimated exchange rate will be used
     * @param slot - the slot to use to estimate exchange rate. If exchangeRate is provided, this parameter is ignored, if exchangeRate is not provided this parameter is required
     * @param referralFeeBps - the referral fee percentage to use for the estimated exchange rate. Defaults to 0. If exchangeRate is provided, this parameter is ignored.
     * @returns the amount of cTokens that corresponds to the given amount of liquidity
     */
    liquidityToCTokens(liquidity: Decimal, slot: Slot, exchangeRate?: Decimal, referralFeeBps?: number): Decimal;
    /**
     * Computes the amount of cTokens that corresponds to a given amount of liquidity
     * @param liquidity - the amount of liquidity to convert to cTokens
     * @param exchangeRate - the exchange rate to use
     * @returns the amount of cTokens that corresponds to the given amount of liquidity
     */
    static liquidityToCTokens(liquidity: Decimal, exchangeRate: Decimal): Decimal;
    /**
     *
     * @returns the total USD value of the existing collateral in the reserve
     */
    getDepositTvl: () => Decimal;
    /**
     *
     * Get the total USD value of the borrowed assets from the reserve
     */
    getBorrowTvl: () => Decimal;
    /**
     * @returns 10^mint_decimals
     */
    getMintFactor(): Decimal;
    /**
     * @returns mint_decimals of the liquidity token
     */
    getMintDecimals(): number;
    /**
     * @returns the collateral farm address if it is set, otherwise none
     */
    getCollateralFarmAddress(): Option<Address>;
    /**
     * @returns the debt farm address if it is set, otherwise none
     */
    getDebtFarmAddress(): Option<Address>;
    /**
     * @Returns true if the total liquidity supply of the reserve is greater than the deposit limit
     */
    depositLimitCrossed(): boolean;
    /**
     * @Returns true if the total borrowed amount of the reserve is greater than the borrow limit
     */
    borrowLimitCrossed(): boolean;
    /**
     *
     * @returns the max capacity of the deposit withdrawal cap
     */
    getDepositWithdrawalCapCapacity(): Decimal;
    /**
     *
     * @returns the current capacity of the deposit withdrawal cap
     */
    getDepositWithdrawalCapCurrent(currentUnixTimestamp: number): Decimal;
    /**
     *
     * @returns the max capacity of the debt withdrawal cap
     */
    getDebtWithdrawalCapCapacity(): Decimal;
    /**
     *
     * @returns the borrow limit of the reserve outside the elevation group
     */
    getBorrowLimitOutsideElevationGroup(): Decimal;
    /**
     *
     * @returns the borrowed amount of the reserve outside the elevation group
     */
    getBorrowedAmountOutsideElevationGroup(): Decimal;
    /**
     *
     * @returns the borrow limit against the collateral reserve in the elevation group
     */
    getBorrowLimitAgainstCollateralInElevationGroup(elevationGroupIndex: number): Decimal;
    /**
     *
     * @returns the borrowed amount against the collateral reserve in the elevation group
     */
    getBorrowedAmountAgainstCollateralInElevationGroup(elevationGroupIndex: number): Decimal;
    private getWithdrawalCapCurrent;
    /**
     *
     * @returns the current capacity of the debt withdrawal cap
     */
    getDebtWithdrawalCapCurrent(currentUnixTimestamp: number): Decimal;
    getBorrowFactor(): Decimal;
    calculateSupplyAPR(slot: Slot, referralFeeBps: number): number;
    getEstimatedDebtAndSupply(slot: Slot, referralFeeBps: number): {
        totalBorrow: Decimal;
        totalSupply: Decimal;
    };
    getEstimatedAccumulatedProtocolFees(slot: Slot, referralFeeBps: number): {
        accumulatedProtocolFees: Decimal;
        compoundedVariableProtocolFee: Decimal;
        compoundedFixedHostFee: Decimal;
    };
    calculateUtilizationRatio(): number;
    getEstimatedUtilizationRatio(slot: Slot, referralFeeBps: number): number;
    calcSimulatedUtilizationRatio(amount: Decimal, action: ActionType, slot: Slot, referralFeeBps: number, outflowAmount?: Decimal): number;
    getMaxBorrowAmountWithCollReserve(market: KaminoMarket, collReserve: KaminoReserve): Decimal;
    calcSimulatedBorrowRate(amount: Decimal, action: ActionType, slot: Slot, referralFeeBps: number, outflowAmount?: Decimal): number;
    calcSimulatedBorrowAPR(amount: Decimal, action: ActionType, slot: Slot, referralFeeBps: number, outflowAmount?: Decimal): number;
    calcSimulatedSupplyAPR(amount: Decimal, action: ActionType, slot: Slot, referralFeeBps: number, outflowAmount?: Decimal): number;
    slotAdjustmentFactor(): number;
    calculateBorrowRate(): number;
    calculateEstimatedBorrowRate(slot: Slot, referralFeeBps: number): number;
    calculateBorrowAPR(slot: Slot, referralFeeBps: number): number;
    calculateBorrowAPRFixedRate(): number;
    /**
     * @returns the mint of the reserve liquidity token
     */
    getLiquidityMint(): Address;
    /**
     * @returns the token program of the reserve liquidity mint
     */
    getLiquidityTokenProgram(): Address;
    /**
     * @returns the mint of the reserve collateral token , i.e. the cToken minted for depositing the liquidity token
     */
    getCTokenMint(): Address;
    /**
     * Returns the reserve kind (FloatRateReserveKind or FixedRateReserveKind) for this reserve.
     *
     * @returns The reserve kind instance
     */
    getKind(): ReserveKind;
    calculateFees(amountLamports: Decimal, borrowFeeRate: Decimal, feeCalculation: FeeCalculation, referralFeeBps: number, hasReferrer: boolean): Fees;
    calculateFlashLoanFees(flashLoanAmountLamports: Decimal, referralFeeBps: number, hasReferrer: boolean): Fees;
    load(tokenOraclePrice: TokenOracleData): Promise<void>;
    reloadState(): Promise<void>;
    totalSupplyAPY(currentSlot: Slot): number;
    totalBorrowAPY(currentSlot: Slot): number;
    totalBorrowAPYFixedRate(): number;
    loadFarmStates(farmsProgramId?: Address): Promise<void>;
    getRewardYields(prices: KaminoPrices, farmsProgramId?: Address): Promise<ReserveRewardYield[]>;
    calculateRewardYield(prices: KaminoPrices, rewardInfo: RewardInfo, isDebtReward: boolean, farmTotalStakeLamports: Decimal): {
        apy: Decimal;
        apr: Decimal;
    };
    private formatReserveData;
    /**
     * Compound current borrow rate over elapsed slots
     *
     * This also calculates protocol fees, which are taken for all obligations that have borrowed from current reserve.
     *
     * This also calculates referral fees, which are taken into pendingReferralFees.
     *
     * https://github.com/Kamino-Finance/klend/blob/release/1.3.0/programs/klend/src/state/reserve.rs#L517
     *
     * @param slotsElapsed
     * @param referralFeeBps
     */
    private compoundInterest;
    /**
     * Approximation to match the smart contract calculation
     * https://github.com/Kamino-Finance/klend/blob/release/1.3.0/programs/klend/src/state/reserve.rs#L1026
     * @param rate
     * @param elapsedSlots
     */
    private approximateCompoundedInterest;
    getBorrowCapForReserve(market: KaminoMarket): BorrowCapsAndCounters;
    getLiquidityAvailableForDebtReserveGivenCaps(market: KaminoMarket, elevationGroups: number[], collateralReserves?: Address[]): Decimal[];
    /**
     * Fetches all withdraw tickets for this reserve (across all users).
     *
     * Useful for computing "queued before you" by comparing ticket sequence numbers.
     *
     * @param programId - The lending program ID (defaults to PROGRAM_ID)
     * @returns Array of all withdraw tickets for this reserve
     */
    getAllWithdrawTickets(programId?: Address): Promise<WithdrawTicket[]>;
    /**
     * Fetches all withdraw tickets for this reserve owned by the given user.
     *
     * @param userWallet - The user's wallet address
     * @param programId - The lending program ID (defaults to PROGRAM_ID)
     * @returns Array of withdraw tickets for the user on this reserve
     */
    getWithdrawTicketsForUser(userWallet: Address, programId?: Address): Promise<WithdrawTicket[]>;
}
export declare function createReserveIxs(rpc: Rpc<GetMinimumBalanceForRentExemptionApi>, owner: TransactionSigner, ownerLiquiditySource: Address, lendingMarket: Address, liquidityMint: Address, liquidityMintTokenProgram: Address, reserveAddress: TransactionSigner, programId: Address): Promise<Instruction[]>;
export declare function updateReserveConfigIx(signer: TransactionSigner, marketAddress: Address, reserveAddress: Address, mode: UpdateConfigModeKind, value: Uint8Array, programId: Address, skipConfigIntegrityValidation?: boolean): Promise<Instruction>;
export declare const RESERVE_CONFIG_UPDATER: ConfigUpdater<UpdateConfigModeKind, ReserveConfig>;
export declare const ENTIRE_RESERVE_CONFIG_UPDATER: PriorityOrderedConfigUpdater<UpdateConfigModeKind, ReserveConfig>;
export declare const GLOBAL_ADMIN_ONLY_MODES: Set<number>;
export declare function isGlobalAdminOnly(mode: UpdateConfigModeKind): boolean;
export type ReserveConfigUpdateIx = {
    ix: Instruction;
    requiresGlobalAdmin: boolean;
};
export declare function parseForChangesReserveConfigAndGetIxs(marketWithAddress: MarketWithAddress, reserve: Reserve | undefined, reserveAddress: Address, reserveConfig: ReserveConfig, programId: Address, lendingMarketOwner?: TransactionSigner, globalAdminSigner?: TransactionSigner): Promise<ReserveConfigUpdateIx[]>;
export type ReserveWithAddress = {
    address: Address;
    state: Reserve;
};
export declare function shouldSkipValidation(mode: UpdateConfigModeKind, reserve: Reserve | undefined): boolean;
export declare function buildReserveConfigPriority(previous: ReserveConfig | undefined, changed: ReserveConfig): (mode: UpdateConfigModeKind) => number;
export declare function priorityOf(mode: UpdateConfigModeKind, liquidationThresholdIncreasing?: boolean, autodeleverageDisabling?: boolean): number;
//# sourceMappingURL=reserve.d.ts.map