diff --git a/packages/contracts/contracts/tokens/FungibleTokenWrapper.sol b/packages/contracts/contracts/tokens/FungibleTokenWrapper.sol index c1b3065bf..1de092c6e 100644 --- a/packages/contracts/contracts/tokens/FungibleTokenWrapper.sol +++ b/packages/contracts/contracts/tokens/FungibleTokenWrapper.sol @@ -32,6 +32,12 @@ contract FungibleTokenWrapper is uint256 public wrappingLimit; event HandlerUpdated(address _handler); + event NativeAllowed(bool _isNativeAllowed); + event TokenAdded(address _tokenAddress); + event TokenRemoved(address _tokenAddress); + event FeeUpdated(uint16 _feePercentage); + event FeeRecipientUpdated(address _feeRecipient); + event WrappingLimitUpdated(uint256 _limit); /// @notice FungibleTokenWrapper constructor /// @param _name The name of the ERC20 TokenWrapper @@ -82,6 +88,7 @@ contract FungibleTokenWrapper is /// @notice Only the handler can call this function function setNativeAllowed(bool _isNativeAllowed) public onlyHandler { isNativeAllowed = _isNativeAllowed; + emit NativeAllowed(_isNativeAllowed); } /// @notice Adds a token at `_tokenAddress` to the FungibleTokenWrapper's wrapping list @@ -100,6 +107,7 @@ contract FungibleTokenWrapper is historicallyValid[_tokenAddress] = true; } valid[_tokenAddress] = true; + emit TokenAdded(_tokenAddress); } /// @notice Removes a token at `_tokenAddress` from the FungibleTokenWrapper's wrapping list @@ -121,6 +129,7 @@ contract FungibleTokenWrapper is require(index < tokens.length, "FungibleTokenWrapper: Token not found"); valid[_tokenAddress] = false; removeTokenAtIndex(index); + emit TokenRemoved(_tokenAddress); } /// @notice Sets a new `_feePercentage` for the FungibleTokenWrapper @@ -133,6 +142,7 @@ contract FungibleTokenWrapper is ) external override onlyHandler onlyIncrementingByOne(_nonce) { require(_feePercentage < 10_000, "FungibleTokenWrapper: Invalid fee percentage"); feePercentage = _feePercentage; + emit FeeUpdated(_feePercentage); } /// @notice Sets a new `_feeRecipient` for the FungibleTokenWrapper @@ -148,6 +158,7 @@ contract FungibleTokenWrapper is "FungibleTokenWrapper: Fee Recipient cannot be zero address" ); feeRecipient = _feeRecipient; + emit FeeRecipientUpdated(_feeRecipient); } /// @notice Removes a token at `_index` from the FungibleTokenWrapper's wrapping list @@ -162,6 +173,7 @@ contract FungibleTokenWrapper is /// @notice Only the handler can call this function function updateLimit(uint256 _limit) public onlyHandler { wrappingLimit = _limit; + emit WrappingLimitUpdated(_limit); } /// @notice Gets the current fee percentage diff --git a/packages/contracts/contracts/tokens/TokenWrapper.sol b/packages/contracts/contracts/tokens/TokenWrapper.sol index ed8f6f772..09885fa69 100644 --- a/packages/contracts/contracts/tokens/TokenWrapper.sol +++ b/packages/contracts/contracts/tokens/TokenWrapper.sol @@ -20,6 +20,21 @@ abstract contract TokenWrapper is ERC20PresetMinterPauser, ITokenWrapper, Reentr uint16 public feePercentage; address payable public feeRecipient; + event Wrapping( + address indexed sender, + address indexed recipient, + address indexed tokenAddress, + uint256 wrappingFee, + uint256 afterFeeAmount + ); + + event Unwrapping( + address indexed sender, + address indexed recipient, + address indexed tokenAddress, + uint256 amount + ); + /// @notice TokenWrapper constructor /// @param _name The name of the ERC20 /// @param _symbol The symbol of the ERC20 @@ -162,6 +177,9 @@ abstract contract TokenWrapper is ERC20PresetMinterPauser, ITokenWrapper, Reentr } // mint the wrapped token for the recipient _mint(recipient, leftover); + + // Emit the wrapping event + emit Wrapping(sender, recipient, tokenAddress, costToWrap, leftover); } function _unwrapAndSendTo( @@ -180,6 +198,9 @@ abstract contract TokenWrapper is ERC20PresetMinterPauser, ITokenWrapper, Reentr // transfer ERC20 liquidity from the token wrapper to the sender IERC20(tokenAddress).safeTransfer(recipient, amount); } + + // Emit the unwrapping event + emit Unwrapping(sender, recipient, tokenAddress, amount); } /// @dev this function is defined in a child contract