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

Balancer Stable Math: calculate_invariant_v2 #368

Merged
merged 8 commits into from
Jul 19, 2022
Merged

Conversation

bh2smith
Copy link
Contributor

@bh2smith bh2smith commented Jul 14, 2022

First part of #343: refactoring the calculate_invariant method so that we can support both versions of StablePool.

There has been a change to the calculateInvariant method in Balancer's stable math. Previously they had a boolean indicator for rounding up or down on division and now they only support rounding up.

The Balancer team have assured us that this computation will always return the same results as the previous implementation of the contract (also confirmed by out unit tests still agreeing), and that the only difference is better convergence. This means we can simply adjust the implementation and use it for all stable pools going forward.

Test Plan

Only one unit test needed to be updated (since this new implementation has a wider convergence ratio).

Release notes

Not yet determined. These changes may also need to be propagated to the quasi-modo solver (where stable math is also implemented) and we will also need to start indexing pools coming from their newly deployed factory.

@vkgnosis
Copy link
Contributor

Another question is whether we want to keep supporting the old pools. In that case we'd need to duplicate the parts of the math that have changed.

@bh2smith
Copy link
Contributor Author

bh2smith commented Jul 14, 2022

Another question is whether we want to keep supporting the old pools.

I think we would definitely want to support all balancer pools so we would need a much more elaborate solution than just updating the code.

They do claim that the math hasn't changed and if that is the case then maybe no change is needed at all. Still waiting to hear if they have some edge cases/unit tests that were introduced in their contract update.

@bh2smith bh2smith changed the title update stable math implementation Balancer Stable Math: calculate_invariant_v2 Jul 18, 2022
@bh2smith bh2smith marked this pull request as ready for review July 19, 2022 12:11
@bh2smith bh2smith requested a review from a team as a code owner July 19, 2022 12:11
@bh2smith
Copy link
Contributor Author

Another question is whether we want to keep supporting the old pools.

Confirmed by balancer here, that the new implementation returns the same values as the only, it only has a wider convergence

@bh2smith bh2smith merged commit 94239cc into main Jul 19, 2022
@bh2smith bh2smith deleted the stable-math-update branch July 19, 2022 12:57
@github-actions github-actions bot locked and limited conversation to collaborators Jul 19, 2022
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.

2 participants