Query editor
WITH daily_trades AS (SELECTtoken_bought_address AS token_contract,token_bought_symbol AS token_symbol,(amount_usd / token_bought_amount) AS price_usd,DATE_TRUNC('day', block_time) AS trade_dayFROM dex.tradesWHERE project = 'thruster'AND token_bought_address = 0xE36072DD051Ce26261BF50CD966311cab62C596e),avg_daily_token_prices AS (SELECTtrade_day,token_contract,token_symbol,AVG(price_usd) AS avg_price_usdFROM daily_tradesGROUP BY trade_day, token_contract, token_symbolHAVING AVG(price_usd) > 0),received_tokens AS (SELECTblock_date AS transaction_day,SUM(amount_usd) AS token_boughtFROMdex.tradesWHEREproject = 'thruster'AND token_bought_address = 0xE36072DD051Ce26261BF50CD966311cab62C596eGROUP BY block_date),withdrawed_tokens AS (SELECTblock_date AS transaction_day,SUM(amount_usd) AS token_soldFROMdex.tradesWHEREproject = 'thruster'AND token_sold_address = 0xE36072DD051Ce26261BF50CD966311cab62C596eGROUP BY block_date),claimed_tokens AS (SELECTcall_block_date AS transaction_day,SUM(amount_ / 1e18) AS claimed_amountFROMthruster_blast.TokenDistributor_call_claimGROUP BY call_block_date),daily_summary AS (SELECTCOALESCE(r.transaction_day, w.transaction_day, c.transaction_day) AS day,COALESCE(r.token_bought, 0) AS THRUST_bought,COALESCE(w.token_sold, 0) AS THRUST_sold,COALESCE(c.claimed_amount, 0) AS THRUST_claimed,(COALESCE(r.token_bought, 0) - COALESCE(w.token_sold, 0)) + COALESCE(c.claimed_amount, 0) AS THRUST_hold_amount,COALESCE(p.avg_price_usd, 0) AS day_avg_token_price_usd,(COALESCE(p.avg_price_usd, 0) * ((COALESCE(r.token_bought, 0) - COALESCE(w.token_sold, 0)) + COALESCE(c.claimed_amount, 0))) AS total_value_usdFROM