Query editor
with getLPBalance as (select sum(case when "from" = 0x0000000000000000000000000000000000000000 THEN (value/1e18) ELSE -(value/1e18) END) AS lp_supplyfrom erc20_ethereum.evt_transferwhere contract_address = 0xac86903cdDA380F20a06Cc8a2DEA7749F1558c68and ("from" = 0x0000000000000000000000000000000000000000 or "to" = 0x0000000000000000000000000000000000000000)),getTVLinPool as (SELECT SUM(amount * price) as total_tvl FROM (SELECT symbol, -(value/POW(10,decimals)) as amountFROM erc20_ethereum.evt_transfer aLEFT JOIN tokens.erc20 b ON a.contract_address = b.contract_address and blockchain = 'ethereum'WHERE "from" = 0xac86903cdDA380F20a06Cc8a2DEA7749F1558c68and a.contract_address IN (0xe76C6c83af64e4C60245D8C7dE953DF673a7A33D, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)UNION ALLSELECT symbol, (value/POW(10,decimals)) as amountFROM erc20_ethereum.evt_transfer aLEFT JOIN tokens.erc20 b ON a.contract_address = b.contract_address and blockchain = 'ethereum'WHERE "to" = 0xac86903cdDA380F20a06Cc8a2DEA7749F1558c68and a.contract_address IN (0xe76C6c83af64e4C60245D8C7dE953DF673a7A33D, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)) as xjoin prices.usd_latest y ON blockchain = 'ethereum' and x.symbol = y.symbol)SELECT *, total_tvl / lp_supply as lp_token_priceFROM getLPBalance join getTVLinPool on 1 = 1