-
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] Enable payments on other chains #425
Conversation
a96802a
to
cb7fdcd
Compare
I compared results from this PR to values computed in cowprotocol/gnosis_chain_solver_payouts#13 Results for batch and quote rewards seem to coincide: For the accounting week 2024-11-12 to 2024-11-19, the other script returns a breakdown of
The code from from this PR returns reward transfers as follows:
So rewards seem to work fine. |
Using this dune query, the rewards and total protocol fee seem to coincide with what this PR proposes. What has not been checked yet is the split of protocol fees into separate transfers to the protocol and to partners. The margin for error should be small there, as the logic around getting amounts and addresses does not depend on the chain. |
3647445
to
504ad05
Compare
src/config.py
Outdated
@@ -80,7 +104,7 @@ class ProtocolFeeConfig: | |||
def from_network(network: Network) -> ProtocolFeeConfig: | |||
"""Initialize protocol fee config for a given network.""" | |||
match network: | |||
case Network.MAINNET: | |||
case Network.MAINNET | Network.GNOSIS | Network.ARBITRUM_ONE: |
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.
@fhenneke This probably needs updating? I think we have different addresses per chain
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 added appropriate addresses for each chain.
src/config.py
Outdated
payment_safe_address = Web3.to_checksum_address( | ||
os.environ.get( | ||
"SAFE_ADDRESS", "0xA03be496e67Ec29bC62F01a428683D7F9c204930" | ||
"SAFE_ADDRESS_MAINNET", |
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.
Just realized that the name is not very descriptive. Something like PAYOUTS_SAFE
would be more descriptive
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 changed it to PAYOUTS_SAFE_ADDRESS_${NETWORK}
.
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.
Looks good overall! Haven't tested it yet but code makes sense.
Added some small comments
src/config.py
Outdated
case Network.MAINNET: | ||
prod_db_url = os.environ.get("PROD_DB_URL_MAINNET", "") | ||
barn_db_url = os.environ.get("BARN_DB_URL_MAINNET", "") | ||
case Network.GNOSIS: | ||
prod_db_url = os.environ.get("PROD_DB_URL_GNOSIS", "") | ||
barn_db_url = os.environ.get("BARN_DB_URL_GNOSIS", "") | ||
case Network.ARBITRUM_ONE: | ||
prod_db_url = os.environ.get("PROD_DB_URL_ARBITRUM", "") | ||
barn_db_url = os.environ.get("BARN_DB_URL_ARBITRUM", "") |
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.
Came here from https://github.com/cowprotocol/infrastructure/pull/2349.
This seems like it complicates the configuration. Why not continue to always read the URLs from PROD_DB_URL
and BARN_DB_URL
and expect the job to be run with the correctly configured env variables?
Same comment applies to NODE_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.
In principle it is possible to have one config file with all environment variables per chain, and remove all post-fixes. With our infrastructure it would be one config file and one secret file per chain then, right?
At some point we had planned to compute all payments in one run and then all secrets would need to be available from the same environment. But this is not planned anymore.
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.
With our infrastructure it would be one config file and one secret file per chain then, right?
Yeah, I think so. Both approaches can definitely work. Just seemed surprising to me that you'd basically have 2 places where you branch based on the network. First when you decide which ENV variable to write your values into and later when you decide which ENV variable to read from. 🤷♂️
.env.sample
Outdated
@@ -4,7 +4,7 @@ FILE_OUT_PATH=./out | |||
DUNE_API_KEY= | |||
|
|||
# Safe Transaction Service Requirements. | |||
SAFE_ADDRESS=0xA03be496e67Ec29bC62F01a428683D7F9c204930 | |||
PAYOUTS_SAFE_ADDRESS=0xA03be496e67Ec29bC62F01a428683D7F9c204930 | |||
NETWORK=mainnet |
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.
Could you add a comment with the options here?
Is it {mainnet, xdai, arbitrum_one} or {ethereum, gnosis, arbitrum}?
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 added a comment.
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.
Looks good overall!
Added some small comments
add comment on possible values of NETWORK reorder variables
This is a PR for the current design of payments on other chains.
The current design allows for creation of csv files on Gnosis and Arbitrum One. The script needs to be invoked once for each chain with a different
.env
file.