diff --git a/app/app.go b/app/app.go index 20b03a4ec..906e79814 100644 --- a/app/app.go +++ b/app/app.go @@ -612,6 +612,7 @@ func NewElysApp( appCodec, keys[estakingmoduletypes.StoreKey], keys[estakingmoduletypes.MemStoreKey], + app.ParameterKeeper, app.StakingKeeper, &app.CommitmentKeeper, &app.DistrKeeper, @@ -816,6 +817,7 @@ func NewElysApp( keys[masterchefmoduletypes.StoreKey], keys[masterchefmoduletypes.MemStoreKey], app.GetSubspace(masterchefmoduletypes.ModuleName), + app.ParameterKeeper, app.CommitmentKeeper, app.AmmKeeper, app.OracleKeeper, @@ -838,6 +840,7 @@ func NewElysApp( appCodec, keys[incentivemoduletypes.StoreKey], keys[incentivemoduletypes.MemStoreKey], + app.ParameterKeeper, commitmentKeeper, app.StakingKeeper, app.AccountKeeper, diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 0c9da604a..7a5efed7a 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -41865,6 +41865,8 @@ paths: format: uint64 amount_per_block: type: string + apr: + type: string description: ExternalIncentive defines the external incentives. default: description: An unexpected error response. @@ -42994,6 +42996,9 @@ paths: type: string broker_address: type: string + total_blocks_per_year: + type: string + format: int64 description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -86919,6 +86924,8 @@ definitions: format: uint64 amount_per_block: type: string + apr: + type: string description: ExternalIncentive defines the external incentives. elys.masterchef.IncentiveInfo: type: object @@ -87095,6 +87102,8 @@ definitions: format: uint64 amount_per_block: type: string + apr: + type: string description: ExternalIncentive defines the external incentives. elys.masterchef.QueryParamsResponse: type: object @@ -87706,6 +87715,8 @@ definitions: type: object elys.parameter.MsgUpdateMinSelfDelegationResponse: type: object + elys.parameter.MsgUpdateTotalBlocksPerYearResponse: + type: object elys.parameter.Params: type: object properties: @@ -87717,6 +87728,9 @@ definitions: type: string broker_address: type: string + total_blocks_per_year: + type: string + format: int64 description: Params defines the parameters for the module. elys.parameter.QueryParamsResponse: type: object @@ -87733,6 +87747,9 @@ definitions: type: string broker_address: type: string + total_blocks_per_year: + type: string + format: int64 description: QueryParamsResponse is response type for the Query/Params RPC method. elys.perpetual.IsWhitelistedResponse: type: object diff --git a/proto/elys/masterchef/external_incentive.proto b/proto/elys/masterchef/external_incentive.proto index 7f3f7a4ca..30f218e6b 100644 --- a/proto/elys/masterchef/external_incentive.proto +++ b/proto/elys/masterchef/external_incentive.proto @@ -14,4 +14,6 @@ message ExternalIncentive { uint64 to_block = 5; string amount_per_block = 6 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string apr = 7 + [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; } diff --git a/proto/elys/masterchef/genesis.proto b/proto/elys/masterchef/genesis.proto index e8b5bc53c..01e9fc9f1 100644 --- a/proto/elys/masterchef/genesis.proto +++ b/proto/elys/masterchef/genesis.proto @@ -12,7 +12,8 @@ option go_package = "github.com/elys-network/elys/x/masterchef/types"; message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; repeated ExternalIncentive external_incentives = 2 [(gogoproto.nullable) = false]; - repeated PoolInfo pool_infos = 3 [(gogoproto.nullable) = false]; - repeated PoolRewardInfo pool_reward_infos = 4 [(gogoproto.nullable) = false]; - repeated UserRewardInfo user_reward_infos = 5 [(gogoproto.nullable) = false]; + uint64 external_incentive_index = 3; + repeated PoolInfo pool_infos = 4 [(gogoproto.nullable) = false]; + repeated PoolRewardInfo pool_reward_infos = 5 [(gogoproto.nullable) = false]; + repeated UserRewardInfo user_reward_infos = 6 [(gogoproto.nullable) = false]; } diff --git a/proto/elys/parameter/params.proto b/proto/elys/parameter/params.proto index 384d12a68..ad4717ceb 100644 --- a/proto/elys/parameter/params.proto +++ b/proto/elys/parameter/params.proto @@ -22,4 +22,5 @@ message Params { (gogoproto.nullable) = false ]; string broker_address = 4; + int64 total_blocks_per_year = 5; } diff --git a/proto/elys/parameter/tx.proto b/proto/elys/parameter/tx.proto index b16d953bd..fdb1ac680 100644 --- a/proto/elys/parameter/tx.proto +++ b/proto/elys/parameter/tx.proto @@ -9,6 +9,7 @@ service Msg { rpc UpdateMaxVotingPower(MsgUpdateMaxVotingPower) returns (MsgUpdateMaxVotingPowerResponse); rpc UpdateMinSelfDelegation(MsgUpdateMinSelfDelegation) returns (MsgUpdateMinSelfDelegationResponse); rpc UpdateBrokerAddress(MsgUpdateBrokerAddress) returns (MsgUpdateBrokerAddressResponse); + rpc UpdateTotalBlocksPerYear(MsgUpdateTotalBlocksPerYear) returns (MsgUpdateTotalBlocksPerYearResponse); } message MsgUpdateMinCommission { @@ -19,18 +20,24 @@ message MsgUpdateMinCommissionResponse {} message MsgUpdateMaxVotingPower { string creator = 1; - string max_voting_power = 3; + string max_voting_power = 2; } message MsgUpdateMaxVotingPowerResponse {} message MsgUpdateMinSelfDelegation { string creator = 1; - string min_self_delegation = 3; + string min_self_delegation = 2; } message MsgUpdateMinSelfDelegationResponse {} message MsgUpdateBrokerAddress { string creator = 1; - string broker_address = 3; + string broker_address = 2; } -message MsgUpdateBrokerAddressResponse {} \ No newline at end of file +message MsgUpdateBrokerAddressResponse {} + +message MsgUpdateTotalBlocksPerYear { + string creator = 1; + int64 total_blocks_per_year = 2; +} +message MsgUpdateTotalBlocksPerYearResponse {} \ No newline at end of file diff --git a/scripts/examples/estaking/estaking.sh b/scripts/examples/estaking/estaking.sh index eb65eb84e..2e06c82ef 100644 --- a/scripts/examples/estaking/estaking.sh +++ b/scripts/examples/estaking/estaking.sh @@ -27,4 +27,5 @@ elysd tx commitment commit-claimed-rewards 1678547 uedenb --from=treasury --keyr # Pay 10000 uusdc as gas fees elysd tx staking delegate $VALIDATOR 1000uelys --fees=10000uusdc --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 -elysd query estaking rewards $TREASURY \ No newline at end of file +elysd query estaking rewards $TREASURY +elysd tx estaking withdraw-all-rewards --from=validator --chain-id=elystestnet-1 diff --git a/testutil/keeper/estaking.go b/testutil/keeper/estaking.go index 61739969a..b7c90d423 100644 --- a/testutil/keeper/estaking.go +++ b/testutil/keeper/estaking.go @@ -38,6 +38,7 @@ func EstakingKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { nil, nil, nil, + nil, "", ) diff --git a/testutil/keeper/incentive.go b/testutil/keeper/incentive.go index 79421d89b..8ea75d77f 100644 --- a/testutil/keeper/incentive.go +++ b/testutil/keeper/incentive.go @@ -47,6 +47,7 @@ func IncentiveKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { nil, nil, nil, + nil, "", govAddress.String(), ) diff --git a/testutil/keeper/masterchef.go b/testutil/keeper/masterchef.go index 4235b5796..d15a71b88 100644 --- a/testutil/keeper/masterchef.go +++ b/testutil/keeper/masterchef.go @@ -50,6 +50,7 @@ func MasterchefKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { nil, nil, nil, + nil, "", ) diff --git a/x/estaking/client/cli/query.go b/x/estaking/client/cli/query.go index bedc2d57f..f38f8441d 100644 --- a/x/estaking/client/cli/query.go +++ b/x/estaking/client/cli/query.go @@ -2,12 +2,12 @@ package cli import ( "fmt" - // "strings" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" "github.com/elys-network/elys/x/estaking/types" @@ -32,3 +32,58 @@ func GetQueryCmd(queryRoute string) *cobra.Command { return cmd } + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "rewards [address]", + Short: "shows the rewards of an account", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.Rewards(cmd.Context(), &types.QueryRewardsRequest{ + Address: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/estaking/client/cli/query_params.go b/x/estaking/client/cli/query_params.go deleted file mode 100644 index 75a954b41..000000000 --- a/x/estaking/client/cli/query_params.go +++ /dev/null @@ -1,64 +0,0 @@ -package cli - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - - "github.com/elys-network/elys/x/estaking/types" -) - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdQueryRewards() *cobra.Command { - cmd := &cobra.Command{ - Use: "rewards", - Short: "shows the rewards of an account", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.Rewards(cmd.Context(), &types.QueryRewardsRequest{ - Address: args[0], - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/estaking/client/wasm/msg_withdraw_elys_staking_rewards.go b/x/estaking/client/wasm/msg_withdraw_elys_staking_rewards.go index b1b1c4bc1..0d99b3a73 100644 --- a/x/estaking/client/wasm/msg_withdraw_elys_staking_rewards.go +++ b/x/estaking/client/wasm/msg_withdraw_elys_staking_rewards.go @@ -23,12 +23,12 @@ func (m *Messenger) msgWithdrawElysStakingRewards(ctx sdk.Context, contractAddr res, err = performMsgWithdrawElysStakingRewards(m.keeper, ctx, contractAddr, msgWithdrawElysStakingRewards) if err != nil { - return nil, nil, errorsmod.Wrap(err, "perform elys claim rewards") + return nil, nil, errorsmod.Wrap(err, "perform msgWithdrawElysStakingRewards") } responseBytes, err := json.Marshal(*res) if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize stake") + return nil, nil, errorsmod.Wrap(err, "failed to serialize msgWithdrawElysStakingRewards response") } resp := [][]byte{responseBytes} diff --git a/x/estaking/client/wasm/msg_withdraw_reward.go b/x/estaking/client/wasm/msg_withdraw_reward.go index ed4bbc0f7..2cd76f5a9 100644 --- a/x/estaking/client/wasm/msg_withdraw_reward.go +++ b/x/estaking/client/wasm/msg_withdraw_reward.go @@ -23,12 +23,12 @@ func (m *Messenger) msgWithdrawReward(ctx sdk.Context, contractAddr sdk.AccAddre res, err = performMsgWithdrawReward(m.keeper, ctx, contractAddr, msgWithdrawReward) if err != nil { - return nil, nil, errorsmod.Wrap(err, "perform elys claim rewards") + return nil, nil, errorsmod.Wrap(err, "perform msgWithdrawReward") } responseBytes, err := json.Marshal(*res) if err != nil { - return nil, nil, errorsmod.Wrap(err, "failed to serialize stake") + return nil, nil, errorsmod.Wrap(err, "failed to serialize msgWithdrawReward response") } resp := [][]byte{responseBytes} diff --git a/x/estaking/keeper/abci.go b/x/estaking/keeper/abci.go index e672a9a47..5154ed185 100644 --- a/x/estaking/keeper/abci.go +++ b/x/estaking/keeper/abci.go @@ -1,8 +1,6 @@ package keeper import ( - "errors" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -48,25 +46,19 @@ func (k Keeper) BurnEdenBIfElysStakingReduced(ctx sdk.Context) { // Rewards distribution func (k Keeper) ProcessRewardsDistribution(ctx sdk.Context) { // Read tokenomics time based inflation params and update incentive module params. - if !k.ProcessUpdateIncentiveParams(ctx) { - ctx.Logger().Error("Invalid tokenomics params", "error", errors.New("invalid tokenomics params")) - return - } + k.ProcessUpdateIncentiveParams(ctx) - canDistribute := k.CanDistributeStakingRewards(ctx) - if canDistribute { - err := k.UpdateStakersRewards(ctx) - if err != nil { - ctx.Logger().Error("Failed to update staker rewards unclaimed", "error", err) - } + err := k.UpdateStakersRewards(ctx) + if err != nil { + ctx.Logger().Error("Failed to update staker rewards unclaimed", "error", err) } } -func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool { +func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) { // Non-linear inflation per year happens and this includes yearly inflation data listTimeBasedInflations := k.tokenomicsKeeper.GetAllTimeBasedInflation(ctx) - if len(listTimeBasedInflations) < 1 { - return false + if len(listTimeBasedInflations) == 0 { + return } params := k.GetParams(ctx) @@ -86,65 +78,18 @@ func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool { // ------------- Stakers parameter ------------- blocksDistributed := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)) - incentiveInfo := types.IncentiveInfo{ + params.StakeIncentives = &types.IncentiveInfo{ EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.IcsStakingRewards)), DistributionStartBlock: sdk.NewInt(int64(inflation.StartBlockHeight)), TotalBlocksPerYear: totalBlocksPerYear, BlocksDistributed: blocksDistributed, } - - if params.StakeIncentives == nil { - params.StakeIncentives = &incentiveInfo - } else { - // If any of block number related parameter changed, we re-calculate the current epoch - if params.StakeIncentives.DistributionStartBlock != incentiveInfo.DistributionStartBlock || - params.StakeIncentives.TotalBlocksPerYear != incentiveInfo.TotalBlocksPerYear { - params.StakeIncentives.BlocksDistributed = blocksDistributed - } - params.StakeIncentives.EdenAmountPerYear = incentiveInfo.EdenAmountPerYear - params.StakeIncentives.DistributionStartBlock = incentiveInfo.DistributionStartBlock - params.StakeIncentives.TotalBlocksPerYear = incentiveInfo.TotalBlocksPerYear - } - break - } - - k.SetParams(ctx, params) - return true -} - -func (k Keeper) CanDistributeStakingRewards(ctx sdk.Context) bool { - // Fetch incentive params - params := k.GetParams(ctx) - if ctx.BlockHeight() < 1 { - return false - } - - // If we don't have enough params - if params.StakeIncentives == nil { - return false - } - - // Incentive params initialize - stakeIncentive := params.StakeIncentives - - curBlockHeight := sdk.NewInt(ctx.BlockHeight()) - if stakeIncentive.DistributionStartBlock.GT(curBlockHeight) { - return false - } - - // Increase current epoch of Stake incentive param - stakeIncentive.BlocksDistributed = stakeIncentive.BlocksDistributed.Add(sdk.OneInt()) - if stakeIncentive.BlocksDistributed.GTE(stakeIncentive.TotalBlocksPerYear) || curBlockHeight.GT(stakeIncentive.TotalBlocksPerYear.Add(stakeIncentive.DistributionStartBlock)) { - params.StakeIncentives = nil k.SetParams(ctx, params) - return false + return } - params.StakeIncentives.BlocksDistributed = stakeIncentive.BlocksDistributed + params.StakeIncentives = nil k.SetParams(ctx, params) - - // return found, stake incentive params - return true } func (k Keeper) UpdateStakersRewards(ctx sdk.Context) error { @@ -163,29 +108,29 @@ func (k Keeper) UpdateStakersRewards(ctx sdk.Context) error { params := k.GetParams(ctx) stakeIncentive := params.StakeIncentives - // Ensure stakeIncentive.TotalBlocksPerYear are not zero to avoid division by zero - if stakeIncentive.TotalBlocksPerYear.IsZero() { - return errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid inflationary params") - } + // Ensure totalBlocksPerYear are not zero to avoid division by zero + totalBlocksPerYear := k.parameterKeeper.GetParams(ctx).TotalBlocksPerYear // Calculate - stakersEdenAmount := stakeIncentive.EdenAmountPerYear. - Quo(stakeIncentive.TotalBlocksPerYear) + edenAmountPerYear := sdk.ZeroInt() + if stakeIncentive != nil && stakeIncentive.EdenAmountPerYear.IsPositive() { + edenAmountPerYear = stakeIncentive.EdenAmountPerYear + } + stakersEdenAmount := edenAmountPerYear.Quo(sdk.NewInt(totalBlocksPerYear)) // Maximum eden APR - 30% by default - // Allocated for staking per day = (0.3/365)* ( total elys staked + total Eden committed + total Eden boost committed) totalElysEdenEdenBStake := k.TotalBondedTokens(ctx) stakersMaxEdenAmount := params.MaxEdenRewardAprStakers. MulInt(totalElysEdenEdenBStake). - QuoInt(stakeIncentive.TotalBlocksPerYear) + QuoInt64(totalBlocksPerYear) // Use min amount (eden allocation from tokenomics and max apr based eden amount) stakersEdenAmount = sdk.MinInt(stakersEdenAmount, stakersMaxEdenAmount.TruncateInt()) stakersEdenBAmount := sdk.NewDecFromInt(totalElysEdenEdenBStake). Mul(params.EdenBoostApr). - QuoInt(stakeIncentive.TotalBlocksPerYear). + QuoInt64(totalBlocksPerYear). RoundInt() // Set block number and total dex rewards given diff --git a/x/estaking/keeper/hooks.go b/x/estaking/keeper/hooks.go index 5d17df2a2..ef061320f 100644 --- a/x/estaking/keeper/hooks.go +++ b/x/estaking/keeper/hooks.go @@ -71,7 +71,7 @@ func (k Keeper) BeforeEdenCommitChange(ctx sdk.Context, addr sdk.AccAddress) err params := k.GetParams(ctx) edenValAddr, err := sdk.ValAddressFromBech32(params.EdenCommitVal) if err != nil { - panic(err) + return err } err = k.Keeper.Hooks().BeforeDelegationSharesModified(ctx, addr, edenValAddr) if err != nil { @@ -84,7 +84,7 @@ func (k Keeper) BeforeEdenBCommitChange(ctx sdk.Context, addr sdk.AccAddress) er params := k.GetParams(ctx) edenBValAddr, err := sdk.ValAddressFromBech32(params.EdenbCommitVal) if err != nil { - panic(err) + return err } err = k.Keeper.Hooks().BeforeDelegationSharesModified(ctx, addr, edenBValAddr) if err != nil { diff --git a/x/estaking/keeper/keeper.go b/x/estaking/keeper/keeper.go index 022c08389..faeb91a57 100644 --- a/x/estaking/keeper/keeper.go +++ b/x/estaking/keeper/keeper.go @@ -26,6 +26,7 @@ type ( cdc codec.BinaryCodec storeKey storetypes.StoreKey memKey storetypes.StoreKey + parameterKeeper types.ParameterKeeper commKeeper types.CommitmentKeeper distrKeeper types.DistrKeeper tokenomicsKeeper types.TokenomicsKeeper @@ -62,6 +63,7 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey, + parameterKeeper types.ParameterKeeper, stakingKeeper *stakingkeeper.Keeper, commKeeper types.CommitmentKeeper, distrKeeper types.DistrKeeper, @@ -74,6 +76,7 @@ func NewKeeper( cdc: cdc, storeKey: storeKey, memKey: memKey, + parameterKeeper: parameterKeeper, commKeeper: commKeeper, authority: authority, distrKeeper: distrKeeper, @@ -293,22 +296,22 @@ func (k Keeper) WithdrawEdenReward(ctx sdk.Context, addr sdk.AccAddress) error { } func (k Keeper) DelegationRewards(ctx sdk.Context, delegatorAddress string, validatorAddress string) (sdk.DecCoins, error) { - valAdr, err := sdk.ValAddressFromBech32(validatorAddress) + valAddr, err := sdk.ValAddressFromBech32(validatorAddress) if err != nil { return nil, err } - val := k.Validator(ctx, valAdr) + val := k.Validator(ctx, valAddr) if val == nil { return nil, errorsmod.Wrap(distrtypes.ErrNoValidatorExists, validatorAddress) } - delAdr, err := sdk.AccAddressFromBech32(delegatorAddress) + delAddr, err := sdk.AccAddressFromBech32(delegatorAddress) if err != nil { return nil, err } - del := k.Delegation(ctx, delAdr, valAdr) + del := k.Delegation(ctx, delAddr, valAddr) if del == nil { return nil, distrtypes.ErrNoDelegationExists } diff --git a/x/estaking/keeper/keeper_burn_edenB.go b/x/estaking/keeper/keeper_burn_edenB.go index 51aec3b26..579433748 100644 --- a/x/estaking/keeper/keeper_burn_edenB.go +++ b/x/estaking/keeper/keeper_burn_edenB.go @@ -88,7 +88,7 @@ func (k Keeper) BurnEdenBFromEdenUncommitted(ctx sdk.Context, delegator string, return nil } - // Burn EdenB ( Deduction EdenB in commitment module) + // Burn EdenB in commitment module commitment, err := k.commKeeper.BurnEdenBoost(ctx, delegator, ptypes.EdenB, edenBToBurn.TruncateInt()) k.commKeeper.SetCommitments(ctx, commitment) return err diff --git a/x/estaking/keeper/keeper_shares.go b/x/estaking/keeper/keeper_shares.go index 0a1af3e33..2bc79aa05 100644 --- a/x/estaking/keeper/keeper_shares.go +++ b/x/estaking/keeper/keeper_shares.go @@ -16,15 +16,11 @@ func (k Keeper) CalcDelegationAmount(ctx sdk.Context, delegator string) math.Int return sdk.ZeroInt() } - // Get elys delegation for creator address + // Get elys delegation delAmount := sdk.ZeroDec() - - // Get all delegations delegations := k.Keeper.GetDelegatorDelegations(ctx, delAddr, gomath.MaxUint16) for _, del := range delegations { - // Get validator address valAddr := del.GetValidatorAddr() - // Get validator val := k.Keeper.Validator(ctx, valAddr) shares := del.GetShares() @@ -46,13 +42,9 @@ func (k Keeper) CalcBondedDelegationAmount(ctx sdk.Context, delegator string) ma // Get elys delegation for creator address delAmount := sdk.ZeroDec() - - // Get all delegations delegations := k.Keeper.GetDelegatorDelegations(ctx, delAddr, gomath.MaxUint16) for _, del := range delegations { - // Get validator address valAddr := del.GetValidatorAddr() - // Get validator val := k.Keeper.Validator(ctx, valAddr) if !val.IsBonded() { diff --git a/x/estaking/keeper/query.go b/x/estaking/keeper/query.go index 7e9ddcc10..04f26e4a6 100644 --- a/x/estaking/keeper/query.go +++ b/x/estaking/keeper/query.go @@ -26,18 +26,21 @@ func (k Keeper) Rewards(goCtx context.Context, req *types.QueryRewardsRequest) ( total := sdk.DecCoins{} var delRewards []types.DelegationDelegatorReward - delAdr, err := sdk.AccAddressFromBech32(req.Address) + delAddr, err := sdk.AccAddressFromBech32(req.Address) if err != nil { return nil, err } k.IterateDelegations( - ctx, delAdr, + ctx, delAddr, func(_ int64, del stakingtypes.DelegationI) (stop bool) { valAddr := del.GetValidatorAddr() val := k.Validator(ctx, valAddr) endingPeriod := k.distrKeeper.IncrementValidatorPeriod(ctx, val) delReward := k.distrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod) + if delReward == nil { + delReward = []sdk.DecCoin{} + } delRewards = append(delRewards, types.DelegationDelegatorReward{ ValidatorAddress: valAddr.String(), diff --git a/x/estaking/types/expected_keepers.go b/x/estaking/types/expected_keepers.go index c2929b827..0e5b07708 100644 --- a/x/estaking/types/expected_keepers.go +++ b/x/estaking/types/expected_keepers.go @@ -7,6 +7,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" commitmenttypes "github.com/elys-network/elys/x/commitment/types" + parametertypes "github.com/elys-network/elys/x/parameter/types" tokenomictypes "github.com/elys-network/elys/x/tokenomics/types" ) @@ -76,3 +77,7 @@ type AssetProfileKeeper interface { // GetUsdcDenom returns USDC denom GetUsdcDenom(ctx sdk.Context) (string, bool) } + +type ParameterKeeper interface { + GetParams(ctx sdk.Context) (params parametertypes.Params) +} diff --git a/x/incentive/keeper/apr.go b/x/incentive/keeper/apr.go index 528050d2b..702dd1c45 100644 --- a/x/incentive/keeper/apr.go +++ b/x/incentive/keeper/apr.go @@ -31,12 +31,9 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat return sdk.ZeroInt(), errorsmod.Wrapf(assetprofiletypes.ErrAssetProfileNotFound, "asset %s not found", ptypes.BaseCurrency) } - lpIncentive := masterchefParams.LpIncentives stkIncentive := estakingParams.StakeIncentives - if lpIncentive.TotalBlocksPerYear.IsZero() || stkIncentive.TotalBlocksPerYear.IsZero() { - return sdk.ZeroInt(), errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid inflationary params") - } + totalBlocksPerYear := k.parameterKeeper.GetParams(ctx).TotalBlocksPerYear if query.Denom == ptypes.Eden { if query.WithdrawType == commitmenttypes.EarnType_USDC_PROGRAM { @@ -52,22 +49,24 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat return sdk.ZeroInt(), nil } + if stkIncentive == nil || stkIncentive.EdenAmountPerYear.IsNil() { + return sdk.ZeroInt(), nil + } + // Calculate - stakersEdenAmount := stkIncentive.EdenAmountPerYear. - Quo(stkIncentive.TotalBlocksPerYear) + stakersEdenAmount := stkIncentive.EdenAmountPerYear.Quo(sdk.NewInt(totalBlocksPerYear)) // Maximum eden APR - 30% by default - // Allocated for staking per day = (0.3/365)* ( total elys staked + total Eden committed + total Eden boost committed) stakersMaxEdenAmount := estakingParams.MaxEdenRewardAprStakers. MulInt(totalStakedSnapshot). - QuoInt(stkIncentive.TotalBlocksPerYear) + QuoInt64(totalBlocksPerYear) // Use min amount (eden allocation from tokenomics and max apr based eden amount) stakersEdenAmount = sdk.MinInt(stakersEdenAmount, stakersMaxEdenAmount.TruncateInt()) - // For Eden reward Apr for elys staking = {(amount of Eden allocated for staking per day)*365/( total elys staked + total Eden committed + total Eden boost committed)}*100 + // For Eden reward Apr for elys staking apr := stakersEdenAmount. - Mul(lpIncentive.TotalBlocksPerYear). + Mul(sdk.NewInt(totalBlocksPerYear)). Mul(sdk.NewInt(100)). Quo(totalStakedSnapshot) @@ -111,7 +110,9 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (mat } // DexReward amount per day = amount distributed / duration(in seconds) * total seconds per day. - yearlyDexRewardAmount := amount.MulInt(lpIncentive.TotalBlocksPerYear).QuoInt(params.DexRewardsStakers.NumBlocks) + yearlyDexRewardAmount := amount. + MulInt64(totalBlocksPerYear). + QuoInt(params.DexRewardsStakers.NumBlocks) // Usdc apr for elys staking = (24 hour dex rewards in USDC generated for stakers) * 365*100/ {price ( elys/usdc)*( sum of (elys staked, Eden committed, Eden boost committed))} // we multiply 10 as we have use 10elys as input in the price estimation diff --git a/x/incentive/keeper/keeper.go b/x/incentive/keeper/keeper.go index bb692bdda..73a29fdbb 100644 --- a/x/incentive/keeper/keeper.go +++ b/x/incentive/keeper/keeper.go @@ -21,6 +21,7 @@ type ( cdc codec.BinaryCodec storeKey storetypes.StoreKey memKey storetypes.StoreKey + parameterKeeper types.ParameterKeeper cmk types.CommitmentKeeper stk types.StakingKeeper authKeeper types.AccountKeeper @@ -42,6 +43,7 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey, + parameterKeeper types.ParameterKeeper, ck types.CommitmentKeeper, sk types.StakingKeeper, ak types.AccountKeeper, @@ -61,6 +63,7 @@ func NewKeeper( cdc: cdc, storeKey: storeKey, memKey: memKey, + parameterKeeper: parameterKeeper, cmk: ck, stk: sk, authKeeper: ak, diff --git a/x/incentive/types/expected_keepers.go b/x/incentive/types/expected_keepers.go index 74064b2b9..1a797a27a 100644 --- a/x/incentive/types/expected_keepers.go +++ b/x/incentive/types/expected_keepers.go @@ -11,6 +11,7 @@ import ( assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" ctypes "github.com/elys-network/elys/x/commitment/types" oracletypes "github.com/elys-network/elys/x/oracle/types" + parametertypes "github.com/elys-network/elys/x/parameter/types" stabletypes "github.com/elys-network/elys/x/stablestake/types" tokenomictypes "github.com/elys-network/elys/x/tokenomics/types" ) @@ -138,3 +139,7 @@ type StableStakeKeeper interface { type TokenomicsKeeper interface { GetAllTimeBasedInflation(ctx sdk.Context) (list []tokenomictypes.TimeBasedInflation) } + +type ParameterKeeper interface { + GetParams(ctx sdk.Context) (params parametertypes.Params) +} diff --git a/x/masterchef/genesis.go b/x/masterchef/genesis.go index aac2c96a5..d6fef1050 100644 --- a/x/masterchef/genesis.go +++ b/x/masterchef/genesis.go @@ -11,14 +11,15 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) - for _, elem := range genState.PoolInfos { - k.SetPool(ctx, elem) - } - + k.SetExternalIncentiveIndex(ctx, genState.ExternalIncentiveIndex) for _, elem := range genState.ExternalIncentives { k.SetExternalIncentive(ctx, elem) } + for _, elem := range genState.PoolInfos { + k.SetPool(ctx, elem) + } + for _, elem := range genState.PoolRewardInfos { k.SetPoolRewardInfo(ctx, elem) } @@ -33,6 +34,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) genesis.ExternalIncentives = k.GetAllExternalIncentives(ctx) + genesis.ExternalIncentiveIndex = k.GetExternalIncentiveIndex(ctx) genesis.PoolInfos = k.GetAllPools(ctx) genesis.PoolRewardInfos = k.GetAllPoolRewardInfos(ctx) genesis.UserRewardInfos = k.GetAllUserRewardInfos(ctx) diff --git a/x/masterchef/keeper/abci.go b/x/masterchef/keeper/abci.go index 27e196da9..19808a72a 100644 --- a/x/masterchef/keeper/abci.go +++ b/x/masterchef/keeper/abci.go @@ -1,8 +1,6 @@ package keeper import ( - "errors" - errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -42,18 +40,12 @@ func (k Keeper) GetPoolTVL(ctx sdk.Context, poolId uint64) math.LegacyDec { } func (k Keeper) ProcessExternalRewardsDistribution(ctx sdk.Context) { - canDistribute := k.CanDistributeLPRewards(ctx) - if !canDistribute { - return - } - - // Fetch incentive params - params := k.GetParams(ctx) - lpIncentive := params.LpIncentives - + baseCurrency, _ := k.assetProfileKeeper.GetUsdcDenom(ctx) curBlockHeight := sdk.NewInt(ctx.BlockHeight()) + totalBlocksPerYear := k.parameterKeeper.GetParams(ctx).TotalBlocksPerYear externalIncentives := k.GetAllExternalIncentives(ctx) + externalIncentiveAprs := make(map[uint64]math.LegacyDec) for _, externalIncentive := range externalIncentives { pool, found := k.GetPool(ctx, externalIncentive.PoolId) if !found { @@ -78,16 +70,23 @@ func (k Keeper) ProcessExternalRewardsDistribution(ctx sdk.Context) { tvl := k.GetPoolTVL(ctx, pool.PoolId) if tvl.IsPositive() { yearlyIncentiveRewardsTotal := externalIncentive.AmountPerBlock. - Mul(lpIncentive.TotalBlocksPerYear). + Mul(sdk.NewInt(totalBlocksPerYear)). Quo(pool.NumBlocks) - baseCurrency, found := k.assetProfileKeeper.GetUsdcDenom(ctx) - if found { - pool.ExternalIncentiveApr = sdk.NewDecFromInt(yearlyIncentiveRewardsTotal). - Mul(k.amm.GetTokenPrice(ctx, externalIncentive.RewardDenom, baseCurrency)). - Quo(tvl) - k.SetPool(ctx, pool) + apr := sdk.NewDecFromInt(yearlyIncentiveRewardsTotal). + Mul(k.amm.GetTokenPrice(ctx, externalIncentive.RewardDenom, baseCurrency)). + Quo(tvl) + externalIncentive.Apr = apr + k.SetExternalIncentive(ctx, externalIncentive) + poolExternalApr, ok := externalIncentiveAprs[pool.PoolId] + if !ok { + poolExternalApr = math.LegacyZeroDec() } + + poolExternalApr = poolExternalApr.Add(apr) + externalIncentiveAprs[pool.PoolId] = poolExternalApr + pool.ExternalIncentiveApr = poolExternalApr + k.SetPool(ctx, pool) } } @@ -99,29 +98,22 @@ func (k Keeper) ProcessExternalRewardsDistribution(ctx sdk.Context) { func (k Keeper) ProcessLPRewardDistribution(ctx sdk.Context) { // Read tokenomics time based inflation params and update incentive module params. - if !k.ProcessUpdateIncentiveParams(ctx) { - ctx.Logger().Error("Invalid tokenomics params", "error", errors.New("invalid tokenomics params")) - return - } + k.ProcessUpdateIncentiveParams(ctx) - canDistribute := k.CanDistributeLPRewards(ctx) - if canDistribute { - err := k.UpdateLPRewards(ctx) - if err != nil { - ctx.Logger().Error("Failed to update lp rewards unclaimed", "error", err) - } + err := k.UpdateLPRewards(ctx) + if err != nil { + ctx.Logger().Error("Failed to update lp rewards unclaimed", "error", err) } } -func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool { +func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) { // Non-linear inflation per year happens and this includes yearly inflation data listTimeBasedInflations := k.tokenomicsKeeper.GetAllTimeBasedInflation(ctx) - if len(listTimeBasedInflations) < 1 { - return false + if len(listTimeBasedInflations) == 0 { + return } params := k.GetParams(ctx) - for _, inflation := range listTimeBasedInflations { // Finding only current inflation data - and skip rest if inflation.StartBlockHeight > uint64(ctx.BlockHeight()) || inflation.EndBlockHeight < uint64(ctx.BlockHeight()) { @@ -136,7 +128,7 @@ func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool { } blocksDistributed := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)) - incentiveInfo := types.IncentiveInfo{ + params.LpIncentives = &types.IncentiveInfo{ // reward amount in eden for 1 year EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.LmRewards)), // starting block height of the distribution @@ -146,58 +138,12 @@ func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool { // number of blocks distributed BlocksDistributed: blocksDistributed, } - - if params.LpIncentives == nil { - params.LpIncentives = &incentiveInfo - } else { - // If any of block number related parameter changed, we re-calculate the current epoch - if params.LpIncentives.DistributionStartBlock != incentiveInfo.DistributionStartBlock || - params.LpIncentives.TotalBlocksPerYear != incentiveInfo.TotalBlocksPerYear { - params.LpIncentives.BlocksDistributed = blocksDistributed - } - params.LpIncentives.EdenAmountPerYear = incentiveInfo.EdenAmountPerYear - params.LpIncentives.DistributionStartBlock = incentiveInfo.DistributionStartBlock - params.LpIncentives.TotalBlocksPerYear = incentiveInfo.TotalBlocksPerYear - } - break - } - - k.SetParams(ctx, params) - return true -} - -func (k Keeper) CanDistributeLPRewards(ctx sdk.Context) bool { - // Fetch incentive params - params := k.GetParams(ctx) - if ctx.BlockHeight() < 1 { - return false - } - - // If we don't have enough params - if params.LpIncentives == nil { - return false - } - - // Incentive params initialize - lpIncentive := params.LpIncentives - - curBlockHeight := sdk.NewInt(ctx.BlockHeight()) - if lpIncentive.DistributionStartBlock.GT(curBlockHeight) { - return false - } - - // Increase current epoch of incentive param - lpIncentive.BlocksDistributed = lpIncentive.BlocksDistributed.Add(sdk.OneInt()) - if lpIncentive.BlocksDistributed.GTE(lpIncentive.TotalBlocksPerYear) || curBlockHeight.GT(lpIncentive.TotalBlocksPerYear.Add(lpIncentive.DistributionStartBlock)) { - params.LpIncentives = nil k.SetParams(ctx, params) - return false + return } - params.LpIncentives.BlocksDistributed = lpIncentive.BlocksDistributed + params.LpIncentives = nil k.SetParams(ctx, params) - - return true } func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { @@ -212,7 +158,7 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { // Collect Gas fees + swap fees gasFeesForLpsDec := k.CollectGasFees(ctx, baseCurrency) - _, dexRevenueForLps := k.CollectDEXRevenue(ctx) + _, dexRevenueForLps, rewardsPerPool := k.CollectDEXRevenue(ctx) // USDC amount in sdk.Dec type dexUsdcAmountForLps := dexRevenueForLps.AmountOf(baseCurrency) @@ -225,20 +171,21 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { // Proxy TVL = 20*0.3+30*0.5+40*1.0 totalProxyTVL := k.CalculateProxyTVL(ctx, baseCurrency) - // Ensure lpIncentive.TotalBlocksPerYear is not zero to avoid division by zero - if lpIncentive.TotalBlocksPerYear.IsZero() { + // Ensure totalBlocksPerYear is not zero to avoid division by zero + totalBlocksPerYear := k.parameterKeeper.GetParams(ctx).TotalBlocksPerYear + if totalBlocksPerYear == 0 { return errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid inflationary params") } // Calculate eden amount per block - lpsEdenAmount := lpIncentive.EdenAmountPerYear. - Quo(lpIncentive.TotalBlocksPerYear) - - // Maximum eden APR - 30% by default - // Allocated for staking per day = (0.3/365)* (total weighted proxy TVL) - edenDenomPrice := k.amm.GetEdenDenomPrice(ctx, baseCurrency) + edenAmountPerYear := sdk.ZeroInt() + if lpIncentive != nil && lpIncentive.EdenAmountPerYear.IsPositive() { + edenAmountPerYear = lpIncentive.EdenAmountPerYear + } + lpsEdenAmount := edenAmountPerYear.Quo(sdk.NewInt(totalBlocksPerYear)) // Ensure edenDenomPrice is not zero to avoid division by zero + edenDenomPrice := k.amm.GetEdenDenomPrice(ctx, baseCurrency) if edenDenomPrice.IsZero() { return errorsmod.Wrap(types.ErrNoInflationaryParams, "invalid eden price") } @@ -260,16 +207,19 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { // Calculate new Eden for this pool newEdenAllocatedForPool := poolShare.MulInt(lpsEdenAmount) + // Maximum eden APR - 30% by default poolMaxEdenAmount := params.MaxEdenRewardAprLps. Mul(tvl). - QuoInt(lpIncentive.TotalBlocksPerYear). + QuoInt64(totalBlocksPerYear). Quo(edenDenomPrice) // Use min amount (eden allocation from tokenomics and max apr based eden amount) newEdenAllocatedForPool = sdk.MinDec(newEdenAllocatedForPool, poolMaxEdenAmount) - err = k.cmk.MintCoins(ctx, types.ModuleName, sdk.Coins{sdk.NewCoin(ptypes.Eden, newEdenAllocatedForPool.TruncateInt())}) - if err != nil { - panic(err) + if newEdenAllocatedForPool.IsPositive() { + err = k.cmk.MintCoins(ctx, types.ModuleName, sdk.Coins{sdk.NewCoin(ptypes.Eden, newEdenAllocatedForPool.TruncateInt())}) + if err != nil { + return err + } } // Get gas fee rewards per pool @@ -278,10 +228,8 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { // ------------------- DEX rewards calculation ------------------- // --------------------------------------------------------------- // Get dex rewards per pool - // Get track key - trackKey := types.GetPoolRevenueTrackKey(pool.PoolId) // Get tracked amount for Lps per pool - dexRewardsAllocatedForPool, ok := k.tci.PoolRevenueTrack[trackKey] + dexRewardsAllocatedForPool, ok := rewardsPerPool[pool.PoolId] if !ok { dexRewardsAllocatedForPool = sdk.NewDec(0) } @@ -303,7 +251,7 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error { k.SetParams(ctx, params) // Update APR for amm pools - k.UpdateAmmPoolAPR(ctx, lpIncentive.TotalBlocksPerYear, totalProxyTVL, edenDenomPrice) + k.UpdateAmmPoolAPR(ctx, totalBlocksPerYear, totalProxyTVL, edenDenomPrice) return nil } @@ -319,7 +267,6 @@ func (k Keeper) ConvertGasFeesToUsdc(ctx sdk.Context, baseCurrency string) sdk.C // Total Swapped coin totalSwappedCoins := sdk.Coins{} - for _, tokenIn := range feesCollected { // if it is base currency - usdc, we don't need convert. We just need to collect it to fee wallet. if tokenIn.Denom == baseCurrency { @@ -405,12 +352,11 @@ func (k Keeper) CollectGasFees(ctx sdk.Context, baseCurrency string) sdk.DecCoin // Assume this is already in USDC. // TODO: // + Collect revenue from perpetual, lend module -func (k Keeper) CollectDEXRevenue(ctx sdk.Context) (sdk.Coins, sdk.DecCoins) { +func (k Keeper) CollectDEXRevenue(ctx sdk.Context) (sdk.Coins, sdk.DecCoins, map[uint64]sdk.Dec) { // Total colllected revenue amount amountTotalCollected := sdk.Coins{} amountLPsCollected := sdk.DecCoins{} - - k.tci.PoolRevenueTrack = make(map[string]sdk.Dec) + rewardsPerPool := make(map[uint64]sdk.Dec) // Iterate to calculate total Eden from LpElys, MElys committed k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { @@ -461,11 +407,8 @@ func (k Keeper) CollectDEXRevenue(ctx sdk.Context) (sdk.Coins, sdk.DecCoins) { } } - // Get track key - trackKey := types.GetPoolRevenueTrackKey(poolId) - // Store revenue portion for Lps temporarilly - k.tci.PoolRevenueTrack[trackKey] = revenuePortionForLPs.AmountOf(ptypes.BaseCurrency) + rewardsPerPool[poolId] = revenuePortionForLPs.AmountOf(ptypes.BaseCurrency) // Sum total collected amount amountTotalCollected = amountTotalCollected.Add(revenue...) @@ -476,18 +419,19 @@ func (k Keeper) CollectDEXRevenue(ctx sdk.Context) (sdk.Coins, sdk.DecCoins) { return false }) - return amountTotalCollected, amountLPsCollected + return amountTotalCollected, amountLPsCollected, rewardsPerPool } // Calculate Proxy TVL func (k Keeper) CalculateProxyTVL(ctx sdk.Context, baseCurrency string) sdk.Dec { - multipliedShareSum := sdk.ZeroDec() + // Ensure stablestakePoolParams exist stableStakePoolId := uint64(stabletypes.PoolId) _, found := k.GetPool(ctx, stableStakePoolId) - // Ensure stablestakePoolParams exist if !found { k.InitStableStakePoolParams(ctx, stableStakePoolId) } + + multipliedShareSum := sdk.ZeroDec() for _, pool := range k.GetAllPools(ctx) { tvl := k.GetPoolTVL(ctx, pool.PoolId) proxyTVL := tvl.Mul(pool.Multiplier) @@ -557,11 +501,8 @@ func (k Keeper) CalculatePoolShareForStableStakeLPs(ctx sdk.Context, totalProxyT // edenAmountLp = 100 tvl := k.stableKeeper.TVL(ctx, k.oracleKeeper, baseCurrency) - // Get pool Id - poolId := uint64(stabletypes.PoolId) - // Get pool info from incentive param - poolInfo, found := k.GetPool(ctx, poolId) + poolInfo, found := k.GetPool(ctx, uint64(stabletypes.PoolId)) if !found { return sdk.ZeroDec() } @@ -577,8 +518,7 @@ func (k Keeper) CalculatePoolShareForStableStakeLPs(ctx sdk.Context, totalProxyT } // Update APR for AMM pool -func (k Keeper) UpdateAmmPoolAPR(ctx sdk.Context, totalBlocksPerYear sdk.Int, totalProxyTVL sdk.Dec, edenDenomPrice sdk.Dec) { - // Iterate to calculate total Eden from LpElys, MElys committed +func (k Keeper) UpdateAmmPoolAPR(ctx sdk.Context, totalBlocksPerYear int64, totalProxyTVL sdk.Dec, edenDenomPrice sdk.Dec) { k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { tvl, err := p.TVL(ctx, k.oracleKeeper) if err != nil { @@ -596,25 +536,24 @@ func (k Keeper) UpdateAmmPoolAPR(ctx sdk.Context, totalBlocksPerYear sdk.Int, to } poolInfo.NumBlocks = sdk.OneInt() - // Invalid block number - if poolInfo.NumBlocks.IsZero() { + + if tvl.IsZero() { return false } - if tvl.IsZero() { + if poolInfo.NumBlocks.IsZero() { return false } // Dex reward Apr per pool = total accumulated usdc rewards for 7 day * 52/ tvl of pool yearlyDexRewardsTotal := poolInfo.DexRewardAmountGiven. - MulInt(totalBlocksPerYear). + MulInt64(totalBlocksPerYear). QuoInt(poolInfo.NumBlocks) - poolInfo.DexApr = yearlyDexRewardsTotal. - Quo(tvl) + poolInfo.DexApr = yearlyDexRewardsTotal.Quo(tvl) // Eden reward Apr per pool = (total LM Eden reward allocated per day*((tvl of pool * multiplier)/total proxy TVL) ) * 365 / TVL of pool yearlyEdenRewardsTotal := poolInfo.EdenRewardAmountGiven. - Mul(totalBlocksPerYear). + Mul(sdk.NewInt(totalBlocksPerYear)). Quo(poolInfo.NumBlocks) poolInfo.EdenApr = sdk.NewDecFromInt(yearlyEdenRewardsTotal). @@ -623,7 +562,6 @@ func (k Keeper) UpdateAmmPoolAPR(ctx sdk.Context, totalBlocksPerYear sdk.Int, to // Update Pool Info k.SetPool(ctx, poolInfo) - return false }) } diff --git a/x/masterchef/keeper/abci_test.go b/x/masterchef/keeper/abci_test.go index e1000ef7c..99996068f 100644 --- a/x/masterchef/keeper/abci_test.go +++ b/x/masterchef/keeper/abci_test.go @@ -80,8 +80,7 @@ func TestABCI_EndBlocker(t *testing.T) { // After the first year ctx = ctx.WithBlockHeight(1) - paramSet := mk.ProcessUpdateIncentiveParams(ctx) - require.Equal(t, paramSet, true) + mk.ProcessUpdateIncentiveParams(ctx) // Check if the params are correctly set params := mk.GetParams(ctx) @@ -91,15 +90,13 @@ func TestABCI_EndBlocker(t *testing.T) { // After the first year ctx = ctx.WithBlockHeight(6307210) - // Incentive param should be empty - lpEpoch := mk.CanDistributeLPRewards(ctx) - params = mk.GetParams(ctx) - require.Equal(t, lpEpoch, false) - require.Nil(t, params.LpIncentives) - // After reading tokenomics again - paramSet = mk.ProcessUpdateIncentiveParams(ctx) - require.Equal(t, paramSet, true) + mk.ProcessUpdateIncentiveParams(ctx) + + // Check if the params are correctly set + params = mk.GetParams(ctx) + require.NotNil(t, params.LpIncentives) + require.Equal(t, params.LpIncentives.EdenAmountPerYear, sdk.NewInt(int64(listTimeBasdInflations[0].Inflation.LmRewards))) } func TestCollectGasFees(t *testing.T) { @@ -310,7 +307,7 @@ func TestCollectDEXRevenue(t *testing.T) { mk.SetParams(ctx, params) // Collect revenue - collectedAmt, rewardForLpsAmt := mk.CollectDEXRevenue(ctx) + collectedAmt, rewardForLpsAmt, _ := mk.CollectDEXRevenue(ctx) // check block height require.Equal(t, int64(0), ctx.BlockHeight()) diff --git a/x/masterchef/keeper/apr_stable_stake.go b/x/masterchef/keeper/apr_stable_stake.go index f9f6e96c6..732199eac 100644 --- a/x/masterchef/keeper/apr_stable_stake.go +++ b/x/masterchef/keeper/apr_stable_stake.go @@ -20,11 +20,12 @@ func (k Keeper) CalculateStableStakeApr(ctx sdk.Context, query *types.QueryStabl // If we don't have enough params if query.Denom == ptypes.Eden { lpIncentive := params.LpIncentives - if lpIncentive == nil { - return sdk.ZeroInt(), errorsmod.Wrap(types.ErrNoInflationaryParams, "no inflationary params available") + if lpIncentive == nil || lpIncentive.EdenAmountPerYear.IsNil() { + return sdk.ZeroInt(), nil } - if lpIncentive.TotalBlocksPerYear.IsZero() { + totalBlocksPerYear := k.parameterKeeper.GetParams(ctx).TotalBlocksPerYear + if totalBlocksPerYear == 0 { return sdk.ZeroInt(), nil } @@ -41,8 +42,7 @@ func (k Keeper) CalculateStableStakeApr(ctx sdk.Context, query *types.QueryStabl // Calculate total Proxy TVL totalProxyTVL := k.CalculateProxyTVL(ctx, baseCurrency) - edenAmount := lpIncentive.EdenAmountPerYear. - Quo(lpIncentive.TotalBlocksPerYear) + edenAmount := lpIncentive.EdenAmountPerYear.Quo(sdk.NewInt(totalBlocksPerYear)) edenDenomPrice := k.amm.GetEdenDenomPrice(ctx, baseCurrency) @@ -53,13 +53,13 @@ func (k Keeper) CalculateStableStakeApr(ctx sdk.Context, query *types.QueryStabl params := k.GetParams(ctx) poolMaxEdenAmount := params.MaxEdenRewardAprLps. Mul(stableTvl). - QuoInt(lpIncentive.TotalBlocksPerYear). + QuoInt64(totalBlocksPerYear). Quo(edenDenomPrice) stableStakeEdenAmount = sdk.MinDec(stableStakeEdenAmount, poolMaxEdenAmount) // Eden Apr for usdc earn program apr := stableStakeEdenAmount. - MulInt(lpIncentive.TotalBlocksPerYear). + MulInt64(totalBlocksPerYear). Mul(edenDenomPrice). MulInt(sdk.NewInt(100)). Quo(stableTvl) diff --git a/x/masterchef/keeper/external_incentive.go b/x/masterchef/keeper/external_incentive.go index 9dd17a9e0..65b7e8f53 100644 --- a/x/masterchef/keeper/external_incentive.go +++ b/x/masterchef/keeper/external_incentive.go @@ -8,35 +8,31 @@ import ( func (k Keeper) GetExternalIncentiveIndex(ctx sdk.Context) (index uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveIndexKeyPrefix)) - index = sdk.BigEndianToUint64(store.Get(types.ExternalIncentiveIndex())) - return index } -func (k Keeper) SetExternalIncentiveIndex(ctx sdk.Context, index uint64) error { +func (k Keeper) SetExternalIncentiveIndex(ctx sdk.Context, index uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveIndexKeyPrefix)) - store.Set(types.ExternalIncentiveIndex(), sdk.Uint64ToBigEndian(index)) - - return nil } -func (k Keeper) SetExternalIncentive(ctx sdk.Context, externalIncentive types.ExternalIncentive) error { +func (k Keeper) AddExternalIncentive(ctx sdk.Context, externalIncentive types.ExternalIncentive) { // Update external incentive index and increase +1 index := k.GetExternalIncentiveIndex(ctx) externalIncentive.Id = index k.SetExternalIncentiveIndex(ctx, index+1) + k.SetExternalIncentive(ctx, externalIncentive) +} +func (k Keeper) SetExternalIncentive(ctx sdk.Context, externalIncentive types.ExternalIncentive) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveKeyPrefix)) b := k.cdc.MustMarshal(&externalIncentive) store.Set(types.ExternalIncentiveKey(externalIncentive.Id), b) - return nil } func (k Keeper) GetExternalIncentive(ctx sdk.Context, id uint64) (val types.ExternalIncentive, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ExternalIncentiveKeyPrefix)) - b := store.Get(types.ExternalIncentiveKey(id)) if b == nil { return val, false diff --git a/x/masterchef/keeper/external_incentive_test.go b/x/masterchef/keeper/external_incentive_test.go index 7c01d91e7..9e34cbbcf 100644 --- a/x/masterchef/keeper/external_incentive_test.go +++ b/x/masterchef/keeper/external_incentive_test.go @@ -22,6 +22,7 @@ func TestExternalIncentive(t *testing.T) { FromBlock: 0, ToBlock: 100, AmountPerBlock: sdk.OneInt(), + Apr: sdk.ZeroDec(), }, { Id: 1, @@ -30,6 +31,7 @@ func TestExternalIncentive(t *testing.T) { FromBlock: 0, ToBlock: 100, AmountPerBlock: sdk.OneInt(), + Apr: sdk.ZeroDec(), }, { Id: 2, @@ -38,12 +40,12 @@ func TestExternalIncentive(t *testing.T) { FromBlock: 0, ToBlock: 100, AmountPerBlock: sdk.OneInt(), + Apr: sdk.ZeroDec(), }, } require.Equal(t, app.MasterchefKeeper.GetExternalIncentiveIndex(ctx), uint64(0)) for _, externalIncentive := range externalIncentives { - err := app.MasterchefKeeper.SetExternalIncentive(ctx, externalIncentive) - require.NoError(t, err) + app.MasterchefKeeper.AddExternalIncentive(ctx, externalIncentive) } require.Equal(t, app.MasterchefKeeper.GetExternalIncentiveIndex(ctx), uint64(3)) for _, externalIncentive := range externalIncentives { diff --git a/x/masterchef/keeper/hooks_masterchef.go b/x/masterchef/keeper/hooks_masterchef.go index f1c989954..24896d0dd 100644 --- a/x/masterchef/keeper/hooks_masterchef.go +++ b/x/masterchef/keeper/hooks_masterchef.go @@ -30,7 +30,6 @@ func (k Keeper) GetPoolBalance(ctx sdk.Context, poolId uint64, user string) sdk. func (k Keeper) UpdateAccPerShare(ctx sdk.Context, poolId uint64, rewardDenom string, amount sdk.Int) { poolRewardInfo, found := k.GetPoolRewardInfo(ctx, poolId, rewardDenom) - if !found { poolRewardInfo = types.PoolRewardInfo{ PoolId: poolId, @@ -94,7 +93,6 @@ func (k Keeper) UpdateUserRewardPending(ctx sdk.Context, poolId uint64, rewardDe func (k Keeper) UpdateUserRewardDebt(ctx sdk.Context, poolId uint64, rewardDenom string, user string) { poolRewardInfo, found := k.GetPoolRewardInfo(ctx, poolId, rewardDenom) - if !found { poolRewardInfo = types.PoolRewardInfo{ PoolId: poolId, @@ -105,7 +103,6 @@ func (k Keeper) UpdateUserRewardDebt(ctx sdk.Context, poolId uint64, rewardDenom } userRewardInfo, found := k.GetUserRewardInfo(ctx, user, poolId, rewardDenom) - if !found { userRewardInfo = types.UserRewardInfo{ User: user, diff --git a/x/masterchef/keeper/hooks_user_actions.go b/x/masterchef/keeper/hooks_user_actions.go index 70751123a..8be83df59 100644 --- a/x/masterchef/keeper/hooks_user_actions.go +++ b/x/masterchef/keeper/hooks_user_actions.go @@ -1,11 +1,12 @@ package keeper import ( + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ptypes "github.com/elys-network/elys/x/parameter/types" ) -func (k Keeper) AfterDepositPerReward(ctx sdk.Context, poolId uint64, rewardDenom string, user string, amount sdk.Int) { +func (k Keeper) AfterDepositPerReward(ctx sdk.Context, poolId uint64, rewardDenom string, user string, amount math.Int) { k.UpdateUserRewardPending( ctx, poolId, @@ -22,7 +23,7 @@ func (k Keeper) AfterDepositPerReward(ctx sdk.Context, poolId uint64, rewardDeno ) } -func (k Keeper) AfterDeposit(ctx sdk.Context, poolId uint64, user string, amount sdk.Int) { +func (k Keeper) AfterDeposit(ctx sdk.Context, poolId uint64, user string, amount math.Int) { for _, rewardDenom := range k.GetRewardDenoms(ctx, poolId) { k.AfterDepositPerReward(ctx, poolId, rewardDenom, user, amount) } @@ -53,23 +54,22 @@ func (k Keeper) AfterWithdraw(ctx sdk.Context, poolId uint64, user string, amoun func (k Keeper) GetRewardDenoms(ctx sdk.Context, poolId uint64) []string { rewardDenoms := make(map[string]bool) - rewardDenoms[ptypes.Eden] = true rewardDenoms[k.GetBaseCurrencyDenom(ctx)] = true + keys := []string{ptypes.Eden, k.GetBaseCurrencyDenom(ctx)} poolInfo, found := k.GetPool(ctx, poolId) if !found { return []string{} } - externalIncentives := poolInfo.ExternalRewardDenoms - for _, externalIncentive := range externalIncentives { - rewardDenoms[externalIncentive] = true - } + for _, denom := range poolInfo.ExternalRewardDenoms { + if rewardDenoms[denom] { + continue + } - keys := make([]string, 0, len(rewardDenoms)) - for k2 := range rewardDenoms { - keys = append(keys, k2) + keys = append(keys, denom) + rewardDenoms[denom] = true } return keys diff --git a/x/masterchef/keeper/keeper.go b/x/masterchef/keeper/keeper.go index e6d1c32b4..8685d7976 100644 --- a/x/masterchef/keeper/keeper.go +++ b/x/masterchef/keeper/keeper.go @@ -19,8 +19,8 @@ type ( memKey storetypes.StoreKey paramstore paramtypes.Subspace + parameterKeeper types.ParameterKeeper cmk types.CommitmentKeeper - tci *types.TotalCommitmentInfo amm types.AmmKeeper oracleKeeper types.OracleKeeper assetProfileKeeper types.AssetProfileKeeper @@ -39,6 +39,7 @@ func NewKeeper( storeKey, memKey storetypes.StoreKey, ps paramtypes.Subspace, + parameterKeeper types.ParameterKeeper, ck types.CommitmentKeeper, amm types.AmmKeeper, ok types.OracleKeeper, @@ -55,8 +56,8 @@ func NewKeeper( storeKey: storeKey, memKey: memKey, paramstore: ps, + parameterKeeper: parameterKeeper, cmk: ck, - tci: &types.TotalCommitmentInfo{}, amm: amm, oracleKeeper: ok, assetProfileKeeper: ap, diff --git a/x/masterchef/keeper/msg_server.go b/x/masterchef/keeper/msg_server.go index edd358d73..a0e1e6e75 100644 --- a/x/masterchef/keeper/msg_server.go +++ b/x/masterchef/keeper/msg_server.go @@ -4,6 +4,7 @@ import ( "context" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/elys-network/elys/x/masterchef/types" @@ -65,6 +66,7 @@ func (k msgServer) AddExternalRewardDenom(goCtx context.Context, msg *types.MsgA func (k msgServer) AddExternalIncentive(goCtx context.Context, msg *types.MsgAddExternalIncentive) (*types.MsgAddExternalIncentiveResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + sender := sdk.MustAccAddressFromBech32(msg.Sender) if msg.FromBlock < uint64(ctx.BlockHeight()) { return nil, status.Error(codes.InvalidArgument, "invalid from block") @@ -93,41 +95,27 @@ func (k msgServer) AddExternalIncentive(goCtx context.Context, msg *types.MsgAdd return nil, status.Error(codes.InvalidArgument, "invalid reward denom") } - err := k.bankKeeper.SendCoinsFromAccountToModule( - ctx, - sdk.MustAccAddressFromBech32(msg.Sender), - types.ModuleName, - sdk.NewCoins( - sdk.NewCoin( - msg.RewardDenom, - msg.AmountPerBlock.Mul( - sdk.NewInt(int64(msg.ToBlock-msg.FromBlock)), - ), - ), - ), - ) + amount := msg.AmountPerBlock.Mul(sdk.NewInt(int64(msg.ToBlock - msg.FromBlock))) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.Coins{sdk.NewCoin(msg.RewardDenom, amount)}) if err != nil { return nil, err } - k.SetExternalIncentive( - ctx, - types.ExternalIncentive{ - Id: 0, - RewardDenom: msg.RewardDenom, - PoolId: msg.PoolId, - FromBlock: msg.FromBlock, - ToBlock: msg.ToBlock, - AmountPerBlock: msg.AmountPerBlock, - }, - ) + k.Keeper.AddExternalIncentive(ctx, types.ExternalIncentive{ + Id: 0, + RewardDenom: msg.RewardDenom, + PoolId: msg.PoolId, + FromBlock: msg.FromBlock, + ToBlock: msg.ToBlock, + AmountPerBlock: msg.AmountPerBlock, + Apr: math.LegacyZeroDec(), + }) return &types.MsgAddExternalIncentiveResponse{}, nil } func (k msgServer) ClaimRewards(goCtx context.Context, msg *types.MsgClaimRewards) (*types.MsgClaimRewardsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - sender := sdk.MustAccAddressFromBech32(msg.Sender) if len(msg.PoolIds) == 0 { @@ -143,7 +131,6 @@ func (k msgServer) ClaimRewards(goCtx context.Context, msg *types.MsgClaimReward for _, rewardDenom := range k.GetRewardDenoms(ctx, poolId) { userRewardInfo, found := k.GetUserRewardInfo(ctx, msg.Sender, poolId, rewardDenom) - if found && userRewardInfo.RewardPending.IsPositive() { coin := sdk.NewCoin(rewardDenom, userRewardInfo.RewardPending.TruncateInt()) coins = coins.Add(coin) @@ -165,7 +152,6 @@ func (k msgServer) ClaimRewards(goCtx context.Context, msg *types.MsgClaimReward func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if k.authority != msg.Authority { return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) } @@ -177,7 +163,6 @@ func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParam func (k msgServer) UpdatePoolMultipliers(goCtx context.Context, msg *types.MsgUpdatePoolMultipliers) (*types.MsgUpdatePoolMultipliersResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if k.authority != msg.Authority { return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) } diff --git a/x/masterchef/keeper/query.go b/x/masterchef/keeper/query.go index 4970740e7..220050dea 100644 --- a/x/masterchef/keeper/query.go +++ b/x/masterchef/keeper/query.go @@ -62,12 +62,7 @@ func (k Keeper) UserPendingReward(goCtx context.Context, req *types.QueryUserPen rewardsInfos := []*types.RewardInfo{} for _, pool := range k.GetAllPools(ctx) { - k.AfterWithdraw( - ctx, - pool.PoolId, - req.User, - sdk.ZeroInt(), - ) + k.AfterWithdraw(ctx, pool.PoolId, req.User, sdk.ZeroInt()) poolRewards := sdk.NewCoins() for _, rewardDenom := range k.GetRewardDenoms(ctx, pool.PoolId) { @@ -88,9 +83,7 @@ func (k Keeper) UserPendingReward(goCtx context.Context, req *types.QueryUserPen }, ) - totalRewards = totalRewards.Add( - poolRewards..., - ) + totalRewards = totalRewards.Add(poolRewards...) } return &types.QueryUserPendingRewardResponse{ @@ -105,7 +98,6 @@ func (k Keeper) StableStakeApr(goCtx context.Context, req *types.QueryStableStak } ctx := sdk.UnwrapSDKContext(goCtx) - apr, err := k.CalculateStableStakeApr(ctx, req) if err != nil { return nil, err diff --git a/x/masterchef/types/expected_keepers.go b/x/masterchef/types/expected_keepers.go index 62f0a1e3c..144a237c8 100644 --- a/x/masterchef/types/expected_keepers.go +++ b/x/masterchef/types/expected_keepers.go @@ -11,6 +11,7 @@ import ( assetprofiletypes "github.com/elys-network/elys/x/assetprofile/types" ctypes "github.com/elys-network/elys/x/commitment/types" oracletypes "github.com/elys-network/elys/x/oracle/types" + parametertypes "github.com/elys-network/elys/x/parameter/types" stabletypes "github.com/elys-network/elys/x/stablestake/types" tokenomictypes "github.com/elys-network/elys/x/tokenomics/types" ) @@ -136,3 +137,7 @@ type StableStakeKeeper interface { type TokenomicsKeeper interface { GetAllTimeBasedInflation(ctx sdk.Context) (list []tokenomictypes.TimeBasedInflation) } + +type ParameterKeeper interface { + GetParams(ctx sdk.Context) (params parametertypes.Params) +} diff --git a/x/masterchef/types/external_incentive.pb.go b/x/masterchef/types/external_incentive.pb.go index 5ea46099a..6ceaaa63a 100644 --- a/x/masterchef/types/external_incentive.pb.go +++ b/x/masterchef/types/external_incentive.pb.go @@ -32,6 +32,7 @@ type ExternalIncentive struct { FromBlock uint64 `protobuf:"varint,4,opt,name=from_block,json=fromBlock,proto3" json:"from_block,omitempty"` ToBlock uint64 `protobuf:"varint,5,opt,name=to_block,json=toBlock,proto3" json:"to_block,omitempty"` AmountPerBlock github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=amount_per_block,json=amountPerBlock,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount_per_block"` + Apr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=apr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"apr"` } func (m *ExternalIncentive) Reset() { *m = ExternalIncentive{} } @@ -111,27 +112,28 @@ func init() { } var fileDescriptor_3d270e9faef9dc8d = []byte{ - // 318 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4e, 0xea, 0x40, - 0x14, 0x86, 0x3b, 0x5c, 0x2e, 0xc8, 0x68, 0x50, 0x1b, 0x13, 0xab, 0x89, 0x05, 0x5d, 0x18, 0x36, - 0x74, 0x16, 0xbe, 0x01, 0xd1, 0x45, 0x77, 0x86, 0x95, 0x71, 0xd3, 0x94, 0xce, 0x01, 0x1a, 0xda, - 0x39, 0xcd, 0xcc, 0x20, 0xf0, 0x16, 0x3e, 0x16, 0x4b, 0x96, 0xc6, 0x05, 0x31, 0xf0, 0x08, 0xbe, - 0x80, 0x99, 0x69, 0x8d, 0xac, 0x66, 0xce, 0xff, 0xfd, 0xf3, 0x4d, 0x72, 0x68, 0x0f, 0xb2, 0x95, - 0x62, 0x79, 0xac, 0x34, 0xc8, 0x64, 0x0a, 0x63, 0x06, 0x4b, 0x0d, 0x52, 0xc4, 0x59, 0x94, 0x8a, - 0x04, 0x84, 0x4e, 0xdf, 0x20, 0x28, 0x24, 0x6a, 0x74, 0x4f, 0x4d, 0x33, 0xf8, 0x6b, 0x5e, 0x5f, - 0x4c, 0x70, 0x82, 0x96, 0x31, 0x73, 0x2b, 0x6b, 0x77, 0xdf, 0x84, 0x9e, 0x3f, 0x55, 0x8e, 0xf0, - 0x57, 0xe1, 0xb6, 0x69, 0x2d, 0xe5, 0x1e, 0xe9, 0x92, 0x5e, 0x7d, 0x58, 0x4b, 0xb9, 0x7b, 0x4b, - 0x4f, 0x24, 0x2c, 0x62, 0xc9, 0x23, 0x0e, 0x02, 0x73, 0xaf, 0xd6, 0x25, 0xbd, 0xd6, 0xf0, 0xb8, - 0xcc, 0x1e, 0x4d, 0xe4, 0x5e, 0xd2, 0x66, 0x81, 0x98, 0x45, 0x29, 0xf7, 0xfe, 0xd9, 0x77, 0x0d, - 0x33, 0x86, 0xdc, 0xbd, 0xa1, 0x74, 0x2c, 0x31, 0x8f, 0x46, 0x19, 0x26, 0x33, 0xaf, 0x6e, 0x59, - 0xcb, 0x24, 0x03, 0x13, 0xb8, 0x57, 0xf4, 0x48, 0x63, 0x05, 0xff, 0x5b, 0xd8, 0xd4, 0x58, 0xa2, - 0x17, 0x7a, 0x16, 0xe7, 0x38, 0x17, 0x3a, 0x2a, 0x40, 0x56, 0x95, 0x86, 0xf9, 0x79, 0x10, 0xac, - 0xb7, 0x1d, 0xe7, 0x73, 0xdb, 0xb9, 0x9f, 0xa4, 0x7a, 0x3a, 0x1f, 0x05, 0x09, 0xe6, 0x2c, 0x41, - 0x95, 0xa3, 0xaa, 0x8e, 0xbe, 0xe2, 0x33, 0xa6, 0x57, 0x05, 0xa8, 0x20, 0x14, 0x7a, 0xd8, 0x2e, - 0x3d, 0xcf, 0x20, 0xad, 0x79, 0x10, 0xae, 0x77, 0x3e, 0xd9, 0xec, 0x7c, 0xf2, 0xb5, 0xf3, 0xc9, - 0xfb, 0xde, 0x77, 0x36, 0x7b, 0xdf, 0xf9, 0xd8, 0xfb, 0xce, 0x2b, 0x3b, 0x30, 0x9a, 0x0d, 0xf6, - 0x05, 0xe8, 0x05, 0xca, 0x99, 0x1d, 0xd8, 0xf2, 0x70, 0xf5, 0x56, 0x3f, 0x6a, 0xd8, 0x3d, 0x3e, - 0xfc, 0x04, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xf4, 0xab, 0xe0, 0x9a, 0x01, 0x00, 0x00, + // 334 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xc1, 0x4e, 0xf2, 0x40, + 0x14, 0x85, 0xdb, 0xc2, 0x0f, 0x3f, 0xa3, 0x41, 0x6d, 0x4c, 0xac, 0x26, 0x16, 0x74, 0x61, 0xd8, + 0xd0, 0x59, 0xf8, 0x02, 0x86, 0xe0, 0xa2, 0x3b, 0xd3, 0x95, 0x71, 0xd3, 0x94, 0xce, 0x05, 0x1a, + 0xda, 0xb9, 0xcd, 0x74, 0x10, 0x78, 0x0b, 0x5f, 0xc6, 0x77, 0x60, 0xc9, 0xd2, 0xb8, 0x20, 0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0xe9, 0x17, 0x6c, 0x46, 0xe5, 0x2a, 0x87, 0xc2, 0xf3, 0xb9, + 0x0c, 0xda, 0x25, 0xe7, 0x09, 0x44, 0x49, 0x7e, 0x20, 0xb5, 0x28, 0x17, 0x4e, 0xf3, 0xcf, 0xb0, + 0x21, 0xc4, 0x81, 0x5a, 0x1d, 0xf8, 0xeb, 0x9d, 0x6b, 0x6e, 0x76, 0xae, 0xf9, 0xb5, 0x73, 0xcd, + 0xb7, 0xbd, 0x6b, 0x6c, 0xf6, 0xae, 0xf1, 0xb1, 0x77, 0x8d, 0x17, 0x7a, 0x80, 0x51, 0x1d, 0xf4, + 0x39, 0xc8, 0x05, 0x8a, 0x99, 0x1e, 0xe8, 0xf2, 0xb0, 0x3c, 0xcd, 0x1c, 0x35, 0x74, 0x13, 0xf7, + 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1b, 0x9c, 0x07, 0x37, 0xdc, 0x01, 0x00, 0x00, } func (m *ExternalIncentive) Marshal() (dAtA []byte, err error) { @@ -154,6 +156,16 @@ func (m *ExternalIncentive) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.Apr.Size() + i -= size + if _, err := m.Apr.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintExternalIncentive(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a { size := m.AmountPerBlock.Size() i -= size @@ -229,6 +241,8 @@ func (m *ExternalIncentive) Size() (n int) { } l = m.AmountPerBlock.Size() n += 1 + l + sovExternalIncentive(uint64(l)) + l = m.Apr.Size() + n += 1 + l + sovExternalIncentive(uint64(l)) return n } @@ -409,6 +423,40 @@ func (m *ExternalIncentive) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Apr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExternalIncentive + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthExternalIncentive + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExternalIncentive + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Apr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipExternalIncentive(dAtA[iNdEx:]) diff --git a/x/masterchef/types/genesis.pb.go b/x/masterchef/types/genesis.pb.go index 85f9be374..a538f784b 100644 --- a/x/masterchef/types/genesis.pb.go +++ b/x/masterchef/types/genesis.pb.go @@ -25,11 +25,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the masterchef module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - ExternalIncentives []ExternalIncentive `protobuf:"bytes,2,rep,name=external_incentives,json=externalIncentives,proto3" json:"external_incentives"` - PoolInfos []PoolInfo `protobuf:"bytes,3,rep,name=pool_infos,json=poolInfos,proto3" json:"pool_infos"` - PoolRewardInfos []PoolRewardInfo `protobuf:"bytes,4,rep,name=pool_reward_infos,json=poolRewardInfos,proto3" json:"pool_reward_infos"` - UserRewardInfos []UserRewardInfo `protobuf:"bytes,5,rep,name=user_reward_infos,json=userRewardInfos,proto3" json:"user_reward_infos"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + ExternalIncentives []ExternalIncentive `protobuf:"bytes,2,rep,name=external_incentives,json=externalIncentives,proto3" json:"external_incentives"` + ExternalIncentiveIndex uint64 `protobuf:"varint,3,opt,name=external_incentive_index,json=externalIncentiveIndex,proto3" json:"external_incentive_index,omitempty"` + PoolInfos []PoolInfo `protobuf:"bytes,4,rep,name=pool_infos,json=poolInfos,proto3" json:"pool_infos"` + PoolRewardInfos []PoolRewardInfo `protobuf:"bytes,5,rep,name=pool_reward_infos,json=poolRewardInfos,proto3" json:"pool_reward_infos"` + UserRewardInfos []UserRewardInfo `protobuf:"bytes,6,rep,name=user_reward_infos,json=userRewardInfos,proto3" json:"user_reward_infos"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -79,6 +80,13 @@ func (m *GenesisState) GetExternalIncentives() []ExternalIncentive { return nil } +func (m *GenesisState) GetExternalIncentiveIndex() uint64 { + if m != nil { + return m.ExternalIncentiveIndex + } + return 0 +} + func (m *GenesisState) GetPoolInfos() []PoolInfo { if m != nil { return m.PoolInfos @@ -107,28 +115,30 @@ func init() { func init() { proto.RegisterFile("elys/masterchef/genesis.proto", fileDescriptor_b55d8c0403fbd8da) } var fileDescriptor_b55d8c0403fbd8da = []byte{ - // 336 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0xd1, 0x31, 0x4f, 0xc2, 0x40, - 0x14, 0x07, 0xf0, 0x56, 0x90, 0xc4, 0xc3, 0x84, 0x58, 0x4d, 0xc4, 0x46, 0x0b, 0x61, 0x62, 0xb1, - 0x4d, 0x30, 0xae, 0x0e, 0x24, 0xc6, 0xb0, 0x29, 0xc6, 0x41, 0x17, 0x52, 0xf0, 0x51, 0x1a, 0xcb, - 0xbd, 0xe6, 0xde, 0x21, 0xf0, 0x05, 0x9c, 0xfd, 0x58, 0x8c, 0x8c, 0x4e, 0xc6, 0xc0, 0x17, 0x31, - 0xbd, 0x9e, 0x11, 0x5a, 0xdd, 0x7a, 0xf7, 0xff, 0xf7, 0x77, 0x2f, 0x79, 0xec, 0x0c, 0xa2, 0x39, - 0x79, 0x63, 0x9f, 0x24, 0x88, 0xc1, 0x08, 0x86, 0x5e, 0x00, 0x1c, 0x28, 0x24, 0x37, 0x16, 0x28, - 0xd1, 0xaa, 0x24, 0xb1, 0xfb, 0x1b, 0xdb, 0x47, 0x01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- 0x3e, 0xd6, 0x8e, 0xf1, 0xe4, 0x05, 0xa1, 0x1c, 0x4d, 0xfa, 0xee, 0x00, 0xc7, 0x5e, 0x62, 0x9f, - 0x73, 0x90, 0x53, 0x14, 0x2f, 0xea, 0xe0, 0xcd, 0x36, 0x17, 0x2b, 0xe7, 0x31, 0x50, 0xbf, 0xa4, - 0x56, 0x7b, 0xf1, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x17, 0x5f, 0x62, 0x86, 0x02, 0x00, 0x00, + // 361 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x41, 0x4f, 0xf2, 0x30, + 0x18, 0xc7, 0xb7, 0x17, 0x5e, 0x12, 0x8b, 0x09, 0xb1, 0x1a, 0x9d, 0x8b, 0x0e, 0xc2, 0x69, 0x17, + 0xb7, 0x04, 0x63, 0xe2, 0xc9, 0x03, 0x89, 0x31, 0xbb, 0x29, 0xc6, 0x83, 0x5e, 0xc8, 0x80, 0x87, + 0xb1, 0x38, 0xda, 0xa5, 0x2d, 0x02, 0xdf, 0xc2, 0x8f, 0xe4, 0x91, 0x23, 0x47, 0x4f, 0xc6, 0xc0, + 0x17, 0x31, 0xeb, 0x6a, 0x84, 0x55, 0x6f, 0x6d, 0x7f, 0xff, 0xfe, 0xfa, 0x6f, 0xf2, 0xa0, 0x53, + 0x48, 0xe6, 0xdc, 0x1f, 0x87, 0x5c, 0x00, 0xeb, 0x8f, 0x60, 0xe8, 0x47, 0x40, 0x80, 0xc7, 0xdc, + 0x4b, 0x19, 0x15, 0x14, 0xd7, 0x32, 0xec, 0xfd, 0x60, 0xfb, 0x20, 0xa2, 0x11, 0x95, 0xcc, 0xcf, + 0x56, 0x79, 0xcc, 0x3e, 0x29, 0x5a, 0xd2, 0x90, 0x85, 0x63, 0x25, 0xb1, 0xdd, 0x22, 0x85, 0x99, + 0x00, 0x46, 0xc2, 0xa4,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, 0xda, 0x31, 0x9e, 0xfc, 0x28, 0x16, 0xa3, + 0x49, 0xcf, 0xeb, 0xd3, 0xb1, 0x9f, 0xb9, 0xcf, 0x08, 0x88, 0x29, 0x65, 0xcf, 0x72, 0xe3, 0xcf, + 0x36, 0x47, 0x42, 0xcc, 0x53, 0xe0, 0xbd, 0x8a, 0x1c, 0x8a, 0xf3, 0xaf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xf1, 0xfe, 0x11, 0x4d, 0xc0, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -162,7 +172,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } } if len(m.PoolRewardInfos) > 0 { @@ -176,7 +186,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } } if len(m.PoolInfos) > 0 { @@ -190,9 +200,14 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } } + if m.ExternalIncentiveIndex != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ExternalIncentiveIndex)) + i-- + dAtA[i] = 0x18 + } if len(m.ExternalIncentives) > 0 { for iNdEx := len(m.ExternalIncentives) - 1; iNdEx >= 0; iNdEx-- { { @@ -245,6 +260,9 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if m.ExternalIncentiveIndex != 0 { + n += 1 + sovGenesis(uint64(m.ExternalIncentiveIndex)) + } if len(m.PoolInfos) > 0 { for _, e := range m.PoolInfos { l = e.Size() @@ -369,6 +387,25 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExternalIncentiveIndex", wireType) + } + m.ExternalIncentiveIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExternalIncentiveIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PoolInfos", wireType) } @@ -402,7 +439,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PoolRewardInfos", wireType) } @@ -436,7 +473,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UserRewardInfos", wireType) } diff --git a/x/masterchef/types/params.go b/x/masterchef/types/params.go index 18bab01e3..cc275c196 100644 --- a/x/masterchef/types/params.go +++ b/x/masterchef/types/params.go @@ -97,10 +97,6 @@ func validateLPIncentives(i interface{}) error { return fmt.Errorf("invalid eden amount per year: %v", vv) } - if vv.TotalBlocksPerYear.LT(sdk.NewInt(1)) { - return fmt.Errorf("invalid total blocks per year: %v", vv) - } - if vv.BlocksDistributed.LT(sdk.NewInt(0)) { return fmt.Errorf("invalid BlocksDistributed: %v", vv) } diff --git a/x/masterchef/types/types.go b/x/masterchef/types/types.go index ea6676e30..ab1254f4c 100644 --- a/x/masterchef/types/types.go +++ b/x/masterchef/types/types.go @@ -1,20 +1 @@ package types - -import ( - fmt "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// TotalCommitmentInfo -// Stores the -type TotalCommitmentInfo struct { - // Revenue tracking per pool, key => (poolId) - PoolRevenueTrack map[string]sdk.Dec -} - -// Returns the pool revenue tracking key. -// Unique per pool, clean once complete the calculation. -func GetPoolRevenueTrackKey(poolId uint64) string { - return fmt.Sprintf("pool_revenue_%d", poolId) -} diff --git a/x/parameter/keeper/msg_server.go b/x/parameter/keeper/msg_server.go index 95f0e9171..9a2917a63 100644 --- a/x/parameter/keeper/msg_server.go +++ b/x/parameter/keeper/msg_server.go @@ -88,3 +88,16 @@ func (k msgServer) UpdateBrokerAddress(goCtx context.Context, msg *types.MsgUpda k.SetParams(ctx, params) return &types.MsgUpdateBrokerAddressResponse{}, nil } + +func (k msgServer) UpdateTotalBlocksPerYear(goCtx context.Context, msg *types.MsgUpdateTotalBlocksPerYear) (*types.MsgUpdateTotalBlocksPerYearResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Creator { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Creator) + } + + params := k.GetParams(ctx) + params.TotalBlocksPerYear = msg.TotalBlocksPerYear + k.SetParams(ctx, params) + return &types.MsgUpdateTotalBlocksPerYearResponse{}, nil +} diff --git a/x/parameter/migrations/v2_migration.go b/x/parameter/migrations/v2_migration.go index 246effd3a..af9b72a36 100644 --- a/x/parameter/migrations/v2_migration.go +++ b/x/parameter/migrations/v2_migration.go @@ -12,6 +12,7 @@ func (m Migrator) V2Migration(ctx sdk.Context) error { sdk.NewDecWithPrec(66, 1), // max voting power sdk.NewInt(1), // min self delegation "elys1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnrec2l", // broker address + 6307200, // total blocks per year ) m.keeper.SetParams(ctx, params) diff --git a/x/parameter/migrations/v3_migration.go b/x/parameter/migrations/v3_migration.go new file mode 100644 index 000000000..ddcfbc225 --- /dev/null +++ b/x/parameter/migrations/v3_migration.go @@ -0,0 +1,20 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/parameter/types" +) + +func (m Migrator) V3Migration(ctx sdk.Context) error { + // reset params + params := types.NewParams( + sdk.NewDecWithPrec(5, 2), // min commission 0.05 + sdk.NewDecWithPrec(66, 2), // max voting power 0.66 + sdk.NewInt(1), // min self delegation + "elys1m3hduhk4uzxn8mxuvpz02ysndxfwgy5mq60h4c34qqn67xud584qeee3m4", // broker address + 6307200, // total blocks per year + ) + m.keeper.SetParams(ctx, params) + + return nil +} diff --git a/x/parameter/module.go b/x/parameter/module.go index 6b352cf24..77ffe70b3 100644 --- a/x/parameter/module.go +++ b/x/parameter/module.go @@ -117,7 +117,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) m := migrations.NewMigrator(am.keeper) - err := cfg.RegisterMigration(types.ModuleName, 1, m.V2Migration) + err := cfg.RegisterMigration(types.ModuleName, 2, m.V3Migration) if err != nil { panic(err) } @@ -144,7 +144,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/parameter/types/codec.go b/x/parameter/types/codec.go index aaf7e6103..36719668e 100644 --- a/x/parameter/types/codec.go +++ b/x/parameter/types/codec.go @@ -15,6 +15,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdateMaxVotingPower{}, "parameter/MsgUpdateMaxVotingPower", nil) cdc.RegisterConcrete(&MsgUpdateMinSelfDelegation{}, "parameter/MsgUpdateMinSelfDelegation", nil) cdc.RegisterConcrete(&MsgUpdateBrokerAddress{}, "parameter/MsgUpdateBrokerAddress", nil) + cdc.RegisterConcrete(&MsgUpdateTotalBlocksPerYear{}, "parameter/MsgUpdateTotalBlocksPerYear", nil) // this line is used by starport scaffolding # 2 } @@ -24,6 +25,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgUpdateMaxVotingPower{}, &MsgUpdateMinSelfDelegation{}, &MsgUpdateBrokerAddress{}, + &MsgUpdateTotalBlocksPerYear{}, ) // this line is used by starport scaffolding # 3 diff --git a/x/parameter/types/msgs.go b/x/parameter/types/msgs.go index eb3b75eff..16647896c 100644 --- a/x/parameter/types/msgs.go +++ b/x/parameter/types/msgs.go @@ -110,3 +110,33 @@ func (msg *MsgUpdateBrokerAddress) ValidateBasic() error { } return nil } + +var _ sdk.Msg = &MsgUpdateTotalBlocksPerYear{} + +func NewMsgUpdateTotalBlocksPerYear(creator string, totalBlocksPerYear int64) *MsgUpdateTotalBlocksPerYear { + return &MsgUpdateTotalBlocksPerYear{ + Creator: creator, + TotalBlocksPerYear: totalBlocksPerYear, + } +} + +func (msg *MsgUpdateTotalBlocksPerYear) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} + +func (msg *MsgUpdateTotalBlocksPerYear) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + + if msg.TotalBlocksPerYear == 0 { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid total blocks per year") + } + + return nil +} diff --git a/x/parameter/types/params.go b/x/parameter/types/params.go index f6dcb3323..88ea6fbf0 100644 --- a/x/parameter/types/params.go +++ b/x/parameter/types/params.go @@ -7,12 +7,19 @@ import ( ) // NewParams creates a new Params instance -func NewParams(minCommissionRate sdk.Dec, maxVotingPower sdk.Dec, minSelfDelegation math.Int, brokerAddress string) Params { +func NewParams( + minCommissionRate sdk.Dec, + maxVotingPower sdk.Dec, + minSelfDelegation math.Int, + brokerAddress string, + totalBlocksPerYear int64, +) Params { return Params{ - MinCommissionRate: minCommissionRate, - MaxVotingPower: maxVotingPower, - MinSelfDelegation: minSelfDelegation, - BrokerAddress: brokerAddress, + MinCommissionRate: minCommissionRate, + MaxVotingPower: maxVotingPower, + MinSelfDelegation: minSelfDelegation, + BrokerAddress: brokerAddress, + TotalBlocksPerYear: totalBlocksPerYear, } } @@ -23,6 +30,7 @@ func DefaultParams() Params { sdk.NewDec(100), sdk.OneInt(), "elys1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnrec2l", + 6307200, ) } diff --git a/x/parameter/types/params.pb.go b/x/parameter/types/params.pb.go index aa540c1dc..b8763e201 100644 --- a/x/parameter/types/params.pb.go +++ b/x/parameter/types/params.pb.go @@ -26,10 +26,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - MinCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_commission_rate"` - MaxVotingPower github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=max_voting_power,json=maxVotingPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_voting_power"` - MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"` - BrokerAddress string `protobuf:"bytes,4,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` + MinCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_commission_rate"` + MaxVotingPower github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=max_voting_power,json=maxVotingPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_voting_power"` + MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"` + BrokerAddress string `protobuf:"bytes,4,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` + TotalBlocksPerYear int64 `protobuf:"varint,5,opt,name=total_blocks_per_year,json=totalBlocksPerYear,proto3" json:"total_blocks_per_year,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -71,6 +72,13 @@ func (m *Params) GetBrokerAddress() string { return "" } +func (m *Params) GetTotalBlocksPerYear() int64 { + if m != nil { + return m.TotalBlocksPerYear + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "elys.parameter.Params") } @@ -78,27 +86,29 @@ func init() { func init() { proto.RegisterFile("elys/parameter/params.proto", fileDescriptor_b61780a5be327c2b) } var fileDescriptor_b61780a5be327c2b = []byte{ - // 316 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0x31, 0x4b, 0xc3, 0x40, - 0x14, 0xc7, 0x93, 0x5a, 0x0a, 0x06, 0x2c, 0x1a, 0x1d, 0x82, 0x42, 0x2a, 0x82, 0xe2, 0xd2, 0xcb, - 0xe0, 0xe6, 0x66, 0xed, 0xa0, 0x5b, 0xa9, 0x20, 0xe2, 0xe0, 0x71, 0x4d, 0x5e, 0xe3, 0xd1, 0xdc, - 0xbd, 0x70, 0x77, 0xda, 0xf6, 0x5b, 0x38, 0x3a, 0xfa, 0x71, 0xba, 0xd9, 0x51, 0x1c, 0x8a, 0xb4, - 0x5f, 0x44, 0x72, 0xd1, 0xd0, 0x55, 0xa7, 0x7b, 0xf7, 0xfe, 0x77, 0x3f, 0x7e, 0xf0, 0xf7, 0x0e, - 0x20, 0x9b,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f, 0x86, 0xee, 0xd7, 0x32, 0x74, 0x5f, 0x56, 0xa1, - 0x33, 0x5f, 0x85, 0xce, 0xc7, 0x2a, 0x74, 0xee, 0xc9, 0x9a, 0x41, 0x51, 0x4e, 0x5b, 0x82, 0x19, - 0xa3, 0x1a, 0xd9, 0x4b, 0x34, 0x59, 0x2b, 0xd2, 0xda, 0x0c, 0x1a, 0xb6, 0xa2, 0xb3, 0xef, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xe2, 0x79, 0x2a, 0x74, 0xe7, 0x01, 0x00, 0x00, + // 352 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xc1, 0x4a, 0xeb, 0x40, + 0x14, 0x86, 0x93, 0xdb, 0xde, 0xc2, 0x0d, 0xdc, 0xa2, 0x51, 0x21, 0x28, 0xa4, 0x45, 0x50, 0xba, + 0x69, 0x82, 0xb8, 0x73, 0x67, 0xed, 0x42, 0x77, 0x25, 0x82, 0xa8, 0x0b, 0x87, 0x49, 0x72, 0x1a, + 0x43, 0x32, 0x73, 0xc2, 0xcc, 0x68, 0xdb, 0xad, 0x4f, 0xe0, 0xd2, 0xa5, 0x8f, 0xd3, 0x65, 0x97, + 0xe2, 0xa2, 0x48, 0xfb, 0x22, 0x92, 0x89, 0x96, 0x6e, 0x75, 0x95, 0x93, 0xf3, 0xcd, 0x7c, 0xfc, + 0xc3, 0x6f, 0xed, 0x41, 0x3e, 0x91, 0x7e, 0x41, 0x05, 0x65, 0xa0, 0x40, 0x54, 0x93, 0xf4, 0x0a, + 0x81, 0x0a, 0xed, 0x66, 0x09, 0xbd, 0x15, 0xdc, 0xdd, 0x4e, 0x30, 0x41, 0x8d, 0xfc, 0x72, 0xaa, + 0x4e, 0xed, 0x3f, 0xd5, 0xac, 0xc6, 0x40, 0x5f, 0xb3, 0xef, 0xac, 0x2d, 0x96, 0x72, 0x12, 0x21, + 0x63, 0x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x1a, 0x6f, 0x4b, 0xd7, 0xb8, 0xf5, 0xd6, 0x42, 0x97, + 0x7d, 0x76, 0x39, 0xa8, 0x11, 0x8a, 0x4c, 0xff, 0xf8, 0xe3, 0xb5, 0xee, 0xf5, 0x03, 0xc2, 0x86, + 0x6e, 0xf5, 0xf8, 0x33, 0x00, 0x00, 0xff, 0xff, 0xf3, 0xe7, 0xd9, 0x9d, 0x1a, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -121,6 +131,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.TotalBlocksPerYear != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.TotalBlocksPerYear)) + i-- + dAtA[i] = 0x28 + } if len(m.BrokerAddress) > 0 { i -= len(m.BrokerAddress) copy(dAtA[i:], m.BrokerAddress) @@ -188,6 +203,9 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } + if m.TotalBlocksPerYear != 0 { + n += 1 + sovParams(uint64(m.TotalBlocksPerYear)) + } return n } @@ -360,6 +378,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.BrokerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBlocksPerYear", wireType) + } + m.TotalBlocksPerYear = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalBlocksPerYear |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/parameter/types/query.pb.gw.go b/x/parameter/types/query.pb.gw.go index b076ffb76..d8ea85070 100644 --- a/x/parameter/types/query.pb.gw.go +++ b/x/parameter/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -54,14 +52,12 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -69,7 +65,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/parameter/types/tx.pb.go b/x/parameter/types/tx.pb.go index 7df69fe5a..4ec89549f 100644 --- a/x/parameter/types/tx.pb.go +++ b/x/parameter/types/tx.pb.go @@ -117,7 +117,7 @@ var xxx_messageInfo_MsgUpdateMinCommissionResponse proto.InternalMessageInfo type MsgUpdateMaxVotingPower struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - MaxVotingPower string `protobuf:"bytes,3,opt,name=max_voting_power,json=maxVotingPower,proto3" json:"max_voting_power,omitempty"` + MaxVotingPower string `protobuf:"bytes,2,opt,name=max_voting_power,json=maxVotingPower,proto3" json:"max_voting_power,omitempty"` } func (m *MsgUpdateMaxVotingPower) Reset() { *m = MsgUpdateMaxVotingPower{} } @@ -205,7 +205,7 @@ var xxx_messageInfo_MsgUpdateMaxVotingPowerResponse proto.InternalMessageInfo type MsgUpdateMinSelfDelegation struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - MinSelfDelegation string `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3" json:"min_self_delegation,omitempty"` + MinSelfDelegation string `protobuf:"bytes,2,opt,name=min_self_delegation,json=minSelfDelegation,proto3" json:"min_self_delegation,omitempty"` } func (m *MsgUpdateMinSelfDelegation) Reset() { *m = MsgUpdateMinSelfDelegation{} } @@ -293,7 +293,7 @@ var xxx_messageInfo_MsgUpdateMinSelfDelegationResponse proto.InternalMessageInfo type MsgUpdateBrokerAddress struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - BrokerAddress string `protobuf:"bytes,3,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` + BrokerAddress string `protobuf:"bytes,2,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` } func (m *MsgUpdateBrokerAddress) Reset() { *m = MsgUpdateBrokerAddress{} } @@ -379,6 +379,94 @@ func (m *MsgUpdateBrokerAddressResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateBrokerAddressResponse proto.InternalMessageInfo +type MsgUpdateTotalBlocksPerYear struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + TotalBlocksPerYear int64 `protobuf:"varint,2,opt,name=total_blocks_per_year,json=totalBlocksPerYear,proto3" json:"total_blocks_per_year,omitempty"` +} + +func (m *MsgUpdateTotalBlocksPerYear) Reset() { *m = MsgUpdateTotalBlocksPerYear{} } +func (m *MsgUpdateTotalBlocksPerYear) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateTotalBlocksPerYear) ProtoMessage() {} +func (*MsgUpdateTotalBlocksPerYear) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{8} +} +func (m *MsgUpdateTotalBlocksPerYear) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateTotalBlocksPerYear) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateTotalBlocksPerYear.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateTotalBlocksPerYear) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateTotalBlocksPerYear.Merge(m, src) +} +func (m *MsgUpdateTotalBlocksPerYear) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateTotalBlocksPerYear) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateTotalBlocksPerYear.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateTotalBlocksPerYear proto.InternalMessageInfo + +func (m *MsgUpdateTotalBlocksPerYear) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateTotalBlocksPerYear) GetTotalBlocksPerYear() int64 { + if m != nil { + return m.TotalBlocksPerYear + } + return 0 +} + +type MsgUpdateTotalBlocksPerYearResponse struct { +} + +func (m *MsgUpdateTotalBlocksPerYearResponse) Reset() { *m = MsgUpdateTotalBlocksPerYearResponse{} } +func (m *MsgUpdateTotalBlocksPerYearResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateTotalBlocksPerYearResponse) ProtoMessage() {} +func (*MsgUpdateTotalBlocksPerYearResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d997b2afb1f3cab, []int{9} +} +func (m *MsgUpdateTotalBlocksPerYearResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateTotalBlocksPerYearResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateTotalBlocksPerYearResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateTotalBlocksPerYearResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateTotalBlocksPerYearResponse.Merge(m, src) +} +func (m *MsgUpdateTotalBlocksPerYearResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateTotalBlocksPerYearResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateTotalBlocksPerYearResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateTotalBlocksPerYearResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgUpdateMinCommission)(nil), "elys.parameter.MsgUpdateMinCommission") proto.RegisterType((*MsgUpdateMinCommissionResponse)(nil), "elys.parameter.MsgUpdateMinCommissionResponse") @@ -388,38 +476,44 @@ func init() { proto.RegisterType((*MsgUpdateMinSelfDelegationResponse)(nil), "elys.parameter.MsgUpdateMinSelfDelegationResponse") proto.RegisterType((*MsgUpdateBrokerAddress)(nil), "elys.parameter.MsgUpdateBrokerAddress") proto.RegisterType((*MsgUpdateBrokerAddressResponse)(nil), "elys.parameter.MsgUpdateBrokerAddressResponse") + proto.RegisterType((*MsgUpdateTotalBlocksPerYear)(nil), "elys.parameter.MsgUpdateTotalBlocksPerYear") + proto.RegisterType((*MsgUpdateTotalBlocksPerYearResponse)(nil), "elys.parameter.MsgUpdateTotalBlocksPerYearResponse") } func init() { proto.RegisterFile("elys/parameter/tx.proto", fileDescriptor_9d997b2afb1f3cab) } var fileDescriptor_9d997b2afb1f3cab = []byte{ - // 408 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xdf, 0x6a, 0xdb, 0x30, - 0x18, 0xc5, 0xe3, 0x05, 0x36, 0x26, 0x48, 0xd8, 0x9c, 0xb1, 0x18, 0x5f, 0x78, 0x99, 0xd9, 0x9f, - 0x30, 0x98, 0x0c, 0xd9, 0x13, 0x2c, 0xdb, 0xc5, 0x6e, 0x02, 0x23, 0x63, 0x83, 0x15, 0x8a, 0x91, - 0xe3, 0x2f, 0xae, 0x89, 0x65, 0x19, 0x49, 0x6d, 0x9c, 0xb7, 0xe8, 0x63, 0xf5, 0x32, 0x97, 0xbd, - 0x2c, 0xc9, 0x8b, 0x14, 0xbb, 0x89, 0x6a, 0x15, 0xdb, 0xe4, 0x52, 0xe8, 0xa7, 0x73, 0x0e, 0xdf, - 0xf9, 0x10, 0x1a, 0x42, 0xb2, 0x11, 0x5e, 0x46, 0x38, 0xa1, 0x20, 0x81, 0x7b, 0x32, 0xc7, 0x19, - 0x67, 0x92, 0x99, 0xfd, 0xe2, 0x02, 0xab, 0x0b, 0xf7, 0x3f, 0x7a, 0x3b, 0x13, 0xd1, 0xdf, 0x2c, - 0x24, 0x12, 0x66, 0x71, 0xfa, 0x83, 0x51, 0x1a, 0x0b, 0x11, 0xb3, 0xd4, 0xb4, 0xd0, 0x8b, 0x05, - 0x07, 0x22, 0x19, 0xb7, 0x8c, 0x91, 0x31, 0x7e, 0x39, 0x3f, 0x1e, 0xcd, 0x8f, 0xa8, 0x4f, 0xe3, - 0xd4, 0x5f, 0x28, 0xd6, 0x7a, 0x56, 0x02, 0x3d, 0x5a, 0x15, 0x70, 0x47, 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x2b, 0x9d, 0xfe, 0xba, 0xd9, 0x39, 0xc6, 0x76, 0xe7, 0x18, 0x77, 0x3b, 0xc7, - 0xb8, 0xde, 0x3b, 0x9d, 0xed, 0xde, 0xe9, 0xdc, 0xee, 0x9d, 0xce, 0x19, 0x8e, 0x62, 0x79, 0x71, - 0x19, 0xe0, 0x05, 0xa3, 0x5e, 0xa1, 0xf9, 0x35, 0x05, 0xb9, 0x66, 0x7c, 0x55, 0x1e, 0xbc, 0xbc, - 0xfa, 0x73, 0x6c, 0x32, 0x10, 0xc1, 0xf3, 0xf2, 0xf7, 0xf8, 0x76, 0x1f, 0x00, 0x00, 0xff, 0xff, - 0xdd, 0x88, 0xed, 0x25, 0x58, 0x04, 0x00, 0x00, + // 474 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xdf, 0x8a, 0xd3, 0x40, + 0x14, 0xc6, 0x1b, 0x57, 0x14, 0x0f, 0x58, 0x34, 0xab, 0xb6, 0x44, 0x88, 0x6b, 0x74, 0x75, 0x51, + 0x4c, 0x70, 0xf7, 0x09, 0xac, 0x5e, 0x78, 0x53, 0x58, 0xea, 0x1f, 0x58, 0x41, 0xc2, 0xa4, 0x3d, + 0x8d, 0xb1, 0x99, 0xcc, 0x30, 0x33, 0xba, 0x0d, 0xf8, 0x10, 0x3e, 0x96, 0x57, 0xb2, 0x97, 0x5e, + 0x4a, 0xfb, 0x22, 0x92, 0xec, 0x66, 0xcc, 0xd8, 0x24, 0xd4, 0xcb, 0x61, 0x7e, 0xf3, 0x7d, 0x87, + 0xf3, 0x7d, 0x0c, 0x0c, 0x30, 0xcd, 0x65, 0xc0, 0x89, 0x20, 0x14, 0x15, 0x8a, 0x40, 0x2d, 0x7d, + 0x2e, 0x98, 0x62, 0x76, 0xbf, 0xb8, 0xf0, 0xf5, 0x85, 0x77, 0x02, 0x77, 0xc6, 0x32, 0x7e, 0xc7, + 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8, 0xad, 0x0a, 0x3e, 0x8c, 0xca, 0x07, 0x21, 0x47, 0x11, + 0xe6, 0x48, 0xce, 0x53, 0xd9, 0x99, 0xd8, 0x6a, 0x43, 0xcc, 0xdb, 0x87, 0x07, 0x1d, 0x5e, 0xd5, + 0x48, 0x87, 0x3f, 0x2f, 0xc3, 0xce, 0x58, 0xc6, 0x36, 0x85, 0xdd, 0xa6, 0x86, 0x3e, 0xf2, 0xcd, + 0x32, 0xfb, 0xcd, 0x75, 0x73, 0xfc, 0xed, 0xb8, 0xca, 0xd6, 0xe6, 0x70, 0xab, 0xb1, 0x93, 0x8f, + 0xdb, 0x75, 0x0c, 0xd0, 0x09, 0xb6, 0x04, 0xb5, 0x63, 0x0e, 0x83, 0xb6, 0x0e, 0x3e, 0xe9, 0x1a, + 0xde, 0x64, 0x9d, 0xc3, 0xed, 0x59, 0x6d, 0xad, 0x77, 0x6b, 0x16, 0xae, 0x7d, 0xb7, 0x06, 0xd7, + 0xb1, 0xdb, 0xc6, 0x96, 0xd9, 0xdf, 0x60, 0xd8, 0x5a, 0xb1, 0xa7, 0xad, 0x5a, 0x9b, 0xb0, 0x73, + 0xf4, 0x1f, 0x70, 0xe5, 0x3e, 0x7a, 0xfd, 0x63, 0xe5, 0x5a, 0x67, 0x2b, 0xd7, 0xfa, 0xbd, 0x72, + 0xad, 0xef, 0x6b, 0xb7, 0x77, 0xb6, 0x76, 0x7b, 0xbf, 0xd6, 0x6e, 0xef, 0x83, 0x1f, 0x27, 0xea, + 0xd3, 0x97, 0xc8, 0x9f, 0x32, 0x1a, 0x14, 0xc2, 0xcf, 0x32, 0x54, 0xa7, 0x4c, 0x2c, 0xca, 0x43, + 0xb0, 0xac, 0x7f, 0xa5, 0x39, 0x47, 0x19, 0x5d, 0x29, 0xbf, 0xd3, 0xa3, 0x3f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x4e, 0x33, 0x30, 0x9f, 0x69, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -438,6 +532,7 @@ type MsgClient interface { UpdateMaxVotingPower(ctx context.Context, in *MsgUpdateMaxVotingPower, opts ...grpc.CallOption) (*MsgUpdateMaxVotingPowerResponse, error) UpdateMinSelfDelegation(ctx context.Context, in *MsgUpdateMinSelfDelegation, opts ...grpc.CallOption) (*MsgUpdateMinSelfDelegationResponse, error) UpdateBrokerAddress(ctx context.Context, in *MsgUpdateBrokerAddress, opts ...grpc.CallOption) (*MsgUpdateBrokerAddressResponse, error) + UpdateTotalBlocksPerYear(ctx context.Context, in *MsgUpdateTotalBlocksPerYear, opts ...grpc.CallOption) (*MsgUpdateTotalBlocksPerYearResponse, error) } type msgClient struct { @@ -484,12 +579,22 @@ func (c *msgClient) UpdateBrokerAddress(ctx context.Context, in *MsgUpdateBroker return out, nil } +func (c *msgClient) UpdateTotalBlocksPerYear(ctx context.Context, in *MsgUpdateTotalBlocksPerYear, opts ...grpc.CallOption) (*MsgUpdateTotalBlocksPerYearResponse, error) { + out := new(MsgUpdateTotalBlocksPerYearResponse) + err := c.cc.Invoke(ctx, "/elys.parameter.Msg/UpdateTotalBlocksPerYear", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { UpdateMinCommission(context.Context, *MsgUpdateMinCommission) (*MsgUpdateMinCommissionResponse, error) UpdateMaxVotingPower(context.Context, *MsgUpdateMaxVotingPower) (*MsgUpdateMaxVotingPowerResponse, error) UpdateMinSelfDelegation(context.Context, *MsgUpdateMinSelfDelegation) (*MsgUpdateMinSelfDelegationResponse, error) UpdateBrokerAddress(context.Context, *MsgUpdateBrokerAddress) (*MsgUpdateBrokerAddressResponse, error) + UpdateTotalBlocksPerYear(context.Context, *MsgUpdateTotalBlocksPerYear) (*MsgUpdateTotalBlocksPerYearResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -508,6 +613,9 @@ func (*UnimplementedMsgServer) UpdateMinSelfDelegation(ctx context.Context, req func (*UnimplementedMsgServer) UpdateBrokerAddress(ctx context.Context, req *MsgUpdateBrokerAddress) (*MsgUpdateBrokerAddressResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateBrokerAddress not implemented") } +func (*UnimplementedMsgServer) UpdateTotalBlocksPerYear(ctx context.Context, req *MsgUpdateTotalBlocksPerYear) (*MsgUpdateTotalBlocksPerYearResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateTotalBlocksPerYear not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -585,6 +693,24 @@ func _Msg_UpdateBrokerAddress_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_UpdateTotalBlocksPerYear_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateTotalBlocksPerYear) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateTotalBlocksPerYear(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.parameter.Msg/UpdateTotalBlocksPerYear", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateTotalBlocksPerYear(ctx, req.(*MsgUpdateTotalBlocksPerYear)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "elys.parameter.Msg", HandlerType: (*MsgServer)(nil), @@ -605,6 +731,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateBrokerAddress", Handler: _Msg_UpdateBrokerAddress_Handler, }, + { + MethodName: "UpdateTotalBlocksPerYear", + Handler: _Msg_UpdateTotalBlocksPerYear_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "elys/parameter/tx.proto", @@ -695,7 +825,7 @@ func (m *MsgUpdateMaxVotingPower) MarshalToSizedBuffer(dAtA []byte) (int, error) copy(dAtA[i:], m.MaxVotingPower) i = encodeVarintTx(dAtA, i, uint64(len(m.MaxVotingPower))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if len(m.Creator) > 0 { i -= len(m.Creator) @@ -755,7 +885,7 @@ func (m *MsgUpdateMinSelfDelegation) MarshalToSizedBuffer(dAtA []byte) (int, err copy(dAtA[i:], m.MinSelfDelegation) i = encodeVarintTx(dAtA, i, uint64(len(m.MinSelfDelegation))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if len(m.Creator) > 0 { i -= len(m.Creator) @@ -815,7 +945,7 @@ func (m *MsgUpdateBrokerAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) copy(dAtA[i:], m.BrokerAddress) i = encodeVarintTx(dAtA, i, uint64(len(m.BrokerAddress))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if len(m.Creator) > 0 { i -= len(m.Creator) @@ -850,6 +980,64 @@ func (m *MsgUpdateBrokerAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgUpdateTotalBlocksPerYear) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateTotalBlocksPerYear) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateTotalBlocksPerYear) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TotalBlocksPerYear != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TotalBlocksPerYear)) + i-- + dAtA[i] = 0x10 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateTotalBlocksPerYearResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateTotalBlocksPerYearResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateTotalBlocksPerYearResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -965,6 +1153,31 @@ func (m *MsgUpdateBrokerAddressResponse) Size() (n int) { return n } +func (m *MsgUpdateTotalBlocksPerYear) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.TotalBlocksPerYear != 0 { + n += 1 + sovTx(uint64(m.TotalBlocksPerYear)) + } + return n +} + +func (m *MsgUpdateTotalBlocksPerYearResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1196,7 +1409,7 @@ func (m *MsgUpdateMaxVotingPower) Unmarshal(dAtA []byte) error { } m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MaxVotingPower", wireType) } @@ -1360,7 +1573,7 @@ func (m *MsgUpdateMinSelfDelegation) Unmarshal(dAtA []byte) error { } m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", wireType) } @@ -1524,7 +1737,7 @@ func (m *MsgUpdateBrokerAddress) Unmarshal(dAtA []byte) error { } m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BrokerAddress", wireType) } @@ -1627,6 +1840,157 @@ func (m *MsgUpdateBrokerAddressResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateTotalBlocksPerYear) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateTotalBlocksPerYear: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateTotalBlocksPerYear: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBlocksPerYear", wireType) + } + m.TotalBlocksPerYear = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalBlocksPerYear |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateTotalBlocksPerYearResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateTotalBlocksPerYearResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateTotalBlocksPerYearResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0