DEX_LIST
Retrieve a list of decentralized exchanges (DEXs) available on a specified blockchain network to identify trading platforms for token swaps.
Instructions
Get dex list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain | No | The blockchain network to execute the transaction on. uses fraxtal as default | fraxtal |
Implementation Reference
- src/tools/chain.ts:60-82 (handler)The main handler function that executes the DEX_LIST tool logic. It resolves the chain from input, fetches the DEX list using ChainService, handles errors, and returns a JSON string.export const dexList = async (args: z.infer<typeof chainParamsSchema>) => { try { const inputChain = args.chain.toLowerCase(); const chainObject = getChainFromName(inputChain); console.error(`[DEX_LIST] Using chain: ${chainObject.name}`); const service = new ChainService(); const dexList = await service.dexList(chainObject.id); if (dexList instanceof Error) { return `Error fetching dexList: ${dexList.message}`; } return JSON.stringify(dexList, null, 2); } catch (error: unknown) { const message = error instanceof Error ? error.message : "An unknown error occurred while fetching dexList."; console.error(`[DEX_LIST] Error: ${message}`); throw new Error(`Failed to fetch dexList: ${message}`); } }
- src/types.ts:4-12 (schema)Zod schema for input parameters of DEX_LIST (and other chain tools), defining an optional chain name with default 'fraxtal'.export const chainParamsSchema = z.object({ chain: z .string() .optional() .describe( "The blockchain network to execute the transaction on. uses fraxtal as default", ) .default("fraxtal") });
- src/tools/index.ts:16-21 (registration)Tool registration object for DEX_LIST, specifying name, description, input schema, and the execute handler reference.dexList: { name: "DEX_LIST", description: "Get dex list", parameters: chainParamsSchema, execute: chainExecute.dexList },