Skip to content

Commit

Permalink
refactor: drop UniversalTokenLib in AdminV2
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Nov 11, 2024
1 parent 87723a5 commit 1b797f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
18 changes: 13 additions & 5 deletions packages/contracts-rfq/contracts/AdminV2.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

Check warning

Code scanning / Slither

Different pragma directives are used Warning

3 different versions of Solidity are used:
- Version constraint ^0.8.20 is used by:
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
-^0.8.20
- Version constraint 0.8.24 is used by:
-0.8.24
-0.8.24
- Version constraint ^0.8.4 is used by:
-^0.8.4
-^0.8.4
-^0.8.4
-^0.8.4
-^0.8.4
-^0.8.4
-^0.8.4
-^0.8.4
-^0.8.4
-^0.8.4

Check warning

Code scanning / Slither

Incorrect versions of Solidity Warning

Version constraint ^0.8.20 contains known severe issues (https://solidity.readthedocs.io/en/latest/bugs.html)
- VerbatimInvalidDeduplication
- FullInlinerNonExpressionSplitArgumentEvaluationOrder
- MissingSideEffectsOnSelectorAccess.
It is used by:
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20
- ^0.8.20

import {AccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol";

import {UniversalTokenLib} from "./libs/UniversalToken.sol";
import {IAdminV2} from "./interfaces/IAdminV2.sol";
import {IAdminV2Errors} from "./interfaces/IAdminV2Errors.sol";

import {AccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol";
import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
using UniversalTokenLib for address;
using SafeERC20 for IERC20;

/// @notice Address reserved for native gas token (ETH on Ethereum and most L2s, AVAX on Avalanche, etc)
address public constant NATIVE_GAS_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant CANCELER_ROLE = keccak256("CANCELER_ROLE");
Expand Down Expand Up @@ -54,7 +58,11 @@ contract AdminV2 is AccessControlEnumerable, IAdminV2, IAdminV2Errors {
if (feeAmount == 0) return; // skip if no accumulated fees

protocolFees[token] = 0;
token.universalTransfer(recipient, feeAmount);
if (token == NATIVE_GAS_TOKEN) {
Address.sendValue(payable(recipient), feeAmount);
} else {
IERC20(token).safeTransfer(recipient, feeAmount);
}
emit FeesSwept(token, recipient, feeAmount);
}

Expand Down
9 changes: 3 additions & 6 deletions packages/contracts-rfq/contracts/FastBridgeV2.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

import {BridgeTransactionV2Lib} from "./libs/BridgeTransactionV2.sol";

import {AdminV2} from "./AdminV2.sol";
Expand All @@ -14,14 +11,14 @@ import {IZapRecipient} from "./interfaces/IZapRecipient.sol";

import {MulticallTarget} from "./utils/MulticallTarget.sol";

import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

/// @notice FastBridgeV2 is a contract for bridging tokens across chains.
contract FastBridgeV2 is AdminV2, MulticallTarget, IFastBridgeV2, IFastBridgeV2Errors {
using BridgeTransactionV2Lib for bytes;
using SafeERC20 for IERC20;

/// @notice Address reserved for native gas token (ETH on Ethereum and most L2s, AVAX on Avalanche, etc)
address public constant NATIVE_GAS_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

/// @notice Dispute period for relayed transactions
uint256 public constant DISPUTE_PERIOD = 30 minutes;

Expand Down

0 comments on commit 1b797f6

Please sign in to comment.