-
Notifications
You must be signed in to change notification settings - Fork 4
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
Introducing the Aggeregate MP Estimation Logic #32
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ contract StakeManager is Ownable { | |
uint256 startTime; | ||
uint256 epochReward; | ||
uint256 totalSupply; | ||
uint256 expMPsToBeMinted; | ||
uint256 stakeIn; | ||
} | ||
|
||
uint256 public constant EPOCH_SIZE = 1 weeks; | ||
|
@@ -152,7 +154,7 @@ contract StakeManager is Ownable { | |
|
||
function calcMaxMultiplierIncrease(uint256 _increasedMultiplier, uint256 _currentMp) private pure returns(uint256 _maxToIncrease) { | ||
uint256 newMp = _increasedMultiplier + _currentMp; | ||
return newMp > MAX_MP ? MAX_MP - newMp : _increasedMultiplier; | ||
return newMp > MAX_MP ? MAX_MP - _currentMp : _increasedMultiplier; | ||
} | ||
|
||
function processEpoch() private { | ||
|
@@ -164,6 +166,8 @@ contract StakeManager is Ownable { | |
//create new epoch | ||
currentEpoch++; | ||
epochs[currentEpoch].startTime = block.timestamp; | ||
epochs[currentEpoch].expMPsToBeMinted = stakeSupply*MP_APY/52; | ||
epochs[currentEpoch].stakeIn = stakeSupply; | ||
} | ||
} | ||
|
||
|
@@ -177,7 +181,8 @@ contract StakeManager is Ownable { | |
//mint multipliers to that epoch | ||
mintMultiplier(account, iEpoch.startTime + EPOCH_SIZE); | ||
uint256 userSupply = account.balance + account.multiplier; | ||
uint256 userShare = userSupply / iEpoch.totalSupply; //TODO: might lose precision, multiply by 100 and divide back later? | ||
uint256 epochSupply = iEpoch.stakeIn + iEpoch.expMPsToBeMinted; | ||
uint256 userShare = userSupply / epochSupply; //TODO: might lose precision, multiply by 100 and divide back later? | ||
userReward += userShare * iEpoch.epochReward; | ||
} | ||
account.epoch = userEpoch; | ||
|
@@ -195,6 +200,7 @@ contract StakeManager is Ownable { | |
uint256 increasedMultiplier = calcMaxMultiplierIncrease( | ||
account.balance * (MP_APY * deltaTime), | ||
account.multiplier); | ||
iEpoch.expMPsToBeMinted += account.balance * (MP_APY * deltaTime)-increasedMultiplier //TODO:this might need to be returned and done in the loop | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I assumed this would be an issue. I need to think about how to circumvent this. |
||
account.multiplier += increasedMultiplier; | ||
multiplierSupply += increasedMultiplier; | ||
} | ||
|
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.
Where is this
52
coming from? Is this for 52 weeks?If yes, then let's introduce a constant for that.
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.
yes, 52 weeks = 1 year