Skip to content

Commit

Permalink
Update and extend unusual slippage query to all chains (#98)
Browse files Browse the repository at this point in the history
* update and extend unusual slippage query to all chains

* Update cowprotocol/accounting/rewards/mainnet/unusual_slippage_query_2332678.sql

Co-authored-by: Felix Leupold <[email protected]>

* Update cowprotocol/accounting/rewards/mainnet/unusual_slippage_query_2332678.sql

Co-authored-by: Felix Leupold <[email protected]>

---------

Co-authored-by: Felix Leupold <[email protected]>
  • Loading branch information
harisang and fleupold authored Dec 23, 2024
1 parent 4ceeb93 commit 5f30a95
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,43 @@
-- {{significant_slippage_value}} -- the absolute threshold above which a tx is always flagged as high-slippage
with
results_per_tx as (
select * from "query_4070065(blockchain='ethereum',start_time='{{start_time}}',end_time='{{end_time}}',slippage_table_name='slippage_per_transaction')"
select * from "query_4070065(blockchain='{{blockchain}}',start_time='{{start_time}}',end_time='{{end_time}}',slippage_table_name='slippage_per_transaction')"
),

url_helper as (
select
case
when '{{blockchain}}' = 'ethereum' then 'eth'
else '{{blockchain}}'
end
)

select --noqa: ST06
rpt.block_time,
concat(environment, '-', name) as solver_name,
concat(
'<a href="https://dune.com/queries/4059683',
'?blockchain=ethereum',
'?blockchain={{blockchain}}',
'&start_time={{start_time}}',
'&end_time={{end_time}}',
'&slippage_table_name=raw_slippage_breakdown',
'" target="_blank">link</a>'
) as token_breakdown,
rpt.tx_hash,
concat(
'<a href="https://phalcon.blocksec.com/explorer/tx/',
(select * from url_helper),
'/0x',
to_hex(rpt.tx_hash),
'" target="_blank">0x',
to_hex(rpt.tx_hash),
'</a>'
) as tx_hash,
slippage_usd,
batch_value,
100 * slippage_usd / batch_value as relative_slippage
from results_per_tx as rpt
inner join cow_protocol_ethereum.batches as b on rpt.tx_hash = b.tx_hash
inner join cow_protocol_ethereum.solvers on address = rpt.solver_address
inner join cow_protocol_{{blockchain}}.batches as b on rpt.tx_hash = b.tx_hash
inner join cow_protocol_{{blockchain}}.solvers on address = rpt.solver_address
where (
abs(slippage_usd) > {{min_absolute_slippage_tolerance}}
and
Expand Down

0 comments on commit 5f30a95

Please sign in to comment.