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

WIP: Adjust stable math & live balances rounding #1020

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jubeira
Copy link
Contributor

@jubeira jubeira commented Sep 26, 2024

Description

computeInvariant returns the same for round up and down in Stable pool. The invariant is precise, but we should still make a difference to favor the vault when computing unbalanced liquidity operations.

Regarding the rounding for live balances: it's more convenient to round up in general (trivial to verify for proportional adds by inspecting the code), but in particular, nonlinear math involved computing the invariants might have significant impact under very specific conditions and pool types. What matters is to prevent roundtrips, and remove liquidity is computed rounding down. Then, using the same rounding for unbalanced add / remove reduces one variable that can affect how the pool prices the assets.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Code refactor / cleanup
  • Optimization: [ ] gas / [ ] bytecode
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • Complex code has been commented, including external interfaces
  • Tests have 100% code coverage
  • The base branch is either main, or there's a description of how to merge

Issue Resolution

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