solana.assets.pnl table holds transaction-level PNL records.
PNL calculation and Methodology
See here for details.Key Fields
The PNL model provides several important fields for analysis:average_cost: The current weighted average cost per token unit, calculated ascumulative_costs / cumulative_quantitiescumulative_costs: The total USD cost basis remaining after accounting for sales (reduces proportionally when tokens are sold)cumulative_quantities: The remaining token quantity after accounting for salesrealized_pnl: The cumulative realized profit/loss from all sales transactions for this tokenunrealized_pnl: The unrealized profit/loss based on the token price at the time of the transactionunrealized_pnl_latest: The current unrealized profit/loss using the latest available token price
Getting Daily PNL
Getting Daily PNL
This query shows how to get daily PNL snapshots for a wallet
Getting Aggregated PNL
Getting Aggregated PNL
This query shows how to get aggregated PNL across multiple address and/or tokens for portfolio-level analysis.
Table Columns
Unique Key:address, token_account, mint, unique_id
| Column Name | Description |
|---|---|
token_type | The type of token (e.g., ‘native’, ‘spl-token’). |
address | The Solana wallet address holding the token. |
token_account | The token account address associated with this token holding. |
mint | The mint address of the token. Native SOL is represented with a special mint address. |
token_name | The name of the token. |
token_symbol | The symbol of the token. |
balance | The current token balance after this transaction. |
prev_balance | The token balance before this transaction. |
balance_change | The change in token balance from this transaction (balance - prev_balance). Can be negative. |
usd_exchange_rate | The USD exchange rate for the token at the time of the transaction. |
usd_balance | The current token balance converted to USD at transaction time. |
usd_balance_change | The change in USD balance from this transaction. Can be negative. |
usd_exchange_rate_latest | The latest available USD exchange rate for the token. |
usd_balance_latest | The current token balance converted to USD using the latest exchange rate. |
transaction_type | The type of transaction: ‘first_purchase’, ‘purchase’, ‘sale’, or ‘no_change’. |
tokens_purchased | The number of tokens purchased in this transaction (0 for sales). |
tokens_sold | The number of tokens sold in this transaction (0 for purchases). |
average_cost | The current weighted average cost per token unit after this transaction. |
cumulative_costs | The total USD cost basis remaining after accounting for proportional reductions from sales. |
cumulative_quantities | The total token quantity remaining after accounting for sales. |
realized_pnl | The cumulative realized profit/loss from all sales transactions for this token up to this point. |
realized_pnl_this_tx | The realized profit/loss from this specific transaction (null for purchases). |
unrealized_pnl | The unrealized profit/loss based on the token price at the time of this transaction. |
unrealized_pnl_latest | The unrealized profit/loss based on the latest available token price. |
block_timestamp | The timestamp of the block containing this transaction. |
block_slot | The Solana block slot number containing this transaction. |
block_height | The Solana block height containing this transaction. |
block_hash | The hash of the block containing this transaction. |
txn_id | The unique transaction ID (signature) for this transaction. |
txn_index | The index of this transaction within the block. |
unique_id | A unique identifier for this PNL record. |