get_etf_price
Retrieve current buy and sell prices for ETF tokens on Paloma DEX across multiple EVM chains to inform trading decisions.
Instructions
Get buy and sell prices for an ETF token.
Args:
chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)
etf_token_address: Address of the ETF token
Returns:
JSON string with buy and sell prices for the ETF token.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chain_id | Yes | ||
| etf_token_address | Yes |
Implementation Reference
- padex.py:906-954 (handler)The core handler implementation for the 'get_etf_price' MCP tool. This async function fetches real-time ETF buy/sell prices from the Paloma DEX API endpoint using the provided chain ID and EVM ETF token address. It includes input validation, API call via httpx, and JSON response formatting. The @mcp.tool() decorator handles automatic registration and schema generation.@mcp.tool() async def get_etf_price(ctx: Context, chain_id: str, etf_token_address: str) -> str: """Get buy and sell prices for an ETF token. Args: chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161) etf_token_address: Address of the ETF token Returns: JSON string with buy and sell prices for the ETF token. """ 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] # Validate ETF token address if not Web3.is_address(etf_token_address): return f"Error: Invalid ETF token address format: {etf_token_address}" 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}" # Call Paloma DEX API to get custom pricing api_url = f"https://api.palomadex.com/etfapi/v1/customindexprice?chain_id={chain_name}&token_evm_address={etf_token_address}" response = await paloma_ctx.http_client.get(api_url) if response.status_code == 200: price_data = response.json() result = { "chain": config.name, "chain_id": config.chain_id, "etf_token_address": etf_token_address, "pricing": price_data, "timestamp": asyncio.get_event_loop().time() } return json.dumps(result, indent=2) else: return f"Error: Failed to fetch ETF price. Status: {response.status_code}" except Exception as e: logger.error(f"Error getting ETF price: {e}") return f"Error getting ETF price: {str(e)}"
- padex.py:833-844 (helper)Helper function used by get_etf_price to map EVM chain IDs to Paloma API chain names (e.g., '1' -> 'ethereum') for constructing the correct API URL.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)
- padex.py:487-513 (helper)ERC-20 ABI snippet for ETF Connector contract, relevant for ETF trading operations referenced in chain configurations used by get_etf_price context.ETF_CONNECTOR_ABI = [ { "name": "buy", "type": "function", "inputs": [ {"name": "etf_token", "type": "address"}, {"name": "etf_amount", "type": "uint256"}, {"name": "usd_amount", "type": "uint256"}, {"name": "recipient", "type": "address"}, {"name": "path", "type": "bytes"}, {"name": "deadline", "type": "uint256"} ], "outputs": [], "stateMutability": "payable" }, { "name": "sell", "type": "function", "inputs": [ {"name": "etf_token", "type": "address"}, {"name": "etf_amount", "type": "uint256"}, {"name": "deadline", "type": "uint256"}, {"name": "recipient", "type": "address"} ], "outputs": [], "stateMutability": "payable" }