-
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
Implement cooldown periods #14
Comments
Cooldown periods will be implemented in the following way:
|
Updated the issue description accordingly. |
Looks good to me |
After I started working on the I'd like to hereby lay out the options we have and their tradeoffs we have to make for either of these options to work. PrerequisiteFirst and foremost I think it's important to understand what impact the
In addition to the above we need to consider that we haven't yet decided if users will be able to stake into a single vault more than once or not. This will have effects on the usability of this protocol. As part of this discussion, I'll consider both paths to be a possibility: users can either stake into new vault, or add stake to existing vaults.
|
I think this can be executed in the first processAccount() call. Then, I guess, this would need to be managed by StakeManager. However, I think it would simplify the rest of the discussion, no? Or is this not feasible?
From a dev perspective, I'd prefer 1. for simplicity. On the contrary, as a user, I know the frustration that you deposit the stake and it is not yet earning anything - it is a strong incentive to lock. Scenario 5 - I think the following would be a good compromise here:
I think this should be possible if we indeed track the cooldown in StakeManager. We can predict on aggregate how many MPs and stake will exit cooldown and become active in the next epoch (recorded at stake transaction). And the rest of the user triggered calculations can happen with the first processAccount(). You make a good point that all deposits within an epoch are treated the same - as a single deposit. With 2 week cooldown and 1 week epoch, we can have max 1 epoch of additional deposit. Not sure it helps but it gives some specifics to scenarios. |
@mart1n-xyz so the idea with this approach would be: basically don't even let the In other words, I'd probably introduce two new functions (and change one)
Something along those lines.
So here, I think it's important to keep in mind that: due to the deposit cooldown you'll not earn anything anyways, if you decide to unstake before deposit cooldown is elapsed and, So one could say that your funds are earning rewards silently. |
I'm starting to implement some of the ideas discussed in the issue. Imagine the following scenario (I realized this is very similar to Scenario 5 discussed above, only difference is that the deposit cooldown period has passed, so all solutions from Scenario 5 apply here):
^ Here, if we keep a trivial check in How do we want to handle this? I see a few options:
But then, this will also introduce the additional complexity that, when a user calls
How does everyone feel about this? |
I just realized, we'll have a similar complexity with the
This works fine if the user decides to
So here, we similar need to keep track of funds that were withdrawn before. In an additional scenario where the user I guess, similarly, we could avoid this complexity by saying, users can only |
Here's another one that maybe @mart1n-xyz can answer as this might have an impact on how well the reward system is balanced. Here's a scenario:
In step 2) it's theoretically possible to give Questions:
In other words, do we want to allow users to also retroactively apply a lockup time for their deposit that was done without a lockup time? Alternatively, we could/would retroactively mint rewards for the deposit cooldown period up until now and then apply the lockup going forward. |
I still feel the solution to majority of these problems indeed lies in tracking the cooldowns in StakeManager and not async in StakeVault. Even if not, in this case, we can make sure processAccount is called if any additional stake is being added (called from within deposit()), activating the previous deposit and emptying the cooldown queue for the new deposit.
I think this is preferable, I have actually experienced this behaviour in other staking contracts. We want to limit response (selling) to price action and having a gradual unstaking is a strong mechanism here. Otherwise, we'd just delay the response by 2 weeks, this way we may somewhat smooth it out.
If we have this deposit()/stake() split, we need to have the user specify the lock up time in deposit(). This is because for locked vaults, the cooldown does not apply (obviously, we need MIN_LOCKUP_TIME>2 weeks). This is another reason why I think we need to get the call to StakeManager. Let me know if I am missing something. |
I actually started with having the cooldown periods tracked in the manager, but after discussing this with @3esmit we decided that this would make
@mart1n-xyz If you want to deposit and stake right away in one go (which requires a lockup time) you'd need to call However, still, in case of using At this point we really just need to decide a) do we allow for apply a lock time now? Basically as if we did stake + lock() and if yes then b) would the lock time retroactively apply to rewards minting as well. I personally think it makes more sense to treat it as
instead of
|
Here's a draft branch that shows what this looks like in action (note: it's a WIP)
Again, it's a WIP. Some things that are missing is the unstake/withdrawal handling and also the ability to call |
Thank you for explaining, this makes sense. I may have been missing your point earlier.
Yes, it makes sense to allow it. As you mention, user can call lock() anyway. I agree with the deposit() -> cooldown -> stake() -> lock(lockTime). I do not see why we should retroactively grant lock time from cooldown - it is user's fault in the first place that he didn't lock at the onset. Allowing for this introduces inconsistency. The dominant strategy would be to always go this path since you have the same outcome as with depositAndStake() but can withdraw anytime within those 2 weeks. |
Another scenario, this time considering the The
Very similar to deposit cooldown, similar things apply. If the user But, what if the following happens:
Does this mean that |
I'd argue for disabling unstaking while there's an active withdrawal cooldown as per one of my previous comments. Reseting the cooldown is another option but I think suboptimal. Here, I'd again consider that we are dealing with epoch time units - hence withdrawals within one epoch can be treated as a single one. |
Unassigning and rolling back to "TODO" state. |
The cooldown periods in Status Staking Summary are not implemented.
UPDATE: Explanding this.
There's two "periods" that need to be implemented: deposit_cooldown_period and withdrawal_cooldown_period
These are meant to work as follows:
This issue is considered done when the following has been implemented:
deposit_cooldown_period
functionality when unstaking fundswithdrawal_cooldown_period
functionality when unstaking fundsNotice that implementing
withdrawal_cooldown_period
for reward collector vault depends on #34 .So it's possible to first only implement it for
unstake()
The text was updated successfully, but these errors were encountered: