import { KaminoMarket, KaminoObligation } from '../classes';
import { SwapIxsProvider, SwapQuoteProvider } from '../leverage';
import { Account, Address, Instruction, Option, Slot, TransactionSigner } from '@solana/kit';
import Decimal from 'decimal.js';
import { AddressLookupTable } from '@solana-program/address-lookup-table';
/**
 * Which token to flash borrow for a swap-collateral operation.
 *
 * - `targetColl`: flash borrow target collateral, deposit it into the obligation, withdraw source collateral, swap
 *   source → target on external DEX, and use the swap output to repay the flash loan. Works even if the debt
 *   reserve's borrow limit is crossed. The flash-loan fee reduces the final amount of target collateral deposited.
 * - `sourceColl`: flash borrow source collateral, swap source → target on external DEX, deposit target collateral,
 *   withdraw source collateral, and use the withdrawn source collateral to repay the flash loan. The flash-loan fee
 *   reduces the source amount sent to the external DEX.
 * - `debt`: flash borrow the debt token, repay debt, withdraw source collateral, swap source → target on external DEX,
 *   deposit target, borrow debt back, and repay the flash loan. Useful when the target collateral reserve has low
 *   flash-loan liquidity. Requires the debt reserve borrow limit to have headroom; fails otherwise. The flash-loan fee
 *   is paid as a small increase in debt.
 */
export type SwapCollFlashBorrowToken = 'sourceColl' | 'targetColl' | 'debt';
/**
 * Inputs to the `getSwapCollIxs()` operation.
 */
export interface SwapCollIxsInputs<QuoteResponse> {
    /**
     * The amount of source collateral to be swapped-in for the target collateral.
     * This value will be treated exactly (i.e. slippage is not applied here) and thus must not exceed the collateral's
     * total amount.
     */
    sourceCollSwapAmount: Decimal;
    /**
     * If true, the source collateral will be closed - whatever amount is left after withdrawing `sourceCollSwapAmount`
     * will be transferred to the user.
     */
    isClosingSourceColl: boolean;
    /**
     * The address of the source collateral reserve (i.e. the current one).
     */
    sourceCollReserveAddress: Address;
    /**
     * The address of the target collateral reserve (i.e. the new one).
     */
    targetCollReserveAddress: Address;
    /**
     * An elevation group ID that the obligation should end up with after the collateral swap - it will be requested by
     * this operation (if different from the obligation's current elevation group).
     */
    newElevationGroup: number;
    /**
     * Which token to use for the flash loan. Defaults to `targetColl` (preserves pre-existing behavior).
     */
    flashBorrowToken?: SwapCollFlashBorrowToken;
    /**
     * The address of the debt reserve. Required when `flashBorrowToken === 'debt'`.
     */
    debtReserveAddress?: Address;
    market: KaminoMarket;
    owner: TransactionSigner;
    obligation: KaminoObligation;
    referrer: Option<Address>;
    currentSlot: Slot;
    budgetAndPriorityFeeIxs?: Instruction[];
    scopeRefreshIx: Instruction[];
    useV2Ixs: boolean;
    quoter: SwapQuoteProvider<QuoteResponse>;
    swapper: SwapIxsProvider<QuoteResponse>;
    logger?: (msg: string, ...extra: unknown[]) => void;
}
/**
 * Outputs from the `getSwapCollIxs()` operation.
 */
export interface SwapCollIxsOutputs<QuoteResponse> {
    /**
     * Instructions for on-chain execution.
     */
    ixs: Instruction[];
    /**
     * Required LUTs.
     */
    lookupTables: Account<AddressLookupTable>[];
    /**
     * Whether the swap is using V2 instructions.
     */
    useV2Ixs: boolean;
    /**
     * Informational-only details of the token amounts/fees/rates that were used during construction of `ixs`.
     */
    simulationDetails: {
        /**
         * Details related to the flash-loan operation needed during collateral swap.
         */
        flashLoan: {
            /**
             * The mint of the flash-borrowed token.
             */
            flashBorrowReserveMint: Address;
            /**
             * The amount flash-borrowed (in token units).
             */
            flashBorrowedAmount: Decimal;
            /**
             * The amount flash-repaid (in token units). Equal to `flashBorrowedAmount` + flash-loan fee.
             */
            flashRepaidAmount: Decimal;
        };
        /**
         * Details related to the external DEX's swap operation (i.e. `swapper` input) needed during collateral swap.
         */
        externalSwap: {
            /**
             * The mint of the token swapped-in to an external DEX (source collateral).
             */
            swapInMint: Address;
            /**
             * The mint of the token swapped-out from an external DEX (target collateral).
             */
            swapOutMint: Address;
            /**
             * The amount actually swapped-in to an external DEX (after redeem-drift sizing — on a
             * closing position this is ~1 ppm below the `sourceCollSwapAmount` input; see `redeem_drift.ts`).
             */
            swapInAmount: Decimal;
            /**
             * The amount swapped-out from an external DEX (subject to on-chain slippage).
             */
            swapOutAmount: Decimal;
            /**
             * The verbatim response coming from the input `quoter`.
             */
            quoteResponse?: QuoteResponse;
        };
    };
}
/**
 * Constructs instructions needed to partially/fully swap the given source collateral for some other collateral type.
 *
 * Three flash-borrow flavors are supported via `inputs.flashBorrowToken`:
 *   - `targetColl` (default) uses a target-coll flash loan
 *   - `sourceColl` uses a source-coll flash loan
 *   - `debt` uses a debt-token flash loan (requires `inputs.debtReserveAddress`)
 */
export declare function getSwapCollIxs<QuoteResponse>(inputs: SwapCollIxsInputs<QuoteResponse>): Promise<Array<SwapCollIxsOutputs<QuoteResponse>>>;
//# sourceMappingURL=swap_collateral_operations.d.ts.map