sodax_get_user_position
Retrieve a user's lending and borrowing position in a money market by wallet address. Returns data in JSON or markdown format.
Instructions
Get a user's lending and borrowing position in the money market
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userAddress | Yes | The wallet address to look up | |
| format | No | Response format: 'json' for raw data or 'markdown' for formatted text | markdown |
Implementation Reference
- src/tools/sodaxApi.ts:370-402 (handler)MCP tool handler for 'sodax_get_user_position' — registers the tool with the MCP server, accepts userAddress and optional format params, calls getUserPosition service, and formats the response as markdown or JSON.
// Tool 8: Get User Position server.tool( "sodax_get_user_position", "Get a user's lending and borrowing position in the money market", { userAddress: z.string() .describe("The wallet address to look up"), format: z.nativeEnum(ResponseFormat).optional().default(ResponseFormat.MARKDOWN) .describe("Response format: 'json' for raw data or 'markdown' for formatted text") }, READ_ONLY, async ({ userAddress, format }) => { try { const position = await getUserPosition(userAddress); if (!position) { return { content: [{ type: "text", text: `No money market position found for ${userAddress}` }] }; } return { content: [{ type: "text", text: `## Money Market Position\n\n**Address:** ${userAddress}\n\n` + formatResponse(position, format) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : "Unknown error"}` }], isError: true }; } } ); - src/types.ts:142-163 (schema)TypeScript interface 'UserPosition' defining the shape of the position data returned by the tool (address, totalSupplyUsd, totalBorrowUsd, healthFactor, netApy, supplies/borrows arrays).
export interface UserPosition { address: string; chainId?: string; totalSupplyUsd: number; totalBorrowUsd: number; healthFactor: number; netApy: number; supplies: { asset: string; symbol: string; amount: string; valueUsd: number; apy: number; }[]; borrows: { asset: string; symbol: string; amount: string; valueUsd: number; apy: number; }[]; } - src/services/sodaxApi.ts:260-275 (helper)Backend service function 'getUserPosition' — fetches the user's money market position from SODAX API via GET /moneymarket/position/{userAddress}. Returns null on 404.
* Get user's money market position */ export async function getUserPosition( userAddress: string ): Promise<UserPosition | null> { try { const response = await apiClient.get(`/moneymarket/position/${userAddress}`); return response.data?.data || response.data || null; } catch (error) { if (axios.isAxiosError(error) && error.response?.status === 404) { return null; } console.error("Error fetching user position:", error); throw new Error("Failed to fetch user position from SODAX API"); } } - src/index.ts:44-44 (registration)Registration entry point — calls registerSodaxApiTools(server) which registers all SODAX tools including sodax_get_user_position on the MCP server.
registerSodaxApiTools(server); - src/services/analytics.ts:56-56 (helper)Analytics group mapping — maps 'sodax_get_user_position' tool name to the 'api' group for PostHog analytics tracking.
sodax_get_user_position: "api",