get_historical_liquidity
Retrieve historical liquidity data for token swaps on specific blockchain networks to analyze trading conditions and market depth over time.
Instructions
GET /api/historicalLiquidity/{token}
Provides the available liquidity for swapping from one token to another on a specific chain.
Parameters:
token: token slug (e.g., 'usdt')
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes |
Implementation Reference
- defillama_server.py:332-342 (handler)The tool handler for 'get_historical_liquidity'. Decorated with @mcp.tool() for registration. Takes a token slug, queries the DefiLlama API for historical liquidity data, and returns the JSON response as a string.@mcp.tool() async def get_historical_liquidity(token: str) -> str: """GET /api/historicalLiquidity/{token} Provides the available liquidity for swapping from one token to another on a specific chain. Parameters: token: token slug (e.g., 'usdt') """ result = await make_request('GET', f'/api/historicalLiquidity/{token}') return str(result)
- defillama_server.py:30-38 (helper)Shared helper function used by get_historical_liquidity (and other tools) to make HTTP requests to the DefiLlama API.async def make_request(method: str, endpoint: str, params: Optional[Dict[str, Any]] = None) -> Any: """Make a request to the DefiLlama API.""" try: response = await client.request(method, endpoint, params=params) response.raise_for_status() return response.json() except Exception as e: return f"Error: {str(e)}"