From 4298ad89bd6b2a4950bbc2565d2f91f8d5371af6 Mon Sep 17 00:00:00 2001 From: harisang Date: Tue, 21 Jan 2025 04:14:19 +0200 Subject: [PATCH] fix solver rewards function --- src/fetch/payouts.py | 8 +++++++- src/pg_client.py | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index f538a23d..6a438be0 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -22,6 +22,7 @@ from src.models.token import Token from src.models.transfer import Transfer from src.pg_client import MultiInstanceDBFetcher +from src.fetch.orderbook import OrderbookFetcher from src.utils.print_store import Category log = set_log(__name__) @@ -503,13 +504,18 @@ def construct_payouts( ) -> list[Transfer]: """Workflow of solver reward payout logic post-CIP27""" # pylint: disable-msg=too-many-locals - + analytics_data_fetcher = OrderbookFetcher() + prod_prices_corrections_str, barn_prices_corrections_str = ( + analytics_data_fetcher.fetch_auction_prices_corrections(config) + ) quote_rewards_df = orderbook.get_quote_rewards(dune.start_block, dune.end_block) batch_rewards_df = orderbook.get_solver_rewards( dune.start_block, dune.end_block, config.reward_config.batch_reward_cap_upper, config.reward_config.batch_reward_cap_lower, + prod_prices_corrections_str, + barn_prices_corrections_str, ) partner_fees_df = batch_rewards_df[["partner_list", "partner_fee_eth"]] batch_rewards_df = batch_rewards_df.drop( diff --git a/src/pg_client.py b/src/pg_client.py index 2f32f91b..d6f288ef 100644 --- a/src/pg_client.py +++ b/src/pg_client.py @@ -48,6 +48,8 @@ def get_solver_rewards( end_block: str, reward_cap_upper: int, reward_cap_lower: int, + prod_prices_corrections_str: str, + barn_prices_corrections_str: str, ) -> DataFrame: """ Returns aggregated solver rewards for accounting period defined by block range @@ -59,6 +61,7 @@ def get_solver_rewards( .replace("{{EPSILON_LOWER}}", str(reward_cap_lower)) .replace("{{EPSILON_UPPER}}", str(reward_cap_upper)) .replace("{{results}}", "solver_rewards_script_table") + .replace("{{auction_prices_corrections}}", prod_prices_corrections_str) ) batch_reward_query_barn = ( open_query("orderbook/barn_batch_rewards.sql") @@ -67,6 +70,7 @@ def get_solver_rewards( .replace("{{EPSILON_LOWER}}", str(reward_cap_lower)) .replace("{{EPSILON_UPPER}}", str(reward_cap_upper)) .replace("{{results}}", "solver_rewards_script_table") + .replace("{{auction_prices_corrections}}", barn_prices_corrections_str) ) results = []