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

fix: move DustCollectorAddress into params #186

Merged
merged 2 commits into from
Feb 14, 2022
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
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

42 changes: 24 additions & 18 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2775,15 +2775,17 @@ paths:
params:
type: object
properties:
initial_pool_coin_supply:
type: string
batch_size:
type: integer
format: int64
tick_precision:
type: integer
format: int64
min_initial_deposit_amount:
fee_collector_address:
type: string
dust_collector_address:
type: string
initial_pool_coin_supply:
type: string
pair_creation_fee:
type: array
Expand Down Expand Up @@ -2819,16 +2821,16 @@ paths:
custom method

signatures required by gogoproto.
fee_collector_address:
min_initial_deposit_amount:
type: string
max_price_limit_ratio:
type: string
max_order_lifespan:
type: string
swap_fee_rate:
type: string
withdraw_fee_rate:
type: string
max_order_lifespan:
type: string
description: Params defines the parameters for the liquidity module.
description: >-
QueryParamsResponse is response type for the Query/Params RPC
Expand Down Expand Up @@ -5488,15 +5490,17 @@ definitions:
squad.liquidity.v1beta1.Params:
type: object
properties:
initial_pool_coin_supply:
type: string
batch_size:
type: integer
format: int64
tick_precision:
type: integer
format: int64
min_initial_deposit_amount:
fee_collector_address:
type: string
dust_collector_address:
type: string
initial_pool_coin_supply:
type: string
pair_creation_fee:
type: array
Expand Down Expand Up @@ -5526,16 +5530,16 @@ definitions:

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
fee_collector_address:
min_initial_deposit_amount:
type: string
max_price_limit_ratio:
type: string
max_order_lifespan:
type: string
swap_fee_rate:
type: string
withdraw_fee_rate:
type: string
max_order_lifespan:
type: string
description: Params defines the parameters for the liquidity module.
squad.liquidity.v1beta1.PoolResponse:
type: object
Expand Down Expand Up @@ -6142,15 +6146,17 @@ definitions:
params:
type: object
properties:
initial_pool_coin_supply:
type: string
batch_size:
type: integer
format: int64
tick_precision:
type: integer
format: int64
min_initial_deposit_amount:
fee_collector_address:
type: string
dust_collector_address:
type: string
initial_pool_coin_supply:
type: string
pair_creation_fee:
type: array
Expand Down Expand Up @@ -6186,16 +6192,16 @@ definitions:
method

signatures required by gogoproto.
fee_collector_address:
min_initial_deposit_amount:
type: string
max_price_limit_ratio:
type: string
max_order_lifespan:
type: string
swap_fee_rate:
type: string
withdraw_fee_rate:
type: string
max_order_lifespan:
type: string
description: Params defines the parameters for the liquidity module.
description: QueryParamsResponse is response type for the Query/Params RPC method.
squad.liquidity.v1beta1.QueryPoolResponse:
Expand Down
28 changes: 15 additions & 13 deletions proto/squad/liquidity/v1beta1/liquidity.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,36 @@ option (gogoproto.goproto_getters_all) = false;

// Params defines the parameters for the liquidity module.
message Params {
string initial_pool_coin_supply = 1
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
uint32 batch_size = 1;

uint32 tick_precision = 2;

uint32 batch_size = 2;
string fee_collector_address = 3;

uint32 tick_precision = 3;
string dust_collector_address = 4;

string min_initial_deposit_amount = 4
string initial_pool_coin_supply = 5
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];

repeated cosmos.base.v1beta1.Coin pair_creation_fee = 5
repeated cosmos.base.v1beta1.Coin pair_creation_fee = 6
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];

repeated cosmos.base.v1beta1.Coin pool_creation_fee = 6
repeated cosmos.base.v1beta1.Coin pool_creation_fee = 7
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];

string fee_collector_address = 7;
string min_initial_deposit_amount = 8
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];

string max_price_limit_ratio = 8
string max_price_limit_ratio = 9
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];

string swap_fee_rate = 9
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
google.protobuf.Duration max_order_lifespan = 10 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];

string withdraw_fee_rate = 10
string swap_fee_rate = 11
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];

google.protobuf.Duration max_order_lifespan = 11 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
string withdraw_fee_rate = 12
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

// Pair defines a coin pair.
Expand Down
4 changes: 3 additions & 1 deletion x/liquidity/keeper/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ func (k Keeper) ApplyMatchResult(ctx sdk.Context, pair types.Pair, orders []amm.
bulkOp.SendCoins(pair.GetEscrowAddress(), order.ReserveAddress, sdk.NewCoins(order.ReceivedDemandCoin))
}
}
bulkOp.SendCoins(pair.GetEscrowAddress(), types.DustCollectorAddress, sdk.NewCoins(sdk.NewCoin(pair.QuoteCoinDenom, quoteCoinDust)))
params := k.GetParams(ctx)
dustCollectorAddr, _ := sdk.AccAddressFromBech32(params.DustCollectorAddress)
bulkOp.SendCoins(pair.GetEscrowAddress(), dustCollectorAddr, sdk.NewCoins(sdk.NewCoin(pair.QuoteCoinDenom, quoteCoinDust)))
if err := bulkOp.Run(ctx, k.bankKeeper); err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion x/liquidity/keeper/swap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ func (s *KeeperTestSuite) TestDustCollector() {
s.Require().True(coinsEq(squad.ParseCoins("900denom2"), s.getBalances(s.addr(2))))

s.Require().True(s.getBalances(pair.GetEscrowAddress()).IsZero())
s.Require().True(coinsEq(squad.ParseCoins("1denom2"), s.getBalances(types.DustCollectorAddress)))
params := s.keeper.GetParams(s.ctx)
dustCollectorAddr, _ := sdk.AccAddressFromBech32(params.DustCollectorAddress)
s.Require().True(coinsEq(squad.ParseCoins("1denom2"), s.getBalances(dustCollectorAddr)))
}

func (s *KeeperTestSuite) TestFitPrice() {
Expand Down
Loading