Query editor
-- This query provides data related to rewards/payouts on a per auction level-- for all auctions that had at least one winner.-- Parameters:-- blockchain: the chain for which we want to retrieve batch data-- The output has the following columns:-- environment: varchar-- auction_id: integer-- block_deadline: integer-- solver: varbinary-- total_network_fee: decimal(38, 0)-- total_execution_cost: decimal(38, 0)-- total_protocol_fee: decimal(38, 0)-- competition_score: decimal(38, 0)-- observed_score: decimal(38, 0)-- uncapped_payment_native_token: decimal(38, 0)-- capped_payment: decimal(38, 0)with block_range as (select * from "query_3333356(blockchain='{{blockchain}}',start_time='{{start_time}}',end_time='{{end_time}}')"),candidate_batches as (selectblock_number,tx_hash,cast(gas_price as decimal(38, 0)) * cast(gas_used as decimal(38, 0)) as execution_costfrom cow_protocol_{{blockchain}}.batcheswhereblock_date >= cast('{{start_time}}' as timestamp) - interval '1' dayand block_date <= cast('{{end_time}}' as timestamp) + interval '1' day),relevant_txs as (selectrbd.tx_hash,b.execution_costfrom "query_4351957(blockchain='{{blockchain}}')" as rbd inner join candidate_batches as bon rbd.block_number = b.block_number and rbd.tx_hash = b.tx_hashwhereblock_deadline >= (select start_block from block_range)and block_deadline <= (select end_block from block_range))select --noqa: ST06rbd.environment,rbd.auction_id,rbd.block_deadline,rbd.solver,cast(sum(coalesce(rbd.network_fee, 0)) as decimal(38, 0)) as total_network_fee,cast(sum(coalesce(txs.execution_cost, 0)) as decimal(38, 0)) as total_execution_cost,cast(sum(coalesce(rbd.protocol_fee, 0)) as decimal(38, 0)) as total_protocol_fee,cast(sum(rbd.winning_score) as decimal(38, 0)) as competition_score,cast(sum(casewhen rbd.block_number is not null and rbd.block_number <= rbd.block_deadline then winning_scoreelse 0end) as decimal(38, 0)) as observed_score,cast(rbd.reference_score as decimal(38, 0)) as reference_score,