@@ -25,7 +25,7 @@ contract FeeHandlerWithOracle is IFeeHandler, AccessControl, ERC20Safe {
2525
2626 struct OracleMessageType {
2727 // Base Effective Rate - effective rate between base currencies of source and dest networks (eg. MATIC/ETH)
28- uint256 ber;
28+ uint256 ber;
2929 // Token Effective Rate - rate between base currency of destination network and token that is being trasferred (eg. MATIC/USDT)
3030 uint256 ter;
3131 uint256 dstGasPrice;
@@ -51,6 +51,18 @@ contract FeeHandlerWithOracle is IFeeHandler, AccessControl, ERC20Safe {
5151
5252 // Admin functions
5353
54+ /**
55+ @notice Removes admin role from {_msgSender()} and grants it to {newAdmin}.
56+ @notice Only callable by an address that currently has the admin role.
57+ @param newAdmin Address that admin role will be granted to.
58+ */
59+ function renounceAdmin (address newAdmin ) external onlyAdmin {
60+ address sender = _msgSender ();
61+ require (sender != newAdmin, 'Cannot renounce oneself ' );
62+ grantRole (DEFAULT_ADMIN_ROLE, newAdmin);
63+ renounceRole (DEFAULT_ADMIN_ROLE, sender);
64+ }
65+
5466 /**
5567 @notice Sets the fee oracle address for signature verification.
5668 @param oracleAddress Fee oracle address.
@@ -101,7 +113,7 @@ contract FeeHandlerWithOracle is IFeeHandler, AccessControl, ERC20Safe {
101113 }
102114
103115 function _calculateFee (address sender , uint8 fromDomainID , uint8 destinationDomainID , bytes32 resourceID , bytes calldata depositData , bytes calldata feeData ) internal view returns (uint256 fee , address tokenAddress ) {
104- /**
116+ /**
105117 Message:
106118 ber * 10^18: uint256
107119 ter * 10^18: uint256
@@ -120,7 +132,7 @@ contract FeeHandlerWithOracle is IFeeHandler, AccessControl, ERC20Safe {
120132
121133 amount: uint256
122134 total: 321
123- */
135+ */
124136
125137 require (feeData.length == 321 , "Incorrect feeData length " );
126138
@@ -132,9 +144,9 @@ contract FeeHandlerWithOracle is IFeeHandler, AccessControl, ERC20Safe {
132144
133145 OracleMessageType memory oracleMessage = abi.decode (feeDataDecoded.message, (OracleMessageType));
134146 require (block .timestamp <= oracleMessage.expiresAt, "Obsolete oracle data " );
135- require ((oracleMessage.fromDomainID == fromDomainID)
136- && (oracleMessage.toDomainID == destinationDomainID)
137- && (oracleMessage.resourceID == resourceID),
147+ require ((oracleMessage.fromDomainID == fromDomainID)
148+ && (oracleMessage.toDomainID == destinationDomainID)
149+ && (oracleMessage.resourceID == resourceID),
138150 "Incorrect deposit params "
139151 );
140152
@@ -144,12 +156,12 @@ contract FeeHandlerWithOracle is IFeeHandler, AccessControl, ERC20Safe {
144156
145157 address tokenHandler = IBridge (_bridgeAddress)._resourceIDToHandlerAddress (resourceID);
146158 address tokenAddress = IERCHandler (tokenHandler)._resourceIDToTokenContractAddress (resourceID);
147-
159+
148160 // txCost = dstGasPrice * _gasUsed * Token Effective Rate (rate of dest base currency to token)
149161 uint256 txCost = oracleMessage.dstGasPrice * _gasUsed * oracleMessage.ter / 1e18 ;
150162
151163 fee = feeDataDecoded.amount * _feePercent / 1e4 ; // 100 for percent and 100 to avoid precision loss
152-
164+
153165 if (fee < txCost) {
154166 fee = txCost;
155167 }
0 commit comments