import { AccountInfo, Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
import Decimal from 'decimal.js';
import { MarketWithAddress, TokenOracleData } from '../utils';
import { FeeCalculation, Fees, ReserveDataType, ReserveRewardYield } from './shared';
import { Reserve } from '../idl_codegen/accounts';
import { ReserveConfig, UpdateConfigModeKind } from '../idl_codegen/types';
import { ConfigUpdater } from './configItems';
import { ActionType } from './action';
import { BorrowCapsAndCounters, KaminoMarket } from './market';
import { KaminoPrices } from '@kamino-finance/kliquidity-sdk';
export declare const DEFAULT_RECENT_SLOT_DURATION_MS = 450;
export declare class KaminoReserve {
    state: Reserve;
    address: PublicKey;
    symbol: string;
    tokenOraclePrice: TokenOracleData;
    stats: ReserveDataType;
    private farmData;
    private buffer;
    private connection;
    private readonly recentSlotDurationMs;
    constructor(state: Reserve, address: PublicKey, tokenOraclePrice: TokenOracleData, connection: Connection, recentSlotDurationMs: number);
    static initialize(accountData: AccountInfo<Buffer>, address: PublicKey, state: Reserve, tokenOraclePrice: TokenOracleData, connection: Connection, recentSlotDurationMs: number): KaminoReserve;
    /**
     * @returns the parsed token symbol of the reserve
     */
    getTokenSymbol(): 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 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;
    /**
     *
     * @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: number, 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: number, referralFeeBps: number): 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: number, referralFeeBps: number): 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 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 daily deposit withdrawal cap
     */
    getDepositWithdrawalCapCapacity(): Decimal;
    /**
     *
     * @returns the current capacity of the daily deposit withdrawal cap
     */
    getDepositWithdrawalCapCurrent(slot: number): Decimal;
    /**
     *
     * @returns the max capacity of the daily 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;
    /**
     *
     * @returns the current capacity of the daily debt withdrawal cap
     */
    getDebtWithdrawalCapCurrent(slot: number): Decimal;
    getBorrowFactor(): Decimal;
    calculateSupplyAPR(slot: number, referralFeeBps: number): number;
    getEstimatedDebtAndSupply(slot: number, referralFeeBps: number): {
        totalBorrow: Decimal;
        totalSupply: Decimal;
    };
    getEstimatedAccumulatedProtocolFees(slot: number, referralFeeBps: number): {
        accumulatedProtocolFees: Decimal;
        compoundedVariableProtocolFee: Decimal;
        compoundedFixedHostFee: Decimal;
    };
    calculateUtilizationRatio(): number;
    getEstimatedUtilizationRatio(slot: number, referralFeeBps: number): number;
    calcSimulatedUtilizationRatio(amount: Decimal, action: ActionType, slot: number, referralFeeBps: number, outflowAmount?: Decimal): number;
    getMaxBorrowAmountWithCollReserve(market: KaminoMarket, collReserve: KaminoReserve, slot: number): Decimal;
    calcSimulatedBorrowRate(amount: Decimal, action: ActionType, slot: number, referralFeeBps: number, outflowAmount?: Decimal): number;
    calcSimulatedBorrowAPR(amount: Decimal, action: ActionType, slot: number, referralFeeBps: number, outflowAmount?: Decimal): number;
    calcSimulatedSupplyAPR(amount: Decimal, action: ActionType, slot: number, referralFeeBps: number, outflowAmount?: Decimal): number;
    slotAdjustmentFactor(): number;
    calculateBorrowRate(): number;
    calculateEstimatedBorrowRate(slot: number, referralFeeBps: number): number;
    calculateBorrowAPR(slot: number, referralFeeBps: number): number;
    /**
     * @returns the mint of the reserve liquidity token
     */
    getLiquidityMint(): PublicKey;
    /**
     * @returns the token program of the reserve liquidity mint
     */
    getLiquidityTokenProgram(): PublicKey;
    /**
     * @returns the mint of the reserve collateral token , i.e. the cToken minted for depositing the liquidity token
     */
    getCTokenMint(): PublicKey;
    calculateFees(amountLamports: Decimal, borrowFeeRate: Decimal, feeCalculation: FeeCalculation, referralFeeBps: number, hasReferrer: boolean): Fees;
    calculateFlashLoanFees(flashLoanAmountLamports: Decimal, referralFeeBps: number, hasReferrer: boolean): Fees;
    setBuffer(buffer: AccountInfo<Buffer> | null): void;
    load(tokenOraclePrice: TokenOracleData): Promise<void>;
    totalSupplyAPY(currentSlot: number): number;
    totalBorrowAPY(currentSlot: number): number;
    loadFarmStates(): Promise<void>;
    getRewardYields(prices: KaminoPrices): Promise<ReserveRewardYield[]>;
    private calculateRewardYield;
    private getRewardPerTimeUnitSecond;
    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
     */
    private approximateCompoundedInterest;
    getBorrowCapForReserve(market: KaminoMarket): BorrowCapsAndCounters;
    getLiquidityAvailableForDebtReserveGivenCaps(market: KaminoMarket, elevationGroups: number[], collateralReserves?: PublicKey[]): Decimal[];
}
export declare function createReserveIxs(connection: Connection, owner: PublicKey, ownerLiquiditySource: PublicKey, lendingMarket: PublicKey, liquidityMint: PublicKey, reserveAddress: PublicKey, programId: PublicKey): Promise<TransactionInstruction[]>;
export declare function updateReserveConfigIx(signer: PublicKey, marketAddress: PublicKey, reserveAddress: PublicKey, mode: UpdateConfigModeKind, value: Uint8Array, programId: PublicKey, skipConfigIntegrityValidation?: boolean): TransactionInstruction;
export declare const RESERVE_CONFIG_UPDATER: ConfigUpdater<UpdateConfigModeKind, ReserveConfig>;
export declare function updateEntireReserveConfigIx(signer: PublicKey, marketAddress: PublicKey, reserveAddress: PublicKey, reserveConfig: ReserveConfig, programId: PublicKey): TransactionInstruction;
export declare function parseForChangesReserveConfigAndGetIxs(marketWithAddress: MarketWithAddress, reserve: Reserve | undefined, reserveAddress: PublicKey, reserveConfig: ReserveConfig, programId: PublicKey): TransactionInstruction[];
export type ReserveWithAddress = {
    address: PublicKey;
    state: Reserve;
};
//# sourceMappingURL=reserve.d.ts.map