get_user_staking_rewards
Retrieve staking reward history for a Hyperliquid account, providing transaction amounts and timestamps in JSON format.
Instructions
Fetch the staking rewards history for a specific user account.
Parameters:
account_address (str): The Hyperliquid account address (e.g., '0xcd5051944f780a621ee62e39e493c489668acf4d').
ctx (Context): The MCP context object for accessing server state.
Returns:
str: A JSON string containing a list of staking reward records, each with amount and timestamp.
Returns a JSON string with an error message if the query fails.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_address | Yes |
Implementation Reference
- main.py:258-275 (handler)This is the implementation of the 'get_user_staking_rewards' tool handler. It is decorated with @mcp.tool(), which also serves as the registration in FastMCP. The function queries the Hyperliquid SDK's Info object for the user's staking rewards and returns the data as a JSON string, handling errors appropriately.async def get_user_staking_rewards(account_address: str, ctx: Context) -> str: """ Fetch the staking rewards history for a specific user account. Parameters: account_address (str): The Hyperliquid account address (e.g., '0xcd5051944f780a621ee62e39e493c489668acf4d'). ctx (Context): The MCP context object for accessing server state. Returns: str: A JSON string containing a list of staking reward records, each with amount and timestamp. Returns a JSON string with an error message if the query fails. """ try: data = info.user_staking_rewards(account_address) return json.dumps(data) except Exception as e: return json.dumps({"error": f"Failed to fetch user staking rewards: {str(e)}"})