Query editor
-- This query computes fees---- It currently uses the raw order rewards table as generated by query 4364122.---- Parameters:-- {{start_time}} - the timestamp for which the analysis should start (inclusively)-- {{end_time}} - the timestamp for which the analysis should end (exclusively)-- {{blockchain}} - network to run the analysis on---- The columns of the result are-- - block_time: time of settlement transaction-- - tx_hash: settlement transaction hash-- - order_uid: order uid of the trade with a fee-- - token_address: address of token with a balance change. contract address for erc20 tokens,-- 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee for native token-- - amount: value of fee in atoms of the token-- - fee_type: 'protocol_fee' for the total protocol fee (including partner fee), 'network_fee' for network feeswith raw_fee_data as (selectblock_time,t.tx_hash,t.order_uid,atoms_sold,atoms_bought,sell_token_address,order_type,protocol_fee,surplus_fee,network_fee,protocol_fee_token as protocol_fee_token_addressfrom cow_protocol_{{blockchain}}.trades as tinner join "query_4364122(blockchain='{{blockchain}}')" as roron t.order_uid = ror.order_uid and t.tx_hash = ror.tx_hashwhere block_time >= cast('{{start_time}}' as timestamp) and block_time < cast('{{end_time}}' as timestamp)),protocol_fees as (selectblock_time,tx_hash,order_uid,casewhen '{{blockchain}}' = 'ethereum' and protocol_fee_token_address = 0x3231cb76718cdef2155fc47b5286d82e6eda273f then 0x39b8b6385416f4ca36a20319f70d28621895279dwhen '{{blockchain}}' = 'gnosis' and protocol_fee_token_address = 0xcb444e90d8198415266c6a2724b7900fb12fc56e then 0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430when '{{blockchain}}' = 'gnosis' and sell_token_address = 0x5cb9073902f2035222b9749f8fb0c9bfe5527108 then 0x8e34bfec4f6eb781f9743d9b4af99cd23f9b7053else protocol_fee_token_addressend as token_address,protocol_fee as amount,'protocol_fee' as fee_typefrom raw_fee_data),network_fees as (select -- noqa: ST06block_time,tx_hash,order_uid,sell_token_address as token_address,-- PRS disabled: int256 is not standard Trino, only available in Dune