logos-co / staking

SNT Staking contracts
Creative Commons Zero v1.0 Universal
0 stars 4 forks source link

Lock and Stake _time parameter is confusing #79

Closed 3esmit closed 6 months ago

3esmit commented 6 months ago

_time parameters can be used differently, depending on how current account state is.

After refactor _time become relative.

  1. If account state is not initializated, or not locked, executes account.lockUntil = block.timestamp + _time.
  2. If account is locked, _time executes account.lockUntil += _time

For both, _mintIntialMP would use _time.

Previously before refactor (https://github.com/logos-co/staking/pull/63) _time was absolute, therefore account.lockUntil = _time, and checks were done to ensure this parameters was within boundries of block.timestamp, and _mintIntialMP would use deltaTime = _time - block.timestamp

3esmit commented 6 months ago

I changed to time be relative together with the initialization of accounts based on lockUntil.

Unlocked accounts basically are accounts that lockUntil the exact same time they deposit, so the _time for locking is the block.timestamp of the transaction that initialized the staking.

Therefore, if an account have a lockUntil == 0, this means this account is not initializated, because timestamp 0 is an invalid timestamp value, therefore this value was used to determine initialization of an account.

Previously the refactor, the _time was absolute, this means that the parameter was exact timestamp of lockUntil. and therefore the parameter could be considered _lockUntil. Or it could be zero, that would use _lockUntil as block.timestamp.

After the refactor, the amount of seconds to increase, relative from:

3esmit commented 6 months ago

I favour the use of relative time, because:

0x-r4bbit commented 6 months ago

There's a chance that changes done here are related to https://github.com/logos-co/staking/issues/80 @3esmit do you think we can get your _time related changes in?

If you confirm it's this commit introducing the necessary changes (https://github.com/logos-co/staking/pull/69/commits/c12d1ee9b17d806300d683fd623f98e965a44d71), we can cherry-pick it.