UNPKG

tensaikit

Version:

An autonomous DeFi AI Agent Kit on Katana enabling AI agents to plan and execute on-chain financial operations.

36 lines (35 loc) 1.82 kB
import { z } from "zod"; import { EvmWalletProvider } from "../../../walletProviders"; import { SupplySchema } from "../schemas"; /** * Supplies a specified amount of loanToken into a Morpho Blue market on behalf of the connected wallet. * * This function: * 1. Validates input and ensures asset amount is greater than zero. * 2. Fetches market configuration using the provided marketId. * 3. Reads the loanToken's decimals and parses the asset amount into atomic units. * 4. Checks allowance and, if necessary, approves the Morpho Blue contract to spend tokens. * 5. Prepares the calldata for the `supply` function on the Morpho Blue contract. * 6. Sends the supply transaction and returns the transaction hash and receipt. * * @param walletProvider - Instance of {@link EvmWalletProvider} connected to the user's wallet. * @param args - Validated input matching {@link SupplySchema}, containing: * @property {string} assets - Amount of loanToken to supply (as a string in human-readable units). * @property {string} marketId - Unique market identifier (bytes32 hex string). * * @returns A Promise resolving to an object containing: * @property {string} loanToken - The address of the loan token used. * @property {string} txHash - The hash of the supply transaction. * @property {object} receipt - The transaction receipt from the network. * * @throws Will throw if: * - The input `assets` value is zero or invalid. * - Market configuration cannot be fetched or is invalid. * - Approve call fails, or allowance check/setting fails. * - The transaction fails to send or confirm. */ export declare const writeSupplyLoanToken: (walletProvider: EvmWalletProvider, args: z.infer<typeof SupplySchema>) => Promise<{ loanToken: any; txHash: `0x${string}`; receipt: any; }>;