Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging for incentive debug #370

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions x/incentive/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/incentive/keeper/keeper_shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions x/incentive/keeper/params.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -236,4 +243,5 @@ func (k Keeper) UpdateTotalCommitmentInfo(ctx sdk.Context, baseCurrency string)
}
return false
})
fmt.Println("TotalEdenEdenBoostCommitted", k.tci.TotalEdenEdenBoostCommitted.String())
}
11 changes: 9 additions & 2 deletions x/incentive/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,32 @@ 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

1. allocation of daily eden in based on tokenmics module which is for LM alllocatioj
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.
Expand Down
Loading