import { type Market } from "@morpho-org/blue-sdk"; /** * Computes the minimum borrow share price (in RAY, 1e27) for slippage protection. * * Mirrors the on-chain check in GeneralAdapter1's `morphoBorrow`: * ```solidity * require(borrowedAssets.rDivDown(borrowedShares) >= minSharePriceE27) * ``` * * @param params - Computation parameters. * @param params.borrowAmount - The amount of assets to borrow. * @param params.market - The market to compute the minimum borrow share price for. * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. 0.003e18 = 0.3%). * @returns minSharePriceE27 in RAY scale (1e27). */ export declare function computeMinBorrowSharePrice(params: { borrowAmount: bigint; market: Market; slippageTolerance: bigint; }): bigint; /** * Computes the maximum repay share price (in RAY, 1e27) for slippage protection. * * Supports both repay-by-assets and repay-by-shares paths: * - By assets: derives expected shares from the repay amount via `toBorrowShares("Down")`. * - By shares: derives expected assets from the shares via `toBorrowAssets("Up")`. * * Direction is opposite of borrow's `minSharePrice`: * - Borrow uses `(WAD - slippage)` → lower bound (protects borrower from getting fewer assets per share). * - Repay uses `(WAD + slippage)` → upper bound (protects repayer from paying too many assets per share). * * Capped at {@link MAX_ABSOLUTE_SHARE_PRICE} to prevent absurd values. * * @param params - Computation parameters. * @param params.repayAssets - The amount of assets to repay (0n when repaying by shares). * @param params.repayShares - The amount of shares to repay (0n when repaying by assets). * @param params.market - The market to compute the maximum repay share price for. * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. 0.003e18 = 0.3%). * @returns maxSharePriceE27 in RAY scale (1e27). */ export declare function computeMaxRepaySharePrice(params: { repayAssets: bigint; repayShares: bigint; market: Market; slippageTolerance: bigint; }): bigint; /** * Computes the maximum supply share price (in RAY, 1e27) for slippage protection. * * Mirrors the on-chain check in GeneralAdapter1's `morphoSupply`: * ```solidity * require(suppliedAssets.rDivUp(suppliedShares) <= maxSharePriceE27) * ``` * * Caps at {@link MAX_ABSOLUTE_SHARE_PRICE} to prevent absurd values on extreme markets. * * @param params - Computation parameters. * @param params.supplyAssets - The amount of loan assets to supply. * @param params.market - The market to compute the maximum supply share price for. * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%). * @returns `maxSharePriceE27` in RAY scale (1e27). * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance >= WAD`. * @throws {ShareDivideByZeroError} when expected shares round down to zero. */ export declare function computeMaxSupplySharePrice(params: { supplyAssets: bigint; market: Market; slippageTolerance: bigint; }): bigint; /** * Computes the minimum withdraw share price (in RAY, 1e27) for slippage protection. * * Mirrors the on-chain check in GeneralAdapter1's `morphoWithdraw`: * ```solidity * require(withdrawnAssets.rDivDown(withdrawnShares) >= minSharePriceE27) * ``` * * Supports both assets and shares modes: * - By assets: derives expected shares via `toSupplyShares("Up")` (upper bound, protects the * withdrawer against over-burning shares). * - By shares: derives expected assets via `toSupplyAssets("Down")` (lower bound, the on-chain * amount paid out). * * Direction is opposite of supply's `maxSharePrice`: * - Supply uses `(WAD + slippage)` → upper bound (anti-inflation). * - Withdraw uses `(WAD − slippage)` → lower bound (protects withdrawer from receiving too few * assets per share burned). * * @param params - Computation parameters. * @param params.withdrawAssets - The amount of assets to withdraw (`0n` when withdrawing by shares). * @param params.withdrawShares - The amount of shares to withdraw (`0n` when withdrawing by assets). * @param params.market - The market to compute the minimum withdraw share price for. * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%). * @returns `minSharePriceE27` in RAY scale (1e27). * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance >= WAD`. * @throws {ShareDivideByZeroError} when expected shares round down to zero. */ export declare function computeMinWithdrawSharePrice(params: { withdrawAssets: bigint; withdrawShares: bigint; market: Market; slippageTolerance: bigint; }): bigint;