diff --git a/x/incentive/keeper/keeper.go b/x/incentive/keeper/keeper.go index eff4f1314..52dbde54d 100644 --- a/x/incentive/keeper/keeper.go +++ b/x/incentive/keeper/keeper.go @@ -135,9 +135,8 @@ func (k Keeper) UpdateStakersRewardsUnclaimed(ctx sdk.Context, stakeIncentive ty epochStakersEdenAmount = sdk.MinInt(epochStakersEdenAmount, epochStakersMaxEdenAmount.TruncateInt()) // Calculate eden amount per distribution epoch - edenAmountPerEpochStakersPerDistribution := epochStakersEdenAmount.Mul(stakeIncentive.DistributionEpochInBlocks).Quo(stakeIncentive.EpochNumBlocks) + stakersEdenAmountPerDistribution := epochStakersEdenAmount.Mul(stakeIncentive.DistributionEpochInBlocks).Quo(stakeIncentive.EpochNumBlocks) - // TODO: check this code block // Track the DEX rewards distribution for stakers // Add dexRevenue amount that was tracked by Lp tracker dexRevenueStakersAmtPerDistribution = dexRevenueStakersAmtPerDistribution.Add(params.DexRewardsStakers.AmountCollectedByOtherTracker) @@ -181,7 +180,9 @@ func (k Keeper) UpdateStakersRewardsUnclaimed(ctx sdk.Context, stakeIncentive ty // Calculate new unclaimed Eden tokens from Elys staked // ---------------------------------------------------------- - newUnclaimedEdenTokens, dexRewards, dexRewardsByStakers := k.CalculateRewardsForStakersByElysStaked(ctx, delegatedAmt, edenAmountPerEpochStakersPerDistribution, dexRevenueStakersAmtPerDistribution) + newUnclaimedEdenTokens, dexRewards, dexRewardsByStakers := k.CalculateRewardsForStakersByElysStaked(ctx, delegatedAmt, stakersEdenAmountPerDistribution, dexRevenueStakersAmtPerDistribution) + fmt.Println("newUnclaimedEdenTokens1", newUnclaimedEdenTokens.String()) + // Total totalEdenGiven = totalEdenGiven.Add(newUnclaimedEdenTokens) totalRewardsGiven = totalRewardsGiven.Add(dexRewards) @@ -199,7 +200,8 @@ func (k Keeper) UpdateStakersRewardsUnclaimed(ctx sdk.Context, stakeIncentive ty // ---------------------------------------------------------- // ---------------------------------------------------------- edenCommitted := commitments.GetCommittedAmountForDenom(ptypes.Eden) - newUnclaimedEdenTokens, dexRewards = k.CalculateRewardsForStakersByCommitted(ctx, edenCommitted, edenAmountPerEpochStakersPerDistribution, dexRevenueStakersAmtPerDistribution) + newUnclaimedEdenTokens, dexRewards = k.CalculateRewardsForStakersByCommitted(ctx, edenCommitted, stakersEdenAmountPerDistribution, dexRevenueStakersAmtPerDistribution) + fmt.Println("newUnclaimedEdenTokens2", newUnclaimedEdenTokens.String()) // Total totalEdenGiven = totalEdenGiven.Add(newUnclaimedEdenTokens) @@ -219,7 +221,8 @@ func (k Keeper) UpdateStakersRewardsUnclaimed(ctx sdk.Context, stakeIncentive ty // ---------------------------------------------------------- // ---------------------------------------------------------- edenBoostCommitted := commitments.GetCommittedAmountForDenom(ptypes.EdenB) - newUnclaimedEdenTokens, dexRewards = k.CalculateRewardsForStakersByCommitted(ctx, edenBoostCommitted, edenAmountPerEpochStakersPerDistribution, dexRevenueStakersAmtPerDistribution) + newUnclaimedEdenTokens, dexRewards = k.CalculateRewardsForStakersByCommitted(ctx, edenBoostCommitted, stakersEdenAmountPerDistribution, dexRevenueStakersAmtPerDistribution) + fmt.Println("newUnclaimedEdenTokens3", newUnclaimedEdenTokens.String()) // Total totalEdenGiven = totalEdenGiven.Add(newUnclaimedEdenTokens) @@ -283,7 +286,10 @@ func (k Keeper) UpdateStakersRewardsUnclaimed(ctx sdk.Context, stakeIncentive ty ) // Calcualte the remainings - edenRemained := edenAmountPerEpochStakersPerDistribution.Sub(totalEdenGiven) + fmt.Println("totalEdenGiven", totalEdenGiven.String()) + fmt.Println("stakersEdenAmountPerDistribution", stakersEdenAmountPerDistribution.String()) + + edenRemained := stakersEdenAmountPerDistribution.Sub(totalEdenGiven) dexRewardsRemained := dexRevenueStakersAmtPerDistribution.Sub(sdk.NewDecFromInt(totalRewardsGiven)) // if edenRemained is negative, override it with zero diff --git a/x/incentive/keeper/keeper_shares.go b/x/incentive/keeper/keeper_shares.go index 85fc13f9c..6e4f9aa39 100644 --- a/x/incentive/keeper/keeper_shares.go +++ b/x/incentive/keeper/keeper_shares.go @@ -11,7 +11,7 @@ import ( // Calculate total share of staking func (k Keeper) CalculateTotalShareOfStaking(amount math.Int) sdk.Dec { - // Total statked = Elys staked + Eden Committed + Eden boost Committed + // Total staked = Elys staked + Eden Committed + Eden boost Committed totalStaked := k.tci.TotalElysBonded.Add(k.tci.TotalEdenEdenBoostCommitted) if totalStaked.LTE(sdk.ZeroInt()) { return sdk.ZeroDec() diff --git a/x/incentive/keeper/params.go b/x/incentive/keeper/params.go index 226b7c147..33ad3d10e 100644 --- a/x/incentive/keeper/params.go +++ b/x/incentive/keeper/params.go @@ -1,6 +1,8 @@ package keeper import ( + "fmt" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ammtypes "github.com/elys-network/elys/x/amm/types" @@ -189,6 +191,8 @@ func (k Keeper) CalculateEpochCountsPerYear(ctx sdk.Context, epochIdentifier str func (k Keeper) UpdateTotalCommitmentInfo(ctx sdk.Context, baseCurrency string) { // Fetch total staked Elys amount again k.tci.TotalElysBonded = k.stk.TotalBondedTokens(ctx) + fmt.Println("TotalElysBonded", k.tci.TotalElysBonded.String()) + // Initialize with amount zero k.tci.TotalEdenEdenBoostCommitted = sdk.ZeroInt() // Initialize with amount zero @@ -211,6 +215,9 @@ func (k Keeper) UpdateTotalCommitmentInfo(ctx sdk.Context, baseCurrency string) k.tci.TotalEdenEdenBoostCommitted = k.tci.TotalEdenEdenBoostCommitted.Add(committedEdenToken).Add(committedEdenBoostToken) + fmt.Println("commitment.owner", commitments.Creator) + fmt.Println("committedEdenToken", committedEdenToken.String()) + fmt.Println("committedEdenBoostToken", committedEdenBoostToken.String()) // Iterate to calculate total Lp tokens committed k.amm.IterateLiquidityPools(ctx, func(p ammtypes.Pool) bool { lpToken := ammtypes.GetPoolShareDenom(p.GetPoolId()) @@ -236,4 +243,5 @@ func (k Keeper) UpdateTotalCommitmentInfo(ctx sdk.Context, baseCurrency string) } return false }) + fmt.Println("TotalEdenEdenBoostCommitted", k.tci.TotalEdenEdenBoostCommitted.String()) } diff --git a/x/incentive/spec/README.md b/x/incentive/spec/README.md index 7519b866b..500aae97d 100644 --- a/x/incentive/spec/README.md +++ b/x/incentive/spec/README.md @@ -9,13 +9,16 @@ Reward is distributed per epoch, `distribution` epoch, which is counted in numbe There's Eden allocation epoch per day, based on tokenomics. The source of rewards are from `Eden + Dex revenue (USDC) + Gas fees (XX,YY -> USDC)` +90 Eden -> vest 90 days -> 90 Elys +Eden committed <-> Elys staked + ## Flow ### Staking 1. allocation of daily eden is based on tokenomics which is in staking allocation 2. capped allocation of daily eden is based on 30% Apr -3. distribution is done every set epoch +3. distribution is done every set epoch (1200 blocks, now 10 blocks - need to be updated on-chain on public testnet) ### LM rewards @@ -23,11 +26,15 @@ The source of rewards are from `Eden + Dex revenue (USDC) + Gas fees (XX,YY -> U 2. capped allocation of daily eden for 50% Apr 3. weights for different pools as different pools will be given different rewards 4. usdc stable coin pool is included here -5. distribution based on proxy tVL ( weighted TVL) +5. distribution based on proxy tVL ( weighted TVL) 3 pool (100, 1000, 1000000) (1, 10, 10000) 6. distribution every set epoch ### EdenBoost allocation +100 Elys + 1000 Eden (1100 staked) -> wait for 1 year -> 1100 EdenB +EdenB is just for increasing the pool weight! +veToken model -> voting to pools (EdenB is voting power) + Eden boost is received at 100% Apr for staking elys and committing Eden. Eden staking and Elys staking is exactly the same other than securing the chain and bonding period They both get Eden and Eden boost.