UNPKG

tensaikit

Version:

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

24 lines (23 loc) 952 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchAllTokenPrices = void 0; const errors_1 = require("../../../common/errors"); const utlis_1 = require("../utlis"); /** * Fetches USD prices for all tokens available on the specified EVM chain via the SushiSwap module. * * @param chainId - The chain ID (as a string) representing the target blockchain network. * @returns A promise resolving to a map of token addresses to their current USD prices. * @throws Throws a formatted error if price fetching fails. */ const fetchAllTokenPrices = async (chainId) => { try { const sushiSwapModule = await (0, utlis_1.SushiSwapModule)(); const typedChainId = chainId; return await sushiSwapModule.prices(typedChainId); } catch (error) { throw (0, errors_1.handleError)("Failed to fetch all token prices", error); } }; exports.fetchAllTokenPrices = fetchAllTokenPrices;