You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unstake 1 near, and wait for the token to be released, so that it is available to withdraw;
At this point calling the unstake_all method will move the 1 token that was available to withdraw back to the pending release state. Upon brief reading of the code around this area
it seems like the behaviour would be the same for the regular unstake method with the amount too.
I’d argue that this behaviour is super unintuitive. Now, some ideas on how it could be improved:
Maintain a separate variable with the number of tokens that are available to withdraw. Any time account.unstaked_available_epoch_height is increased, the contract would move the tokens that are already available for withdraw to this new variable;
This still has a problem where the tokens would never become available to withdraw if unstake(amount: 1N) was called every 24 hours, for example (at least as long as the staked balance is available).
Maintain a log of pending unstakes?
Sounds potentially pretty expensive on storage.
Maintain a list of tokens pending to release for the upcoming NUM_EPOCHS_TO_UNLOCK epochs of interest.
Constant storage per account, that scales with NUM_EPOCHS_TO_UNLOCK rather than the number of operations.
Has the "intuitive" behaviour in all cases in that as tokens are unstaked they are always made available to withdraw NUM_EPOCHS_TO_UNLOCK epochs later, no matter what other operations have been executed before withdrawing.
Not sure if any of these changes are feasible or possible though (upgrading contract data sounds like it’d be non-trivial…)
The text was updated successfully, but these errors were encountered:
nagisa
changed the title
staking-pool: unstake_all will lock up the tokens that are available to withdraw
staking-pool: unstake_all will lock up the tokens that are already available to withdraw
Jan 3, 2023
Consider a situation like this:
At this point calling the
unstake_all
method will move the 1 token that was available to withdraw back to the pending release state. Upon brief reading of the code around this areacore-contracts/staking-pool/src/internal.rs
Lines 154 to 157 in dad58eb
unstake
method with the amount too.I’d argue that this behaviour is super unintuitive. Now, some ideas on how it could be improved:
account.unstaked_available_epoch_height
is increased, the contract would move the tokens that are already available for withdraw to this new variable;unstake(amount: 1N)
was called every 24 hours, for example (at least as long as the staked balance is available).NUM_EPOCHS_TO_UNLOCK
epochs of interest.NUM_EPOCHS_TO_UNLOCK
rather than the number of operations.NUM_EPOCHS_TO_UNLOCK
epochs later, no matter what other operations have been executed before withdrawing.Not sure if any of these changes are feasible or possible though (upgrading contract data sounds like it’d be non-trivial…)
The text was updated successfully, but these errors were encountered: