Skip to main content
Glama

sodax_get_money_market_assets

Retrieve available lending and borrowing assets in the SODAX money market. Filter by chain ID and choose response format to access real-time financial data.

Instructions

List all assets available for lending and borrowing in the SODAX money market

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNoFilter by chain ID
formatNoResponse format: 'json' for raw data or 'markdown' for formatted textmarkdown

Implementation Reference

  • MCP tool registration and handler function for sodax_get_money_market_assets. Defines the tool with zod schema validation (chainId and format parameters) and implements the async handler that calls getMoneyMarketAssets service function and formats the response.
    // Tool 7: Get Money Market Assets
    server.tool(
      "sodax_get_money_market_assets",
      "List all assets available for lending and borrowing in the SODAX money market",
      {
        chainId: z.string().optional()
          .describe("Filter by chain ID"),
        format: z.nativeEnum(ResponseFormat).optional().default(ResponseFormat.MARKDOWN)
          .describe("Response format: 'json' for raw data or 'markdown' for formatted text")
      },
      READ_ONLY,
      async ({ chainId, format }) => {
        try {
          const assets = await getMoneyMarketAssets(chainId);
          const header = chainId 
            ? `## Money Market Assets on ${chainId}\n\n`
            : `## Money Market Assets\n\n`;
          return {
            content: [{
              type: "text",
              text: header + `${assets.length} assets available\n\n` + formatResponse(assets, format)
            }]
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : "Unknown error"}` }],
            isError: true
          };
        }
      }
    );
  • Core service function getMoneyMarketAssets that implements the business logic. Fetches money market assets from the SODAX API endpoint '/moneymarket/asset/all', implements caching, and returns an array of MoneyMarketAsset objects.
    /**
     * List lending/borrowing assets in money market
     */
    export async function getMoneyMarketAssets(chainId?: string): Promise<MoneyMarketAsset[]> {
      const cacheKey = `mm-assets-${chainId || "all"}`;
      const cached = getCached<MoneyMarketAsset[]>(cacheKey);
      if (cached) return cached;
    
      try {
        // Always use the /all endpoint, API doesn't support chainId filter
        const response = await apiClient.get("/moneymarket/asset/all");
        // API returns array directly
        const assets = Array.isArray(response.data) ? response.data : (response.data?.data || []);
        setCache(cacheKey, assets);
        return assets;
      } catch (error) {
        console.error("Error fetching money market assets:", error);
        throw new Error("Failed to fetch money market assets from SODAX API");
      }
    }
  • Type definition for MoneyMarketAsset interface. Defines the structure of money market asset data including address, chainId, symbol, name, decimals, totalSupply, totalBorrow, supplyApy, borrowApy, collateralFactor, liquidationThreshold, and priceUsd.
    /**
     * Money market asset
     */
    export interface MoneyMarketAsset {
      address: string;
      chainId: string;
      symbol: string;
      name: string;
      decimals: number;
      totalSupply: string;
      totalBorrow: string;
      supplyApy: number;
      borrowApy: number;
      collateralFactor: number;
      liquidationThreshold: number;
      priceUsd: number;
    }
  • ResponseFormat enum defining the two output format options for the tool: JSON for raw data or MARKDOWN for formatted text display.
    export enum ResponseFormat {
      JSON = "json",
      MARKDOWN = "markdown"
    }
  • Helper function formatResponse that conditionally formats the tool output based on the requested ResponseFormat. Returns formatted Markdown or JSON string representation of the data.
    function formatResponse(data: unknown, format: ResponseFormat): string {
      if (format === ResponseFormat.MARKDOWN) {
        return formatAsMarkdown(data);
      }
      return JSON.stringify(data, null, 2);
    }

Latest Blog Posts

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/gosodax/sodax-builders-mcp'

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