Skip to content

Commit

Permalink
add raw batch data wrapper query
Browse files Browse the repository at this point in the history
  • Loading branch information
harisang committed Dec 2, 2024
1 parent 3f95dbd commit 2d4ae55
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cowprotocol/raw_data/.sqlfluff
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[sqlfluff:templater:jinja:context]
start_time='2024-08-01 12:00'
end_time='2024-08-02 12:00'
blockchain='ethereum'
111 changes: 111 additions & 0 deletions cowprotocol/raw_data/batch_data_4351957.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
with
past_batch_data_ethereum as (
select
s.environment,
-1 as auction_id,
d.block_number,
d.block_deadline,
d.tx_hash,
d.solver,
cast(d.data.execution_cost as decimal(32, 0)) as execution_cost, --noqa: RF01
cast(d.data.surplus as decimal(32, 0)) as surplus, --noqa: RF01
cast(d.data.protocol_fee as decimal(32, 0)) as protocol_fee, --noqa: RF01
cast(d.data.fee as decimal(32, 0)) as network_fee, --noqa: RF01
cast(d.data.uncapped_payment_eth as decimal(32, 0)) as uncapped_payment_native_token, --noqa: RF01
cast(d.data.capped_payment as decimal(32, 0)) as capped_payment, --noqa: RF01
cast(d.data.winning_score as decimal(32, 0)) as winning_score, --noqa: RF01
cast(d.data.reference_score as decimal(32, 0)) as reference_score --noqa: RF01
from cowswap.raw_batch_rewards as d inner join cow_protocol_ethereum.solvers as s on d.solver = cast(s.address as varchar) where d.block_deadline < 20866925
),

past_batch_data_gnosis as ( --noqa: ST03
select
'a' as environment,
0 as auction_id,
0 as block_number,
0 as block_deadline,
'0x' as tx_hash,
'0x' as solver,
0 as execution_cost,
0 as surplus,
0 as protocol_fee,
0 as network_fee,
0 as uncapped_payment_native_token,
0 as capped_payment,
0 as winning_score,
0 as reference_score
where false
),

past_batch_data_arbitrum as ( --noqa: ST03
select
'a' as environment,
0 as auction_id,
0 as block_number,
0 as block_deadline,
'0x' as tx_hash,
'0x' as solver,
0 as execution_cost,
0 as surplus,
0 as protocol_fee,
0 as network_fee,
0 as uncapped_payment_native_token,
0 as capped_payment,
0 as winning_score,
0 as reference_score
where 1 = 0
)

select
environment,
auction_id,
block_number,
block_deadline,
cast(tx_hash as varchar) as tx_hash,
cast(solver as varchar) as solver,
cast(execution_cost as decimal(32, 0)) as execution_cost,
cast(surplus as decimal(32, 0)) as surplus,
cast(protocol_fee as decimal(32, 0)) as protocol_fee,
cast(network_fee as decimal(32, 0)) as network_fee,
cast(uncapped_payment_eth as decimal(32, 0)) as uncapped_payment_native_token,
cast(capped_payment as decimal(32, 0)) as capped_payment,
cast(winning_score as decimal(32, 0)) as winning_score,
cast(reference_score as decimal(32, 0)) as reference_score
from dune.cowprotocol.dataset_batch_data_{{blockchain}}_2024_10
union all
select
environment,
auction_id,
block_number,
block_deadline,
cast(tx_hash as varchar) as tx_hash,
cast(solver as varchar) as solver,
cast(execution_cost as decimal(32, 0)) as execution_cost,
cast(surplus as decimal(32, 0)) as surplus,
cast(protocol_fee as decimal(32, 0)) as protocol_fee,
cast(network_fee as decimal(32, 0)) as network_fee,
cast(uncapped_payment_eth as decimal(32, 0)) as uncapped_payment_native_token,
cast(capped_payment as decimal(32, 0)) as capped_payment,
cast(winning_score as decimal(32, 0)) as winning_score,
cast(reference_score as decimal(32, 0)) as reference_score
from dune.cowprotocol.dataset_batch_data_{{blockchain}}_2024_11
union all
select
environment,
auction_id,
block_number,
block_deadline,
cast(tx_hash as varchar) as tx_hash,
cast(solver as varchar) as solver,
cast(execution_cost as decimal(32, 0)) as execution_cost,
cast(surplus as decimal(32, 0)) as surplus,
cast(protocol_fee as decimal(32, 0)) as protocol_fee,
cast(network_fee as decimal(32, 0)) as network_fee,
cast(uncapped_payment_eth as decimal(32, 0)) as uncapped_payment_native_token,
cast(capped_payment as decimal(32, 0)) as capped_payment,
cast(winning_score as decimal(32, 0)) as winning_score,
cast(reference_score as decimal(32, 0)) as reference_score
from dune.cowprotocol.dataset_batch_data_{{blockchain}}_2024_12
union all
select *
from past_batch_data_{{blockchain}}

0 comments on commit 2d4ae55

Please sign in to comment.