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 default min transfer amounts per network #474

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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 = 1000000000000000 # 0.001 ETH
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer 10**15 or 1_000_000_000_000_000 over the bare integer notation, here and below.

min_cow_transfer = 20000000000000000000 # 20 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 = 10000000000000000 # 0.01 xDAI
min_cow_transfer = 1000000000000000000 # 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 = 100000000000000 # 0.0001 ETH
min_cow_transfer = 1000000000000000000 # 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 = 100000000000000 # 0.0001 ETH
min_cow_transfer = 1000000000000000000 # 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
6 changes: 4 additions & 2 deletions src/fetch/transfer_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ def auto_propose(
def main() -> None:
"""Generate transfers for an accounting period"""

args = generic_script_init(description="Fetch Complete Reimbursement")

config = AccountingConfig.from_network(Network(os.environ["NETWORK"]))

args = generic_script_init(
description="Fetch Complete Reimbursement", config=config
)

Comment on lines -116 to +121
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the dependency should be the other way around: the config should be set up with a dependency on command line arguments. The code would then only use the config.

A similar approach could be used for all other command line arguments.

For the change to minimal amounts in this PR, it would also be viable to remove the option to set them via the command line. (Or first ignore the command line option and later remove it, to not break how the script is currently being called.)

accounting_period = AccountingPeriod(args.start)

orderbook = MultiInstanceDBFetcher(
Expand Down
7 changes: 4 additions & 3 deletions src/utils/script_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
from datetime import date, timedelta
from dataclasses import dataclass
from src.config import AccountingConfig


@dataclass
Expand All @@ -17,7 +18,7 @@ class ScriptArgs:
ignore_slippage: bool


def generic_script_init(description: str) -> ScriptArgs:
def generic_script_init(description: str, config: AccountingConfig) -> ScriptArgs:
"""
1. parses parses command line arguments,
2. establishes dune connection
Expand Down Expand Up @@ -47,13 +48,13 @@ def generic_script_init(description: str) -> ScriptArgs:
"--min-transfer-amount-wei",
type=int,
help="Ignore ETH transfers with amount less than this",
default=1000000000000000,
default=config.payment_config.min_native_token_transfer,
)
parser.add_argument(
"--min-transfer-amount-cow-atoms",
type=int,
help="Ignore COW transfers with amount less than this",
default=20000000000000000000,
default=config.payment_config.min_cow_transfer,
)
parser.add_argument(
"--ignore-slippage",
Expand Down
Loading