import { Address, Slot } from '@solana/kit';
import Decimal from 'decimal.js';
import { KaminoMarket, KaminoObligation, KaminoReserve } from '../classes';
import { AdjustLeverageCalcsResult, AdjustDepositDebtFlashCalcsResult, AdjustWithdrawCollFlashCalcsResult, DepositLeverageCalcsResult, DepositLeverageDebtFlashCalcsResult, WithdrawLeverageCalcsResult, WithdrawLeverageCollFlashCalcsResult } from './types';
export declare enum LeverageOption {
    deposit = "Deposit",
    withdraw = "Withdraw",
    adjust = "Adjust",
    close = "Close"
}
export interface LeverageCalcsArgs {
    depositAmount: Decimal;
    withdrawAmount: Decimal;
    deposited: Decimal;
    borrowed: Decimal;
    debtTokenMint: Address;
    selectedTokenMint: Address;
    collTokenMint: Address;
    targetLeverage: Decimal;
    activeLeverageOption: LeverageOption;
    flashLoanFeeRatio: Decimal;
    debtBorrowFactorPct: Decimal;
    priceCollToDebt: Decimal;
    priceDebtToColl: Decimal;
}
export interface LeverageCalcsResult {
    earned: Decimal;
    totalDeposited: Decimal;
    totalBorrowed: Decimal;
    netValue: Decimal;
    netValueUsd: Decimal;
    ltv: Decimal;
}
export declare function calculateMultiplyEffects(getPriceByTokenMintDecimal: (mint: Address) => Promise<Decimal>, { depositAmount, withdrawAmount, deposited, borrowed, debtTokenMint, selectedTokenMint, collTokenMint, targetLeverage, activeLeverageOption, flashLoanFeeRatio, debtBorrowFactorPct, priceCollToDebt, priceDebtToColl, }: LeverageCalcsArgs, logEstimations?: boolean): Promise<LeverageCalcsResult>;
/**
 * returns how much borrowToken will be borrowed to reach leverage given initial collateral amount
 * @param depositTokenAmount
 * @param leverage
 * @param priceAToB
 * @param flashBorrowFee
 */
export declare const calcBorrowAmount: ({ depositTokenAmount, targetLeverage, priceCollToDebt, flashLoanFeeRatio, }: {
    depositTokenAmount: Decimal;
    targetLeverage: Decimal;
    priceCollToDebt: Decimal;
    flashLoanFeeRatio: Decimal;
}) => Decimal;
interface UseEstimateWithdrawAmountsProps {
    priceCollToDebt: Decimal;
    amount: Decimal.Value;
    deposited: Decimal;
    borrowed: Decimal;
    collTokenMint: Address;
    selectedTokenMint: Address;
}
export declare const estimateWithdrawMode: (props: UseEstimateWithdrawAmountsProps) => WithdrawResult;
export interface WithdrawParams {
    currentBorrowPosition: Decimal;
    currentDepositPosition: Decimal;
    priceCollToDebt: Decimal;
    withdrawAmount: Decimal;
    selectedTokenMint: Address;
    collTokenMint: Address;
}
interface WithdrawResult {
    adjustDepositPosition: Decimal;
    adjustBorrowPosition: Decimal;
}
export declare function calcWithdrawAmounts(params: WithdrawParams): WithdrawResult;
interface UseEstimateAdjustAmountsProps {
    targetLeverage: Decimal;
    debtTokenMint: Address;
    collTokenMint: Address;
    totalDeposited: Decimal;
    totalBorrowed: Decimal;
    flashLoanFee: Decimal;
}
/**
 * Calculate how much token will be deposited or withdrawn in case of position adjustment
 * @param leverage
 * @param totalDeposited
 * @param totalBorrowed
 */
export declare const estimateAdjustMode: (priceCollToDebt: Decimal, { targetLeverage, totalDeposited, totalBorrowed, flashLoanFee }: UseEstimateAdjustAmountsProps) => AdjustLeverageResult;
export interface AdjustLeverageParams {
    targetLeverage: Decimal;
    currentBorrowPosition: Decimal;
    currentDepositPosition: Decimal;
    priceCollToDebt: Decimal;
    flashLoanFee: Decimal;
}
interface AdjustLeverageResult {
    adjustDepositPosition: Decimal;
    adjustBorrowPosition: Decimal;
}
/**
 * Calculates the amounts of tokenA to deposit/withdraw and tokenB to borrow/repay proportionally to adjust the leverage of a position.
 *
 * @param {AdjustLeverageParams} params - Parameters for the calculation
 * @param {number} params.targetLeverage - The target leverage for the position
 * @param {Decimal} params.currentPositionTokenA - The current amount of tokenA in the position
 * @param {Decimal} params.currentPositionTokenB - The current amount of borrowed tokenB in the position
 * @param {number} params.priceAtoB - The conversion rate from tokenA to tokenB (tokenA price = tokenB price * priceAtoB)
 * @returns {AdjustLeverageResult} An object containing the amounts of tokenA to deposit/withdraw and tokenB to borrow/repay
 */
export declare function calcAdjustAmounts({ targetLeverage, currentBorrowPosition, currentDepositPosition, priceCollToDebt, flashLoanFee, }: AdjustLeverageParams): AdjustLeverageResult;
interface UseTransactionInfoStats {
    priceCollToDebt: Decimal;
    priceDebtToColl: Decimal;
    amount: Decimal;
    targetLeverage: Decimal;
    selectedTokenMint: Address;
    collTokenMint: Address;
    flashLoanFee: Decimal;
    slippagePct?: Decimal;
}
export declare const estimateDepositMode: ({ priceCollToDebt, priceDebtToColl, amount, targetLeverage, selectedTokenMint, collTokenMint, flashLoanFee, slippagePct, }: UseTransactionInfoStats) => {
    adjustDepositPosition: number;
    adjustBorrowPosition: number;
};
export declare const depositLeverageCalcs: (props: {
    depositAmount: Decimal;
    depositTokenIsCollToken: boolean;
    depositTokenIsSol: boolean;
    priceDebtToColl: Decimal;
    targetLeverage: Decimal;
    slippagePct: Decimal;
    flashLoanFee: Decimal;
}) => DepositLeverageCalcsResult;
export declare function withdrawLeverageCalcs(market: KaminoMarket, collReserve: KaminoReserve, debtReserve: KaminoReserve, priceCollToDebt: Decimal, withdrawAmount: Decimal, deposited: Decimal, borrowed: Decimal, currentSlot: Slot, isClosingPosition: boolean, selectedTokenIsCollToken: boolean, selectedTokenMint: Address, obligation: KaminoObligation, flashLoanFee: Decimal, slippagePct: Decimal): WithdrawLeverageCalcsResult;
export declare function adjustDepositLeverageCalcs(debtReserve: KaminoReserve, adjustDepositPosition: Decimal, adjustBorrowPosition: Decimal, priceDebtToColl: Decimal, flashLoanFee: Decimal, slippagePct: Decimal): AdjustLeverageCalcsResult;
export declare function adjustWithdrawLeverageCalcs(adjustDepositPosition: Decimal, adjustBorrowPosition: Decimal, flashLoanFee: Decimal, slippagePct: Decimal): AdjustLeverageCalcsResult;
/**
 * Deposit with flash borrow DEBT token.
 * Flow: flash borrow debt -> swap debt->coll -> deposit coll -> borrow debt -> flash repay debt
 *
 * The user deposits collateral (or debt token). We flash borrow debt, swap it to coll,
 * deposit all coll, borrow debt to repay the flash loan (principal + fee).
 */
export declare const depositLeverageCalcsDebtFlash: (props: {
    depositAmount: Decimal;
    depositTokenIsCollToken: boolean;
    depositTokenIsSol: boolean;
    priceDebtToColl: Decimal;
    targetLeverage: Decimal;
    slippagePct: Decimal;
    flashLoanFee: Decimal;
}) => DepositLeverageDebtFlashCalcsResult;
/**
 * Withdraw with flash borrow COLLATERAL token.
 * Flow: flash borrow coll -> swap coll->debt -> repay debt -> withdraw coll -> flash repay coll
 *
 * We flash borrow enough coll to swap for the debt repayment amount,
 * then repay debt, withdraw coll, and use the withdrawn coll to repay the flash loan.
 */
export declare function withdrawLeverageCalcsCollFlash(market: KaminoMarket, collReserve: KaminoReserve, debtReserve: KaminoReserve, priceCollToDebt: Decimal, withdrawAmount: Decimal, deposited: Decimal, borrowed: Decimal, currentSlot: Slot, isClosingPosition: boolean, selectedTokenIsCollToken: boolean, selectedTokenMint: Address, obligation: KaminoObligation, flashLoanFee: Decimal, slippagePct: Decimal): WithdrawLeverageCollFlashCalcsResult;
/**
 * Adjust (increase leverage) with flash borrow DEBT token.
 * Flow: flash borrow debt -> swap debt->coll -> deposit coll -> borrow debt -> flash repay debt
 */
export declare function adjustDepositLeverageCalcsDebtFlash(debtReserve: KaminoReserve, adjustDepositPosition: Decimal, adjustBorrowPosition: Decimal, priceDebtToColl: Decimal, flashLoanFee: Decimal, slippagePct: Decimal): AdjustDepositDebtFlashCalcsResult;
/**
 * Adjust (decrease leverage) with flash borrow COLLATERAL token.
 * Flow: flash borrow coll -> swap coll->debt -> repay debt -> withdraw coll -> flash repay coll
 */
export declare function adjustWithdrawLeverageCalcsCollFlash(adjustDepositPosition: Decimal, adjustBorrowPosition: Decimal, priceCollToDebt: Decimal, flashLoanFee: Decimal, slippagePct: Decimal): AdjustWithdrawCollFlashCalcsResult;
export {};
//# sourceMappingURL=calcs.d.ts.map