Skip to content

Commit

Permalink
Merge branch 'main' into improve_slack_log_message
Browse files Browse the repository at this point in the history
  • Loading branch information
harisang authored Jan 10, 2025
2 parents 35bf37e + 9dd446f commit a838a4d
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 @@ -135,7 +160,7 @@ def main() -> None:
)

log_saver.print(
f"The data aggregated can be visualized at\n{accounting_period.dashboard_url()}\n",
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 a838a4d

Please sign in to comment.