Skip to main content
Glama
formatTokenAmount.ts746 B
import { formatUnits } from "ethers"; export interface FormattedTokenAmount { raw: string; formatted: string; readable: string; } /** * Formats a token amount with the given decimals and optional symbol * @param amount - The raw token amount as a string * @param decimals - The number of decimals for the token * @param symbol - Optional token symbol to append to the readable format * @returns An object containing raw, formatted, and readable representations */ export function formatTokenAmount(amount: string, decimals: number, symbol?: string): FormattedTokenAmount { const formatted = formatUnits(amount, decimals); return { raw: amount, formatted, readable: `${formatted}${symbol ? ` ${symbol}` : ''}` }; }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/crazyrabbitLTC/mpc-tally-api-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server