Sync delegatedStakeToPoolByOwner whenever _withdrawAndSyncDelegatorRewards is called
This commit is contained in:
		| @@ -31,25 +31,13 @@ contract MixinStakingPoolRewards is | |||||||
| { | { | ||||||
|     using LibSafeMath for uint256; |     using LibSafeMath for uint256; | ||||||
|  |  | ||||||
|     /// @dev Syncs rewards for a delegator. This includes transferring WETH |     /// @dev Withdraws the caller's WETH rewards that have accumulated | ||||||
|     ///      rewards to the delegator, and adding/removing |     ///      until the last epoch. | ||||||
|     ///      dependencies on cumulative rewards. |  | ||||||
|     ///      This is used by a delegator when they want to sync their rewards |  | ||||||
|     ///      without delegating/undelegating. It's effectively the same as |  | ||||||
|     ///      delegating zero stake. |  | ||||||
|     /// @param poolId Unique id of pool. |     /// @param poolId Unique id of pool. | ||||||
|     function withdrawDelegatorRewards(bytes32 poolId) |     function withdrawDelegatorRewards(bytes32 poolId) | ||||||
|         external |         external | ||||||
|     { |     { | ||||||
|         address member = msg.sender; |         _withdrawAndSyncDelegatorRewards(poolId, msg.sender); | ||||||
|  |  | ||||||
|         _withdrawAndSyncDelegatorRewards( |  | ||||||
|             poolId, |  | ||||||
|             member |  | ||||||
|         ); |  | ||||||
|  |  | ||||||
|         _delegatedStakeToPoolByOwner[member][poolId] = |  | ||||||
|             _loadCurrentBalance(_delegatedStakeToPoolByOwner[member][poolId]); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// @dev Computes the reward balance in ETH of the operator of a pool. |     /// @dev Computes the reward balance in ETH of the operator of a pool. | ||||||
| @@ -105,8 +93,8 @@ contract MixinStakingPoolRewards is | |||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /// @dev Syncs rewards for a delegator. This includes transferring rewards |     /// @dev Syncs rewards for a delegator. This includes withdrawing rewards | ||||||
|     ///      withdrawing rewards and adding/removing dependencies on cumulative rewards. |     ///      rewards and adding/removing dependencies on cumulative rewards. | ||||||
|     /// @param poolId Unique id of pool. |     /// @param poolId Unique id of pool. | ||||||
|     /// @param member of the pool. |     /// @param member of the pool. | ||||||
|     function _withdrawAndSyncDelegatorRewards( |     function _withdrawAndSyncDelegatorRewards( | ||||||
| @@ -128,6 +116,12 @@ contract MixinStakingPoolRewards is | |||||||
|             0 |             0 | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|  |         // Sync the delegated stake balance. This will ensure future calls of | ||||||
|  |         // `_computeDelegatorReward` during this epoch will return 0,  | ||||||
|  |         // preventing a delegator from withdrawing more than once an epoch. | ||||||
|  |         _delegatedStakeToPoolByOwner[member][poolId] = | ||||||
|  |             _loadCurrentBalance(_delegatedStakeToPoolByOwner[member][poolId]); | ||||||
|  |  | ||||||
|         // Withdraw non-0 balance |         // Withdraw non-0 balance | ||||||
|         if (balance != 0) { |         if (balance != 0) { | ||||||
|             // Decrease the balance of the pool |             // Decrease the balance of the pool | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user