false
false

Contract Address Details

0xa21ac1436f7fcD43008c9473A78433339E222FcA

Contract Name
FeePool
Creator
0xf4abd1–e0cb1f at 0x410b37–90eb01
Balance
0 SX
Tokens
Fetching tokens...
Transactions
3 Transactions
Transfers
178,273 Transfers
Gas Used
152,202
Last Balance Update
6214108
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
FeePool




Optimization enabled
false
Compiler version
v0.8.9+commit.e5eed63a




EVM Version
default




Verified at
2022-08-31T17:30:37.584419Z

Constructor Arguments

0000000000000000000000001d730f26293fc2f3495a8acb199b8726c24a6cde00000000000000000000000099dd65a547981f662ef8ba0893bed966d3d78c9a

Arg [0] (address) : <a href=/address/0x1d730f26293fc2f3495a8acb199b8726c24a6cde>0x1d730f26293fc2f3495a8acb199b8726c24a6cde</a>
Arg [1] (address) : <a href=/address/0x99dd65a547981f662ef8ba0893bed966d3d78c9a>0x99dd65a547981f662ef8ba0893bed966d3d78c9a</a>

              

Contract source code

// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.9;
pragma abicoder v2;

abstract contract IFeePool {
    function withdrawFee(
        address user,
        address baseToken,
        uint256 amount
    ) external virtual;

    function emergencyWithdraw(address token, uint256 amount) external virtual;
}

abstract contract IStaking {
    function finalizeEpoch() external virtual;

    function claimRewards(address staker, address token) external virtual;

    function stake(uint256 amount) external virtual;

    function metaStake(
        address staker,
        uint256 amount,
        uint256 nonce,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external virtual;

    function stakeBehalf(address staker, uint256 amount) external virtual;

    function unstake(uint256 amount) external virtual;

    function metaUnstake(
        address staker,
        uint256 amount,
        uint256 nonce,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external virtual;

    function withdraw(uint256 amount) external virtual;

    function metaWithdraw(
        address staker,
        uint256 amount,
        uint256 nonce,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external virtual;

    function getStakeNonces(address staker)
        public
        view
        virtual
        returns (uint256);

    function getUnstakeNonces(address staker)
        public
        view
        virtual
        returns (uint256);

    function getWithdrawNonces(address staker)
        public
        view
        virtual
        returns (uint256);

    function getPreviousEpochRewards(address token)
        public
        view
        virtual
        returns (uint256);

    function getPreviousEpochClaimedRewards(address token)
        public
        view
        virtual
        returns (uint256);

    function getEpoch() public view virtual returns (uint256);

    function getStakedAmounts(address staker)
        public
        view
        virtual
        returns (uint256);

    function getTotalStakedAmount() public view virtual returns (uint256);

    function getRewardsClaimed(
        uint256 epoch,
        address token,
        address staker
    ) public view virtual returns (bool);

    function getPendingWithdrawAmounts(address staker)
        public
        view
        virtual
        returns (uint256);

    function getLatestUnstakeTime(address staker)
        public
        view
        virtual
        returns (uint256);

    function canFinalizeEpoch() public view virtual returns (bool);

    function getStartEpochTime() public view virtual returns (uint256);
}

// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(
        bytes32 indexed role,
        bytes32 indexed previousAdminRole,
        bytes32 indexed newAdminRole
    );

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(
        bytes32 indexed role,
        address indexed account,
        address indexed sender
    );

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(
        bytes32 indexed role,
        address indexed account,
        address indexed sender
    );

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account)
        external
        view
        returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length)
        internal
        pure
        returns (string memory)
    {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override
        returns (bool)
    {
        return interfaceId == type(IERC165).interfaceId;
    }
}

abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override
        returns (bool)
    {
        return
            interfaceId == type(IAccessControl).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account)
        public
        view
        virtual
        override
        returns (bool)
    {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role)
        public
        view
        virtual
        override
        returns (bytes32)
    {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account)
        public
        virtual
        override
        onlyRole(getRoleAdmin(role))
    {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account)
        public
        virtual
        override
        onlyRole(getRoleAdmin(role))
    {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account)
        public
        virtual
        override
    {
        require(
            account == _msgSender(),
            "AccessControl: can only renounce roles for self"
        );

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

contract IPermissions is AccessControl {
    bytes32 public constant OUTCOME_REPORTER_ROLE =
        keccak256("OUTCOME_REPORTER_ROLE");
    bytes32 public constant SYSTEM_PARAMETERS_ROLE =
        keccak256("SYSTEM_PARAMETERS_ROLE");
}

// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender)
        external
        view
        returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(
            address(this).balance >= amount,
            "Address: insufficient balance"
        );

        (bool success, ) = recipient.call{value: amount}("");
        require(
            success,
            "Address: unable to send value, recipient may have reverted"
        );
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data)
        internal
        returns (bytes memory)
    {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return
            functionCallWithValue(
                target,
                data,
                value,
                "Address: low-level call with value failed"
            );
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(
            address(this).balance >= value,
            "Address: insufficient balance for call"
        );
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(
            data
        );
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data)
        internal
        view
        returns (bytes memory)
    {
        return
            functionStaticCall(
                target,
                data,
                "Address: low-level static call failed"
            );
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data)
        internal
        returns (bytes memory)
    {
        return
            functionDelegateCall(
                target,
                data,
                "Address: low-level delegate call failed"
            );
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.transfer.selector, to, value)
        );
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
        );
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.approve.selector, spender, value)
        );
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(
                token.approve.selector,
                spender,
                newAllowance
            )
        );
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(
                oldAllowance >= value,
                "SafeERC20: decreased allowance below zero"
            );
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(
                token,
                abi.encodeWithSelector(
                    token.approve.selector,
                    spender,
                    newAllowance
                )
            );
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(
            data,
            "SafeERC20: low-level call failed"
        );
        if (returndata.length > 0) {
            // Return data is optional
            require(
                abi.decode(returndata, (bool)),
                "SafeERC20: ERC20 operation did not succeed"
            );
        }
    }
}

contract FeePool is IFeePool {
    using SafeERC20 for IERC20;

    IStaking private staking;
    IPermissions private permissions;

    constructor(IStaking _staking, IPermissions _permissions) {
        staking = _staking;
        permissions = _permissions;
    }

    /// @notice Throws if the caller is not the Staking Contract
    modifier onlyStaking() {
        require(msg.sender == address(staking), "ONLY_STAKING_CONTRACT");
        _;
    }

    /// @notice Throws if the user is not a default admin
    modifier onlyDefaultAdminRole() {
        require(
            permissions.hasRole(permissions.DEFAULT_ADMIN_ROLE(), msg.sender),
            "CALLER_IS_NOT_DEFAULT_ADMIN"
        );
        _;
    }

    function withdrawFee(
        address user,
        address baseToken,
        uint256 amount
    ) external override onlyStaking {
        IERC20(baseToken).safeTransfer(user, amount);
    }

    function emergencyWithdraw(address token, uint256 amount)
        external
        override
        onlyDefaultAdminRole
    {
        IERC20(token).safeTransfer(msg.sender, amount);
    }
}
        

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_staking","internalType":"contract IStaking"},{"type":"address","name":"_permissions","internalType":"contract IPermissions"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"emergencyWithdraw","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawFee","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"address","name":"baseToken","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]}]
              

Contract Creation Code

0x60806040523480156200001157600080fd5b5060405162000df238038062000df2833981810160405281019062000037919062000183565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050620001ca565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000f282620000c5565b9050919050565b60006200010682620000e5565b9050919050565b6200011881620000f9565b81146200012457600080fd5b50565b60008151905062000138816200010d565b92915050565b60006200014b82620000e5565b9050919050565b6200015d816200013e565b81146200016957600080fd5b50565b6000815190506200017d8162000152565b92915050565b600080604083850312156200019d576200019c620000c0565b5b6000620001ad8582860162000127565b9250506020620001c0858286016200016c565b9150509250929050565b610c1880620001da6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80631095b6d71461003b57806395ccea6714610057575b600080fd5b61005560048036038101906100509190610687565b610073565b005b610071600480360381019061006c91906106da565b610131565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f890610777565b60405180910390fd5b61012c83828473ffffffffffffffffffffffffffffffffffffffff166102eb9092919063ffffffff16565b505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166391d14854600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a217fddf6040518163ffffffff1660e01b815260040160206040518083038186803b1580156101d757600080fd5b505afa1580156101eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020f91906107cd565b336040518363ffffffff1660e01b815260040161022d929190610818565b60206040518083038186803b15801561024557600080fd5b505afa158015610259573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027d9190610879565b6102bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102b3906108f2565b60405180910390fd5b6102e733828473ffffffffffffffffffffffffffffffffffffffff166102eb9092919063ffffffff16565b5050565b61036c8363a9059cbb60e01b848460405160240161030a929190610921565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610371565b505050565b60006103d3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166104389092919063ffffffff16565b905060008151111561043357808060200190518101906103f39190610879565b610432576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610429906109bc565b60405180910390fd5b5b505050565b60606104478484600085610450565b90509392505050565b606082471015610495576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048c90610a4e565b60405180910390fd5b61049e85610564565b6104dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d490610aba565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516105069190610b54565b60006040518083038185875af1925050503d8060008114610543576040519150601f19603f3d011682016040523d82523d6000602084013e610548565b606091505b5091509150610558828286610587565b92505050949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60608315610597578290506105e7565b6000835111156105aa5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105de9190610bc0565b60405180910390fd5b9392505050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061061e826105f3565b9050919050565b61062e81610613565b811461063957600080fd5b50565b60008135905061064b81610625565b92915050565b6000819050919050565b61066481610651565b811461066f57600080fd5b50565b6000813590506106818161065b565b92915050565b6000806000606084860312156106a05761069f6105ee565b5b60006106ae8682870161063c565b93505060206106bf8682870161063c565b92505060406106d086828701610672565b9150509250925092565b600080604083850312156106f1576106f06105ee565b5b60006106ff8582860161063c565b925050602061071085828601610672565b9150509250929050565b600082825260208201905092915050565b7f4f4e4c595f5354414b494e475f434f4e54524143540000000000000000000000600082015250565b600061076160158361071a565b915061076c8261072b565b602082019050919050565b6000602082019050818103600083015261079081610754565b9050919050565b6000819050919050565b6107aa81610797565b81146107b557600080fd5b50565b6000815190506107c7816107a1565b92915050565b6000602082840312156107e3576107e26105ee565b5b60006107f1848285016107b8565b91505092915050565b61080381610797565b82525050565b61081281610613565b82525050565b600060408201905061082d60008301856107fa565b61083a6020830184610809565b9392505050565b60008115159050919050565b61085681610841565b811461086157600080fd5b50565b6000815190506108738161084d565b92915050565b60006020828403121561088f5761088e6105ee565b5b600061089d84828501610864565b91505092915050565b7f43414c4c45525f49535f4e4f545f44454641554c545f41444d494e0000000000600082015250565b60006108dc601b8361071a565b91506108e7826108a6565b602082019050919050565b6000602082019050818103600083015261090b816108cf565b9050919050565b61091b81610651565b82525050565b60006040820190506109366000830185610809565b6109436020830184610912565b9392505050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b60006109a6602a8361071a565b91506109b18261094a565b604082019050919050565b600060208201905081810360008301526109d581610999565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000610a3860268361071a565b9150610a43826109dc565b604082019050919050565b60006020820190508181036000830152610a6781610a2b565b9050919050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000610aa4601d8361071a565b9150610aaf82610a6e565b602082019050919050565b60006020820190508181036000830152610ad381610a97565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015610b0e578082015181840152602081019050610af3565b83811115610b1d576000848401525b50505050565b6000610b2e82610ada565b610b388185610ae5565b9350610b48818560208601610af0565b80840191505092915050565b6000610b608284610b23565b915081905092915050565b600081519050919050565b6000601f19601f8301169050919050565b6000610b9282610b6b565b610b9c818561071a565b9350610bac818560208601610af0565b610bb581610b76565b840191505092915050565b60006020820190508181036000830152610bda8184610b87565b90509291505056fea264697066735822122014d9e22269107421188c073a87678ef5b3a37f19c4f17d30c6a7bdea0da7ebc164736f6c634300080900330000000000000000000000001d730f26293fc2f3495a8acb199b8726c24a6cde00000000000000000000000099dd65a547981f662ef8ba0893bed966d3d78c9a

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100365760003560e01c80631095b6d71461003b57806395ccea6714610057575b600080fd5b61005560048036038101906100509190610687565b610073565b005b610071600480360381019061006c91906106da565b610131565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f890610777565b60405180910390fd5b61012c83828473ffffffffffffffffffffffffffffffffffffffff166102eb9092919063ffffffff16565b505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166391d14854600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a217fddf6040518163ffffffff1660e01b815260040160206040518083038186803b1580156101d757600080fd5b505afa1580156101eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020f91906107cd565b336040518363ffffffff1660e01b815260040161022d929190610818565b60206040518083038186803b15801561024557600080fd5b505afa158015610259573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027d9190610879565b6102bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102b3906108f2565b60405180910390fd5b6102e733828473ffffffffffffffffffffffffffffffffffffffff166102eb9092919063ffffffff16565b5050565b61036c8363a9059cbb60e01b848460405160240161030a929190610921565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610371565b505050565b60006103d3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166104389092919063ffffffff16565b905060008151111561043357808060200190518101906103f39190610879565b610432576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610429906109bc565b60405180910390fd5b5b505050565b60606104478484600085610450565b90509392505050565b606082471015610495576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048c90610a4e565b60405180910390fd5b61049e85610564565b6104dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d490610aba565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516105069190610b54565b60006040518083038185875af1925050503d8060008114610543576040519150601f19603f3d011682016040523d82523d6000602084013e610548565b606091505b5091509150610558828286610587565b92505050949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60608315610597578290506105e7565b6000835111156105aa5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105de9190610bc0565b60405180910390fd5b9392505050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061061e826105f3565b9050919050565b61062e81610613565b811461063957600080fd5b50565b60008135905061064b81610625565b92915050565b6000819050919050565b61066481610651565b811461066f57600080fd5b50565b6000813590506106818161065b565b92915050565b6000806000606084860312156106a05761069f6105ee565b5b60006106ae8682870161063c565b93505060206106bf8682870161063c565b92505060406106d086828701610672565b9150509250925092565b600080604083850312156106f1576106f06105ee565b5b60006106ff8582860161063c565b925050602061071085828601610672565b9150509250929050565b600082825260208201905092915050565b7f4f4e4c595f5354414b494e475f434f4e54524143540000000000000000000000600082015250565b600061076160158361071a565b915061076c8261072b565b602082019050919050565b6000602082019050818103600083015261079081610754565b9050919050565b6000819050919050565b6107aa81610797565b81146107b557600080fd5b50565b6000815190506107c7816107a1565b92915050565b6000602082840312156107e3576107e26105ee565b5b60006107f1848285016107b8565b91505092915050565b61080381610797565b82525050565b61081281610613565b82525050565b600060408201905061082d60008301856107fa565b61083a6020830184610809565b9392505050565b60008115159050919050565b61085681610841565b811461086157600080fd5b50565b6000815190506108738161084d565b92915050565b60006020828403121561088f5761088e6105ee565b5b600061089d84828501610864565b91505092915050565b7f43414c4c45525f49535f4e4f545f44454641554c545f41444d494e0000000000600082015250565b60006108dc601b8361071a565b91506108e7826108a6565b602082019050919050565b6000602082019050818103600083015261090b816108cf565b9050919050565b61091b81610651565b82525050565b60006040820190506109366000830185610809565b6109436020830184610912565b9392505050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b60006109a6602a8361071a565b91506109b18261094a565b604082019050919050565b600060208201905081810360008301526109d581610999565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000610a3860268361071a565b9150610a43826109dc565b604082019050919050565b60006020820190508181036000830152610a6781610a2b565b9050919050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000610aa4601d8361071a565b9150610aaf82610a6e565b602082019050919050565b60006020820190508181036000830152610ad381610a97565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015610b0e578082015181840152602081019050610af3565b83811115610b1d576000848401525b50505050565b6000610b2e82610ada565b610b388185610ae5565b9350610b48818560208601610af0565b80840191505092915050565b6000610b608284610b23565b915081905092915050565b600081519050919050565b6000601f19601f8301169050919050565b6000610b9282610b6b565b610b9c818561071a565b9350610bac818560208601610af0565b610bb581610b76565b840191505092915050565b60006020820190508181036000830152610bda8184610b87565b90509291505056fea264697066735822122014d9e22269107421188c073a87678ef5b3a37f19c4f17d30c6a7bdea0da7ebc164736f6c63430008090033