From cc463405fd361028c12511de51cad1c69bce7e18 Mon Sep 17 00:00:00 2001 From: harisang Date: Tue, 24 Dec 2024 16:35:15 +0200 Subject: [PATCH 1/3] add default min transfer amounts per network --- src/config.py | 15 +++++++++++++++ src/fetch/transfer_file.py | 4 ++-- src/utils/script_args.py | 7 ++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/config.py b/src/config.py index fba45090..acfee4b5 100644 --- a/src/config.py +++ b/src/config.py @@ -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: @@ -266,6 +268,8 @@ def from_network(network: Network) -> PaymentConfig: wrapped_eth_address = Address( "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" ) + min_native_token_transfer = 1000000000000000 + min_cow_transfer = 20000000000000000000 case Network.GNOSIS: payment_network = EthereumNetwork.GNOSIS @@ -280,6 +284,9 @@ def from_network(network: Network) -> PaymentConfig: wrapped_eth_address = Address( "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1" ) + min_native_token_transfer = 10000000000000000 + min_cow_transfer = 1000000000000000000 + case Network.ARBITRUM_ONE: payment_network = EthereumNetwork.ARBITRUM_ONE short_name = "arb1" @@ -293,6 +300,9 @@ def from_network(network: Network) -> PaymentConfig: wrapped_eth_address = Address( "0x82af49447d8a07e3bd95bd0d56f35241523fbab1" ) + min_native_token_transfer = 100000000000000 + min_cow_transfer = 1000000000000000000 + case Network.BASE: payment_network = EthereumNetwork.BASE_MAINNET short_name = "base" @@ -306,6 +316,9 @@ def from_network(network: Network) -> PaymentConfig: wrapped_eth_address = Address( "0x4200000000000000000000000000000000000006" ) + min_native_token_transfer = 100000000000000 + min_cow_transfer = 1000000000000000000 + case _: raise ValueError(f"No payment config set up for network {network}.") @@ -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, ) diff --git a/src/fetch/transfer_file.py b/src/fetch/transfer_file.py index 1f22e978..5a6b5b85 100644 --- a/src/fetch/transfer_file.py +++ b/src/fetch/transfer_file.py @@ -113,10 +113,10 @@ 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") + accounting_period = AccountingPeriod(args.start) orderbook = MultiInstanceDBFetcher( diff --git a/src/utils/script_args.py b/src/utils/script_args.py index 65b1802f..ab3f2a16 100644 --- a/src/utils/script_args.py +++ b/src/utils/script_args.py @@ -3,6 +3,7 @@ import argparse from datetime import date, timedelta from dataclasses import dataclass +from src.config import AccountingConfig @dataclass @@ -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 @@ -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", From 0514dba94003bc37632a29ee10a62d4909b58ea0 Mon Sep 17 00:00:00 2001 From: harisang Date: Tue, 24 Dec 2024 16:39:37 +0200 Subject: [PATCH 2/3] Add comment --- src/config.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/config.py b/src/config.py index acfee4b5..540f4f3e 100644 --- a/src/config.py +++ b/src/config.py @@ -268,8 +268,8 @@ def from_network(network: Network) -> PaymentConfig: wrapped_eth_address = Address( "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" ) - min_native_token_transfer = 1000000000000000 - min_cow_transfer = 20000000000000000000 + min_native_token_transfer = 1000000000000000 # 0.001 ETH + min_cow_transfer = 20000000000000000000 # 20 COW case Network.GNOSIS: payment_network = EthereumNetwork.GNOSIS @@ -284,8 +284,8 @@ def from_network(network: Network) -> PaymentConfig: wrapped_eth_address = Address( "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1" ) - min_native_token_transfer = 10000000000000000 - min_cow_transfer = 1000000000000000000 + min_native_token_transfer = 10000000000000000 # 0.01 xDAI + min_cow_transfer = 1000000000000000000 # 1 COW case Network.ARBITRUM_ONE: payment_network = EthereumNetwork.ARBITRUM_ONE @@ -300,8 +300,8 @@ def from_network(network: Network) -> PaymentConfig: wrapped_eth_address = Address( "0x82af49447d8a07e3bd95bd0d56f35241523fbab1" ) - min_native_token_transfer = 100000000000000 - min_cow_transfer = 1000000000000000000 + min_native_token_transfer = 100000000000000 # 0.0001 ETH + min_cow_transfer = 1000000000000000000 # 1 COW case Network.BASE: payment_network = EthereumNetwork.BASE_MAINNET @@ -316,8 +316,8 @@ def from_network(network: Network) -> PaymentConfig: wrapped_eth_address = Address( "0x4200000000000000000000000000000000000006" ) - min_native_token_transfer = 100000000000000 - min_cow_transfer = 1000000000000000000 + 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}.") From fe30553ff1afed9833de18c6815ff987943e9adb Mon Sep 17 00:00:00 2001 From: harisang Date: Tue, 24 Dec 2024 16:49:34 +0200 Subject: [PATCH 3/3] pass config as parameter --- src/fetch/transfer_file.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fetch/transfer_file.py b/src/fetch/transfer_file.py index 5a6b5b85..e2eda4bd 100644 --- a/src/fetch/transfer_file.py +++ b/src/fetch/transfer_file.py @@ -115,7 +115,9 @@ def main() -> None: config = AccountingConfig.from_network(Network(os.environ["NETWORK"])) - args = generic_script_init(description="Fetch Complete Reimbursement") + args = generic_script_init( + description="Fetch Complete Reimbursement", config=config + ) accounting_period = AccountingPeriod(args.start)