Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: optimize modifiers #7

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/ERC20/ERC20PermitPermissionedMint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,22 @@ contract ERC20PermitPermissionedMint is ERC20Permit, ERC20Burnable, Owned {
/* ========== MODIFIERS ========== */

modifier onlyByOwnGov() {
require(msg.sender == timelock_address || msg.sender == owner, "Not owner or timelock");
_onlyByOwnGov();
_;
}

function _onlyByOwnGov() private view {
require(msg.sender == timelock_address || msg.sender == owner, "Not owner or timelock");
}

modifier onlyMinters() {
require(minters[msg.sender] == true, "Only minters");
_onlyMinters();
_;
}
}

function _onlyMinters() private view {
require(minters[msg.sender] == true, "Only minters");
}

/* ========== RESTRICTED FUNCTIONS ========== */

Expand Down
7 changes: 6 additions & 1 deletion src/OperatorRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pragma solidity ^0.8.0;
// Reviewer(s) / Contributor(s)
// Travis Moore: https://github.com/FortisFortuna
// Dennis: https://github.com/denett
// Carter Carlson: https://github.com/pegahcarter

import "./Utils/Owned.sol";

Expand All @@ -43,10 +44,14 @@ contract OperatorRegistry is Owned {
}

modifier onlyByOwnGov() {
require(msg.sender == timelock_address || msg.sender == owner, "Not owner or timelock");
_onlyByOwnGov();
_;
}

function _onlyByOwnGov() private view {
require(msg.sender == timelock_address || msg.sender == owner, "Not owner or timelock");
}

/// @notice Add a new validator
/** @dev You should verify offchain that the validator is indeed valid before adding it
Reason we don't do that here is for gas */
Expand Down
7 changes: 6 additions & 1 deletion src/sfrxETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pragma solidity ^0.8.0;
// Dennett: https://github.com/denett
// Travis Moore: https://github.com/FortisFortuna
// Jamie Turley: https://github.com/jyturley
// Carter Carlson: https://github.com/pegahcarter

import { ERC20, ERC4626, xERC4626 } from "ERC4626/xERC4626.sol";
import "openzeppelin-contracts/contracts/security/ReentrancyGuard.sol";
Expand All @@ -40,10 +41,14 @@ import "openzeppelin-contracts/contracts/security/ReentrancyGuard.sol";
contract sfrxETH is xERC4626, ReentrancyGuard {

modifier andSync {
if (block.timestamp >= rewardsCycleEnd) { syncRewards(); }
_andSync();
_;
}

function _andSync() private {
if (block.timestamp >= rewardsCycleEnd) { syncRewards(); }
}

/* ========== CONSTRUCTOR ========== */
constructor(ERC20 _underlying, uint32 _rewardsCycleLength)
ERC4626(_underlying, "Staked Frax Ether", "sfrxETH")
Expand Down