Skip to content

Commit 6b4ea16

Browse files
authored
evm: Emit events when updating inbound and outbound limits (#546)
* Add `OutboundTransferLimitUpdated` and `InboundTransferLimitUpdated` events * Emit these events when `_setOutboundLimit` and `_setInboundLimit` are called respectively
1 parent 8d9e6ab commit 6b4ea16

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

evm/src/interfaces/IRateLimiterEvents.sol

+15
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,19 @@ interface IRateLimiterEvents {
2525
event OutboundTransferRateLimited(
2626
address indexed sender, uint64 sequence, uint256 amount, uint256 currentCapacity
2727
);
28+
29+
/// @notice Emitted when the outbound transfer limit is updated.
30+
/// @dev Topic0
31+
/// 0x7e3b0fc388be9d36273f66210aed83be975df3a9adfffa4c734033f498f362cd.
32+
/// @param oldLimit The old outbound limit.
33+
/// @param newLimit The new outbound limit.
34+
event OutboundTransferLimitUpdated(uint256 oldLimit, uint256 newLimit);
35+
36+
/// @notice Emitted when the inbound transfer limit is updated.
37+
/// @dev Topic0
38+
/// 0x739ed886fd81a3ddc9f4b327ab69152e513cd45b26fda0c73660eaca8e119301.
39+
/// @param chainId The chain ID the limit is set for.
40+
/// @param oldLimit The old inbound limit.
41+
/// @param newLimit The new inbound limit.
42+
event InboundTransferLimitUpdated(uint16 indexed chainId, uint256 oldLimit, uint256 newLimit);
2843
}

evm/src/libraries/RateLimiter.sol

+12-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
9696
function _setOutboundLimit(
9797
TrimmedAmount limit
9898
) internal virtual {
99-
_setLimit(limit, _getOutboundLimitParamsStorage());
99+
RateLimitParams storage rateLimitParams = _getOutboundLimitParamsStorage();
100+
TrimmedAmount oldLimit = rateLimitParams.limit;
101+
uint8 decimals = tokenDecimals();
102+
_setLimit(limit, rateLimitParams);
103+
emit OutboundTransferLimitUpdated(oldLimit.untrim(decimals), limit.untrim(decimals));
100104
}
101105

102106
function getOutboundLimitParams() public pure virtual returns (RateLimitParams memory) {
@@ -116,7 +120,13 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
116120
}
117121

118122
function _setInboundLimit(TrimmedAmount limit, uint16 chainId_) internal virtual {
119-
_setLimit(limit, _getInboundLimitParamsStorage()[chainId_]);
123+
RateLimitParams storage rateLimitParams = _getInboundLimitParamsStorage()[chainId_];
124+
TrimmedAmount oldLimit = rateLimitParams.limit;
125+
uint8 decimals = tokenDecimals();
126+
_setLimit(limit, rateLimitParams);
127+
emit InboundTransferLimitUpdated(
128+
chainId_, oldLimit.untrim(decimals), limit.untrim(decimals)
129+
);
120130
}
121131

122132
function getInboundLimitParams(

0 commit comments

Comments
 (0)