Skip to main content

Leaderboard Stats

Get aggregate protocol-level statistics using get_pnl_leaderboard_stats. Returns pnl_leaderboard_stats rows with metrics like total traders, average PnL, and profitability rates.

Query Structure​

query GetPnlLeaderboardStats {
get_pnl_leaderboard_stats(
args: {
p_term_id: null
p_time_filter: null
}
) {
total_traders
profitable_traders
unprofitable_traders
profitable_pct
total_pnl_sum
avg_pnl
median_pnl
total_volume
avg_volume
}
}

Function Arguments​

ArgumentTypeDescription
p_term_idStringOptional term filter (null for protocol-wide)
p_time_filterStringOptional time filter preset

Response Fields (pnl_leaderboard_stats)​

FieldTypeDescription
total_tradersbigintTotal number of traders
profitable_tradersbigintNumber of traders with positive PnL
unprofitable_tradersbigintNumber of traders with negative PnL
profitable_pctnumericPercentage of profitable traders
total_pnl_sumnumericSum of all PnL across traders
avg_pnlnumericAverage PnL per trader
median_pnlnumericMedian PnL across traders
total_volumenumericTotal trading volume across all traders
avg_volumenumericAverage volume per trader

Interactive Example​

Query

query GetPnlLeaderboardStats {
  get_pnl_leaderboard_stats(args: {}) {
    total_traders
    profitable_traders
    unprofitable_traders
    profitable_pct
    total_pnl_sum
    avg_pnl
    median_pnl
    total_volume
    avg_volume
  }
}

Variables

Click "Run Query" to execute the GraphQL query and see results

Use Cases​

Protocol Health Dashboard​

Display aggregate protocol trading metrics:

import { GraphQLClient } from 'graphql-request'
import { API_URL_PROD } from '@0xintuition/graphql'

const client = new GraphQLClient(API_URL_PROD)

async function getProtocolStats() {
const query = `
query GetPnlLeaderboardStats {
get_pnl_leaderboard_stats(args: {}) {
total_traders
profitable_pct
avg_pnl
median_pnl
total_volume
}
}
`

const data = await client.request(query)
return data.get_pnl_leaderboard_stats[0]
}