IPTokenStaking unstake function patch

The maximum number of decimals the Consensus Client works with 9 decimals (gwei). Due to that limitation, in IPTokenStaking we round down to gwei the amount when staking, creating validator (returning the difference to the caller) and when redelegating.

When unstaking however, the function would revert if the unstake amount provided by the caller is not divisible by gwei. For direct users this is not an issue since the amount can be corrected in subsequent transactions. One of our integration partners found an edge case where smart contract integrations could fail to unstake, for example if they have rounding errors, potentially leading to funds being stuck.

To avoid such cases, we:

  • Deployed a new implementation that rounds the unstaking amount instead of reverting (rounding errors may leave dust without unstaking, but they won’t revert, avoiding blockers when unstaking tokens)

PR:

New implementation:

  • Story Governance scheduled the upgrade transaction in the TimelockController to update the staking contract proxy

PR:

Transaction:

ABI, events and other functionality are exactly the same than before the patch, so there is no action required from users or other projects integrating with the staking contract, API, SDK, etc.

4 Likes