get_asset_price
Retrieve current asset prices from Aave oracles to monitor collateral values, assess liquidation risks, and analyze protocol positions.
Instructions
Get current price for a specific asset from Aave oracle.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assetAddress | Yes | Token contract address |
Implementation Reference
- src/index.ts:105-119 (registration)Tool registration in the listTools handler, including name, description, and input schema definition.{ name: 'get_asset_price', description: 'Get current price for a specific asset from Aave oracle.', inputSchema: { type: 'object', properties: { assetAddress: { type: 'string', description: 'Token contract address', }, }, required: ['assetAddress'], }, },
- src/index.ts:341-374 (handler)Primary MCP tool handler that validates the assetAddress input and calls the AaveClient to retrieve the price, then formats the response.case 'get_asset_price': { const assetAddress = args?.assetAddress as string; if (!assetAddress || typeof assetAddress !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'assetAddress parameter is required and must be a string' ); } if (!aaveClient.isValidAddress(assetAddress)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid Ethereum address format' ); } const price = await aaveClient.getAssetPrice(assetAddress); return { content: [ { type: 'text', text: JSON.stringify( { assetAddress, priceUSD: price, }, null, 2 ), }, ], }; }
- src/aave-client.ts:182-186 (helper)Helper method in AaveClient that queries the Aave oracle contract for the asset price and formats it to USD string.async getAssetPrice(assetAddress: string): Promise<string> { const price = await this.oracleContract.getAssetPrice(assetAddress); // Oracle returns price with 8 decimals return ethers.formatUnits(price, 8); }