Skip to content

Commit 5ca7621

Browse files
committed
chore(protocol-contracts): take review into account
1 parent e0af048 commit 5ca7621

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

protocol-contracts/staking/contracts/OperatorRewarder.sol

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,24 @@ contract OperatorRewarder is Ownable {
5656
/// @notice Error for invalid beneficiary address.
5757
error InvalidBeneficiary(address beneficiary);
5858

59+
/// @notice Error for beneficiary already set to the same address.
60+
error BeneficiaryAlreadySet(address beneficiary);
61+
5962
/// @notice Error for attempting to shutdown when already shutdown.
6063
error AlreadyShutdown();
6164

6265
/// @notice Error for invalid basis points value.
6366
error InvalidBasisPoints(uint16 basisPoints);
6467

68+
/// @notice Error for fee already set to the same value.
69+
error FeeAlreadySet(uint16 basisPoints, uint16 feeBasisPoints);
70+
6571
/// @notice Error for basis points value greater than the maximum allowed.
6672
error MaxBasisPointsExceeded(uint16 basisPoints, uint16 maxBasisPoints);
6773

74+
/// @notice Error for max fee already set to the same value.
75+
error MaxFeeAlreadySet(uint16 basisPoints, uint16 maxFeeBasisPoints);
76+
6877
modifier onlyOperatorStaking() {
6978
require(msg.sender == address(operatorStaking()), CallerNotOperatorStaking(msg.sender));
7079
_;
@@ -281,9 +290,9 @@ contract OperatorRewarder is Ownable {
281290
* @param newBeneficiary The new beneficiary address.
282291
*/
283292
function _transferBeneficiary(address newBeneficiary) internal virtual {
284-
if (newBeneficiary == address(0)) {
285-
revert InvalidBeneficiary(address(0));
286-
}
293+
require(newBeneficiary != address(0), InvalidBeneficiary(address(0)));
294+
require(newBeneficiary != _beneficiary, BeneficiaryAlreadySet(newBeneficiary));
295+
287296
address oldBeneficiary = _beneficiary;
288297
_beneficiary = newBeneficiary;
289298
emit BeneficiaryTransferred(oldBeneficiary, newBeneficiary);
@@ -311,6 +320,7 @@ contract OperatorRewarder is Ownable {
311320
*/
312321
function _setMaxfee(uint16 basisPoints) internal virtual {
313322
require(basisPoints <= 10000, InvalidBasisPoints(basisPoints));
323+
require(basisPoints != _maxfeeBasisPoints, MaxFeeAlreadySet(basisPoints, _maxfeeBasisPoints));
314324

315325
if (basisPoints < _feeBasisPoints) {
316326
_setFee(basisPoints);
@@ -327,6 +337,7 @@ contract OperatorRewarder is Ownable {
327337
*/
328338
function _setFee(uint16 basisPoints) internal virtual {
329339
require(basisPoints <= 10000, InvalidBasisPoints(basisPoints));
340+
require(basisPoints != feeBasisPoints(), FeeAlreadySet(basisPoints, feeBasisPoints()));
330341
require(basisPoints <= _maxfeeBasisPoints, MaxBasisPointsExceeded(basisPoints, _maxfeeBasisPoints));
331342

332343
_claimFee();

protocol-contracts/staking/tasks/deposit.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';
1414
// --network testnet
1515
task('task:depositOperatorStakingFromDeployer')
1616
.addParam('assets', 'The amount of assets to deposit into the operator staking contract', 0n, types.bigint)
17-
.addParam('receiver', 'The address of the operator rewarder contract to set the fee for', '', types.string)
17+
.addParam('receiver', 'The address to receive the minted shares', '', types.string)
1818
.addParam(
1919
'operatorStakingAddress',
2020
'The address of the operator staking contract to deposit assets into',
@@ -30,11 +30,11 @@ task('task:depositOperatorStakingFromDeployer')
3030
const { deployer } = await getNamedAccounts();
3131
const deployerSigner = await ethers.getSigner(deployer);
3232

33-
// Get the Zama token mock contract
34-
const zamaTokenMock = await ethers.getContractAt('ERC20Mock', getRequiredEnvVar('ZAMA_TOKEN_ADDRESS'));
33+
// Get the Zama token contract as an ERC20 interface
34+
const zamaToken = await ethers.getContractAt('IERC20', getRequiredEnvVar('ZAMA_TOKEN_ADDRESS'));
3535

3636
// Approve the operator staking contract with the assets amount
37-
const txApprove = await zamaTokenMock.connect(deployerSigner).approve(operatorStakingAddress, assets);
37+
const txApprove = await zamaToken.connect(deployerSigner).approve(operatorStakingAddress, assets);
3838
const receiptApprove = await txApprove.wait();
3939

4040
if (receiptApprove?.status !== 1) {

0 commit comments

Comments
 (0)