{"uid":"cap_0pD2IDR4Dyi1CVQfG73O4","slug":"x402-deployer-x402-deployer-workers-dev-6cf6264b","name":"Wallet Token P&L & FIFO Cost Basis Analyzer","description":"Wallet token P&L / FIFO cost basis / realized + unrealized profit / EVM portfolio analytics. For any (wallet, ERC-20, chain) triple, pulls all transfers from Etherscan v2, prices each one at the historical USD spot via CoinGecko, runs FIFO accounting and reports cost basis, realized gain, unrealized gain, current balance, and tx count. Capped at the most recent 500 transfers.","url":"https://x402-deployer.x402-deployer.workers.dev/wallet-pnl","method":"POST","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method","bodyType","body"],"properties":{"body":{"required":["wallet","token_address"],"properties":{"chain":{"enum":["base","ethereum","polygon","arbitrum","optimism"],"type":"string","description":"EVM chain. Default 'ethereum'."},"wallet":{"type":"string","description":"0x-prefixed 20-byte wallet address."},"token_address":{"type":"string","description":"0x-prefixed 20-byte ERC-20 contract."}}},"type":{"type":"string","const":"http"},"method":{"enum":["POST"],"type":"string"},"bodyType":{"enum":["json","form-data","text"],"type":"string"}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"chain":{"type":"string"},"token":{"type":"string"},"source":{"type":"string"},"symbol":{"type":"string"},"wallet":{"type":"string"},"decimals":{"type":"integer"},"tx_count":{"type":"integer"},"capped_at":{"type":"null"},"coingecko_id":{"type":"string"},"transfers_in":{"type":"number"},"total_pnl_usd":{"type":"number"},"transfers_out":{"type":"number"},"cost_basis_usd":{"type":"number"},"current_balance":{"type":"number"},"realized_pnl_usd":{"type":"number"},"current_price_usd":{"type":"number"},"unrealized_pnl_usd":{"type":"number"}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.05","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.05/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_D8OyjvkHp7UOh52SGWTOk","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.05","costPer":"request","priority":0,"asset":null,"unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Calculates realized and unrealized profit/loss, FIFO cost basis, and current balance for any ERC-20 token in a wallet on a given EVM chain using historical Etherscan transfers priced with CoinGecko spot rates.","exampleAgentPrompt":"What's my realized and unrealized P&L for USDC (contract 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) in my Ethereum wallet 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 — I want FIFO cost basis, current balance, and total gain breakdown.","exampleUseCases":null,"resultDescription":"Returns cost basis in USD, realized gain/loss, unrealized gain/loss, current token balance, and transaction count — all computed via FIFO accounting across the most recent 500 transfers, with each transfer priced at its historical USD spot rate.","failureModes":["Wallet address not found or invalid — returns error","ERC-20 contract address not recognized by Etherscan — empty transfer list","Chain not supported by Etherscan v2 — error response","CoinGecko rate unavailable for a historical timestamp — may result in incomplete pricing","More than 500 transfers exist — results capped, older cost basis may be inaccurate","Rate limiting from Etherscan or CoinGecko — timeout or partial result","Malformed wallet or token address — validation error"],"whenToPreferThis":"Use this endpoint when you need FIFO-based tax cost basis or realized/unrealized P&L for a specific ERC-20 token in a specific EVM wallet. Prefer it over general portfolio dashboards when you need programmatic, per-token accounting with historical USD pricing. Best suited for on-demand analytics on a single (wallet, token, chain) triple rather than broad multi-asset sweeps.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T12:57:16.532Z","isFirstParty":false}