Skip to main content
Glama

read.account.pnl

Read-onlyIdempotent

Get an Arcadia account's PnL (cost basis) and yield earned. Returns lifetime cost, current value, net transfers, and yield per token.

Instructions

Get PnL (cost basis) and yield earned for an Arcadia account. Returns lifetime totals: cost basis vs current value (negative cost_basis = net profit withdrawn), net transfers per token, total yield earned in USD and per token. cost_basis, current_value, cost_diff are in USD (human-readable). Per-token fields (net_transfers, summed_yields_earned) are in raw token units.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_addressYesArcadia account address
chain_idNoChain ID: 8453 (Base), 130 (Unichain), or 10 (Optimism)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
pnl_cost_basisYes
yield_earnedYes

Implementation Reference

  • The handler function for 'read.account.pnl'. Calls api.getPnlCostBasis and api.getYieldEarned, processes the raw data (filtering out large arrays like direct_deposits, flashaction_deposits/withdrawals, direct_withdrawals, yield_withdrawals, daily_yields, daily_yields_usd), and returns typed structured content with pnl_cost_basis and yield_earned.
      async ({ account_address, chain_id }) => {
        try {
          const validChainId = validateChainId(chain_id);
          const [pnlRaw, yieldRaw] = await Promise.all([
            api.getPnlCostBasis(validChainId, account_address),
            api.getYieldEarned(validChainId, account_address),
          ]);
    
          const {
            direct_deposits: _,
            flashaction_deposits,
            flashaction_withdrawals,
            direct_withdrawals,
            yield_withdrawals,
            ...pnl
          } = pnlRaw as Record<string, unknown>;
          if (Array.isArray(flashaction_deposits) && flashaction_deposits.length > 0)
            (pnl as Record<string, unknown>).flashaction_deposit_count = flashaction_deposits.length;
          if (Array.isArray(flashaction_withdrawals) && flashaction_withdrawals.length > 0)
            (pnl as Record<string, unknown>).flashaction_withdrawal_count =
              flashaction_withdrawals.length;
          if (Array.isArray(direct_withdrawals) && direct_withdrawals.length > 0)
            (pnl as Record<string, unknown>).direct_withdrawal_count = direct_withdrawals.length;
          if (Array.isArray(yield_withdrawals) && yield_withdrawals.length > 0)
            (pnl as Record<string, unknown>).yield_withdrawal_count = yield_withdrawals.length;
    
          const {
            daily_yields: _dy,
            daily_yields_usd: _dyu,
            ...yieldData
          } = yieldRaw as Record<string, unknown>;
    
          const result = { pnl_cost_basis: pnl, yield_earned: yieldData };
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(result, null, 2),
              },
            ],
            structuredContent: result,
          };
        } catch (err) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error: ${err instanceof Error ? err.message : String(err)}`,
              },
            ],
            isError: true,
          };
        }
      },
    );
  • Output schema (AccountPnlOutput) defined as z.object with pnl_cost_basis and yield_earned fields as z.record(z.unknown()).
    export const AccountPnlOutput = z.object({
      pnl_cost_basis: z.record(z.unknown()),
      yield_earned: z.record(z.unknown()),
    });
  • Registration of 'read.account.pnl' tool with server.registerTool(), including annotations (title 'Get Account PnL', readOnlyHint, etc.), description, inputSchema (account_address string, chain_id number default 8453), and outputSchema reference to AccountPnlOutput.
    server.registerTool(
      "read.account.pnl",
      {
        annotations: {
          title: "Get Account PnL",
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: true,
        },
        description:
          "Get PnL (cost basis) and yield earned for an Arcadia account. Returns lifetime totals: cost basis vs current value (negative cost_basis = net profit withdrawn), net transfers per token, total yield earned in USD and per token. cost_basis, current_value, cost_diff are in USD (human-readable). Per-token fields (net_transfers, summed_yields_earned) are in raw token units.",
        inputSchema: {
          account_address: z.string().describe("Arcadia account address"),
          chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
        },
        outputSchema: AccountPnlOutput,
      },
      async ({ account_address, chain_id }) => {
  • registerAllTools() calls registerAccountTools(server, api, chains), which registers the 'read.account.pnl' tool along with other account read tools.
    export function registerAllTools(
      server: McpServer,
      api: ArcadiaApiClient,
      chains: Record<ChainId, ChainConfig>,
    ) {
      // Read tools
      registerAccountTools(server, api, chains);
Behavior4/5

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

Annotations already mark it as read-only, non-destructive, idempotent, and open-world. The description adds value by explaining the meaning of negative cost_basis, units (USD vs raw tokens), and that returns are lifetime totals, which are not covered by annotations.

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 a single dense paragraph with no filler. It front-loads the purpose and covers key details. While it could benefit from bullet points, it is concise and informative without being verbose.

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

Completeness5/5

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

Given the presence of an output schema (not shown), the description need not fully detail return values. It adequately explains the structure of returned data (lifetime totals, cost_diff in USD, per-token fields in raw units) and units. For a read-only tool with good annotations, it is complete.

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

Parameters3/5

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

Schema description coverage is 100% for both parameters, including details for chain_id (enum values and default). The description does not add new information about parameters beyond what the schema provides, so baseline 3 applies.

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 tool retrieves PnL and yield for an Arcadia account, specifying the returned data (lifetime totals, cost basis vs current value, etc.). It uses specific verbs and resources, and among sibling read tools, it uniquely focuses on PnL, making its purpose distinct.

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 does not explicitly compare to sibling tools or state when to use this tool over others like read.account.history or read.account.info. Usage context is implied by its specific output, but no explicit guidance on scenarios or exclusions 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/arcadia-finance/mcp-server'

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