Skip to main content
Glama

get_etf_balance

Check ETF token balance for any wallet address across multiple EVM chains. Retrieve balance information by specifying chain ID and token address.

Instructions

Get ETF token balance for a wallet address.

Args:
    chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)
    etf_token_address: Address of the ETF token
    wallet_address: Wallet address to check (defaults to server wallet)

Returns:
    JSON string with ETF token balance information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_idYes
etf_token_addressYes
wallet_addressNo

Implementation Reference

  • The handler function implementing the get_etf_balance tool. It retrieves the ERC20 token balance of a specified ETF token for a wallet on a given EVM chain using Web3.py, formats it into JSON with chain details, token info, and human-readable balance.
    async def get_etf_balance(ctx: Context, chain_id: str, etf_token_address: str, wallet_address: Optional[str] = None) -> str:
        """Get ETF token balance for a wallet address.
        
        Args:
            chain_id: Chain ID (1, 10, 56, 100, 137, 8453, 42161)
            etf_token_address: Address of the ETF token
            wallet_address: Wallet address to check (defaults to server wallet)
        
        Returns:
            JSON string with ETF token balance 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]
            
            # Use server wallet if no address provided
            if wallet_address is None:
                wallet_address = paloma_ctx.address
            
            # Validate addresses
            if not Web3.is_address(etf_token_address):
                return f"Error: Invalid ETF token address format: {etf_token_address}"
            
            if not Web3.is_address(wallet_address):
                return f"Error: Invalid wallet address format: {wallet_address}"
            
            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]
            etf_contract = web3.eth.contract(
                address=etf_token_address,
                abi=ERC20_ABI
            )
            
            # Get token info
            try:
                balance_wei = etf_contract.functions.balanceOf(wallet_address).call()
                decimals = etf_contract.functions.decimals().call()
                symbol = etf_contract.functions.symbol().call()
                balance = balance_wei / (10 ** decimals)
            except Exception as e:
                return f"Error: Failed to read ETF token contract: {str(e)}"
            
            balance_info = {
                "chain": config.name,
                "chain_id": config.chain_id,
                "wallet_address": wallet_address,
                "etf_token_address": etf_token_address,
                "symbol": symbol,
                "balance": str(balance),
                "balance_wei": str(balance_wei),
                "decimals": decimals
            }
            
            return json.dumps(balance_info, indent=2)
            
        except Exception as e:
            logger.error(f"Error getting ETF balance: {e}")
            return f"Error getting ETF balance: {str(e)}"
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool reads balance information (implied safe operation) and specifies a default for 'wallet_address', adding useful context. However, it lacks details on error handling, rate limits, authentication needs, or what the JSON return includes (e.g., balance units, timestamps), leaving gaps for a mutation-free tool.

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

Conciseness4/5

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

The description is well-structured and front-loaded with the core purpose, followed by parameter and return details. It uses bullet-like sections ('Args:', 'Returns:') for clarity. However, the 'Args' section could be more concise by integrating details into the main text, and some redundancy exists (e.g., repeating 'ETF token' in parameter names).

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

Completeness3/5

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

Given no annotations, 0% schema coverage, and no output schema, the description is moderately complete. It covers the purpose, parameters, and return format at a high level. However, it lacks specifics on the JSON structure (e.g., keys like 'balance' or 'decimals'), error cases, or how it differs from similar balance-checking tools, making it adequate but with clear gaps for a 3-parameter tool.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining each parameter: 'chain_id' with enumerated values (1, 10, etc.), 'etf_token_address' as the token's address, and 'wallet_address' with its default. This clarifies beyond the schema's basic types, though it doesn't detail format constraints (e.g., address validation) or optionality nuances.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get ETF token balance for a wallet address.' It specifies the verb ('Get'), resource ('ETF token balance'), and target ('wallet address'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'get_address_balance_single_chain' or 'get_pusd_balance', which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_address_balance_single_chain' (which might handle general token balances) or 'get_pusd_balance' (for a specific token), leaving the agent to infer usage context. The default behavior for 'wallet_address' is noted, but no broader usage context is given.

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