import type { Client } from "viem"; import { type Address } from "viem"; import { type AuthorizationRequirementSignature, type BlueAuthorizationAction, type Requirement, type Transaction } from "../../../types/index.js"; /** * Resolves whether `GeneralAdapter1` needs Blue authorization for the given user, and returns * the requirement to satisfy it when it does. * * Reads `Morpho.isAuthorized(userAddress, generalAdapter1)` on the target chain. Required before * any bundled Blue path that operates on behalf of the user (`borrow`, `withdraw`, * `supplyCollateralBorrow`, `repayWithdrawCollateral`, `refinance`). * * - When `supportSignature` is falsy (default), returns the * `setAuthorization(generalAdapter1, true)` transaction the user submits before the bundle. * - When `supportSignature` is `true`, reads the user's Morpho `nonce` and returns a signable * `Requirement`; the signed authorization is folded into the bundle via * `setAuthorizationWithSig`, removing the standalone transaction. * * @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`. * @param params.chainId - Target chain id (used to resolve Morpho and `GeneralAdapter1`). * @param params.userAddress - The user that must authorize `GeneralAdapter1`. * @param params.supportSignature - When `true`, return a signable `Requirement` instead of a * transaction so authorization can be bundled via `setAuthorizationWithSig`. * @returns A deep-frozen `Transaction`, a signable authorization * `Requirement` (when `supportSignature` is `true`), or `null` when authorization is already in * place. * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`. * @example * ```ts * import { createPublicClient, http } from "viem"; * import { mainnet } from "viem/chains"; * import { getBlueAuthorizationRequirement } from "@morpho-org/morpho-sdk"; * * const client = createPublicClient({ chain: mainnet, transport: http() }); * const requirement = await getBlueAuthorizationRequirement({ * viemClient: client, * chainId: 1, * userAddress: borrower, * supportSignature: true, * }); * // requirement is null when already authorized, a Requirement when supportSignature is true, * // otherwise Readonly> * ``` */ export declare const getBlueAuthorizationRequirement: (params: { viemClient: Client; chainId: number; userAddress: Address; supportSignature?: boolean; }) => Promise> | Requirement | null>;