Skip to content

Commit 9be7ca8

Browse files
authored
Merge pull request #7 from Renzo-Protocol/v1.8-v1.9
V1.8 v1.9
2 parents 57f6b3e + 2aad4e6 commit 9be7ca8

9 files changed

+847
-195
lines changed

contracts/Delegation/OperatorDelegator.sol

Lines changed: 150 additions & 54 deletions
Large diffs are not rendered by default.

contracts/Deposits/DepositQueue.sol

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ import "./DepositQueueStorage.sol";
77
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
88
import "../Errors/Errors.sol";
99

10-
contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueueStorageV2 {
10+
contract DepositQueue is
11+
Initializable,
12+
ReentrancyGuardUpgradeable,
13+
DepositQueueStorageV2
14+
{
1115
using SafeERC20 for IERC20;
1216

13-
address public constant IS_NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
17+
address public constant IS_NATIVE =
18+
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
1419

1520
event RewardsDeposited(IERC20 token, uint256 amount);
1621

@@ -32,7 +37,10 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
3237
event GasRefunded(address admin, uint256 gasRefunded);
3338

3439
/// @dev Event emitted when withdrawQueue is updated
35-
event WithdrawQueueUpdated(address oldWithdrawQueue, address newWithdrawQueue);
40+
event WithdrawQueueUpdated(
41+
address oldWithdrawQueue,
42+
address newWithdrawQueue
43+
);
3644

3745
/// @dev Event emitted when withdrawQueue buffer is filled for specified token
3846
event BufferFilled(address token, uint256 amount);
@@ -42,7 +50,8 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
4250

4351
/// @dev Allows only a whitelisted address to configure the contract
4452
modifier onlyRestakeManagerAdmin() {
45-
if (!roleManager.isRestakeManagerAdmin(msg.sender)) revert NotRestakeManagerAdmin();
53+
if (!roleManager.isRestakeManagerAdmin(msg.sender))
54+
revert NotRestakeManagerAdmin();
4655
_;
4756
}
4857

@@ -54,13 +63,15 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
5463

5564
/// @dev Allows only a whitelisted address to trigger native ETH staking
5665
modifier onlyNativeEthRestakeAdmin() {
57-
if (!roleManager.isNativeEthRestakeAdmin(msg.sender)) revert NotNativeEthRestakeAdmin();
66+
if (!roleManager.isNativeEthRestakeAdmin(msg.sender))
67+
revert NotNativeEthRestakeAdmin();
5868
_;
5969
}
6070

6171
/// @dev Allows only a whitelisted address to trigger ERC20 rewards sweeping
6272
modifier onlyERC20RewardsAdmin() {
63-
if (!roleManager.isERC20RewardsAdmin(msg.sender)) revert NotERC20RewardsAdmin();
73+
if (!roleManager.isERC20RewardsAdmin(msg.sender))
74+
revert NotERC20RewardsAdmin();
6475
_;
6576
}
6677

@@ -84,9 +95,14 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
8495
* @dev permissioned call (onlyRestakeManagerAdmin)
8596
* @param _withdrawQueue new withdraw Queue contract address
8697
*/
87-
function setWithdrawQueue(IWithdrawQueue _withdrawQueue) external onlyRestakeManagerAdmin {
98+
function setWithdrawQueue(
99+
IWithdrawQueue _withdrawQueue
100+
) external onlyRestakeManagerAdmin {
88101
if (address(_withdrawQueue) == address(0)) revert InvalidZeroInput();
89-
emit WithdrawQueueUpdated(address(withdrawQueue), address(_withdrawQueue));
102+
emit WithdrawQueueUpdated(
103+
address(withdrawQueue),
104+
address(_withdrawQueue)
105+
);
90106
withdrawQueue = _withdrawQueue;
91107
}
92108
/// @dev Sets the config for fees - if either value is set to 0 then fees are disabled
@@ -109,7 +125,9 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
109125
}
110126

111127
/// @dev Sets the address of the RestakeManager contract
112-
function setRestakeManager(IRestakeManager _restakeManager) external onlyRestakeManagerAdmin {
128+
function setRestakeManager(
129+
IRestakeManager _restakeManager
130+
) external onlyRestakeManagerAdmin {
113131
if (address(_restakeManager) == address(0x0)) revert InvalidZeroInput();
114132

115133
restakeManager = _restakeManager;
@@ -131,7 +149,10 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
131149
* @param _asset address of asset to fill up the buffer for
132150
* @param _amount amount of token to fill up the buffer with
133151
*/
134-
function fillERC20withdrawBuffer(address _asset, uint256 _amount) external nonReentrant {
152+
function fillERC20withdrawBuffer(
153+
address _asset,
154+
uint256 _amount
155+
) external nonReentrant {
135156
if (_amount == 0 || _asset == address(0)) revert InvalidZeroInput();
136157
// safeTransfer from restake manager to this address
137158
IERC20(_asset).safeTransferFrom(msg.sender, address(this), _amount);
@@ -162,7 +183,7 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
162183
// Take protocol cut of rewards if enabled
163184
if (feeAddress != address(0x0) && feeBasisPoints > 0) {
164185
feeAmount = (msg.value * feeBasisPoints) / 10000;
165-
(bool success, ) = feeAddress.call{ value: feeAmount }("");
186+
(bool success, ) = feeAddress.call{value: feeAmount}("");
166187
if (!success) revert TransferFailed();
167188

168189
emit ProtocolFeesPaid(IERC20(address(0x0)), feeAmount, feeAddress);
@@ -186,14 +207,19 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
186207
) external onlyNativeEthRestakeAdmin {
187208
uint256 gasBefore = gasleft();
188209
// Send the ETH and the params through to the restake manager
189-
restakeManager.stakeEthInOperatorDelegator{ value: 32 ether }(
210+
restakeManager.stakeEthInOperatorDelegator{value: 32 ether}(
190211
operatorDelegator,
191212
pubkey,
192213
signature,
193214
depositDataRoot
194215
);
195216

196-
emit ETHStakedFromQueue(operatorDelegator, pubkey, 32 ether, address(this).balance);
217+
emit ETHStakedFromQueue(
218+
operatorDelegator,
219+
pubkey,
220+
32 ether,
221+
address(this).balance
222+
);
197223

198224
// Refund the gas to the Admin address if enough ETH available
199225
_refundGas(gasBefore);
@@ -220,7 +246,7 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
220246
uint256 arrayLength = operatorDelegators.length;
221247
for (uint256 i = 0; i < arrayLength; ) {
222248
// Send the ETH and the params through to the restake manager
223-
restakeManager.stakeEthInOperatorDelegator{ value: 32 ether }(
249+
restakeManager.stakeEthInOperatorDelegator{value: 32 ether}(
224250
operatorDelegators[i],
225251
pubkeys[i],
226252
signatures[i],
@@ -259,8 +285,14 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
259285
}
260286

261287
// Approve and deposit the rewards
262-
token.safeIncreaseAllowance(address(restakeManager), balance - feeAmount);
263-
restakeManager.depositTokenRewardsFromProtocol(token, balance - feeAmount);
288+
token.safeIncreaseAllowance(
289+
address(restakeManager),
290+
balance - feeAmount
291+
);
292+
restakeManager.depositTokenRewardsFromProtocol(
293+
token,
294+
balance - feeAmount
295+
);
264296

265297
// Emit the rewards event
266298
emit RewardsDeposited(IERC20(address(token)), balance - feeAmount);
@@ -273,8 +305,10 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
273305
*/
274306
function _refundGas(uint256 initialGas) internal {
275307
uint256 gasUsed = (initialGas - gasleft()) * block.basefee;
276-
uint256 gasRefund = address(this).balance >= gasUsed ? gasUsed : address(this).balance;
277-
(bool success, ) = payable(msg.sender).call{ value: gasRefund }("");
308+
uint256 gasRefund = address(this).balance >= gasUsed
309+
? gasUsed
310+
: address(this).balance;
311+
(bool success, ) = payable(msg.sender).call{value: gasRefund}("");
278312
if (!success) revert TransferFailed();
279313
emit GasRefunded(msg.sender, gasRefund);
280314
}
@@ -284,13 +318,13 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
284318
*/
285319
function _checkAndFillETHWithdrawBuffer(uint256 _amount) internal {
286320
// Check the withdraw buffer and fill if below buffer target
287-
uint256 bufferToFill = withdrawQueue.getBufferDeficit(IS_NATIVE);
321+
uint256 bufferToFill = withdrawQueue.getWithdrawDeficit(IS_NATIVE);
288322

289323
if (bufferToFill > 0) {
290324
bufferToFill = (_amount <= bufferToFill) ? _amount : bufferToFill;
291325

292326
// fill withdraw buffer from received ETH
293-
withdrawQueue.fillEthWithdrawBuffer{ value: bufferToFill }();
327+
withdrawQueue.fillEthWithdrawBuffer{value: bufferToFill}();
294328

295329
emit BufferFilled(IS_NATIVE, bufferToFill);
296330
}

contracts/Errors/Errors.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ error InvalidZeroOutput();
107107
error NotEnoughBalance(uint256 currentBalance, uint256 calculatedFees);
108108

109109
/// @dev error when source chain is not expected
110-
error InvalidSourceChain(uint64 expectedCCIPChainSelector, uint64 actualCCIPChainSelector);
110+
error InvalidSourceChain(
111+
uint64 expectedCCIPChainSelector,
112+
uint64 actualCCIPChainSelector
113+
);
111114

112115
/// @dev Error when an unauthorized address tries to call the bridge function on the L2
113116
error UnauthorizedBridgeSweeper();
@@ -168,3 +171,6 @@ error InvalidStrategy();
168171

169172
/// @dev Error when strategy already set and hold non zero token balance
170173
error NonZeroUnderlyingStrategyExist();
174+
175+
/// @dev Error when caller tried to claim queued withdrawal when not filled
176+
error QueuedWithdrawalNotFilled();

0 commit comments

Comments
 (0)