|
6 | 6 | -- Parameters |
7 | 7 | -- {{blockchain}}: string the blockchain to query |
8 | 8 |
|
9 | | -with |
10 | | -solver_latest_batches as ( |
| 9 | +with solver_latest_batches as ( |
11 | 10 | select |
12 | 11 | solver_address, |
13 | 12 | max(block_time) as latest_settlement |
14 | 13 | from cow_protocol_{{blockchain}}.batches |
15 | 14 | group by solver_address |
16 | 15 | ), |
17 | 16 |
|
| 17 | +solvers as ( |
| 18 | + select |
| 19 | + address, |
| 20 | + environment, |
| 21 | + name, |
| 22 | + whitelisted as active |
| 23 | + from dune.cowprotocol.solvers |
| 24 | + where blockchain = '{{blockchain}}' |
| 25 | +), |
| 26 | + |
18 | 27 | active_solvers as ( |
19 | 28 | select |
20 | 29 | address, |
21 | 30 | environment, |
22 | 31 | name, |
23 | 32 | coalesce(latest_settlement, timestamp '1970-01-01') as latest_settlement |
24 | | - from cow_protocol_{{blockchain}}.solvers |
25 | | - full outer join solver_latest_batches |
26 | | - on address = solver_address |
27 | | - where |
28 | | - environment not in ('test', 'service') |
29 | | - and active = true |
| 33 | + from solvers full outer join solver_latest_batches on address = solver_address |
| 34 | + where environment not in ('test', 'service') and active = true |
30 | 35 | ) |
31 | 36 |
|
32 | 37 | select |
33 | 38 | prod.name, |
34 | 39 | prod.address as prod_address, |
35 | 40 | barn.address as barn_address, |
36 | 41 | greatest(prod.latest_settlement, barn.latest_settlement) as latest_settlement |
37 | | -from active_solvers as prod |
38 | | -inner join active_solvers as barn |
39 | | - on |
40 | | - prod.name = barn.name |
41 | | - and prod.environment = 'prod' |
42 | | - and barn.environment = 'barn' |
| 42 | +from active_solvers as prodinner join active_solvers as barn |
| 43 | + on prod.name = barn.name and prod.environment = 'prod' and barn.environment = 'barn' |
43 | 44 | order by greatest(prod.latest_settlement, barn.latest_settlement) desc |
0 commit comments