From cc4d80351e00097acf57d699b35dc1bc9545fd0d Mon Sep 17 00:00:00 2001 From: harisang Date: Wed, 25 Oct 2023 12:27:07 +0300 Subject: [PATCH 1/3] add runtime arg for minimum cow transfer threshold --- README.md | 7 ++++--- src/fetch/payouts.py | 2 ++ src/fetch/transfer_file.py | 17 ++++++++++------- src/utils/script_args.py | 10 +++++++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 44554ca0..f9dce3f4 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ looking at the script help menu can help provide a list of options! $ python -m src.fetch.transfer_file --help usage: Fetch Complete Reimbursement [-h] [--start START] [--post-tx POST_TX] [--consolidate-transfers CONSOLIDATE_TRANSFERS] [--dry-run DRY_RUN] - [--min-transfer-amount-wei MIN_TRANSFER_AMOUNT_WEI] + [--min-transfer-amount-wei MIN_TRANSFER_AMOUNT_WEI] [--min-transfer-amount-cow-atoms MIN_TRANSFER_AMOUNT_COW_ATOMS] options: -h, --help show this help message and exit @@ -86,8 +86,9 @@ options: --dry-run DRY_RUN Flag indicating whether script should not post alerts or transactions. Only relevant in combination with --post-tx TruePrimarily intended for deployment in staging environment. --min-transfer-amount-wei MIN_TRANSFER_AMOUNT_WEI - Ignore transfers with amount less than this - + Ignore ETH transfers with amount less than this + --min-transfer-amount-cow-atoms MIN_TRANSFER_AMOUNT_COW_ATOMS + Ignore COW transfers with amount less than this ``` The solver reimbursements are executed each Tuesday with the accounting period of the last 7 days. diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index 45998382..2c42518f 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -264,6 +264,8 @@ def extend_payment_df(pdf: DataFrame, converter: TokenConversion) -> DataFrame: """ # Note that this can be negative! pdf["reward_eth"] = pdf["payment_eth"] - pdf["execution_cost_eth"] + # num = pdf._get_numeric_data() + # num[num < 0] = 0 pdf["reward_cow"] = pdf["reward_eth"].apply(converter.eth_to_token) secondary_allocation = max(PERIOD_BUDGET_COW - pdf["reward_cow"].sum(), 0) diff --git a/src/fetch/transfer_file.py b/src/fetch/transfer_file.py index d2407226..6088733a 100644 --- a/src/fetch/transfer_file.py +++ b/src/fetch/transfer_file.py @@ -108,18 +108,21 @@ def auto_propose( category=Category.GENERAL, ) - payout_transfers = construct_payouts( + payout_transfers_temp = construct_payouts( args.dune, orderbook=MultiInstanceDBFetcher( [os.environ["PROD_DB_URL"], os.environ["BARN_DB_URL"]] ), ) - payout_transfers = list( - filter( - lambda payout: payout.amount_wei > args.min_transfer_amount_wei, - payout_transfers, - ) - ) + payout_transfers = [] + for tr in payout_transfers_temp: + if tr.token is None: + if tr.amount_wei > args.min_transfer_amount_wei: + payout_transfers.append(tr) + else: + if tr.amount_wei > args.min_transfer_amount_cow_atoms: + payout_transfers.append(tr) + if args.consolidate_transfers: payout_transfers = Transfer.consolidate(payout_transfers) diff --git a/src/utils/script_args.py b/src/utils/script_args.py index 91461ad6..2f1ea58f 100644 --- a/src/utils/script_args.py +++ b/src/utils/script_args.py @@ -19,6 +19,7 @@ class ScriptArgs: dry_run: bool consolidate_transfers: bool min_transfer_amount_wei: int + min_transfer_amount_cow_atoms: int def generic_script_init(description: str) -> ScriptArgs: @@ -60,9 +61,15 @@ def generic_script_init(description: str) -> ScriptArgs: parser.add_argument( "--min-transfer-amount-wei", type=int, - help="Ignore transfers with amount less than this", + help="Ignore ETH transfers with amount less than this", default=1000000000000000, ) + parser.add_argument( + "--min-transfer-amount-cow-atoms", + type=int, + help="Ignore COW transfers with amount less than this", + default=10, + ) args = parser.parse_args() return ScriptArgs( dune=DuneFetcher( @@ -73,4 +80,5 @@ def generic_script_init(description: str) -> ScriptArgs: dry_run=args.dry_run, consolidate_transfers=args.consolidate_transfers, min_transfer_amount_wei=args.min_transfer_amount_wei, + min_transfer_amount_cow_atoms=args.min_transfer_amount_cow_atoms, ) From 129ce06f723bad63a4480303ada55271dceaaf07 Mon Sep 17 00:00:00 2001 From: harisang Date: Wed, 25 Oct 2023 12:31:30 +0300 Subject: [PATCH 2/3] clean up --- src/fetch/payouts.py | 2 -- src/utils/script_args.py | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index 2c42518f..45998382 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -264,8 +264,6 @@ def extend_payment_df(pdf: DataFrame, converter: TokenConversion) -> DataFrame: """ # Note that this can be negative! pdf["reward_eth"] = pdf["payment_eth"] - pdf["execution_cost_eth"] - # num = pdf._get_numeric_data() - # num[num < 0] = 0 pdf["reward_cow"] = pdf["reward_eth"].apply(converter.eth_to_token) secondary_allocation = max(PERIOD_BUDGET_COW - pdf["reward_cow"].sum(), 0) diff --git a/src/utils/script_args.py b/src/utils/script_args.py index 2f1ea58f..eb856b54 100644 --- a/src/utils/script_args.py +++ b/src/utils/script_args.py @@ -57,7 +57,6 @@ def generic_script_init(description: str) -> ScriptArgs: "Primarily intended for deployment in staging environment.", default=False, ) - # TODO: this should be per token (like list[tuple[Token,minAmount]]) parser.add_argument( "--min-transfer-amount-wei", type=int, @@ -68,7 +67,7 @@ def generic_script_init(description: str) -> ScriptArgs: "--min-transfer-amount-cow-atoms", type=int, help="Ignore COW transfers with amount less than this", - default=10, + default=100000000000000000000, ) args = parser.parse_args() return ScriptArgs( From 15d3d18288f6d9422404f62b5fe5fab5781d909f Mon Sep 17 00:00:00 2001 From: harisang Date: Mon, 30 Oct 2023 20:35:19 +0200 Subject: [PATCH 3/3] replaced greater with greater or equal --- src/fetch/transfer_file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fetch/transfer_file.py b/src/fetch/transfer_file.py index 6088733a..b4d5ebb8 100644 --- a/src/fetch/transfer_file.py +++ b/src/fetch/transfer_file.py @@ -117,10 +117,10 @@ def auto_propose( payout_transfers = [] for tr in payout_transfers_temp: if tr.token is None: - if tr.amount_wei > args.min_transfer_amount_wei: + if tr.amount_wei >= args.min_transfer_amount_wei: payout_transfers.append(tr) else: - if tr.amount_wei > args.min_transfer_amount_cow_atoms: + if tr.amount_wei >= args.min_transfer_amount_cow_atoms: payout_transfers.append(tr) if args.consolidate_transfers: