Blockchain Coverage
We support PNL data for the following blockchains:PNL calculation
The PNL (Profit and Loss) calculation uses the average-cost methodology to determine realized and unrealized gains/losses for fungible assets. This approach provides a fair and consistent way to calculate performance across multiple transactions and time periods.Average-Cost Methodology
The average-cost method calculates PNL by maintaining a running average of the cost basis for each asset position. The methodology tracks cumulative costs and quantities to compute accurate profit and loss metrics.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
Core Principles
- Cost Basis Averaging: When acquiring additional tokens, the new average cost becomes the weighted average of previous holdings and the new acquisition.
-
Proportional Cost Reduction: When disposing of tokens, both
cumulative_costsandquantitiesare reduced proportionally, keeping theaverage_costunchanged. - Transaction-Level Tracking: The average cost basis and PNL metrics are updated with every transaction that changes the token balance.
Detailed PNL Calculation Methodology and Examples
Detailed PNL Calculation Methodology and Examples
Calculation Steps
1. Purchase Transactions (transaction_type: ‘purchase’ or ‘first_purchase’)
When tokens are acquired:- Existing: 100 ETH, cumulative_costs = 2,000
- New purchase: 50 ETH at 120,000
- New cumulative_costs: 120,000 = $320,000
- New quantities: 100 + 50 = 150 ETH
- New average_cost: 2,133.33 per ETH
2. Sale Transactions (transaction_type: ‘sale’)
When tokens are sold:- Before sale: 150 ETH, cumulative_costs = 2,133.33
- Sell: 30 ETH at $2,500 per ETH
- Realized PNL: 30 × (2,133.33) = $11,000.10 gain
- New cumulative_costs: 2,133.33) = $256,000.10
- New quantities: 150 - 30 = 120 ETH
- New average_cost: 2,133.33 per ETH (unchanged)
3. Unrealized PNL Calculations
At Transaction Time:- Current holdings: 120 ETH at average_cost of $2,133.33
- Token price at transaction: $2,600
- Latest token price: $2,800
- Unrealized PNL (transaction time): 120 × (2,133.33) = $56,000.40
- Unrealized PNL Latest: 120 × (2,133.33) = $80,000.40
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:chain, address, token_address, unique_id