mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
6ef9bab67d
* wip Add claim * Add distr keeper and claiming * Add claim test * Update claim test with failures * wip Add staking rewards * -S Fix savings to earn incentive methods * Use a single accural time for all earn incentives * Add additional required liquid methods * Update genesis to only include 1 accrual time for earn * Revert "Update genesis to only include 1 accrual time for earn" This reverts commit cc7e35347298681c0c8a4a0b9bf9b9b296c25531. * Revert "Use a single accural time for all earn incentives" This reverts commit aeb49c4622d4e3d99dc6421c8830932b1b546be9. * Update tests with incentive distribution * Add earn to incentive rewards query * add earn cli tx * Update claim example to use ukava large * Use underlying ukava to determine proportional reward amount * Rename liquid methods to reflect derivative value * Add tests for derivative values * Return error to panic in BeginBlocker Co-authored-by: karzak <kjydavis3@gmail.com>
39 lines
1009 B
Go
39 lines
1009 B
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))
|
|
}
|
|
}
|
|
}
|