Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- GUNFinanceTreasury
- Optimization enabled
- true
- Compiler version
- v0.8.9+commit.e5eed63a
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2025-02-25T16:44:59.914629Z
Contract source code
// Sources flattened with hardhat v2.22.17 https://hardhat.org // SPDX-License-Identifier: MIT // File openzeppelin-contracts-upgradeable/access/IAccessControlUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @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; } // File openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // File openzeppelin-contracts-upgradeable/utils/ContextUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // File openzeppelin-contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @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 IERC165Upgradeable { /** * @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); } // File openzeppelin-contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @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 ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; } // File openzeppelin-contracts-upgradeable/utils/StringsUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { 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); } } // File openzeppelin-contracts-upgradeable/access/AccessControlUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/AccessControl.sol) pragma solidity ^0.8.0; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } 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, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @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 { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.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 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()); } } uint256[49] private __gap; } // File openzeppelin-contracts-upgradeable/security/PausableUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (security/Pausable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } // File contracts/PlatformSettings.sol // Original license: SPDX_License_Identifier: MIT pragma solidity ^0.8.0; /// @title A platform settings for OTG contracts /// @notice Admin can use this contract for granting and revoking roles, pause and unpause platform, set new wallets for fee receiving /// @dev This contract inherits 'Initializable', 'AccessControlUpgradeable', 'PausableUpgradeable' contracts form openzeppelin library contract PlatformSettings is Initializable, AccessControlUpgradeable, PausableUpgradeable{ bytes32 public constant SECONDARY_ADMIN_ROLE = keccak256("SECONDARY_ADMIN_ROLE"); bytes32 public constant BACKEND_ROLE = keccak256("BACKEND_ROLE"); uint256 public constant gunDecimals = 10**18; uint256 public constant PERCENT_DENOMINATOR = 100; // address of main admin address public initialAdmin; // address of financial wallet (withdraws GUNs from contract) address payable public financialWallet; // percentage that represents validator fee during decoding process uint256 public validatorFeePercentageForDecoding; // percentage that represents platform fee during decoding process uint256 public platformFeePercentageForDecoding; bytes32 public constant BRIDGE_ROLE = keccak256("BRIDGE_ROLE"); bytes32 public constant DECODER_ROLE = keccak256("DECODER_ROLE"); /// @notice this event is emitted when new financial wallet is set /// @param newWallet address of new financial wallet event ChangedFinancialWallet( address indexed newWallet ); error InvalidRole(address caller, bytes32 role); error IncorrectFeeDistribution(); error AlreadyHasRole(address account, bytes32 role); error AlreadyHasNotRole(address account, bytes32 role); /// @notice A disposable function for initializing contract /// @param _admin address of initial admin of contract /// @dev Grants caller with admin role /// @dev Also calls initializers of AccessControl and Pausable contracts. /// @dev Sets caller as an initialAdmin and financeWallet(wallet for receiving fees and royalties) /// @dev Sets initial fee percentage for decoding process function initialize( address _admin )public initializer{ __AccessControl_init(); __Pausable_init_unchained(); _setupRole(DEFAULT_ADMIN_ROLE, _admin); initialAdmin = _admin; financialWallet = payable(msg.sender); validatorFeePercentageForDecoding = 50; platformFeePercentageForDecoding = 50; } // *********************** MODIFIERS ********************************************* /// @notice verifies if message sender is an admin or secondary admin modifier onlyAdmin{ if(!(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(SECONDARY_ADMIN_ROLE,msg.sender))){ revert InvalidRole(msg.sender, SECONDARY_ADMIN_ROLE); } _; } // *********************** VIEW FUNCTIONS ********************************************* function version() public pure returns (uint32){ //version in format aaa.bbb.ccc => aaa*1E6+bbb*1E3+ccc; return uint32(2_001_011); } // *********************** FUNCTIONS ********************************************* /// @notice checks account for admin roles function isAdmin(address account) public view returns(bool){ return (hasRole(DEFAULT_ADMIN_ROLE, account)||hasRole(SECONDARY_ADMIN_ROLE, account)); } /// @notice checks account for backend role function isBackendRole(address account) public view returns(bool){ return hasRole(BACKEND_ROLE, account); } function isBridgeRole(address account) public view returns(bool){ return hasRole(BRIDGE_ROLE, account); } function isDecoderRole(address account) public view returns(bool){ return hasRole(DECODER_ROLE, account); } /// @notice checks account for admin roles or if platform is not paused function isAdminOrNotPaused(address caller) public view returns(bool){ return(!paused()||hasRole(DEFAULT_ADMIN_ROLE,caller)||hasRole(SECONDARY_ADMIN_ROLE,caller)); } /// TODO check if this function must exist /// @notice returns a number, that represents amount of fee, which validator will receive after decoding process function getValidatorFeeForDecoding(uint256 _price)public view returns(uint256){ if((platformFeePercentageForDecoding + validatorFeePercentageForDecoding)!=100){ revert IncorrectFeeDistribution(); } return (_price* gunDecimals * validatorFeePercentageForDecoding)/PERCENT_DENOMINATOR; } /// TODO check if this function must exist /// @notice returns a number, that represents amount of fee, which financialWallet will receive after decoding process function getPlatformFeeForDecoding(uint256 _price)public view returns(uint256){ if((platformFeePercentageForDecoding + validatorFeePercentageForDecoding)!=100){ revert IncorrectFeeDistribution(); } return (_price* gunDecimals * platformFeePercentageForDecoding)/PERCENT_DENOMINATOR; } /// @notice suspends most functions in contracts /// @dev Caller must be admin function pause() public onlyAdmin{ _pause(); } /// @notice restores most functions in contracts /// @dev Caller must be admin function unpause() public onlyAdmin{ _unpause(); } /// @notice sets new address as a payable financialWallet /// @dev caller must be admin, emits 'ChangedFinancialWallet' function setNewFinancialWallet(address _newWalletAddress) public onlyAdmin{ financialWallet = payable(_newWalletAddress); emit ChangedFinancialWallet(_newWalletAddress); } /// @notice granting secondary admin role to a specific address /// @param account address of a specific account function grantSecondaryAdminRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(SECONDARY_ADMIN_ROLE, account)){ revert AlreadyHasRole(account, SECONDARY_ADMIN_ROLE); } grantRole(SECONDARY_ADMIN_ROLE, account); } /// @notice revoking secondary admin role from a specific address /// @param account address of a specific account function revokeSecondaryAdminRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(SECONDARY_ADMIN_ROLE, account)){ revert AlreadyHasNotRole(account, SECONDARY_ADMIN_ROLE); } revokeRole(SECONDARY_ADMIN_ROLE, account); } /// @notice granting backend admin role from a specific address /// @param account address of a specific account function grantBackendRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(BACKEND_ROLE, account)){ revert AlreadyHasRole(account, BACKEND_ROLE); } grantRole(BACKEND_ROLE, account); } /// @notice revoking backend admin role from a specific address /// @param account address of a specific account function revokeBackendRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(BACKEND_ROLE, account)){ revert AlreadyHasNotRole(account, BACKEND_ROLE); } revokeRole(BACKEND_ROLE, account); } function grantBridgeRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(BRIDGE_ROLE, account)){ revert AlreadyHasRole(account, BRIDGE_ROLE); } grantRole(BRIDGE_ROLE, account); } function revokeBridgeRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(BRIDGE_ROLE, account)){ revert AlreadyHasNotRole(account, BRIDGE_ROLE); } revokeRole(BRIDGE_ROLE, account); } function grantDecoderRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(DECODER_ROLE, account)){ revert AlreadyHasRole(account, DECODER_ROLE); } grantRole(DECODER_ROLE, account); } function revokeDecoderRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(DECODER_ROLE, account)){ revert AlreadyHasNotRole(account, DECODER_ROLE); } revokeRole(DECODER_ROLE, account); } /// TODO maybe it will be better, to set validatorFeePercentageForDecoding and platformFeePercentageForDecoding with one function /// @notice Sets a number, that represents amount of fee, which validator will receive after /// @dev caller must be admin function setValidatorFeePercentageForDecoding(uint256 _percentage) public onlyAdmin{ validatorFeePercentageForDecoding = _percentage; } /// @notice Sets a number, that represents amount of fee, which financialWallet will receive after /// @dev caller must be admin function setPlatformFeePercentageForDecoding(uint256 _percentage) public onlyAdmin{ platformFeePercentageForDecoding = _percentage; } // TODO DEPRECATED, will be deleted sooner function getValidatorFeePercentageForDecoding() external view returns(uint256){ return(validatorFeePercentageForDecoding); } // TODO DEPRECATED, will be deleted sooner function getPlatformFeePercentageForDecoding() external view returns(uint256){ return(platformFeePercentageForDecoding); } } // File contracts/GUNFinanceTreasury.sol // Original license: SPDX_License_Identifier: MIT pragma solidity ^0.8.0; contract GUNFinanceTreasury is Initializable { address public platformSettingsContractAddress; event TransferFunds( address indexed from, address indexed to, uint256 amount ); error ContractsIsPaused(); error InvalidRole(address caller, bytes32 role); error InsufficientBalance(uint256 amount, uint256 balance); error UnsuccessfulPayment(address to, uint256 amount); error IncorrectDistribution(); function initialize( address _platformSettingsContractAddress ) public initializer { platformSettingsContractAddress = _platformSettingsContractAddress; } // *********************** MODIFIERS ********************************************* /// @notice verifies if switch "_paused" in PlatformSettings contract is off modifier whenNotPaused() { if (PlatformSettings(platformSettingsContractAddress).paused()) { revert ContractsIsPaused(); } _; } /// @notice verifies if message sender is an admin or secondary admin modifier onlyAdmin() { if ( !(PlatformSettings(platformSettingsContractAddress).hasRole( PlatformSettings(platformSettingsContractAddress) .DEFAULT_ADMIN_ROLE(), msg.sender ) || PlatformSettings(platformSettingsContractAddress).hasRole( PlatformSettings(platformSettingsContractAddress) .SECONDARY_ADMIN_ROLE(), msg.sender )) ) { revert InvalidRole( msg.sender, PlatformSettings(platformSettingsContractAddress) .SECONDARY_ADMIN_ROLE() ); } _; } // *********************** VIEW FUNCTIONS ********************************************* function version() public pure returns (uint32) { //version in format aaa.bbb.ccc => aaa*1E6+bbb*1E3+ccc; return uint32(2_001_011); } // *********************** FUNCTIONS ********************************************* // Receive function to handle incoming Ether receive() external payable whenNotPaused { emit TransferFunds(msg.sender, address(this), msg.value); } function sendToAddress( address _receiver, uint256 _amount ) public onlyAdmin whenNotPaused { _sendToAddress(_receiver, _amount); } function batchSendToAddress( address[] memory _receivers, uint256[] memory _amounts ) public onlyAdmin whenNotPaused { if (_amounts.length != _receivers.length) { revert IncorrectDistribution(); } for (uint256 i = 0; i < _receivers.length; ++i) { _sendToAddress(_receivers[i], _amounts[i]); } } function _sendToAddress( address _receiver, uint256 _amount ) internal virtual { if (_amount > address(this).balance) { revert InsufficientBalance(_amount, address(this).balance); } (bool success, ) = _receiver.call{value: _amount}(""); if (!success) { revert UnsuccessfulPayment(_receiver, _amount); } emit TransferFunds(address(this), _receiver, _amount); } }
Contract ABI
[{"type":"error","name":"ContractsIsPaused","inputs":[]},{"type":"error","name":"IncorrectDistribution","inputs":[]},{"type":"error","name":"InsufficientBalance","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"balance","internalType":"uint256"}]},{"type":"error","name":"InvalidRole","inputs":[{"type":"address","name":"caller","internalType":"address"},{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"error","name":"UnsuccessfulPayment","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"event","name":"TransferFunds","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"batchSendToAddress","inputs":[{"type":"address[]","name":"_receivers","internalType":"address[]"},{"type":"uint256[]","name":"_amounts","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_platformSettingsContractAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"platformSettingsContractAddress","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"sendToAddress","inputs":[{"type":"address","name":"_receiver","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"version","inputs":[]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x608060405234801561001057600080fd5b50610d5a806100206000396000f3fe60806040526004361061004e5760003560e01c80633debd2d81461013557806354fd4d5014610157578063c4d66de81461017a578063c6a319fa1461019a578063ccf98453146101d857600080fd5b3661013057600060029054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100a157600080fd5b505afa1580156100b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100d99190610aac565b156100f75760405163487ea6bb60e11b815260040160405180910390fd5b604051348152309033907f5a0155838afb0f859197785e575b9ad1afeb456c6e522b6f632ee8465941315e9060200160405180910390a3005b600080fd5b34801561014157600080fd5b50610155610150366004610af1565b6101f8565b005b34801561016357600080fd5b50604051621e887381526020015b60405180910390f35b34801561018657600080fd5b50610155610195366004610b1b565b610568565b3480156101a657600080fd5b506000546101c0906201000090046001600160a01b031681565b6040516001600160a01b039091168152602001610171565b3480156101e457600080fd5b506101556101f3366004610c0c565b61063d565b6000546040805163a217fddf60e01b81529051620100009092046001600160a01b0316916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561024a57600080fd5b505afa15801561025e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102829190610ccc565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156102bf57600080fd5b505afa1580156102d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102f79190610aac565b806103fc57506000546040805163a6b4321160e01b81529051620100009092046001600160a01b0316916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561034f57600080fd5b505afa158015610363573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103879190610ccc565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156103c457600080fd5b505afa1580156103d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fc9190610aac565b6104b65733600060029054906101000a90046001600160a01b03166001600160a01b031663a6b432116040518163ffffffff1660e01b815260040160206040518083038186803b15801561044f57600080fd5b505afa158015610463573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104879190610ccc565b6040516316b4d34b60e31b81526001600160a01b03909216600483015260248201526044015b60405180910390fd5b600060029054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561050457600080fd5b505afa158015610518573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053c9190610aac565b1561055a5760405163487ea6bb60e11b815260040160405180910390fd5b61056482826109b7565b5050565b600054610100900460ff1680610581575060005460ff16155b6105e45760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104ad565b600054610100900460ff16158015610606576000805461ffff19166101011790555b6000805462010000600160b01b031916620100006001600160a01b038516021790558015610564576000805461ff00191690555050565b6000546040805163a217fddf60e01b81529051620100009092046001600160a01b0316916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561068f57600080fd5b505afa1580156106a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c79190610ccc565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561070457600080fd5b505afa158015610718573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073c9190610aac565b8061084157506000546040805163a6b4321160e01b81529051620100009092046001600160a01b0316916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561079457600080fd5b505afa1580156107a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107cc9190610ccc565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561080957600080fd5b505afa15801561081d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108419190610aac565b6108945733600060029054906101000a90046001600160a01b03166001600160a01b031663a6b432116040518163ffffffff1660e01b815260040160206040518083038186803b15801561044f57600080fd5b600060029054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108e257600080fd5b505afa1580156108f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091a9190610aac565b156109385760405163487ea6bb60e11b815260040160405180910390fd5b815181511461095a57604051635c3810af60e01b815260040160405180910390fd5b60005b82518110156109b2576109a283828151811061097b5761097b610ce5565b602002602001015183838151811061099557610995610ce5565b60200260200101516109b7565b6109ab81610cfb565b905061095d565b505050565b478111156109e15760405163cf47918160e01b8152600481018290524760248201526044016104ad565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610a2e576040519150601f19603f3d011682016040523d82523d6000602084013e610a33565b606091505b5050905080610a675760405163299f419960e21b81526001600160a01b0384166004820152602481018390526044016104ad565b6040518281526001600160a01b0384169030907f5a0155838afb0f859197785e575b9ad1afeb456c6e522b6f632ee8465941315e9060200160405180910390a3505050565b600060208284031215610abe57600080fd5b81518015158114610ace57600080fd5b9392505050565b80356001600160a01b0381168114610aec57600080fd5b919050565b60008060408385031215610b0457600080fd5b610b0d83610ad5565b946020939093013593505050565b600060208284031215610b2d57600080fd5b610ace82610ad5565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610b7557610b75610b36565b604052919050565b600067ffffffffffffffff821115610b9757610b97610b36565b5060051b60200190565b600082601f830112610bb257600080fd5b81356020610bc7610bc283610b7d565b610b4c565b82815260059290921b84018101918181019086841115610be657600080fd5b8286015b84811015610c015780358352918301918301610bea565b509695505050505050565b60008060408385031215610c1f57600080fd5b823567ffffffffffffffff80821115610c3757600080fd5b818501915085601f830112610c4b57600080fd5b81356020610c5b610bc283610b7d565b82815260059290921b84018101918181019089841115610c7a57600080fd5b948201945b83861015610c9f57610c9086610ad5565b82529482019490820190610c7f565b96505086013592505080821115610cb557600080fd5b50610cc285828601610ba1565b9150509250929050565b600060208284031215610cde57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000600019821415610d1d57634e487b7160e01b600052601160045260246000fd5b506001019056fea2646970667358221220eae3c8fbbad74487c7c98831ad888f2163b06dff7f6b4dcd4b2343f3bf5f938c64736f6c63430008090033
Deployed ByteCode
0x60806040526004361061004e5760003560e01c80633debd2d81461013557806354fd4d5014610157578063c4d66de81461017a578063c6a319fa1461019a578063ccf98453146101d857600080fd5b3661013057600060029054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100a157600080fd5b505afa1580156100b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100d99190610aac565b156100f75760405163487ea6bb60e11b815260040160405180910390fd5b604051348152309033907f5a0155838afb0f859197785e575b9ad1afeb456c6e522b6f632ee8465941315e9060200160405180910390a3005b600080fd5b34801561014157600080fd5b50610155610150366004610af1565b6101f8565b005b34801561016357600080fd5b50604051621e887381526020015b60405180910390f35b34801561018657600080fd5b50610155610195366004610b1b565b610568565b3480156101a657600080fd5b506000546101c0906201000090046001600160a01b031681565b6040516001600160a01b039091168152602001610171565b3480156101e457600080fd5b506101556101f3366004610c0c565b61063d565b6000546040805163a217fddf60e01b81529051620100009092046001600160a01b0316916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561024a57600080fd5b505afa15801561025e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102829190610ccc565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156102bf57600080fd5b505afa1580156102d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102f79190610aac565b806103fc57506000546040805163a6b4321160e01b81529051620100009092046001600160a01b0316916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561034f57600080fd5b505afa158015610363573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103879190610ccc565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156103c457600080fd5b505afa1580156103d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fc9190610aac565b6104b65733600060029054906101000a90046001600160a01b03166001600160a01b031663a6b432116040518163ffffffff1660e01b815260040160206040518083038186803b15801561044f57600080fd5b505afa158015610463573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104879190610ccc565b6040516316b4d34b60e31b81526001600160a01b03909216600483015260248201526044015b60405180910390fd5b600060029054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561050457600080fd5b505afa158015610518573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053c9190610aac565b1561055a5760405163487ea6bb60e11b815260040160405180910390fd5b61056482826109b7565b5050565b600054610100900460ff1680610581575060005460ff16155b6105e45760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104ad565b600054610100900460ff16158015610606576000805461ffff19166101011790555b6000805462010000600160b01b031916620100006001600160a01b038516021790558015610564576000805461ff00191690555050565b6000546040805163a217fddf60e01b81529051620100009092046001600160a01b0316916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561068f57600080fd5b505afa1580156106a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c79190610ccc565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561070457600080fd5b505afa158015610718573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073c9190610aac565b8061084157506000546040805163a6b4321160e01b81529051620100009092046001600160a01b0316916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561079457600080fd5b505afa1580156107a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107cc9190610ccc565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561080957600080fd5b505afa15801561081d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108419190610aac565b6108945733600060029054906101000a90046001600160a01b03166001600160a01b031663a6b432116040518163ffffffff1660e01b815260040160206040518083038186803b15801561044f57600080fd5b600060029054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108e257600080fd5b505afa1580156108f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091a9190610aac565b156109385760405163487ea6bb60e11b815260040160405180910390fd5b815181511461095a57604051635c3810af60e01b815260040160405180910390fd5b60005b82518110156109b2576109a283828151811061097b5761097b610ce5565b602002602001015183838151811061099557610995610ce5565b60200260200101516109b7565b6109ab81610cfb565b905061095d565b505050565b478111156109e15760405163cf47918160e01b8152600481018290524760248201526044016104ad565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610a2e576040519150601f19603f3d011682016040523d82523d6000602084013e610a33565b606091505b5050905080610a675760405163299f419960e21b81526001600160a01b0384166004820152602481018390526044016104ad565b6040518281526001600160a01b0384169030907f5a0155838afb0f859197785e575b9ad1afeb456c6e522b6f632ee8465941315e9060200160405180910390a3505050565b600060208284031215610abe57600080fd5b81518015158114610ace57600080fd5b9392505050565b80356001600160a01b0381168114610aec57600080fd5b919050565b60008060408385031215610b0457600080fd5b610b0d83610ad5565b946020939093013593505050565b600060208284031215610b2d57600080fd5b610ace82610ad5565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610b7557610b75610b36565b604052919050565b600067ffffffffffffffff821115610b9757610b97610b36565b5060051b60200190565b600082601f830112610bb257600080fd5b81356020610bc7610bc283610b7d565b610b4c565b82815260059290921b84018101918181019086841115610be657600080fd5b8286015b84811015610c015780358352918301918301610bea565b509695505050505050565b60008060408385031215610c1f57600080fd5b823567ffffffffffffffff80821115610c3757600080fd5b818501915085601f830112610c4b57600080fd5b81356020610c5b610bc283610b7d565b82815260059290921b84018101918181019089841115610c7a57600080fd5b948201945b83861015610c9f57610c9086610ad5565b82529482019490820190610c7f565b96505086013592505080821115610cb557600080fd5b50610cc285828601610ba1565b9150509250929050565b600060208284031215610cde57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000600019821415610d1d57634e487b7160e01b600052601160045260246000fd5b506001019056fea2646970667358221220eae3c8fbbad74487c7c98831ad888f2163b06dff7f6b4dcd4b2343f3bf5f938c64736f6c63430008090033