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

Feat/incentive apr #280

Merged
merged 8 commits into from
Nov 28, 2023
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
20 changes: 11 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,15 @@ func NewElysApp(
)
stablestake := stablestake.NewAppModule(appCodec, app.StablestakeKeeper, app.AccountKeeper, app.BankKeeper)

app.TokenomicsKeeper = *tokenomicsmodulekeeper.NewKeeper(
appCodec,
keys[tokenomicsmoduletypes.StoreKey],
keys[tokenomicsmoduletypes.MemStoreKey],
app.GetSubspace(tokenomicsmoduletypes.ModuleName),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
tokenomicsModule := tokenomicsmodule.NewAppModule(appCodec, app.TokenomicsKeeper, app.AccountKeeper, app.BankKeeper)

app.IncentiveKeeper = *incentivemodulekeeper.NewKeeper(
appCodec,
keys[incentivemoduletypes.StoreKey],
Expand All @@ -766,8 +775,10 @@ func NewElysApp(
app.AssetprofileKeeper,
app.EpochsKeeper,
app.StablestakeKeeper,
app.TokenomicsKeeper,
authtypes.FeeCollectorName,
DexRevenueCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
incentiveModule := incentivemodule.NewAppModule(appCodec, app.IncentiveKeeper)

Expand All @@ -779,15 +790,6 @@ func NewElysApp(

commitmentModule := commitmentmodule.NewAppModule(appCodec, app.CommitmentKeeper, app.AccountKeeper, app.BankKeeper)

app.TokenomicsKeeper = *tokenomicsmodulekeeper.NewKeeper(
appCodec,
keys[tokenomicsmoduletypes.StoreKey],
keys[tokenomicsmoduletypes.MemStoreKey],
app.GetSubspace(tokenomicsmoduletypes.ModuleName),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
tokenomicsModule := tokenomicsmodule.NewAppModule(appCodec, app.TokenomicsKeeper, app.AccountKeeper, app.BankKeeper)

app.BurnerKeeper = *burnermodulekeeper.NewKeeper(
appCodec,
keys[burnermoduletypes.StoreKey],
Expand Down
20 changes: 2 additions & 18 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,24 +287,8 @@ genesis:
amount: "200000"
incentive:
params:
lp_incentives:
- eden_amount_per_year: "10000000000000"
distribution_start_block: "1"
total_blocks_per_year: "10512000"
allocation_epoch_in_blocks: "28800"
max_eden_per_allocation: "27397238400"
distribution_epoch_in_blocks: "10"
current_epoch_in_blocks: "0"
eden_boost_apr: "1"
stake_incentives:
- eden_amount_per_year: "10000000000000"
distribution_start_block: "1"
total_blocks_per_year: "10512000"
allocation_epoch_in_blocks: "28800"
max_eden_per_allocation: "27397238400"
distribution_epoch_in_blocks: "20"
current_epoch_in_blocks: "0"
eden_boost_apr: "1"
lp_incentives: []
stake_incentives: []
community_tax: "0.00"
withdraw_addr_enabled: true
reward_portion_for_lps: "0.65"
Expand Down
47 changes: 41 additions & 6 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39622,9 +39622,20 @@ paths:
type: string
amount_collected_by_other_tracker:
type: string
max_eden_reward_apr:
max_eden_reward_apr_stakers:
type: string
title: Maximum eden reward apr
title: Maximum eden reward apr for stakers
max_eden_reward_apr_lps:
type: string
title: Maximum eden reward apr for lps
distribution_epoch_for_stakers_in_blocks:
type: string
format: int64
title: Distribution epochs for stakers in blocks
distribution_epoch_for_lps_in_blocks:
type: string
format: int64
title: Distribution epochs for LPs in blocks
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
Expand Down Expand Up @@ -84408,6 +84419,8 @@ definitions:
type: string
title: eden boost apr (0-1) range
title: Incentive Info
elys.incentive.MsgUpdateIncentiveParamsResponse:
type: object
elys.incentive.MsgWithdrawRewardsResponse:
type: object
description: >-
Expand Down Expand Up @@ -84532,9 +84545,20 @@ definitions:
type: string
amount_collected_by_other_tracker:
type: string
max_eden_reward_apr:
max_eden_reward_apr_stakers:
type: string
title: Maximum eden reward apr for stakers
max_eden_reward_apr_lps:
type: string
title: Maximum eden reward apr for lps
distribution_epoch_for_stakers_in_blocks:
type: string
title: Maximum eden reward apr
format: int64
title: Distribution epochs for stakers in blocks
distribution_epoch_for_lps_in_blocks:
type: string
format: int64
title: Distribution epochs for LPs in blocks
description: Params defines the parameters for the module.
elys.incentive.PoolInfo:
type: object
Expand Down Expand Up @@ -84686,9 +84710,20 @@ definitions:
type: string
amount_collected_by_other_tracker:
type: string
max_eden_reward_apr:
max_eden_reward_apr_stakers:
type: string
title: Maximum eden reward apr for stakers
max_eden_reward_apr_lps:
type: string
title: Maximum eden reward apr
title: Maximum eden reward apr for lps
distribution_epoch_for_stakers_in_blocks:
type: string
format: int64
title: Distribution epochs for stakers in blocks
distribution_epoch_for_lps_in_blocks:
type: string
format: int64
title: Distribution epochs for LPs in blocks
description: QueryParamsResponse is response type for the Query/Params RPC method.
elys.leveragelp.IsWhitelistedResponse:
type: object
Expand Down
16 changes: 14 additions & 2 deletions proto/elys/incentive/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,21 @@ message Params {
// Tracking dex rewards given to LPs
DexRewardsTracker dex_rewards_lps = 9 [(gogoproto.nullable) = false];

// Maximum eden reward apr
string max_eden_reward_apr = 10 [
// Maximum eden reward apr for stakers
string max_eden_reward_apr_stakers = 10 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Maximum eden reward apr for lps
string max_eden_reward_apr_lps = 11 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Distribution epochs for stakers in blocks
int64 distribution_epoch_for_stakers_in_blocks = 12;

// Distribution epochs for LPs in blocks
int64 distribution_epoch_for_lps_in_blocks = 13;
}
57 changes: 39 additions & 18 deletions proto/elys/incentive/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,63 @@ option go_package = "github.com/elys-network/elys/x/incentive/types";

// Msg defines the Msg service.
service Msg {

// WithdrawDelegatorReward defines a method to withdraw rewards of delegator
// from a single validator.
rpc WithdrawRewards(MsgWithdrawRewards) returns (MsgWithdrawRewardsResponse);

rpc WithdrawRewards (MsgWithdrawRewards) returns (MsgWithdrawRewardsResponse);
// WithdrawValidatorCommission defines a method to withdraw the
// full commission to the validator address.
rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse);

rpc WithdrawValidatorCommission (MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse);
rpc UpdateIncentiveParams (MsgUpdateIncentiveParams ) returns (MsgUpdateIncentiveParamsResponse );
}

// MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator
// from a single validator.
message MsgWithdrawRewards {
option (gogoproto.equal) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
elys.commitment.EarnType withdraw_type = 2;
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
elys.commitment.EarnType withdraw_type = 2;
}

// MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type.
message MsgWithdrawRewardsResponse {
}

message MsgWithdrawRewardsResponse {}

// MsgWithdrawValidatorCommission withdraws the full commission to the validator
// address.
message MsgWithdrawValidatorCommission {
option (gogoproto.equal) = false;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type.
message MsgWithdrawValidatorCommissionResponse {
message MsgWithdrawValidatorCommissionResponse {}

message MsgUpdateIncentiveParams {
string authority = 1;
string communityTax = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bool withdrawAddrEnabled = 3;
string rewardPortionForLps = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
int64 elysStakeTrackingRate = 5;
string maxEdenRewardAprStakers = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string maxEdenRewardAprLps = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
int64 distributionEpochForStakers = 8;
int64 distributionEpochForLps = 9;
}


message MsgUpdateIncentiveParamsResponse {}

4 changes: 4 additions & 0 deletions testutil/keeper/incentive.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/elys-network/elys/x/incentive/keeper"
"github.com/elys-network/elys/x/incentive/types"
Expand All @@ -29,6 +30,7 @@ func IncentiveKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {

registry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(registry)
govAddress := sdk.AccAddress(address.Module("gov"))

paramsSubspace := typesparams.NewSubspace(cdc,
types.Amino,
Expand All @@ -50,8 +52,10 @@ func IncentiveKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
nil,
nil,
nil,
nil,
"",
"",
govAddress.String(),
)

ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
Expand Down
1 change: 1 addition & 0 deletions x/incentive/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func GetTxCmd() *cobra.Command {
CmdUpdatePoolInfoProposal(),
)

cmd.AddCommand(CmdUpdateIncentiveParams())
// this line is used by starport scaffolding # 1

return cmd
Expand Down
Loading
Loading