Download the exact captured file
---
name: wallet-pnl
description: >-
Measures whether a wallet makes money from its swaps: realized profit (sold) and open profit (still held) per chain
and per token at average cost, a day-by-day realized calendar, and its latest swaps with explorer links. Reads a 0x
wallet on Monad, Robinhood Chain, Arc, Avalanche, Base, BNB Chain, Arbitrum and Ethereum at once, adds Solana with
the wallet's Solana address, or reads a Solana address alone. Counts swaps on every venue Chord indexes, not only
Chord's own router; transfers, holdings and staking are not trades, so a wallet that never swaps shows no profit.
Use when the user asks "is this wallet making money", "what is its PnL", "best and worst tokens", "how did it do
this month", "show its trades". Not for what a wallet holds (use wallet-xray), ranking traders (use smart-money) or
ENS names (ask for the address). Read only; never signs or moves funds.
license: MIT
compatibility: Needs python3 and HTTPS to api.getchord.xyz. Set CHORD_API_KEY (free at chordsi.xyz/me).
metadata:
author: Chord (getchord.xyz)
homepage: https://chordsi.xyz/s/wallet-pnl
version: "1.0.0"
---
# Wallet PnL
A wallet's profit from its own swaps, read from Chord's trade index of each chain. Profit uses average cost: realized =
what sales brought in minus the average buy price of what was sold; open = what is still held from those buys at the
current price, minus its cost. A token that arrived by transfer has no cost and stays out of profit, and selling tokens
the index never saw bought is not counted as profit.
## What each chain counts
| Chains | What is counted | How far back | "Held" means |
|---|---|---|---|
| Monad, Robinhood Chain, Arc | every swap on every venue Chord indexes, by the address that sent it (keeper and relayer fills go to the real trader); swaps under $0.10 skipped | all the history Chord holds for the chain | the live on-chain balance |
| Avalanche, Base, BNB Chain, Arbitrum, Ethereum | every swap on every venue Chord indexes; a chain may skip small trades (BNB Chain under $100, see `tradesUnderUsdSkipped`) | the window in `counts` (days of raw tape plus archive; Ethereum about 8 weeks, Base a few days) | bought minus sold in the window |
| Solana | every swap Chord indexes | the last 1 to 45 days (`--sol-days`) | bought minus sold in the window |
The swap list (`--view trades`) differs on Monad: it holds only swaps through Chord's own router and nad.fun curve trades
of about the last 12 days, while Monad's profit counts every venue. On every other chain the list and the profit read the
same swaps. For every Monad swap of a wallet, use the wallet-xray skill.
A wallet that only holds, receives or sends tokens (vitalik.eth, for example) has no swaps, so its profit is zero
everywhere. That is the answer, not an error: say it counts swaps only.
## Run it
```bash
python3 scripts/wallet_pnl.py WALLET [--view summary|tokens|calendar|trades|all] [--chains LIST] [--sol SOLANA_ADDRESS] [--limit N] [--days N] [--sol-days N]
```
- `WALLET`: a 0x address, or a Solana address exactly as written (case matters). Names like vitalik.eth are refused:
ask the person for the address.
- `--view`: `summary` (default: totals per chain, best and worst tokens), `tokens` (every token with its profit),
`calendar` (realized profit per UTC day: Monad, Robinhood Chain and Arc only), `trades` (newest swaps), `all`.
- `--chains`: a comma list to narrow, e.g. `monad,base`. Default: all eight EVM chains, plus Solana with `--sol`.
- `--limit`: rows per list, 1 to 50 (default 10). `--days`: calendar days to show, 1 to 366 (default 30).
- `--sol-days`: the Solana window, 1 to 45 (default 7).
Example: `python3 scripts/wallet_pnl.py 0x3a5e35aff6cad28f17c06995842f150c2d4a5f54 --chains robinhood --view all --limit 5`
## Read the answer
- `totals`: realized, open, total and held dollars over the chains with swaps; `chainsWithoutSwaps`; `chainsUnread`
(a chain the API did not answer, left out of the totals).
- `chains`: per chain, `counts` (what and how far back), realized, open, total, held. Monad, Robinhood Chain and Arc add
`leftWithoutSale` (tokens bought then gone with no sale on record: sent away or sold through a contract, outcome
unknown, kept out of profit). Other chains add `trades`, `volumeUsd` and `soldWithoutCostUsd`.
- `bestTokens` / `worstTokens` (summary) or `tokens`: chain, symbol, address, realized, open, total, held, amount,
`avgBuyUsd`, `openRoiPct`, `arrivedByTransferUsd`. A missing symbol means the index has none: show the address.
- `calendar.calendars`: per chain, first and last trade day, all-time realized, realized in the window, green and red
days, best and worst day, then each day (newest first) with its realized dollars and swap count.
- `recent.trades`: time in UTC, chain, buy or sell (seen from the wallet), token, amount, dollars, venue, explorer link.
## How to answer the user
1. Lead with total profit, split realized and open, and name the chains it comes from and how far back each one counts.
2. Name the best and worst tokens with dollars. For the calendar, give the window total, green vs red days, best and
worst day.
3. Say what is left out when it matters: `leftWithoutSale`, `arrivedByTransferUsd`, unread chains, short windows.
4. Zero everywhere = no swaps on record, not a broken wallet. Describe; never advise buying, selling or copying.
## Cost
One call per chain read per view: `summary` or `tokens` on all eight EVM chains is seven calls (Monad and Robinhood Chain
share one), `calendar` up to three, `trades` one per chain; narrow with `--chains`. 300 calls a month are free; then
$0.006 a call from your ChordSI credit. If the script exits with code 4, show the person the message: their credit is
empty or a limit was reached, and chordsi.xyz/me is where they top up.
## Chord endpoints it calls
- `GET /v1/portfolio/{wallet}/pnl?chain=all|143|4663|5042` (`all` = Monad and Robinhood Chain together)
- `GET /v1/portfolio/{wallet}/pnl-calendar?chain=143|4663|5042`
- `GET /v1/portfolio/{wallet}/trades?chain=143|4663|5042`
- `GET /v1/chains/{avalanche|base|bnb|arbitrum|ethereum}/wallet/{address}` and `.../wallet/{address}/trades?limit=`
- `GET /v1/chains/solana/wallet/{address}?days=` and `.../wallet/{address}/trades?limit=`