Skip to content

Commit

Permalink
Add runtime argument for minimum cow transfer threshold (#324)
Browse files Browse the repository at this point in the history
This PR adds the option to specify a minimum COW transfer amount,
effectively ignoring all transfers below that amount.

After merging this PR and before tagging a new release, I will do a PR
in the infrastructure repo to set up these arguments correctly.
  • Loading branch information
harisang authored Oct 31, 2023
1 parent 21510af commit b04d99e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
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:
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,
)

0 comments on commit b04d99e

Please sign in to comment.