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: add the cli to create, join, exit the pool #13

Merged
merged 6 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.6.1
github.com/tendermint/tendermint v0.34.0-rc4.0.20201005135527-d7d0ffea13c6
github.com/tendermint/tm-db v0.6.2
Expand Down
18 changes: 8 additions & 10 deletions proto/osmosis/gamm/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ message MsgJoinPool {
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"sender\""
];
uint64 targetPool = 2 [
(gogoproto.moretags) = "yaml:\"target_pool\""
uint64 targetPoolId = 2 [
(gogoproto.moretags) = "yaml:\"target_pool_id\""
];
string poolAmountOut = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Expand Down Expand Up @@ -55,8 +55,8 @@ message MsgExitPool {
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"sender\""
];
uint64 targetPool = 2 [
(gogoproto.moretags) = "yaml:\"target_pool\""
uint64 targetPoolId = 2 [
(gogoproto.moretags) = "yaml:\"target_pool_id\""
];
string poolAmountIn = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Expand Down Expand Up @@ -125,9 +125,8 @@ message MsgSwapExactAmountIn {
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"sender\""
];
bytes targetPool = 2 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"target_pool\""
uint64 targetPoolId = 2 [
(gogoproto.moretags) = "yaml:\"target_pool_id\""
];
cosmos.base.v1beta1.Coin tokenIn = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin",
Expand Down Expand Up @@ -162,9 +161,8 @@ message MsgSwapExactAmountOut {
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"sender\""
];
bytes targetPool = 2 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"target_pool\""
uint64 targetPoolId = 2 [
(gogoproto.moretags) = "yaml:\"target_pool_id\""
];
cosmos.base.v1beta1.Coin tokenIn = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin",
Expand Down
61 changes: 61 additions & 0 deletions x/gamm/client/cli/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package cli

import (
flag "github.com/spf13/pflag"
)

const (
FlagPoolTokenCustomDenom = "pool-token-custom-denom"
FlagPoolTokenDescription = "pool-token-description"
FlagPoolBindTokens = "bind-tokens"
FlagPoolBindTokenWeights = "bind-tokens-weight"
FlagSwapFee = "swap-fee"

FlagPoolId = "pool-id"
// This is string, because it is parsed as sdk.Int
FlagPoolAmountOut = "pool-amount-out"
// List of coin
FlagMaxAountsIn = "pool-max-amounts-in"

// This is string, because it is parsed as sdk.Int
FlagPoolAmountIn = "pool-amount-in"
// List of coin
FlagMinAmountsOut = "pool-min-amounts-out"
)

func FlagSetCreatePool() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)

fs.String(FlagPoolTokenCustomDenom, "", "The custom denom for pool's liquidity token")
fs.String(FlagPoolTokenDescription, "", "Description of the pool token")
fs.StringArray(FlagPoolBindTokens, []string{""}, "The tokens to be provided to the pool initially")
fs.StringArray(FlagPoolBindTokenWeights, []string{""}, "The weights of the tokens in the pool")
fs.String(FlagSwapFee, "", "Swap fee of the pool")
return fs
}

func FlagSetJoinPool() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)

fs.Uint64(FlagPoolId, 0, "The id of pool")
// This is string, because it is parsed as sdk.Int
// TODO: 어떻게 설명해야하지...
fs.String(FlagPoolAmountOut, "", "TODO: add description")
// TODO: 어떻게 설명해야하지...
fs.StringArray(FlagMaxAountsIn, []string{""}, "TODO: add description")

return fs
}

func FlagSetExitPool() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)

fs.Uint64(FlagPoolId, 0, "The id of pool")
// This is string, because it is parsed as sdk.Int
// TODO: 어떻게 설명해야하지...
fs.String(FlagPoolAmountIn, "", "TODO: add description")
// TODO: 어떻게 설명해야하지...
fs.StringArray(FlagMinAmountsOut, []string{""}, "TODO: add description")

return fs
}
Loading