@@ -25,6 +25,7 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
2525 error ZeroAddress ();
2626 error ZeroAmount ();
2727 error NotGovernance ();
28+ error NotAdmin ();
2829 error NotTreasury ();
2930 error WithdrawalAlreadyClaimed ();
3031 error WithdrawalPeriodNotPassed ();
@@ -38,6 +39,7 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
3839
3940 event TreasurySet (address indexed treasury );
4041 event GovernanceTransferred (address indexed oldGovernance , address indexed newGovernance );
42+ event AdminTransferred (address indexed oldAdmin , address indexed newAdmin );
4143 event EpochAdvanced (uint256 oldEpochBlock , uint256 newEpochBlock );
4244 event WithdrawalRequested (address indexed user , uint256 sharesAmount , uint256 withdrawalId );
4345 event WithdrawalClaimed (address indexed user , uint256 withdrawalId , uint256 usxAmount );
@@ -62,6 +64,11 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
6264 _;
6365 }
6466
67+ modifier onlyAdmin () {
68+ if (msg .sender != _getStorage ().admin) revert NotAdmin ();
69+ _;
70+ }
71+
6572 modifier onlyTreasury () {
6673 if (msg .sender != address (_getStorage ().treasury)) revert NotTreasury ();
6774 _;
@@ -88,6 +95,7 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
8895 struct SUSXStorage {
8996 IERC20 USX; // USX token reference (the underlying asset)
9097 ITreasury treasury; // treasury contract
98+ address admin; // address that controls admin of the contract
9199 address governance; // address that controls governance of the contract
92100 uint256 withdrawalPeriod; // withdrawal period in seconds, (default == 15 * 24 * 60 * 60 (15 days))
93101 uint256 withdrawalFeeFraction; // fraction of withdrawals determining the withdrawal fee, (default 0.05% == 500) with precision 6 decimals
@@ -126,7 +134,7 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
126134 /// @param _usx Address of the USX token
127135 /// @param _treasury Address of the Treasury contract
128136 /// @param _governance Address of the governance
129- function initialize (address _usx , address _treasury , address _governance ) public initializer {
137+ function initialize (address _usx , address _treasury , address _admin , address _governance ) public initializer {
130138 if (_usx == address (0 ) || _governance == address (0 )) revert ZeroAddress ();
131139
132140 // Initialize ERC4626, ERC20, and ReentrancyGuard
@@ -137,6 +145,7 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
137145 SUSXStorage storage $ = _getStorage ();
138146 $.USX = IERC20 (_usx);
139147 $.treasury = ITreasury (_treasury);
148+ $.admin = _admin;
140149 $.governance = _governance;
141150
142151 // Set default values
@@ -147,7 +156,7 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
147156
148157 /// @notice Set the initial Treasury address - can only be called once when treasury is address(0)
149158 /// @param _treasury Address of the Treasury contract
150- function initializeTreasury (address _treasury ) external onlyGovernance {
159+ function initializeTreasury (address _treasury ) external onlyAdmin {
151160 if (_treasury == address (0 )) revert ZeroAddress ();
152161 SUSXStorage storage $ = _getStorage ();
153162 if ($.treasury != ITreasury (address (0 ))) revert TreasuryAlreadySet ();
@@ -216,15 +225,6 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
216225
217226 /*=========================== Governance Functions =========================*/
218227
219- /// @notice Sets withdrawal period in seconds
220- /// @param _withdrawalPeriod The new withdrawal period in seconds
221- function setWithdrawalPeriod (uint256 _withdrawalPeriod ) public onlyGovernance {
222- SUSXStorage storage $ = _getStorage ();
223- uint256 oldPeriod = $.withdrawalPeriod;
224- $.withdrawalPeriod = _withdrawalPeriod;
225- emit WithdrawalPeriodSet (oldPeriod, _withdrawalPeriod);
226- }
227-
228228 /// @notice Sets withdrawal fee with precision to 0.001 percent
229229 /// @param _withdrawalFeeFraction The new withdrawal fee fraction
230230 function setWithdrawalFeeFraction (uint256 _withdrawalFeeFraction ) public onlyGovernance {
@@ -235,16 +235,6 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
235235 emit WithdrawalFeeFractionSet (oldFraction, _withdrawalFeeFraction);
236236 }
237237
238- /// @notice Sets duration of epoch in seconds
239- /// @param _epochDurationSeconds The new epoch duration in seconds
240- function setEpochDuration (uint256 _epochDurationSeconds ) public onlyGovernance {
241- if (_epochDurationSeconds < MIN_EPOCH_DURATION) revert InvalidEpochDuration ();
242- SUSXStorage storage $ = _getStorage ();
243- uint256 oldDuration = $.epochDuration;
244- $.epochDuration = _epochDurationSeconds;
245- emit EpochDurationSet (oldDuration, _epochDurationSeconds);
246- }
247-
248238 /// @notice Set new governance address
249239 /// @param newGovernance Address of new governance
250240 function setGovernance (address newGovernance ) external onlyGovernance {
@@ -257,15 +247,46 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
257247 emit GovernanceTransferred (oldGovernance, newGovernance);
258248 }
259249
250+ /*=========================== Admin Functions =========================*/
251+
252+ /// @notice Set new admin address
253+ /// @param newAdmin Address of new admin
254+ function setAdmin (address newAdmin ) external onlyAdmin {
255+ if (newAdmin == address (0 )) revert ZeroAddress ();
256+ SUSXStorage storage $ = _getStorage ();
257+ address oldAdmin = $.admin;
258+ $.admin = newAdmin;
259+ emit AdminTransferred (oldAdmin, newAdmin);
260+ }
261+
262+ /// @notice Sets withdrawal period in seconds
263+ /// @param _withdrawalPeriod The new withdrawal period in seconds
264+ function setWithdrawalPeriod (uint256 _withdrawalPeriod ) public onlyAdmin {
265+ SUSXStorage storage $ = _getStorage ();
266+ uint256 oldPeriod = $.withdrawalPeriod;
267+ $.withdrawalPeriod = _withdrawalPeriod;
268+ emit WithdrawalPeriodSet (oldPeriod, _withdrawalPeriod);
269+ }
270+
271+ /// @notice Sets duration of epoch in seconds
272+ /// @param _epochDurationSeconds The new epoch duration in seconds
273+ function setEpochDuration (uint256 _epochDurationSeconds ) public onlyAdmin {
274+ if (_epochDurationSeconds < MIN_EPOCH_DURATION) revert InvalidEpochDuration ();
275+ SUSXStorage storage $ = _getStorage ();
276+ uint256 oldDuration = $.epochDuration;
277+ $.epochDuration = _epochDurationSeconds;
278+ emit EpochDurationSet (oldDuration, _epochDurationSeconds);
279+ }
280+
260281 /// @notice Unpause deposit, allowing users to deposit again
261- function unpauseDeposit () external onlyGovernance {
282+ function unpauseDeposit () external onlyAdmin {
262283 SUSXStorage storage $ = _getStorage ();
263284 $.depositPaused = false ;
264285 emit DepositPausedChanged (false );
265286 }
266287
267288 /// @notice Pause deposit, preventing users from depositing USX
268- function pauseDeposit () external onlyGovernance {
289+ function pauseDeposit () external onlyAdmin {
269290 SUSXStorage storage $ = _getStorage ();
270291 $.depositPaused = true ;
271292 emit DepositPausedChanged (true );
@@ -415,6 +436,10 @@ contract StakedUSX is ERC4626Upgradeable, UUPSUpgradeable, ReentrancyGuardUpgrad
415436 return _getStorage ().governance;
416437 }
417438
439+ function admin () public view returns (address ) {
440+ return _getStorage ().admin;
441+ }
442+
418443 function withdrawalPeriod () public view returns (uint256 ) {
419444 return _getStorage ().withdrawalPeriod;
420445 }
0 commit comments