Skip to main content
Glama

sell_etf_token

Simulate selling ETF tokens for base currency on Paloma DEX across multiple EVM chains to preview transaction outcomes before execution.

Instructions

Sell ETF tokens back to base currency (simulation only - no actual transaction).

Args:
    chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)
    etf_token_address: Address of the ETF token to sell
    etf_amount: Amount of ETF tokens to sell (in token units, e.g. '10.5')

Returns:
    JSON string with transaction simulation details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_idYes
etf_token_addressYes
etf_amountYes

Implementation Reference

  • The handler function for the 'sell_etf_token' MCP tool. It validates inputs, checks balances, and returns a simulation of selling ETF tokens via the ETF connector contract without executing an actual transaction.
    async def sell_etf_token(ctx: Context, chain_id: str, etf_token_address: str, etf_amount: str) -> str:
        """Sell ETF tokens back to base currency (simulation only - no actual transaction).
        
        Args:
            chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)
            etf_token_address: Address of the ETF token to sell
            etf_amount: Amount of ETF tokens to sell (in token units, e.g. '10.5')
        
        Returns:
            JSON string with transaction simulation details.
        """
        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]
            
            if not config.etf_connector:
                return f"Error: ETF connector not configured for {config.name}"
            
            # Validate addresses
            if not Web3.is_address(etf_token_address):
                return f"Error: Invalid ETF token address format: {etf_token_address}"
            
            try:
                etf_amount_float = float(etf_amount)
                if etf_amount_float <= 0:
                    raise ValueError("Amount must be positive")
            except ValueError:
                return f"Error: Invalid ETF amount: {etf_amount}"
            
            # Get ETF token information
            if chain_id not in paloma_ctx.web3_clients:
                return f"Error: Web3 client not available for {config.name}"
            
            web3 = paloma_ctx.web3_clients[chain_id]
            
            try:
                etf_contract = web3.eth.contract(address=etf_token_address, abi=ERC20_ABI)
                etf_symbol = etf_contract.functions.symbol().call()
                etf_decimals = etf_contract.functions.decimals().call()
                
                # Check current balance
                balance_wei = etf_contract.functions.balanceOf(paloma_ctx.address).call()
                balance = balance_wei / (10 ** etf_decimals)
                
            except Exception as e:
                return f"Error: Failed to read ETF token contract: {str(e)}"
            
            # Check if user has sufficient balance
            if etf_amount_float > balance:
                return f"Error: Insufficient balance. You have {balance} {etf_symbol}, trying to sell {etf_amount}"
            
            # Simulate transaction details (no actual execution)
            simulation_result = {
                "operation": "sell_etf_token",
                "chain": config.name,
                "chain_id": config.chain_id,
                "etf_connector": config.etf_connector,
                "etf_token": {
                    "address": etf_token_address,
                    "symbol": etf_symbol,
                    "amount_to_sell": etf_amount,
                    "current_balance": str(balance),
                    "decimals": etf_decimals
                },
                "recipient": paloma_ctx.address,
                "status": "simulation",
                "note": "This is a simulation. Actual trading requires approval and proper transaction execution.",
                "next_steps": [
                    "1. Approve ETF token spending to ETF connector",
                    "2. Call ETF connector sell() function with deadline parameter",
                    "3. Handle gas fees and transaction confirmation",
                    "4. Receive proceeds in base currency"
                ]
            }
            
            return json.dumps(simulation_result, indent=2)
            
        except Exception as e:
            logger.error(f"Error in sell ETF token simulation: {e}")
            return f"Error in sell ETF token simulation: {str(e)}"
  • The ABI definition for the 'sell' function on the ETF connector contract, which is referenced in the sell_etf_token tool implementation.
    {
        "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"
    }
  • The docstring of the sell_etf_token function defines the input parameters and return type, serving as the tool schema for MCP.
    Args:
        chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)
        etf_token_address: Address of the ETF token to sell
        etf_amount: Amount of ETF tokens to sell (in token units, e.g. '10.5')
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by disclosing critical behavioral traits: this is a simulation-only operation (no actual transaction occurs), it returns JSON with transaction simulation details, and it involves selling tokens back to base currency. However, it doesn't mention rate limits, authentication needs, or error handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly structured with a clear purpose statement upfront, followed by well-organized parameter explanations and return value description. Every sentence adds value with zero wasted words, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 3-parameter tool with no annotations and no output schema, the description provides good coverage of purpose, parameters, and behavioral context (simulation-only nature). It could improve by mentioning authentication requirements or error scenarios, but it's substantially complete for the tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates well by explaining all three parameters: chain_id with specific network examples, etf_token_address as the token address, and etf_amount with units clarification. It adds meaningful context beyond the bare schema, though it doesn't specify format requirements (e.g., address validation).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('sell ETF tokens back to base currency'), identifies the resource (ETF tokens), and distinguishes it from sibling tools like 'buy_etf_token' by specifying the opposite direction of the transaction. The simulation-only disclaimer adds important context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through the 'simulation only' context and distinguishes from actual transactions, but doesn't explicitly state when to use this versus alternatives like 'execute_token_swap' or 'buy_etf_token'. No guidance on prerequisites or error conditions is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/VolumeFi/mcpPADEX'

If you have feedback or need assistance with the MCP directory API, please join our Discord server