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

[SB-1967] GEMA smoothing #40

Merged
merged 11 commits into from
Sep 13, 2024
Merged

[SB-1967] GEMA smoothing #40

merged 11 commits into from
Sep 13, 2024

Conversation

SupernaviX
Copy link
Collaborator

@SupernaviX SupernaviX commented Sep 12, 2024

Implement GEMA smoothing, where increases in the current price are "smoothed" based on the previous price. The window we're using is 10 rounds, we can change that in configuration later.

The output of the current round of signature aggregation depends on the output of older rounds. This required some other changes:

  • The leader now sends the latest signed feed for each synthetic to its followers, even if that feed is from an older round. This helps newly joined/restarted nodes get in sync. We still only push "new" feeds to Butane, but the /payload endpoint includes the latest feed for everything.
  • We do all price calculations in BigRationals (infinite-precision rational numbers). Price sources such as sundaeswap and bybit still report prices with Decimals (which have finite precision), but we convert that to BigRational before doing the math.
  • Because BigRational can get arbitrarily large after many cycles of GEMA, we round prices in the final payload to take at most 1024 bits (128 bytes). This should be more than enough precision for what we need. We also round the older prices used for the EMA calculation to 512 bits (64 bytes).

@SupernaviX SupernaviX merged commit a89d775 into main Sep 13, 2024
7 checks passed
@SupernaviX SupernaviX deleted the SB-1967/oracle-gema-smoothing branch September 13, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant