vacp2p / staking-reward-streamer

MIT License
0 stars 0 forks source link

initialMP (bonusMP) should be considered in calculations #43

Closed 3esmit closed 4 weeks ago

3esmit commented 1 month ago

The definition of the MP logic states that:

0x-r4bbit commented 1 month ago

when user stakes, bonusMP should be generated from APY(balance, secondsLocked)

This is happening here: https://github.com/vacp2p/staking-reward-streamer/blob/286bfd2ff43732b395682917c9d81f24fa81cf2f/src/RewardsStreamerMP.sol#L83-L88

when user unstakes, bonusMP should be recalculated based on new APY(balance, secondsLocked)

Currently "bonusMP" are just an increase in the userMP, so when you unstake, userMP gets reduced accordingly, so doespotentialMP. This is happening here: https://github.com/vacp2p/staking-reward-streamer/blob/286bfd2ff43732b395682917c9d81f24fa81cf2f/src/RewardsStreamerMP.sol#L122-L124

and if it was locked before, the bonus would be lost

This indeed is not taken into account atm.

when considering MAX_MULTIPLIER, the bonusMP should not be taken in account, otherwise, a user that locked for MAX_LOCKUP_PERIOD would get no (or almost none) increase in MPs.

Not sure what you mean by that. When MPs are calculated, it's done based on thestakedAmount (which is the same as initialMP without lock). This can be seen here:

https://github.com/vacp2p/staking-reward-streamer/blob/286bfd2ff43732b395682917c9d81f24fa81cf2f/src/RewardsStreamerMP.sol#L208

0x-r4bbit commented 1 month ago

@3esmit so it turns out the bonusMP are reduced correctly.

I've added test cases for this here: https://github.com/vacp2p/staking-reward-streamer/pull/48

0x-r4bbit commented 4 weeks ago

Test for this have landed in #48 Closing this.