Skip to content

Commit

Permalink
WIP: add liquidation params for inflation rate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gsk967 committed Jul 13, 2023
1 parent fc7c1fc commit 0d519e7
Show file tree
Hide file tree
Showing 23 changed files with 1,749 additions and 115 deletions.
6 changes: 6 additions & 0 deletions proto/umee/ugov/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package umee.ugov.v1;
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "umee/ugov/v1/ugov.proto";

option go_package = "github.com/umee-network/umee/v5/x/ugov";
option (gogoproto.goproto_getters_all) = false;
Expand All @@ -17,3 +18,8 @@ message EventMinGasPrice {
message EventEmergencyGroup {
string emergency_group = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// EventLiquidationParams is emitted when GovUpdateLiquidationParams is correctly executed.
message EventLiquidationParams {
LiquidationParams liquidation_params = 1 [(gogoproto.nullable) = false];
}
5 changes: 5 additions & 0 deletions proto/umee/ugov/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package umee.ugov.v1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/duration.proto";

Check failure on line 6 in proto/umee/ugov/v1/genesis.proto

View workflow job for this annotation

GitHub Actions / buf-lint

Import "google/protobuf/duration.proto" is unused.
import "cosmos_proto/cosmos.proto";
import "umee/ugov/v1/ugov.proto";

option go_package = "github.com/umee-network/umee/v5/x/ugov";
option (gogoproto.goproto_getters_all) = false;
Expand All @@ -14,4 +16,7 @@ message GenesisState {

// Emergency Group address
string emergency_group = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// LiquidationParams is params for new liquidation inflation rate params for staking denoms
LiquidationParams liquidation_params = 3 [(gogoproto.nullable) = false];
}
14 changes: 14 additions & 0 deletions proto/umee/ugov/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "umee/ugov/v1/ugov.proto";

option go_package = "github.com/umee-network/umee/v5/x/ugov";

Expand All @@ -21,6 +22,11 @@ service Query {
rpc EmergencyGroup(QueryEmergencyGroup) returns (QueryEmergencyGroupResponse) {
option (google.api.http).get = "/umee/ugov/v1/emergency-group";
}

// LiquidationParams
rpc LiquidationParams(QueryLiquidationParams) returns (QueryLiquidationParamsResponse) {
option (google.api.http).get = "/umee/ugov/v1/liquidation-params";
}
}

// QueryMinGasPrice is a request type.
Expand All @@ -38,3 +44,11 @@ message QueryEmergencyGroup {}
message QueryEmergencyGroupResponse {
string emergency_group = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// QueryLiquidationParams request type.
message QueryLiquidationParams {}

// QueryLiquidationParamsResponse response type.
message QueryLiquidationParamsResponse {
LiquidationParams liquidation_params = 1 [(gogoproto.nullable) = false];
}
16 changes: 16 additions & 0 deletions proto/umee/ugov/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "umee/ugov/v1/ugov.proto";

option go_package = "github.com/umee-network/umee/v5/x/ugov";

Expand All @@ -17,6 +18,9 @@ service Msg {

// GovSetEmergencyGroup sets emergency group address.
rpc GovSetEmergencyGroup(MsgGovSetEmergencyGroup) returns (MsgGovSetEmergencyGroupResponse);

// GovUpdateLiquidationParams sets new liquidation params for inflation
rpc GovUpdateLiquidationParams(MsgGovUpdateLiquidationParams) returns (GovUpdateLiquidationParamsResponse);
}

// MsgGovUpdateMinGasPrice request type.
Expand All @@ -43,3 +47,15 @@ message MsgGovSetEmergencyGroup {

// MsgGovSetEmergencyGroupResponse response type.
message MsgGovSetEmergencyGroupResponse {};

// MsgGovUpdateLiquidationParams request type.
message MsgGovUpdateLiquidationParams {
option (cosmos.msg.v1.signer) = "authority";

// authority must be the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
LiquidationParams liquidation_params = 2 [(gogoproto.nullable) = false];
}

// GovUpdateLiquidationParamsResponse response type.
message GovUpdateLiquidationParamsResponse {}
29 changes: 29 additions & 0 deletions proto/umee/ugov/v1/ugov.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
syntax = "proto3";
package umee.ugov.v1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/duration.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/umee-network/umee/v5/x/ugov";
option (gogoproto.goproto_getters_all) = false;

// LiquidationParams
message LiquidationParams {
// max_supply is the maximum supply for liquidation.
cosmos.base.v1beta1.Coin max_supply = 1 [(gogoproto.nullable) = false];
// inflation_cycle_duration is duration for changing the inflation rates for liquidation.
google.protobuf.Duration inflation_cycle_duration = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "inflation_cycle_duration,omitempty",
(gogoproto.moretags) = "yaml:\"inflation_cycle_duration\""
];
// inflation_reduction_rate is reduction rate for inflation every inflation cycle.
string inflation_reduction_rate = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
24 changes: 24 additions & 0 deletions x/ugov/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func GetQueryCmd() *cobra.Command {

cmd.AddCommand(
QueryMinGasPrice(),
QueryLiquidationParams(),
)

return cmd
Expand Down Expand Up @@ -49,3 +50,26 @@ func QueryMinGasPrice() *cobra.Command {

return cmd
}

// QueryLiquidationParams create the Msg/QueryLiquidationParams CLI.
func QueryLiquidationParams() *cobra.Command {
cmd := &cobra.Command{
Use: "liquidation-params",
Args: cobra.NoArgs,
Short: "Query the liquidation params",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := ugov.NewQueryClient(clientCtx)
resp, err := queryClient.LiquidationParams(cmd.Context(), &ugov.QueryLiquidationParams{})
return cli.PrintOrErr(resp, err, clientCtx)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
2 changes: 2 additions & 0 deletions x/ugov/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ func init() {
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgGovUpdateMinGasPrice{}, proto.MessageName(&MsgGovUpdateMinGasPrice{}), nil)
cdc.RegisterConcrete(&MsgGovSetEmergencyGroup{}, "umee/ugov/MsgGovSetEmergencyGroup", nil)
cdc.RegisterConcrete(&MsgGovUpdateLiquidationParams{}, "umee/ugov/MsgGovUpdateLiquidationParams", nil)
}

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgGovUpdateMinGasPrice{},
&MsgGovSetEmergencyGroup{},
&MsgGovUpdateLiquidationParams{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
Expand Down
Loading

0 comments on commit 0d519e7

Please sign in to comment.