Query editor
WITH latest_share_price AS (-- Get recent withdrawals to establish share priceSELECTAVG((u.value * 1.0) / s.value) as avg_share_priceFROM erc20_ethereum.evt_Transfer sJOIN erc20_ethereum.evt_Transfer uON s.evt_tx_hash = u.evt_tx_hashWHERE s.contract_address = 0x9Fb7b4477576Fe5B32be4C1843aFB1e55F251B33AND s."to" = 0x0000000000000000000000000000000000000000 -- Burns onlyAND u.contract_address = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 -- USDCAND u."from" = 0x52Aa899454998Be5b000Ad077a46Bbe360F4e497 -- Fluid treasuryAND s.evt_block_time >= NOW() - interval '1' day),decoded_balances AS (SELECTcaller as user_address,SUBSTR(CAST(data AS VARCHAR), 67, 8) as pool_id,bytearray_to_uint256(substring(data from 97 for 32)) as balance_after,ROW_NUMBER() OVER (PARTITION BY caller, SUBSTR(CAST(data AS VARCHAR), 67, 8)ORDER BY evt_block_time DESC) as user_pool_rnFROM brava_ethereum.Logger_evt_ActionEventWHERE logId = 1 -- BALANCE_UPDATE)SELECTb.pool_id,p.pool_name,COUNT(DISTINCT b.user_address) as unique_users,SUM(b.balance_after) / 1e6 as total_shares,sp.avg_share_price as share_price,(SUM(b.balance_after) / 1e6) * sp.avg_share_price as total_value_usdcFROM decoded_balances bJOIN dune.splidge.dataset_pools pON b.pool_id = p.pool_idCROSS JOIN latest_share_price spWHERE b.user_pool_rn = 1AND p.pool_address = 0x9Fb7b4477576Fe5B32be4C1843aFB1e55F251B33 -- Fluid USDC poolGROUP BYb.pool_id,p.pool_name,sp.avg_share_priceORDER BY total_value_usdc DESC;