poanetwork / posdao-contracts

Smart contracts for POSDAO (Proof of Stake Decentralized Autonomous Organization consensus), a DPOS consensus implemented in Solidity and running within EVM with swappable BFT consensus
Other
105 stars 49 forks source link

Change stakes withdrawal logic #32

Closed varasev closed 5 years ago

varasev commented 5 years ago

Change the logic so that a delegator could order a withdrawal at any time, but would only receive their funds after the current staking epoch and only if the validator behaved correctly.

Allow withdrawing any stakes that are not active yet, i.e. which the delegator made during the current staking epoch.

varasev commented 5 years ago

The corresponding changes have been made in https://github.com/poanetwork/posdao-contracts/commit/4825aba66020d1e3b5e9566d98a0e932e84f74f5.

Now, the staker (delegator or validator) can use the orderWithdraw function.

It can be called during exactly the same period of time when the withdraw can be called.

The ordered withdraw amount will be sent to the staker automatically when the next staking epoch starts.

Note that orderWithdraw accepts the _amount param as a signed integer: this allows the staker to cancel or reduce their ordered withdraw amount (for the case when the staker changed their mind).