get_trending_tokens_on_pumpswap
Identify trending tokens on PumpSwap by retrieving the highest trading volume within specific time spans (5h, 12h, 24h), providing a formatted table with mint addresses and volume data for informed trading decisions.
Instructions
Retrieve tokens with the highest trading volume on PumpSwap within a specified time span.
Args:
time_span (str): Time period for the query. Must be one of: '5h', '12h', '24h'.
Defaults to '5h'.
limit (int): Maximum number of tokens to return. Defaults to 100.
Returns:
str: A formatted table of trending tokens on PumpSwap including mint address
and trading volume, or an error message if the query fails.
Raises:
ValueError: If an invalid time_span value is provided.
httpx.HTTPStatusError: If the Dune API request fails.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| time_span | No | 5h |
Implementation Reference
- main.py:294-331 (handler)The main handler function for the 'get_trending_tokens_on_pumpswap' tool. It fetches trending tokens on PumpSwap by querying Dune Analytics based on time_span ('5h', '12h', '24h'), processes the data using helpers like get_latest_result and strip_a_tag, formats it into a table using tabulate, and returns the result as a string.@mcp.tool() def get_trending_tokens_on_pumpswap(time_span: str = "5h", limit: int = 100) -> str: """Retrieve tokens with the highest trading volume on PumpSwap within a specified time span. Args: time_span (str): Time period for the query. Must be one of: '5h', '12h', '24h'. Defaults to '5h'. limit (int): Maximum number of tokens to return. Defaults to 100. Returns: str: A formatted table of trending tokens on PumpSwap including mint address and trading volume, or an error message if the query fails. Raises: ValueError: If an invalid time_span value is provided. httpx.HTTPStatusError: If the Dune API request fails. """ query_ids = { "5h": 4929624, "12h": 4929617, "24h": 4929607, } try: query_id = query_ids.get(time_span) if query_id is None: raise ValueError("Invalid time_span value. Allowed: 5h | 12h | 24h") data = get_latest_result(query_id, limit=limit) rows = [ [ strip_a_tag(row["contract_address"]), f'${row["volume_usd"]:.2f}' ] for row in data ] headers = ["Mint Address", "Trading Volume"] return f"# Top {limit} Trending Tokens on PumpSwap - Last {time_span}\n\n" + tabulate(rows, headers=headers) except Exception as e: return str(e)