tensaikit
Version:
An autonomous DeFi AI Agent Kit on Katana enabling AI agents to plan and execute on-chain financial operations.
38 lines (37 loc) • 1.95 kB
TypeScript
import { z } from "zod";
import { EvmWalletProvider } from "../../../walletProviders";
import { GetMarketInfoSchema } from "../schemas";
/**
* Fetches detailed market information for a given Morpho Blue market ID.
*
* This function interacts with the Morpho Blue smart contract on the current network,
* using the provided EVM wallet provider to read the market parameters associated with
* the specified `marketId`. These parameters include the loan token address, collateral
* token address, oracle, interest rate model (IRM), and loan-to-value ratio (LLTV).
*
* @param walletProvider - An instance of {@link EvmWalletProvider} connected to the user's wallet.
* @param args - An object validated by {@link GetMarketInfoSchema}, containing:
* @property {string} marketId - The unique bytes32 market identifier (hex string).
*
* @returns A Promise resolving to an object with the following properties:
* @property {string} marketId - The original market ID used in the request.
* @property {string} loanToken - The address of the loan token for the market.
* @property {string} collateralToken - The address of the collateral token.
* @property {string} oracle - The address of the oracle associated with the market.
* @property {string} irm - The address of the Interest Rate Model contract.
* @property {bigint} lltv - The loan-to-value ratio in basis points (1e4 = 100%).
*
* @throws Will throw an error if:
* - The network or chainId is invalid or unavailable.
* - The market ID does not exist or returns no response from the contract.
* - Any unexpected error occurs during contract read.
*/
export declare const fetchMarketConfigFromContract: (walletProvider: EvmWalletProvider, args: z.infer<typeof GetMarketInfoSchema>) => Promise<{
marketId: string;
morphoBlueContractAddress: `0x${string}`;
loanToken: any;
collateralToken: any;
oracle: any;
irm: any;
lltv: any;
}>;