From a840dc0b8a1de59a3ea06e0814ea3ce26707bdae Mon Sep 17 00:00:00 2001 From: Vapor Kane Date: Sun, 4 Jun 2023 09:17:46 +0000 Subject: [PATCH] fix 6 --- src/AMO2.sol | 16 ++++++++++++++++ src/CVXStaker.sol | 11 ++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/AMO2.sol b/src/AMO2.sol index 9fed8bf..fadc236 100644 --- a/src/AMO2.sol +++ b/src/AMO2.sol @@ -657,4 +657,20 @@ contract xETH_AMO is AccessControl { stETH.safeTransfer(msg.sender, output); } + + /** + * @notice Recover any token from AMO + * @param token Token to recover + * @param to Recipient address + * @param amount Amount to recover + */ + function recoverToken( + address token, + address to, + uint256 amount + ) external onlyRole(DEFAULT_ADMIN_ROLE) { + IERC20(token).safeTransfer(to, amount); + + emit RecoveredToken(token, to, amount); + } } diff --git a/src/CVXStaker.sol b/src/CVXStaker.sol index d5e334e..5c959bd 100644 --- a/src/CVXStaker.sol +++ b/src/CVXStaker.sol @@ -93,7 +93,7 @@ contract CVXStaker is Ownable { } /** - * @notice Recover any token from AMO + * @notice Recover any token from cvxStaker * @param token Token to recover * @param to Recipient address * @param amount Amount to recover @@ -163,18 +163,19 @@ contract CVXStaker is Ownable { /** * @dev Withdraws all staked tokens from the reward pool and unwraps them to the original tokens. * @param claim A boolean indicating whether to claim rewards before withdrawing. - * @param sendToOperator A boolean indicating whether to send the unwrapped tokens to the operator. + * @param sendToOwner A boolean indicating whether to send the unwrapped tokens to the owner. * If false, the tokens will remain in the contract. * Only the contract owner can call this function. */ function withdrawAllAndUnwrap( bool claim, - bool sendToOperator + bool sendToOwner ) external onlyOwner { IBaseRewardPool(cvxPoolInfo.rewards).withdrawAllAndUnwrap(claim); - if (sendToOperator) { + if (sendToOwner) { uint256 totalBalance = clpToken.balanceOf(address(this)); - clpToken.safeTransfer(operator, totalBalance); + /// @dev msg.sender is the owner, due to onlyOwner modifier + clpToken.safeTransfer(msg.sender, totalBalance); } }