UNPKG

@morpho-org/midnight-sdk

Version:

Viem-based package for Morpho Midnight that exports protocol utilities, fetch helpers, and Midnight API utilities under a dedicated API subpath.

35 lines (34 loc) • 1.51 kB
import { type Address, type Hex } from "viem"; /** * Computes the CREATE2 address of `owner`'s `BlueBuyCallback` for `salt`, as deployed or * returned by the chain's `midnightBlueBuyCallbackFactory.createBlueBuyCallback(owner, salt)`. * * The derivation is pure: it reads only the pinned creation bytecode and the address registry. * * @param params.chainId - Chain whose `midnightBlueBuyCallbackFactory`, `midnight` and `blue` are used. * @param params.owner - Callback owner, the maker. * @param params.salt - Callback salt. * @returns The callback address, whether or not it is deployed yet. * @throws {UnsupportedChainIdError} when the chain is absent from the address registry. * @throws {UnknownAddressError} when the chain has no `midnightBlueBuyCallbackFactory`, `midnight` or `blue` deployment. * @example * ```ts * import { getBlueBuyCallbackAddress } from "@morpho-org/midnight-sdk"; * import { ChainId } from "@morpho-org/morpho-ts"; * import { keccak256, toHex } from "viem"; * import type { Address } from "viem"; * * const callbackFor = (maker: Address) => * getBlueBuyCallbackAddress({ * chainId: ChainId.EthMainnet, * owner: maker, * salt: keccak256(toHex("my-strategy")), * }); * // `callbackFor(maker)` returns the maker's BlueBuyCallback address, deployed or not. * ``` */ export declare const getBlueBuyCallbackAddress: ({ chainId, owner, salt, }: { readonly chainId: number; readonly owner: Address; readonly salt: Hex; }) => Address;