Skip to main content
Glama
clumsynonono

Aave Liquidation MCP Server

by clumsynonono

get_user_health

Check an Ethereum address's health factor, collateral, debt, and liquidation status on Aave V3 to monitor position safety and identify risks.

Instructions

Get health factor and account data for a specific Ethereum address on Aave V3. Returns collateral, debt, and liquidation status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesEthereum address to check (must be a valid address)

Implementation Reference

  • src/index.ts:52-65 (registration)
    Registration of the 'get_user_health' tool in the ListTools response, including name, description, and input schema.
    name: 'get_user_health', description: 'Get health factor and account data for a specific Ethereum address on Aave V3. Returns collateral, debt, and liquidation status.', inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Ethereum address to check (must be a valid address)', }, }, required: ['address'], }, },
  • Input schema definition for the get_user_health tool.
    inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Ethereum address to check (must be a valid address)', }, }, required: ['address'], },
  • MCP CallTool handler for 'get_user_health': validates input, fetches account data via AaveClient, formats response.
    case 'get_user_health': { const address = args?.address as string; if (!address || typeof address !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'address parameter is required and must be a string' ); } if (!aaveClient.isValidAddress(address)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid Ethereum address format' ); } const accountData = await aaveClient.getUserAccountData(address); return { content: [ { type: 'text', text: JSON.stringify( { address: accountData.address, healthFactor: accountData.healthFactorFormatted, totalCollateralUSD: parseFloat( ethers.formatUnits(accountData.totalCollateralBase, 8) ).toFixed(2), totalDebtUSD: parseFloat( ethers.formatUnits(accountData.totalDebtBase, 8) ).toFixed(2), availableBorrowsUSD: parseFloat( ethers.formatUnits(accountData.availableBorrowsBase, 8) ).toFixed(2), liquidationThreshold: parseFloat( (Number(accountData.currentLiquidationThreshold) / 10000).toFixed(4) ), ltv: parseFloat((Number(accountData.ltv) / 10000).toFixed(4)), isLiquidatable: accountData.isLiquidatable, isAtRisk: accountData.isAtRisk, status: accountData.isLiquidatable ? 'LIQUIDATABLE' : accountData.isAtRisk ? 'AT_RISK' : 'HEALTHY', }, null, 2 ), }, ], }; }
  • Core helper function in AaveClient that queries the Aave V3 pool contract for user account data and computes health factor, liquidation risk.
    async getUserAccountData(userAddress: string): Promise<UserAccountData> { const data = await this.poolContract.getUserAccountData(userAddress); const healthFactorFormatted = ethers.formatUnits(data.healthFactor, 18); const healthFactorNumber = parseFloat(healthFactorFormatted); return { address: userAddress, totalCollateralBase: data.totalCollateralBase, totalDebtBase: data.totalDebtBase, availableBorrowsBase: data.availableBorrowsBase, currentLiquidationThreshold: data.currentLiquidationThreshold, ltv: data.ltv, healthFactor: data.healthFactor, healthFactorFormatted, isLiquidatable: healthFactorNumber < LIQUIDATION_THRESHOLD && healthFactorNumber > 0, isAtRisk: healthFactorNumber < WARNING_THRESHOLD && healthFactorNumber > 0, }; }

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/clumsynonono/aave-liquidation-mcp'

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