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

Begin stableswap spec #2873

Merged
merged 22 commits into from
Sep 29, 2022
Merged

Begin stableswap spec #2873

merged 22 commits into from
Sep 29, 2022

Conversation

ValarDragon
Copy link
Member

@ValarDragon ValarDragon commented Sep 26, 2022

What is the purpose of the change

WIP work on a spec for Solidly stableswap and description of equations used within it

Rendered URL: https://github.com/osmosis-labs/osmosis/blob/dev/stableswap_spec/x/gamm/pool-models/stableswap/README.md

@ValarDragon ValarDragon requested review from AlpinYukseloglu and a team September 26, 2022 14:55
@github-actions github-actions bot added C:docs Improvements or additions to documentation C:x/gamm Changes, features and bugs related to the gamm module. labels Sep 26, 2022
x/gamm/pool-models/stableswap/README.md Outdated Show resolved Hide resolved
x/gamm/pool-models/stableswap/README.md Outdated Show resolved Hide resolved
x/gamm/pool-models/stableswap/README.md Outdated Show resolved Hide resolved
Suppose the existence of a function $\text{solve\_cfmm}(x, v, w, k) = y\text{ s.t. }g(x, y, v, w) = k$.
Then we can solve swaps by first computing $k = g(x_0, y_0, v, w)$.
Then suppose I want to swap $a$ units of $x$, and then want to find how many units $b$ of $y$ that we get out.
We do this by computing $y_f = \text{solve\_cfmm}(x_0 + a, v, w, k)$, and then $b = y_0 - y_f$
Copy link
Member

@p0mvn p0mvn Sep 26, 2022

Choose a reason for hiding this comment

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

This and all of the remaining expressions also do not render for me unfortunately

@AlpinYukseloglu
Copy link
Contributor

Thoughts on throwing this into a hackmd so we can work on filling out the rest together? Or would you prefer to fill out the whole spec and then have others review?

upperbound =
```

### Spot Price
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these considered as TODOs for future reference?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, just things that should be filled in before stableswap has a full spec

@ValarDragon
Copy link
Member Author

@p0mvn github rendering now fixed

@ValarDragon
Copy link
Member Author

@AlpinYukseloglu happy with either of the options you proposed.

Feel free to commit to the branch, or move it to a hackmd. I also don't think we need to have the full spec written in one PR though. (e.g. I'm happy with this getting in its current form, I feel like it gives us a swap algorithm description we can iterate on for comparing against code)

The maximal upperbound is obviously unworkable, and in general binary searching around wide ranges is unfortunate, as we expect most trades to be centered around $y_0$.
This would suggest that we should do something smarter to iteratively approach the right value for the upperbound at least.
Notice that $h$ is super-linearly related in $y$, and at most cubically related to $y$.
This means that $ \forall c \in \R^+, c * h(x,y,w) < h(x,c*y,w) < c^3 * h(x,y,w)$.
Copy link
Member

Choose a reason for hiding this comment

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

This one isn't rendering still

@ValarDragon
Copy link
Member Author

ty. fixed! (Also apologies, last commit got cut off a bit early in the web editor)

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

The progress so far LGTM and everything makes sense. Nice work

@mergify mergify bot merged commit 76a99c7 into main Sep 29, 2022
@mergify mergify bot deleted the dev/stableswap_spec branch September 29, 2022 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge C:docs Improvements or additions to documentation C:x/gamm Changes, features and bugs related to the gamm module.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants