Skip to content

Commit

Permalink
Feat/incentive (#40)
Browse files Browse the repository at this point in the history
* chore: 🤖 fix make install + version display

* add: scaffold incentive

* add: declare incentive params -LP &Stake

* add: implement hook interface functions in incentive module

* add: implement staking hook interface functions in incentive module

* add: add commitmentKeeper as incentive newkeeper param, declare keeper functions for staking hooks

* add: calls appropriate keeper functions ffrom hook functions

* fix: add one more param in calling newkeeper of testutil-incentive.go

* fix: remove exception handling for checking block height in hook functions in order to be succeed in unit test

---------

Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com>
  • Loading branch information
kenta-elys and cosmic-vagabond authored Apr 14, 2023
1 parent d114d36 commit ff0ef6b
Show file tree
Hide file tree
Showing 40 changed files with 3,158 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ import (
tokenomicsmodulekeeper "github.com/elys-network/elys/x/tokenomics/keeper"
tokenomicsmoduletypes "github.com/elys-network/elys/x/tokenomics/types"

incentivemodule "github.com/elys-network/elys/x/incentive"
incentivemodulekeeper "github.com/elys-network/elys/x/incentive/keeper"
incentivemoduletypes "github.com/elys-network/elys/x/incentive/types"

// this line is used by starport scaffolding # stargate/app/moduleImport

appparams "github.com/elys-network/elys/app/params"
Expand Down Expand Up @@ -188,6 +192,7 @@ var (
oraclemodule.AppModuleBasic{},
commitmentmodule.AppModuleBasic{},
tokenomicsmodule.AppModuleBasic{},
incentivemodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -273,6 +278,8 @@ type ElysApp struct {
CommitmentKeeper commitmentmodulekeeper.Keeper

TokenomicsKeeper tokenomicsmodulekeeper.Keeper

IncentiveKeeper incentivemodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// mm is the module manager
Expand Down Expand Up @@ -323,6 +330,7 @@ func NewElysApp(
oracletypes.StoreKey,
commitmentmoduletypes.StoreKey,
tokenomicsmoduletypes.StoreKey,
incentivemoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -561,12 +569,22 @@ func NewElysApp(
)
commitmentModule := commitmentmodule.NewAppModule(appCodec, app.CommitmentKeeper, app.AccountKeeper, app.BankKeeper)

app.IncentiveKeeper = *incentivemodulekeeper.NewKeeper(
appCodec,
keys[incentivemoduletypes.StoreKey],
keys[incentivemoduletypes.MemStoreKey],
app.GetSubspace(incentivemoduletypes.ModuleName),
app.CommitmentKeeper,
)
incentiveModule := incentivemodule.NewAppModule(appCodec, app.IncentiveKeeper, app.AccountKeeper, app.BankKeeper)

epochsKeeper := epochsmodulekeeper.NewKeeper(appCodec, keys[epochsmoduletypes.StoreKey])
app.EpochsKeeper = *epochsKeeper.SetHooks(
epochsmodulekeeper.NewMultiEpochHooks(
// insert epoch hooks receivers here
app.OracleKeeper.Hooks(),
app.CommitmentKeeper.Hooks(),
app.IncentiveKeeper.Hooks(),
),
)
epochsModule := epochsmodule.NewAppModule(appCodec, app.EpochsKeeper)
Expand Down Expand Up @@ -621,6 +639,7 @@ func NewElysApp(
// insert staking hooks receivers here
app.DistrKeeper.Hooks(),
app.SlashingKeeper.Hooks(),
app.IncentiveKeeper.StakingHooks(),
),
)

Expand Down Expand Up @@ -669,6 +688,7 @@ func NewElysApp(
oracleModule,
commitmentModule,
tokenomicsModule,
incentiveModule,
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -705,6 +725,7 @@ func NewElysApp(
oracletypes.ModuleName,
commitmentmoduletypes.ModuleName,
tokenomicsmoduletypes.ModuleName,
incentivemoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -736,6 +757,7 @@ func NewElysApp(
oracletypes.ModuleName,
commitmentmoduletypes.ModuleName,
tokenomicsmoduletypes.ModuleName,
incentivemoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -771,6 +793,7 @@ func NewElysApp(
oracletypes.ModuleName,
commitmentmoduletypes.ModuleName,
tokenomicsmoduletypes.ModuleName,
incentivemoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand Down Expand Up @@ -806,6 +829,7 @@ func NewElysApp(
oracleModule,
commitmentModule,
tokenomicsModule,
incentiveModule,
// this line is used by starport scaffolding # stargate/app/appModule
)
app.sm.RegisterStoreDecoders()
Expand Down Expand Up @@ -1015,6 +1039,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(oracletypes.ModuleName)
paramsKeeper.Subspace(commitmentmoduletypes.ModuleName)
paramsKeeper.Subspace(tokenomicsmoduletypes.ModuleName)
paramsKeeper.Subspace(incentivemoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
187 changes: 187 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33175,6 +33175,83 @@ paths:
type: boolean
tags:
- Query
/elys-network/elys/incentive/params:
get:
summary: Parameters queries the parameters of the module.
operationId: ElysnetworkElysIncentiveParams
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
properties:
LPIncentives:
type: array
items:
type: object
properties:
amount:
type: string
title: reward amount
epochIdentifier:
type: string
title: epoch identifier
start_time:
type: string
format: date-time
title: start_time of the distribution
numEpochs:
type: string
format: int64
title: distribution duration
title: Incentive Info
StakeIncentives:
type: array
items:
type: object
properties:
amount:
type: string
title: reward amount
epochIdentifier:
type: string
title: epoch identifier
start_time:
type: string
format: date-time
title: start_time of the distribution
numEpochs:
type: string
format: int64
title: distribution duration
title: Incentive Info
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
tags:
- Query
/elys-network/elys/liquidityprovider/params:
get:
summary: Parameters queries the parameters of the module.
Expand Down Expand Up @@ -69016,6 +69093,116 @@ definitions:
description: |-
QueryEpochsInfoResponse is the response type for the Query/EpochInfos RPC
method.
elysnetwork.elys.incentive.IncentiveInfo:
type: object
properties:
amount:
type: string
title: reward amount
epochIdentifier:
type: string
title: epoch identifier
start_time:
type: string
format: date-time
title: start_time of the distribution
numEpochs:
type: string
format: int64
title: distribution duration
title: Incentive Info
elysnetwork.elys.incentive.Params:
type: object
properties:
LPIncentives:
type: array
items:
type: object
properties:
amount:
type: string
title: reward amount
epochIdentifier:
type: string
title: epoch identifier
start_time:
type: string
format: date-time
title: start_time of the distribution
numEpochs:
type: string
format: int64
title: distribution duration
title: Incentive Info
StakeIncentives:
type: array
items:
type: object
properties:
amount:
type: string
title: reward amount
epochIdentifier:
type: string
title: epoch identifier
start_time:
type: string
format: date-time
title: start_time of the distribution
numEpochs:
type: string
format: int64
title: distribution duration
title: Incentive Info
description: Params defines the parameters for the module.
elysnetwork.elys.incentive.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
properties:
LPIncentives:
type: array
items:
type: object
properties:
amount:
type: string
title: reward amount
epochIdentifier:
type: string
title: epoch identifier
start_time:
type: string
format: date-time
title: start_time of the distribution
numEpochs:
type: string
format: int64
title: distribution duration
title: Incentive Info
StakeIncentives:
type: array
items:
type: object
properties:
amount:
type: string
title: reward amount
epochIdentifier:
type: string
title: epoch identifier
start_time:
type: string
format: date-time
title: start_time of the distribution
numEpochs:
type: string
format: int64
title: distribution duration
title: Incentive Info
description: QueryParamsResponse is response type for the Query/Params RPC method.
elysnetwork.elys.liquidityprovider.Params:
type: object
description: Params defines the parameters for the module.
Expand Down
12 changes: 12 additions & 0 deletions proto/elys/incentive/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package elysnetwork.elys.incentive;

import "gogoproto/gogo.proto";
import "elys/incentive/params.proto";

option go_package = "github.com/elys-network/elys/x/incentive/types";

// GenesisState defines the incentive module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
}
20 changes: 20 additions & 0 deletions proto/elys/incentive/incentive.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";
package elysnetwork.elys.incentive;
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/elys-network/elys/x/incentive/types";

// Incentive Info
message IncentiveInfo {
// reward amount
string amount = 1
[ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"amount\""];
// epoch identifier
string epochIdentifier = 2;
// start_time of the distribution
google.protobuf.Timestamp start_time = 3
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\""];
// distribution duration
int64 numEpochs = 4;
}
14 changes: 14 additions & 0 deletions proto/elys/incentive/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package elysnetwork.elys.incentive;

import "gogoproto/gogo.proto";
import "elys/incentive/incentive.proto";

option go_package = "github.com/elys-network/elys/x/incentive/types";

// Params defines the parameters for the module.
message Params {
option (gogoproto.goproto_stringer) = false;
repeated IncentiveInfo LPIncentives = 1 [(gogoproto.nullable) = false];
repeated IncentiveInfo StakeIncentives = 2 [(gogoproto.nullable) = false];
}
26 changes: 26 additions & 0 deletions proto/elys/incentive/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";
package elysnetwork.elys.incentive;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "elys/incentive/params.proto";

option go_package = "github.com/elys-network/elys/x/incentive/types";

// Query defines the gRPC querier service.
service Query {
// Parameters queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/elys-network/elys/incentive/params";
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}
Loading

0 comments on commit ff0ef6b

Please sign in to comment.