Skip to content
Verified contractPartialMIT

UniversalEscrowUpgradeable

Address0x415a0b6ab8720e2fd858587e583cedfd9a4cf3ae
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.36

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.36+commit.8a079791
Language
solidity
Optimization
Yes, 1 runs
EVM version
osaka
Via IR
yes
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,456,256
Creation transaction
0x59c0ea3a29…c51c134cbf

59 files

The source code is large: one file is shown at a time. Choose a file in the list.

contracts/universal-escrow/UniversalEscrowUpgradeable.sol

/// SPDX-License-Identifier: MIT
pragma solidity <0.9.0;

import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
import {MulticallUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
import {EscrowIssuance} from "contracts/universal-escrow/EscrowIssuance.sol";
import {EscrowSettlement} from "contracts/universal-escrow/EscrowSettlement.sol";
import {CommonErrors, EscrowErrors} from "contracts/utils/Errors.sol";
import {EscrowRoles} from "contracts/utils/Roles.sol";

/// @title UniversalEscrowUpgradeable
/// @notice Single UUPS-proxied escrow managing all token issuances across the protocol
/// @custom:security-contact [email protected]
contract UniversalEscrowUpgradeable is Initializable, UUPSUpgradeable, MulticallUpgradeable, EscrowIssuance, EscrowSettlement {
    /// @dev Bump on every upgrade.
    uint8 private constant VERSION = 1;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /// @dev Initializes the escrow. `_admin` is the DEFAULT_ADMIN (multisig), `_manager` is the backend that holds
    /// ESCROW_MANAGER_ROLE (distinct from admin), and `_feeManager` is wired as the fee manager: address(0) selects
    /// no-fee mode, any other value must be a contract.
    function initialize(address _admin, address _manager, address _feeManager) external initializer {
        require(_admin != address(0) && _manager != address(0), CommonErrors.NotZeroAddress());
        require(_feeManager == address(0) || _feeManager.code.length > 0, EscrowErrors.InvalidFeeManager());
        __AccessControlEnumerable_init();
        __Multicall_init();
        __EIP712_init("UniversalEscrow", "1");
        _grantRole(DEFAULT_ADMIN_ROLE, _admin);
        _grantRole(EscrowRoles.ESCROW_MANAGER_ROLE, _manager);
        _getEscrowStorageV1().feeManager = _feeManager;
        emit FeeManagerChanged(_feeManager);
    }

    /// @dev Configures the global payment-token whitelist (manager tier)
    function configPaymentTokens(address[] calldata tokens, bool[] calldata statuses) external whenNotGloballyPaused onlyRole(EscrowRoles.ESCROW_MANAGER_ROLE) {
        require(tokens.length == statuses.length, EscrowErrors.LengthsMismatch());
        for (uint256 i; i < tokens.length; ++i) {
            _setPaymentTokenAllowed(tokens[i], statuses[i]);
        }
        emit PaymentTokensConfigured(tokens, statuses);
    }

    /// @dev Whether `account` may grant/revoke the token-scoped `baseRole` for `issuedToken` under the role pyramid.
    /// DEFAULT_ADMIN and ESCROW_MANAGER may manage any token role; the token's NEW_ISSUANCE holder may manage the
    /// bottom-tier roles (patch / finalize / withdraw) for that token only.
    function canManageTokenRole(address issuedToken, bytes32 baseRole, address account) public view override returns (bool) {
        if (hasRole(DEFAULT_ADMIN_ROLE, account) || hasRole(EscrowRoles.ESCROW_MANAGER_ROLE, account)) return true;
        if (baseRole == EscrowRoles.ESCROW_PATCH_ISSUANCE_ROLE || baseRole == EscrowRoles.ESCROW_ISSUANCE_FINALIZER_ROLE || baseRole == EscrowRoles.ESCROW_WITHDRAW_ROLE)
        {
            return hasRole(getTokenRoleHash(EscrowRoles.ESCROW_NEW_ISSUANCE_ROLE, issuedToken), account);
        }
        return false;
    }

    /// @dev Sets the external fee manager
    function setFeeManager(address newFeeManager) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(newFeeManager == address(0) || newFeeManager.code.length > 0, EscrowErrors.InvalidFeeManager());
        _getEscrowStorageV1().feeManager = newFeeManager;
        emit FeeManagerChanged(newFeeManager);
    }

    /// @dev Sets the global pause state
    function setGlobalPause(bool paused) external onlyRole(DEFAULT_ADMIN_ROLE) {
        _getEscrowStorageV1().globalPaused = paused;
        emit GlobalPauseChanged(paused);
    }

    /// @dev Sets the pause state for a single issuance
    function setIssuancePause(address issuedToken, uint256 issuanceIndex, bool paused) external onlyRole(DEFAULT_ADMIN_ROLE) {
        _getEscrowStorageV1().issuancePaused[issuedToken][issuanceIndex] = paused;
        emit IssuancePauseChanged(issuedToken, issuanceIndex, paused);
    }

    /// @dev Returns the configured fee manager address
    function getFeeManager() external view returns (address) {
        return _getEscrowStorageV1().feeManager;
    }

    /// @dev Returns the contract version
    /// @return The contract version number
    function version() external pure returns (uint8) {
        return VERSION;
    }

    /// @dev Restricts upgrades to the default admin
    function _authorizeUpgrade(address) internal override onlyRole(DEFAULT_ADMIN_ROLE) {}
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": false,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 1,
    "enabled": true
  },
  "viaSSACFG": false,
  "evmVersion": "osaka",
  "remappings": [
    "ethereum-vault-connector/=lib/ethereum-vault-connector/src/",
    "permit2/=lib/permit2/",
    "ds-test/=lib/ethereum-vault-connector/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/",
    "forge-std/=lib/forge-std/src/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "contracts/=contracts/",
    "test/=test/",
    "scripts/utils/=scripts/utils/",
    "lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts-upgradeable/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts-upgradeable/:halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts-upgradeable/:openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/",
    "lib/openzeppelin-contracts-upgradeable/:openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/",
    "lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "lib/openzeppelin-contracts/:halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "@openzeppelin/=node_modules/@openzeppelin/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "experimental": false
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.