From 85b004b953a54fb4cc6afecad801d92fd00f1cff Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Mon, 11 Nov 2024 18:25:03 +0000 Subject: [PATCH] refactor: event before external call, docs --- packages/contracts-rfq/contracts/AdminV2.sol | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/contracts-rfq/contracts/AdminV2.sol b/packages/contracts-rfq/contracts/AdminV2.sol index 25ed352130..3737afd8bb 100644 --- a/packages/contracts-rfq/contracts/AdminV2.sol +++ b/packages/contracts-rfq/contracts/AdminV2.sol @@ -42,10 +42,16 @@ contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors { _setCancelDelay(DEFAULT_CANCEL_DELAY); } + /// @notice Allows the contract governor to set the cancel delay. The cancel delay is the time after the transaction + /// deadline after which it can be permissionlessly cancelled, if it hasn't been proven by any of the Relayers. function setCancelDelay(uint256 newCancelDelay) external onlyRole(GOVERNOR_ROLE) { _setCancelDelay(newCancelDelay); } + /// @notice Allows the contract governor to set the protocol fee rate. The protocol fee is taken from the origin + /// amount only for completed and claimed transactions. + /// @dev The protocol fee is abstracted away from the relayers, they always operate using the amounts after fees: + /// what they see as the origin amount emitted in the log is what they get credited with. function setProtocolFeeRate(uint256 newFeeRate) external onlyRole(GOVERNOR_ROLE) { if (newFeeRate > FEE_RATE_MAX) revert FeeRateAboveMax(); uint256 oldFeeRate = protocolFeeRate; @@ -53,17 +59,19 @@ contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors { emit FeeRateUpdated(oldFeeRate, newFeeRate); } + /// @notice Allows the contract governor to sweep the accumulated protocol fees in the contract. function sweepProtocolFees(address token, address recipient) external onlyRole(GOVERNOR_ROLE) { uint256 feeAmount = protocolFees[token]; if (feeAmount == 0) return; // skip if no accumulated fees protocolFees[token] = 0; + emit FeesSwept(token, recipient, feeAmount); + /// Sweep the fees as the last transaction action if (token == NATIVE_GAS_TOKEN) { Address.sendValue(payable(recipient), feeAmount); } else { IERC20(token).safeTransfer(recipient, feeAmount); } - emit FeesSwept(token, recipient, feeAmount); } /// @notice Internal function to set the cancel delay. Security checks are performed outside of this function.