Skip to content

Commit

Permalink
Add min transfer amounts per network (#474)
Browse files Browse the repository at this point in the history
This PR sets min transfer amounts (native token and COW) for all
networks, and removes the runtime arg for determining those as it has
been rarely (if ever) used in the past.
  • Loading branch information
harisang authored Jan 8, 2025
1 parent 2bbd634 commit a4e55bd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ 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-cow-atoms MIN_TRANSFER_AMOUNT_COW_ATOMS]

options:
-h, --help show this help message and exit
Expand All @@ -85,10 +84,6 @@ options:
Flag to indicate whether payout transfer file should be optimized (i.e. squash transfers having same receiver-token pair)
--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 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
--ignore-slippage IGNORE_SLIPPAGE
Ignore slippage computations
```
Expand Down
15 changes: 15 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ class PaymentConfig:
verification_docs_url: str
wrapped_native_token_address: ChecksumAddress
wrapped_eth_address: Address
min_native_token_transfer: int
min_cow_transfer: int

@staticmethod
def from_network(network: Network) -> PaymentConfig:
Expand Down Expand Up @@ -266,6 +268,8 @@ def from_network(network: Network) -> PaymentConfig:
wrapped_eth_address = Address(
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
)
min_native_token_transfer = 10**15 # 0.001 ETH
min_cow_transfer = 10 * 10**18 # 10 COW

case Network.GNOSIS:
payment_network = EthereumNetwork.GNOSIS
Expand All @@ -280,6 +284,9 @@ def from_network(network: Network) -> PaymentConfig:
wrapped_eth_address = Address(
"0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1"
)
min_native_token_transfer = 10**16 # 0.01 xDAI
min_cow_transfer = 10**18 # 1 COW

case Network.ARBITRUM_ONE:
payment_network = EthereumNetwork.ARBITRUM_ONE
short_name = "arb1"
Expand All @@ -293,6 +300,9 @@ def from_network(network: Network) -> PaymentConfig:
wrapped_eth_address = Address(
"0x82af49447d8a07e3bd95bd0d56f35241523fbab1"
)
min_native_token_transfer = 10**14 # 0.0001 ETH
min_cow_transfer = 10**18 # 1 COW

case Network.BASE:
payment_network = EthereumNetwork.BASE_MAINNET
short_name = "base"
Expand All @@ -306,6 +316,9 @@ def from_network(network: Network) -> PaymentConfig:
wrapped_eth_address = Address(
"0x4200000000000000000000000000000000000006"
)
min_native_token_transfer = 10**14 # 0.0001 ETH
min_cow_transfer = 10**18 # 1 COW

case _:
raise ValueError(f"No payment config set up for network {network}.")

Expand All @@ -321,6 +334,8 @@ def from_network(network: Network) -> PaymentConfig:
verification_docs_url=docs_url,
wrapped_native_token_address=wrapped_native_token_address,
wrapped_eth_address=wrapped_eth_address,
min_native_token_transfer=min_native_token_transfer,
min_cow_transfer=min_cow_transfer,
)


Expand Down
4 changes: 2 additions & 2 deletions src/fetch/transfer_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ def main() -> None:
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 >= config.payment_config.min_native_token_transfer:
payout_transfers.append(tr)
else:
if tr.amount_wei >= args.min_transfer_amount_cow_atoms:
if tr.amount_wei >= config.payment_config.min_cow_transfer:
payout_transfers.append(tr)

if args.post_tx:
Expand Down
16 changes: 0 additions & 16 deletions src/utils/script_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class ScriptArgs:
start: str
post_tx: bool
dry_run: bool
min_transfer_amount_wei: int
min_transfer_amount_cow_atoms: int
ignore_slippage: bool


Expand Down Expand Up @@ -43,18 +41,6 @@ def generic_script_init(description: str) -> ScriptArgs:
"Only relevant in combination with --post-tx"
"Primarily intended for deployment in staging environment.",
)
parser.add_argument(
"--min-transfer-amount-wei",
type=int,
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=20000000000000000000,
)
parser.add_argument(
"--ignore-slippage",
action="store_true",
Expand All @@ -65,7 +51,5 @@ def generic_script_init(description: str) -> ScriptArgs:
start=args.start,
post_tx=args.post_tx,
dry_run=args.dry_run,
min_transfer_amount_wei=args.min_transfer_amount_wei,
min_transfer_amount_cow_atoms=args.min_transfer_amount_cow_atoms,
ignore_slippage=args.ignore_slippage,
)

0 comments on commit a4e55bd

Please sign in to comment.