Nansen Query Documentation
  • Introduction
  • Overview
    • 📍Getting Started
    • 📍Benefits of Curation
  • Data
    • 🗃️Data Sources
    • 🗃️Data Catalog
      • 🗃️Raw Events
      • 🗃️Aggregates
        • Entity Stats
        • Address Stats
        • Token Usage Stats
        • Transaction Stats
        • Address & Their Relationships
      • 🗃️Dex Trades
        • 🗃️Dex Trader P&L
        • 🗃️Dex Trader Use Cases
        • 🗃️Advanced Topics
        • 🗃️Trader P&L FAQ
      • 🗃️Decoded Contracts
      • 🗃️NFTs
      • 🗃️Governance
      • 🗃️Solana
        • 🗃️Solana Aggregates
    • 🗃️Repeated / Nested Fields
    • 🗃️Adding New Projects
    • 🗃️Data Marketplace
  • Web App
    • 🖥️Overview
    • 🖥️Getting Started: Web App
    • 🖥️My Queries
    • 🖥️Query Editor
    • 🖥️Visualizations
    • 🖥️Dashboards
    • 🖥️Dashboard Editor
    • 🖥️Refresh Schedules
    • ⚙️Custom Query APIs
      • ⚙️API Keys
      • ⚙️Execute A Query
      • ⚙️Get Query Results
  • Database Access
    • 📂Database Overview
    • 📂Getting Started: Database
    • 📂Sample Queries
      • 📂Wallet Examples
      • 📂Token Examples
      • 📂Trader P&L
      • 📂Project Examples
      • 📂Solana Queries
      • 📂Blockchain Examples
    • 📂Sample Python Code
      • 📂Wallet Examples
      • 📂Token Examples
    • 📂Cost Optimization
    • 📂Database FAQs
  • Other
    • ⁉️General FAQs
    • 🏷️Wallet Labels
Powered by GitBook
On this page
  • Basics
  • Profit & Loss Book Keeping
  1. Data
  2. Data Catalog
  3. Dex Trades

Trader P&L FAQ

Additional documentation on the Dex Trader P&L Table

PreviousAdvanced TopicsNextDecoded Contracts

Last updated 1 year ago

Basics

  • All profit fields are based on realized P&L. For example, fields such as:

    • total_profit, adjusted_pnl, block_hour_profit

  • Only tokens bought and sold on dexes count toward the P&L

  • The profit for each trade is based on the counterpart token value and price

    • E.g., swapping token A for token B, the value of this trade is based on Token B

  • For now, we only consider the major DEX to avoid data quality issues

  • Multi-path trades are consolidated whenever possible

    • USDC -> ETH, ETH -> UNI is converted into USDC -> UNI

  • Trades for tokens that that have a mint or burn function, combined add/remove LP + swap calls, extra fee logic, or have different or multiple sender / receiver (MEV bots bribing validators) are excluded from the analysis

Profit & Loss Book Keeping

For each valid buy, we create an open balance for that token.

For each valid sale, we deduct from the open balance and calculate the profit and loss for that transaction.

For each token balance change, we multiply -DELTA by the USD$ price.

The P&L at any given time is the total value of the book, minus the initial value of the unsold inventory. Mechanically, we issue a "refund" to deduct from the P&L amount. This results in a $1k profit for ETH and no profit for USDC.

We also deduct transactions fees incurred during these transactions from the final profit and loss amount.

🗃️
🗃️
🗃️
Examples of open balances for some transactions
Partial P&L for each transaction
Profit and Loss Example