-
Notifications
You must be signed in to change notification settings - Fork 5
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
[Multi-Chain] Add config file #412
Conversation
since tests need this variable
this should be removed later. we should - add special handling of secrets, or - check this variable at the start of the script
remove token_list again
@fhenneke can you rebase once the easy PRs are merged, and in case it is ready for review, let's also remove the "draft" label |
# Conflicts: # tests/unit/test_models.py
The things which can already be discussed are:
|
this addresses review comments - uses an enum instead of a string for better checking of network values - move initialization of configs into individual classes: use from_network and from_env to initialize classes
mostly by adding comments
This PR slightly restructures the price fetching for converting token amount for rewards. - Instead of having functions for converting to and from ETH (`eth_in_token`, `token_in_eth`) we just provide an exchange rate for conversion between two tokens (`exchange_rate_atoms`). This will make it easier to add conversion between COW and the native token of the chain, as well as between XDAI and ETH. - Instead of using token ids as argument, the main function accepts addresses. This is mostly to avoid leaking the implementation of the price fetching (token id on coin paprika) into the rest of the code. It also avoids a circular dependency in making the reward token part of the configuration in #412. The `TokenId` abstraction still feels a bit stange as there is some overlap with `Token` due to decimals. Supporting USDC seems a bit artificial since that is only used for testing and checking that decimals are correctly accounted for. Tests for price fetching were adapted accordingly. Transfers for the accounting week starting on 2024-10-29 only differ on the level of floating point precision. --------- Co-authored-by: Haris Angelidakis <[email protected]>
# Conflicts: # src/fetch/payouts.py
# Conflicts: # src/fetch/payouts.py # tests/unit/test_payouts.py
src/config.py
Outdated
"""Initialize node config for a given network.""" | ||
# Found this exposed infura key on https://rpc.info/ | ||
infura_key = os.environ.get("INFURA_KEY", "9aa3d95b3bc440fa88ea12eaa4456161") | ||
node_url = f"https://{network}.infura.io/v3/{infura_key}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR #430 simplifies a bit this part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new environment variable is used now.
src/config.py
Outdated
safe_url = ( | ||
f"https://app.safe.global/{short_name}:{payment_safe_address}" | ||
) | ||
airdrop_url = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this? Seems like an overkill
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove it, as it also did not work for me when I tried it some time ago.
Generally, I think we should provide instructions as part of error messages and logging as much as possible.
# Conflicts: # src/constants.py # src/fetch/transfer_file.py
# Conflicts: # src/config.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense overall, although i admit i haven;t thought too much about its structure.
Definitely nice to save on a lot of imports and random constants showing up in various files.
This PR adds a config file. This configuration is supposed to be extended to other chains in future PRs.
This PR adds a config
AccountingConfig
which consists of multple configurations for different aspects of the accounting.The config is used as a global config. At the moment it is not explicitly passed to any function.
Next steps:
There are still hardcoded constants somewhere in the code. One place is when fetching prices in converting token values, via an ID. The id cannot be part of the config due to circular imports. Instead, an address or id string should be passed and the pricing code should turn it into an appropriate type.
How to review
The first two commits (the names are wrong, I might force push correct ones) add a config and use the config throughout the code. The third commit just removes the old constants file.
One discussion should mostly be about the first commit, i.e. the one adding the configuration classes in
config.py
.Another discussion would be around how to move forward from here.