import { type AccrualPosition, type MarketId } from "@morpho-org/blue-sdk"; import { type Address } from "viem"; import { type VaultReallocation } from "../types"; /** * Validates that the provided user address matches the client's connected account. * Only enforced when the client has an account — skips validation for public clients * (e.g., when building transactions to be signed externally). * * Throws {@link AddressMismatchError} if the client account is present * and does not match `userAddress`. * * @param clientAccountAddress - The client's account address (may be undefined). * @param userAddress - The user address provided by the caller. */ export declare const validateUserAddress: (clientAccountAddress: Address | undefined, userAddress: Address) => void; /** * Validates that the accrual position belongs to the expected market and user. * Throws {@link MarketIdMismatchError} if the position's market ID * does not match the expected market. * Throws {@link AccrualPositionUserMismatchError} if the position's user * does not match the expected user. * * @param params - Validation parameters. * @param params.positionData - The accrual position to validate. * @param params.expectedMarketId - The market ID the position must belong to. * @param params.expectedUser - The user address the position must belong to. */ export declare const validateAccrualPosition: (params: { positionData: AccrualPosition; expectedMarketId: MarketId; expectedUser: Address; }) => void; /** * Validates that the resulting position stays within the safe LTV threshold * (LLTV minus buffer) after supplying additional collateral and borrowing. * * @param params - Validation parameters. * @param params.positionData - The current accrual position with market data. * @param params.additionalCollateral - Amount of collateral being added. * @param params.borrowAmount - Amount being borrowed. * @param params.marketId - The market identifier (for error messages). * @param params.lltv - The market's liquidation LTV. */ export declare const validatePositionHealth: (params: { positionData: AccrualPosition; additionalCollateral: bigint; borrowAmount: bigint; marketId: MarketId; lltv: bigint; }) => void; /** * Validates that the viem client chain ID matches the expected chain ID. * Throws {@link ChainIdMismatchError} if they differ. * * @param clientChainId - Chain ID reported by the viem client (may be undefined). * @param expectedChainId - Chain ID expected by the entity or action. */ export declare const validateChainId: (clientChainId: number | undefined, expectedChainId: number) => void; /** * Validates that the given collateral token is the chain's wrapped native token. * Throws {@link ChainWNativeMissingError} if wNative is not configured for the chain. * Throws {@link NativeAmountOnNonWNativeCollateralError} if collateral is not wNative. * * @param chainId - The chain to look up wNative on. * @param collateralToken - The market's collateral token address. */ export declare const validateNativeCollateral: (chainId: number, collateralToken: Address) => void; /** * Validates that the resulting position stays within the safe LTV threshold * (LLTV minus buffer) after withdrawing collateral. * * @param params - Validation parameters. * @param params.positionData - The current accrual position with market data. * @param params.withdrawAmount - Amount of collateral being withdrawn. * @param params.lltv - The market's liquidation LTV. * @param params.marketId - The market identifier (for error messages). */ export declare const validatePositionHealthAfterWithdraw: (params: { positionData: AccrualPosition; withdrawAmount: bigint; lltv: bigint; marketId: MarketId; }) => void; /** * Validates that the repay amount assets does not exceed the outstanding debt. * * @param params - Validation parameters. * @param params.positionData - The current accrual position. * @param params.repayAssets - The amount of assets to repay. * @param params.marketId - The market identifier (for error messages). */ export declare const validateRepayAmount: (params: { positionData: AccrualPosition; repayAssets: bigint; marketId: MarketId; }) => void; /** * Validates that the repay shares do not exceed the outstanding borrow shares. * * @param params - Validation parameters. * @param params.positionData - The current accrual position. * @param params.repayShares - The amount of shares to repay. * @param params.marketId - The market identifier (for error messages). */ export declare const validateRepayShares: (params: { positionData: AccrualPosition; repayShares: bigint; marketId: MarketId; }) => void; /** * Validates the common repay input parameters shared by `marketV1Repay` * and `marketV1RepayWithdrawCollateral`. * * @param params - Validation parameters. * @param params.assets - Repay assets amount (0n when repaying by shares). * @param params.shares - Repay shares amount (0n when repaying by assets). * @param params.transferAmount - ERC20 amount to transfer to GeneralAdapter1. * @param params.maxSharePrice - Maximum repay share price (in ray). Must be positive. * @param params.marketId - The market identifier (for error messages). */ export declare const validateRepayParams: (params: { assets: bigint; shares: bigint; transferAmount: bigint; maxSharePrice: bigint; marketId: MarketId; }) => void; /** * Validates that vault reallocations are well-formed. * * Enforces the following invariants for each {@link VaultReallocation}: * - `fee` must be non-negative. * - `withdrawals` must be non-empty. * - Every withdrawal `amount` must be strictly positive. * - No withdrawal may target `targetMarketId` (the borrow market). * - Withdrawal market IDs must be strictly ascending (required by `PublicAllocator.reallocateTo`). * * @param reallocations - The reallocations to validate. * @param targetMarketId - The ID of the market being borrowed from. No withdrawal may reference this market. */ export declare const validateReallocations: (reallocations: readonly VaultReallocation[], targetMarketId: MarketId) => void; /** * Validates that a slippage tolerance is within an acceptable range. * * Throws {@link NegativeSlippageToleranceError} if negative. * Throws {@link ExcessiveSlippageToleranceError} if greater than {@link MAX_SLIPPAGE_TOLERANCE}. * * @param slippageTolerance - The slippage tolerance in WAD. */ export declare const validateSlippageTolerance: (slippageTolerance: bigint) => void;