Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:tendermint/liquidity into hallaz…
Browse files Browse the repository at this point in the history
…zang/364-depleted-pool
  • Loading branch information
hallazzang committed Jun 2, 2021
2 parents c391959 + d1c90aa commit 096a0a0
Show file tree
Hide file tree
Showing 37 changed files with 1,230 additions and 884 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
# process linker flags

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=liquidityd \
-X github.com/cosmos/cosmos-sdk/version.AppName=liquidity \
-X github.com/cosmos/cosmos-sdk/version.AppName=liquidityd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
Expand Down
6 changes: 6 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ func NewLiquidityApp(
),
)
app.SetEndBlocker(app.EndBlocker)
app.UpgradeKeeper.SetUpgradeHandler("Gravity-DEX",
func(ctx sdk.Context, plan upgradetypes.Plan) {
var genState liquiditytypes.GenesisState
genState.Params = liquiditytypes.DefaultParams()
app.LiquidityKeeper.InitGenesis(ctx, genState)
})

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

617 changes: 335 additions & 282 deletions client/docs/swagger-ui/swagger.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions proto/tendermint/liquidity/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/tendermint/liquidity/x/liquidity/types";

// record of the state of each pool after genesis export or import, used to check variables
// records the state of each pool after genesis export or import, used to check variables
message PoolRecord {
Pool pool = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"pool\""];
PoolMetadata pool_metadata = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"pool_metadata\""];
Expand All @@ -21,7 +21,7 @@ message GenesisState {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// params defines all the parameters of related to liquidity.
// params defines all the parameters for the liquidity module.
Params params = 1 [(gogoproto.nullable) = false];
repeated PoolRecord pool_records = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"pools\""];
}
46 changes: 27 additions & 19 deletions proto/tendermint/liquidity/v1beta1/liquidity.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message PoolType {
option (gogoproto.equal) = true;

// The id of the pool_type to use as pool_type_id for pool creation.
// Only pool-type-id 1 is supported
// Only pool-type-id 1 is supported.
// {"id":1,"name":"ConstantProductLiquidityPool","min_reserve_coin_num":2,"max_reserve_coin_num":2,"description":""}
uint32 id = 1 [(gogoproto.moretags) = "yaml:\"id\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
Expand All @@ -28,14 +28,14 @@ message PoolType {
example: "\"ConstantProductLiquidityPool\"",
}];

// min number of reserveCoins for LiquidityPoolType only 2 is allowed on this spec
// minimum number of reserveCoins for LiquidityPoolType. Only 2 reserveCoins are allowed.
uint32 min_reserve_coin_num = 3 [(gogoproto.moretags) = "yaml:\"min_reserve_coin_num\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"2\"",
format: "uint32"
}];

// max number of reserveCoins for LiquidityPoolType only 2 is allowed on this spec
// maximum number of reserveCoins for LiquidityPoolType. Only 2 reserveCoins are allowed.
uint32 max_reserve_coin_num = 4 [(gogoproto.moretags) = "yaml:\"max_reserve_coin_num\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"2\"",
Expand All @@ -57,7 +57,7 @@ message Params {
(gogoproto.nullable) = false
];

// Minimum number of coins to be deposited to the liquidity pool upon pool creation
// Minimum number of coins to be deposited to the liquidity pool on pool creation
string min_init_deposit_amount = 2 [
(gogoproto.moretags) = "yaml:\"min_init_deposit_amount\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Expand All @@ -67,7 +67,7 @@ message Params {
format: "sdk.Int"
}];

// Initial mint amount of pool coin upon pool creation
// Initial mint amount of pool coins upon pool creation
string init_pool_coin_mint_amount = 3 [
(gogoproto.moretags) = "yaml:\"init_pool_coin_mint_amount\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Expand All @@ -77,7 +77,7 @@ message Params {
format: "sdk.Int"
}];

// Limit the size of each liquidity pool in the beginning phase of Liquidity Module adoption to minimize risk, 0 means no limit
// Limit the size of each liquidity pool. In the beginning phase of Liquidity Module adoption, this limit minimizes risk. Although not recommended for production, you can set to 0 for no limit.
string max_reserve_coin_amount = 4 [
(gogoproto.moretags) = "yaml:\"max_reserve_coin_amount\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Expand All @@ -98,7 +98,7 @@ message Params {
}
];

// Swap fee rate for every executed swap
// Swap fee rate for every executed swap.
string swap_fee_rate = 6 [
(gogoproto.moretags) = "yaml:\"swap_fee_rate\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
Expand All @@ -108,7 +108,7 @@ message Params {
format: "sdk.Dec"
}];

// Reserve coin withdrawal with less proportion by withdrawFeeRate
// Reserve coin withdrawal with less proportion by withdrawFeeRate.
string withdraw_fee_rate = 7 [
(gogoproto.moretags) = "yaml:\"withdraw_fee_rate\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
Expand All @@ -118,7 +118,7 @@ message Params {
format: "sdk.Dec"
}];

// Maximum ratio of reserve coins that can be ordered at a swap order
// Maximum ratio of reserve coins that can be ordered at a swap order.
string max_order_amount_ratio = 8 [
(gogoproto.moretags) = "yaml:\"max_order_amount_ratio\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
Expand All @@ -128,13 +128,21 @@ message Params {
format: "sdk.Dec"
}];

// The smallest unit batch height for every liquidity pool
// The smallest unit batch height for every liquidity pool.
uint32 unit_batch_height = 9 [
(gogoproto.moretags) = "yaml:\"unit_batch_height\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"1\"",
format: "uint32"
}];

// Circuit breaker enables or disables transaction messages in liquidity module
bool circuit_breaker_enabled = 10 [
(gogoproto.moretags) = "yaml:\"circuit_breaker_enabled\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"false\"",
format: "bool"
}];
}

// The liquidity pool information
Expand Down Expand Up @@ -227,7 +235,7 @@ message PoolBatch {
format: "uint64"
}];

// height where this batch is begun
// height where this batch is started
int64 begin_height = 3 [(gogoproto.moretags) = "yaml:\"begin_height\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"1000\"",
Expand Down Expand Up @@ -255,14 +263,14 @@ message PoolBatch {
format: "uint64"
}];

// true if executed, false if not executed yet
// true if executed, false if not executed
bool executed = 7 [(gogoproto.moretags) = "yaml:\"executed\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "true",
}];
}

// DepositMsgState defines the state of the deposit message that contains the state information as it is processed in the next batch or batches
// DepositMsgState defines the state of the deposit message that contains the state information as the message is processed in the next batch or batches
message DepositMsgState {

// height where this message is appended to the batch
Expand All @@ -279,7 +287,7 @@ message DepositMsgState {
format: "uint64"
}];

// true if executed on this batch, false if not executed yet
// true if executed on this batch, false if not executed
bool executed = 3 [(gogoproto.moretags) = "yaml:\"executed\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "true",
Expand All @@ -301,7 +309,7 @@ message DepositMsgState {
MsgDepositWithinBatch msg = 6 [(gogoproto.moretags) = "yaml:\"msg\""];
}

// WithdrawMsgState defines the state of the withdraw message that contains state information as it is processed in the next batch or batches
// WithdrawMsgState defines the state of the withdraw message that contains state information as the message is processed in the next batch or batches
message WithdrawMsgState {

// height where this message is appended to the batch
Expand All @@ -318,7 +326,7 @@ message WithdrawMsgState {
format: "uint64"
}];

// true if executed on this batch, false if not executed yet
// true if executed on this batch, false if not executed
bool executed = 3 [(gogoproto.moretags) = "yaml:\"executed\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "true",
Expand All @@ -340,7 +348,7 @@ message WithdrawMsgState {
MsgWithdrawWithinBatch msg = 6 [(gogoproto.moretags) = "yaml:\"msg\""];
}

// SwapMsgState defines the state of swap message that contains state information as it is processed in the next batch or batches
// SwapMsgState defines the state of swap message that contains state information as the message is processed in the next batch or batches
message SwapMsgState {

// height where this message is appended to the batch
Expand All @@ -357,7 +365,7 @@ message SwapMsgState {
format: "uint64"
}];

// true if executed on this batch, false if not executed yet
// true if executed on this batch, false if not executed
bool executed = 3 [(gogoproto.moretags) = "yaml:\"executed\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "true",
Expand All @@ -375,7 +383,7 @@ message SwapMsgState {
example: "true",
}];

// swap orders are cancelled when current height is equal or higher than ExpiryHeight
// swap orders are cancelled when current height is equal to or higher than ExpiryHeight
int64 order_expiry_height = 6 [(gogoproto.moretags) = "yaml:\"order_expiry_height\"",
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"1000\"",
Expand Down
13 changes: 7 additions & 6 deletions x/liquidity/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ func (s *IntegrationTestSuite) SetupTest() {
cfg := liquiditytestutil.NewConfig(db)
cfg.NumValidators = 1

var liquidtyGenesisState liquiditytypes.GenesisState
err := cfg.Codec.UnmarshalJSON(cfg.GenesisState[liquiditytypes.ModuleName], &liquidtyGenesisState)
var liquidityGenState liquiditytypes.GenesisState
err := cfg.Codec.UnmarshalJSON(cfg.GenesisState[liquiditytypes.ModuleName], &liquidityGenState)
s.Require().NoError(err)

liquidtyGenesisState.Params = liquiditytypes.DefaultParams()
liquidityGenState.Params = liquiditytypes.DefaultParams()

cfg.GenesisState[liquiditytypes.ModuleName] = cfg.Codec.MustMarshalJSON(&liquidtyGenesisState)
cfg.GenesisState[liquiditytypes.ModuleName] = cfg.Codec.MustMarshalJSON(&liquidityGenState)
cfg.AccountTokens = sdk.NewInt(100_000_000_000) // node0token denom
cfg.StakingTokens = sdk.NewInt(100_000_000_000) // stake denom

Expand Down Expand Up @@ -480,12 +480,13 @@ func (s *IntegrationTestSuite) TestGetCmdQueryParams() {
{
"json output",
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
`{"pool_types":[{"id":1,"name":"DefaultPoolType","min_reserve_coin_num":2,"max_reserve_coin_num":2,"description":""}],"min_init_deposit_amount":"1000000","init_pool_coin_mint_amount":"1000000","max_reserve_coin_amount":"0","pool_creation_fee":[{"denom":"stake","amount":"100000000"}],"swap_fee_rate":"0.003000000000000000","withdraw_fee_rate":"0.003000000000000000","max_order_amount_ratio":"0.100000000000000000","unit_batch_height":1}`,
`{"pool_types":[{"id":1,"name":"DefaultPoolType","min_reserve_coin_num":2,"max_reserve_coin_num":2,"description":""}],"min_init_deposit_amount":"1000000","init_pool_coin_mint_amount":"1000000","max_reserve_coin_amount":"0","pool_creation_fee":[{"denom":"stake","amount":"100000000"}],"swap_fee_rate":"0.003000000000000000","withdraw_fee_rate":"0.003000000000000000","max_order_amount_ratio":"0.100000000000000000","unit_batch_height":1,"circuit_breaker_enabled":false}`,
},
{
"text output",
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
`init_pool_coin_mint_amount: "1000000"
`circuit_breaker_enabled: false
init_pool_coin_mint_amount: "1000000"
max_order_amount_ratio: "0.100000000000000000"
max_reserve_coin_amount: "0"
min_init_deposit_amount: "1000000"
Expand Down
Loading

0 comments on commit 096a0a0

Please sign in to comment.