2020-04-24 15:20:34 +00:00
|
|
|
package incentive
|
|
|
|
|
|
|
|
import (
|
2022-09-28 20:20:01 +00:00
|
|
|
"fmt"
|
|
|
|
|
2020-04-24 15:20:34 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2020-04-30 14:13:31 +00:00
|
|
|
|
2020-04-24 15:20:34 +00:00
|
|
|
"github.com/kava-labs/kava/x/incentive/keeper"
|
|
|
|
)
|
|
|
|
|
|
|
|
// BeginBlocker runs at the start of every block
|
|
|
|
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
|
2021-01-21 13:52:09 +00:00
|
|
|
params := k.GetParams(ctx)
|
2021-07-22 12:53:18 +00:00
|
|
|
|
2021-01-21 13:52:09 +00:00
|
|
|
for _, rp := range params.USDXMintingRewardPeriods {
|
2021-07-22 12:53:18 +00:00
|
|
|
k.AccumulateUSDXMintingRewards(ctx, rp)
|
2021-01-21 13:52:09 +00:00
|
|
|
}
|
|
|
|
for _, rp := range params.HardSupplyRewardPeriods {
|
2021-07-22 12:53:18 +00:00
|
|
|
k.AccumulateHardSupplyRewards(ctx, rp)
|
2021-01-21 13:52:09 +00:00
|
|
|
}
|
|
|
|
for _, rp := range params.HardBorrowRewardPeriods {
|
2021-07-22 12:53:18 +00:00
|
|
|
k.AccumulateHardBorrowRewards(ctx, rp)
|
2021-01-18 19:12:37 +00:00
|
|
|
}
|
2021-07-07 16:50:14 +00:00
|
|
|
for _, rp := range params.DelegatorRewardPeriods {
|
2021-07-22 12:53:18 +00:00
|
|
|
k.AccumulateDelegatorRewards(ctx, rp)
|
2021-01-29 20:32:07 +00:00
|
|
|
}
|
2021-07-07 13:23:06 +00:00
|
|
|
for _, rp := range params.SwapRewardPeriods {
|
|
|
|
k.AccumulateSwapRewards(ctx, rp)
|
|
|
|
}
|
2022-04-12 14:14:14 +00:00
|
|
|
for _, rp := range params.SavingsRewardPeriods {
|
|
|
|
k.AccumulateSavingsRewards(ctx, rp)
|
|
|
|
}
|
2022-09-22 18:26:08 +00:00
|
|
|
for _, rp := range params.EarnRewardPeriods {
|
2022-09-28 20:20:01 +00:00
|
|
|
if err := k.AccumulateEarnRewards(ctx, rp); err != nil {
|
|
|
|
panic(fmt.Sprintf("failed to accumulate earn rewards: %s", err))
|
|
|
|
}
|
2022-09-22 18:26:08 +00:00
|
|
|
}
|
2020-04-24 15:20:34 +00:00
|
|
|
}
|