From 9dd446f6e3aa4cbfc557a7a89ebf43720fde0ec4 Mon Sep 17 00:00:00 2001 From: Felix Henneke Date: Fri, 10 Jan 2025 16:03:32 +0100 Subject: [PATCH] Fix dashboard url (#487) This PR fixes the dashboard url for verifying payments. It now takes into account the network and network specific parameters. A follow up PR should fix parameters for unusual slippage. At some point the function `dashboard_url` should be moved to some other file. It is not related to creating transfer files. The old place with the accounting period does not work though, as the url does depend on additional parameters. This closes #473. --- src/fetch/transfer_file.py | 35 ++++++++++++++++++++++++++++----- src/models/accounting_period.py | 14 ------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/fetch/transfer_file.py b/src/fetch/transfer_file.py index 9ed93f28..bce7cc40 100644 --- a/src/fetch/transfer_file.py +++ b/src/fetch/transfer_file.py @@ -7,6 +7,8 @@ import os import ssl from dataclasses import asdict +from fractions import Fraction +import urllib.parse import certifi from dune_client.client import DuneClient @@ -30,6 +32,33 @@ log = set_log(__name__) +def dashboard_url(period: AccountingPeriod, config: AccountingConfig) -> str: + """Returns a link to the solver accounting dashboard.s""" + base = "https://dune.com/cowprotocol/" + slug = "cow-solver-rewards" + # reward parameters + decimals_native_token = 18 # this could be fetched from a node + decimals_cow = 18 # this could be fetched from a node + upper_cap = Fraction( + config.reward_config.batch_reward_cap_upper, 10**decimals_native_token + ) + lower_cap = -Fraction( + config.reward_config.batch_reward_cap_lower, 10**decimals_native_token + ) + quote_reward = Fraction(config.reward_config.quote_reward_cow, 10**decimals_cow) + quote_cap_native_token = Fraction( + config.reward_config.quote_reward_cap_native, 10**decimals_native_token + ) + query = ( + f"?start_time={period.start}&end_time={period.end}" + f"&blockchain={config.dune_config.dune_blockchain}" + f"&upper_cap={upper_cap:g}&lower_cap={lower_cap:g}" + f""e_reward={quote_reward:g}" + f""e_cap_native_token={quote_cap_native_token:g}" + ) + return base + urllib.parse.quote_plus(slug + query, safe="=&?") + + def manual_propose( transfers: list[Transfer], period: AccountingPeriod, @@ -39,10 +68,6 @@ def manual_propose( Entry point to manual creation of rewards payout transaction. This function generates the CSV transfer file to be pasted into the COW Safe app """ - print( - f"Please double check the batches with unusual slippage: " - f"{period.unusual_slippage_url()}" - ) csv_transfers = [asdict(CSVTransfer.from_transfer(t)) for t in transfers] FileIO(config.io_config.csv_output_dir).write_csv( csv_transfers, f"transfers-{config.io_config.network.value}-{period}.csv" @@ -134,7 +159,7 @@ def main() -> None: ) log_saver.print( - f"The data aggregated can be visualized at\n{accounting_period.dashboard_url()}", + f"The data aggregated can be visualized at\n{dashboard_url(accounting_period, config)}", category=Category.GENERAL, ) diff --git a/src/models/accounting_period.py b/src/models/accounting_period.py index 6c36ed21..e75beb8c 100644 --- a/src/models/accounting_period.py +++ b/src/models/accounting_period.py @@ -4,7 +4,6 @@ from __future__ import annotations -import urllib.parse from datetime import datetime, timedelta from dune_client.types import QueryParameter @@ -36,16 +35,3 @@ def as_query_params(self) -> list[QueryParameter]: QueryParameter.date_type("start_time", self.start), QueryParameter.date_type("end_time", self.end), ] - - def dashboard_url(self) -> str: - """Constructs Solver Accounting Dashboard URL for Period""" - base = "https://dune.com/cowprotocol/" - slug = "cow-solver-rewards" - query = f"?start_time={self.start}&end_time={self.end}" - return base + urllib.parse.quote_plus(slug + query, safe="=&?") - - def unusual_slippage_url(self) -> str: - """Returns a link to unusual slippage query for period""" - base = "https://dune.com/queries/2332678" - query = f"?start_time={self.start}&end_time={self.end}" - return base + urllib.parse.quote_plus(query, safe="=&?")