From faf61b8c32d9223678f0c46e374a46b817c9285e Mon Sep 17 00:00:00 2001 From: harisang Date: Mon, 18 Nov 2024 22:10:11 +0200 Subject: [PATCH 1/5] use new service fee query --- src/fetch/dune.py | 4 +++- src/fetch/payouts.py | 9 ++++----- src/queries.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/fetch/dune.py b/src/fetch/dune.py index d54f1ed1..d7dd395f 100644 --- a/src/fetch/dune.py +++ b/src/fetch/dune.py @@ -118,6 +118,8 @@ def get_service_fee_status(self) -> list[DuneRecord]: return self._get_query_results( query=self._parameterized_query( query_data=QUERIES["SERVICE_FEE_STATUS"], - params=[], + params=[ + QueryParameter.date_type("time", self.period.end), + ], ) ) diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index 1bc79912..30805fbf 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -516,11 +516,10 @@ def construct_payouts( ).fillna(0) service_fee_df = pandas.DataFrame(dune.get_service_fee_status()) - service_fee_df["service_fee"] = [ - (datetime.strptime(time_string, "%Y-%m-%d %H:%M:%S.%f %Z") <= dune.period.start) - * config.reward_config.service_fee_factor - for time_string in service_fee_df["expires"] - ] + service_fee_df["service_fee"] = ( + service_fee_df["service_fee"] * config.reward_config.service_fee_factor + ) + reward_target_df = pandas.DataFrame(dune.get_vouches()) # construct slippage df if ignore_slippage_flag or (not config.buffer_accounting_config.include_slippage): diff --git a/src/queries.py b/src/queries.py index 3dcd94bf..fd627e78 100644 --- a/src/queries.py +++ b/src/queries.py @@ -40,7 +40,7 @@ def with_params(self, params: list[QueryParameter]) -> QueryBase: ), "SERVICE_FEE_STATUS": QueryData( name="CIP-48 Service fee status", - q_id=4017925, + q_id=4298142, ), "PERIOD_SLIPPAGE": QueryData( name="Solver Slippage for Period", From 4d239d7f2864c680b26b8a2640035a343d18c983 Mon Sep 17 00:00:00 2001 From: harisang Date: Mon, 18 Nov 2024 23:05:44 +0200 Subject: [PATCH 2/5] remove unused import --- src/fetch/payouts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index 30805fbf..25d86766 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -5,7 +5,7 @@ import logging import math from dataclasses import dataclass -from datetime import datetime, timedelta +from datetime import timedelta from fractions import Fraction from typing import Callable From 8d440370bb8720040b37dbda68e4cdef503be499 Mon Sep 17 00:00:00 2001 From: harisang Date: Mon, 18 Nov 2024 23:19:59 +0200 Subject: [PATCH 3/5] bug fix --- src/fetch/payouts.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index 25d86766..97a1c163 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -516,9 +516,10 @@ def construct_payouts( ).fillna(0) service_fee_df = pandas.DataFrame(dune.get_service_fee_status()) - service_fee_df["service_fee"] = ( - service_fee_df["service_fee"] * config.reward_config.service_fee_factor - ) + service_fee_df["service_fee"] = [ + service_fee_flag * config.reward_config.service_fee_factor + for service_fee_flag in service_fee_df["service_fee"] + ] reward_target_df = pandas.DataFrame(dune.get_vouches()) # construct slippage df From 3f62142661b9f522ba29a500750f350851ef740f Mon Sep 17 00:00:00 2001 From: harisang Date: Mon, 18 Nov 2024 23:37:18 +0200 Subject: [PATCH 4/5] remove warning log for solvers without explicit service fee --- src/fetch/payouts.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index 97a1c163..649d08ad 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -436,13 +436,6 @@ def construct_payout_dataframe( config.reward_config.reward_token_address.address ) - # 7. Missing service fee is treated as new solver - if any(merged_df["service_fee"].isna()): - missing_solvers = merged_df["solver"].loc[merged_df["service_fee"].isna()] - logging.warning( - f"Solvers {missing_solvers} without service fee info. Using 0%. " - f"Check service fee query." - ) merged_df["service_fee"] = merged_df["service_fee"].fillna(Fraction(0, 1)) # type: ignore return merged_df From 41afb1e0125159b7520e09a0e8c3c13d15bf6ab4 Mon Sep 17 00:00:00 2001 From: harisang Date: Thu, 21 Nov 2024 00:50:53 +0200 Subject: [PATCH 5/5] edit parameters of new servie fee query --- src/fetch/dune.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fetch/dune.py b/src/fetch/dune.py index d7dd395f..507f37ff 100644 --- a/src/fetch/dune.py +++ b/src/fetch/dune.py @@ -119,7 +119,8 @@ def get_service_fee_status(self) -> list[DuneRecord]: query=self._parameterized_query( query_data=QUERIES["SERVICE_FEE_STATUS"], params=[ - QueryParameter.date_type("time", self.period.end), + QueryParameter.date_type("start_time", self.period.start), + QueryParameter.date_type("end_time", self.period.end), ], ) )