Skip to content

Commit

Permalink
Fix dashboard url (#487)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fhenneke authored Jan 10, 2025
1 parent a4e55bd commit 9dd446f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
35 changes: 30 additions & 5 deletions src/fetch/transfer_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"&quote_reward={quote_reward:g}"
f"&quote_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,
Expand All @@ -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"
Expand Down Expand Up @@ -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,
)

Expand Down
14 changes: 0 additions & 14 deletions src/models/accounting_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from __future__ import annotations

import urllib.parse
from datetime import datetime, timedelta

from dune_client.types import QueryParameter
Expand Down Expand Up @@ -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="=&?")

0 comments on commit 9dd446f

Please sign in to comment.