@@ -31,6 +31,9 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable {
3131 /// @notice Error: Attempting to unstake amount greater than the balance.
3232 error UnstakeAmountExceedsBalance (uint256 _amountToUnstake , uint256 _currentStake );
3333
34+ /// @notice Error: Unstake transfer failed.
35+ error UnstakeTransferFailed ();
36+
3437 /// @notice Error: The sum of all amounts to distribute did not equal msg.value of the distribute transaction.
3538 error DistributionAmountsDoNotMatchTotal (uint256 _msgValue , uint256 _calculatedTotalDistribution );
3639
@@ -137,7 +140,21 @@ contract StakeHolder is AccessControlEnumerableUpgradeable, UUPSUpgradeable {
137140
138141 emit StakeRemoved (msg .sender , _amountToUnstake, newBalance);
139142
140- payable (msg .sender ).transfer (_amountToUnstake);
143+ // slither-disable-next-line low-level-calls
144+ (bool success , bytes memory returndata ) = payable (msg .sender ).call {value: _amountToUnstake}("" );
145+ if (! success) {
146+ // Look for revert reason and bubble it up if present.
147+ // Revert reasons should contain an error selector, which is four bytes long.
148+ if (returndata.length >= 4 ) {
149+ // solhint-disable-next-line no-inline-assembly
150+ assembly {
151+ let returndata_size := mload (returndata)
152+ revert (add (32 , returndata), returndata_size)
153+ }
154+ } else {
155+ revert UnstakeTransferFailed ();
156+ }
157+ }
141158 }
142159
143160 /**
0 commit comments