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

evm: Emit events when updating inbound and outbound limits #546

Merged
merged 9 commits into from
Nov 7, 2024
15 changes: 15 additions & 0 deletions evm/src/interfaces/IRateLimiterEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,19 @@ interface IRateLimiterEvents {
event OutboundTransferRateLimited(
address indexed sender, uint64 sequence, uint256 amount, uint256 currentCapacity
);

/// @notice Emitted when the outbound transfer limit is updated.
/// @dev Topic0
/// 0x7e3b0fc388be9d36273f66210aed83be975df3a9adfffa4c734033f498f362cd.
/// @param oldLimit The old outbound limit.
/// @param newLimit The new outbound limit.
event OutboundTransferLimitUpdated(uint256 oldLimit, uint256 newLimit);

/// @notice Emitted when the inbound transfer limit is updated.
/// @dev Topic0
/// 0x739ed886fd81a3ddc9f4b327ab69152e513cd45b26fda0c73660eaca8e119301.
/// @param chainId The chain ID the limit is set for.
/// @param oldLimit The old inbound limit.
/// @param newLimit The new inbound limit.
event InboundTransferLimitUpdated(uint16 indexed chainId, uint256 oldLimit, uint256 newLimit);
nik-suri marked this conversation as resolved.
Show resolved Hide resolved
}
14 changes: 12 additions & 2 deletions evm/src/libraries/RateLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
function _setOutboundLimit(
TrimmedAmount limit
) internal virtual {
_setLimit(limit, _getOutboundLimitParamsStorage());
RateLimitParams storage rateLimitParams = _getOutboundLimitParamsStorage();
TrimmedAmount oldLimit = rateLimitParams.limit;
uint8 decimals = tokenDecimals();
_setLimit(limit, rateLimitParams);
emit OutboundTransferLimitUpdated(oldLimit.untrim(decimals), limit.untrim(decimals));
}

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

function _setInboundLimit(TrimmedAmount limit, uint16 chainId_) internal virtual {
_setLimit(limit, _getInboundLimitParamsStorage()[chainId_]);
RateLimitParams storage rateLimitParams = _getInboundLimitParamsStorage()[chainId_];
TrimmedAmount oldLimit = rateLimitParams.limit;
uint8 decimals = tokenDecimals();
_setLimit(limit, rateLimitParams);
emit InboundTransferLimitUpdated(
chainId_, oldLimit.untrim(decimals), limit.untrim(decimals)
);
}

function getInboundLimitParams(
Expand Down
Loading