dex-get-pools
Retrieve all available liquidity pools from the DEX by specifying the network name, enabling users to access essential data for trading and asset management on MantraChain.
Instructions
Get all available liquidity pools from the DEX
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| networkName | Yes | Name of the network to use - must first check available networks through `networks://all` |
Implementation Reference
- src/tools/dex.ts:17-23 (handler)MCP tool handler for 'dex-get-pools': initializes MantraClient and retrieves pools via getPools(), returns as JSON text content.async ({ networkName }) => { await mantraClient.initialize(networkName); const pools = await mantraClient.getPools(); return { content: [{type: "text", text: JSON.stringify(pools)}], }; }
- src/tools/dex.ts:12-16 (schema)Input schema for the tool using Zod: validates networkName against available networks.{ networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check available networks through `networks://all`"), },
- src/tools/dex.ts:9-24 (registration)Registration of the 'dex-get-pools' MCP tool using server.tool(), including name, description, input schema, and handler.server.tool( "dex-get-pools", "Get all available liquidity pools from the DEX", { networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check available networks through `networks://all`"), }, async ({ networkName }) => { await mantraClient.initialize(networkName); const pools = await mantraClient.getPools(); return { content: [{type: "text", text: JSON.stringify(pools)}], }; } );
- src/services/dex-service.ts:59-69 (helper)Core implementation of getPools() in DexService: queries the DEX smart contract with { pools: {} } to retrieve all pool information.async getPools(): Promise<PoolInfo[]> { try { const contractAddress = this.getDexContractAddress(); const response = await this.wasmClient.queryContractSmart(contractAddress, { pools: {} }); return response.pools; } catch (error) { throw new Error(`Failed to get pools: ${error instanceof Error ? error.message : String(error)}`); } }
- src/mantra-client.ts:274-279 (helper)Wrapper method in MantraClient.getPools() that delegates to DexService.getPools() after checking initialization.async getPools(): Promise<PoolInfo[]> { if (!this.dexService) { throw new Error('Client not initialized. Call initialize() first.'); } return this.dexService.getPools(); }