Skip to content

Commit

Permalink
Merge branch 'main' into fix_cancel_unbonding_delegations_wasmbinding
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond authored Dec 16, 2023
2 parents 65c6d0a + 54c7fcd commit c1a7dce
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 108 deletions.
16 changes: 5 additions & 11 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,11 @@ func setUpgradeHandler(app *ElysApp) {
// dedicated x/consensus module.
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.ConsensusParamsKeeper)

// FIXME: temporary code to fix usdc/elys pool weights
pool, found := app.AmmKeeper.GetPool(ctx, 3)
if found {
totalWeight := sdk.ZeroInt()
for i := range pool.PoolAssets {
pool.PoolAssets[i].Weight = sdk.NewInt(107374182400)
totalWeight = totalWeight.Add(pool.PoolAssets[i].Weight)
}
pool.TotalWeight = totalWeight
pool.PoolParams.FeeDenom = "ibc/2180E84E20F5679FCC760D8C165B60F42065DEF7F46A72B447CFF1B7DC6C0A65"
app.AmmKeeper.SetPool(ctx, pool)
// set authority value for all time based inflation
for _, item := range app.TokenomicsKeeper.GetAllTimeBasedInflation(ctx) {
// set the gov module address to the authority
item.Authority = authtypes.NewModuleAddress(govtypes.ModuleName).String()
app.TokenomicsKeeper.SetTimeBasedInflation(ctx, item)
}

return app.mm.RunMigrations(ctx, app.configurator, vm)
Expand Down
3 changes: 3 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ genesis:
- startBlockHeight: 1
endBlockHeight: 6307200
description: 1st Year Inflation
authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3
inflation:
lmRewards: 9999999
icsStakingRewards: 9999999
Expand All @@ -348,6 +349,7 @@ genesis:
- startBlockHeight: 6307201
endBlockHeight: 12614401
description: 2nd Year Inflation
authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3
inflation:
lmRewards: 9999999
icsStakingRewards: 9999999
Expand All @@ -357,6 +359,7 @@ genesis:
- startBlockHeight: 12614402
endBlockHeight: 18921602
description: 3rd Year Inflation
authority: elys10d07y265gmmuvt4z0w9aw880jnsr700j6z2zm3
inflation:
lmRewards: 9999999
icsStakingRewards: 9999999
Expand Down
46 changes: 0 additions & 46 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37481,42 +37481,6 @@ paths:
format: uint64
tags:
- Query
/elys-network/elys/accountedpool/params:
get:
summary: Parameters queries the parameters of the module.
operationId: ElysAccountedpoolParams
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
'@type':
type: string
additionalProperties: {}
tags:
- Query
/elys-network/elys/amm/balance/{address}/{denom}:
get:
summary: Queries a list of Balance items.
Expand Down Expand Up @@ -82189,9 +82153,6 @@ definitions:
type: string
total_weight:
type: string
elys.accountedpool.Params:
type: object
description: Params defines the parameters for the module.
elys.accountedpool.QueryAllAccountedPoolResponse:
type: object
properties:
Expand Down Expand Up @@ -82316,13 +82277,6 @@ definitions:
type: string
total_weight:
type: string
elys.accountedpool.QueryParamsResponse:
type: object
properties:
params:
description: params holds all the parameters of this module.
type: object
description: QueryParamsResponse is response type for the Query/Params RPC method.
elys.amm.PoolAsset:
type: object
properties:
Expand Down
10 changes: 9 additions & 1 deletion x/accountedpool/types/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion x/commitment/types/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 76 additions & 49 deletions x/incentive/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,64 +119,91 @@ func (k Keeper) ProcessUpdateIncentiveParams(ctx sdk.Context) bool {

totalBlocksPerYear := sdk.NewInt(int64(inflation.EndBlockHeight - inflation.StartBlockHeight + 1))

// ------------- LP Incentive parameter -------------
// ptypes.DaysPerYear is guaranteed to be positive as it is defined as a constant
allocationEpochInblocks := totalBlocksPerYear.Quo(sdk.NewInt(ptypes.DaysPerYear))
totalDistributionEpochPerYear := totalBlocksPerYear.Quo(sdk.NewInt(params.DistributionEpochForLpsInBlocks))
// If totalDistributionEpochPerYear is zero, we skip this inflation to avoid division by zero
if totalBlocksPerYear == sdk.ZeroInt() {
continue
}
currentEpochInBlocks := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)).Mul(totalDistributionEpochPerYear).Quo(totalBlocksPerYear)
maxEdenPerAllocation := sdk.NewInt(int64(inflation.Inflation.LmRewards)).Mul(allocationEpochInblocks).Quo(totalBlocksPerYear)
incentiveInfo := types.IncentiveInfo{
// reward amount in eden for 1 year
EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.LmRewards)),
// starting block height of the distribution
DistributionStartBlock: sdk.NewInt(int64(inflation.StartBlockHeight)),
// distribution duration - block number per year
TotalBlocksPerYear: totalBlocksPerYear,
// we set block numbers in 24 hrs
AllocationEpochInBlocks: allocationEpochInblocks,
// maximum eden allocation per day that won't exceed 30% apr
MaxEdenPerAllocation: maxEdenPerAllocation,
// number of block intervals that distribute rewards.
DistributionEpochInBlocks: sdk.NewInt(params.DistributionEpochForLpsInBlocks),
// current epoch in block number
CurrentEpochInBlocks: currentEpochInBlocks,
// eden boost apr (0-1) range
EdenBoostApr: sdk.NewDec(1),
}

if len(params.LpIncentives) == 0 {
totalDistributionEpochPerYear := totalBlocksPerYear.Quo(sdk.NewInt(params.DistributionEpochForLpsInBlocks))
// If totalDistributionEpochPerYear is zero, we skip this inflation to avoid division by zero
if totalBlocksPerYear == sdk.ZeroInt() {
continue
params.LpIncentives = append(params.LpIncentives, incentiveInfo)
} else {
// If any of block number related parameter changed, we re-calculate the current epoch
if params.LpIncentives[0].DistributionStartBlock != incentiveInfo.DistributionStartBlock ||
params.LpIncentives[0].TotalBlocksPerYear != incentiveInfo.TotalBlocksPerYear ||
params.LpIncentives[0].DistributionEpochInBlocks != incentiveInfo.DistributionEpochInBlocks {
params.LpIncentives[0].CurrentEpochInBlocks = currentEpochInBlocks
}
currentEpochInBlocks := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)).Mul(totalDistributionEpochPerYear).Quo(totalBlocksPerYear)
maxEdenPerAllocation := sdk.NewInt(int64(inflation.Inflation.LmRewards)).Mul(allocationEpochInblocks).Quo(totalBlocksPerYear)
params.LpIncentives = append(params.LpIncentives, types.IncentiveInfo{
// reward amount in eden for 1 year
EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.LmRewards)),
// starting block height of the distribution
DistributionStartBlock: sdk.NewInt(int64(inflation.StartBlockHeight)),
// distribution duration - block number per year
TotalBlocksPerYear: totalBlocksPerYear,
// we set block numbers in 24 hrs
AllocationEpochInBlocks: allocationEpochInblocks,
// maximum eden allocation per day that won't exceed 30% apr
MaxEdenPerAllocation: maxEdenPerAllocation,
// number of block intervals that distribute rewards.
DistributionEpochInBlocks: sdk.NewInt(params.DistributionEpochForLpsInBlocks),
// current epoch in block number
CurrentEpochInBlocks: currentEpochInBlocks,
// eden boost apr (0-1) range
EdenBoostApr: sdk.NewDec(1),
})
params.LpIncentives[0].EdenAmountPerYear = incentiveInfo.EdenAmountPerYear
params.LpIncentives[0].DistributionStartBlock = incentiveInfo.DistributionStartBlock
params.LpIncentives[0].TotalBlocksPerYear = incentiveInfo.TotalBlocksPerYear
params.LpIncentives[0].AllocationEpochInBlocks = incentiveInfo.AllocationEpochInBlocks
params.LpIncentives[0].DistributionEpochInBlocks = incentiveInfo.DistributionEpochInBlocks
params.LpIncentives[0].EdenBoostApr = incentiveInfo.EdenBoostApr
}

// ------------- Stakers parameter -------------
totalDistributionEpochPerYear = totalBlocksPerYear.Quo(sdk.NewInt(params.DistributionEpochForStakersInBlocks))
currentEpochInBlocks = sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)).Mul(totalDistributionEpochPerYear).Quo(totalBlocksPerYear)
maxEdenPerAllocation = sdk.NewInt(int64(inflation.Inflation.IcsStakingRewards)).Mul(allocationEpochInblocks).Quo(totalBlocksPerYear)
incentiveInfo = types.IncentiveInfo{
// reward amount in eden for 1 year
EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.IcsStakingRewards)),
// starting block height of the distribution
DistributionStartBlock: sdk.NewInt(int64(inflation.StartBlockHeight)),
// distribution duration - block number per year
TotalBlocksPerYear: totalBlocksPerYear,
// we set block numbers in 24 hrs
AllocationEpochInBlocks: allocationEpochInblocks,
// maximum eden allocation per day that won't exceed 30% apr
MaxEdenPerAllocation: maxEdenPerAllocation,
// number of block intervals that distribute rewards.
DistributionEpochInBlocks: sdk.NewInt(params.DistributionEpochForStakersInBlocks),
// current epoch in block number
CurrentEpochInBlocks: currentEpochInBlocks,
// eden boost apr (0-1) range
EdenBoostApr: sdk.NewDec(1),
}

if len(params.StakeIncentives) == 0 {
totalDistributionEpochPerYear := totalBlocksPerYear.Quo(sdk.NewInt(params.DistributionEpochForStakersInBlocks))
// If totalDistributionEpochPerYear is zero, we skip this inflation to avoid division by zero
if totalBlocksPerYear == sdk.ZeroInt() {
continue
params.StakeIncentives = append(params.StakeIncentives, incentiveInfo)
} else {
// If any of block number related parameter changed, we re-calculate the current epoch
if params.StakeIncentives[0].DistributionStartBlock != incentiveInfo.DistributionStartBlock ||
params.StakeIncentives[0].TotalBlocksPerYear != incentiveInfo.TotalBlocksPerYear ||
params.StakeIncentives[0].DistributionEpochInBlocks != incentiveInfo.DistributionEpochInBlocks {
params.StakeIncentives[0].CurrentEpochInBlocks = currentEpochInBlocks
}
currentEpochInBlocks := sdk.NewInt(ctx.BlockHeight() - int64(inflation.StartBlockHeight)).Mul(totalDistributionEpochPerYear).Quo(totalBlocksPerYear)
maxEdenPerAllocation := sdk.NewInt(int64(inflation.Inflation.IcsStakingRewards)).Mul(allocationEpochInblocks).Quo(totalBlocksPerYear)
params.StakeIncentives = append(params.StakeIncentives, types.IncentiveInfo{
// reward amount in eden for 1 year
EdenAmountPerYear: sdk.NewInt(int64(inflation.Inflation.IcsStakingRewards)),
// starting block height of the distribution
DistributionStartBlock: sdk.NewInt(int64(inflation.StartBlockHeight)),
// distribution duration - block number per year
TotalBlocksPerYear: totalBlocksPerYear,
// we set block numbers in 24 hrs
AllocationEpochInBlocks: allocationEpochInblocks,
// maximum eden allocation per day that won't exceed 30% apr
MaxEdenPerAllocation: maxEdenPerAllocation,
// number of block intervals that distribute rewards.
DistributionEpochInBlocks: sdk.NewInt(params.DistributionEpochForStakersInBlocks),
// current epoch in block number
CurrentEpochInBlocks: currentEpochInBlocks,
// eden boost apr (0-1) range
EdenBoostApr: sdk.NewDec(1),
})
params.StakeIncentives[0].EdenAmountPerYear = incentiveInfo.EdenAmountPerYear
params.StakeIncentives[0].DistributionStartBlock = incentiveInfo.DistributionStartBlock
params.StakeIncentives[0].TotalBlocksPerYear = incentiveInfo.TotalBlocksPerYear
params.StakeIncentives[0].AllocationEpochInBlocks = incentiveInfo.AllocationEpochInBlocks
params.StakeIncentives[0].DistributionEpochInBlocks = incentiveInfo.DistributionEpochInBlocks
params.StakeIncentives[0].EdenBoostApr = incentiveInfo.EdenBoostApr
}

break
}

Expand Down

0 comments on commit c1a7dce

Please sign in to comment.