Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/incentive refactor #291

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 85 additions & 8 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39623,7 +39623,14 @@ paths:
type: string
description: >-
Dex revenue percent for lps, 100 - reward_portion_for_lps
= revenue percent for stakers.
- reward_portion_for_stakers = revenue percent for
protocol.
reward_portion_for_stakers:
type: string
description: >-
Dex revenue percent for lps, 100 - reward_portion_for_lps
- reward_portion_for_stakers = revenue percent for
protocol.
pool_infos:
type: array
items:
Expand All @@ -39639,10 +39646,25 @@ paths:
multiplier:
type: string
title: multiplier for lp rewards
num_blocks:
type: string
title: Block number since creation
dex_reward_amount_given:
type: string
title: Total dex rewards given
eden_reward_amount_given:
type: string
title: Total eden rewards given
eden_apr:
type: string
title: Eden APR
dex_apr:
type: string
title: Dex APR
title: Pool Info
title: |-
Pool information
poolId, reward wallet, mulitplier
poolId, reward wallet, mulitplier, dex rewards given
elys_stake_tracking_rate:
type: string
format: int64
Expand Down Expand Up @@ -84051,8 +84073,13 @@ definitions:
reward_portion_for_lps:
type: string
description: >-
Dex revenue percent for lps, 100 - reward_portion_for_lps = revenue
percent for stakers.
Dex revenue percent for lps, 100 - reward_portion_for_lps -
reward_portion_for_stakers = revenue percent for protocol.
reward_portion_for_stakers:
type: string
description: >-
Dex revenue percent for lps, 100 - reward_portion_for_lps -
reward_portion_for_stakers = revenue percent for protocol.
pool_infos:
type: array
items:
Expand All @@ -84068,10 +84095,25 @@ definitions:
multiplier:
type: string
title: multiplier for lp rewards
num_blocks:
type: string
title: Block number since creation
dex_reward_amount_given:
type: string
title: Total dex rewards given
eden_reward_amount_given:
type: string
title: Total eden rewards given
eden_apr:
type: string
title: Eden APR
dex_apr:
type: string
title: Dex APR
title: Pool Info
title: |-
Pool information
poolId, reward wallet, mulitplier
poolId, reward wallet, mulitplier, dex rewards given
elys_stake_tracking_rate:
type: string
format: int64
Expand Down Expand Up @@ -84123,6 +84165,21 @@ definitions:
multiplier:
type: string
title: multiplier for lp rewards
num_blocks:
type: string
title: Block number since creation
dex_reward_amount_given:
type: string
title: Total dex rewards given
eden_reward_amount_given:
type: string
title: Total eden rewards given
eden_apr:
type: string
title: Eden APR
dex_apr:
type: string
title: Dex APR
title: Pool Info
elys.incentive.QueryCommunityPoolResponse:
type: object
Expand Down Expand Up @@ -84216,8 +84273,13 @@ definitions:
reward_portion_for_lps:
type: string
description: >-
Dex revenue percent for lps, 100 - reward_portion_for_lps =
revenue percent for stakers.
Dex revenue percent for lps, 100 - reward_portion_for_lps -
reward_portion_for_stakers = revenue percent for protocol.
reward_portion_for_stakers:
type: string
description: >-
Dex revenue percent for lps, 100 - reward_portion_for_lps -
reward_portion_for_stakers = revenue percent for protocol.
pool_infos:
type: array
items:
Expand All @@ -84233,10 +84295,25 @@ definitions:
multiplier:
type: string
title: multiplier for lp rewards
num_blocks:
type: string
title: Block number since creation
dex_reward_amount_given:
type: string
title: Total dex rewards given
eden_reward_amount_given:
type: string
title: Total eden rewards given
eden_apr:
type: string
title: Eden APR
dex_apr:
type: string
title: Dex APR
title: Pool Info
title: |-
Pool information
poolId, reward wallet, mulitplier
poolId, reward wallet, mulitplier, dex rewards given
elys_stake_tracking_rate:
type: string
format: int64
Expand Down
28 changes: 6 additions & 22 deletions proto/elys/commitment/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ message MsgVest {
string denom = 3;
}

message MsgVestCW {
string creator = 1;
string address = 2;
string amount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string denom = 4;
}

message MsgVestResponse {}

message MsgCancelVest {
Expand All @@ -93,13 +86,6 @@ message MsgCancelVest {
string denom = 3;
}

message MsgCancelVestCW {
string creator = 1;
string address = 2;
string amount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string denom = 4;
}

message MsgCancelVestResponse {}

message MsgVestNow {
Expand Down Expand Up @@ -138,10 +124,9 @@ message MsgClaimRewardsResponse {}

message MsgStake {
string creator = 1;
string address = 2;
string amount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string asset = 4;
string validator_address = 5;
string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string asset = 3;
string validator_address = 4;
}

message MsgStakeResponse {
Expand All @@ -151,10 +136,9 @@ message MsgStakeResponse {

message MsgUnstake {
string creator = 1;
string address = 2;
string amount = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string asset = 4;
string validator_address = 5;
string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string asset = 3;
string validator_address = 4;
}

message MsgUnstakeResponse {
Expand Down
30 changes: 18 additions & 12 deletions proto/elys/incentive/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package elys.incentive;
import "gogoproto/gogo.proto";
import "elys/incentive/incentive.proto";
import "elys/incentive/pool.proto";
import "elys/incentive/dex_rewards_stakers.proto";
import "elys/incentive/dex_rewards_traker.proto";

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

Expand All @@ -20,39 +20,45 @@ message Params {
];

bool withdraw_addr_enabled = 4;
// Dex revenue percent for lps, 100 - reward_portion_for_lps = revenue percent for stakers.
// Dex revenue percent for lps, 100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol.
string reward_portion_for_lps = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];


// Dex revenue percent for lps, 100 - reward_portion_for_lps - reward_portion_for_stakers = revenue percent for protocol.
string reward_portion_for_stakers = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Pool information
// poolId, reward wallet, mulitplier
repeated PoolInfo pool_infos = 6 [(gogoproto.nullable) = false];
// poolId, reward wallet, mulitplier, dex rewards given
repeated PoolInfo pool_infos = 7 [(gogoproto.nullable) = false];

int64 elys_stake_tracking_rate = 7;
int64 elys_stake_tracking_rate = 8;

// Tracking dex rewards given to stakers
DexRewardsTracker dex_rewards_stakers = 8 [(gogoproto.nullable) = false];
DexRewardsTracker dex_rewards_stakers = 9 [(gogoproto.nullable) = false];

// Tracking dex rewards given to LPs
DexRewardsTracker dex_rewards_lps = 9 [(gogoproto.nullable) = false];
DexRewardsTracker dex_rewards_lps = 10 [(gogoproto.nullable) = false];

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

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

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

// Distribution epochs for LPs in blocks
int64 distribution_epoch_for_lps_in_blocks = 13;
int64 distribution_epoch_for_lps_in_blocks = 14;
}
26 changes: 26 additions & 0 deletions proto/elys/incentive/pool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,30 @@ message PoolInfo {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Block number since creation
string num_blocks = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// Total dex rewards given
string dex_reward_amount_given = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// Total eden rewards given
string eden_reward_amount_given = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
// Eden APR
string eden_apr = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// Dex APR
string dex_apr = 8 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
28 changes: 12 additions & 16 deletions proto/elys/incentive/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ service Msg {
message MsgWithdrawRewards {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
elys.commitment.EarnType withdraw_type = 3;
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
elys.commitment.EarnType withdraw_type = 2;
}

// MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type.
Expand All @@ -39,9 +38,8 @@ message MsgWithdrawRewardsResponse {}
message MsgWithdrawValidatorCommission {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type.
Expand Down Expand Up @@ -77,22 +75,20 @@ message MsgBeginRedelegate {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_src_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_dst_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 5 [(gogoproto.nullable) = false];
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_src_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_dst_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false];
}

message MsgCancelUnbondingDelegation{
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string creator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// amount is always less than or equal to unbonding delegation entry balance
cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
// creation_height is the height which the unbonding took place.
int64 creation_height = 5;
int64 creation_height = 4;
}
4 changes: 2 additions & 2 deletions wasmbindings/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ type ElysMsg struct {
CommitmentCommitLiquidTokens *commitmenttypes.MsgCommitLiquidTokens `json:"commitment_commit_liquid_tokens,omitempty"`
CommitmentCommitUnclaimedRewards *commitmenttypes.MsgCommitClaimedRewards `json:"commitment_commit_unclaimed_rewards,omitempty"`
CommitmentUncommitTokens *commitmenttypes.MsgUncommitTokens `json:"commitment_uncommit_tokens,omitempty"`
CommitmentVest *commitmenttypes.MsgVestCW `json:"commitment_vest"`
CommitmentVest *commitmenttypes.MsgVest `json:"commitment_vest"`
CommitmentVestNow *commitmenttypes.MsgVestNow `json:"commitment_vest_now"`
CommitmentVestLiquid *commitmenttypes.MsgVestLiquid `json:"commitment_vest_liquid"`
CommitmentCancelVest *commitmenttypes.MsgCancelVestCW `json:"commitment_cancel_vest"`
CommitmentCancelVest *commitmenttypes.MsgCancelVest `json:"commitment_cancel_vest"`
CommitmentUpdateVestingInfo *commitmenttypes.MsgUpdateVestingInfo `json:"commitment_update_vesting_info"`
CommitmentStake *commitmenttypes.MsgStake `json:"commitment_stake,omitempty"`
CommitmentUnstake *commitmenttypes.MsgUnstake `json:"commitment_unstake,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions x/commitment/client/wasm/msg_cancel_vest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
paramtypes "github.com/elys-network/elys/x/parameter/types"
)

func (m *Messenger) msgCancelVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelVest *commitmenttypes.MsgCancelVestCW) ([]sdk.Event, [][]byte, error) {
func (m *Messenger) msgCancelVest(ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelVest *commitmenttypes.MsgCancelVest) ([]sdk.Event, [][]byte, error) {
if msgCancelVest == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "cancel vest null msg"}
}
Expand Down Expand Up @@ -43,13 +43,13 @@ func (m *Messenger) msgCancelVest(ctx sdk.Context, contractAddr sdk.AccAddress,
return nil, resp, nil
}

func performMsgCancelVestEden(f *commitmentkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelVest *commitmenttypes.MsgCancelVestCW) (*wasmbindingstypes.RequestResponse, error) {
func performMsgCancelVestEden(f *commitmentkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, msgCancelVest *commitmenttypes.MsgCancelVest) (*wasmbindingstypes.RequestResponse, error) {
if msgCancelVest == nil {
return nil, wasmvmtypes.InvalidRequest{Err: "Invalid cancel vesting parameter"}
}

msgServer := commitmentkeeper.NewMsgServerImpl(*f)
msgMsgCancelVest := commitmenttypes.NewMsgCancelVest(msgCancelVest.Address, msgCancelVest.Amount, msgCancelVest.Denom)
msgMsgCancelVest := commitmenttypes.NewMsgCancelVest(msgCancelVest.Creator, msgCancelVest.Amount, msgCancelVest.Denom)

if err := msgMsgCancelVest.ValidateBasic(); err != nil {
return nil, errorsmod.Wrap(err, "failed validating msgMsgCancelVest")
Expand Down
Loading
Loading