mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 18:15:19 +00:00
dce631d3de
* 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
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package incentive
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/kava-labs/kava/x/incentive/keeper"
|
|
)
|
|
|
|
// BeginBlocker runs at the start of every block
|
|
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
|
|
params := k.GetParams(ctx)
|
|
|
|
for _, rp := range params.USDXMintingRewardPeriods {
|
|
k.AccumulateUSDXMintingRewards(ctx, rp)
|
|
}
|
|
for _, rp := range params.HardSupplyRewardPeriods {
|
|
k.AccumulateHardSupplyRewards(ctx, rp)
|
|
}
|
|
for _, rp := range params.HardBorrowRewardPeriods {
|
|
k.AccumulateHardBorrowRewards(ctx, rp)
|
|
}
|
|
for _, rp := range params.DelegatorRewardPeriods {
|
|
k.AccumulateDelegatorRewards(ctx, rp)
|
|
}
|
|
for _, rp := range params.SwapRewardPeriods {
|
|
k.AccumulateSwapRewards(ctx, rp)
|
|
}
|
|
for _, rp := range params.SavingsRewardPeriods {
|
|
k.AccumulateSavingsRewards(ctx, rp)
|
|
}
|
|
for _, rp := range params.EarnRewardPeriods {
|
|
if err := k.AccumulateEarnRewards(ctx, rp); err != nil {
|
|
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)
|
|
}
|
|
}
|
|
}
|