Skip to content

Commit

Permalink
Merge pull request #240 from b-harvest/dongsam/fix-appname-on-example…
Browse files Browse the repository at this point in the history
…-and-empty-event

Fix appName on example, empty event
  • Loading branch information
dongsam authored May 3, 2021
2 parents 8762698 + 11730cd commit fce1add
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 43 deletions.
18 changes: 9 additions & 9 deletions doc/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
32 changes: 11 additions & 21 deletions x/liquidity/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
19 changes: 8 additions & 11 deletions x/liquidity/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -47,15 +48,14 @@ 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.
[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 {
Expand Down Expand Up @@ -116,15 +116,14 @@ 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.
[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 {
Expand Down Expand Up @@ -181,15 +180,14 @@ 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.
[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 {
Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions x/liquidity/keeper/liquidity_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit fce1add

Please sign in to comment.