Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unusual slippage query (2332678) #33

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cowprotocol/accounting/rewards/mainnet/.sqlfluff
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ cte_name = 'results'
start_time='2024-08-20 00:00:00'
end_time='2024-08-27 00:00:00'
vouch_cte_name=valid_vouches,named_results
min_absolute_slippage_tolerance=100
relative_slippage_tolerance=0.3
significant_slippage_value=1000
time='2024-08-27 00:00:00'
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- Query that detects high slippage settlements
-- Parameters:
-- {{start_time}} - the start date timestamp for the accounting period (inclusively)
-- {{end_time}} - the end date timestamp for the accounting period (exclusively)
-- {{min_absolute_slippage_tolerance}} -- the minimum absolute threshold above which a tx is may be flagged as high-slippage
-- {{relative_slippage_tolerance}} -- the minimum relative threshold (wrt batch value) above which a tx may be flagged as high-slippage
-- {{significant_slippage_value}} -- the absolute threshold above which a tx is always flagged as high-slippage
with
results_per_tx as (
select * from "query_3427730(start_time='{{start_time}}',end_time='{{end_time}}',cte_name='results_per_tx')"
)

select --noqa: ST06
block_time,
concat(environment, '-', name) as solver_name,
concat('<a href="https://dune.com/queries/1955401?TxHash=', cast(rpt.tx_hash as varchar), '&sidebar=none" target="_blank">link</a>') as token_breakdown,
rpt.tx_hash,
usd_value,
batch_value,
100 * usd_value / 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
where (
abs(usd_value) > {{min_absolute_slippage_tolerance}}
and
100.0 * abs(usd_value) / batch_value > {{relative_slippage_tolerance}}
) or abs(usd_value) > {{significant_slippage_value}}
order by relative_slippage
Loading