From 8b4024a6b5c13140d60e740e0cc0925e422ed331 Mon Sep 17 00:00:00 2001 From: orngefrost Date: Sun, 18 Oct 2020 22:56:54 +0900 Subject: [PATCH 1/3] feat(x/gamm): no test, but completed --- x/gamm/keeper/pool/lp.go | 10 ++--- x/gamm/keeper/pool/service.go | 84 ++++++++++++++++++++++++++++++++--- 2 files changed, 82 insertions(+), 12 deletions(-) diff --git a/x/gamm/keeper/pool/lp.go b/x/gamm/keeper/pool/lp.go index 82202b8bc18..fd37dd672b4 100644 --- a/x/gamm/keeper/pool/lp.go +++ b/x/gamm/keeper/pool/lp.go @@ -6,27 +6,27 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" ) -type lp struct { +type lpService struct { denom string bankKeeper bankkeeper.Keeper } -func (p lp) pushPoolShare(ctx sdk.Context, to sdk.AccAddress, amount sdk.Int) error { +func (p lpService) pushPoolShare(ctx sdk.Context, to sdk.AccAddress, amount sdk.Int) error { lp := sdk.Coin{Denom: p.denom, Amount: amount} return p.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, to, sdk.Coins{lp}) } -func (p lp) pullPoolShare(ctx sdk.Context, from sdk.AccAddress, amount sdk.Int) error { +func (p lpService) pullPoolShare(ctx sdk.Context, from sdk.AccAddress, amount sdk.Int) error { lp := sdk.Coin{Denom: p.denom, Amount: amount} return p.bankKeeper.SendCoinsFromAccountToModule(ctx, from, types.ModuleName, sdk.Coins{lp}) } -func (p lp) mintPoolShare(ctx sdk.Context, amount sdk.Int) error { +func (p lpService) mintPoolShare(ctx sdk.Context, amount sdk.Int) error { lp := sdk.Coin{Denom: p.denom, Amount: amount} return p.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.Coins{lp}) } -func (p lp) burnPoolShare(ctx sdk.Context, amount sdk.Int) error { +func (p lpService) burnPoolShare(ctx sdk.Context, amount sdk.Int) error { lp := sdk.Coin{Denom: p.denom, Amount: amount} return p.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.Coins{lp}) } diff --git a/x/gamm/keeper/pool/service.go b/x/gamm/keeper/pool/service.go index 10a8675be47..1362e5be3b3 100644 --- a/x/gamm/keeper/pool/service.go +++ b/x/gamm/keeper/pool/service.go @@ -81,8 +81,9 @@ func (p poolService) JoinPool( if err != nil { return err } + lpToken := pool.Token - poolTotal := pool.Token.TotalSupply.ToDec() + poolTotal := lpToken.TotalSupply.ToDec() poolRatio := poolAmountOut.ToDec().Quo(poolTotal) if poolRatio.Equal(sdk.NewDec(0)) { return sdkerrors.Wrapf(types.ErrMathApprox, "calc poolRatio") @@ -90,17 +91,22 @@ func (p poolService) JoinPool( var sendTargets sdk.Coins for _, maxAmountIn := range maxAmountsIn { - record := pool.Records[maxAmountIn.Denom] - tokenAmountIn := poolRatio.Mul(record.Balance.ToDec()).TruncateInt() + var ( + tokenDenom = maxAmountIn.Denom + record = pool.Records[tokenDenom] + tokenAmountIn = poolRatio.Mul(record.Balance.ToDec()).TruncateInt() + ) if tokenAmountIn.Equal(sdk.NewInt(0)) { return sdkerrors.Wrapf(types.ErrMathApprox, "calc tokenAmountIn") } if tokenAmountIn.GT(maxAmountIn.MaxAmount) { - return sdkerrors.Wrapf(types.ErrLimitExceed, "limit exceeded") + return sdkerrors.Wrapf(types.ErrLimitExceed, "max amount limited") } record.Balance = record.Balance.Add(tokenAmountIn) + pool.Records[tokenDenom] = record // update record + sendTargets = append(sendTargets, sdk.Coin{ - Denom: maxAmountIn.Denom, + Denom: tokenDenom, Amount: tokenAmountIn, }) } @@ -115,8 +121,8 @@ func (p poolService) JoinPool( return err } - poolShare := lp{ - denom: pool.Token.Name, + poolShare := lpService{ + denom: lpToken.Name, bankKeeper: p.bankKeeper, } if err := poolShare.mintPoolShare(ctx, poolAmountOut); err != nil { @@ -125,6 +131,11 @@ func (p poolService) JoinPool( if err := poolShare.pushPoolShare(ctx, sender, poolAmountOut); err != nil { return err } + + // save changes + lpToken.TotalSupply = lpToken.TotalSupply.Add(poolAmountOut) + pool.Token = lpToken + p.store.StorePool(ctx, pool) return nil } @@ -135,5 +146,64 @@ func (p poolService) ExitPool( poolAmountIn sdk.Int, minAmountsOut []types.MinAmountOut, ) error { + pool, err := p.store.FetchPool(ctx, targetPoolId) + if err != nil { + return err + } + lpToken := pool.Token + + poolTotal := lpToken.TotalSupply.ToDec() + poolRatio := poolAmountIn.ToDec().Quo(poolTotal) + if poolRatio.Equal(sdk.NewDec(0)) { + return sdkerrors.Wrapf(types.ErrMathApprox, "calc poolRatio") + } + + poolShare := lpService{ + denom: lpToken.Name, + bankKeeper: p.bankKeeper, + } + if err := poolShare.pullPoolShare(ctx, sender, poolAmountIn); err != nil { + return err + } + if err := poolShare.burnPoolShare(ctx, poolAmountIn); err != nil { + return err + } + + var sendTargets sdk.Coins + for _, minAmountOut := range minAmountsOut { + var ( + tokenDenom = minAmountOut.Denom + record = pool.Records[tokenDenom] + tokenAmountOut = poolRatio.Mul(record.Balance.ToDec()).TruncateInt() + ) + if tokenAmountOut.Equal(sdk.NewInt(0)) { + return sdkerrors.Wrapf(types.ErrMathApprox, "calc tokenAmountOut") + } + if tokenAmountOut.LT(minAmountOut.MinAmount) { + return sdkerrors.Wrapf(types.ErrLimitExceed, "min amount limited") + } + record.Balance = record.Balance.Sub(tokenAmountOut) + pool.Records[tokenDenom] = record + + sendTargets = append(sendTargets, sdk.Coin{ + Denom: tokenDenom, + Amount: tokenAmountOut, + }) + } + + err = p.bankKeeper.SendCoinsFromModuleToAccount( + ctx, + types.ModuleName, + sender, + sendTargets, + ) + if err != nil { + return err + } + + // save changes + lpToken.TotalSupply = lpToken.TotalSupply.Sub(poolAmountIn) + pool.Token = lpToken + p.store.StorePool(ctx, pool) return nil } From 00b0ee9483a46516a3e94f64aeb7485e843ab9b5 Mon Sep 17 00:00:00 2001 From: orngefrost Date: Sun, 18 Oct 2020 23:00:13 +0900 Subject: [PATCH 2/3] common: format code & dependencies --- go.mod | 1 + proto/osmosis/gamm/v1beta1/pool.proto | 48 ++----- proto/osmosis/gamm/v1beta1/tx.proto | 173 +++++--------------------- x/gamm/types/tx.pb.go | 7 +- 4 files changed, 46 insertions(+), 183 deletions(-) diff --git a/go.mod b/go.mod index 6fb3fa0539a..6f102c76d01 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.14 require ( github.com/cosmos/cosmos-sdk v0.34.4-0.20200921130040-27db2cf89772 + github.com/gogo/protobuf v1.3.1 github.com/gorilla/mux v1.8.0 github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.3.1 diff --git a/proto/osmosis/gamm/v1beta1/pool.proto b/proto/osmosis/gamm/v1beta1/pool.proto index 8b48e5f60de..2524f791dc8 100644 --- a/proto/osmosis/gamm/v1beta1/pool.proto +++ b/proto/osmosis/gamm/v1beta1/pool.proto @@ -7,49 +7,19 @@ import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/c-osmosis/osmosis/x/gamm/types"; message Record { - string denormalizedWeight = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"denormalized_weight\"", - (gogoproto.nullable) = false - ]; - string balance = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"balance\"", - (gogoproto.nullable) = false - ]; + string denormalizedWeight = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"denormalized_weight\"", (gogoproto.nullable) = false]; + string balance = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"balance\"", (gogoproto.nullable) = false]; } message LP { - string name = 1 [ - (gogoproto.moretags) = "yaml:\"name\"" - ]; - string totalSupply = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"total_supply\"", - (gogoproto.nullable) = false - ]; + string name = 1 [(gogoproto.moretags) = "yaml:\"name\""]; + string totalSupply = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"total_supply\"", (gogoproto.nullable) = false]; } message Pool { - uint64 id = 1 [ - (gogoproto.moretags) = "yaml:\"id\"" - ]; - string swapFee = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"swap_fee\"", - (gogoproto.nullable) = false - ]; - string totalWeight = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"total_weight\"", - (gogoproto.nullable) = false - ]; - LP token = 4 [ - (gogoproto.moretags) = "yaml:\"token\"", - (gogoproto.nullable) = false - ]; - map records = 5 [ - (gogoproto.moretags) = "yaml:\"records\"", - (gogoproto.nullable) = false - ]; + uint64 id = 1 [(gogoproto.moretags) = "yaml:\"id\""]; + string swapFee = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"swap_fee\"", (gogoproto.nullable) = false]; + string totalWeight = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"total_weight\"", (gogoproto.nullable) = false]; + LP token = 4 [(gogoproto.moretags) = "yaml:\"token\"", (gogoproto.nullable) = false]; + map records = 5 [(gogoproto.moretags) = "yaml:\"records\"", (gogoproto.nullable) = false]; } diff --git a/proto/osmosis/gamm/v1beta1/tx.proto b/proto/osmosis/gamm/v1beta1/tx.proto index 18ee4fcac26..ad9bd3a3541 100644 --- a/proto/osmosis/gamm/v1beta1/tx.proto +++ b/proto/osmosis/gamm/v1beta1/tx.proto @@ -6,176 +6,67 @@ import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/c-osmosis/osmosis/x/gamm/types"; - // ===================== MsgJoinPool message MaxAmountIn { - string denom = 1 [ - (gogoproto.moretags) = "yaml:\"denom\"" - ]; - string maxAmount = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"max_amount\"", - (gogoproto.nullable) = false - ]; + string denom = 1 [(gogoproto.moretags) = "yaml:\"denom\""]; + string maxAmount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"max_amount\"", (gogoproto.nullable) = false]; } message MsgJoinPool { - bytes sender = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"sender\"" - ]; - uint64 targetPool = 2 [ - (gogoproto.moretags) = "yaml:\"target_pool\"" - ]; - string poolAmountOut = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"pool_amount_out\"", - (gogoproto.nullable) = false - ]; + bytes sender = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", (gogoproto.moretags) = "yaml:\"sender\""]; + uint64 targetPool = 2 [(gogoproto.moretags) = "yaml:\"target_pool\""]; + string poolAmountOut = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"pool_amount_out\"", (gogoproto.nullable) = false]; - repeated MaxAmountIn maxAmountsIn = 4 [ - (gogoproto.moretags) = "yaml:\"max_amounts_in\"", - (gogoproto.nullable) = false - ]; + repeated MaxAmountIn maxAmountsIn = 4 [(gogoproto.moretags) = "yaml:\"max_amounts_in\"", (gogoproto.nullable) = false]; } // ===================== MsgExitPool message MinAmountOut { - string denom = 1 [ - (gogoproto.moretags) = "yaml:\"denom\"" - ]; - string minAmount = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"min_amount\"", - (gogoproto.nullable) = false - ]; + string denom = 1 [(gogoproto.moretags) = "yaml:\"denom\""]; + string minAmount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"min_amount\"", (gogoproto.nullable) = false]; } message MsgExitPool { - bytes sender = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"sender\"" - ]; - uint64 targetPool = 2 [ - (gogoproto.moretags) = "yaml:\"target_pool\"" - ]; - string poolAmountIn = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"pool_amount_in\"", - (gogoproto.nullable) = false - ]; + bytes sender = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", (gogoproto.moretags) = "yaml:\"sender\""]; + uint64 targetPool = 2 [(gogoproto.moretags) = "yaml:\"target_pool\""]; + string poolAmountIn = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"pool_amount_in\"", (gogoproto.nullable) = false]; - repeated MinAmountOut minAmountsOut = 4 [ - (gogoproto.moretags) = "yaml:\"min_amounts_out\"", - (gogoproto.nullable) = false - ]; + repeated MinAmountOut minAmountsOut = 4 [(gogoproto.moretags) = "yaml:\"min_amounts_out\"", (gogoproto.nullable) = false]; } // ===================== MsgCreatePool message TokenInfo { - string denom = 1 [ - (gogoproto.moretags) = "yaml:\"denom\"" - ]; - string ratio = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"ratio\"", - (gogoproto.nullable) = false - ]; - string amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"amount\"", - (gogoproto.nullable) = false - ]; + string denom = 1 [(gogoproto.moretags) = "yaml:\"denom\""]; + string ratio = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"ratio\"", (gogoproto.nullable) = false]; + string amount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"amount\"", (gogoproto.nullable) = false]; } message MsgCreatePool { - bytes sender = 1 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", - (gogoproto.moretags) = "yaml:\"sender\"" - ]; + bytes sender = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", (gogoproto.moretags) = "yaml:\"sender\""]; - string swapFee = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"swap_fee\"", - (gogoproto.nullable) = false - ]; + string swapFee = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"swap_fee\"", (gogoproto.nullable) = false]; - repeated TokenInfo tokenInfo = 3 [ - (gogoproto.moretags) = "yaml:\"token_info\"", - (gogoproto.nullable) = false - ]; + repeated TokenInfo tokenInfo = 3 [(gogoproto.moretags) = "yaml:\"token_info\"", (gogoproto.nullable) = false]; } // ===================== MsgSwapExactAmountIn message MsgSwapExactAmountIn { - bytes sender = 1 [ - (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\"" - ]; - cosmos.base.v1beta1.Coin tokenIn = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.moretags) = "yaml:\"token_in\"", - (gogoproto.nullable) = false - ]; - string tokenAmountIn = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"token_amount_in\"", - (gogoproto.nullable) = false - ]; - cosmos.base.v1beta1.Coin tokenOut = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.moretags) = "yaml:\"token_out\"", - (gogoproto.nullable) = false - ]; - string minAmountOut = 6 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"min_amount_out\"", - (gogoproto.nullable) = false - ]; - string maxPrice = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"max_price\"", - (gogoproto.nullable) = false - ]; + bytes sender = 1 [(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\""]; + cosmos.base.v1beta1.Coin tokenIn = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.moretags) = "yaml:\"token_in\"", (gogoproto.nullable) = false]; + string tokenAmountIn = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"token_amount_in\"", (gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin tokenOut = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.moretags) = "yaml:\"token_out\"", (gogoproto.nullable) = false]; + string minAmountOut = 6 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"min_amount_out\"", (gogoproto.nullable) = false]; + string maxPrice = 7 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"max_price\"", (gogoproto.nullable) = false]; } // ===================== MsgSwapExactAmountOut message MsgSwapExactAmountOut { - bytes sender = 1 [ - (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\"" - ]; - cosmos.base.v1beta1.Coin tokenIn = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.moretags) = "yaml:\"token_in\"", - (gogoproto.nullable) = false - ]; - string maxAmountIn = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"max_amount_in\"", - (gogoproto.nullable) = false - ]; - cosmos.base.v1beta1.Coin tokenOut = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.moretags) = "yaml:\"token_out\"", - (gogoproto.nullable) = false - ]; - string tokenAmountOut = 6 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"token_amount_out\"", - (gogoproto.nullable) = false - ]; - string maxPrice = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.moretags) = "yaml:\"max_price\"", - (gogoproto.nullable) = false - ]; + bytes sender = 1 [(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\""]; + cosmos.base.v1beta1.Coin tokenIn = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.moretags) = "yaml:\"token_in\"", (gogoproto.nullable) = false]; + string maxAmountIn = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"max_amount_in\"", (gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin tokenOut = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.moretags) = "yaml:\"token_out\"", (gogoproto.nullable) = false]; + string tokenAmountOut = 6 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"token_amount_out\"", (gogoproto.nullable) = false]; + string maxPrice = 7 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"max_price\"", (gogoproto.nullable) = false]; } \ No newline at end of file diff --git a/x/gamm/types/tx.pb.go b/x/gamm/types/tx.pb.go index cc84217bf36..d2bc8146312 100644 --- a/x/gamm/types/tx.pb.go +++ b/x/gamm/types/tx.pb.go @@ -5,13 +5,14 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. From f15aec9d76879136f3104940a9908b743c629bb0 Mon Sep 17 00:00:00 2001 From: orngefrost Date: Sun, 18 Oct 2020 23:01:14 +0900 Subject: [PATCH 3/3] refactor(x/gamm): move math to home --- x/gamm/keeper/pool/{math => }/math.go | 2 +- x/gamm/keeper/pool/{math => }/math_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename x/gamm/keeper/pool/{math => }/math.go (99%) rename x/gamm/keeper/pool/{math => }/math_test.go (98%) diff --git a/x/gamm/keeper/pool/math/math.go b/x/gamm/keeper/pool/math.go similarity index 99% rename from x/gamm/keeper/pool/math/math.go rename to x/gamm/keeper/pool/math.go index 7793162b435..d66ac85efca 100644 --- a/x/gamm/keeper/pool/math/math.go +++ b/x/gamm/keeper/pool/math.go @@ -1,4 +1,4 @@ -package math +package pool import ( "fmt" diff --git a/x/gamm/keeper/pool/math/math_test.go b/x/gamm/keeper/pool/math_test.go similarity index 98% rename from x/gamm/keeper/pool/math/math_test.go rename to x/gamm/keeper/pool/math_test.go index 87e76c6c75d..d938cdda8bd 100644 --- a/x/gamm/keeper/pool/math/math_test.go +++ b/x/gamm/keeper/pool/math_test.go @@ -1,4 +1,4 @@ -package math +package pool import ( "testing"