Query editor
-- ๐ฅ MOLTEN Token Staking Leaderboard on Arbitrum-- Token: 0x66E535e8D2ebf13F49F3D49e5c50395a97C137b1-- Staking Contract: 0x35ad17c9ee4aab967ecbd95b4ce7eb9d8e761a2bWITH molten_transfers AS (SELECTevt_block_time,"from" AS from_address,"to" AS to_address,value / 1e18 AS amountFROM erc20_arbitrum.evt_TransferWHERE contract_address = from_hex('0x66E535e8D2ebf13F49F3D49e5c50395a97C137b1')),-- ๐ Tokens sent TO staking contract = stakestaked AS (SELECTfrom_address AS wallet,SUM(amount) AS total_stakedFROM molten_transfersWHERE to_address = from_hex('0x35ad17c9ee4aab967ecbd95b4ce7eb9d8e761a2b')GROUP BY from_address),-- ๐ Tokens sent FROM staking contract = unstakeunstaked AS (SELECTto_address AS wallet,SUM(amount) AS total_unstakedFROM molten_transfersWHERE from_address = from_hex('0x35ad17c9ee4aab967ecbd95b4ce7eb9d8e761a2b')GROUP BY to_address),-- ๐งพ Compute net staked per walletnet_staking AS (SELECTCOALESCE(s.wallet, u.wallet) AS wallet,COALESCE(s.total_staked, 0) - COALESCE(u.total_unstaked, 0) AS net_stakedFROM staked sFULL OUTER JOIN unstaked u ON s.wallet = u.wallet)-- ๐ Final leaderboard with ranksSELECTROW_NUMBER() OVER (ORDER BY net_staked DESC) AS rank,wallet,net_staked,ROUND(net_staked / SUM(net_staked) OVER () * 100, 2) AS percent_of_totalFROM net_stakingWHERE net_staked > 0ORDER BY rank;