import { type InputMarketParams } from "@morpho-org/blue-sdk"; import { type Address, type Hex, type Signature } from "viem"; import type { Action, Authorization, InputReallocation, Permit2PermitSingle } from "./types.js"; /** * Encoded low-level call consumed by Bundler3's `multicall`. */ export interface BundlerCall { /** Contract or account called by Bundler3. */ readonly to: Address; /** ABI-encoded calldata sent to `to`. */ readonly data: Hex; /** Native-token value sent with the call. */ readonly value: bigint; /** Whether Bundler3 should continue when the call reverts. */ readonly skipRevert: boolean; /** Expected callback hash for calls that reenter Bundler3, or zero hash. */ readonly callbackHash: Hex; } /** * Encodes the Bundler3 action subset used by `morpho-sdk` transaction builders. * * @remarks * The namespace covers only the Bundler3 actions required by `morpho-sdk`. * It does not expose operation population or broad simulation helpers. */ export declare namespace BundlerAction { /** * Encodes a list of Bundler3 actions into a single Bundler3 multicall * transaction request. * * @remarks * This is a low-level encoding helper, not a safe bundle constructor. It * does not validate that native-token pre-funding is fully consumed or that * pre-funding actions are ordered before the value-carrying calls they fund. * * When custom actions include `nativeTransfer(externalOwner, bundler3, * amount)`, no inner Bundler3 call is emitted for that transfer. Consumers * must ensure those pre-funding actions precede their downstream consumers * and leave no residual pre-funded native token; otherwise `tx.value` can be * over-counted or native token can remain stranded on Bundler3. The * high-level `morpho-sdk` action builders construct actions in that order, * but this invariant is not checked at runtime by `encodeBundle`. * * @param chainId - Chain where the bundle will execute. * @param actions - Ordered Bundler3 actions to encode. * @returns Transaction target, calldata, and native value required by the * bundle. * @throws {BundlerErrors.MissingSignature} when a signature action is unsigned. * @throws {BundlerErrors.UnexpectedAction} when an action is unavailable on the chain. * * @example * ```ts * import { getChainAddresses } from "@morpho-org/morpho-sdk/addresses"; * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const { generalAdapter1 } = getChainAddresses(1).bundler3; * const sender = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * * const tx = BundlerAction.encodeBundle(1, [ * { * type: "nativeTransfer", * args: [sender, generalAdapter1, 1_000000000000000000n], * }, * ]); * ``` */ function encodeBundle(chainId: number, actions: Action[]): { to: `0x${string}`; value: bigint; data: `0x${string}`; }; /** * Encodes a single supported Bundler3 action into one or more low-level * Bundler3 calls. * * @param chainId - Chain where the action will execute. * @param action - Bundler3 action to encode. * @returns Encoded Bundler3 calls. * @throws {BundlerErrors.MissingSignature} when a signature action is unsigned. * @throws {BundlerErrors.UnexpectedAction} when the action is unavailable on the chain. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * * const calls = BundlerAction.encode(1, { * type: "wrapNative", * args: [1_000000000000000000n, recipient], * }); * ``` */ function encode(chainId: number, action: Action): BundlerCall[]; /** * Encodes a native-token transfer for Bundler3 execution. * * @remarks * Transfers to Bundler3 are treated as bundle pre-funding and emit no inner * call. Transfers whose `owner` is GeneralAdapter1 are encoded as * `GeneralAdapter1.nativeTransfer(recipient, amount)` and always use * `skipRevert: false`; the caller-supplied `skipRevert` argument applies * only to direct native transfers from other owners. * * @param chainId - Chain where the action will execute. * @param owner - Current native-token owner in the bundle. * @param recipient - Native-token recipient. * @param amount - Native-token amount in wei. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const sender = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const recipient = "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359"; * * const calls = BundlerAction.nativeTransfer( * 1, * sender, * recipient, * 1_000000000000000000n, * ); * ``` */ function nativeTransfer(chainId: number, owner: Address, recipient: Address, amount: bigint, skipRevert?: boolean): BundlerCall[]; /** * Encodes an ERC20 transfer from the given adapter. * * @param asset - ERC20 token to transfer. * @param recipient - Recipient of the transferred tokens. * @param amount - Token amount to transfer. * @param adapter - Adapter that currently holds the tokens. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { getChainAddresses } from "@morpho-org/morpho-sdk/addresses"; * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const adapter = getChainAddresses(1).bundler3.generalAdapter1; * const asset = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * * const calls = BundlerAction.erc20Transfer( * asset, * recipient, * 100n, * adapter, * ); * ``` */ function erc20Transfer(asset: Address, recipient: Address, amount: bigint, adapter: Address, skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 ERC20 `transferFrom`. * * @param chainId - Chain where the action will execute. * @param asset - ERC20 token to transfer. * @param amount - Token amount to transfer. * @param recipient - Recipient of the transferred tokens. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const asset = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * * const calls = BundlerAction.erc20TransferFrom( * 1, * asset, * 100n, * recipient, * ); * ``` */ function erc20TransferFrom(chainId: number, asset: Address, amount: bigint, recipient: Address, skipRevert?: boolean): BundlerCall[]; /** * Encodes an ERC20 permit for GeneralAdapter1 spending. * * @param chainId - Chain where the action will execute. * @param owner - Token owner signing the permit. * @param asset - ERC20 token being permitted. * @param amount - Allowance amount. * @param deadline - Permit deadline timestamp. * @param signature - Owner signature. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const owner = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const asset = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const signature = * "0x111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222221b"; * * const calls = BundlerAction.permit( * 1, * owner, * asset, * 100n, * 1_900_000_000n, * signature, * ); * ``` */ function permit(chainId: number, owner: Address, asset: Address, amount: bigint, deadline: bigint, signature: Hex | Signature, skipRevert?: boolean): BundlerCall[]; /** * Encodes a Permit2 approval for GeneralAdapter1 spending. * * @param chainId - Chain where the action will execute. * @param owner - Token owner signing the Permit2 payload. * @param permitSingle - Permit2 allowance payload. * @param signature - Owner signature. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * @throws {BundlerErrors.UnexpectedAction} when Permit2 is unavailable on the chain. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const owner = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const token = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const signature = * "0x111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222221b"; * * const calls = BundlerAction.approve2( * 1, * owner, * { * details: { * token, * amount: 100n, * expiration: 1_900_000_000, * nonce: 0, * }, * sigDeadline: 1_900_000_000n, * }, * signature, * ); * ``` */ function approve2(chainId: number, owner: Address, permitSingle: Permit2PermitSingle, signature: Hex | Signature, skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 Permit2 transfer. * * @param chainId - Chain where the action will execute. * @param asset - ERC20 token to transfer through Permit2. * @param amount - Token amount to transfer. * @param recipient - Recipient of the transferred tokens. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const asset = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * * const calls = BundlerAction.transferFrom2( * 1, * asset, * 100n, * recipient, * ); * ``` */ function transferFrom2(chainId: number, asset: Address, amount: bigint, recipient: Address, skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 ERC4626 deposit. * * @param chainId - Chain where the action will execute. * @param erc4626 - ERC4626 vault address. * @param assets - Asset amount to deposit. * @param maxSharePrice - Maximum accepted share price in RAY. * @param receiver - Recipient of minted vault shares. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const vault = "0x186514400e52270cef3D80e1c6F8d10A75d47344"; * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * * const calls = BundlerAction.erc4626Deposit( * 1, * vault, * 100n, * 1_000000000000000000000000000n, * recipient, * ); * ``` */ function erc4626Deposit(chainId: number, erc4626: Address, assets: bigint, maxSharePrice: bigint, receiver: Address, skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 ERC4626 redeem. * * @param chainId - Chain where the action will execute. * @param erc4626 - ERC4626 vault address. * @param shares - Share amount to redeem. * @param minSharePrice - Minimum accepted share price in RAY. * @param receiver - Recipient of redeemed assets. * @param owner - Owner of the shares being redeemed. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const vault = "0x186514400e52270cef3D80e1c6F8d10A75d47344"; * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const owner = recipient; * * const calls = BundlerAction.erc4626Redeem( * 1, * vault, * 100n, * 900000000000000000000000000n, * recipient, * owner, * ); * ``` */ function erc4626Redeem(chainId: number, erc4626: Address, shares: bigint, minSharePrice: bigint, receiver: Address, owner: Address, skipRevert?: boolean): BundlerCall[]; /** * Encodes a Morpho Blue `setAuthorizationWithSig` call that submits a signed authorization. * * Lets a bundle grant `authorization.authorized` (GeneralAdapter1) operator rights on Morpho * on behalf of `authorization.authorizer` without a separate `setAuthorization` transaction. * * @param chainId - Chain where the action will execute. * @param authorization - The Morpho authorization payload covered by the signature. * @param signature - The owner's EIP-712 signature over the authorization typed data, as a hex * string or a viem `Signature` object. * @param skipRevert - Whether Bundler3 should tolerate a revert. Defaults to `true`, matching * the convention for already-authorized accounts (the call reverts harmlessly). * @returns Encoded Bundler3 calls. * @throws {BundlerErrors.UnexpectedSignature} when `authorization.authorized` is not the chain's * `GeneralAdapter1` — the only operator this bundled path may grant rights to. * * @example * ```ts * import { getChainAddresses } from "@morpho-org/morpho-sdk/addresses"; * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const { generalAdapter1 } = getChainAddresses(1).bundler3; * const owner = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const signature = * "0x111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222221b"; * * const calls = BundlerAction.morphoSetAuthorizationWithSig( * 1, * { * authorizer: owner, * authorized: generalAdapter1, * isAuthorized: true, * nonce: 0n, * deadline: 1_900_000_000n, * }, * signature, * ); * ``` */ function morphoSetAuthorizationWithSig(chainId: number, authorization: Authorization, signature: Hex | Signature, skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 Morpho Blue supply-collateral call. * * @param chainId - Chain where the action will execute. * @param market - Morpho Blue market parameters. * @param assets - Collateral asset amount to supply. * @param onBehalf - Account receiving the collateral position. * @param callbackCalls - Calls executed in Morpho's callback. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"; * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC"; * const onBehalf = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const marketParams = { * loanToken, * collateralToken, * oracle, * irm, * lltv: 860_000000000000000000n, * }; * * const calls = BundlerAction.morphoSupplyCollateral( * 1, * marketParams, * 100n, * onBehalf, * [], * ); * ``` */ function morphoSupplyCollateral(chainId: number, market: InputMarketParams, assets: bigint, onBehalf: Address, callbackCalls: BundlerCall[], skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 Morpho Blue supply call. * * @param chainId - Chain where the action will execute. * @param market - Morpho Blue market parameters. * @param assets - Supply asset amount. * @param shares - Supply share amount. * @param slippageAmount - Slippage guard amount (max share price in RAY for share-price slippage). * @param onBehalf - Account receiving the supply position. * @param callbackCalls - Calls executed in Morpho's callback. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"; * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC"; * const onBehalf = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const marketParams = { * loanToken, * collateralToken, * oracle, * irm, * lltv: 860_000000000000000000n, * }; * * const calls = BundlerAction.morphoSupply( * 1, * marketParams, * 100n, * 0n, * 1_010000000000000000000000000n, * onBehalf, * [], * ); * ``` */ function morphoSupply(chainId: number, market: InputMarketParams, assets: bigint, shares: bigint, slippageAmount: bigint, onBehalf: Address, callbackCalls: BundlerCall[], skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 Morpho Blue borrow call. * * @param chainId - Chain where the action will execute. * @param market - Morpho Blue market parameters. * @param assets - Borrow asset amount. * @param shares - Borrow share amount. * @param minSharePrice - Minimum amount of borrowed assets per borrow share minted, scaled by 1e27. * @param receiver - Recipient of borrowed assets. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"; * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC"; * const receiver = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const marketParams = { * loanToken, * collateralToken, * oracle, * irm, * lltv: 860_000000000000000000n, * }; * * const calls = BundlerAction.morphoBorrow( * 1, * marketParams, * 100n, * 0n, * 1_000000000000000000000000000n, * receiver, * ); * ``` */ function morphoBorrow(chainId: number, market: InputMarketParams, assets: bigint, shares: bigint, minSharePrice: bigint, receiver: Address, skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 Morpho Blue repay call. * * @param chainId - Chain where the action will execute. * @param market - Morpho Blue market parameters. * @param assets - Repay asset amount. * @param shares - Repay share amount. * @param maxSharePrice - Maximum amount of repaid assets per borrow share redeemed, scaled by 1e27. * @param onBehalf - Account whose borrow is repaid. * @param callbackCalls - Calls executed in Morpho's callback. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"; * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC"; * const onBehalf = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const marketParams = { * loanToken, * collateralToken, * oracle, * irm, * lltv: 860_000000000000000000n, * }; * * const calls = BundlerAction.morphoRepay( * 1, * marketParams, * 100n, * 0n, * 1_000000000000000000000000000n, * onBehalf, * [], * ); * ``` */ function morphoRepay(chainId: number, market: InputMarketParams, assets: bigint, shares: bigint, maxSharePrice: bigint, onBehalf: Address, callbackCalls: BundlerCall[], skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 Morpho Blue withdraw call. * * @param chainId - Chain where the action will execute. * @param market - Morpho Blue market parameters. * @param assets - Withdraw asset amount. * @param shares - Withdraw share amount. * @param slippageAmount - Slippage guard amount (min share price in RAY for share-price slippage). * @param receiver - Recipient of withdrawn assets. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"; * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC"; * const receiver = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const marketParams = { * loanToken, * collateralToken, * oracle, * irm, * lltv: 860_000000000000000000n, * }; * * const calls = BundlerAction.morphoWithdraw( * 1, * marketParams, * 100n, * 0n, * 990000000000000000000000000n, * receiver, * ); * ``` */ function morphoWithdraw(chainId: number, market: InputMarketParams, assets: bigint, shares: bigint, slippageAmount: bigint, receiver: Address, skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 Morpho Blue withdraw-collateral call. * * @param chainId - Chain where the action will execute. * @param market - Morpho Blue market parameters. * @param assets - Collateral asset amount to withdraw. * @param receiver - Recipient of withdrawn collateral. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"; * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC"; * const receiver = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * const marketParams = { * loanToken, * collateralToken, * oracle, * irm, * lltv: 860_000000000000000000n, * }; * * const calls = BundlerAction.morphoWithdrawCollateral( * 1, * marketParams, * 100n, * receiver, * ); * ``` */ function morphoWithdrawCollateral(chainId: number, market: InputMarketParams, assets: bigint, receiver: Address, skipRevert?: boolean): BundlerCall[]; /** * Encodes a PublicAllocator reallocation call. * * @param chainId - Chain where the action will execute. * @param vault - Vault to reallocate. * @param fee - Public allocator fee. * @param withdrawals - Market withdrawals performed before supply. * @param supplyMarketParams - Target supply market parameters. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * @throws {BundlerErrors.UnexpectedAction} when the PublicAllocator is unavailable on the chain. * @deprecated Vault V1 PublicAllocator composition will be removed in the next major. Use * `vaultV2BluePublicAllocatorReallocate` or `vaultV2BluePublicAllocatorAllocateFromIdle`. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const loanToken = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; * const collateralToken = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; * const oracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"; * const irm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC"; * const vault = "0x186514400e52270cef3D80e1c6F8d10A75d47344"; * const marketParams = { * loanToken, * collateralToken, * oracle, * irm, * lltv: 860_000000000000000000n, * }; * * const calls = BundlerAction.publicAllocatorReallocateTo( * 1, * vault, * 0n, * [{ marketParams, amount: 100n }], * marketParams, * ); * ``` */ function publicAllocatorReallocateTo(chainId: number, vault: Address, fee: bigint, withdrawals: InputReallocation[], supplyMarketParams: InputMarketParams, skipRevert?: boolean): BundlerCall[]; /** * Encodes a Vault V2 Blue Public Allocator market-to-market reallocation. * * @remarks Bundler3 must already hold the computed penalty assets. The * high-level Blue builders add the corresponding GeneralAdapter1 transfer. * * @param chainId - Chain whose canonical Blue Public Allocator is called. * @param vault - Vault whose liquidity is reallocated. * @param deallocateAdapter - Vault V2 adapter supplying the source market. * @param deallocateMarket - Source Morpho Blue market parameters. * @param allocateAdapter - Vault V2 adapter supplying the target market. * @param allocateMarket - Target Morpho Blue market parameters. * @param assets - Assets to reallocate, bounded by `uint128` by the high-level action. * @param penalty - Vault-configured proportional penalty, scaled by WAD. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns A zero reset and exact approval when needed, then the allocator call. * @throws {BundlerErrors.UnexpectedAction} when the chain has no Blue Public Allocator deployment. * @throws {BundlerErrors.SkippableAllocatorPenalty} when `skipRevert` is true and a token approval is required. * @example * ```ts * import { ChainId } from "@morpho-org/morpho-sdk/constants"; * import type { BlueInputMarketParams } from "@morpho-org/morpho-sdk/types"; * import { * BundlerAction, * type BundlerCall, * } from "@morpho-org/morpho-sdk/bundler"; * import type { Address } from "viem"; * * const keyrockUsdcVault = * "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145" satisfies Address; * const sourceAdapterFixture = * "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" satisfies Address; * const targetAdapterFixture = * "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" satisfies Address; * const usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" satisfies Address; * const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" satisfies Address; * const wbtc = "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" satisfies Address; * const ethUsdOracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" satisfies Address; * const adaptiveCurveIrm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" satisfies Address; * const sourceMarket = { * loanToken: usdc, * collateralToken: weth, * oracle: ethUsdOracle, * irm: adaptiveCurveIrm, * lltv: 860_000_000_000_000_000n, * } satisfies BlueInputMarketParams; * const targetMarket = { * ...sourceMarket, * collateralToken: wbtc, * } satisfies BlueInputMarketParams; * * const calls: BundlerCall[] = BundlerAction.vaultV2BluePublicAllocatorReallocate( * ChainId.EthMainnet, * keyrockUsdcVault, * sourceAdapterFixture, * sourceMarket, * targetAdapterFixture, * targetMarket, * 1_000_000n, * 1_000_000_000_000_000n, * ); * // Bundler3 resets and approves 1_000 USDC units, then calls `reallocate` with zero native value. * ``` */ function vaultV2BluePublicAllocatorReallocate(chainId: number, vault: Address, deallocateAdapter: Address, deallocateMarket: InputMarketParams, allocateAdapter: Address, allocateMarket: InputMarketParams, assets: bigint, penalty: bigint, skipRevert?: boolean): BundlerCall[]; /** * Encodes a Vault V2 Blue Public Allocator allocation from vault idle liquidity. * * @remarks Bundler3 must already hold the computed penalty assets. The * high-level Blue builders add the corresponding GeneralAdapter1 transfer. * * @param chainId - Chain whose canonical Blue Public Allocator is called. * @param vault - Vault whose idle liquidity is allocated. * @param adapter - Vault V2 adapter supplying the target market. * @param market - Target Morpho Blue market parameters. * @param assets - Assets to allocate, bounded by `uint128` by the high-level action. * @param penalty - Vault-configured proportional penalty, scaled by WAD. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns A zero reset and exact approval when needed, then the allocator call. * @throws {BundlerErrors.UnexpectedAction} when the chain has no Blue Public Allocator deployment. * @throws {BundlerErrors.SkippableAllocatorPenalty} when `skipRevert` is true and a token approval is required. * @example * ```ts * import { ChainId } from "@morpho-org/morpho-sdk/constants"; * import type { BlueInputMarketParams } from "@morpho-org/morpho-sdk/types"; * import { * BundlerAction, * type BundlerCall, * } from "@morpho-org/morpho-sdk/bundler"; * import type { Address } from "viem"; * * const keyrockUsdcVault = * "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145" satisfies Address; * const targetAdapterFixture = * "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" satisfies Address; * const usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" satisfies Address; * const weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" satisfies Address; * const ethUsdOracle = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" satisfies Address; * const adaptiveCurveIrm = "0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC" satisfies Address; * const targetMarket = { * loanToken: usdc, * collateralToken: weth, * oracle: ethUsdOracle, * irm: adaptiveCurveIrm, * lltv: 860_000_000_000_000_000n, * } satisfies BlueInputMarketParams; * * const calls: BundlerCall[] = BundlerAction.vaultV2BluePublicAllocatorAllocateFromIdle( * ChainId.EthMainnet, * keyrockUsdcVault, * targetAdapterFixture, * targetMarket, * 1_000_000n, * 1_000_000_000_000_000n, * ); * // Bundler3 resets and approves 1_000 USDC units, then calls `allocateFromIdle` with zero native value. * ``` */ function vaultV2BluePublicAllocatorAllocateFromIdle(chainId: number, vault: Address, adapter: Address, market: InputMarketParams, assets: bigint, penalty: bigint, skipRevert?: boolean): BundlerCall[]; /** * Encodes a GeneralAdapter1 native-token wrap call. * * @param chainId - Chain where the action will execute. * @param amount - Native-token amount to wrap. * @param recipient - Recipient of wrapped native tokens. * @param skipRevert - Whether Bundler3 should tolerate a revert. * @returns Encoded Bundler3 calls. * * @example * ```ts * import { BundlerAction } from "@morpho-org/morpho-sdk/bundler"; * * const recipient = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; * * const calls = BundlerAction.wrapNative( * 1, * 1_000000000000000000n, * recipient, * ); * ``` */ function wrapNative(chainId: number, amount: bigint, recipient: Address, skipRevert?: boolean): BundlerCall[]; }