-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat!: refactor x/mint
module
#321
feat!: refactor x/mint
module
#321
Conversation
func DefaultGenesis() *GenesisState { | ||
epochs := []EpochInfo{ | ||
{ | ||
Identifier: WEEK_EPOCH, | ||
Identifier: HOUR_EPOCH, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do not support minute ephocs, as stated in the PRD?
x/mint/keeper/hooks.go
Outdated
if epochNumber < params.MintingRewardsDistributionStartEpoch { | ||
// Update inflation | ||
if epochIdentifier == params.InflationEpochIdentifier { | ||
newInfaltion, err := k.HandleInflationChange(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
x/mint/keeper/mint.go
Outdated
return mintedCoins, nil | ||
} | ||
|
||
func (k Keeper) CalcMintedCoins(ctx sdk.Context, totalAmt sdk.Int) sdk.Dec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess is better to change the use of sdk.int for cosmossdk.io/math, since its deprecated
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func (k Keeper) HandleInflationChange(ctx sdk.Context) (inflationRate sdk.Dec, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the function, i understand we support increasing inflation functions as well.
I thought, from the PRD, inflation was always a decreasing function, but just asking to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it depends on the target inflation, relatives to current inflation
x/mint/keeper/mint.go
Outdated
func (k Keeper) CalcMintedCoins(ctx sdk.Context, totalAmt sdk.Int) sdk.Dec { | ||
params := k.GetParams(ctx) | ||
minter := k.GetMinter(ctx) | ||
mintAmount := minter.CurrentInflationRate.MulInt(totalAmt).QuoInt(sdk.NewInt(params.MintEpochSpreadFactor)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i understand that MintEpochSpreadFactor param, is the number of minting epochs in a year that is used to calculate the minted tokens for each epoch.
If this is the case , i do not see why it is necessary to have a specific parameter for that, and why cannot be derived from MintEpochIdentifier to calculate how many minting epochs we have in a year. and in case we use it, i think MintEpochSpreadFactor needs to be validated to match the MintEpochIdentifier and probably a better name like MintingEpochsInAYear can be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check if possible to get it from the epochKeeper
otherwise, we need some translation between mint_epoch - string
to num of epochs in a year
anyway, it allow some generalized approach, in case inflation won't be calculated annually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Co-authored-by: zale144 <[email protected]> Co-authored-by: Omri <[email protected]>
Co-authored-by: zale144 <[email protected]> Co-authored-by: Omri <[email protected]>
mint module now:
mint_epoch
by calculatingcurrent_inflation
of thetotal_supply
inflation_epoch
byinflation_rate_change
towards thetarget_inflation_rate
PRD:
https://www.notion.so/dymension/RollApp-Mint-4e0e66a9c2f142ceb3dbfc188830da0d?pvs=4
Missing: