{"uid":"cap_dgUMupa56CxIW2h1h2lnc","slug":"api-x402node-dev-6e259dc2","name":"Wallet PnL & Cost Basis Calculator (ERC20 / Base)","description":"Realized profit and loss and cost basis for an ERC20 token in a wallet on Base, computed from on-chain DEX trades against a quote asset (USDC by default). Returns average buy and sell price, realized PnL, remaining position and cost basis. Search terms: wallet PnL, realized gains, cost basis, token profit, crypto tax accounting, trade history. Accepts payment on Base or Solana — either network works.","url":"https://api.x402node.dev/wallet/pnl","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["quote"],"properties":{"quote":{"type":"string","description":"Quote (required)"},"token":{"type":"string","description":"ERC20 contract address (optional)"},"wallet":{"type":"string","description":"Wallet (optional)"},"address":{"type":"string","description":"EVM/chain address (optional)"}}}},"additionalProperties":false}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.1","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.1/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.1","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.1","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_BvZoVbwSFpI6IDEO8lX7m","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.1","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes realized profit and loss, average buy/sell price, cost basis, and remaining position for an ERC20 token in a wallet by analyzing on-chain DEX trades on Base against a quote asset (default USDC).","exampleAgentPrompt":"What's my realized PnL and cost basis for the token at 0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed in my wallet 0xAbC123...def on Base — use USDC as the quote asset?","exampleUseCases":null,"resultDescription":"Returns a structured object containing average buy price, average sell price, realized PnL (in the quote asset, default USDC), remaining token position size, and cost basis computed from on-chain DEX trade history on the Base network.","failureModes":["Wallet address not found or has no DEX trade history — returns empty or zero values","ERC20 token address invalid or not traded on Base DEXes — returns error or null result","No trades found against the specified quote asset — may return zero PnL","RPC or indexing latency causes stale or incomplete trade data","Malformed wallet or token address returns a 400-level error"],"whenToPreferThis":"Use this endpoint when you need on-chain, DEX-derived realized PnL and cost basis for an ERC20 token on Base — ideal for crypto tax accounting, portfolio performance reporting, or DeFi trade analysis. Prefer this over off-chain or CEX-based PnL tools when the trades occurred on Base DEXes and you need average buy/sell prices and remaining position computed from actual blockchain data.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T06:48:49.284Z","isFirstParty":false}