From 7215ba756eb239b705fff69c151e925962ecd0b7 Mon Sep 17 00:00:00 2001 From: Haris Angelidakis <64154020+harisang@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:47:10 +0300 Subject: [PATCH] Disable participation rewards after July 23, 2024 (#376) This PR enforces CIP-48 by removing participation rewards starting with the accounting week of July 23 - July 30. --- queries/orderbook/barn_batch_rewards.sql | 16 ++++++++++++++-- queries/orderbook/prod_batch_rewards.sql | 16 ++++++++++++++-- src/fetch/payouts.py | 5 +++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/queries/orderbook/barn_batch_rewards.sql b/queries/orderbook/barn_batch_rewards.sql index b234e9b8..b20218f9 100644 --- a/queries/orderbook/barn_batch_rewards.sql +++ b/queries/orderbook/barn_batch_rewards.sql @@ -409,16 +409,28 @@ reward_per_auction as ( participation_data as ( SELECT tx_hash, + block_deadline, unnest(participating_solvers) as participant FROM reward_per_auction ), +participation_data_intermediate as ( + SELECT + tx_hash, + CASE + WHEN block_deadline <= 20365510 THEN 1 -- final block deadline of accounting week of July 16 - July 23, 2024 + ELSE 0 + END as count_participation, + participant + FROM + participation_data +), participation_counts as ( SELECT participant as solver, - count(*) as num_participating_batches + sum(count_participation) as num_participating_batches FROM - participation_data + participation_data_intermediate GROUP BY participant ), diff --git a/queries/orderbook/prod_batch_rewards.sql b/queries/orderbook/prod_batch_rewards.sql index b234e9b8..b20218f9 100644 --- a/queries/orderbook/prod_batch_rewards.sql +++ b/queries/orderbook/prod_batch_rewards.sql @@ -409,16 +409,28 @@ reward_per_auction as ( participation_data as ( SELECT tx_hash, + block_deadline, unnest(participating_solvers) as participant FROM reward_per_auction ), +participation_data_intermediate as ( + SELECT + tx_hash, + CASE + WHEN block_deadline <= 20365510 THEN 1 -- final block deadline of accounting week of July 16 - July 23, 2024 + ELSE 0 + END as count_participation, + participant + FROM + participation_data +), participation_counts as ( SELECT participant as solver, - count(*) as num_participating_batches + sum(count_participation) as num_participating_batches FROM - participation_data + participation_data_intermediate GROUP BY participant ), diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index a9d57bf3..79f0c953 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -282,6 +282,11 @@ def extend_payment_df(pdf: DataFrame, converter: TokenConversion) -> DataFrame: 0, ) participation_total = pdf["num_participating_batches"].sum() + if participation_total == 0: + # Due to CIP-48 we will stop counting participation. This workaround avoids + # division by zero as the num_participation_batches is set to zero for all + # solvers after CIP-48. + participation_total = 1 pdf["secondary_reward_cow"] = ( secondary_allocation * pdf["num_participating_batches"] / participation_total )