Cost basis is what you paid for an asset. When you dispose of it, the gain or loss is the proceeds minus that basis. This page explains how our wallet reports compute it from Solana transactions.
A report replays a wallet's history in order. Each change in a token's balance is a leg, priced in USD at the time of its block.
A swap is two legs: a decrease of the token you gave and an increase of the token you got. Swapping 10 SOL for USDC therefore realizes a gain or loss on the 10 SOL, and opens a USDC lot at the price of the swap.
When a decrease draws from several lots, the method decides which go first:
| Method | Consumes first |
|---|---|
| FIFO (the default) | the oldest lot |
| LIFO | the newest lot |
| HIFO | the lot with the highest cost per unit; lots with no price go last |
| Average | one pooled lot per asset, at the quantity-weighted mean cost |
Example: buy 10 at $1, 10 at $2 and 10 at $3, then sell 15 at $5. FIFO sells 10 at $1 and 5 at $2, a basis of $20. HIFO sells 10 at $3 and 5 at $2, a basis of $40.
The SOL paid as a transaction fee is a decrease like any other: it consumes SOL lots and realizes the gain or loss on that SOL.
Solana requires a small SOL deposit, called rent, to keep an account open, such as a token account. That SOL stays yours and comes back when the account is closed. Reports track it as a separate rent-locked position, moved at its original basis, so paying or recovering rent never realizes a gain or loss.
If a wallet sells more of a token than the replay has seen it acquire, for example because it held the token before the scanned history begins, the excess is dropped rather than given an invented basis. A rent refund with no matching deposit is reported as an anomaly instead of being counted as new SOL.
See pricing for what a report costs.