Skip to content

Commit

Permalink
add three additional columns to slippage query (#111)
Browse files Browse the repository at this point in the history
on total imbalance, protocol fee, network fee
  • Loading branch information
fhenneke authored Jan 6, 2025
1 parent 566ef0d commit 5e6c0c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ select --noqa: ST06
) as tx_hash,
slippage_usd,
batch_value,
100 * slippage_usd / batch_value as relative_slippage
100 * slippage_usd / batch_value as relative_slippage,
imbalance_usd,
protocol_fee_usd,
network_fee_usd
from results_per_tx as rpt
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
Expand Down
8 changes: 7 additions & 1 deletion cowprotocol/accounting/slippage/slippage_4070065.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
-- - solver_address: address of the solver executing the settlement
-- - slippage_usd: USD value of slippage
-- - slippage_wei: value of slippage in atoms of native token
-- - imbalance_usd: USD value of total buffer imbalance
-- - protocol_fee_usd: USD value of protocol fees
-- - network_fee_usd: USD value of network fees
--
-- The columns of slippage_per_solver are
-- - solver_address: address of the solver executing the settlement
Expand All @@ -33,7 +36,10 @@ slippage_per_transaction as (
rs.tx_hash,
solver_address,
sum(slippage_usd) as slippage_usd,
sum(slippage_wei) as slippage_wei
sum(slippage_wei) as slippage_wei,
sum(if(slippage_type = 'raw_imbalance', slippage_usd, 0)) as imbalance_usd,
sum(if(slippage_type = 'protocol_fee', -slippage_usd, 0)) as protocol_fee_usd,
sum(if(slippage_type = 'network_fee', -slippage_usd, 0)) as network_fee_usd
from "query_4059683(blockchain='{{blockchain}}',start_time='{{start_time}}',end_time='{{end_time}}',raw_slippage_table_name='raw_slippage_breakdown')" as rs
inner join cow_protocol_{{blockchain}}.batches as b
on rs.tx_hash = b.tx_hash
Expand Down

0 comments on commit 5e6c0c8

Please sign in to comment.