Add generic incentive AccumulateRewards method (#1392)

* Add generic accumulator

* Add MultiRewardPeriodOfClaimType type to params

* Add adapters wrapper

* Add MultiRewardPeriodsOfClaimType to params

* Add multireward period to genesis test

* Rename MultiRewardPeriodOfClaimType to TypedMultiRewardPeriod

* Use source adapters wrapper
This commit is contained in:
Derrick Lee 2022-11-29 13:59:11 -08:00 committed by GitHub
parent 3a766030a3
commit dce631d3de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 891 additions and 89 deletions

View File

@ -330,6 +330,7 @@
- [MultipliersPerDenom](#kava.incentive.v1beta1.MultipliersPerDenom)
- [Params](#kava.incentive.v1beta1.Params)
- [RewardPeriod](#kava.incentive.v1beta1.RewardPeriod)
- [TypedMultiRewardPeriod](#kava.incentive.v1beta1.TypedMultiRewardPeriod)
- [kava/incentive/v1beta1/genesis.proto](#kava/incentive/v1beta1/genesis.proto)
- [AccrualTime](#kava.incentive.v1beta1.AccrualTime)
@ -4743,7 +4744,8 @@ MultiRewardPeriod supports multiple reward types
<a name="kava.incentive.v1beta1.Multiplier"></a>
### Multiplier
Multiplier amount the claim rewards get increased by, along with how long the claim rewards are locked
Multiplier amount the claim rewards get increased by, along with how long the
claim rewards are locked
| Field | Type | Label | Description |
@ -4790,6 +4792,7 @@ Params
| `claim_end` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | |
| `savings_reward_periods` | [MultiRewardPeriod](#kava.incentive.v1beta1.MultiRewardPeriod) | repeated | |
| `earn_reward_periods` | [MultiRewardPeriod](#kava.incentive.v1beta1.MultiRewardPeriod) | repeated | |
| `reward_periods` | [TypedMultiRewardPeriod](#kava.incentive.v1beta1.TypedMultiRewardPeriod) | repeated | |
@ -4814,6 +4817,22 @@ RewardPeriod stores the state of an ongoing reward
<a name="kava.incentive.v1beta1.TypedMultiRewardPeriod"></a>
### TypedMultiRewardPeriod
TypedMultiRewardPeriod stores mutiple reward types of a claim type
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `claim_type` | [ClaimType](#kava.incentive.v1beta1.ClaimType) | | |
| `reward_periods` | [MultiRewardPeriod](#kava.incentive.v1beta1.MultiRewardPeriod) | repeated | |
<!-- end messages -->
<!-- end enums -->

View File

@ -4,6 +4,7 @@ package kava.incentive.v1beta1;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "kava/incentive/v1beta1/claims.proto";
option go_package = "github.com/kava-labs/kava/x/incentive/types";
option (gogoproto.goproto_getters_all) = false;
@ -49,7 +50,17 @@ message MultiRewardPeriod {
];
}
// Multiplier amount the claim rewards get increased by, along with how long the claim rewards are locked
// TypedMultiRewardPeriod stores mutiple reward types of a claim type
message TypedMultiRewardPeriod {
ClaimType claim_type = 1;
repeated MultiRewardPeriod reward_periods = 2 [
(gogoproto.castrepeated) = "MultiRewardPeriods",
(gogoproto.nullable) = false
];
}
// Multiplier amount the claim rewards get increased by, along with how long the
// claim rewards are locked
message Multiplier {
string name = 1;
@ -118,4 +129,9 @@ message Params {
(gogoproto.castrepeated) = "MultiRewardPeriods",
(gogoproto.nullable) = false
];
repeated TypedMultiRewardPeriod reward_periods = 10 [
(gogoproto.castrepeated) = "TypedMultiRewardPeriods",
(gogoproto.nullable) = false
];
}

View File

@ -35,4 +35,11 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
panic(fmt.Sprintf("failed to accumulate earn rewards: %s", err))
}
}
// New generic RewardPeriods
for _, mrp := range params.RewardPeriods {
for _, rp := range mrp.RewardPeriods {
k.AccumulateRewards(ctx, mrp.ClaimType, rp)
}
}
}

View File

@ -94,6 +94,7 @@ func (suite *GenesisTestSuite) SetupTest() {
},
},
suite.genesisTime.Add(5*oneYear),
types.DefaultTypedMultiRewardPeriods,
),
types.DefaultGenesisRewardState,
types.DefaultGenesisRewardState,
@ -165,6 +166,14 @@ func (suite *GenesisTestSuite) TestExportedGenesisMatchesImported() {
},
},
genesisTime.Add(5*oneYear),
types.TypedMultiRewardPeriods{
types.NewTypedMultiRewardPeriod(
types.CLAIM_TYPE_SWAP,
types.MultiRewardPeriods{
types.NewMultiRewardPeriod(true, "ukava", genesisTime.Add(-1*oneYear), genesisTime.Add(oneYear), cs(c("hard", 122354))),
},
),
},
),
types.NewGenesisRewardState(
types.AccumulationTimes{

View File

@ -0,0 +1,78 @@
package adapters
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/incentive/keeper/adapters/swap"
"github.com/kava-labs/kava/x/incentive/types"
)
// SourceAdapters is a collection of source adapters.
type SourceAdapters struct {
adapters map[types.ClaimType]types.SourceAdapter
}
// SourceShare is a single share from a source with it's corresponding ID.
type SourceShare struct {
ID string
Shares sdk.Dec
}
// NewSourceAdapters returns a new SourceAdapters instance with all available
// source adapters.
func NewSourceAdapters(
swapKeeper types.SwapKeeper,
) SourceAdapters {
return SourceAdapters{
adapters: map[types.ClaimType]types.SourceAdapter{
types.CLAIM_TYPE_SWAP: swap.NewSourceAdapter(swapKeeper),
},
}
}
// OwnerSharesBySource returns a slice of SourceShares for each sourceID from a
// specified owner. The slice is sorted by sourceID.
func (a SourceAdapters) OwnerSharesBySource(
ctx sdk.Context,
claimType types.ClaimType,
owner sdk.AccAddress,
sourceIDs []string,
) []SourceShare {
adapter, found := a.adapters[claimType]
if !found {
panic(fmt.Sprintf("no source share fetcher for claim type %s", claimType))
}
ownerShares := adapter.OwnerSharesBySource(ctx, owner, sourceIDs)
var shares []SourceShare
for _, sourceID := range sourceIDs {
singleShares, found := ownerShares[sourceID]
if !found {
panic(fmt.Sprintf("no source shares for claimType %s and source %s", claimType, sourceID))
}
shares = append(shares, SourceShare{
ID: sourceID,
Shares: singleShares,
})
}
return shares
}
// TotalSharesBySource returns the total shares of a given claimType and sourceID.
func (a SourceAdapters) TotalSharesBySource(
ctx sdk.Context,
claimType types.ClaimType,
sourceID string,
) sdk.Dec {
adapter, found := a.adapters[claimType]
if !found {
panic(fmt.Sprintf("no source share fetcher for claim type %s", claimType))
}
return adapter.TotalSharesBySource(ctx, sourceID)
}

View File

@ -1,14 +1,13 @@
package keeper
import (
"fmt"
"time"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/incentive/keeper/adapters/swap"
"github.com/kava-labs/kava/x/incentive/keeper/adapters"
"github.com/kava-labs/kava/x/incentive/types"
)
@ -27,7 +26,7 @@ type Keeper struct {
liquidKeeper types.LiquidKeeper
earnKeeper types.EarnKeeper
adapters map[types.ClaimType]types.SourceAdapter
adapters adapters.SourceAdapters
// Keepers used for APY queries
mintKeeper types.MintKeeper
@ -60,9 +59,7 @@ func NewKeeper(
liquidKeeper: lqk,
earnKeeper: ek,
adapters: map[types.ClaimType]types.SourceAdapter{
types.CLAIM_TYPE_SWAP: swap.NewSourceAdapter(swpk),
},
adapters: adapters.NewSourceAdapters(swpk),
mintKeeper: mk,
distrKeeper: dk,
@ -894,15 +891,6 @@ func (k Keeper) IterateEarnRewardAccrualTimes(ctx sdk.Context, cb func(string, t
// -----------------------------------------------------------------------------
// New deduplicated methods
func (k Keeper) GetSourceAdapter(claimType types.ClaimType) types.SourceAdapter {
fetcher, found := k.adapters[claimType]
if !found {
panic(fmt.Sprintf("no source share fetcher for claim type %s", claimType))
}
return fetcher
}
// GetClaim returns the claim in the store corresponding the the owner and
// claimType, and a boolean for if the claim was found
func (k Keeper) GetClaim(

View File

@ -7,6 +7,36 @@ import (
"github.com/kava-labs/kava/x/incentive/types"
)
// AccumulateRewards calculates new rewards to distribute this block and updates the global indexes to reflect this.
// The provided rewardPeriod must be valid to avoid panics in calculating time durations.
func (k Keeper) AccumulateRewards(
ctx sdk.Context,
claimType types.ClaimType,
rewardPeriod types.MultiRewardPeriod,
) {
previousAccrualTime, found := k.GetRewardAccrualTime(ctx, claimType, rewardPeriod.CollateralType)
if !found {
previousAccrualTime = ctx.BlockTime()
}
indexes, found := k.GetRewardIndexesOfClaimType(ctx, claimType, rewardPeriod.CollateralType)
if !found {
indexes = types.RewardIndexes{}
}
acc := types.NewAccumulator(previousAccrualTime, indexes)
totalSource := k.adapters.TotalSharesBySource(ctx, claimType, rewardPeriod.CollateralType)
acc.Accumulate(rewardPeriod, totalSource, ctx.BlockTime())
k.SetRewardAccrualTime(ctx, claimType, rewardPeriod.CollateralType, acc.PreviousAccumulationTime)
if len(acc.Indexes) > 0 {
// the store panics when setting empty or nil indexes
k.SetRewardIndexes(ctx, claimType, rewardPeriod.CollateralType, acc.Indexes)
}
}
// InitializeClaim creates a new claim with zero rewards and indexes matching
// the global indexes. If the claim already exists it just updates the indexes.
func (k Keeper) InitializeClaim(
@ -106,12 +136,11 @@ func (k Keeper) GetSynchronizedClaim(
return false
})
adapter := k.GetSourceAdapter(claimType)
accShares := adapter.OwnerSharesBySource(ctx, owner, sourceIDs)
accShares := k.adapters.OwnerSharesBySource(ctx, claimType, owner, sourceIDs)
// Synchronize claim for each source ID
for _, sourceID := range sourceIDs {
claim = k.synchronizeClaim(ctx, claim, sourceID, owner, accShares[sourceID])
for _, share := range accShares {
claim = k.synchronizeClaim(ctx, claim, share.ID, owner, share.Shares)
}
return claim, true

View File

@ -0,0 +1,334 @@
package keeper_test
import (
"testing"
"time"
"github.com/kava-labs/kava/x/incentive/types"
"github.com/stretchr/testify/suite"
)
type AccumulateTestSuite struct {
unitTester
}
func TestAccumulateTestSuite(t *testing.T) {
suite.Run(t, new(AccumulateTestSuite))
}
func (suite *AccumulateTestSuite) storedTimeEquals(
claimType types.ClaimType,
poolID string,
expected time.Time,
) {
storedTime, found := suite.keeper.GetRewardAccrualTime(suite.ctx, claimType, poolID)
suite.True(found)
suite.Equal(expected, storedTime)
}
func (suite *AccumulateTestSuite) storedIndexesEquals(
claimType types.ClaimType,
poolID string,
expected types.RewardIndexes,
) {
storedIndexes, found := suite.keeper.GetRewardIndexesOfClaimType(suite.ctx, claimType, poolID)
suite.Equal(found, expected != nil)
if found {
suite.Equal(expected, storedIndexes)
} else {
suite.Empty(storedIndexes)
}
}
func (suite *AccumulateTestSuite) TestStateUpdatedWhenBlockTimeHasIncreased() {
claimType := types.CLAIM_TYPE_SWAP
pool := "btc:usdx"
swapKeeper := newFakeSwapKeeper().addPool(pool, i(1e6))
suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, nil, swapKeeper, nil, nil, nil)
suite.storeGlobalIndexes(claimType, types.MultiRewardIndexes{
{
CollateralType: pool,
RewardIndexes: types.RewardIndexes{
{
CollateralType: "swap",
RewardFactor: d("0.02"),
},
{
CollateralType: "ukava",
RewardFactor: d("0.04"),
},
},
},
})
previousAccrualTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
suite.keeper.SetRewardAccrualTime(suite.ctx, claimType, pool, previousAccrualTime)
newAccrualTime := previousAccrualTime.Add(1 * time.Hour)
suite.ctx = suite.ctx.WithBlockTime(newAccrualTime)
period := types.NewMultiRewardPeriod(
true,
pool,
time.Unix(0, 0), // ensure the test is within start and end times
distantFuture,
cs(c("swap", 2000), c("ukava", 1000)), // same denoms as in global indexes
)
suite.keeper.AccumulateRewards(suite.ctx, claimType, period)
// check time and factors
suite.storedTimeEquals(claimType, pool, newAccrualTime)
suite.storedIndexesEquals(claimType, pool, types.RewardIndexes{
{
CollateralType: "swap",
RewardFactor: d("7.22"),
},
{
CollateralType: "ukava",
RewardFactor: d("3.64"),
},
})
}
func (suite *AccumulateTestSuite) TestStateUnchangedWhenBlockTimeHasNotIncreased() {
claimType := types.CLAIM_TYPE_SWAP
pool := "btc:usdx"
swapKeeper := newFakeSwapKeeper().addPool(pool, i(1e6))
suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, nil, swapKeeper, nil, nil, nil)
previousIndexes := types.MultiRewardIndexes{
{
CollateralType: pool,
RewardIndexes: types.RewardIndexes{
{
CollateralType: "swap",
RewardFactor: d("0.02"),
},
{
CollateralType: "ukava",
RewardFactor: d("0.04"),
},
},
},
}
suite.storeGlobalIndexes(claimType, previousIndexes)
previousAccrualTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
suite.keeper.SetRewardAccrualTime(suite.ctx, claimType, pool, previousAccrualTime)
suite.ctx = suite.ctx.WithBlockTime(previousAccrualTime)
period := types.NewMultiRewardPeriod(
true,
pool,
time.Unix(0, 0), // ensure the test is within start and end times
distantFuture,
cs(c("swap", 2000), c("ukava", 1000)), // same denoms as in global indexes
)
suite.keeper.AccumulateRewards(suite.ctx, claimType, period)
// check time and factors
suite.storedTimeEquals(claimType, pool, previousAccrualTime)
expected, f := previousIndexes.Get(pool)
suite.True(f)
suite.storedIndexesEquals(claimType, pool, expected)
}
func (suite *AccumulateTestSuite) TestNoAccumulationWhenSourceSharesAreZero() {
claimType := types.CLAIM_TYPE_SWAP
pool := "btc:usdx"
swapKeeper := newFakeSwapKeeper() // no pools, so no source shares
suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, nil, swapKeeper, nil, nil, nil)
previousIndexes := types.MultiRewardIndexes{
{
CollateralType: pool,
RewardIndexes: types.RewardIndexes{
{
CollateralType: "swap",
RewardFactor: d("0.02"),
},
{
CollateralType: "ukava",
RewardFactor: d("0.04"),
},
},
},
}
suite.storeGlobalIndexes(claimType, previousIndexes)
previousAccrualTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
suite.keeper.SetRewardAccrualTime(suite.ctx, claimType, pool, previousAccrualTime)
firstAccrualTime := previousAccrualTime.Add(7 * time.Second)
suite.ctx = suite.ctx.WithBlockTime(firstAccrualTime)
period := types.NewMultiRewardPeriod(
true,
pool,
time.Unix(0, 0), // ensure the test is within start and end times
distantFuture,
cs(c("swap", 2000), c("ukava", 1000)), // same denoms as in global indexes
)
suite.keeper.AccumulateRewards(suite.ctx, claimType, period)
// check time and factors
suite.storedTimeEquals(claimType, pool, firstAccrualTime)
expected, f := previousIndexes.Get(pool)
suite.True(f)
suite.storedIndexesEquals(claimType, pool, expected)
}
func (suite *AccumulateTestSuite) TestStateAddedWhenStateDoesNotExist() {
claimType := types.CLAIM_TYPE_SWAP
pool := "btc:usdx"
swapKeeper := newFakeSwapKeeper().addPool(pool, i(1e6))
suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, nil, swapKeeper, nil, nil, nil)
period := types.NewMultiRewardPeriod(
true,
pool,
time.Unix(0, 0), // ensure the test is within start and end times
distantFuture,
cs(c("swap", 2000), c("ukava", 1000)),
)
firstAccrualTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
suite.ctx = suite.ctx.WithBlockTime(firstAccrualTime)
suite.keeper.AccumulateRewards(suite.ctx, claimType, period)
// After the first accumulation only the current block time should be stored.
// The indexes will be empty as no time has passed since the previous block because it didn't exist.
suite.storedTimeEquals(claimType, pool, firstAccrualTime)
suite.storedIndexesEquals(claimType, pool, nil)
secondAccrualTime := firstAccrualTime.Add(10 * time.Second)
suite.ctx = suite.ctx.WithBlockTime(secondAccrualTime)
suite.keeper.AccumulateRewards(suite.ctx, claimType, period)
// After the second accumulation both current block time and indexes should be stored.
suite.storedTimeEquals(claimType, pool, secondAccrualTime)
suite.storedIndexesEquals(claimType, pool, types.RewardIndexes{
{
CollateralType: "swap",
RewardFactor: d("0.02"),
},
{
CollateralType: "ukava",
RewardFactor: d("0.01"),
},
})
}
func (suite *AccumulateTestSuite) TestNoPanicWhenStateDoesNotExist() {
claimType := types.CLAIM_TYPE_SWAP
pool := "btc:usdx"
swapKeeper := newFakeSwapKeeper()
suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, nil, swapKeeper, nil, nil, nil)
period := types.NewMultiRewardPeriod(
true,
pool,
time.Unix(0, 0), // ensure the test is within start and end times
distantFuture,
cs(),
)
accrualTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
suite.ctx = suite.ctx.WithBlockTime(accrualTime)
// Accumulate with no swap shares and no rewards per second will result in no increment to the indexes.
// No increment and no previous indexes stored, results in an updated of nil. Setting this in the state panics.
// Check there is no panic.
suite.NotPanics(func() {
suite.keeper.AccumulateRewards(suite.ctx, claimType, period)
})
suite.storedTimeEquals(claimType, pool, accrualTime)
suite.storedIndexesEquals(claimType, pool, nil)
}
func (suite *AccumulateTestSuite) TestNoAccumulationWhenBeforeStartTime() {
claimType := types.CLAIM_TYPE_SWAP
pool := "btc:usdx"
swapKeeper := newFakeSwapKeeper().addPool(pool, i(1e6))
suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, nil, swapKeeper, nil, nil, nil)
previousIndexes := types.MultiRewardIndexes{
{
CollateralType: pool,
RewardIndexes: types.RewardIndexes{
{
CollateralType: "swap",
RewardFactor: d("0.02"),
},
{
CollateralType: "ukava",
RewardFactor: d("0.04"),
},
},
},
}
suite.storeGlobalIndexes(claimType, previousIndexes)
previousAccrualTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
suite.keeper.SetRewardAccrualTime(suite.ctx, claimType, pool, previousAccrualTime)
firstAccrualTime := previousAccrualTime.Add(10 * time.Second)
period := types.NewMultiRewardPeriod(
true,
pool,
firstAccrualTime.Add(time.Nanosecond), // start time after accrual time
distantFuture,
cs(c("swap", 2000), c("ukava", 1000)),
)
suite.ctx = suite.ctx.WithBlockTime(firstAccrualTime)
suite.keeper.AccumulateRewards(suite.ctx, claimType, period)
// The accrual time should be updated, but the indexes unchanged
suite.storedTimeEquals(claimType, pool, firstAccrualTime)
expectedIndexes, f := previousIndexes.Get(pool)
suite.True(f)
suite.storedIndexesEquals(claimType, pool, expectedIndexes)
}
func (suite *AccumulateTestSuite) TestPanicWhenCurrentTimeLessThanPrevious() {
claimType := types.CLAIM_TYPE_SWAP
pool := "btc:usdx"
swapKeeper := newFakeSwapKeeper().addPool(pool, i(1e6))
suite.keeper = suite.NewKeeper(&fakeParamSubspace{}, nil, nil, nil, nil, nil, swapKeeper, nil, nil, nil)
previousAccrualTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
suite.keeper.SetRewardAccrualTime(suite.ctx, claimType, pool, previousAccrualTime)
firstAccrualTime := time.Time{}
period := types.NewMultiRewardPeriod(
true,
pool,
time.Time{}, // start time after accrual time
distantFuture,
cs(c("swap", 2000), c("ukava", 1000)),
)
suite.ctx = suite.ctx.WithBlockTime(firstAccrualTime)
suite.Panics(func() {
suite.keeper.AccumulateRewards(suite.ctx, claimType, period)
})
}

View File

@ -56,6 +56,7 @@ func TestGenesisState_Validate(t *testing.T) {
},
},
time.Date(2025, 10, 15, 14, 0, 0, 0, time.UTC),
DefaultTypedMultiRewardPeriods,
),
USDXRewardState: GenesisRewardState{
AccumulationTimes: AccumulationTimes{{

View File

@ -24,11 +24,13 @@ var (
KeyEarnRewardPeriods = []byte("EarnRewardPeriods")
KeyClaimEnd = []byte("ClaimEnd")
KeyMultipliers = []byte("ClaimMultipliers")
KeyTypedMultiRewardPeriods = []byte("TypedMultiRewardPeriods")
DefaultActive = false
DefaultRewardPeriods = RewardPeriods{}
DefaultMultiRewardPeriods = MultiRewardPeriods{}
DefaultMultipliers = MultipliersPerDenoms{}
DefaultTypedMultiRewardPeriods = TypedMultiRewardPeriods{}
DefaultClaimEnd = tmtime.Canonical(time.Unix(1, 0))
BondDenom = "ukava"
@ -44,6 +46,7 @@ func NewParams(
hardSupply, hardBorrow, delegator, swap, savings, earn MultiRewardPeriods,
multipliers MultipliersPerDenoms,
claimEnd time.Time,
rewardPeriods TypedMultiRewardPeriods,
) Params {
return Params{
USDXMintingRewardPeriods: usdxMinting,
@ -52,8 +55,10 @@ func NewParams(
DelegatorRewardPeriods: delegator,
SwapRewardPeriods: swap,
SavingsRewardPeriods: savings,
EarnRewardPeriods: earn,
ClaimMultipliers: multipliers,
ClaimEnd: claimEnd,
RewardPeriods: rewardPeriods,
}
}
@ -69,6 +74,7 @@ func DefaultParams() Params {
DefaultMultiRewardPeriods,
DefaultMultipliers,
DefaultClaimEnd,
DefaultTypedMultiRewardPeriods,
)
}
@ -89,6 +95,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
paramtypes.NewParamSetPair(KeyEarnRewardPeriods, &p.EarnRewardPeriods, validateMultiRewardPeriodsParam),
paramtypes.NewParamSetPair(KeyMultipliers, &p.ClaimMultipliers, validateMultipliersPerDenomParam),
paramtypes.NewParamSetPair(KeyClaimEnd, &p.ClaimEnd, validateClaimEndParam),
paramtypes.NewParamSetPair(KeyTypedMultiRewardPeriods, &p.RewardPeriods, validatedRewardPeriodsParam),
}
}
@ -166,6 +173,15 @@ func validateClaimEndParam(i interface{}) error {
return nil
}
func validatedRewardPeriodsParam(i interface{}) error {
periods, ok := i.(TypedMultiRewardPeriods)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
return periods.Validate()
}
// NewRewardPeriod returns a new RewardPeriod
func NewRewardPeriod(active bool, collateralType string, start time.Time, end time.Time, reward sdk.Coin) RewardPeriod {
return RewardPeriod{
@ -306,3 +322,45 @@ func (mrps MultiRewardPeriods) Validate() error {
return nil
}
// NewTypedMultiRewardPeriod returns a new TypedMultiRewardPeriod
func NewTypedMultiRewardPeriod(claimType ClaimType, rewardPeriods MultiRewardPeriods) TypedMultiRewardPeriod {
return TypedMultiRewardPeriod{
ClaimType: claimType,
RewardPeriods: rewardPeriods,
}
}
// Validate performs a basic check of a TypedMultiRewardPeriod fields.
func (mrp TypedMultiRewardPeriod) Validate() error {
if err := mrp.ClaimType.Validate(); err != nil {
return fmt.Errorf("invalid claim type: %w", err)
}
if err := mrp.RewardPeriods.Validate(); err != nil {
return fmt.Errorf("invalid reward periods: %w", err)
}
return nil
}
// TypedMultiRewardPeriods array of TypedMultiRewardPeriod
type TypedMultiRewardPeriods []TypedMultiRewardPeriod
// Validate checks if all the TypedMultiRewardPeriods are valid and there
// are no duplicated entries.
func (mrps TypedMultiRewardPeriods) Validate() error {
seenClaimTypes := make(map[ClaimType]bool)
for _, mrp := range mrps {
if seenClaimTypes[mrp.ClaimType] {
return fmt.Errorf("duplicated reward period with claim type %s", mrp.ClaimType)
}
if err := mrp.Validate(); err != nil {
return fmt.Errorf("invalid reward period for claimType %s: %w", mrp.ClaimType, err)
}
seenClaimTypes[mrp.ClaimType] = true
}
return nil
}

View File

@ -113,7 +113,47 @@ func (m *MultiRewardPeriod) XXX_DiscardUnknown() {
var xxx_messageInfo_MultiRewardPeriod proto.InternalMessageInfo
// Multiplier amount the claim rewards get increased by, along with how long the claim rewards are locked
// TypedMultiRewardPeriod stores mutiple reward types of a claim type
type TypedMultiRewardPeriod struct {
ClaimType ClaimType `protobuf:"varint,1,opt,name=claim_type,json=claimType,proto3,enum=kava.incentive.v1beta1.ClaimType" json:"claim_type,omitempty"`
RewardPeriods MultiRewardPeriods `protobuf:"bytes,2,rep,name=reward_periods,json=rewardPeriods,proto3,castrepeated=MultiRewardPeriods" json:"reward_periods"`
}
func (m *TypedMultiRewardPeriod) Reset() { *m = TypedMultiRewardPeriod{} }
func (m *TypedMultiRewardPeriod) String() string { return proto.CompactTextString(m) }
func (*TypedMultiRewardPeriod) ProtoMessage() {}
func (*TypedMultiRewardPeriod) Descriptor() ([]byte, []int) {
return fileDescriptor_bb8833f5d745eac9, []int{2}
}
func (m *TypedMultiRewardPeriod) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *TypedMultiRewardPeriod) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_TypedMultiRewardPeriod.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 *TypedMultiRewardPeriod) XXX_Merge(src proto.Message) {
xxx_messageInfo_TypedMultiRewardPeriod.Merge(m, src)
}
func (m *TypedMultiRewardPeriod) XXX_Size() int {
return m.Size()
}
func (m *TypedMultiRewardPeriod) XXX_DiscardUnknown() {
xxx_messageInfo_TypedMultiRewardPeriod.DiscardUnknown(m)
}
var xxx_messageInfo_TypedMultiRewardPeriod proto.InternalMessageInfo
// Multiplier amount the claim rewards get increased by, along with how long the
// claim rewards are locked
type Multiplier struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
MonthsLockup int64 `protobuf:"varint,2,opt,name=months_lockup,json=monthsLockup,proto3" json:"months_lockup,omitempty"`
@ -124,7 +164,7 @@ func (m *Multiplier) Reset() { *m = Multiplier{} }
func (m *Multiplier) String() string { return proto.CompactTextString(m) }
func (*Multiplier) ProtoMessage() {}
func (*Multiplier) Descriptor() ([]byte, []int) {
return fileDescriptor_bb8833f5d745eac9, []int{2}
return fileDescriptor_bb8833f5d745eac9, []int{3}
}
func (m *Multiplier) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -163,7 +203,7 @@ func (m *MultipliersPerDenom) Reset() { *m = MultipliersPerDenom{} }
func (m *MultipliersPerDenom) String() string { return proto.CompactTextString(m) }
func (*MultipliersPerDenom) ProtoMessage() {}
func (*MultipliersPerDenom) Descriptor() ([]byte, []int) {
return fileDescriptor_bb8833f5d745eac9, []int{3}
return fileDescriptor_bb8833f5d745eac9, []int{4}
}
func (m *MultipliersPerDenom) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -203,13 +243,14 @@ type Params struct {
ClaimEnd time.Time `protobuf:"bytes,7,opt,name=claim_end,json=claimEnd,proto3,stdtime" json:"claim_end"`
SavingsRewardPeriods MultiRewardPeriods `protobuf:"bytes,8,rep,name=savings_reward_periods,json=savingsRewardPeriods,proto3,castrepeated=MultiRewardPeriods" json:"savings_reward_periods"`
EarnRewardPeriods MultiRewardPeriods `protobuf:"bytes,9,rep,name=earn_reward_periods,json=earnRewardPeriods,proto3,castrepeated=MultiRewardPeriods" json:"earn_reward_periods"`
RewardPeriods TypedMultiRewardPeriods `protobuf:"bytes,10,rep,name=reward_periods,json=rewardPeriods,proto3,castrepeated=TypedMultiRewardPeriods" json:"reward_periods"`
}
func (m *Params) Reset() { *m = Params{} }
func (m *Params) String() string { return proto.CompactTextString(m) }
func (*Params) ProtoMessage() {}
func (*Params) Descriptor() ([]byte, []int) {
return fileDescriptor_bb8833f5d745eac9, []int{4}
return fileDescriptor_bb8833f5d745eac9, []int{5}
}
func (m *Params) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -241,6 +282,7 @@ var xxx_messageInfo_Params proto.InternalMessageInfo
func init() {
proto.RegisterType((*RewardPeriod)(nil), "kava.incentive.v1beta1.RewardPeriod")
proto.RegisterType((*MultiRewardPeriod)(nil), "kava.incentive.v1beta1.MultiRewardPeriod")
proto.RegisterType((*TypedMultiRewardPeriod)(nil), "kava.incentive.v1beta1.TypedMultiRewardPeriod")
proto.RegisterType((*Multiplier)(nil), "kava.incentive.v1beta1.Multiplier")
proto.RegisterType((*MultipliersPerDenom)(nil), "kava.incentive.v1beta1.MultipliersPerDenom")
proto.RegisterType((*Params)(nil), "kava.incentive.v1beta1.Params")
@ -251,56 +293,60 @@ func init() {
}
var fileDescriptor_bb8833f5d745eac9 = []byte{
// 774 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x96, 0xcf, 0x6e, 0xd3, 0x4a,
0x14, 0xc6, 0xe3, 0xfc, 0xbb, 0xc9, 0xb4, 0xbd, 0xb7, 0x9d, 0x46, 0xb9, 0xbe, 0xb9, 0xc8, 0xa9,
0x52, 0x04, 0x41, 0x55, 0x6d, 0x0a, 0x12, 0x0b, 0x76, 0x98, 0x82, 0x84, 0x44, 0xa5, 0xca, 0x2d,
0x12, 0xb0, 0x89, 0x26, 0xf6, 0xd4, 0xb5, 0x6a, 0x7b, 0xac, 0x99, 0x49, 0xda, 0x88, 0x05, 0x12,
0x0b, 0x76, 0x48, 0x15, 0x0b, 0x1e, 0xa2, 0xaf, 0xc1, 0xa6, 0xcb, 0x8a, 0x15, 0x62, 0xd1, 0x42,
0xfa, 0x22, 0x68, 0xc6, 0x6e, 0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8a, 0x12, 0xba, 0xf4, 0xeb, 0x31, 0x38, 0x1f, 0x2f, 0xf3, 0x46, 0x82, 0xad, 0x8c, 0xd9,
0x64, 0xd6, 0xac, 0x64, 0xa4, 0xb6, 0xe0, 0x23, 0x50, 0x8e, 0xb9, 0xe2, 0xbe, 0xfb, 0xeb, 0x1a,
0xf7, 0x5d, 0x49, 0x96, 0x3d, 0x09, 0x1d, 0xf8, 0x06, 0x54, 0x19, 0xea, 0x7a, 0xa1, 0xcb, 0x46,
0x4d, 0x2b, 0x4d, 0xd2, 0xb4, 0x4a, 0x02, 0xb9, 0x70, 0x5c, 0x18, 0xd1, 0x70, 0x94, 0x5c, 0x9e,
0xe8, 0x71, 0x09, 0xc2, 0x50, 0xc8, 0x7c, 0x76, 0xf8, 0x43, 0xcb, 0x1c, 0xf6, 0x35, 0xe5, 0xa8,
0xaf, 0x29, 0xdf, 0xfb, 0x9a, 0xb2, 0x7f, 0xaa, 0x65, 0x8e, 0x4e, 0xb5, 0xcc, 0xd7, 0x53, 0x2d,
0xf3, 0x7a, 0x29, 0x75, 0x57, 0x0a, 0x05, 0xcb, 0x3e, 0x6a, 0x33, 0xb9, 0x32, 0xf6, 0x52, 0xff,
0x48, 0xe4, 0xa5, 0xd9, 0x2e, 0x4a, 0x9b, 0xef, 0xff, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xca, 0x77,
0xf8, 0x09, 0xb0, 0x08, 0x00, 0x00,
// 844 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0xeb, 0x44,
0x14, 0x8e, 0xf3, 0x47, 0x32, 0xfd, 0xa1, 0x9d, 0x46, 0xa9, 0x09, 0xc8, 0x2e, 0x29, 0x82, 0xa0,
0xaa, 0x36, 0x2d, 0x12, 0x0b, 0x56, 0xe0, 0x16, 0x24, 0x24, 0x2a, 0x55, 0x6e, 0x91, 0x80, 0x8d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, 0xd2, 0xed, 0x40, 0x91, 0xfe, 0x1f, 0x28, 0xd2, 0xf5, 0x83, 0x92, 0xbb, 0x7d,
0x50, 0x72, 0xff, 0x3e, 0x28, 0xb9, 0x9f, 0x77, 0xc6, 0x66, 0x34, 0xe7, 0xb1, 0xeb, 0xa3, 0x36,
0x13, 0x96, 0x7e, 0x35, 0xf6, 0x95, 0x25, 0x86, 0x75, 0xbb, 0x2c, 0xda, 0xfb, 0xf9, 0xcb, 0x00,
0x00, 0x00, 0xff, 0xff, 0x4c, 0xba, 0x2a, 0x08, 0x18, 0x0a, 0x00, 0x00,
}
func (m *RewardPeriod) Marshal() (dAtA []byte, err error) {
@ -439,6 +485,48 @@ func (m *MultiRewardPeriod) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *TypedMultiRewardPeriod) 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 *TypedMultiRewardPeriod) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *TypedMultiRewardPeriod) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.RewardPeriods) > 0 {
for iNdEx := len(m.RewardPeriods) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.RewardPeriods[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
}
if m.ClaimType != 0 {
i = encodeVarintParams(dAtA, i, uint64(m.ClaimType))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func (m *Multiplier) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@ -548,6 +636,20 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.RewardPeriods) > 0 {
for iNdEx := len(m.RewardPeriods) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.RewardPeriods[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintParams(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x52
}
}
if len(m.EarnRewardPeriods) > 0 {
for iNdEx := len(m.EarnRewardPeriods) - 1; iNdEx >= 0; iNdEx-- {
{
@ -730,6 +832,24 @@ func (m *MultiRewardPeriod) Size() (n int) {
return n
}
func (m *TypedMultiRewardPeriod) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.ClaimType != 0 {
n += 1 + sovParams(uint64(m.ClaimType))
}
if len(m.RewardPeriods) > 0 {
for _, e := range m.RewardPeriods {
l = e.Size()
n += 1 + l + sovParams(uint64(l))
}
}
return n
}
func (m *Multiplier) Size() (n int) {
if m == nil {
return 0
@ -823,6 +943,12 @@ func (m *Params) Size() (n int) {
n += 1 + l + sovParams(uint64(l))
}
}
if len(m.RewardPeriods) > 0 {
for _, e := range m.RewardPeriods {
l = e.Size()
n += 1 + l + sovParams(uint64(l))
}
}
return n
}
@ -1235,6 +1361,109 @@ func (m *MultiRewardPeriod) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *TypedMultiRewardPeriod) 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 ErrIntOverflowParams
}
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: TypedMultiRewardPeriod: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: TypedMultiRewardPeriod: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ClaimType", wireType)
}
m.ClaimType = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ClaimType |= ClaimType(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field RewardPeriods", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.RewardPeriods = append(m.RewardPeriods, MultiRewardPeriod{})
if err := m.RewardPeriods[len(m.RewardPeriods)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipParams(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthParams
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Multiplier) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -1819,6 +2048,40 @@ func (m *Params) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 10:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field RewardPeriods", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthParams
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthParams
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.RewardPeriods = append(m.RewardPeriods, TypedMultiRewardPeriod{})
if err := m.RewardPeriods[len(m.RewardPeriods)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipParams(dAtA[iNdEx:])