Catalog/chain-wallet-pnl

Chain

Wallet P&L with cost-basis accounting (realized + unrealized) API

Profit/loss report for an EVM wallet across its ERC-20 holdings with real cost-basis accounting — not a balance dump. Over a bounded window of recent token-transfers it reconstructs, per token, amount in/out, the average cost basis (from inbound transfers' USD price), realized P&L (outbound amount x (sell price - cost basis)), the current holding from token-balances valued at a live keyless spot price, and unrealized P&L (holding x (current price - cost basis)). Rolls up to portfolio totals: total realized, total unrealized, net P&L, total current value, win rate, and best/worst position. Answers 'Is this wallet up or down, and by how much?', 'What is my realized vs unrealized P&L per token?', 'What is my cost basis and win rate?'.

Price$0.2per request
MethodPOST
Route/v1/chain/wallet-pnl
StatusLive
MIME typeapplication/json
Rate limit60/minute
Cache300s public
chainpnlprofit-losscost-basisportfoliotradingrealizedunrealizedwallet
API URLhttps://x402.hexl.dev/v1/chain/wallet-pnl
Integration docs
Example request
{
  "address": "0x28C6c06298d514Db089934071355E5743bf21d60",
  "chain": "ethereum"
}
Example response
{
  "address": "0x28c6c06298d514db089934071355e5743bf21d60",
  "chain": "ethereum",
  "method": "average-cost",
  "portfolio": {
    "tokensAnalyzed": 1707,
    "totalRealizedPnl": 0,
    "totalUnrealizedPnl": 6.87,
    "netPnl": 6.87,
    "winRate": 0.5,
    "tokensInProfit": 2,
    "tokensScored": 4,
    "bestToken": {
      "symbol": "SKL",
      "totalPnl": 5.68
    },
    "unpricedTokens": [
      "WHITE",
      "STARMAN"
    ]
  },
  "tokens": [
    {
      "symbol": "CBBTC",
      "amountIn": 3.75,
      "amountOut": 3.14,
      "costBasis": 63745,
      "realizedPnl": 0,
      "holding": 34.75,
      "currentPrice": 63897,
      "unrealizedPnl": 5283.07,
      "totalPnl": 5283.07,
      "priced": true,
      "status": "profit"
    }
  ],
  "narrative": "Across 1707 token(s) in the sampled window, this wallet is UP a net $6.87 (realized $0, unrealized $6.87). Win rate 50% (2/4 priced positions in profit).",
  "priceSource": "coingecko",
  "disclaimer": "Best-effort P&L over a bounded window of the most recent ERC-20 token-transfers (cap 100) plus current token-balances. Average-cost method. Per-transfer cost-basis prices come from Blockscout exchange_rate (a current USD snapshot, not a true block-time price), so realized/cost-basis figures are approximate. ERC-20 only — native ETH not included. NOT financial or tax advice."
}
Input schema
{
  "type": "object",
  "required": [
    "address"
  ],
  "properties": {
    "address": {
      "type": "string",
      "description": "0x-prefixed 40-hex EVM address to compute P&L for."
    },
    "chain": {
      "type": "string",
      "enum": [
        "base",
        "ethereum"
      ],
      "default": "base",
      "description": "Chain to analyze on."
    }
  },
  "examples": [
    {
      "address": "0x28C6c06298d514Db089934071355E5743bf21d60",
      "chain": "ethereum"
    }
  ]
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}