Query editor
with wash_trading AS (SELECT distinct wash_trading_filter_ AS wash_trading_filterFROM (SELECT CASE WHEN '{{Wash Trading Filter}}' IN ('ON', 'OFF') THEN false END AS wash_trading_filter_UNIONSELECT CASE WHEN '{{Wash Trading Filter}}'='OFF' THEN true END AS wash_trading_filter_)WHERE wash_trading_filter_ IS NOT NULL), minter AS(SELECTtransfer.to AS address,transfer.tokenId AS token_id,count(distinct transfer.evt_tx_hash) AS total_mint,sum(txs.gas_price * txs.gas_used/1e18 * p.price) as total_gas_spent_usd,sum(txs.gas_price * txs.gas_used/1e18) as total_gas_spent_ethFROM erc721_ethereum.evt_Transfer transferJOIN ethereum.transactions txs ON txs.hash = transfer.evt_tx_hashLEFT JOIN prices.usd p ON date_trunc('minute',transfer.evt_block_time) = p.minute AND p.contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2WHERE transfer.contract_address = {{nft_address}}AND transfer."from" = 0x0000000000000000000000000000000000000000GROUP BY 1, 2), nft_balances as (select -- token out-count( evt_tx_hash) as amount, "from" as address, tokenId as token_idfrom erc721_{{chain}}.evt_Transfer awhere a.contract_address = {{nft_address}}group by 2, 3union allselect -- token incount(evt_tx_hash) as amount, a.to as address, tokenId as token_idfrom erc721_{{chain}}.evt_Transfer awhere a.contract_address = {{nft_address}}group by 2, 3),nft_holders as (selectaddress, cast(token_id as varchar) token_id, sum(amount) as balancefrom nft_balancesgroup by 1, 2),nft_trades as (select -- sell transactiont.seller address, t.token_id, t.currency_contract, t.nft_contract_address, 0 amount_buy_eth, t.amount_original amount_sell_eth, 0 amount_buy_usd, t.amount_usd amount_sell_usd