Query editor
WITH staking_events AS (SELECTsm."to" as staker,sm.evt_tx_hash,sm.evt_block_time,sm.evt_block_number,CAST(sm.value AS DECIMAL(38,0)) / 1e18 as stprove_amount,CAST(prove_tx.value AS DECIMAL(38,0)) / 1e18 as prove_amount,CAST(ipt.value AS DECIMAL(38,0)) / 1e18 as ipt_amountFROM erc20_ethereum.evt_Transfer smJOIN erc20_ethereum.evt_Transfer ipt ON sm.evt_tx_hash = ipt.evt_tx_hashJOIN erc20_ethereum.evt_Transfer prove_tx ON sm.evt_tx_hash = prove_tx.evt_tx_hashWHERE sm.contract_address = 0x59A2d7b0421bA13F57bF012f46C58ab5a65B1d3CAND sm."from" = 0x0000000000000000000000000000000000000000AND ipt.contract_address = 0x04ece2a2c3ea68356274f37c096258c7a9e72fa1AND ipt."to" = 0x4eac32f0a25ea9d7f22d1aa40735cb761c672bd6AND prove_tx.contract_address = 0x6bef15d938d4e72056ac92ea4bdd0d76b1c4ad29AND prove_tx."to" = 0x04ece2a2c3ea68356274f37c096258c7a9e72fa1),price_data AS (SELECTAVG(price) as current_priceFROM (SELECTCASEWHEN token_bought_address = 0x6bef15d938d4e72056ac92ea4bdd0d76b1c4ad29THEN amount_usd / NULLIF(token_bought_amount, 0)WHEN token_sold_address = 0x6bef15d938d4e72056ac92ea4bdd0d76b1c4ad29THEN amount_usd / NULLIF(token_sold_amount, 0)END as priceFROM dex.tradesWHERE project_contract_address IN (0x7aed0a7bf286abc736959fd42acc27d80b0507d6d3053755359ae459ac27743f, -- PROVE/USDC0xf6d500fc33e0865ff1c1c6c58a2c9e247db2e5df007c080f6664a9375f374ff1, -- PROVE/USDT0xc76cdb74d781e219e8c8855a99584dd2e4580046 -- PROVE/WETH)AND blockchain = 'ethereum'AND (token_bought_address = 0x6bef15d938d4e72056ac92ea4bdd0d76b1c4ad29OR token_sold_address = 0x6bef15d938d4e72056ac92ea4bdd0d76b1c4ad29)AND amount_usd > 100ORDER BY block_time DESCLIMIT 30) recent_tradesWHERE price IS NOT NULL AND price > 0),total_tvl AS (SELECTSUM(CASEWHEN "to" IN (0x04ece2a2c3ea68356274f37c096258c7a9e72fa1, 0x59A2d7b0421bA13F57bF012f46C58ab5a65B1d3C)AND "from" NOT IN (0x04ece2a2c3ea68356274f37c096258c7a9e72fa1, 0x59A2d7b0421bA13F57bF012f46C58ab5a65B1d3C, 0x16ec6dadfe11e523c47cb8878b85606c0ca5cf95)THEN CAST(value AS DECIMAL(38,0)) / 1e18WHEN "from" IN (0x04ece2a2c3ea68356274f37c096258c7a9e72fa1, 0x59A2d7b0421bA13F57bF012f46C58ab5a65B1d3C)AND "to" NOT IN (0x04ece2a2c3ea68356274f37c096258c7a9e72fa1, 0x59A2d7b0421bA13F57bF012f46C58ab5a65B1d3C, 0x0000000000000000000000000000000000000000)THEN -CAST(value AS DECIMAL(38,0)) / 1e18ELSE 0END) AS total_staked_allFROM erc20_ethereum.evt_TransferWHERE contract_address = 0x6bef15d938d4e72056ac92ea4bdd0d76b1c4ad29AND ("to" IN (0x04ece2a2c3ea68356274f37c096258c7a9e72fa1, 0x59A2d7b0421bA13F57bF012f46C58ab5a65B1d3C)OR "from" IN (0x04ece2a2c3ea68356274f37c096258c7a9e72fa1, 0x59A2d7b0421bA13F57bF012f46C58ab5a65B1d3C))