Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add runtime argument for minimum cow transfer threshold #324

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
17 changes: 10 additions & 7 deletions src/fetch/transfer_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads a bit strange in that it does not refer to wei but is called amount_wei.
But renaming to amount or amount_atoms looks a bit overkill for the change in this PR.

payout_transfers.append(tr)

if args.consolidate_transfers:
payout_transfers = Transfer.consolidate(payout_transfers)

Expand Down
11 changes: 9 additions & 2 deletions src/utils/script_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -56,13 +57,18 @@ 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,
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=100000000000000000000,
)
args = parser.parse_args()
return ScriptArgs(
dune=DuneFetcher(
Expand All @@ -73,4 +79,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,
)
Loading