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

Restructure price fetching #421

Merged
merged 5 commits into from
Nov 10, 2024
Merged

Restructure price fetching #421

merged 5 commits into from
Nov 10, 2024

Conversation

fhenneke
Copy link
Collaborator

@fhenneke fhenneke commented Nov 7, 2024

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 [Multi-Chain] Add config file #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.

- use addresses instead of token ids for price fetching
- allow for arbitrary token conversions
- explicitly load constants from payouts.py, to allow for changing it to use a config later
Copy link
Contributor

@bh2smith bh2smith left a comment

Choose a reason for hiding this comment

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

Sweet!

Copy link
Contributor

@harisang harisang left a comment

Choose a reason for hiding this comment

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

Looks good. Also confirmed last week's results look fine with this change.

@fhenneke fhenneke merged commit 59cb592 into main Nov 10, 2024
5 checks passed
@fhenneke fhenneke deleted the restructure_price_fetching branch November 10, 2024 15:48
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants