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

feat: allowed empty AMM levels #2358

Draft
wants to merge 5 commits into
base: suzukacastle_II
Choose a base branch
from

Conversation

cdummett
Copy link
Collaborator

@cdummett cdummett commented Sep 9, 2024

Summary

Currently core rejects any AMM pool which does not provide at least one unit of volume between every tick in the AMM's range. PR updates spec with a new market parameter $allowedEmptyAmmLevels$ which defines the maximum size of a range in which an AMM is allowed to quote no volume. This range is measured in ticks.

As a guide of what this change means for mainnet markets, the below plot shows the value $allowedEmptyAmmLevels$ should be set to for the smallest commitment to be valid when the specific parameters are selected.

e.g. to allow $leverageAtLowerBounds=5$ for a $lowerBound$ offset 2% from the $basePrice$, $allowedEmptyAmmLevels\geq1600$

largest_empty_range

The PR also gives equations for calculating the best-bid / best-ask to avoid core iterating over the range to find the price at which an AMM provides at least one unit of volume.

Notes

  • PR also corrects spec inaccuracy where it is stated the curve is recalculated based on the account balances. The curve is in fact fixed based on the commitment size - see commit f2b856539a24350baec3ad1093f72106e25b6705.
  • with current core implementation rearranging formulas to allow the AMM estimation API to return the commitment size for required for a specific pool is not trivial, for now it is left as simply returning pool valid / not-valid.

@cdummett cdummett added this to the 🏯🏯 Suzuka Castle II milestone Sep 9, 2024
@cdummett cdummett self-assigned this Sep 9, 2024
@cdummett cdummett force-pushed the feat/empty_amm_levels branch from 7246759 to 4d6a294 Compare September 10, 2024 10:16
@cdummett cdummett force-pushed the feat/empty_amm_levels branch from 4d6a294 to 705a118 Compare September 10, 2024 10:25
feat: apply refactor feedback

Co-authored-by: David Siska <62546419+davidsiska-vega@users.noreply.github.com>
$$

$$
n\cdot\Delta{p} \geq {p_u} - (\frac{L\cdot\sqrt{p_u}}{L + \Delta{P}\cdot \sqrt{p_u}})^2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
n\cdot\Delta{p} \geq {p_u} - (\frac{L\cdot\sqrt{p_u}}{L + \Delta{P}\cdot \sqrt{p_u}})^2
n\cdot\Delta{p} \geq {p_u} - \bigg(\frac{L\cdot\sqrt{p_u}}{L + \Delta{P}\cdot \sqrt{p_u}}\bigg)^2

$$
n\cdot\Delta{p} \geq (p_u - p_{bb})
$$

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this is equivalent to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants