import Decimal from 'decimal.js'; import { KaminoMarket, KaminoObligation, KaminoReserve } from '../classes'; import { Address, Slot } from '@solana/kit'; import { SwapCollFlashBorrowToken } from './swap_collateral_operations'; import { SwapDebtFlashBorrowToken } from './swap_debt_operations'; import { LedgerInstant, LedgerInstantCompatible } from '../utils/ledger'; export type SwapCollLiquidityFlashBorrowToken = Extract; export interface DetermineSwapCollateralFlashBorrowTypeInputs { kaminoMarket: KaminoMarket; obligation: KaminoObligation; sourceCollReserveAddress: Address; targetCollReserveAddress: Address; /** * Amount of source collateral to swap, in source-collateral token units. */ amount: Decimal; /** * Price of one source collateral token denominated in target collateral tokens. */ priceSourceToTarget: Decimal; /** * Slippage percentage (e.g. `0.5` for 0.5%). Required. */ slippagePct: Decimal; } export interface DetermineSwapDebtFlashBorrowTypeInputs { kaminoMarket: KaminoMarket; obligation: KaminoObligation; sourceDebtReserveAddress: Address; targetDebtReserveAddress: Address; /** * Amount of source debt to repay/replace, in source-debt token units. Ignored when `isClosingSourceDebt === true` * (the actual flow sizes around the full outstanding source-debt position instead). */ amount: Decimal; /** * If true, the picker sizes liquidity around the obligation's current source-debt position (matching the close * path inside `getSwapDebtIxs`), instead of `amount`. Avoids picking a side that lacks liquidity for the * close-sized loan. */ isClosingSourceDebt?: boolean; /** * Price of one source debt token denominated in target debt tokens. */ priceSourceToTarget: Decimal; /** * Slippage percentage (e.g. `0.5` for 0.5%). Required. */ slippagePct: Decimal; currentSlot: Slot; currentLedgerInstant?: LedgerInstant; } export type DetermineSwapDebtFlashBorrowTypeParams = LedgerInstantCompatible; export interface ChooseSwapDebtFlashBorrowTokenInputs { sourceDebtReserve: KaminoReserve; targetDebtReserve: KaminoReserve; } export interface ChooseSwapCollFlashBorrowTokenInputs { sourceCollReserve: KaminoReserve; targetCollReserve: KaminoReserve; } /** * Chooses the swap-debt flash-borrow side with the larger available liquidity value. * * Ties resolve to `targetDebt`, preserving the previous/default route preference. */ export declare function chooseSwapDebtFlashBorrowTokenByLiquidity(inputs: ChooseSwapDebtFlashBorrowTokenInputs): SwapDebtFlashBorrowToken; /** * Chooses the swap-collateral flash-borrow side with the larger available liquidity value. * * Ties resolve to `targetColl`, preserving the previous/default route preference. */ export declare function chooseSwapCollFlashBorrowTokenByLiquidity(inputs: ChooseSwapCollFlashBorrowTokenInputs): SwapCollLiquidityFlashBorrowToken; /** * Determines which collateral side a swap-collateral caller should flash borrow when the FE only describes intent. * * The helper resolves reserves, mirrors the swap-collateral builder's lamport sizing, and delegates the final reserve * checks to `determineFlashBorrowType`: flash loans must be enabled and the reserve must have enough liquidity. When * both sides are viable it prefers `targetColl`, preserving the operation's default route. * * Throws when neither source nor target collateral can satisfy the required flash-borrow amount. */ export declare function determineSwapCollateralFlashBorrowType(props: DetermineSwapCollateralFlashBorrowTypeInputs): SwapCollLiquidityFlashBorrowToken; /** * Determines which debt side a swap-debt caller should flash borrow when the FE only describes intent. * * The helper resolves reserves, mirrors the swap-debt builder's lamport sizing, and delegates the final reserve checks * to `pickFlashBorrowSide`: flash loans must be enabled and the reserve must have enough liquidity. When both * sides are viable it prefers `targetDebt`, preserving the operation's default route. * * Throws when neither source nor target debt can satisfy the required flash-borrow amount. */ export declare function determineSwapDebtFlashBorrowType(props: DetermineSwapDebtFlashBorrowTypeParams): SwapDebtFlashBorrowToken; //# sourceMappingURL=swap_flash_borrow_selection.d.ts.map