Skip to content

Commit

Permalink
Update cow_protocol_arbitrum_batches.sql
Browse files Browse the repository at this point in the history
Reverting the hardcoded logic back.
  • Loading branch information
olgafetisova authored Jun 27, 2024
1 parent c718097 commit 90aceb8
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion models/cow_protocol/arbitrum/cow_protocol_arbitrum_batches.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@
}}

WITH
-- Find the PoC Query here: https://dune.com/queries/3840594
solver_activation_events AS (
SELECT
solver,
evt_block_number,
evt_index,
TRUE AS activated
FROM {{ source('gnosis_protocol_v2_arbitrum', 'GPv2AllowListAuthentication_evt_SolverAdded') }}
UNION
SELECT
solver,
evt_block_number,
evt_index,
FALSE AS activated
FROM {{ source('gnosis_protocol_v2_arbitrum', 'GPv2AllowListAuthentication_evt_SolverRemoved') }}
),
ranked_solver_events as (
select
rank() over (partition by solver order by evt_block_number desc, evt_index desc) as rk,
solver,
evt_block_number,
evt_index,
activated as active
from solver_activation_events
),
registered_solvers as (
select solver as address, active
from ranked_solver_events
where rk = 1
),
batch_counts as (
select try_cast(date_trunc('day', s.evt_block_time) as date) as block_date,
s.evt_block_time,
Expand All @@ -36,7 +66,7 @@ batch_counts as (
{% if is_incremental() %}
AND {{ incremental_predicate('i.evt_block_time') }}
{% endif %}
join {{ source('cow_protocol_arbitrum', 'solvers') }}
join registered_solvers
on solver = address
{% if is_incremental() %}
WHERE {{ incremental_predicate('s.evt_block_time') }}
Expand Down

0 comments on commit 90aceb8

Please sign in to comment.