Skip to content

Commit

Permalink
Merge branch 'main' into restructure_price_fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
harisang authored Nov 8, 2024
2 parents 13c6a3e + a4e9be6 commit e3a0ed2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 36 deletions.
15 changes: 3 additions & 12 deletions src/fetch/payouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,19 +399,10 @@ def construct_payout_dataframe(
normalize_address_field(service_fee_df, join_column)

# 3. Merge the three dataframes (joining on solver)

reward_target_reduced_df_columns = [
x for x in list(reward_target_df.columns) if x != "solver_name"
]
reward_target_reduced_df = reward_target_df[reward_target_reduced_df_columns]
service_fee_reduced_df_columns = [
x for x in list(service_fee_df.columns) if x != "solver_name"
]
service_fee_reduced_df = service_fee_df[service_fee_reduced_df_columns]
merged_df = (
payment_df.merge(slippage_df, on=join_column, how="left")
.merge(reward_target_reduced_df, on=join_column, how="left")
.merge(service_fee_reduced_df, on=join_column, how="left")
.merge(reward_target_df, on=join_column, how="left")
.merge(service_fee_df, on=join_column, how="left")
)

# 4. Add slippage from fees to slippage
Expand Down Expand Up @@ -461,7 +452,7 @@ def construct_partner_fee_payments(


def construct_payouts(
dune: DuneFetcher, ignore_slippage_flag: bool, orderbook: MultiInstanceDBFetcher
orderbook: MultiInstanceDBFetcher, dune: DuneFetcher, ignore_slippage_flag: bool
) -> list[Transfer]:
"""Workflow of solver reward payout logic post-CIP27"""
# pylint: disable-msg=too-many-locals
Expand Down
21 changes: 15 additions & 6 deletions src/fetch/transfer_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from dataclasses import asdict

import certifi
from dune_client.client import DuneClient
from dune_client.file.interface import FileIO
from eth_typing import URI
from gnosis.eth.ethereum_client import EthereumClient
Expand All @@ -23,6 +24,7 @@
FILE_OUT_DIR,
DOCS_URL,
)
from src.fetch.dune import DuneFetcher
from src.fetch.payouts import construct_payouts
from src.models.accounting_period import AccountingPeriod
from src.models.transfer import Transfer, CSVTransfer
Expand Down Expand Up @@ -103,19 +105,26 @@ def auto_propose(

if __name__ == "__main__":
args = generic_script_init(description="Fetch Complete Reimbursement")
dune = args.dune

orderbook = MultiInstanceDBFetcher(
[os.environ["PROD_DB_URL"], os.environ["BARN_DB_URL"]]
)
dune = DuneFetcher(
dune=DuneClient(os.environ["DUNE_API_KEY"]),
period=AccountingPeriod(args.start),
)

dune.log_saver.print(
f"The data aggregated can be visualized at\n{dune.period.dashboard_url()}",
category=Category.GENERAL,
)

payout_transfers_temp = construct_payouts(
args.dune,
args.ignore_slippage,
orderbook=MultiInstanceDBFetcher(
[os.environ["PROD_DB_URL"], os.environ["BARN_DB_URL"]]
),
orderbook=orderbook,
dune=dune,
ignore_slippage_flag=args.ignore_slippage,
)

payout_transfers = []
for tr in payout_transfers_temp:
if tr.token is None:
Expand Down
24 changes: 6 additions & 18 deletions src/utils/script_args.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
"""Common method for initializing setup for scripts"""

import argparse
import os
from datetime import date, timedelta
from dataclasses import dataclass

from dune_client.client import DuneClient

from src.fetch.dune import DuneFetcher
from src.models.accounting_period import AccountingPeriod


@dataclass
class ScriptArgs:
"""A collection of common script arguments relevant to this project"""

dune: DuneFetcher
start: str
post_tx: bool
dry_run: bool
min_transfer_amount_wei: int
Expand All @@ -38,18 +32,16 @@ def generic_script_init(description: str) -> ScriptArgs:
)
parser.add_argument(
"--post-tx",
type=bool,
action="store_true",
help="Flag indicating whether multisend should be posted to safe "
"(requires valid env var `PROPOSER_PK`)",
default=False,
)
parser.add_argument(
"--dry-run",
type=bool,
action="store_true",
help="Flag indicating whether script should not post alerts or transactions. "
"Only relevant in combination with --post-tx True"
"Only relevant in combination with --post-tx"
"Primarily intended for deployment in staging environment.",
default=False,
)
parser.add_argument(
"--min-transfer-amount-wei",
Expand All @@ -65,16 +57,12 @@ def generic_script_init(description: str) -> ScriptArgs:
)
parser.add_argument(
"--ignore-slippage",
type=bool,
action="store_true",
help="Flag for ignoring slippage computations",
default=False,
)
args = parser.parse_args()
return ScriptArgs(
dune=DuneFetcher(
dune=DuneClient(os.environ["DUNE_API_KEY"]),
period=AccountingPeriod(args.start),
),
start=args.start,
post_tx=args.post_tx,
dry_run=args.dry_run,
min_transfer_amount_wei=args.min_transfer_amount_wei,
Expand Down

0 comments on commit e3a0ed2

Please sign in to comment.