Query editor
WITH token_price AS (-- Reference the price from querySELECTmarket_cap_usd / 1_100_000_000 AS price_usd -- Calculate price from market capFROM query_4505713),token_staked AS (-- Capture all tokens staked into the contractSELECTvalue / 1e18 AS amountFROM erc20_base.evt_transferWHEREcontract_address = 0x20ef84969f6d81Ff74AE4591c331858b20AD82CDAND "to" = 0x5a5fa9f4355be88e75ef82a4f0594afce1f8162d),token_unstaked AS (-- Capture all tokens unstaked from the contractSELECT-(value / 1e18) AS amountFROM erc20_base.evt_transferWHEREcontract_address = 0x20ef84969f6d81Ff74AE4591c331858b20AD82CDAND "from" = 0x5a5fa9f4355be88e75ef82a4f0594afce1f8162d),combined_transfers AS (-- Combine staking and unstaking eventsSELECT * FROM token_stakedUNION ALLSELECT * FROM token_unstaked),net_staked AS (-- Calculate the net staked amountSELECTSUM(amount) AS net_staked_tokenFROM combined_transfers),net_staked_usd AS (-- Convert the net staked amount to USDSELECTns.net_staked_token * fp.price_usd AS net_staked_usdFROM net_staked nsCROSS JOIN token_price fp)SELECTnet_staked_usdFROM net_staked_usd;