UNPKG

tensaikit

Version:

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

25 lines (24 loc) 980 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchTokenMetadata = void 0; const errors_1 = require("../../../common/errors"); const utils_1 = require("../../../common/utils"); const utlis_1 = require("../utlis"); /** * Fetches metadata for a token (e.g., decimals, symbol, name) from SushiSwap's public API. * * @param chainId - Chain ID the token belongs to * @param tokenAddress - The ERC20 token contract address * @returns An object containing token metadata * @throws If the API call fails or returns an error */ const fetchTokenMetadata = async (chainId, tokenAddress) => { try { const metadata = await (0, utils_1.fetchFromApi)(`${utlis_1.SUSHI_TOKEN_ENDPOINT}/${chainId}/${tokenAddress}`); return metadata; } catch (error) { throw (0, errors_1.createError)("Failed to fetch token information", errors_1.ErrorCode.API_CALL_FAILED); } }; exports.fetchTokenMetadata = fetchTokenMetadata;