get_liquidity_depth
Analyze token liquidity depth by checking pool reserves across all DEXes on Base blockchain to assess market stability and trading conditions.
Instructions
Check pool reserves and liquidity depth for a token across all DEXes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_address | Yes | Token contract address on Base |
Implementation Reference
- src/index.ts:653-716 (handler)Implementation of the get_liquidity_depth MCP tool, which queries DEX pools for token reserves and liquidity data.
server.tool( "get_liquidity_depth", "Check pool reserves and liquidity depth for a token across all DEXes", { token_address: z.string().describe("Token contract address on Base"), }, async ({ token_address }) => { try { const quoteAddress = WETH; const [tokenDecimals, quoteDecimals, tokenSymbol] = await Promise.all([ getTokenDecimals(token_address), getTokenDecimals(quoteAddress), getTokenSymbol(token_address), ]); const pools = await findAllPools(token_address, quoteAddress); if (pools.length === 0) { return { content: [{ type: "text" as const, text: `No DEX pools found for ${token_address} on Base.` }] }; } const poolData = pools.map((pool) => { const price = calculatePrice(pool, tokenDecimals, quoteDecimals); if (pool.sqrtPriceX96 !== undefined) { // V3 pool — report liquidity return { dex: pool.dex, pool: pool.address, type: "concentrated", liquidity: pool.liquidity?.toString() ?? "0", price: formatEth(price), }; } // V2/Aerodrome — report reserves const tokenReserve = pool.tokenIsToken0 ? Number(ethers.formatUnits(pool.reserve0, tokenDecimals)) : Number(ethers.formatUnits(pool.reserve1, tokenDecimals)); const ethReserve = pool.tokenIsToken0 ? Number(ethers.formatUnits(pool.reserve1, quoteDecimals)) : Number(ethers.formatUnits(pool.reserve0, quoteDecimals)); return { dex: pool.dex, pool: pool.address, type: "constant-product", tokenReserve: tokenReserve.toFixed(4), ethReserve: formatEth(ethReserve), totalValueETH: formatEth(ethReserve * 2), price: formatEth(price), }; }); return { content: [{ type: "text" as const, text: JSON.stringify({ token: token_address, symbol: tokenSymbol, poolCount: pools.length, pools: poolData, }, null, 2), }], };