Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new service fee query #433

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/fetch/dune.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ 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("start_time", self.period.start),
QueryParameter.date_type("end_time", self.period.end),
],
)
)
15 changes: 4 additions & 11 deletions src/fetch/payouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -437,13 +437,6 @@ def construct_payout_dataframe(
config.reward_config.reward_token_address.address
)

# 7. Missing service fee is treated as new solver
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed since the meaning of missing entries changed, right? Before it was an indication of missing data for new solvers. Now it could also just be a solver who is not in the COW bonding pool.

Not important for today's payouts, but it might be useful to reactivate a check restricted to missing service fee status for solvers in the COW bonding pool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed, the previous query was supposed to return an entry for every single active (vouched) solver, while this one only cares about CoW DAO bonding pool solvers. So if we want to bring back the check, we need to restrict it to the CoW DAO solvers

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
Expand Down Expand Up @@ -518,10 +511,10 @@ def construct_payouts(

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_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
if ignore_slippage_flag or (not config.buffer_accounting_config.include_slippage):
Expand Down
2 changes: 1 addition & 1 deletion src/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading