import { KaminoMarket, KaminoObligation } from '../classes';
import { FlashBorrowType, FlashLoanInfo, SwapInputs, SwapIxsProvider, SwapQuote, SwapQuoteProvider } from '../leverage/types';
import { KlendAccountsResult } from '../utils';
import { AddressLookupTable } from '@solana-program/address-lookup-table';
import { Account, Address, Instruction, Option, Slot, TransactionSigner } from '@solana/kit';
import Decimal from 'decimal.js';
export type RepayWithCollIxsResponse<QuoteResponse> = {
    ixs: Instruction[];
    lookupTables: Account<AddressLookupTable>[];
    flashLoanInfo: FlashLoanInfo;
    swapInputs: SwapInputs;
    initialInputs: RepayWithCollInitialInputs<QuoteResponse>;
    quote?: QuoteResponse;
};
interface RepayWithCollInitialInputsCommon<QuoteResponse> {
    /** Debt-token-denominated amount being repaid to the obligation. */
    debtRepayAmountLamports: Decimal;
    /**
     * Flash-loan repay amount in the lamports of the FLASH-BORROWED reserve.
     *  - debt-flash: debt lamports = `debtRepayAmountLamports` + flash fee.
     *  - coll-flash: coll lamports = `collSwapInLamports * (1 + collFlashLoanFee)`.
     * Use the `flashBorrowType` discriminant on the parent type to know which denomination.
     */
    flashRepayAmountLamports: Decimal;
    /**
     * The amount of collateral available to withdraw, if this is less than the swap input amount, then the swap may fail due to slippage, or tokens may be debited from the user's ATA, so the caller needs to check this
     */
    maxCollateralWithdrawLamports: Decimal;
    /**
     * The quote from the provided quoter
     */
    swapQuote: SwapQuote<QuoteResponse>;
    currentSlot: Slot;
    klendAccounts: Array<Address>;
}
export interface DebtFlashRepayWithCollInitialInputs<QuoteResponse> extends RepayWithCollInitialInputsCommon<QuoteResponse> {
    flashBorrowType: 'debt';
}
export interface CollFlashRepayWithCollInitialInputs<QuoteResponse> extends RepayWithCollInitialInputsCommon<QuoteResponse> {
    flashBorrowType: 'coll';
}
export type RepayWithCollInitialInputs<QuoteResponse> = DebtFlashRepayWithCollInitialInputs<QuoteResponse> | CollFlashRepayWithCollInitialInputs<QuoteResponse>;
export interface RepayWithCollSwapInputsProps<QuoteResponse> {
    kaminoMarket: KaminoMarket;
    debtReserveAddress: Address;
    collReserveAddress: Address;
    owner: TransactionSigner;
    obligation: KaminoObligation;
    referrer: Option<Address>;
    currentSlot: Slot;
    repayAmount: Decimal;
    isClosingPosition: boolean;
    budgetAndPriorityFeeIxs?: Instruction[];
    scopeRefreshIx: Instruction[];
    useV2Ixs: boolean;
    quoter: SwapQuoteProvider<QuoteResponse>;
    /**
     * The user's max-acceptable swap slippage, expressed as a percent (e.g. `0.5` for 0.5%).
     *
     * Contract: callers pass a SIMULATED (mid) `priceAInB` from the quoter — the SDK applies this
     * value as the sizing buffer when computing the flash-borrow / swap-input lamports, so the
     * worst-case real fill still satisfies the on-chain repay / flash-repay constraint. Conceptually
     * a separate knob from the on-chain swap `min_out` (which the swapper sets); in the future this
     * could be a smaller, capped value.
     */
    slippagePct: Decimal;
    /**
     * Which side to flash borrow on:
     *  - `'debt'` (default): flash borrow debt → repay+withdraw → swap coll→debt → flash repay debt.
     *  - `'coll'`: flash borrow coll → swap coll→debt → repay+withdraw → flash repay coll.
     * Useful when the default reserve has flash loans disabled or insufficient liquidity.
     */
    flashBorrowType?: FlashBorrowType;
}
/**
 * Inputs for {@link getRepayWithCollKlendAccounts}: the subset of {@link getRepayWithCollSwapInputs}'s props that
 * the klend account footprint depends on. Derived from {@link RepayWithCollSwapInputsProps} (so the two never drift)
 * by dropping only the fields account discovery does not use: the quoter and the slippage. Unlike the swap-coll /
 * swap-debt families, `flashBorrowType` is KEPT, because the two repay routes flash-borrow different reserves
 * (debt vs coll) and so reference a different reserve fee-vault — the account set is NOT invariant to the side.
 */
export type RepayWithCollKlendAccountsInputs = Omit<RepayWithCollSwapInputsProps<unknown>, 'quoter' | 'slippagePct'>;
/**
 * Light helper: returns the exact, final set of klend accounts (and program ids) a repay-with-collateral operation
 * with the same inputs would consume, plus their count, WITHOUT calling the quoter/swapper. This is the same set the
 * operation passes to the quoter (invariant to the swap amounts), so the count is accurate and final — the FE can use
 * it to know how many accounts remain for the external swap. Pass the same `flashBorrowType` the operation will use:
 * the debt-flash and coll-flash routes flash different reserves and so reference a different fee vault.
 */
export declare function getRepayWithCollKlendAccounts(inputs: RepayWithCollKlendAccountsInputs): Promise<KlendAccountsResult>;
export declare function getRepayWithCollSwapInputs<QuoteResponse>({ collReserveAddress, currentSlot, debtReserveAddress, kaminoMarket, owner, obligation, quoter, referrer, repayAmount, isClosingPosition, budgetAndPriorityFeeIxs, scopeRefreshIx, useV2Ixs, slippagePct, flashBorrowType, }: RepayWithCollSwapInputsProps<QuoteResponse>): Promise<{
    swapInputs: SwapInputs;
    flashLoanInfo: FlashLoanInfo;
    initialInputs: RepayWithCollInitialInputs<QuoteResponse>;
}>;
interface RepayWithCollIxsProps<QuoteResponse> extends RepayWithCollSwapInputsProps<QuoteResponse> {
    swapper: SwapIxsProvider<QuoteResponse>;
    logger?: (msg: string, ...extra: any[]) => void;
}
export declare function getRepayWithCollIxs<QuoteResponse>({ repayAmount, isClosingPosition, budgetAndPriorityFeeIxs, collReserveAddress, currentSlot, debtReserveAddress, kaminoMarket, owner, obligation, quoter, swapper, referrer, scopeRefreshIx, useV2Ixs, slippagePct, flashBorrowType, logger, }: RepayWithCollIxsProps<QuoteResponse>): Promise<Array<RepayWithCollIxsResponse<QuoteResponse>>>;
export {};
//# sourceMappingURL=repay_with_collateral_operations.d.ts.map