Query editor
-- PnL Leaderboard - Flex Frenzy Trading Competition - JUP-- Top 10 PnL: 30% = $1,800 (proportional distribution)-- Eligibility: Users must have positive realized PnL and at least $25k volume to qualifyWITH config AS (SELECTTIMESTAMP '2026-01-22 00:01:00' AS start_time,TIMESTAMP '2026-01-31 23:59:59' AS end_time),-- Excluded walletsexcluded_wallets AS (SELECT wallet FROM (VALUES(0xf7d48932f456e98d2ff824e38830e8f59de13f4a)) AS t(wallet)),-- Account connection mappingaccount_connection AS (SELECT DISTINCT*FROM (SELECTprimaryAccount AS account,subAccountFROM flexperp_base.TradeService_evt_LogIncreasePosition)),-- Market names with asset informationmarket_name AS (SELECTindex,assetId AS asset,CASEWHEN assetClass = 0 THEN 'Crypto'WHEN assetClass = 1 THEN 'Equities'WHEN assetClass = 2 THEN 'Forex'WHEN assetClass = 3 THEN 'Commodity'END AS assetClassFROM (SELECTindex,-- Remove null bytes (chr(0)) from the hex-decoded asset name (invisible characters)REPLACE(from_utf8(from_hex(REPLACE(CAST(json_value(newConfig, 'strict $.assetId') AS VARCHAR), '0x', ''))),chr(0),'') AS assetId,CAST(json_value(newConfig, 'strict $.assetClass') AS DECIMAL)AS assetClassFROM flexperp_base.ConfigStorage_evt_LogAddMarketConfig)),-- Get JUP market indexjup_market AS (SELECT index AS marketIndexFROM market_name