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: improve math for single asset join #1115

Merged
merged 9 commits into from
Dec 13, 2022
Merged

Conversation

matthiasmatt
Copy link
Contributor

@matthiasmatt matthiasmatt commented Dec 11, 2022

Description

@NibiruHeisenberg came up with an easier way to compute the single asset join while at the same time allow for swap fee to be computed: https://www.notion.so/nibiru/Single-Asset-Join-Math-2075178cb9684062b9b65ad23ff14417.

Basically, instead of swapping then joining, we join the pool and then do a single asset join.

This PR migrate the existing single asset join/imbalance join to the new method.

We leverage the uint256 library to do multiplication since we are computing the square of the pool liquidity, which considering the 1e6 precision we use quickly become a very big number (>>int64).

Purpose

Why is this PR important?

@matthiasmatt matthiasmatt requested a review from a team as a code owner December 11, 2022 21:05
@matthiasmatt matthiasmatt enabled auto-merge (squash) December 11, 2022 22:12
Copy link
Member

@Unique-Divine Unique-Divine left a comment

Choose a reason for hiding this comment

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

very nice

x/dex/types/shares.go Outdated Show resolved Hide resolved
x/dex/types/shares_test.go Outdated Show resolved Hide resolved
x/dex/keeper/keeper_test.go Show resolved Hide resolved
x/dex/types/pool.go Outdated Show resolved Hide resolved
x/dex/types/shares.go Outdated Show resolved Hide resolved
x/dex/types/shares.go Outdated Show resolved Hide resolved
@matthiasmatt matthiasmatt merged commit 6f2cd67 into master Dec 13, 2022
@matthiasmatt matthiasmatt deleted the mat/dex-saj-v2 branch December 13, 2022 19:59
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.

3 participants