Query editor
-- Read-back of solv's two-way trader rule on the QUOTE reward (2026-12-01; solv fcdd150 live 2026-11-30 18:14:35Z).-- CIP-88 scoring as in cip88_executor.sql / cip88_week.sql (the five smallest errors share an order's budget by-- 1/e^2, an exact quote takes all), over the in-scope orders of CoW's quote table, split by-- period = before / cold start / after the rule (2026-11-30 18:14, 2026-11-30 18:40 inside [2026-11-30 00:00, 2026-11-30 22:00)),-- grp = 'two_way' (the wallets the rule refuses, '98ac5b90e4562baee0ed3989fc587dfe3ca7d9b5', 'e84353dbcf2a71890aa069a432198f84166045e6', 'ebef2aed95a5219ad2da2942ad27df26c68620df', '8d4dbe6dfcd42015e58d8856109f579f27e76a31', 'b777c453b8a3e47df03de4d36408a5014f74f3ba', '57281d1045b459e738393bfdfc17b8e961965474', 'e29771d17e879beae9be4b7127f3d5c7bbd50a36', '1074526386cf34da62ffe4b06b47f0f560d58f17', '1298a8d46931c2920e3dcf358d415f91ab79e3ab', 'd35d7fb17ee3061ee6ef5f6856a3cef70d5a1cf1', 'e3c0c6cad89a83c9424d5c21abcc380ceee3ac0f', 'a4ad63e9b5967474b620adfd8e73e0e978e964a7', '8eb3efea8a3e46c145a13b5873c6e5c129e5d787', '364acb22141089ba72d3e7de4fdde4af1b242b58') | 'other',-- who settled (us | someone else) and CoW's own is_eligible_for_quote_reward flag.-- R rows: orders, orders that carry a quote of ours, orders whose stored winning quote is ours, our order-equivalents.-- S rows: who settled the two-way wallets' orders, per period, with OUR order-equivalents on them.-- Run through tools/dune.py (name cip88_two_way_readback); one aggregate run.with q as (select order_uid, solver, is_winner,try_cast(replace(cast(effective_sell_amount as varchar), '_', '') as double) es,try_cast(replace(cast(effective_buy_amount as varchar), '_', '') as double) ebfrom dune.cowprotocol.dataset_prod_quote_competition_ethereum),t as (select order_uid, tx_hash, partial_fill, block_time,cast(atoms_sold as double) xs, cast(atoms_bought as double) xb,cast(limit_sell_amount as double) ls, cast(limit_buy_amount as double) lb,case when lower(to_hex(trader)) in ('98ac5b90e4562baee0ed3989fc587dfe3ca7d9b5', 'e84353dbcf2a71890aa069a432198f84166045e6', 'ebef2aed95a5219ad2da2942ad27df26c68620df', '8d4dbe6dfcd42015e58d8856109f579f27e76a31', 'b777c453b8a3e47df03de4d36408a5014f74f3ba', '57281d1045b459e738393bfdfc17b8e961965474', 'e29771d17e879beae9be4b7127f3d5c7bbd50a36', '1074526386cf34da62ffe4b06b47f0f560d58f17', '1298a8d46931c2920e3dcf358d415f91ab79e3ab', 'd35d7fb17ee3061ee6ef5f6856a3cef70d5a1cf1', 'e3c0c6cad89a83c9424d5c21abcc380ceee3ac0f', 'a4ad63e9b5967474b620adfd8e73e0e978e964a7', '8eb3efea8a3e46c145a13b5873c6e5c129e5d787', '364acb22141089ba72d3e7de4fdde4af1b242b58') then 'two_way' else 'other' end grp,case when block_time < timestamp '2026-11-30 18:14' then 'a before' when block_time < timestamp '2026-11-30 18:40' then 'b cold start'else 'c after' end periodfrom cow_protocol_ethereum.tradeswhere block_time >= timestamp '2026-11-30 00:00' and block_time < timestamp '2026-11-30 22:00'),bs as (select tx_hash, lower(to_hex(solver_address)) settler from cow_protocol_ethereum.batcheswhere block_time >= timestamp '2026-11-30 00:00' and block_time < timestamp '2026-11-30 22:00'),od as (select order_uid, bool_or(is_eligible_for_quote_reward) elfrom dune.cowprotocol.dataset_prod_order_data_mainnet_2026_11 od0 group by 1),w as (select order_uid, eb / es wq, lower(to_hex(solver)) ws from q where is_winner and es > 0 and eb > 0),o as (select t.*, coalesce(bs.settler, '-') settler, w.ws, coalesce(od.el, false) elfrom t join w on t.order_uid = w.order_uidleft join bs on bs.tx_hash = t.tx_hashleft join od on od.order_uid = t.order_uidwhere t.xs > 0 and t.ls > 0 and not t.partial_fill and t.lb / t.ls <= w.wq),e as (select q.order_uid, lower(to_hex(q.solver)) s,abs(((q.eb / q.es) - (o.xb / o.xs)) / (o.xb / o.xs)) errfrom q join o on q.order_uid = o.order_uidwhere q.es > 0 and q.eb > 0 and o.xb > 0),x as (select e.*, row_number() over (partition by order_uid order by err) rk from e),z as (select order_uid, count_if(err <= 1e-8) nz, sum(1 / power(greatest(err, 1e-12), 2)) sm from x where rk <= 5 group by 1),ours as (select x.order_uid,max(case when x.rk > 5 then 0e0 when z.nz > 0 then if(x.err <= 1e-8, 1e0 / z.nz, 0e0)else (1 / power(x.err, 2)) / z.sm end) share,max(x.err) errfrom x join z on z.order_uid = x.order_uidwhere x.s = 'a7842153fde380a864726d0e91f14f6ffab7d46c' group by 1),j as (select o.period, o.grp, o.settler, o.el, o.ws, ours.share, ours.err, (ours.order_uid is not null) quotedfrom o left join ours on ours.order_uid = o.order_uid