The Panda Protocol subgraph defines several core entities that model the protocol's data. Each entity represents a specific aspect of the protocol's state and behavior.
Core Entities
PandaPool
Represents an individual Panda liquidity pool. Each pool manages a pair of tokens and tracks trading activity.
typePandaPool@entity { id: ID! # Pool contract address baseToken: Token! # The base currency token pandaToken: Token! # The Panda token being traded price: BigDecimal! # Current token price volumeUSD: BigDecimal! # Total USD volume marketCapBase: BigDecimal! # Market cap in base currency terms marketCapUSD: BigDecimal! # Market cap in USD termes swapsCount: BigInt! # Total number of swaps lastSwapTimestamp: BigInt! # Last swap timestamp graduated: Boolean! # Graduation status raised: BigDecimal! # amount of tokens raised tokensInPool: BigDecimal! # Total token in the pool pandaReserve: BigDecimal! # Panda token reserve baseReserve: BigDecimal! # Base token reserve startPrice: BigDecimal! # Initial token price}
Common Queries
# Get active pools with high volume{ pandaPools( where: {graduated: false,volumeUSD_gt: "100000" }, orderBy: volumeUSD, orderDirection: desc ) { id price volumeUSD swapsCount }}# Get pool reserves{ pandaPool(id: "0x...") { pandaReserve baseReserve tokensInPool }}
Token
Tracks both Panda and base tokens in the protocol.
typeToken@entity { id: ID! # Token contract address name: String! # Token name symbol: String! # Token symbol decimals: BigInt! # Token decimals totalSupply: BigDecimal! # Total supply isPandaToken: Boolean! # Token type identifier pools: [PandaPool!]! # Associated pools holders: [Holder!]! # Token holders holdersCount: BigInt! # Number of holders lastSwapTimestamp: BigInt! # Last swap timestamp createdAtTimestamp: BigInt! # Creation timestamp}
Example Queries
# Get token details with holder metrics{ token(id: "0x...") { symbol totalSupply holdersCount holders(first: 10, orderBy: balance, orderDirection: desc) { balance sharePercentage } }}
PandaPoolSwap
Records individual swap transactions within pools.
typePandaPoolSwap@entity(immutable: true) { id: ID! # Unique swap identifier pool: PandaPool! # Reference to pool timestamp: BigInt! # Swap timestamp amountPandaIn: BigDecimal! # Panda tokens in amountPandaOut: BigDecimal! # Panda tokens out amountBaseIn: BigDecimal! # Base tokens in amountBaseOut: BigDecimal! # Base tokens out from: Bytes! # Sender address to: Bytes! # Recipient address tx: String! # Transaction hash origin: String! # Transaction origin volumeUSD: BigDecimal! # Volume in USD averagePrice: BigDecimal! # Average execution price}
Querying Swaps
# Get recent swaps for a pool{ pandaPoolSwaps( where: { pool: "0x..." } orderBy: timestamp orderDirection: desc first: 100 ) { timestamp amountPandaIn amountPandaOut volumeUSD averagePrice }}
PriceSnapshot
Time-based price aggregation for historical analysis.