Query editor
with token_balances as (select -- tokens boughtsum(cast(value as double) / pow(10, b.decimals)) as amount, a.to as addressfrom erc20_ethereum.evt_Transfer ajoin tokens.erc20 b on a.contract_address = b.contract_addresswhere a.contract_address = 0xFA1C09fC8B491B6A4d3Ff53A10CAd29381b3F949group by 2union allselect -- tokens sold-sum(cast(value as double) / pow(10, b.decimals)) as amount, "from" as addressfrom erc20_ethereum.evt_Transfer ajoin tokens.erc20 b on a.contract_address = b.contract_addresswhere a.contract_address = 0xFA1C09fC8B491B6A4d3Ff53A10CAd29381b3F949group by 2),supply as (selectsum(amount) as circulating_supplyfrom token_balanceswhere address <> 0x0000000000000000000000000000000000000000),latest_price as (select pricefrom prices.hourwhere 1=1and blockchain = 'ethereum'and contract_address = 0xFA1C09fC8B491B6A4d3Ff53A10CAd29381b3F949order by timestamp desclimit 1)select-- price,circulating_supply-- price * circulating_supply as market_capfrom supply cross join latest_price