Query editor
WITH deposits AS (SELECTSUM(cast(boostAmount as double)) as boosted,SUM(cast(depositAmount as double)) as deposited,SUM(cast(boostAmount as double) + cast(depositAmount as double)) as boosted_deposit, -- incl multiplier for boosted amtSUM((cast(boostAmount as double)/5) + cast(depositAmount as double)) as total_deposit, -- excl multiplier for boosted amtpidFROMsophon_ethereum.SophonFarming_evt_DepositGROUP BYpid),withdraws AS (SELECTSUM(cast(amount as double)) as withdrawn,pidFROMsophon_ethereum.SophonFarming_evt_WithdrawGROUP BYpid),booster AS (SELECTSUM(cast(boostAmount as double)/5) as boostAmount, --excl multiplierpidFROMsophon_ethereum.SophonFarming_evt_IncreaseBoostGROUP BYpid),current_holdings AS (SELECTd.pid,d.deposited,COALESCE(w.withdrawn, 0) as withdrawn,d.total_deposit - COALESCE(w.withdrawn, 0) as total_holdings -- current holdingsFROMdeposits dLEFT JOINwithdraws w ON d.pid = w.pidLEFT JOINbooster b ON d.pid = b.pid)-- Fetch names, prices, and decimals from query_3847099SELECTc.pid,SUM(c.total_holdings * nap.price / POWER(10, nap.decimals)) AS tvl,SUM(c.total_holdings / POWER(10, nap.decimals)) AS token_amount,nap.name,nap.decimalsFROMcurrent_holdings cJOINquery_3847099 nap ON c.pid = nap.pidGROUP BYc.pid, nap.name, nap.decimalsORDER BYpid ASC