-
Notifications
You must be signed in to change notification settings - Fork 607
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
JoinPoolNoSwap simulation #3242
Changes from all commits
4bccd64
952805b
0b36043
772a339
3a412be
44d5e7e
d256d6a
21507ac
13ee4cc
8c1842a
b0a7e02
d27f5f5
1885ab3
92bb3e0
d82a187
ad4ad23
b570872
6b8bc7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,6 +288,29 @@ func (q Querier) CalcExitPoolCoinsFromShares(ctx context.Context, req *types.Que | |
return &types.QueryCalcExitPoolCoinsFromSharesResponse{TokensOut: exitCoins}, nil | ||
} | ||
|
||
// CalcJoinPoolNoSwapShares returns the amount of shares you'd get if joined a pool without a swap and tokens which need to be provided | ||
func (q Querier) CalcJoinPoolNoSwapShares(ctx context.Context, req *types.QueryCalcJoinPoolNoSwapSharesRequest) (*types.QueryCalcJoinPoolNoSwapSharesResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "empty request") | ||
} | ||
|
||
sdkCtx := sdk.UnwrapSDKContext(ctx) | ||
pool, err := q.GetPoolAndPoke(sdkCtx, req.PoolId) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method calls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CC: @ValarDragon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
sharesOut, tokensJoined, err := pool.CalcJoinPoolNoSwapShares(sdkCtx, req.TokensIn, pool.GetSwapFee(sdkCtx)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &types.QueryCalcJoinPoolNoSwapSharesResponse{ | ||
TokensOut: tokensJoined, | ||
SharesOut: sharesOut, | ||
}, nil | ||
} | ||
|
||
// PoolParams queries a specified pool for its params. | ||
func (q Querier) PoolParams(ctx context.Context, req *types.QueryPoolParamsRequest) (*types.QueryPoolParamsResponse, error) { | ||
if req == nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please add this and your previous query to this test:
osmosis/x/gamm/client/cli/query_test.go
Line 26 in 0423e96
It ensures that queries don't alter state. This would be very useful for a stargate query
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, I'll change this ASAP