get_available_trading_tokens
Retrieve available tokens for trading on a specific blockchain within the Paloma DEX ecosystem. Provide a chain ID to get token information for cross-chain trading operations.
Instructions
Get available tokens for trading on a specific chain.
Args:
chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)
Returns:
JSON string with available trading tokens and their information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain_id | Yes |
Implementation Reference
- padex.py:1277-1349 (handler)Handler function for the 'get_available_trading_tokens' MCP tool. Retrieves trading tokens for a chain using PalomaDEXAPI or fallback mock data, returns JSON with token info.@mcp.tool() async def get_available_trading_tokens(ctx: Context, chain_id: str) -> str: """Get available tokens for trading on a specific chain. Args: chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161) Returns: JSON string with available trading tokens and their information. """ try: paloma_ctx = ctx.request_context.lifespan_context if chain_id not in CHAIN_CONFIGS: return f"Error: Unsupported chain ID {chain_id}" config = CHAIN_CONFIGS[chain_id] chain_name = get_chain_name_for_api(chain_id) if not chain_name: return f"Error: Chain name mapping not found for chain ID {chain_id}" # Use our Paloma-based API implementation try: tokens_data = await paloma_ctx.palomadex_api.get_tokens(chain_id) result = { "chain": config.name, "chain_id": config.chain_id, "trader_contract": TRADER_ADDRESSES.get(chain_id, "Not configured"), "total_tokens": len(tokens_data), "tradeable_tokens": len([t for t in tokens_data if t.get('is_pair_exist', False)]), "tokens": tokens_data, "data_source": "paloma_dex_api" } return json.dumps(result, indent=2) except Exception as api_error: logger.warning(f"Paloma API failed: {api_error}, using fallback") # Fallback: Return common tokens that are likely available for trading common_tokens = [] if chain_id == ChainID.ETHEREUM_MAIN: common_tokens = [ {"erc20_name": "USD Coin", "erc20_symbol": "USDC", "erc20_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "erc20_decimals": 6, "is_pair_exist": True}, {"erc20_name": "Tether USD", "erc20_symbol": "USDT", "erc20_address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", "erc20_decimals": 6, "is_pair_exist": True}, {"erc20_name": "Wrapped Ether", "erc20_symbol": "WETH", "erc20_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "erc20_decimals": 18, "is_pair_exist": True} ] elif chain_id == ChainID.ARBITRUM_MAIN: common_tokens = [ {"erc20_name": "USD Coin", "erc20_symbol": "USDC", "erc20_address": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", "erc20_decimals": 6, "is_pair_exist": True}, {"erc20_name": "Tether USD", "erc20_symbol": "USDT", "erc20_address": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", "erc20_decimals": 6, "is_pair_exist": True} ] # Add more chains as needed result = { "chain": config.name, "chain_id": config.chain_id, "trader_contract": TRADER_ADDRESSES.get(chain_id, "Not configured"), "note": "Using fallback token list - Paloma API unavailable", "total_tokens": len(common_tokens), "tradeable_tokens": len(common_tokens), "tokens": common_tokens, "data_source": "fallback" } return json.dumps(result, indent=2) except Exception as e: logger.error(f"Error getting available tokens: {e}") return f"Error getting available tokens: {str(e)}"
- padex.py:421-438 (helper)PalomaDEXAPI.get_tokens helper method called by the handler. Provides mock data for available ERC20 tokens on Ethereum and Arbitrum chains.async def get_tokens(self, chain_id: str) -> List[Dict]: """Get available tokens for a chain (mock implementation).""" # In real implementation, this would query the factory contract # For now, return common tokens per chain common_tokens = { "1": [ # Ethereum {"erc20_name": "USD Coin", "erc20_symbol": "USDC", "erc20_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "erc20_decimals": 6, "is_pair_exist": True}, {"erc20_name": "Tether USD", "erc20_symbol": "USDT", "erc20_address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", "erc20_decimals": 6, "is_pair_exist": True}, {"erc20_name": "Wrapped Ether", "erc20_symbol": "WETH", "erc20_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "erc20_decimals": 18, "is_pair_exist": True} ], "42161": [ # Arbitrum {"erc20_name": "USD Coin", "erc20_symbol": "USDC", "erc20_address": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", "erc20_decimals": 6, "is_pair_exist": True}, {"erc20_name": "Tether USD", "erc20_symbol": "USDT", "erc20_address": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", "erc20_decimals": 6, "is_pair_exist": True} ] } return common_tokens.get(chain_id, [])
- padex.py:833-845 (helper)Helper function to map chain_id to lowercase chain name used in Paloma DEX API calls.def get_chain_name_for_api(chain_id: str) -> Optional[str]: """Map chain ID to chain name for Paloma DEX API calls.""" chain_name_mapping = { "1": "ethereum", "10": "optimism", "56": "bsc", "100": "gnosis", "137": "polygon", "8453": "base", "42161": "arbitrum" } return chain_name_mapping.get(chain_id)