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

[x/gamm][Misc Improvements] Fix API inconsistency between JoinPool and CalcJoinPoolShares #1443

Closed
Tracked by #1453
ValarDragon opened this issue May 6, 2022 · 2 comments
Labels
T:task ⚙️ A task belongs to a story

Comments

@ValarDragon
Copy link
Member

The API is currently:

	// JoinPool joins the pool using all of the tokensIn provided.
	// The AMM swaps to the correct internal ratio should be and returns the number of shares created.
	// This function is mutative and updates the pool's internal state if there is no error.
	// It is up to pool implementation if they support LP'ing at arbitrary ratios, or a subset of ratios.
	// Pools are expected to guarantee LP'ing at the exact ratio, and single sided LP'ing.
	JoinPool(ctx sdk.Context, tokensIn sdk.Coins, swapFee sdk.Dec) (numShares sdk.Int, err error)
	// CalcJoinPoolShares returns how many LP shares JoinPool would return on these arguments.
	// This does not mutate the pool, or state.
	CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, swapFee sdk.Dec) (numShares sdk.Int, newLiquidity sdk.Coins, err error)

CalcJoinPoolShares should either not return newLiquidity or JoinPool should return it. The current method of one method not being guaranteed to use all liquidity, while the other is required to use all liquidity is ... odd.

@daniel-farina daniel-farina moved this to Needs Review 🔍 in Osmosis Chain Development May 6, 2022
@p0mvn p0mvn changed the title gamm: Fix API inconsistency between JoinPool and CalcJoinPoolShares [x/gamm] Fix API inconsistency between JoinPool and CalcJoinPoolShares May 9, 2022
@p0mvn p0mvn changed the title [x/gamm] Fix API inconsistency between JoinPool and CalcJoinPoolShares [x/gamm][Misc Improvements] Fix API inconsistency between JoinPool and CalcJoinPoolShares May 9, 2022
@p0mvn p0mvn added the T:task ⚙️ A task belongs to a story label May 9, 2022
@p0mvn p0mvn mentioned this issue May 9, 2022
6 tasks
@mattverse
Copy link
Member

@ValarDragon wdym by

The current method of one method not being guaranteed to use all liquidity, while the other is required to use all liquidity

imo, the API inconsistency makes sense: since JoinPool deosn't need to return newLiquidity because the return value would not be used. We also have the option to make both not return newLiquidity as you have mentioned, but then we would have to move the layer of calculating the updated liquidity to JoinPool which would result in extra overhead

@p0mvn
Copy link
Member

p0mvn commented Jul 15, 2022

I agree with @mattverse here. I don't see a reason for returning newLiquidity from JoinPool. At the same, if we don't return it from CalcJoinPoolShares, then we must essentially merge the two methods.

I will close this issue for now. However, if anyone disagrees / would like to discuss further, please let me know

@p0mvn p0mvn closed this as completed Jul 15, 2022
Repository owner moved this from Needs Review 🔍 to Done ✅ in Osmosis Chain Development Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T:task ⚙️ A task belongs to a story
Projects
Archived in project
Development

No branches or pull requests

3 participants