Query editor
WITHfee_and_costs_per_trade as (SELECTt.block_time,t.tx_hash,fee_usd as fee,tx_cost_usd / num_trades as gas_cost,trader as owner,order_uid as uid,app_data,'success' as cost_typeFROM cow_protocol_{{blockchain}}.trades tJOIN cow_protocol_{{blockchain}}.batches bON t.block_time = b.block_timeAND t.tx_hash = b.tx_hashAND t.tx_hash = b.tx_hashAND t.block_date >= timestamp '2022-03-01'AND b.block_date >= timestamp '2022-03-01'-- wrongly set sell/buy token amount in the raw tableswhere t.tx_hash !=0x84d57d1d57e01dd34091c763765ddda6ff713ad67840f39735f0bf0cced11f02),failed_settlements as (SELECTblock_time,hash as tx_hash,0 as fee,(gas_used * gas_price * p.price) / pow(10, 18) as gas_cost,0x as owner,0x as uid,0x as app_data,'failed' as cost_typeFROM {{blockchain}}.transactions as txJOIN prices.usd as pON contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2AND p.minute = date_trunc('minute', block_time)AND blockchain = '{{blockchain}}'AND position('0x13d79a0b' in cast(data as VARCHAR)) > 0 --! settle method IDAND success = falseAND to = 0x9008d19f58aabd9ed0d60971565aa8510560ab41AND block_time >= timestamp '2022-03-01'),-- PoC Cancellations: https://dune.com/queries/2478109cancelations as (SELECTblock_time,hash as tx_hash,0 as fee,(gas_used * gas_price * p.price) / pow(10, 18) as gas_cost,0x as owner,0x as uid,0x as app_data,'canceled' as cost_typeFROM {{blockchain}}.transactions as txJOIN prices.usd as pON contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2AND p.minute = date_trunc('minute', block_time)AND blockchain = '{{blockchain}}'WHERE "from" in (select address from cow_protocol_ethereum.solvers)