From 11730cd21b3db04b5973384c24874e5168868c11 Mon Sep 17 00:00:00 2001 From: dongsam Date: Tue, 4 May 2021 00:57:14 +0900 Subject: [PATCH] Fix appName on example, empty event --- doc/client.md | 18 ++++++++-------- x/liquidity/client/cli/query.go | 32 ++++++++++------------------ x/liquidity/client/cli/tx.go | 19 +++++++---------- x/liquidity/keeper/liquidity_pool.go | 3 +-- 4 files changed, 29 insertions(+), 43 deletions(-) diff --git a/doc/client.md b/doc/client.md index ad5fac42e..73eb7ba94 100644 --- a/doc/client.md +++ b/doc/client.md @@ -55,7 +55,7 @@ See [here](https://github.com/tendermint/liquidity/blob/develop/x/liquidity/type Create liquidity pool and deposit coins. Example: -$ liquidity tx liquidity create-pool 1 1000000000uatom,50000000000uusd --from mykey +$ liquidityd tx liquidity create-pool 1 1000000000uatom,50000000000uusd --from mykey This example creates a liquidity pool of pool-type 1 (two coins) and deposits 1000000000uatom and 50000000000uusd. New liquidity pools can be created only for coin combinations that do not already exist in the network. @@ -252,7 +252,7 @@ This deposit request is not processed immediately since it is accumulated in the All requests in a batch are treated equally and executed at the same swap price. Example: -$ liquidity tx liquidity deposit 1 100000000uatom,5000000000uusd --from mykey +$ liquidityd tx liquidity deposit 1 100000000uatom,5000000000uusd --from mykey This example request deposits 100000000uatom and 5000000000uusd to pool-id 1. Deposits must be the same coin denoms as the reserve coins. @@ -598,7 +598,7 @@ This swap request is not processed immediately since it is accumulated in the li All requests in a batch are treated equally and executed at the same swap price. Example: -$ liquidity tx liquidity withdraw 1 10000pool96EF6EA6E5AC828ED87E8D07E7AE2A8180570ADD212117B2DA6F0B75D17A6295 --from mykey +$ liquidityd tx liquidity withdraw 1 10000pool96EF6EA6E5AC828ED87E8D07E7AE2A8180570ADD212117B2DA6F0B75D17A6295 --from mykey This example request withdraws 10000 pool coin from the specified liquidity pool. The appropriate pool coin must be requested from the specified pool. @@ -803,7 +803,7 @@ See [here](https://github.com/tendermint/liquidity/blob/develop/x/liquidity/type ```bash Query details of a liquidity pool batch Example: -$ liquidity query liquidity batch 1 +$ liquidityd query liquidity batch 1 Usage: liquidityd query liquidity batch [pool-id] [flags] @@ -833,7 +833,7 @@ If batch messages are normally processed from the endblock, the resulting state To query for past blocks, query the block height using the REST/gRPC API of a node that is not pruned. Example: -$ liquidity query liquidity deposits 1 +$ liquidityd query liquidity deposits 1 Usage: liquidityd query liquidity deposits [pool-id] [flags] @@ -881,7 +881,7 @@ pagination: ``` Query details of a liquidity pool Example: -$ liquidity query liquidity pool 1 +$ liquidityd query liquidity pool 1 Usage: liquidityd query liquidity pool [pool-id] [flags] @@ -932,7 +932,7 @@ denom: pool96EF6EA6E5AC828ED87E8D07E7AE2A8180570ADD212117B2DA6F0B75D17A6295 ``` Query details about all liquidity pools on a network. Example: -$ liquidity query liquidity pools +$ liquidityd query liquidity pools Usage: liquidityd query liquidity pools [flags] @@ -999,7 +999,7 @@ the resulting state is applied and the messages are removed in the beginning of To query for past blocks, query the block height using the REST/gRPC API of a node that is not pruned. Example: -$ liquidity query liquidity swaps 1 +$ liquidityd query liquidity swaps 1 Usage: liquidityd query liquidity swaps [pool-id] [flags] @@ -1063,7 +1063,7 @@ the resulting state is applied and the messages are removed in the beginning of To query for past blocks, query the block height using the REST/gRPC API of a node that is not pruned. Example: -$ liquidity query liquidity withdraws 1 +$ liquidityd query liquidity withdraws 1 Usage: liquidityd query liquidity withdraws [pool-id] [flags] diff --git a/x/liquidity/client/cli/query.go b/x/liquidity/client/cli/query.go index 095e02c6c..91c09f648 100644 --- a/x/liquidity/client/cli/query.go +++ b/x/liquidity/client/cli/query.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/version" + "github.com/tendermint/liquidity/x/liquidity/types" ) @@ -53,9 +53,8 @@ func GetCmdQueryParams() *cobra.Command { fmt.Sprintf(`Query values set as liquidity parameters. Example: -$ %s query liquidity params +$ liquidityd query liquidity params `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -88,9 +87,8 @@ func GetCmdQueryLiquidityPool() *cobra.Command { Long: strings.TrimSpace( fmt.Sprintf(`Query details of a liquidity pool Example: -$ %s query liquidity pool 1 +$ liquidityd query liquidity pool 1 `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -137,9 +135,8 @@ func GetCmdQueryLiquidityPools() *cobra.Command { Long: strings.TrimSpace( fmt.Sprintf(`Query details about all liquidity pools on a network. Example: -$ %s query liquidity pools +$ liquidityd query liquidity pools `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -173,9 +170,8 @@ func GetCmdQueryLiquidityPoolBatch() *cobra.Command { Long: strings.TrimSpace( fmt.Sprintf(`Query details of a liquidity pool batch Example: -$ %s query liquidity batch 1 +$ liquidityd query liquidity batch 1 `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -224,9 +220,8 @@ If batch messages are normally processed from the endblock, the resulting state To query for past blocks, query the block height using the REST/gRPC API of a node that is not pruned. Example: -$ %s query liquidity deposits 1 +$ liquidityd query liquidity deposits 1 `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -272,9 +267,8 @@ the resulting state is applied and the messages are removed from the beginning o To query for past blocks, query the block height using the REST/gRPC API of a node that is not pruned. Example: -$ %s query liquidity deposit 1 20 +$ liquidityd query liquidity deposit 1 20 `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -321,9 +315,8 @@ the resulting state is applied and the messages are removed in the beginning of To query for past blocks, query the block height using the REST/gRPC API of a node that is not pruned. Example: -$ %s query liquidity withdraws 1 +$ liquidityd query liquidity withdraws 1 `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -369,9 +362,8 @@ the resulting state is applied and the messages are removed in the beginning of To query for past blocks, query the block height using the REST/gRPC API of a node that is not pruned. Example: -$ %s query liquidity withdraw 1 20 +$ liquidityd query liquidity withdraw 1 20 `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -418,9 +410,8 @@ the resulting state is applied and the messages are removed in the beginning of To query for past blocks, query the block height using the REST/gRPC API of a node that is not pruned. Example: -$ %s query liquidity swaps 1 +$ liquidityd query liquidity swaps 1 `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -466,9 +457,8 @@ the resulting state is applied and the messages are removed in the beginning of To query for past blocks, query the block height using the REST/gRPC API of a node that is not pruned. Example: -$ %s query liquidity swap 1 20 +$ liquidityd query liquidity swap 1 20 `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/x/liquidity/client/cli/tx.go b/x/liquidity/client/cli/tx.go index 1a1813d43..17697fa12 100644 --- a/x/liquidity/client/cli/tx.go +++ b/x/liquidity/client/cli/tx.go @@ -5,15 +5,16 @@ package cli import ( "fmt" + "strconv" + "strings" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/version" "github.com/spf13/cobra" - "strconv" - "strings" "github.com/cosmos/cosmos-sdk/client" + "github.com/tendermint/liquidity/x/liquidity/types" ) @@ -47,7 +48,7 @@ func NewCreatePoolCmd() *cobra.Command { fmt.Sprintf(`Create liquidity pool and deposit coins. Example: -$ %s tx liquidity create-pool 1 1000000000uatom,50000000000uusd --from mykey +$ liquidityd tx liquidity create-pool 1 1000000000uatom,50000000000uusd --from mykey This example creates a liquidity pool of pool-type 1 (two coins) and deposits 1000000000uatom and 50000000000uusd. New liquidity pools can be created only for coin combinations that do not already exist in the network. @@ -55,7 +56,6 @@ New liquidity pools can be created only for coin combinations that do not alread [pool-type]: The id of the liquidity pool-type. The only supported pool type is 1 [deposit-coins]: The amount of coins to deposit to the liquidity pool. The number of deposit coins must be 2 in pool type 1. `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -116,7 +116,7 @@ This deposit request is not processed immediately since it is accumulated in the All requests in a batch are treated equally and executed at the same swap price. Example: -$ %s tx liquidity deposit 1 100000000uatom,5000000000uusd --from mykey +$ liquidityd tx liquidity deposit 1 100000000uatom,5000000000uusd --from mykey This example request deposits 100000000uatom and 5000000000uusd to pool-id 1. Deposits must be the same coin denoms as the reserve coins. @@ -124,7 +124,6 @@ Deposits must be the same coin denoms as the reserve coins. [pool-id]: The pool id of the liquidity pool [deposit-coins]: The amount of coins to deposit to the liquidity pool `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -181,7 +180,7 @@ This swap request is not processed immediately since it is accumulated in the li All requests in a batch are treated equally and executed at the same swap price. Example: -$ %s tx liquidity withdraw 1 10000pool96EF6EA6E5AC828ED87E8D07E7AE2A8180570ADD212117B2DA6F0B75D17A6295 --from mykey +$ liquidityd tx liquidity withdraw 1 10000pool96EF6EA6E5AC828ED87E8D07E7AE2A8180570ADD212117B2DA6F0B75D17A6295 --from mykey This example request withdraws 10000 pool coin from the specified liquidity pool. The appropriate pool coin must be requested from the specified pool. @@ -189,7 +188,6 @@ The appropriate pool coin must be requested from the specified pool. [pool-id]: The pool id of the liquidity pool [pool-coin]: The amount of pool coin to withdraw from the liquidity pool `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -246,7 +244,7 @@ The requested swap is executed with a swap price that is calculated from the giv Swap orders are executed only when the execution swap price is equal to or greater than the submitted order price of the swap order. Example: -$ %s liquidityd tx liquidity swap 1 1 50000000uusd uatom 0.019 0.003 --from mykey +$ liquidityd tx liquidity swap 1 1 50000000uusd uatom 0.019 0.003 --from mykey For this example, imagine that an existing liquidity pool has with 1000000000uatom and 50000000000uusd. This example request swaps 50000000uusd for at least 950000uatom with the order price of 0.019 and swap fee rate of 0.003. @@ -265,7 +263,6 @@ The only supported swap-type is 1. For the detailed swap algorithm, see https:// [order-price]: The limit order price for the swap order. The price is the exchange ratio of X/Y where X is the amount of the first coin and Y is the amount of the second coin when their denoms are sorted alphabetically [swap-fee-rate]: The swap fee rate to pay for swap that is proportional to swap amount. The swap fee rate must be the value that set as liquidity parameter in the current network. `, - version.AppName, ), ), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/x/liquidity/keeper/liquidity_pool.go b/x/liquidity/keeper/liquidity_pool.go index dfe63d701..2719944eb 100644 --- a/x/liquidity/keeper/liquidity_pool.go +++ b/x/liquidity/keeper/liquidity_pool.go @@ -205,7 +205,6 @@ func (k Keeper) DepositLiquidityPool(ctx sdk.Context, msg types.DepositMsgState, lastReserveCoinA := sdk.NewDecFromInt(reserveCoins[0].Amount) lastReserveCoinB := sdk.NewDecFromInt(reserveCoins[1].Amount) lastReserveRatio := lastReserveCoinA.QuoTruncate(lastReserveCoinB) - ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeDepositToPool, @@ -214,7 +213,7 @@ func (k Keeper) DepositLiquidityPool(ctx sdk.Context, msg types.DepositMsgState, sdk.NewAttribute(types.AttributeValueMsgIndex, strconv.FormatUint(msg.MsgIndex, 10)), sdk.NewAttribute(types.AttributeValueDepositor, depositor.String()), sdk.NewAttribute(types.AttributeValueAcceptedCoins, msg.Msg.DepositCoins.String()), - sdk.NewAttribute(types.AttributeValueRefundedCoins, sdk.NewCoins().String()), + sdk.NewAttribute(types.AttributeValueRefundedCoins, ""), sdk.NewAttribute(types.AttributeValuePoolCoinDenom, mintPoolCoin.Denom), sdk.NewAttribute(types.AttributeValuePoolCoinAmount, mintPoolCoin.Amount.String()), sdk.NewAttribute(types.AttributeValueSuccess, types.Success),