Skip to main content
Glama

hyperd.wallet.pnl

Compute realized and unrealized profit and loss for any EVM wallet across a time window. Supports FIFO, LIFO, and HCFO cost-basis methods with per-token breakdown.

Instructions

Realized + unrealized P&L for a wallet over a time window. ERC-20 + native, single chain per call. Three cost-basis methods: FIFO (default, IRS standard), LIFO (last-in-first-out), HCFO (highest-cost-first-out, tax-loss-harvesting view). Per-token breakdown with weighted-avg cost + mark-to-market. Unpriced trades and untracked-proceeds gaps surfaced honestly under coverage.* fields. v1.0 defers per-tx gas-fee USD attribution. Costs $0.05 in USDC.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes0x EVM wallet address
chainNoChain to compute P&L on. Default 'base'.
fromNoWindow start, unix seconds. Default = to - 30 days. Must be >= 1577836800 (2020-01-01).
toNoWindow end, unix seconds. Default = now. Cannot be > now+60.
methodNoCost-basis method. Default 'fifo'.

Implementation Reference

  • src/server.ts:389-404 (registration)
    Tool registration using server.tool() with name 'hyperd.wallet.pnl' and the description schema
    // hyperd.wallet.pnl — realized + unrealized P&L (FIFO/LIFO/HCFO) ($0.05)
    server.tool(
      "hyperd.wallet.pnl",
      "Realized + unrealized P&L for a wallet over a time window. ERC-20 + native, single chain per call. Three cost-basis methods: FIFO (default, IRS standard), LIFO (last-in-first-out), HCFO (highest-cost-first-out, tax-loss-harvesting view). Per-token breakdown with weighted-avg cost + mark-to-market. Unpriced trades and untracked-proceeds gaps surfaced honestly under coverage.* fields. v1.0 defers per-tx gas-fee USD attribution. Costs $0.05 in USDC.",
      {
        address: z.string().describe("0x EVM wallet address"),
        chain: z
          .enum(["base", "ethereum", "polygon", "arbitrum", "optimism", "avalanche", "bnb"])
          .optional()
          .describe("Chain to compute P&L on. Default 'base'."),
        from: z.number().int().optional().describe("Window start, unix seconds. Default = to - 30 days. Must be >= 1577836800 (2020-01-01)."),
        to: z.number().int().optional().describe("Window end, unix seconds. Default = now. Cannot be > now+60."),
        method: z.enum(["fifo", "lifo", "hcfo"]).optional().describe("Cost-basis method. Default 'fifo'."),
      },
      async (args) => asText(await paidGet("/api/wallet/pnl", args)),
    );
  • Input schema for hyperd.wallet.pnl: address (string, required), chain (enum optional, default base), from/to (unix seconds optional), method (fifo/lifo/hcfo optional, default fifo)
    {
      address: z.string().describe("0x EVM wallet address"),
      chain: z
        .enum(["base", "ethereum", "polygon", "arbitrum", "optimism", "avalanche", "bnb"])
        .optional()
        .describe("Chain to compute P&L on. Default 'base'."),
      from: z.number().int().optional().describe("Window start, unix seconds. Default = to - 30 days. Must be >= 1577836800 (2020-01-01)."),
      to: z.number().int().optional().describe("Window end, unix seconds. Default = now. Cannot be > now+60."),
      method: z.enum(["fifo", "lifo", "hcfo"]).optional().describe("Cost-basis method. Default 'fifo'."),
    },
  • Handler: calls paidGet('/api/wallet/pnl', args) which makes an x402-signed GET request to the hyperD API, then formats response as text via asText()
    async (args) => asText(await paidGet("/api/wallet/pnl", args)),
  • paidGet helper function that constructs the URL with query params and delegates to paidRequest for x402 payment flow
    async function paidGet(
      path: string,
      query: Record<string, string | number | boolean | undefined>,
    ): Promise<unknown> {
      if (!httpClient) {
        throw new Error(WALLET_NOT_CONFIGURED_MSG);
      }
    
      const url = new URL(`${API_BASE}${path}`);
      for (const [k, v] of Object.entries(query)) {
        if (v !== undefined && v !== "" && v !== null) url.searchParams.set(k, String(v));
      }
      return paidRequest("GET", url, undefined);
    }
  • asText helper function that wraps JSON response into MCP text content format
    function asText(data: unknown) {
      return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] };
    }
Behavior4/5

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

No annotations exist, so description carries full burden. It discloses cost-basis methods, per-token breakdown, coverage gaps, deferred gas fees, and cost. Fully transparent about limitations.

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?

Five sentences packed with info; first sentence immediately states purpose. No wasted words.

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?

No output schema, but description mentions per-token breakdown and coverage fields. Addresses key behavioral aspects, though response format is not specified.

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 has 100% coverage, but description adds context: default time window, default method, chain restrictions, and real-world labels (IRS standard, tax-loss-harvesting). Adds significant value.

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 it computes realized and unrealized P&L for a wallet over a time window, single chain, with cost-basis methods. It differentiates from siblings like hyperd.balance.get (balance) and hyperd.wallet.anomaly (anomalies).

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

Usage Guidelines4/5

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

It explains when to use (P&L computation) and notes limitations like unpriced trades and deferred gas attribution, but does not explicitly state when not to use it vs alternatives.

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/hyperd-ai/hyperd-mcp'

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