-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat(dividends): module scaffolding #686
Draft
keruch
wants to merge
5
commits into
main
Choose a base branch
from
kirill/dividends
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
288323b
feat(dividends): module scaffolding
keruch 6b9867e
feat(dividends): msg server and epoch hooks
keruch a27d903
module basic, validation, scaffolding tests
keruch ebb927f
begin block and epoch hook
keruch bb9f4ea
msg server tests
keruch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
752 changes: 752 additions & 0 deletions
752
github.com/dymensionxyz/dymension-rdk/x/dividends/types/events.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
1,777 changes: 1,777 additions & 0 deletions
1,777
github.com/dymensionxyz/dymension-rdk/x/dividends/types/gauge.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
427 changes: 427 additions & 0 deletions
427
github.com/dymensionxyz/dymension-rdk/x/dividends/types/genesis.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
syntax = "proto3"; | ||
package rollapp.dividends; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "dividends/gauge.proto"; | ||
|
||
option go_package = "github.com/dymensionxyz/dymension-rdk/x/dividends/types"; | ||
|
||
message EventUpdateParams { | ||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
Params new_params = 2 [ (gogoproto.nullable) = false ]; | ||
Params old_params = 3 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
message EventCreateGauge { | ||
// Authority is the address that controls the module. | ||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
// query_condition is *where* the gauge rewards are distributed to | ||
QueryCondition query_condition = 2 [ (gogoproto.nullable) = false ]; | ||
// vesting_condition is *how long* the gauge rewards are distributed to | ||
VestingCondition vesting_condition = 3 [ (gogoproto.nullable) = false ]; | ||
// vesting_condition is *how frequent* the gauge rewards are distributed to | ||
VestingFrequency vesting_frequency = 4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
syntax = "proto3"; | ||
package rollapp.dividends; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/dymensionxyz/dymension-rdk/x/dividends/types"; | ||
|
||
// Params holds parameters for the incentives module | ||
message Params { | ||
// distr_epoch_identifier is what epoch type distribution will be triggered by | ||
// (day, week, etc.) | ||
string distr_epoch_identifier = 1; | ||
// approved_denoms is a list of allowed tokens: only gov can approve tokens | ||
// that can be used for dividends | ||
repeated string approved_denoms = 2; | ||
} | ||
|
||
// Gauge is an object that stores and distributes yields to recipients who | ||
// satisfy certain conditions. | ||
message Gauge { | ||
// id is the unique ID of a gauge | ||
uint64 id = 1; | ||
// address is a bech32-formatted address that holds the tokens to allocate | ||
string address = 2; | ||
// query_condition is *where* the gauge rewards are distributed to | ||
QueryCondition query_condition = 3 [ (gogoproto.nullable) = false ]; | ||
// vesting_condition is *how long* the gauge rewards are distributed to | ||
VestingCondition vesting_condition = 4 [ (gogoproto.nullable) = false ]; | ||
// vesting_condition is *how frequent* the gauge rewards are distributed to | ||
VestingFrequency vesting_frequency = 5; | ||
} | ||
|
||
message QueryCondition { | ||
oneof condition { | ||
QueryConditionStakers stakers = 1; | ||
} | ||
} | ||
|
||
message VestingCondition { | ||
oneof condition { | ||
VestingConditionPerpetual perpetual = 1; | ||
VestingConditionLimited limited = 2; | ||
} | ||
} | ||
|
||
enum VestingFrequency { | ||
VESTING_FREQUENCY_UNSPECIFIED = 0; | ||
VESTING_FREQUENCY_BLOCK = 1; | ||
VESTING_FREQUENCY_EPOCH = 2; | ||
} | ||
|
||
// QueryConditionStakers queries the stakers | ||
message QueryConditionStakers {} | ||
|
||
// VestingConditionPerpetual is a vesting condition that distributes rewards | ||
// infinitely. Perpetual gauges distribute all their tokens at a single time | ||
// and only distribute their tokens again once the gauge is refilled. | ||
// | ||
// Non-perpetual gauges distribute their tokens equally per period while the | ||
// gauge is in the active period. Perpetual gauges distribute all their tokens | ||
// at a single time and only distribute their tokens again once the gauge is | ||
// refilled. | ||
message VestingConditionPerpetual {} | ||
|
||
// VestingConditionLimited is a vesting condition that distributes rewards over | ||
// the specified time. Non-perpetual gauges distribute their tokens equally per | ||
// period while the gauge is in the active period. | ||
message VestingConditionLimited { | ||
// num_units is the number of total epochs/blocks distribution will be | ||
// completed over | ||
int64 num_units = 1; | ||
// filled_epochs is the number of epochs/blocks distribution has been | ||
// completed on already | ||
int64 filled_units = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
syntax = "proto3"; | ||
package rollapp.dividends; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "dividends/gauge.proto"; | ||
|
||
option go_package = "github.com/dymensionxyz/dymension-rdk/x/dividends/types"; | ||
|
||
// GenesisState defines the incentives module's various parameters when first | ||
// initialized | ||
message GenesisState { | ||
// params are all the parameters of the module | ||
Params params = 1 [ (gogoproto.nullable) = false ]; | ||
// gauges are all gauges that should exist at genesis | ||
repeated Gauge gauges = 2 [ (gogoproto.nullable) = false ]; | ||
// last_gauge_id is what the gauge number will increment from when creating | ||
// the next gauge after genesis | ||
uint64 last_gauge_id = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
syntax = "proto3"; | ||
package rollapp.dividends; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "cosmos/base/query/v1beta1/pagination.proto"; | ||
import "dividends/gauge.proto"; | ||
|
||
option go_package = "github.com/dymensionxyz/dymension-rdk/x/dividends/types"; | ||
|
||
// Query defines the gRPC querier service | ||
service Query { | ||
rpc GaugeByID(GaugeByIDRequest) returns (GaugeByIDResponse) { | ||
option (google.api.http).get = "/rollapp/dividends/gauge_by_id/{id}"; | ||
} | ||
|
||
rpc Gauges(GaugesRequest) returns (GaugesResponse) { | ||
option (google.api.http).get = "/rollapp/dividends/gauges"; | ||
} | ||
|
||
rpc Params(ParamsRequest) returns (ParamsResponse) { | ||
option (google.api.http).get = "/rollapp/dividends/params"; | ||
} | ||
} | ||
|
||
message GaugeByIDRequest { | ||
uint64 id = 1; | ||
} | ||
|
||
message GaugeByIDResponse { | ||
Gauge gauge = 1 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
message GaugesRequest { | ||
cosmos.base.query.v1beta1.PageRequest pagination = 1; | ||
} | ||
|
||
message GaugesResponse { | ||
repeated Gauge data = 1 [ (gogoproto.nullable) = false ]; | ||
cosmos.base.query.v1beta1.PageResponse pagination = 2; | ||
} | ||
|
||
message ParamsRequest {} | ||
|
||
message ParamsResponse { | ||
Params params = 1 [ (gogoproto.nullable) = false ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
syntax = "proto3"; | ||
package rollapp.dividends; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/msg/v1/msg.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "dividends/gauge.proto"; | ||
|
||
option go_package = "github.com/dymensionxyz/dymension-rdk/x/dividends/types"; | ||
|
||
service Msg { | ||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); | ||
rpc CreateGauge(MsgCreateGauge) returns (MsgCreateGaugeResponse); | ||
} | ||
|
||
// MsgCreateGauge creates a gague to distribute rewards to users | ||
message MsgCreateGauge { | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
// Authority is the address that controls the module. | ||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
// query_condition is *where* the gauge rewards are distributed to | ||
QueryCondition query_condition = 2 [ (gogoproto.nullable) = false ]; | ||
// vesting_condition is *how long* the gauge rewards are distributed to | ||
VestingCondition vesting_condition = 3 [ (gogoproto.nullable) = false ]; | ||
// vesting_condition is *how frequent* the gauge rewards are distributed to | ||
VestingFrequency vesting_frequency = 4; | ||
} | ||
|
||
message MsgCreateGaugeResponse {} | ||
|
||
// MsgUpdateParams allows to update module params. | ||
message MsgUpdateParams { | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
|
||
// Authority is the address that controls the module. | ||
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
// NewParams should be fully populated. | ||
Params new_params = 2 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
message MsgUpdateParamsResponse {} |
Submodule cosmos_tmp
added at
c7b003
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Calling the system time Warning test