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

Stableswap #980

Closed
jonator opened this issue Nov 9, 2022 · 3 comments
Closed

Stableswap #980

jonator opened this issue Nov 9, 2022 · 3 comments
Assignees
Milestone

Comments

@jonator
Copy link
Member

jonator commented Nov 9, 2022

Here are our final core stableswap functions:

The solver is the same for both and runs mostly boilerplate binary search on the CFMM, which is defined here (the comments about the solver function I linked in the third bullet point should explain its logic in detail) (edited)

Basically for Out Given In, we pass in a negative yIn to the solver (i.e. the “out” amount), which gives us the correct but negative output, which we have to negate

@jonator jonator added this to the v13 Upgrade milestone Nov 9, 2022
@jonator jonator changed the title Osmosis v13 upgrade Stableswap Nov 9, 2022
@AlpinYukseloglu
Copy link
Contributor

@jonator
Copy link
Member Author

jonator commented Nov 19, 2022

Stableswap implementation:

getNormalizedLiquidity(tokenInDenom: string, tokenOutDenom: string): Dec {
const tokenOut = this.getPoolAsset(tokenOutDenom);
const tokenIn = this.getPoolAsset(tokenInDenom);
return tokenOut.amount
.toDec()
.mul(new Dec(tokenIn.scalingFactor))
.quo(new Dec(tokenIn.scalingFactor).add(new Dec(tokenOut.scalingFactor))); // TODO: ensure this works in router
}

Weighted implementation:

getNormalizedLiquidity(tokenInDenom: string, tokenOutDenom: string): Dec {
const tokenIn = this.getPoolAsset(tokenInDenom);
const tokenOut = this.getPoolAsset(tokenOutDenom);
return tokenOut.amount
.toDec()
.mul(tokenIn.weight.toDec())
.quo(tokenIn.weight.toDec().add(tokenOut.weight.toDec()));
}

@jonator
Copy link
Member Author

jonator commented Nov 22, 2022

  • Iconography on pools page
  • Label on pool detail page
  • New create pool workflow
  • Only multi asset join pool

@jonator jonator mentioned this issue Nov 23, 2022
5 tasks
@jonator jonator closed this as completed Dec 13, 2022
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

No branches or pull requests

2 participants