creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/soma/SecurityTokens/SecurityToken.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"./extensions/partitions/ERC20SecurityPartition.sol\";\nimport \"./extensions/MintableSecurity.sol\";\nimport \"./ISecurityToken.sol\";\nimport \"../Lockdrop/extensions/TokenRecoveryUpgradeable.sol\";\n\n/**\n * @notice Implementation of the {ISecurityToken} interface.\n */\ncontract SecurityToken is ISecurityToken, ERC20SecurityPartition, MintableSecurity, TokenRecoveryUpgradeable {\n    constructor() {\n        _disableInitializers();\n    }\n\n    /**\n     * @inheritdoc ISecurityToken\n     */\n    function initialize(string memory domain, string memory name, string memory symbol) external virtual initializer {\n        __ERC20Security_init(domain, name, symbol);\n        __MintableSecurity_init_unchained();\n        __TokenRecovery__init_unchained(new address[](0));\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        virtual\n        override(ERC20SecurityPartition, MintableSecurity, TokenRecoveryUpgradeable)\n        returns (bool)\n    {\n        return interfaceId == type(ISecurityToken).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @notice Returns a boolean indicating if the contracts are paused.\n     */\n    function paused() public view virtual override(ERC20SecurityPartition, SomaContractUpgradeable) returns (bool) {\n        return super.paused();\n    }\n\n    function _mint(address to, bytes32 id, uint256 amount, bytes memory data)\n        internal\n        override(ERC20SecurityPartition, MintableSecurity)\n    {\n        super._mint(to, id, amount, data);\n    }\n\n    function _burn(address from, bytes32 id, uint256 amount, bytes memory data)\n        internal\n        override(ERC20SecurityPartition, MintableSecurity)\n    {\n        super._burn(from, id, amount, data);\n    }\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/ERC20SecurityPartition.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol\";\n\nimport \"../ERC20HistoryUpgradeable.sol\";\nimport \"./ERC20GuardPartition.sol\";\nimport \"./SeizableSecurityPartition.sol\";\nimport \"./DeprecatableSecurity.sol\";\nimport \"./TransferablePartition.sol\";\n\nabstract contract ERC20SecurityPartition is\n    ERC20PausableUpgradeable,\n    ERC20HistoryUpgradeable,\n    ERC20PermitUpgradeable,\n    SeizableSecurityPartition,\n    DeprecatableSecurity,\n    TransferablePartition,\n    ERC20GuardPartition\n{\n    function __ERC20Security_init(string memory domain, string memory name, string memory symbol)\n        internal\n        onlyInitializing\n    {\n        __ERC20Pausable_init_unchained();\n        __Context_init_unchained();\n        __Pausable_init_unchained();\n        __ERC20History_init_unchained();\n        __EIP712_init_unchained(domain, \"1\");\n        __ERC20Permit_init_unchained(domain);\n        __ERC165_init_unchained();\n        __SeizableSecurity_init_unchained();\n        __SomaContract_init_unchained();\n        __Accessible_init_unchained();\n        __Multicall_init_unchained();\n        __Guardable__init_unchained();\n        __ERC20Security_init_unchained();\n        __ERC20_init_unchained(name, symbol);\n        __DeprecatableSecurity_init_unchained();\n        __TransferPartitions_init_unchained();\n    }\n\n    function __ERC20Security_init_unchained() internal onlyInitializing {}\n\n    function paused() public view virtual override(PausableUpgradeable, SomaContractUpgradeable) returns (bool) {\n        return super.paused();\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId)\n        public\n        view\n        virtual\n        override(SeizableSecurityPartition, ERC20GuardPartition, DeprecatableSecurity, TransferablePartition)\n        returns (bool)\n    {\n        return interfaceId == type(IERC20Upgradeable).interfaceId\n            || interfaceId == type(IERC20PermitUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    function _mint(address to, bytes32 id, uint256 amount, bytes memory data)\n        internal\n        virtual\n        override(ERC20Partition)\n    {\n        super._mint(to, id, amount, data);\n    }\n\n    function _mint(address to, uint256 amount) internal virtual override(ERC20Upgradeable, ERC20HistoryUpgradeable) {\n        super._mint(to, amount);\n    }\n\n    function _burn(address from, bytes32 id, uint256 amount, bytes memory data)\n        internal\n        virtual\n        override(ERC20Partition)\n    {\n        super._burn(from, id, amount, data);\n    }\n\n    function _burn(address to, uint256 amount) internal virtual override(ERC20Upgradeable, ERC20HistoryUpgradeable) {\n        super._burn(to, amount);\n    }\n\n    function _afterTokenTransfer(address from, address to, uint256 amount)\n        internal\n        virtual\n        override(ERC20Upgradeable, ERC20HistoryUpgradeable)\n    {\n        super._afterTokenTransfer(from, to, amount);\n    }\n\n    function _seize(address from, address to, bytes32 fromId, bytes32 toId, uint256 amount, bytes memory data)\n        internal\n        override\n    {\n        _transfer(from, to, fromId, toId, amount, data);\n    }\n\n    function _beforeTokenTransfer(address from, address to, uint256 amount)\n        internal\n        virtual\n        override(ERC20Upgradeable, ERC20PausableUpgradeable)\n    {\n        return super._beforeTokenTransfer(from, to, amount);\n    }\n\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        bytes32 fromId,\n        bytes32 toId,\n        uint256 amount,\n        bytes memory data\n    ) internal virtual override(ERC20GuardPartition, ERC20Partition) {\n        super._beforeTokenTransfer(from, to, fromId, toId, amount, data);\n    }\n\n    function _transfer(address from, address to, uint256 amount)\n        internal\n        virtual\n        override(ERC20Partition, ERC20Upgradeable)\n    {\n        super._transfer(from, to, amount);\n    }\n\n    function _bypassValidate() internal virtual override returns (bool) {\n        return (seizeInProgress) ? true : false;\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/MintableSecurity.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"../../SomaGuard/utils/GuardableUpgradeable.sol\";\n\nimport \"./IMintableSecurity.sol\";\n\n/**\n * @notice Implementation of the {IMintableSecurity} interface.\n */\nabstract contract MintableSecurity is IMintableSecurity, AccessibleUpgradeable {\n    /**\n     * @notice Initializer for extended contracts.\n     */\n    function __MintableSecurity_init() internal {\n        __Accessible_init_unchained();\n        __SomaContract_init_unchained();\n        __ERC165_init_unchained();\n        __Context_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n        __MintableSecurity_init_unchained();\n    }\n\n    /**\n     * @notice Unchained initializer.\n     */\n    function __MintableSecurity_init_unchained() internal onlyInitializing {\n        LOCAL_MINT_ROLE = keccak256(abi.encodePacked(address(this), GLOBAL_MINT_ROLE));\n    }\n\n    /**\n     * @notice Returns the GLOBAL_MINT_ROLE.\n     */\n    bytes32 public constant GLOBAL_MINT_ROLE = keccak256(\"MintableSecurity.MINT_ROLE\");\n\n    /**\n     * @notice Returns the LOCAL_MINT_ROLE.\n     */\n    bytes32 public LOCAL_MINT_ROLE;\n\n    /**\n     * @notice Modifier to restrict a function caller to accounts that have the GLOBAL_MINT_ROLE or LOCAL_MINT_ROLE.\n     */\n    modifier onlyMintRole() {\n        address sender = _msgSender();\n        require(hasRole(LOCAL_MINT_ROLE, sender) || hasRole(GLOBAL_MINT_ROLE, sender), \"MintableSecurity: UNAUTHORIZED\");\n        _;\n    }\n\n    /**\n     * @notice Checks if MintableSecurity inherits a given contract interface.\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IMintableSecurity).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @inheritdoc IMintableSecurity\n     */\n    function mint(bytes32 id, uint256 amount, bytes memory data) public override onlyMintRole {\n        address mintTo = SOMA.mintTo();\n        _mint(mintTo, id, amount, data);\n        emit Minted(_msgSender(), mintTo, id, amount, data);\n    }\n\n    /**\n     * @inheritdoc IMintableSecurity\n     */\n    function burn(bytes32 id, uint256 amount, bytes memory data) public override onlyMintRole {\n        address mintTo = SOMA.mintTo();\n        _burn(mintTo, id, amount, data);\n        emit Burned(_msgSender(), mintTo, id, amount, data);\n    }\n\n    function _mint(address to, bytes32 id, uint256 amount, bytes memory data) internal virtual;\n\n    function _burn(address from, bytes32 id, uint256 amount, bytes memory data) internal virtual;\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/SecurityTokens/ISecurityToken.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Security Token Contract.\n * @author SOMA.finance\n * @notice A guarded, mintable and seizable security token.\n */\ninterface ISecurityToken {\n    /**\n     * @notice Initialize function for the Security Token contract.\n     * @param domain The domain of the token.\n     * @param name The name of the token.\n     * @param symbol The symbol of the token.\n     */\n    function initialize(string memory domain, string memory name, string memory symbol) external;\n}\n"
      },
      "contracts/soma/Lockdrop/extensions/TokenRecoveryUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nimport \"../../SomaAccessControl/utils/AccessibleUpgradeable.sol\";\n\nimport \"./ITokenRecoveryUpgradeable.sol\";\n\n/**\n * @notice Implementation of the {ITokenRecoveryUpgradeable} interface.\n */\nabstract contract TokenRecoveryUpgradeable is ITokenRecoveryUpgradeable, AccessibleUpgradeable {\n    using EnumerableSet for EnumerableSet.AddressSet;\n    using SafeERC20 for IERC20;\n\n    /**\n     * @notice Initializer for the extended contracts.\n     */\n    function __TokenRecovery__init() internal onlyInitializing {\n        __TokenRecovery__init(new address[](0));\n    }\n\n    /**\n     * @notice Initializer for the extended contracts.\n     */\n    function __TokenRecovery__init(address[] memory disabledTokens) internal onlyInitializing {\n        __ERC165_init_unchained();\n        __Context_init_unchained();\n        __SomaContract_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n        __Accessible_init_unchained();\n        __TokenRecovery__init_unchained(disabledTokens);\n    }\n\n    /**\n     * @notice Unchained initializer.\n     */\n    function __TokenRecovery__init_unchained(address[] memory disabledTokens) internal onlyInitializing {\n        for (uint256 i; i < disabledTokens.length; ++i) {\n            _disabledTokens.add(disabledTokens[i]);\n        }\n    }\n\n    /**\n     * @inheritdoc ITokenRecoveryUpgradeable\n     */\n    bytes32 public constant override TOKEN_RECOVERY_ROLE = keccak256(\"TokenRecovery.TOKEN_RECOVERY_ROLE\");\n\n    EnumerableSet.AddressSet private _disabledTokens;\n\n    /**\n     * @notice Checks if TokenRecoveryUpgradeable inherits a given contract interface.\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(ITokenRecoveryUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @inheritdoc ITokenRecoveryUpgradeable\n     */\n    function recoverTokens(address token, address to, uint256 amount) external override onlyRole(TOKEN_RECOVERY_ROLE) {\n        require(!_disabledTokens.contains(token), \"TokenRecovery: INVALID_TOKEN\");\n        IERC20(token).safeTransfer(to, amount);\n        emit TokensRecovered(token, to, amount, _msgSender());\n    }\n\n    function _disableTokenRecovery(address token) internal {\n        _disabledTokens.add(token);\n    }\n\n    function _enableTokenRecovery(address token) internal {\n        _disabledTokens.remove(token);\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../security/PausableUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev ERC20 token with pausable token transfers, minting and burning.\n *\n * Useful for scenarios such as preventing trades until the end of an evaluation\n * period, or having an emergency switch for freezing all token transfers in the\n * event of a large bug.\n */\nabstract contract ERC20PausableUpgradeable is Initializable, ERC20Upgradeable, PausableUpgradeable {\n    function __ERC20Pausable_init() internal onlyInitializing {\n        __Pausable_init_unchained();\n    }\n\n    function __ERC20Pausable_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {ERC20-_beforeTokenTransfer}.\n     *\n     * Requirements:\n     *\n     * - the contract must not be paused.\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual override {\n        super._beforeTokenTransfer(from, to, amount);\n\n        require(!paused(), \"ERC20Pausable: token transfer while paused\");\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20PermitUpgradeable.sol\";\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/cryptography/draft-EIP712Upgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n\n    mapping(address => CountersUpgradeable.Counter) private _nonces;\n\n    // solhint-disable-next-line var-name-mixedcase\n    bytes32 private constant _PERMIT_TYPEHASH =\n        keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n    /**\n     * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n     * However, to ensure consistency with the upgradeable transpiler, we will continue\n     * to reserve a slot.\n     * @custom:oz-renamed-from _PERMIT_TYPEHASH\n     */\n    // solhint-disable-next-line var-name-mixedcase\n    bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n    /**\n     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n     *\n     * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n     */\n    function __ERC20Permit_init(string memory name) internal onlyInitializing {\n        __EIP712_init_unchained(name, \"1\");\n    }\n\n    function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}\n\n    /**\n     * @dev See {IERC20Permit-permit}.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public virtual override {\n        require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n        bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n        bytes32 hash = _hashTypedDataV4(structHash);\n\n        address signer = ECDSAUpgradeable.recover(hash, v, r, s);\n        require(signer == owner, \"ERC20Permit: invalid signature\");\n\n        _approve(owner, spender, value);\n    }\n\n    /**\n     * @dev See {IERC20Permit-nonces}.\n     */\n    function nonces(address owner) public view virtual override returns (uint256) {\n        return _nonces[owner].current();\n    }\n\n    /**\n     * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n        return _domainSeparatorV4();\n    }\n\n    /**\n     * @dev \"Consume a nonce\": return the current value and increment.\n     *\n     * _Available since v4.1._\n     */\n    function _useNonce(address owner) internal virtual returns (uint256 current) {\n        CountersUpgradeable.Counter storage nonce = _nonces[owner];\n        current = nonce.current();\n        nonce.increment();\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/ERC20HistoryUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"./IERC20HistoryUpgradeable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @notice Implementation of the {IERC20HistoryUpgradeable} interface.\n */\nabstract contract ERC20HistoryUpgradeable is Initializable, IERC20HistoryUpgradeable, ERC20Upgradeable {\n    /**\n     * @notice Initializer for extended contracts.\n     */\n    function __ERC20History_init() internal onlyInitializing {\n        __Context_init_unchained();\n        __ERC20History_init_unchained();\n    }\n\n    /**\n     * @notice Unchained initializer for extended contracts.\n     */\n    function __ERC20History_init_unchained() internal onlyInitializing {}\n\n    /**\n     * @notice Checkpoint structure.\n     * @param fromBlock The block marking the start of the checkpoint.\n     * @param balance The balance of an account in a given checkpoint.\n     */\n    struct Checkpoint {\n        uint32 fromBlock;\n        uint224 balance;\n    }\n\n    mapping(address => Checkpoint[]) private _checkpoints;\n    Checkpoint[] private _totalSupplyCheckpoints;\n\n    /**\n     * @notice Get the `pos`-th checkpoint for `account`.\n     * @param account The account to return the checkpoints of.\n     * @param pos The index of the checkpoint to return.\n     * @return The checkpoint structure representing the `pos`-th checkpoint for `account`.\n     */\n    function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) {\n        return _checkpoints[account][pos];\n    }\n\n    /**\n     * @notice Returns the number of checkpoints for `account`.\n     * @param account The account to return the number of checkpoints for.\n     * @return The number of checkpoints for `account`.\n     */\n    function numCheckpoints(address account) public view virtual returns (uint32) {\n        return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n    }\n\n    /**\n     * @inheritdoc IERC20HistoryUpgradeable\n     */\n    function getPastBalance(address account, uint256 blockNumber) public view virtual override returns (uint256) {\n        require(blockNumber < block.number, \"ERC20History: block not yet mined\");\n        return _checkpointsLookup(_checkpoints[account], blockNumber);\n    }\n\n    /**\n     * @inheritdoc IERC20HistoryUpgradeable\n     */\n    function getPastTotalSupply(uint256 blockNumber) public view virtual override returns (uint256) {\n        require(blockNumber < block.number, \"ERC20History: block not yet mined\");\n        return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber);\n    }\n\n    /**\n     * @dev Lookup a value in a list of (sorted) checkpoints.\n     */\n    function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n        // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n        //\n        // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n        // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n        // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n        // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n        // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n        // out of bounds (in which case we're looking too far in the past and the result is 0).\n        // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n        // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n        // the same.\n        uint256 high = ckpts.length;\n        uint256 low = 0;\n        while (low < high) {\n            uint256 mid = MathUpgradeable.average(low, high);\n            if (ckpts[mid].fromBlock > blockNumber) {\n                high = mid;\n            } else {\n                low = mid + 1;\n            }\n        }\n\n        return high == 0 ? 0 : ckpts[high - 1].balance;\n    }\n\n    /**\n     * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1).\n     */\n    function _maxSupply() internal view virtual returns (uint224) {\n        return type(uint224).max;\n    }\n\n    /**\n     * @dev Snapshots the totalSupply after it has been increased.\n     */\n    function _mint(address account, uint256 amount) internal virtual override {\n        super._mint(account, amount);\n        require(totalSupply() <= _maxSupply(), \"ERC20History: total supply risks overflowing votes\");\n\n        _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);\n    }\n\n    /**\n     * @dev Snapshots the totalSupply after it has been decreased.\n     */\n    function _burn(address account, uint256 amount) internal virtual override {\n        super._burn(account, amount);\n\n        _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);\n    }\n\n    /**\n     * @dev Move balance when tokens are transferred.\n     *\n     * Emits a {DelegateVotesChanged} event.\n     */\n    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual override {\n        super._afterTokenTransfer(from, to, amount);\n\n        _moveBalance(from, to, amount);\n    }\n\n    function _moveBalance(address src, address dst, uint256 amount) private {\n        if (src != dst && amount > 0) {\n            if (src != address(0)) {\n                (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount);\n                emit BalanceChanged(src, oldWeight, newWeight);\n            }\n\n            if (dst != address(0)) {\n                (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);\n                emit BalanceChanged(dst, oldWeight, newWeight);\n            }\n        }\n    }\n\n    function _writeCheckpoint(\n        Checkpoint[] storage ckpts,\n        function(uint256, uint256) view returns (uint256) op,\n        uint256 delta\n    ) private returns (uint256 oldWeight, uint256 newWeight) {\n        uint256 pos = ckpts.length;\n        oldWeight = pos == 0 ? 0 : ckpts[pos - 1].balance;\n        newWeight = op(oldWeight, delta);\n\n        if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {\n            ckpts[pos - 1].balance = SafeCastUpgradeable.toUint224(newWeight);\n        } else {\n            ckpts.push(\n                Checkpoint({\n                    fromBlock: SafeCastUpgradeable.toUint32(block.number),\n                    balance: SafeCastUpgradeable.toUint224(newWeight)\n                })\n            );\n        }\n    }\n\n    function _add(uint256 a, uint256 b) private pure returns (uint256) {\n        return a + b;\n    }\n\n    function _subtract(uint256 a, uint256 b) private pure returns (uint256) {\n        return a - b;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[47] private __gap;\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/ERC20GuardPartition.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"../../../SomaGuard/utils/MultiGuardableUpgradeable.sol\";\n\nimport \"./IERC20GuardPartition.sol\";\nimport \"./ERC20Partition.sol\";\n\n/**\n * @notice Implementation of the {IERC20GuardPartition} interface.\n */\nabstract contract ERC20GuardPartition is IERC20GuardPartition, ERC20Partition, MultiGuardableUpgradeable {\n    mapping(address => bytes32) _requiredPrivileges;\n    /**\n     * @notice Initializer for extended contracts.\n     */\n\n    function __ERC20Guard_init() internal {\n        __ERC165_init_unchained();\n        __Context_init_unchained();\n        __Guardable__init_unchained();\n        __SomaContract_init_unchained();\n        __Accessible_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    /**\n     * @inheritdoc IERC20GuardPartition\n     */\n    function canTransferFrom(address _from, address _to, uint256 amount) public view virtual returns (bool) {\n        return canTransferFrom(_from, _to, DEFAULT_PARTITION, DEFAULT_PARTITION, amount);\n    }\n\n    /**\n     * @inheritdoc IERC20GuardPartition\n     */\n    function canTransferFrom(address _from, address _to, bytes32 fromId, bytes32 toId, uint256)\n        public\n        view\n        virtual\n        returns (bool)\n    {\n        ISomaGuard _guard = ISomaGuard(SOMA.guard());\n        bytes32 _fromPrivileges = requiredPrivileges(fromId);\n        bytes32 _toPrivileges = fromId == toId ? _fromPrivileges : requiredPrivileges(toId);\n\n        // if the from address is 0 then it is minting\n        // if the to address is 0 then it is burning\n        // in both scenarios, we want to assume that address(0) is allowed.\n        return (_from == address(0) || _guard.check(_from, _fromPrivileges))\n            && (_to == address(0) || _guard.check(_to, _toPrivileges));\n    }\n\n    /**\n     * @notice Checks if ERC20Guard inherits a given contract interface.\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC20GuardPartition).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        bytes32 fromId,\n        bytes32 toId,\n        uint256 amount,\n        bytes memory data\n    ) internal virtual override {\n        super._beforeTokenTransfer(from, to, fromId, toId, amount, data);\n\n        // ignore checks if bypass is true\n        if (_bypassValidate()) return;\n\n        // SomaGuard check, for determining if each user has the requiredPrivileges for this security\n        require(canTransferFrom(from, to, fromId, toId, amount), \"ERC20Guard: MISSING_PRIVILEGES\");\n    }\n\n    function _bypassValidate() internal virtual returns (bool) {\n        return false;\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/SeizableSecurityPartition.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"../../../SomaAccessControl/utils/AccessibleUpgradeable.sol\";\n\nimport \"./ISeizableSecurityPartition.sol\";\n\n/**\n * @notice Implementation of the {ISeizableSecurityPartition} interface.\n */\nabstract contract SeizableSecurityPartition is ISeizableSecurityPartition, AccessibleUpgradeable {\n    /**\n     * @notice Initializer for extended contracts.\n     */\n    function __SeizableSecurity_init() internal {\n        __ERC165_init_unchained();\n        __Context_init_unchained();\n        __SomaContract_init_unchained();\n        __Accessible_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n        __SeizableSecurity_init_unchained();\n    }\n\n    /**\n     * @notice Unchained initializer.\n     */\n    function __SeizableSecurity_init_unchained() internal onlyInitializing {\n        LOCAL_SEIZE_ROLE = keccak256(abi.encodePacked(address(this), GLOBAL_SEIZE_ROLE));\n    }\n\n    /**\n     * @notice Returns the GLOBAL_SEIZE_ROLE.\n     */\n    bytes32 public constant GLOBAL_SEIZE_ROLE = keccak256(\"SeizableSecurity.SEIZE_ROLE\");\n\n    /**\n     * @notice Returns the LOCAL_SEIZE_ROLE.\n     */\n    bytes32 public LOCAL_SEIZE_ROLE;\n\n    /**\n     * @notice True if a seize is in progress, else False.\n     */\n    bool internal seizeInProgress;\n\n    /**\n     * @notice Modifier to update seize in progress state.\n     */\n    modifier enableSeizing() {\n        seizeInProgress = true;\n        _;\n        seizeInProgress = false;\n    }\n\n    /**\n     * @notice Modifier to restrict a function caller to an account with the GLOBAL_SEIZE_ROLE or LOCAL_SEIZE_ROLE.\n     */\n    modifier onlySeizeRole() {\n        address sender = _msgSender();\n        require(\n            hasRole(LOCAL_SEIZE_ROLE, sender) || hasRole(GLOBAL_SEIZE_ROLE, sender), \"SeizableSecurity: UNAUTHORIZED\"\n        );\n        _;\n    }\n\n    /**\n     * @notice Checks if SeizableSecurity inherits a given contract interface.\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(ISeizableSecurityPartition).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @inheritdoc ISeizableSecurityPartition\n     */\n    function seize(address tokenHolder, bytes32 fromId, bytes32 toId, uint256 amount, bytes memory data)\n        public\n        override\n        enableSeizing\n        onlySeizeRole\n    {\n        address seizeTo = SOMA.seizeTo();\n        _seize(tokenHolder, seizeTo, fromId, toId, amount, data);\n        emit Seized(_msgSender(), tokenHolder, seizeTo, fromId, toId, amount, data);\n    }\n\n    function _seize(address from, address to, bytes32 fromId, bytes32 toId, uint256 amount, bytes memory data)\n        internal\n        virtual;\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/DeprecatableSecurity.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"../../../SomaGuard/utils/GuardableUpgradeable.sol\";\n\nimport \"./IDeprecatableSecurity.sol\";\nimport \"./ERC20Partition.sol\";\n\n/**\n * @notice Implementation of the {IDeprecatableSecurity} interface.\n */\nabstract contract DeprecatableSecurity is IDeprecatableSecurity, ERC20Partition, AccessibleUpgradeable {\n    /**\n     * @notice Initializer for extended contracts.\n     */\n    function __DeprecatableSecurity_init() internal {\n        __Accessible_init_unchained();\n        __SomaContract_init_unchained();\n        __ERC165_init_unchained();\n        __Context_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n        __DeprecatableSecurity_init_unchained();\n    }\n\n    /**\n     * @notice Unchained initializer.\n     */\n    function __DeprecatableSecurity_init_unchained() internal onlyInitializing {\n        LOCAL_DEPRECATE_ROLE = keccak256(abi.encodePacked(address(this), GLOBAL_DEPRECATE_ROLE));\n    }\n\n    /**\n     * @notice Returns the GLOBAL_DEPRECATE_ROLE.\n     */\n    bytes32 public constant GLOBAL_DEPRECATE_ROLE = keccak256(\"DeprecatableSecurity.DEPRECATE_ROLE\");\n\n    /**\n     * @notice Returns the LOCAL_DEPRECATE_ROLE.\n     */\n    bytes32 public LOCAL_DEPRECATE_ROLE;\n\n    /**\n     * @notice Modifier to restrict a function caller to accounts that have the GLOBAL_MINT_ROLE or LOCAL_MINT_ROLE.\n     */\n    modifier onlyDeprecateRole() {\n        address sender = _msgSender();\n        require(\n            hasRole(LOCAL_DEPRECATE_ROLE, sender) || hasRole(GLOBAL_DEPRECATE_ROLE, sender),\n            \"DeprecatableSecurity: UNAUTHORIZED\"\n        );\n        _;\n    }\n\n    /**\n     * @notice Checks if DeprecatableSecurity inherits a given contract interface.\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IDeprecatableSecurity).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @inheritdoc IDeprecatableSecurity\n     */\n    function deprecatePartition(bytes32 id, bytes memory data) public override onlyDeprecateRole {\n        _deprecatePartition(id, data);\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/TransferablePartition.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"../../../SomaAccessControl/utils/AccessibleUpgradeable.sol\";\n\nimport \"./ITransferablePartition.sol\";\nimport \"./ERC20Partition.sol\";\n\nabstract contract TransferablePartition is ITransferablePartition, ERC20Partition, AccessibleUpgradeable {\n    /**\n     * @notice Initializer for extended contracts.\n     */\n    function __TransferPartitions_init() internal {\n        __ERC165_init_unchained();\n        __Context_init_unchained();\n        __SomaContract_init_unchained();\n        __Accessible_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n        __TransferPartitions_init_unchained();\n    }\n\n    /**\n     * @notice Unchained initializer.\n     */\n    function __TransferPartitions_init_unchained() internal onlyInitializing {\n        LOCAL_MANAGE_ROLE = keccak256(abi.encodePacked(address(this), GLOBAL_MANAGE_ROLE));\n    }\n\n    /**\n     * @notice Returns the GLOBAL_SEIZE_ROLE.\n     */\n    bytes32 public constant GLOBAL_MANAGE_ROLE = keccak256(\"TransferPartitions.MANAGE_ROLE\");\n\n    /**\n     * @notice Returns the LOCAL_SEIZE_ROLE.\n     */\n    bytes32 public LOCAL_MANAGE_ROLE;\n\n    /**\n     * @notice Modifier to restrict a function caller to an account with the GLOBAL_SEIZE_ROLE or LOCAL_SEIZE_ROLE.\n     */\n    modifier onlyManageRole() {\n        address sender = _msgSender();\n        require(\n            hasRole(LOCAL_MANAGE_ROLE, sender) || hasRole(GLOBAL_MANAGE_ROLE, sender),\n            \"TransferPartitions: UNAUTHORIZED\"\n        );\n        _;\n    }\n\n    /**\n     * @notice Checks if TransferPartitions inherits a given contract interface.\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(ITransferablePartition).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @inheritdoc ITransferablePartition\n     */\n    function transferPartition(address account, bytes32 fromId, bytes32 toId, uint256 amount, bytes memory data)\n        public\n        override\n        onlyManageRole\n        returns (bool)\n    {\n        _transferPartition(account, account, fromId, toId, balanceOf(account), amount, data);\n        emit MovedPartition(account, fromId, toId, amount, data);\n        return true;\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\n    mapping(address => uint256) private _balances;\n\n    mapping(address => mapping(address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}.\n     *\n     * The default value of {decimals} is 18. To select a different value for\n     * {decimals} you should overload it.\n     *\n     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n        __ERC20_init_unchained(name_, symbol_);\n    }\n\n    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the value {ERC20} uses, unless this function is\n     * overridden;\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual override returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual override returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address to, uint256 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _transfer(owner, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n     * `transferFrom`. This is semantically equivalent to an infinite approval.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\n     *\n     * NOTE: Does not update the allowance if the current allowance\n     * is the maximum `uint256`.\n     *\n     * Requirements:\n     *\n     * - `from` and `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     * - the caller must have allowance for ``from``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public virtual override returns (bool) {\n        address spender = _msgSender();\n        _spendAllowance(from, spender, amount);\n        _transfer(from, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, allowance(owner, spender) + addedValue);\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        uint256 currentAllowance = allowance(owner, spender);\n        require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n        unchecked {\n            _approve(owner, spender, currentAllowance - subtractedValue);\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Moves `amount` of tokens from `from` to `to`.\n     *\n     * This internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     */\n    function _transfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {\n        require(from != address(0), \"ERC20: transfer from the zero address\");\n        require(to != address(0), \"ERC20: transfer to the zero address\");\n\n        _beforeTokenTransfer(from, to, amount);\n\n        uint256 fromBalance = _balances[from];\n        require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n        unchecked {\n            _balances[from] = fromBalance - amount;\n        }\n        _balances[to] += amount;\n\n        emit Transfer(from, to, amount);\n\n        _afterTokenTransfer(from, to, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, amount);\n\n        _totalSupply += amount;\n        _balances[account] += amount;\n        emit Transfer(address(0), account, amount);\n\n        _afterTokenTransfer(address(0), account, amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), amount);\n\n        uint256 accountBalance = _balances[account];\n        require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n        unchecked {\n            _balances[account] = accountBalance - amount;\n        }\n        _totalSupply -= amount;\n\n        emit Transfer(account, address(0), amount);\n\n        _afterTokenTransfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    /**\n     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n     *\n     * Does not update the allowance amount in case of infinite allowance.\n     * Revert if not enough allowance is available.\n     *\n     * Might emit an {Approval} event.\n     */\n    function _spendAllowance(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        uint256 currentAllowance = allowance(owner, spender);\n        if (currentAllowance != type(uint256).max) {\n            require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n            unchecked {\n                _approve(owner, spender, currentAllowance - amount);\n            }\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * has been transferred to `to`.\n     * - when `from` is zero, `amount` tokens have been minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[45] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    function __Pausable_init() internal onlyInitializing {\n        __Pausable_init_unchained();\n    }\n\n    function __Pausable_init_unchained() internal onlyInitializing {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        require(!paused(), \"Pausable: paused\");\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        require(paused(), \"Pausable: not paused\");\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n     * initialization step. This is essential to configure modules that are added through upgrades and that require\n     * initialization.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized < type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n    /* solhint-disable var-name-mixedcase */\n    bytes32 private _HASHED_NAME;\n    bytes32 private _HASHED_VERSION;\n    bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n    /* solhint-enable var-name-mixedcase */\n\n    /**\n     * @dev Initializes the domain separator and parameter caches.\n     *\n     * The meaning of `name` and `version` is specified in\n     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n     *\n     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n     * - `version`: the current major version of the signing domain.\n     *\n     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n     * contract upgrade].\n     */\n    function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n        __EIP712_init_unchained(name, version);\n    }\n\n    function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n        bytes32 hashedName = keccak256(bytes(name));\n        bytes32 hashedVersion = keccak256(bytes(version));\n        _HASHED_NAME = hashedName;\n        _HASHED_VERSION = hashedVersion;\n    }\n\n    /**\n     * @dev Returns the domain separator for the current chain.\n     */\n    function _domainSeparatorV4() internal view returns (bytes32) {\n        return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n    }\n\n    function _buildDomainSeparator(\n        bytes32 typeHash,\n        bytes32 nameHash,\n        bytes32 versionHash\n    ) private view returns (bytes32) {\n        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n    }\n\n    /**\n     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n     * function returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n     *\n     * ```solidity\n     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n     *     keccak256(\"Mail(address to,string contents)\"),\n     *     mailTo,\n     *     keccak256(bytes(mailContents))\n     * )));\n     * address signer = ECDSA.recover(digest, signature);\n     * ```\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n        return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n    }\n\n    /**\n     * @dev The hash of the name parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712NameHash() internal virtual view returns (bytes32) {\n        return _HASHED_NAME;\n    }\n\n    /**\n     * @dev The hash of the version parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712VersionHash() internal virtual view returns (bytes32) {\n        return _HASHED_VERSION;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS,\n        InvalidSignatureV\n    }\n\n    function _throwError(RecoverError error) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert(\"ECDSA: invalid signature\");\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert(\"ECDSA: invalid signature length\");\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert(\"ECDSA: invalid signature 's' value\");\n        } else if (error == RecoverError.InvalidSignatureV) {\n            revert(\"ECDSA: invalid signature 'v' value\");\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature` or error string. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-assembly\n            assembly {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength);\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, signature);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address, RecoverError) {\n        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n        uint8 v = uint8((uint256(vs) >> 255) + 27);\n        return tryRecover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     *\n     * _Available since v4.2._\n     */\n    function recover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address, RecoverError) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS);\n        }\n        if (v != 27 && v != 28) {\n            return (address(0), RecoverError.InvalidSignatureV);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature);\n        }\n\n        return (signer, RecoverError.NoError);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from `s`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Typed Data, created from a\n     * `domainSeparator` and a `structHash`. This produces hash corresponding\n     * to the one signed with the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n     * JSON-RPC method as part of EIP-712.\n     *\n     * See {recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n    struct Counter {\n        // This variable should never be directly accessed by users of the library: interactions must be restricted to\n        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n        // this feature: see https://github.com/ethereum/solidity/issues/4637\n        uint256 _value; // default: 0\n    }\n\n    function current(Counter storage counter) internal view returns (uint256) {\n        return counter._value;\n    }\n\n    function increment(Counter storage counter) internal {\n        unchecked {\n            counter._value += 1;\n        }\n    }\n\n    function decrement(Counter storage counter) internal {\n        uint256 value = counter._value;\n        require(value > 0, \"Counter: decrement overflow\");\n        unchecked {\n            counter._value = value - 1;\n        }\n    }\n\n    function reset(Counter storage counter) internal {\n        counter._value = 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n    bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        // Inspired by OraclizeAPI's implementation - MIT licence\n        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n        if (value == 0) {\n            return \"0\";\n        }\n        uint256 temp = value;\n        uint256 digits;\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n        bytes memory buffer = new bytes(digits);\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return \"0x00\";\n        }\n        uint256 temp = value;\n        uint256 length = 0;\n        while (temp != 0) {\n            length++;\n            temp >>= 8;\n        }\n        return toHexString(value, length);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _HEX_SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/IERC20HistoryUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA ERC20 History Upgradeable Contract.\n * @author SOMA.finance\n * @notice An ERC20 extension to keep a history of each account's voting balance.\n */\ninterface IERC20HistoryUpgradeable {\n    /**\n     * @notice Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n     * @param account The account that had a change in balance.\n     * @param previousBalance The previous balance of `account`.\n     * @param newBalance The new balance of `account`.\n     */\n    event BalanceChanged(address indexed account, uint256 previousBalance, uint256 newBalance);\n\n    /**\n     * @notice Returns the balance for `account` at the end of `blockNumber`.\n     * @param account The account to return the past balance of.\n     * @param blockNumber The block number to return ``account``'s balance at.\n     * @custom:requirement `blockNumber` must have been already mined.\n     * @return The balance of `account` at `blockNumber`.\n     */\n    function getPastBalance(address account, uint256 blockNumber) external view returns (uint256);\n\n    /**\n     * @notice Returns the total supply of votes available at the end of a past block (`blockNumber`).\n     * @dev This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n     * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n     * vote.\n     * @param blockNumber The block number to return the total supply at.\n     * @custom:requirement `blockNumber` must have been already mined.\n     * @return The total supply at `blockNumber`.\n     */\n    function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a >= b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1);\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator,\n        Rounding rounding\n    ) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`.\n        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n        // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1;\n        uint256 x = a;\n        if (x >> 128 > 0) {\n            x >>= 128;\n            result <<= 64;\n        }\n        if (x >> 64 > 0) {\n            x >>= 64;\n            result <<= 32;\n        }\n        if (x >> 32 > 0) {\n            x >>= 32;\n            result <<= 16;\n        }\n        if (x >> 16 > 0) {\n            x >>= 16;\n            result <<= 8;\n        }\n        if (x >> 8 > 0) {\n            x >>= 8;\n            result <<= 4;\n        }\n        if (x >> 4 > 0) {\n            x >>= 4;\n            result <<= 2;\n        }\n        if (x >> 2 > 0) {\n            result <<= 1;\n        }\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = sqrt(a);\n        if (rounding == Rounding.Up && result * result < a) {\n            result += 1;\n        }\n        return result;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\n    /**\n     * @dev Returns the downcasted uint248 from uint256, reverting on\n     * overflow (when the input is greater than largest uint248).\n     *\n     * Counterpart to Solidity's `uint248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint248(uint256 value) internal pure returns (uint248) {\n        require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n        return uint248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint240 from uint256, reverting on\n     * overflow (when the input is greater than largest uint240).\n     *\n     * Counterpart to Solidity's `uint240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint240(uint256 value) internal pure returns (uint240) {\n        require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n        return uint240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint232 from uint256, reverting on\n     * overflow (when the input is greater than largest uint232).\n     *\n     * Counterpart to Solidity's `uint232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint232(uint256 value) internal pure returns (uint232) {\n        require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n        return uint232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     *\n     * _Available since v4.2._\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint216 from uint256, reverting on\n     * overflow (when the input is greater than largest uint216).\n     *\n     * Counterpart to Solidity's `uint216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint216(uint256 value) internal pure returns (uint216) {\n        require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n        return uint216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint208 from uint256, reverting on\n     * overflow (when the input is greater than largest uint208).\n     *\n     * Counterpart to Solidity's `uint208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint208(uint256 value) internal pure returns (uint208) {\n        require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n        return uint208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint200 from uint256, reverting on\n     * overflow (when the input is greater than largest uint200).\n     *\n     * Counterpart to Solidity's `uint200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint200(uint256 value) internal pure returns (uint200) {\n        require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n        return uint200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint192 from uint256, reverting on\n     * overflow (when the input is greater than largest uint192).\n     *\n     * Counterpart to Solidity's `uint192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint192(uint256 value) internal pure returns (uint192) {\n        require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n        return uint192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint184 from uint256, reverting on\n     * overflow (when the input is greater than largest uint184).\n     *\n     * Counterpart to Solidity's `uint184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint184(uint256 value) internal pure returns (uint184) {\n        require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n        return uint184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint176 from uint256, reverting on\n     * overflow (when the input is greater than largest uint176).\n     *\n     * Counterpart to Solidity's `uint176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint176(uint256 value) internal pure returns (uint176) {\n        require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n        return uint176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint168 from uint256, reverting on\n     * overflow (when the input is greater than largest uint168).\n     *\n     * Counterpart to Solidity's `uint168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint168(uint256 value) internal pure returns (uint168) {\n        require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n        return uint168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint160 from uint256, reverting on\n     * overflow (when the input is greater than largest uint160).\n     *\n     * Counterpart to Solidity's `uint160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n        return uint160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint152 from uint256, reverting on\n     * overflow (when the input is greater than largest uint152).\n     *\n     * Counterpart to Solidity's `uint152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint152(uint256 value) internal pure returns (uint152) {\n        require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n        return uint152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint144 from uint256, reverting on\n     * overflow (when the input is greater than largest uint144).\n     *\n     * Counterpart to Solidity's `uint144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint144(uint256 value) internal pure returns (uint144) {\n        require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n        return uint144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint136 from uint256, reverting on\n     * overflow (when the input is greater than largest uint136).\n     *\n     * Counterpart to Solidity's `uint136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint136(uint256 value) internal pure returns (uint136) {\n        require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n        return uint136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint120 from uint256, reverting on\n     * overflow (when the input is greater than largest uint120).\n     *\n     * Counterpart to Solidity's `uint120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint120(uint256 value) internal pure returns (uint120) {\n        require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n        return uint120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint112 from uint256, reverting on\n     * overflow (when the input is greater than largest uint112).\n     *\n     * Counterpart to Solidity's `uint112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint112(uint256 value) internal pure returns (uint112) {\n        require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n        return uint112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint104 from uint256, reverting on\n     * overflow (when the input is greater than largest uint104).\n     *\n     * Counterpart to Solidity's `uint104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint104(uint256 value) internal pure returns (uint104) {\n        require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n        return uint104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     *\n     * _Available since v4.2._\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint88 from uint256, reverting on\n     * overflow (when the input is greater than largest uint88).\n     *\n     * Counterpart to Solidity's `uint88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint88(uint256 value) internal pure returns (uint88) {\n        require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n        return uint88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint80 from uint256, reverting on\n     * overflow (when the input is greater than largest uint80).\n     *\n     * Counterpart to Solidity's `uint80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint80(uint256 value) internal pure returns (uint80) {\n        require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n        return uint80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint72 from uint256, reverting on\n     * overflow (when the input is greater than largest uint72).\n     *\n     * Counterpart to Solidity's `uint72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint72(uint256 value) internal pure returns (uint72) {\n        require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n        return uint72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint56 from uint256, reverting on\n     * overflow (when the input is greater than largest uint56).\n     *\n     * Counterpart to Solidity's `uint56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint56(uint256 value) internal pure returns (uint56) {\n        require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n        return uint56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint48 from uint256, reverting on\n     * overflow (when the input is greater than largest uint48).\n     *\n     * Counterpart to Solidity's `uint48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint48(uint256 value) internal pure returns (uint48) {\n        require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n        return uint48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint40 from uint256, reverting on\n     * overflow (when the input is greater than largest uint40).\n     *\n     * Counterpart to Solidity's `uint40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint40(uint256 value) internal pure returns (uint40) {\n        require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n        return uint40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint24 from uint256, reverting on\n     * overflow (when the input is greater than largest uint24).\n     *\n     * Counterpart to Solidity's `uint24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     *\n     * _Available since v4.7._\n     */\n    function toUint24(uint256 value) internal pure returns (uint24) {\n        require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n        return uint24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     *\n     * _Available since v2.5._\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     *\n     * _Available since v3.0._\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        require(value >= 0, \"SafeCast: value must be positive\");\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int248 from int256, reverting on\n     * overflow (when the input is less than smallest int248 or\n     * greater than largest int248).\n     *\n     * Counterpart to Solidity's `int248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt248(int256 value) internal pure returns (int248) {\n        require(value >= type(int248).min && value <= type(int248).max, \"SafeCast: value doesn't fit in 248 bits\");\n        return int248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int240 from int256, reverting on\n     * overflow (when the input is less than smallest int240 or\n     * greater than largest int240).\n     *\n     * Counterpart to Solidity's `int240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt240(int256 value) internal pure returns (int240) {\n        require(value >= type(int240).min && value <= type(int240).max, \"SafeCast: value doesn't fit in 240 bits\");\n        return int240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int232 from int256, reverting on\n     * overflow (when the input is less than smallest int232 or\n     * greater than largest int232).\n     *\n     * Counterpart to Solidity's `int232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt232(int256 value) internal pure returns (int232) {\n        require(value >= type(int232).min && value <= type(int232).max, \"SafeCast: value doesn't fit in 232 bits\");\n        return int232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int224 from int256, reverting on\n     * overflow (when the input is less than smallest int224 or\n     * greater than largest int224).\n     *\n     * Counterpart to Solidity's `int224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt224(int256 value) internal pure returns (int224) {\n        require(value >= type(int224).min && value <= type(int224).max, \"SafeCast: value doesn't fit in 224 bits\");\n        return int224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int216 from int256, reverting on\n     * overflow (when the input is less than smallest int216 or\n     * greater than largest int216).\n     *\n     * Counterpart to Solidity's `int216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt216(int256 value) internal pure returns (int216) {\n        require(value >= type(int216).min && value <= type(int216).max, \"SafeCast: value doesn't fit in 216 bits\");\n        return int216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int208 from int256, reverting on\n     * overflow (when the input is less than smallest int208 or\n     * greater than largest int208).\n     *\n     * Counterpart to Solidity's `int208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt208(int256 value) internal pure returns (int208) {\n        require(value >= type(int208).min && value <= type(int208).max, \"SafeCast: value doesn't fit in 208 bits\");\n        return int208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int200 from int256, reverting on\n     * overflow (when the input is less than smallest int200 or\n     * greater than largest int200).\n     *\n     * Counterpart to Solidity's `int200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt200(int256 value) internal pure returns (int200) {\n        require(value >= type(int200).min && value <= type(int200).max, \"SafeCast: value doesn't fit in 200 bits\");\n        return int200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int192 from int256, reverting on\n     * overflow (when the input is less than smallest int192 or\n     * greater than largest int192).\n     *\n     * Counterpart to Solidity's `int192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt192(int256 value) internal pure returns (int192) {\n        require(value >= type(int192).min && value <= type(int192).max, \"SafeCast: value doesn't fit in 192 bits\");\n        return int192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int184 from int256, reverting on\n     * overflow (when the input is less than smallest int184 or\n     * greater than largest int184).\n     *\n     * Counterpart to Solidity's `int184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt184(int256 value) internal pure returns (int184) {\n        require(value >= type(int184).min && value <= type(int184).max, \"SafeCast: value doesn't fit in 184 bits\");\n        return int184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int176 from int256, reverting on\n     * overflow (when the input is less than smallest int176 or\n     * greater than largest int176).\n     *\n     * Counterpart to Solidity's `int176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt176(int256 value) internal pure returns (int176) {\n        require(value >= type(int176).min && value <= type(int176).max, \"SafeCast: value doesn't fit in 176 bits\");\n        return int176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int168 from int256, reverting on\n     * overflow (when the input is less than smallest int168 or\n     * greater than largest int168).\n     *\n     * Counterpart to Solidity's `int168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt168(int256 value) internal pure returns (int168) {\n        require(value >= type(int168).min && value <= type(int168).max, \"SafeCast: value doesn't fit in 168 bits\");\n        return int168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int160 from int256, reverting on\n     * overflow (when the input is less than smallest int160 or\n     * greater than largest int160).\n     *\n     * Counterpart to Solidity's `int160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt160(int256 value) internal pure returns (int160) {\n        require(value >= type(int160).min && value <= type(int160).max, \"SafeCast: value doesn't fit in 160 bits\");\n        return int160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int152 from int256, reverting on\n     * overflow (when the input is less than smallest int152 or\n     * greater than largest int152).\n     *\n     * Counterpart to Solidity's `int152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt152(int256 value) internal pure returns (int152) {\n        require(value >= type(int152).min && value <= type(int152).max, \"SafeCast: value doesn't fit in 152 bits\");\n        return int152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int144 from int256, reverting on\n     * overflow (when the input is less than smallest int144 or\n     * greater than largest int144).\n     *\n     * Counterpart to Solidity's `int144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt144(int256 value) internal pure returns (int144) {\n        require(value >= type(int144).min && value <= type(int144).max, \"SafeCast: value doesn't fit in 144 bits\");\n        return int144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int136 from int256, reverting on\n     * overflow (when the input is less than smallest int136 or\n     * greater than largest int136).\n     *\n     * Counterpart to Solidity's `int136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt136(int256 value) internal pure returns (int136) {\n        require(value >= type(int136).min && value <= type(int136).max, \"SafeCast: value doesn't fit in 136 bits\");\n        return int136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt128(int256 value) internal pure returns (int128) {\n        require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n        return int128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int120 from int256, reverting on\n     * overflow (when the input is less than smallest int120 or\n     * greater than largest int120).\n     *\n     * Counterpart to Solidity's `int120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt120(int256 value) internal pure returns (int120) {\n        require(value >= type(int120).min && value <= type(int120).max, \"SafeCast: value doesn't fit in 120 bits\");\n        return int120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int112 from int256, reverting on\n     * overflow (when the input is less than smallest int112 or\n     * greater than largest int112).\n     *\n     * Counterpart to Solidity's `int112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt112(int256 value) internal pure returns (int112) {\n        require(value >= type(int112).min && value <= type(int112).max, \"SafeCast: value doesn't fit in 112 bits\");\n        return int112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int104 from int256, reverting on\n     * overflow (when the input is less than smallest int104 or\n     * greater than largest int104).\n     *\n     * Counterpart to Solidity's `int104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt104(int256 value) internal pure returns (int104) {\n        require(value >= type(int104).min && value <= type(int104).max, \"SafeCast: value doesn't fit in 104 bits\");\n        return int104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int96 from int256, reverting on\n     * overflow (when the input is less than smallest int96 or\n     * greater than largest int96).\n     *\n     * Counterpart to Solidity's `int96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt96(int256 value) internal pure returns (int96) {\n        require(value >= type(int96).min && value <= type(int96).max, \"SafeCast: value doesn't fit in 96 bits\");\n        return int96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int88 from int256, reverting on\n     * overflow (when the input is less than smallest int88 or\n     * greater than largest int88).\n     *\n     * Counterpart to Solidity's `int88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt88(int256 value) internal pure returns (int88) {\n        require(value >= type(int88).min && value <= type(int88).max, \"SafeCast: value doesn't fit in 88 bits\");\n        return int88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int80 from int256, reverting on\n     * overflow (when the input is less than smallest int80 or\n     * greater than largest int80).\n     *\n     * Counterpart to Solidity's `int80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt80(int256 value) internal pure returns (int80) {\n        require(value >= type(int80).min && value <= type(int80).max, \"SafeCast: value doesn't fit in 80 bits\");\n        return int80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int72 from int256, reverting on\n     * overflow (when the input is less than smallest int72 or\n     * greater than largest int72).\n     *\n     * Counterpart to Solidity's `int72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt72(int256 value) internal pure returns (int72) {\n        require(value >= type(int72).min && value <= type(int72).max, \"SafeCast: value doesn't fit in 72 bits\");\n        return int72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt64(int256 value) internal pure returns (int64) {\n        require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n        return int64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int56 from int256, reverting on\n     * overflow (when the input is less than smallest int56 or\n     * greater than largest int56).\n     *\n     * Counterpart to Solidity's `int56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt56(int256 value) internal pure returns (int56) {\n        require(value >= type(int56).min && value <= type(int56).max, \"SafeCast: value doesn't fit in 56 bits\");\n        return int56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int48 from int256, reverting on\n     * overflow (when the input is less than smallest int48 or\n     * greater than largest int48).\n     *\n     * Counterpart to Solidity's `int48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt48(int256 value) internal pure returns (int48) {\n        require(value >= type(int48).min && value <= type(int48).max, \"SafeCast: value doesn't fit in 48 bits\");\n        return int48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int40 from int256, reverting on\n     * overflow (when the input is less than smallest int40 or\n     * greater than largest int40).\n     *\n     * Counterpart to Solidity's `int40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt40(int256 value) internal pure returns (int40) {\n        require(value >= type(int40).min && value <= type(int40).max, \"SafeCast: value doesn't fit in 40 bits\");\n        return int40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt32(int256 value) internal pure returns (int32) {\n        require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n        return int32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int24 from int256, reverting on\n     * overflow (when the input is less than smallest int24 or\n     * greater than largest int24).\n     *\n     * Counterpart to Solidity's `int24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     *\n     * _Available since v4.7._\n     */\n    function toInt24(int256 value) internal pure returns (int24) {\n        require(value >= type(int24).min && value <= type(int24).max, \"SafeCast: value doesn't fit in 24 bits\");\n        return int24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt16(int256 value) internal pure returns (int16) {\n        require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n        return int16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt8(int256 value) internal pure returns (int8) {\n        require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n        return int8(value);\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     *\n     * _Available since v3.0._\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n        return int256(value);\n    }\n}\n"
      },
      "contracts/soma/SomaGuard/utils/MultiGuardableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"../../SomaAccessControl/utils/AccessibleUpgradeable.sol\";\n\nimport \"../ISomaGuard.sol\";\n\nimport \"./GuardHelper.sol\";\nimport \"./IMultiGuardable.sol\";\n\n/**\n * @notice Implementation of the {IGuardable} interface.\n */\nabstract contract MultiGuardableUpgradeable is IMultiGuardable, AccessibleUpgradeable {\n    /**\n     * @notice Initializer for extended contracts.\n     */\n    function __Guardable__init() internal {\n        __Context_init_unchained();\n        __ERC165_init_unchained();\n        __Guardable__init_unchained();\n        __SomaContract_init_unchained();\n        __Accessible_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    /**\n     * @notice Unchained initializer for extended contracts.\n     */\n    function __Guardable__init_unchained() internal onlyInitializing {\n        LOCAL_UPDATE_PRIVILEGES_ROLE = keccak256(abi.encodePacked(address(this), GLOBAL_UPDATE_PRIVILEGES_ROLE));\n        _updateRequiredPrivileges(DEFAULT_ID, bytes32(type(uint256).max));\n    }\n\n    bytes32 public immutable DEFAULT_PRIVILEGES = GuardHelper.DEFAULT_PRIVILEGES;\n    bytes32 public immutable DEFAULT_ID = 0x00;\n    bytes32 public constant GLOBAL_UPDATE_PRIVILEGES_ROLE = keccak256(\"Guardable.GLOBAL_UPDATE_PRIVILEGES_ROLE\");\n\n    bytes32 public LOCAL_UPDATE_PRIVILEGES_ROLE;\n    mapping(bytes32 => bytes32) private _requiredPrivileges;\n\n    /**\n     * @notice Modifier restricting a function call to accounts that have the required privileges.\n     */\n    modifier onlyApprovedPrivileges(address sender) {\n        require(hasPrivileges(sender), \"required privileges not met\");\n        _;\n    }\n\n    /**\n     * @inheritdoc IMultiGuardable\n     */\n    function hasPrivileges(address account) public view virtual override returns (bool) {\n        return hasPrivileges(DEFAULT_ID, account);\n    }\n\n    /**\n     * @inheritdoc IMultiGuardable\n     */\n    function hasPrivileges(bytes32 id, address account) public view virtual override returns (bool) {\n        return ISomaGuard(SOMA.guard()).check(account, requiredPrivileges(id));\n    }\n\n    /**\n     * @inheritdoc IMultiGuardable\n     */\n    function requiredPrivileges() public view virtual override returns (bytes32) {\n        return requiredPrivileges(DEFAULT_ID);\n    }\n\n    /**\n     * @inheritdoc IMultiGuardable\n     */\n    function requiredPrivileges(bytes32 id) public view virtual override returns (bytes32) {\n        return _requiredPrivileges[id];\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IMultiGuardable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @inheritdoc IMultiGuardable\n     */\n    function updateRequiredPrivileges(bytes32 newRequiredPrivileges) public virtual override returns (bool) {\n        return updateRequiredPrivileges(DEFAULT_ID, newRequiredPrivileges);\n    }\n\n    /**\n     * @inheritdoc IMultiGuardable\n     */\n    function updateRequiredPrivileges(bytes32 id, bytes32 newRequiredPrivileges)\n        public\n        virtual\n        override\n        returns (bool)\n    {\n        require(\n            hasRole(LOCAL_UPDATE_PRIVILEGES_ROLE, _msgSender()) || hasRole(GLOBAL_UPDATE_PRIVILEGES_ROLE, _msgSender()),\n            \"Guardable: you do not have the required roles to do this\"\n        );\n        _updateRequiredPrivileges(id, newRequiredPrivileges);\n        return true;\n    }\n\n    function _updateRequiredPrivileges(bytes32 id, bytes32 newRequiredPrivileges) internal {\n        emit RequiredPrivilegesUpdated(id, _requiredPrivileges[id], newRequiredPrivileges, _msgSender());\n        _requiredPrivileges[id] = newRequiredPrivileges;\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/IERC20GuardPartition.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA ERC20 Guard Partition Contract.\n * @author SOMA.finance.\n * @notice Interface of the {ERC20GuardPartition} contract.\n */\ninterface IERC20GuardPartition {\n    /**\n     * @notice Checks that both `from` and `to` have the required privileges. Ignores address zero.\n     * @param from The address sending the tokens.\n     * @param to The address receiving the tokens.\n     * @param fromId The from partition id of the tokens.\n     * @param toId The to partition id of the tokens.\n     * @param amount The amount of tokens to transfer.\n     * @return True if the transfer is valid.\n     */\n    function canTransferFrom(address from, address to, bytes32 fromId, bytes32 toId, uint256 amount)\n        external\n        view\n        returns (bool);\n    /**\n     * @notice Checks that both `from` and `to` have the required privileges. Ignores address zero.\n     * @param from The address sending the tokens.\n     * @param to The address receiving the tokens.\n     * @param amount The amount of tokens to transfer.\n     * @return True if the transfer is valid.\n     */\n    function canTransferFrom(address from, address to, uint256 amount) external view returns (bool);\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/ERC20Partition.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\nimport \"./IERC20Partition.sol\";\n\nabstract contract ERC20Partition is ERC20Upgradeable, IERC20Partition {\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n\n    bytes32 public constant DEFAULT_PARTITION = 0x00;\n\n    mapping(address => EnumerableSet.Bytes32Set) private _partitions;\n    mapping(bytes32 => uint256) private _totalSupplies;\n    mapping(bytes32 => bool) private _deprecated;\n    mapping(address => mapping(bytes32 => uint256)) private _balances;\n    mapping(address => mapping(address => mapping(bytes32 => uint256))) private _allowances;\n\n    uint256[50] private __gap;\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply(bytes32 id) public view returns (uint256) {\n        return _totalSupplies[id];\n    }\n\n    /**\n     * @dev Returns a boolean indicating if a partition is deprecated.\n     */\n    function deprecated(bytes32 id) public view returns (bool) {\n        return _deprecated[id];\n    }\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account, bytes32 id) public view returns (uint256) {\n        return _balances[account][id];\n    }\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, bytes32 id, uint256 amount, bytes memory data) public returns (bool) {\n        address owner = _msgSender();\n        _transfer(owner, to, id, id, amount, data);\n        return true;\n    }\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender, bytes32 id) public view returns (uint256) {\n        return _allowances[owner][spender][id];\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, bytes32 id, uint256 amount, bytes memory data) public returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, id, amount, data);\n        return true;\n    }\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, bytes32 id, uint256 amount, bytes memory data)\n        public\n        returns (bool)\n    {\n        address spender = _msgSender();\n        _spendAllowance(from, spender, id, amount, data);\n        _transfer(from, to, id, id, amount, data);\n        return true;\n    }\n\n    function _transfer(address from, address to, uint256 amount) internal virtual override {\n        require(from != address(0), \"ERC20Partition: transfer from the zero address\");\n        require(to != address(0), \"ERC20Partition: transfer to the zero address\");\n\n        EnumerableSet.Bytes32Set storage _userPartitions = _partitions[from];\n\n        uint256 _remainingBalance = amount;\n        uint256 _fromBalance = _balances[from][DEFAULT_PARTITION];\n        uint256 _useAmount;\n\n        if (_fromBalance > 0) {\n            _useAmount = _calculateUseAmount(_fromBalance, _remainingBalance);\n            _transferPartition(from, to, DEFAULT_PARTITION, DEFAULT_PARTITION, _fromBalance, _useAmount, \"\");\n\n            unchecked {\n                _remainingBalance -= _useAmount;\n            }\n        }\n\n        if (_remainingBalance > 0) {\n            uint256 _totalPartitions = _userPartitions.length();\n\n            uint256 i;\n            while (i < _totalPartitions) {\n                bytes32 _id = _userPartitions.at(i);\n                _fromBalance = _balances[from][_id];\n                if (_fromBalance == 0) continue;\n\n                _useAmount = _calculateUseAmount(_fromBalance, _remainingBalance);\n\n                unchecked {\n                    _remainingBalance -= _useAmount;\n                }\n\n                _transferPartition(from, to, _id, _id, _fromBalance, _useAmount, \"\");\n\n                if (_fromBalance == _useAmount) {\n                    unchecked {\n                        _totalPartitions--;\n                    }\n                } else {\n                    unchecked {\n                        i++;\n                    }\n                }\n            }\n\n            require(_remainingBalance > 0, \"ERC20Partition: transfer amount exceeds balance\");\n        }\n\n        super._transfer(from, to, amount);\n    }\n\n    function _transferPartition(\n        address from,\n        address to,\n        bytes32 fromPartitionId,\n        bytes32 toPartitionId,\n        uint256 fromBalance,\n        uint256 amount,\n        bytes memory data\n    ) internal virtual {\n        if (toPartitionId != DEFAULT_PARTITION && _deprecated[toPartitionId]) {\n            toPartitionId = DEFAULT_PARTITION;\n        }\n\n        require(fromBalance >= amount, \"ERC20Partition: insufficient partition balance\");\n\n        _beforeTokenTransfer(from, to, fromPartitionId, toPartitionId, amount, data);\n\n        unchecked {\n            _balances[from][fromPartitionId] = fromBalance - amount;\n            _balances[to][toPartitionId] += amount;\n        }\n\n        if (fromBalance == amount && fromPartitionId != DEFAULT_PARTITION) {\n            _partitions[from].remove(fromPartitionId);\n        }\n\n        if (toPartitionId != DEFAULT_PARTITION) {\n            _partitions[to].add(toPartitionId);\n        }\n\n        if (fromPartitionId != toPartitionId) {\n            uint256 _fromTotalSupply = _totalSupplies[fromPartitionId];\n\n            unchecked {\n                _totalSupplies[fromPartitionId] = _fromTotalSupply - amount;\n                _totalSupplies[toPartitionId] += amount;\n            }\n\n            if (_fromTotalSupply == amount) {\n                delete _deprecated[fromPartitionId];\n            }\n        }\n\n        emit TransferPartition(from, to, fromPartitionId, toPartitionId, amount, data);\n\n        _afterTokenTransfer(from, to, fromPartitionId, toPartitionId, amount, data);\n    }\n\n    /**\n     * @dev Moves `amount` of tokens from `from` to `to`.\n     *\n     * This internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     */\n    function _transfer(address from, address to, bytes32 fromId, bytes32 toId, uint256 amount, bytes memory data)\n        internal\n        virtual\n    {\n        require(from != address(0), \"ERC20Partition: transfer from the zero address\");\n        require(to != address(0), \"ERC20Partition: transfer to the zero address\");\n\n        _transferPartition(from, to, fromId, toId, _balances[from][fromId], amount, data);\n\n        super._transfer(from, to, amount);\n    }\n\n    /**\n     * @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function _mint(address account, bytes32 id, uint256 amount, bytes memory data) internal virtual {\n        require(account != address(0), \"ERC20Partition: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, id, id, amount, data);\n\n        _totalSupplies[id] += amount;\n        unchecked {\n            _balances[account][id] += amount;\n        }\n\n        if (id != DEFAULT_PARTITION) {\n            _partitions[account].add(id);\n        }\n\n        emit TransferPartition(address(0), account, id, id, amount, data);\n\n        super._mint(account, amount);\n\n        _afterTokenTransfer(address(0), account, id, id, amount, data);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, bytes32 id, uint256 amount, bytes memory data) internal virtual {\n        require(account != address(0), \"ERC20Partition: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), id, id, amount, data);\n\n        uint256 accountBalance = _balances[account][id];\n        require(accountBalance >= amount, \"ERC20Partition: burn amount exceeds balance\");\n        unchecked {\n            _balances[account][id] = accountBalance - amount;\n        }\n        _totalSupplies[id] -= amount;\n\n        if (id != DEFAULT_PARTITION && amount == accountBalance) {\n            _partitions[account].remove(id);\n        }\n\n        emit TransferPartition(account, address(0), id, id, amount, data);\n\n        super._burn(account, amount);\n\n        _afterTokenTransfer(account, address(0), id, id, amount, data);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(address owner, address spender, bytes32 id, uint256 amount, bytes memory data) internal virtual {\n        require(owner != address(0), \"ERC20Partition: approve from the zero address\");\n        require(spender != address(0), \"ERC20Partition: approve to the zero address\");\n\n        _allowances[owner][spender][id] = amount;\n        emit ApprovalPartition(owner, spender, id, amount, data);\n    }\n\n    /**\n     * @dev Deprecates a partition.\n     *\n     * Emits an {DeprecatePartition} event.\n     *\n     * Requirements:\n     *\n     * - `id` cannot be an already deprecated partition.\n     * - `id` cannot be the DEFAULT_PARTITION.\n     */\n    function _deprecatePartition(bytes32 id, bytes memory data) internal virtual {\n        require(!_deprecated[id], \"ERC20Partition: already deprecated\");\n        require(id != DEFAULT_PARTITION, \"ERC20Partition: cannot deprecate the default partition\");\n\n        _deprecated[id] = true;\n        emit DeprecatePartition(id, data);\n    }\n\n    /**\n     *\n     * Does not update the allowance amount in case of infinite allowance.\n     * Revert if not enough allowance is available.\n     *\n     * Might emit an {Approval} event.\n     */\n    function _spendAllowance(address owner, address spender, bytes32 id, uint256 amount, bytes memory data)\n        internal\n        virtual\n    {\n        uint256 currentAllowance = allowance(owner, spender, id);\n        if (currentAllowance == type(uint256).max) return;\n        if (currentAllowance >= amount) {\n            unchecked {\n                _approve(owner, spender, id, currentAllowance - amount, data);\n            }\n        } else {\n            if (currentAllowance > 0) {\n                _approve(owner, spender, id, 0, data);\n            }\n            unchecked {\n                _spendAllowance(owner, spender, amount - currentAllowance);\n            }\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        bytes32 fromId,\n        bytes32 toId,\n        uint256 amount,\n        bytes memory data\n    ) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * has been transferred to `to`.\n     * - when `from` is zero, `amount` tokens have been minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(\n        address from,\n        address to,\n        bytes32 fromId,\n        bytes32 toId,\n        uint256 amount,\n        bytes memory data\n    ) internal virtual {}\n\n    function _calculateUseAmount(uint256 balance, uint256 amount) private pure returns (uint256 useAmount) {\n        unchecked {\n            useAmount = balance > amount ? amount : balance;\n        }\n    }\n}\n"
      },
      "contracts/soma/SomaAccessControl/utils/AccessibleUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\nimport \"@openzeppelin/contracts/access/IAccessControl.sol\";\n\nimport \"../../utils/security/IPausable.sol\";\nimport \"../../utils/SomaContractUpgradeable.sol\";\n\nimport \"../ISomaAccessControl.sol\";\nimport \"./IAccessible.sol\";\n\n/**\n * @title SOMA Accessible Upgradeable Contract.\n * @author SOMA.finance\n */\nabstract contract AccessibleUpgradeable is IAccessible, SomaContractUpgradeable {\n    /**\n     * @notice Initializer for extended contracts.\n     */\n    function __Accessible_init() internal onlyInitializing {\n        __ERC165_init_unchained();\n        __Context_init_unchained();\n        __SomaContract_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n        __Accessible_init_unchained();\n    }\n\n    /**\n     * @notice Unchained initializer for extended contracts.\n     */\n    function __Accessible_init_unchained() internal onlyInitializing {}\n\n    /**\n     * @notice The modifier that restricts a function caller to accounts that have been granted `role`.\n     * @param role The role that an account must have to execute a function.\n     */\n    modifier onlyRole(bytes32 role) {\n        require(hasRole(role, _msgSender()), \"SomaAccessControl: caller does not have the appropriate authority\");\n        _;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessible).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @inheritdoc IAccessible\n     */\n    // slither-disable-next-line external-function\n    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {\n        return IAccessControlUpgradeable(SOMA.access()).getRoleAdmin(role);\n    }\n\n    /**\n     * @inheritdoc IAccessible\n     */\n    function hasRole(bytes32 role, address account) public view override returns (bool) {\n        return IAccessControlUpgradeable(SOMA.access()).hasRole(role, account);\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/SomaGuard/ISomaGuard.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @title SOMA Guard Contract.\n * @author SOMA.finance\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n * @notice A contract to batch update account privileges.\n */\ninterface ISomaGuard {\n    /**\n     * @notice Emitted when privileges for a 2D array of accounts are updated.\n     * @param accounts The 2D array of addresses.\n     * @param privileges The array of privileges.\n     * @param sender The address of the message sender.\n     */\n    event BatchUpdate(address[][] accounts, bytes32[] privileges, address indexed sender);\n\n    /**\n     * @notice Emitted when privileges for an array of accounts are updated.\n     * @param accounts The array of addresses.\n     * @param access The array of privileges.\n     * @param sender The address of the message sender.\n     */\n    event BatchUpdateSingle(address[] accounts, bytes32[] access, address indexed sender);\n\n    /**\n     * @notice Returns the default privileges of the SomaGuard contract.\n     * @dev Returns bytes32(uint256(2 ** 64 - 1)).\n     */\n    function DEFAULT_PRIVILEGES() external view returns (bytes32);\n\n    /**\n     * @notice Returns the operator role of the SomaGuard contract.\n     * @dev Returns keccak256('SomaGuard.OPERATOR_ROLE').\n     */\n    function OPERATOR_ROLE() external view returns (bytes32);\n\n    /**\n     * @notice Returns the privilege of an account.\n     * @param account The account to return the privilege of.\n     */\n    function privileges(address account) external view returns (bytes32);\n\n    /**\n     * @notice Returns True if an account passes a query, where query is the desired privileges.\n     * @param account The account to check the privileges of.\n     * @param query The desired privileges to check for.\n     */\n    function check(address account, bytes32 query) external view returns (bool);\n\n    /**\n     * @notice Returns the privileges for each account.\n     * @param accounts_ The array of accounts return the privileges of.\n     * @return privileges_ The array of privileges.\n     */\n    function batchFetch(address[] calldata accounts_) external view returns (bytes32[] memory privileges_);\n\n    /**\n     * @notice Updates the privileges of an array of accounts.\n     * @param accounts_ The array of addresses to accumulate privileges of.\n     * @param privileges_ The array of privileges to update the array of accounts with.\n     * @custom:emits BatchUpdateSingle\n     * @custom:requirement The length of `accounts_` must be equal to the length of `privileges_`.\n     * @custom:requirement The length of `accounts_` must be greater than zero.\n     * @custom:requirement The function caller must have the OPERATOR_ROLE.\n     * @return True if the batch update was successful.\n     */\n    function batchUpdate(address[] calldata accounts_, bytes32[] calldata privileges_) external returns (bool);\n\n    /**\n     * @notice Updates the privileges of a 2D array of accounts, where the child array of accounts are all assigned to the\n     * same privileges.\n     * @param accounts_ The array of addresses to accumulate privileges of.\n     * @param privileges_ The array of privileges to update the 2D array of accounts with.\n     * @custom:emits BatchUpdate\n     * @custom:requirement The length of `accounts_` must be equal to the length of `privileges_`.\n     * @custom:requirement The length of `accounts_` must be greater than zero.\n     * @custom:requirement The function caller must have the OPERATOR_ROLE.\n     * @return True if the batch update was successful.\n     */\n    function batchUpdate(address[][] calldata accounts_, bytes32[] calldata privileges_) external returns (bool);\n}\n"
      },
      "contracts/soma/SomaGuard/utils/GuardHelper.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"./IGuardable.sol\";\n\nlibrary GuardHelper {\n    // 00000000(192 0's repeated)111(64times)\n    // (64 default on, 192 default off)\n    bytes32 internal constant DEFAULT_PRIVILEGES = bytes32(uint256(2 ** 64 - 1));\n\n    function requiredPrivileges(address account) internal view returns (bytes32 privileges) {\n        // call to account with no code returns true\n        // call to account with code and no function returns false\n        // call to account with code and function returns true\n        (bool success, bytes memory returndata) =\n            account.staticcall(abi.encodePacked(IGuardable.requiredPrivileges.selector));\n        privileges = (success && (account.code.length > 0)) ? bytes32(returndata) : DEFAULT_PRIVILEGES;\n    }\n\n    function check(bytes32 privileges, bytes32 query) internal pure returns (bool) {\n        return privileges & query == query;\n    }\n\n    function mergePrivileges(bytes32 privileges1, bytes32 privileges2) internal pure returns (bytes32) {\n        return privileges1 | privileges2;\n    }\n\n    function mergePrivileges(bytes32 privileges1, bytes32 privileges2, bytes32 privileges3)\n        internal\n        pure\n        returns (bytes32)\n    {\n        return privileges1 | privileges2 | privileges3;\n    }\n\n    function switchOn(uint256[] memory ids, bytes32 base) internal pure returns (bytes32 result) {\n        result = base;\n        for (uint256 i; i < ids.length; ++i) {\n            result = result | bytes32(2 ** ids[i]);\n        }\n    }\n\n    function switchOff(uint256[] memory ids, bytes32 base) internal pure returns (bytes32 result) {\n        result = base;\n        for (uint256 i; i < ids.length; ++i) {\n            result = result & bytes32(type(uint256).max - 2 ** ids[i]);\n        }\n    }\n}\n"
      },
      "contracts/soma/SomaGuard/utils/IMultiGuardable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Guardable Upgradeable Contract.\n * @author SOMA.finance\n * @notice Interface of the {GuardableUpgradeable} contract.\n */\ninterface IMultiGuardable {\n    /**\n     * @notice Emitted when the required privileges are updated.\n     * @param id The id in question\n     * @param prevPrivileges The previous required privileges.\n     * @param newPrivileges The new required privileges.\n     * @param sender The message sender that triggered the event.\n     */\n    event RequiredPrivilegesUpdated(bytes32 id, bytes32 prevPrivileges, bytes32 newPrivileges, address indexed sender);\n\n    /**\n     * @notice Returns a boolean indicating if `account` has the required privileges.\n     * @param id The id to check against.\n     * @param account The account to check against the required privileges.\n     * @return True if `account` has the required privileges, False otherwise.\n     */\n    function hasPrivileges(bytes32 id, address account) external view returns (bool);\n\n    /**\n     * @notice Returns a boolean indicating if `account` has the required privileges.\n     * @param account The account to check against the required privileges.\n     * @return True if `account` has the required privileges, False otherwise.\n     */\n    function hasPrivileges(address account) external view returns (bool);\n\n    /**\n     * @notice Returns the required privileges.\n     */\n    function requiredPrivileges() external view returns (bytes32);\n\n    /**\n     * @notice Returns the required privileges.\n     * @param id The id to check against.\n     */\n    function requiredPrivileges(bytes32 id) external view returns (bytes32);\n\n    /**\n     * @notice Updates the required privileges.\n     * @param id The id to check against.\n     * @param newRequiredPrivileges The new required privileges.\n     * @custom:emits RequiredPrivilegesUpdated\n     * @custom:requirement The message sender must have either the LOCAL_UPDATE_PRIVILEGES_ROLE or the\n     * GLOBAL_UPDATE_PRIVILEGES_ROLE role.\n     * @return True if the update was successful.\n     */\n    function updateRequiredPrivileges(bytes32 id, bytes32 newRequiredPrivileges) external returns (bool);\n\n    /**\n     * @notice Updates the required privileges.\n     * @param newRequiredPrivileges The new required privileges.\n     * @custom:emits RequiredPrivilegesUpdated\n     * @custom:requirement The message sender must have either the LOCAL_UPDATE_PRIVILEGES_ROLE or the\n     * GLOBAL_UPDATE_PRIVILEGES_ROLE role.\n     * @return True if the update was successful.\n     */\n    function updateRequiredPrivileges(bytes32 newRequiredPrivileges) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControlUpgradeable {\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"
      },
      "@openzeppelin/contracts/access/IAccessControl.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"
      },
      "contracts/soma/utils/security/IPausable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\ninterface IPausable {\n    function paused() external view returns (bool);\n\n    function pause() external;\n\n    function unpause() external;\n}\n"
      },
      "contracts/soma/utils/SomaContractUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol\";\n\nimport \"../ISOMA.sol\";\nimport \"../SOMAlib.sol\";\n\nimport \"./ISomaContract.sol\";\n\ncontract SomaContractUpgradeable is ISomaContract, PausableUpgradeable, ERC165Upgradeable, MulticallUpgradeable {\n    function __SomaContract_init() internal onlyInitializing {\n        __ERC165_init_unchained();\n        __Context_init_unchained();\n        __SomaContract_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    function __SomaContract_init_unchained() internal onlyInitializing {}\n\n    ISOMA public immutable override SOMA = SOMAlib.SOMA;\n\n    modifier onlyMaster() {\n        address sender = _msgSender();\n        require(SOMA.master() == sender, \"SOMA: MASTER\");\n        _;\n    }\n\n    modifier onlyMasterOrSubMaster() {\n        address sender = _msgSender();\n        require(SOMA.master() == sender || SOMA.subMaster() == sender, \"SOMA: MASTER or SUB MASTER only\");\n        _;\n    }\n\n    function pause() external virtual override onlyMasterOrSubMaster {\n        _pause();\n    }\n\n    function unpause() external virtual override onlyMasterOrSubMaster {\n        _unpause();\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(ISomaContract).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    function paused() public view virtual override returns (bool) {\n        return PausableUpgradeable(address(SOMA)).paused() || super.paused();\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/SomaAccessControl/ISomaAccessControl.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Access Control Contract.\n * @author SOMA.finance.\n * @notice An access control contract that establishes a hierarchy of accounts and controls\n * function call permissions.\n */\ninterface ISomaAccessControl {\n    /**\n     * @notice Sets the admin of a role.\n     * @dev Sets the admin for the `role` role.\n     * @param role The role to set the admin role of.\n     * @param adminRole The admin of `role`.\n     * @custom:emits RoleAdminChanged\n     * @custom:requirement The function caller must have the DEFAULT_ADMIN_ROLE.\n     */\n    function setRoleAdmin(bytes32 role, bytes32 adminRole) external;\n}\n"
      },
      "contracts/soma/SomaAccessControl/utils/IAccessible.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Accessible Contract.\n * @author SOMA.finance\n * @notice Interface of the {Accessible} contract.\n */\ninterface IAccessible {\n    /**\n     * @notice Returns the role admin, given a role.\n     * @param role The role to return the admin of.\n     * @return The admin of the role.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @notice Returns a boolean indicating if `account` has been granted `role`.\n     * @param role The role to check against `account`.\n     * @param account The account to check against `role`.\n     * @return True if `account` has been granted `role`, False otherwise.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n    function __ERC165_init() internal onlyInitializing {\n    }\n\n    function __ERC165_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165Upgradeable).interfaceId;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./AddressUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides a function to batch together multiple calls in a single external call.\n *\n * _Available since v4.1._\n */\nabstract contract MulticallUpgradeable is Initializable {\n    function __Multicall_init() internal onlyInitializing {\n    }\n\n    function __Multicall_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev Receives and executes a batch of function calls on this contract.\n     */\n    function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {\n        results = new bytes[](data.length);\n        for (uint256 i = 0; i < data.length; i++) {\n            results[i] = _functionDelegateCall(address(this), data[i]);\n        }\n        return results;\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n        require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return AddressUpgradeable.verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/ISOMA.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"./SomaAccessControl/ISomaAccessControl.sol\";\nimport \"./SomaSwap/periphery/ISomaSwapRouter.sol\";\nimport \"./SomaSwap/core/interfaces/ISomaSwapFactory.sol\";\nimport \"./SomaGuard/ISomaGuard.sol\";\nimport \"./TemplateFactory/ITemplateFactory.sol\";\nimport \"./Lockdrop/ILockdropFactory.sol\";\n\n/**\n * @title SOMA Contract.\n * @author SOMA.finance\n * @notice Interface of the SOMA contract.\n */\ninterface ISOMA {\n    /**\n     * @notice Emitted when the SOMA snapshot is updated.\n     * @param version The version of the new snapshot.\n     * @param hash The hash of the new snapshot.\n     * @param snapshot The new snapshot.\n     */\n    event SOMAUpgraded(bytes32 indexed version, bytes32 indexed hash, bytes snapshot);\n\n    /**\n     * @notice Emitted when the `seizeTo` address is updated.\n     * @param prevSeizeTo The address of the previous `seizeTo`.\n     * @param newSeizeTo The address of the new `seizeTo`.\n     * @param sender The address of the message sender.\n     */\n    event SeizeToUpdated(address indexed prevSeizeTo, address indexed newSeizeTo, address indexed sender);\n\n    /**\n     * @notice Emitted when the `mintTo` address is updated.\n     * @param prevMintTo The address of the previous `mintTo`.\n     * @param newMintTo The address of the new `mintTo`.\n     * @param sender The address of the message sender.\n     */\n    event MintToUpdated(address indexed prevMintTo, address indexed newMintTo, address indexed sender);\n\n    /**\n     * @notice Snapshot of the SOMA contracts.\n     * @param master The master address.\n     * @param subMaster The subMaster address.\n     * @param access The ISomaAccessControl contract.\n     * @param guard The ISomaGuard contract.\n     * @param factory The ITemplateFactory contract.\n     * @param token The IERC20 contract.\n     */\n    struct Snapshot {\n        address master;\n        address subMaster;\n        address access;\n        address guard;\n        address factory;\n        address token;\n    }\n\n    /**\n     * @notice Returns the address that has been assigned the master role.\n     */\n    function master() external view returns (address);\n\n    /**\n     * @notice Returns the address that has been assigned the subMaster role.\n     */\n    function subMaster() external view returns (address);\n\n    /**\n     * @notice Returns the address of the {ISomaAccessControl} contract.\n     */\n    function access() external view returns (address);\n\n    /**\n     * @notice Returns the address of the {ISomaGuard} contract.\n     */\n    function guard() external view returns (address);\n\n    /**\n     * @notice Returns the address of the {ITemplateFactory} contract.\n     */\n    function factory() external view returns (address);\n\n    /**\n     * @notice Returns the address of the {IERC20} contract.\n     */\n    function token() external view returns (address);\n\n    /**\n     * @notice Returns the hash of the latest snapshot.\n     */\n    function snapshotHash() external view returns (bytes32);\n\n    /**\n     * @notice Returns the latest snapshot version.\n     */\n    function snapshotVersion() external view returns (bytes32);\n\n    /**\n     * @notice Returns the snapshot, given a snapshot hash.\n     * @param hash The snapshot hash.\n     * @return _snapshot The snapshot matching the `hash`.\n     */\n    function snapshots(bytes32 hash) external view returns (bytes memory _snapshot);\n\n    /**\n     * @notice Returns the hash when given a version, returns a version when given a hash.\n     * @param versionOrHash The version or hash.\n     * @return hashOrVersion The hash or version based on the input.\n     */\n    function versions(bytes32 versionOrHash) external view returns (bytes32 hashOrVersion);\n\n    /**\n     * @notice Returns the address that receives all minted tokens.\n     */\n    function mintTo() external view returns (address);\n\n    /**\n     * @notice Returns the address that receives all seized tokens.\n     */\n    function seizeTo() external view returns (address);\n\n    /**\n     * @notice Updates the current SOMA snapshot and is called after the proxy has been upgraded.\n     * @param version The version to upgrade to.\n     * @custom:emits SOMAUpgraded\n     * @custom:requirement The incoming snapshot hash cannot be equal to the contract's existing snapshot hash.\n     */\n    function __upgrade(bytes32 version) external;\n\n    /**\n     * @notice Triggers the SOMA paused state. Pauses all the SOMA contracts.\n     * @custom:emits Paused\n     * @custom:requirement SOMA must be already unpaused.\n     * @custom:requirement The caller must be the master or subMaster.\n     */\n    function pause() external;\n\n    /**\n     * @notice Triggers the SOMA unpaused state. Unpauses all the SOMA contracts.\n     * @custom:emits Unpaused\n     * @custom:requirement SOMA must be already paused.\n     * @custom:requirement The caller must be the master or subMaster.\n     */\n    function unpause() external;\n\n    /**\n     * @notice Sets the `mintTo` address to `_mintTo`.\n     * @param _mintTo The address to be set as the `mintTo` address.\n     * @custom:emits MintToUpdated\n     * @custom:requirement The caller must be the master.\n     */\n    function setMintTo(address _mintTo) external;\n\n    /**\n     * @notice Sets the `seizeTo` address to `_seizeTo`.\n     * @param _seizeTo The address to be set as the `seizeTo` address.\n     * @custom:emits SeizeToUpdated\n     * @custom:requirement The caller must be the master.\n     */\n    function setSeizeTo(address _seizeTo) external;\n\n    /**\n     * @notice Returns the current snapshot of the SOMA contracts.\n     */\n    function snapshot() external view returns (Snapshot memory _snapshot);\n}\n"
      },
      "contracts/soma/SOMAlib.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"./ISOMA.sol\";\n\nlibrary SOMAlib {\n    /**\n     * @notice The fixed address where the SOMA contract will be located (this is a proxy).\n     */\n    ISOMA public constant SOMA = ISOMA(0x0F3dC00189dbCD1D0c574e48031270cAe04C4ADF);\n}\n"
      },
      "contracts/soma/utils/ISomaContract.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nimport \"../ISOMA.sol\";\n\ninterface ISomaContract {\n    function pause() external;\n    function unpause() external;\n\n    function SOMA() external view returns (ISOMA);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"
      },
      "contracts/soma/SomaSwap/periphery/ISomaSwapRouter.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2;\n\n/**\n * @title SOMA Swap Router Contract.\n * @author SOMA.finance\n * @notice Interface for the {SomaSwapRouter} contract.\n */\ninterface ISomaSwapRouter {\n    /**\n     * @notice Returns the address of the factory contract.\n     */\n    function factory() external view returns (address);\n\n    /**\n     * @notice Returns the address of the WETH token.\n     */\n    function WETH() external view returns (address);\n\n    /**\n     * @notice Adds liquidity to the pool.\n     * @param tokenA The token0 of the pair to add liquidity to.\n     * @param tokenB The token1 of the pair to add liquidity to.\n     * @param amountADesired The amount of token0 to add as liquidity.\n     * @param amountBDesired The amount of token1 to add as liquidity.\n     * @param amountAMin The bound of the tokenB / tokenA price can go up\n     * before transaction reverts.\n     * @param amountBMin The bound of the tokenA / tokenB price can go up\n     * before transaction reverts.\n     * @param to The address to receive the liquidity tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement `tokenA` and `tokenB` pair must already exist.\n     * @custom:requirement the router's expiration deadline must be greater than the timestamp of the\n     * function call\n     * @return amountA The amount of tokenA added as liquidity.\n     * @return amountB The amount of tokenB added as liquidity.\n     * @return liquidity The amount of liquidity tokens minted.\n     */\n    function addLiquidity(\n        address tokenA,\n        address tokenB,\n        uint256 amountADesired,\n        uint256 amountBDesired,\n        uint256 amountAMin,\n        uint256 amountBMin,\n        address to,\n        uint256 deadline\n    ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);\n\n    /**\n     * @notice Adds liquidity to the pool with ETH.\n     * @param token The pool token.\n     * @param amountTokenDesired The amount of token to add as liquidity if WETH/token price\n     * is less or equal to the value of msg.value/amountTokenDesired (token depreciates).\n     * @param amountTokenMin The bound that WETH/token price can go up before the transactions\n     * reverts.\n     * @param amountETHMin The bound that token/WETH price can go up before the transaction reverts.\n     * @param to The recipient of the liquidity tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement `tokenA` and `tokenB` pair must already exist.\n     * @custom:requirement the router's expiration deadline must be greater than the timestamp of the\n     * function call\n     * @return amountToken The amount of token sent to the pool.\n     * @return amountETH The amount of ETH converted to WETH and sent to the pool.\n     * @return liquidity The amount of liquidity tokens minted.\n     */\n    function addLiquidityETH(\n        address token,\n        uint256 amountTokenDesired,\n        uint256 amountTokenMin,\n        uint256 amountETHMin,\n        address to,\n        uint256 deadline\n    ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);\n\n    /**\n     * @notice Removes liquidity from the pool.\n     * @param tokenA The pool token.\n     * @param tokenB The pool token.\n     * @param liquidity The amount of liquidity tokens to remove.\n     * @param amountAMin The minimum amount of tokenA that must be received\n     * for the transaction not to revert.\n     * @param amountBMin The minimum amount of tokenB that must be received\n     * for the transaction not to revert.\n     * @param to The recipient of the underlying asset.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement `amountA` must be greater than or equal to `amountAMin`.\n     * @custom:requirement `amountB` must be greater than or equal to `amountBMin`.\n     * @return amountA The amount of tokenA received.\n     * @return amountB The amount of tokenB received.\n     */\n    function removeLiquidity(\n        address tokenA,\n        address tokenB,\n        uint256 liquidity,\n        uint256 amountAMin,\n        uint256 amountBMin,\n        address to,\n        uint256 deadline\n    ) external returns (uint256 amountA, uint256 amountB);\n\n    /**\n     * @notice Removes liquidity from the pool and the caller receives ETH.\n     * @param token The pool token.\n     * @param liquidity The amount of liquidity tokens to remove.\n     * @param amountTokenMin The minimum amount of tokens that must be received\n     * for the transaction not to revert.\n     * @param amountETHMin The minimum amount of ETH that must be received for the\n     * transaction not to revert.\n     * @param to The recipient of the underlying assets.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement `amountA` must be greater than or equal to `amountAMin`.\n     * @custom:requirement `amountB` must be greater than or equal to `amountBMin`.\n     * @return amountToken The amount of token received.\n     * @return amountETH The amount of ETH received.\n     */\n    function removeLiquidityETH(\n        address token,\n        uint256 liquidity,\n        uint256 amountTokenMin,\n        uint256 amountETHMin,\n        address to,\n        uint256 deadline\n    ) external returns (uint256 amountToken, uint256 amountETH);\n\n    /**\n     * @notice Removes liquidity from the pool without pre-approval.\n     * @param tokenA The pool token0.\n     * @param tokenB The pool token1.\n     * @param liquidity The amount of liquidity to remove.\n     * @param amountAMin The minimum amount of tokenA that must be received for the\n     * transaction not to revert.\n     * @param amountBMin The minimum amount of tokenB that must be received for the\n     * transaction not to revert.\n     * @param to The recipient of the underlying asset.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @param approveMax Boolean value indicating if the approval amount in the signature\n     * is for liquidity or uint(-1).\n     * @param v The v component of the permit signature.\n     * @param r The r component of the permit signature.\n     * @param s The s component of the permit signature.\n     * @custom:requirement `amountA` must be greater than or equal to `amountAMin`.\n     * @custom:requirement `amountB` must be greater than or equal to `amountBMin`.\n     * @return amountA The amount of tokenA received.\n     * @return amountB The amount of tokenB received.\n     */\n    function removeLiquidityWithPermit(\n        address tokenA,\n        address tokenB,\n        uint256 liquidity,\n        uint256 amountAMin,\n        uint256 amountBMin,\n        address to,\n        uint256 deadline,\n        bool approveMax,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external returns (uint256 amountA, uint256 amountB);\n\n    /**\n     * @notice Removes liquidity from the pool and the caller receives ETH without pre-approval.\n     * @param token The pool token.\n     * @param liquidity The amount of liquidity to remove.\n     * @param amountTokenMin The minimum amount of token that must be received for the transaction\n     * not to revert.\n     * @param amountETHMin The minimum amount of ETH that must be received for the transaction not\n     * to revert.\n     * @param to The recipient of the underlying asset.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @param approveMax Boolean value indicating if the approval amount in the signature\n     * is for liquidity or uint(-1).\n     * @param v The v component of the permit signature.\n     * @param r The r component of the permit signature.\n     * @param s The s component of the permit signature.\n     * @return amountToken The amount fo token received.\n     * @return amountETH The amount of ETH received.\n     */\n    function removeLiquidityETHWithPermit(\n        address token,\n        uint256 liquidity,\n        uint256 amountTokenMin,\n        uint256 amountETHMin,\n        address to,\n        uint256 deadline,\n        bool approveMax,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external returns (uint256 amountToken, uint256 amountETH);\n\n    /**\n     * @notice Swaps an exact amount of input tokens for as many output tokens as possible, along\n     * with the route determined by the path.\n     * @param amountIn The amount of input tokens to send.\n     * @param amountOutMin The minimum amount of output tokens that must be received for the transaction\n     * not to revert.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @param to The recipient of the output tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement The value at the last index of `amounts` (from `SomaSwapLibrary.getAmountsOut()`) must be greater than or equal to `amountOutMin`.\n     * @return amounts The input token amount and all subsequent output token amounts.\n     */\n    function swapExactTokensForTokens(\n        uint256 amountIn,\n        uint256 amountOutMin,\n        address[] calldata path,\n        address to,\n        uint256 deadline\n    ) external returns (uint256[] memory amounts);\n\n    /**\n     * @notice Caller receives an exact amount of output tokens for as few input input tokens as possible, along\n     * with the route determined by the path.\n     * @param amountOut The amount of output tokens to receive.\n     * @param amountInMax The maximum amount of input tokens that can be required before the transaction reverts.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @param to The recipient of the output tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement The value of the first index of `amounts` (from `SomaSwapLibrary.getAmountsIn()`) must be less than or equal to `amountInMax`.\n     * @return amounts The input token amount and all subsequent output token amounts.\n     */\n    function swapTokensForExactTokens(\n        uint256 amountOut,\n        uint256 amountInMax,\n        address[] calldata path,\n        address to,\n        uint256 deadline\n    ) external returns (uint256[] memory amounts);\n\n    /**\n     * @notice Swaps an exact amount of ETH for as many output tokens as possible, along with the route\n     * determined by the path.\n     * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @param to The recipient of the output tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement The first element of `path` must be equal to the WETH address.\n     * @custom:requirement The last element of `amounts` (from `SomaSwapLibrary.getAmountsOut()`) must be greater than or equal to `amount0Min`.\n     * @return amounts The input token amount and all subsequent output token amounts.\n     */\n    function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline)\n        external\n        payable\n        returns (uint256[] memory amounts);\n\n    /**\n     * @notice Caller receives an exact amount of ETH for as few input tokens as possible, along with the route\n     * determined by the path.\n     * @param amountOut The amount of ETH to receive.\n     * @param amountInMax The maximum amount of input tokens that can be required before the transaction reverts.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @param to The recipient of the output tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement The last element of `path` must be equal to the WETH address.\n     * @custom:requirement The first element of `amounts` (from `SomaSwapLibrary.getAmountsIn()`) must be less than or equal to `amountInMax`.\n     * @return amounts The input token amount and all subsequent output token amounts.\n     */\n    function swapTokensForExactETH(\n        uint256 amountOut,\n        uint256 amountInMax,\n        address[] calldata path,\n        address to,\n        uint256 deadline\n    ) external returns (uint256[] memory amounts);\n\n    /**\n     * @notice Swaps an exact amount of tokens for as much ETH as possible, along with the route determined\n     * by the path.\n     * @param amountIn The amount of input tokens to send.\n     * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @param to The recipient of the output tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement The last element of `path` must be equal to the WETH address.\n     * @custom:requirement The last element of `amounts` (from `SomaSwapLibrary.getAmountsOut()`) must be greater than or\n     * equal to `amountOutMin`.\n     * @return amounts The input token amount and all subsequent output token amounts.\n     */\n    function swapExactTokensForETH(\n        uint256 amountIn,\n        uint256 amountOutMin,\n        address[] calldata path,\n        address to,\n        uint256 deadline\n    ) external returns (uint256[] memory amounts);\n\n    /**\n     * @notice Caller receives an exact amount of tokens for as little ETH as possible, along with the route determined\n     * by the path.\n     * @param amountOut The amount of tokens to receive.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @param to The recipient of the output tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement The first element of `path` must be equal to the WETH address.\n     * @custom:requirement The first element of `amounts` (from `SomaSwapLibrary.getAmountIn()`) must be less than or equal\n     * to the `msg.value`.\n     * @return amounts The input token amount and all subsequent output token amounts.\n     */\n    function swapETHForExactTokens(uint256 amountOut, address[] calldata path, address to, uint256 deadline)\n        external\n        payable\n        returns (uint256[] memory amounts);\n\n    /**\n     * @notice Given some asset amount and reserves, returns the amount of the other asset representing equivalent value.\n     * @param amountA The amount of token0.\n     * @param reserveA The reserves of token0.\n     * @param reserveB The reserves of token1.\n     * @custom:requirement `amountA` must be greater than zero.\n     * @custom:requirement `reserveA` must be greater than zero.\n     * @custom:requirement `reserveB` must be greater than zero.\n     * @return amountB The amount of token1.\n     */\n    function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB);\n\n    /**\n     * @notice Given some asset amount and reserves, returns the maximum output amount of the other asset (accounting for fees).\n     * @param amountIn The amount of the input token.\n     * @param reserveIn The reserves of the input token.\n     * @param reserveOut The reserves of the output token.\n     * @custom:requirement `amountIn` must be greater than zero.\n     * @custom:requirement `reserveIn` must be greater than zero.\n     * @custom:requirement `reserveOut` must be greater than zero.\n     * @return amountOut The amount of the output token.\n     */\n    function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)\n        external\n        pure\n        returns (uint256 amountOut);\n\n    /**\n     * @notice Returns the minimum input asset amount required to buy the given output asset amount (accounting for fees).\n     * @param amountOut The amount of the output token.\n     * @param reserveIn The reserves of the input token.\n     * @param reserveOut The reserves of the output token.\n     * @custom:requirement `amountOut` must be greater than zero.\n     * @custom:requirement `reserveIn` must be greater than zero.\n     * @custom:requirement `reserveOut` must be greater than zero.\n     * @return amountIn The required input amount of the input asset.\n     */\n    function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)\n        external\n        pure\n        returns (uint256 amountIn);\n\n    /**\n     * @notice Given an input asset amount and an array of token addresses, calculates all subsequent maximum output token amounts\n     * calling `getReserves()` for each pair of token addresses in the path in turn, and using these to call `getAmountOut()`.\n     * @param amountIn The amount of the input token.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @custom:requirement `path` length must be greater than or equal to 2.\n     * @return amounts The maximum output amounts.\n     */\n    function getAmountsOut(uint256 amountIn, address[] calldata path)\n        external\n        view\n        returns (uint256[] memory amounts);\n\n    /**\n     * @notice Given an output asset amount and an array of token addresses, calculates all preceding minimum input token amounts\n     * by calling `getReserves()` for each pair of token addresses in the path in turn, and using these to call `getAmountIn()`.\n     * @param amountOut The amount of the output token.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @custom:requirement `path` length must be greater than or equal to 2.\n     * @return amounts The required input amounts.\n     */\n    function getAmountsIn(uint256 amountOut, address[] calldata path)\n        external\n        view\n        returns (uint256[] memory amounts);\n\n    /**\n     * @notice See {ISomaSwapRouter-removeLiquidityETH} - Identical but succeeds for tokens that take a fee on transfer.\n     * @param token The pool token.\n     * @param liquidity The amount of liquidity tokens to remove.\n     * @param amountTokenMin The minimum amount of token that must be received for the transaction not to revert.\n     * @param amountETHMin The minimum amount of ETH that must be received for the transaction not to revert.\n     * @param to Recipient of the underlying assets.\n     * @param deadline Unix timestamp after which the transaction will revert.\n     * @custom:requirement There must be enough liquidity for both token amounts to be removed.\n     * @return amountETH The amount of ETH received.\n     */\n    function removeLiquidityETHSupportingFeeOnTransferTokens(\n        address token,\n        uint256 liquidity,\n        uint256 amountTokenMin,\n        uint256 amountETHMin,\n        address to,\n        uint256 deadline\n    ) external returns (uint256 amountETH);\n\n    /**\n     * @notice See {ISomaSwapRouter-removeLiquidityETHWithPermit} - Identical but succeeds for tokens that take a fee on transfer.\n     * @param token The pool token.\n     * @param liquidity The amount of liquidity tokens to remove.\n     * @param amountTokenMin The minimum amount of token that must be received for the transaction not to revert.\n     * @param amountETHMin The minimum amount of ETH that must be received for the transaction not to revert.\n     * @param to The recipient of the underlying assets.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @param approveMax Whether or not the approval amount in the signature is for liquidity or uint(-1).\n     * @param v The v component of the permit signature.\n     * @param r The r component of the permit signature.\n     * @param s The s component of the permit signature.\n     * @custom:requirement There must be enough liquidity for both token amounts to be removed.\n     * @return amountETH The amount of ETH received.\n     */\n    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n        address token,\n        uint256 liquidity,\n        uint256 amountTokenMin,\n        uint256 amountETHMin,\n        address to,\n        uint256 deadline,\n        bool approveMax,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external returns (uint256 amountETH);\n\n    /**\n     * @notice See {ISomaSwapRouter-swapExactTokensForTokens} - Identical but succeeds for tokens that take a fee on transfer.\n     * @param amountIn The amount of input tokens to send.\n     * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @param to The recipient of the underlying assets.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     */\n    function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n        uint256 amountIn,\n        uint256 amountOutMin,\n        address[] calldata path,\n        address to,\n        uint256 deadline\n    ) external;\n\n    /**\n     * @notice See {ISomaSwapRouter-swapExactETHForTokens} - Identical but succeeds for tokens that take a fee on transfer.\n     * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @param to The recipient of the output tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement The first element of `path` must be equal to the WETH address.\n     * @custom:requirement The increase in balance of the last element of `path` for the `to` address must be greater than\n     * or equal to `amountOutMin`.\n     */\n    function swapExactETHForTokensSupportingFeeOnTransferTokens(\n        uint256 amountOutMin,\n        address[] calldata path,\n        address to,\n        uint256 deadline\n    ) external payable;\n\n    /**\n     * @notice See {ISomaSwapRouter-swapExactTokensForETH} - Identical but succeeds for tokens that take a fee on transfer.\n     * @param amountIn The amount of input tokens to send.\n     * @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.\n     * @param path The array of token addresses, where pools for each pair of addresses must exist and\n     * have liquidity.\n     * @param to The recipient of the output tokens.\n     * @param deadline The unix timestamp after which the transaction will revert.\n     * @custom:requirement The last element of `path` must be equal to the WETH address.\n     * @custom:requirement The WETH balance of the router must be greater than or equal to `amountOutMin`.\n     */\n    function swapExactTokensForETHSupportingFeeOnTransferTokens(\n        uint256 amountIn,\n        uint256 amountOutMin,\n        address[] calldata path,\n        address to,\n        uint256 deadline\n    ) external;\n}\n"
      },
      "contracts/soma/SomaSwap/core/interfaces/ISomaSwapFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.8.18;\n\n/**\n * @title SOMA Swap Factory Contract.\n * @author SOMA.finance\n * @notice Interface for the {SomaSwapFactory} contract.\n */\ninterface ISomaSwapFactory {\n    /**\n     * @notice Emitted when a pair is created via `createPair()`.\n     * @param token0 The address of token0.\n     * @param token1 The address of token1.\n     * @param pair The address of the created pair.\n     */\n    event PairCreated(address indexed token0, address indexed token1, address pair, uint256);\n\n    /**\n     * @notice Emitted when the `feeTo` address is updated from `prevFeeTo` to `newFeeTo` by `sender`.\n     * @param prevFeeTo The address of the previous fee to.\n     * @param prevFeeTo The address of the new fee to.\n     * @param sender The address of the message sender.\n     */\n    event FeeToUpdated(address indexed prevFeeTo, address indexed newFeeTo, address indexed sender);\n\n    /**\n     * @notice Emitted when a router is added by `sender`.\n     * @param router The address of the router added.\n     * @param sender The address of the message sender.\n     */\n    event RouterAdded(address indexed router, address indexed sender);\n\n    /**\n     * @notice Emitted when a router is removed by `sender`.\n     * @param router The address of the router removed.\n     * @param sender The address of the message sender.\n     */\n    event RouterRemoved(address indexed router, address indexed sender);\n\n    /**\n     * @notice Returns SOMA Swap Factory Create Pair Role.\n     * @dev Returns `keccak256('SomaSwapFactory.CREATE_PAIR_ROLE')`.\n     */\n    function CREATE_PAIR_ROLE() external pure returns (bytes32);\n\n    /**\n     * @notice Returns SOMA Swap Factory Fee Setter Role.\n     * @dev Returns `keccak256('SomaSwapFactory.FEE_SETTER_ROLE')`.\n     */\n    function FEE_SETTER_ROLE() external pure returns (bytes32);\n\n    /**\n     * @notice Returns SOMA Swap Factory Manage Router Role.\n     * @dev Returns `keccak256('SomaSwapFactory.MANAGE_ROUTER_ROLE')`.\n     */\n    function MANAGE_ROUTER_ROLE() external pure returns (bytes32);\n\n    /**\n     * @notice Returns the address where fees from the exchange get transferred to.\n     */\n    function feeTo() external view returns (address);\n\n    /**\n     * @notice Returns the address of the pair contract for tokenA and tokenB if it exists, else returns address(0).\n     * @dev Returns the address of the pair for `tokenA` and `tokenB` if it exists, else returns `address(0)`.\n     * @param tokenA The token0 of the pair.\n     * @param tokenB The token1 of the pair.\n     * @return pair The address of the pair.\n     */\n    function getPair(address tokenA, address tokenB) external view returns (address pair);\n\n    /**\n     * @notice Returns the nth pair created through the factory, or address(0).\n     * @dev Returns the `n-th` pair (0 indexed) created through the factory, or `address(0)`.\n     * @return pair The address of the pair.\n     */\n    function allPairs(uint256) external view returns (address pair);\n\n    /**\n     * @notice Returns the total number of pairs created through the factory so far.\n     */\n    function allPairsLength() external view returns (uint256);\n\n    /**\n     * @notice Returns True if an address is an existing router, else returns False.\n     * @param target The address to return true if it an existing router, or false if it is not.\n     * @return Boolean value indicating if the address is an existing router.\n     */\n    function isRouter(address target) external view returns (bool);\n\n    /**\n     * @notice Adds an address as a new router. A router is able to tell a pair who is swapping.\n     * @param router The address to add as a new router.\n     * @custom:emits RouterAdded\n     * @custom:requirement The function caller must have the MANAGE_ROUTER_ROLE.\n     */\n    function addRouter(address router) external;\n\n    /**\n     * @notice Removes an address from the list of routers. A router is able to tell a pair who is swapping.\n     * @param router The address to remove from the list of routers.\n     * @custom:emits RouterRemoved\n     * @custom:requirement The function caller must have the MANAGE_ROUTER_ROLE.\n     */\n    function removeRouter(address router) external;\n\n    /**\n     * @notice Creates a new pair.\n     * @dev Creates a pair for `tokenA` and `tokenB` if one does not exist already.\n     * @param tokenA The address of token0 of the pair.\n     * @param tokenB The address of token1 of the pair.\n     * @custom:emits PairCreated\n     * @custom:requirement The function caller must have the CREATE_PAIR_ROLE.\n     * @custom:requirement `tokenA` must not be equal to `tokenB`.\n     * @custom:requirement `tokenA` must not be equal to `address(0)`.\n     * @custom:requirement `tokenA` and `tokenB` must not be an existing pair.\n     * @custom:requirement The system must not be paused.\n     * @return pair The address of the pair created.\n     */\n    function createPair(address tokenA, address tokenB) external returns (address pair);\n\n    /**\n     * @notice Sets a new `feeTo` address.\n     * @param _feeTo The new address to receive the protocol fees.\n     * @custom:emits FeeToUpdated\n     * @custom:requirement The function caller must have the FEE_SETTER_ROLE.\n     * @custom:requirement The system must not be paused.\n     */\n    function setFeeTo(address _feeTo) external;\n}\n"
      },
      "contracts/soma/TemplateFactory/ITemplateFactory.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\n/**\n * @title SOMA Template Factory Contract.\n * @author SOMA.finance.\n * @notice Interface of the {TemplateFactory} contract.\n */\ninterface ITemplateFactory {\n    /**\n     * @notice Emitted when a template version is created.\n     * @param templateId The ID of the template added.\n     * @param version The version of the template.\n     * @param implementation The address of the implementation of the template.\n     * @param sender The address of the message sender.\n     */\n    event TemplateVersionCreated(\n        bytes32 indexed templateId, uint256 indexed version, address implementation, address indexed sender\n    );\n\n    /**\n     * @notice Emitted when a deploy role is updated.\n     * @param templateId The ID of the template with the updated deploy role.\n     * @param prevRole The previous role.\n     * @param newRole The new role.\n     * @param sender The address of the message sender.\n     */\n    event DeployRoleUpdated(bytes32 indexed templateId, bytes32 prevRole, bytes32 newRole, address indexed sender);\n\n    /**\n     * @notice Emitted when a template is enabled.\n     * @param templateId The ID of the template.\n     * @param sender The address of the message sender.\n     */\n    event TemplateEnabled(bytes32 indexed templateId, address indexed sender);\n\n    /**\n     * @notice Emitted when a template is disabled.\n     * @param templateId The ID of the template.\n     * @param sender The address of the message sender.\n     */\n    event TemplateDisabled(bytes32 indexed templateId, address indexed sender);\n\n    /**\n     * @notice Emitted when a template version is deprecated.\n     * @param templateId The ID of the template.\n     * @param version The version of the template deprecated.\n     * @param sender The address of the message sender.\n     */\n    event TemplateVersionDeprecated(bytes32 indexed templateId, uint256 indexed version, address indexed sender);\n\n    /**\n     * @notice Emitted when a template version is undeprecated.\n     * @param templateId The ID of the template.\n     * @param version The version of the template undeprecated.\n     * @param sender The address of the message sender.\n     */\n    event TemplateVersionUndeprecated(bytes32 indexed templateId, uint256 indexed version, address indexed sender);\n\n    /**\n     * @notice Emitted when a template is deployed.\n     * @param instance The instance of the deployed template.\n     * @param templateId The ID of the template.\n     * @param version The version of the template.\n     * @param args The abi-encoded constructor arguments.\n     * @param functionCalls The abi-encoded function calls.\n     * @param sender The address of the message sender.\n     */\n    event TemplateDeployed(\n        address indexed instance,\n        bytes32 indexed templateId,\n        uint256 version,\n        bytes args,\n        bytes[] functionCalls,\n        address indexed sender\n    );\n\n    /**\n     * @notice Emitted when a template is cloned.\n     * @param instance The instance of the deployed template.\n     * @param templateId The ID of the template.\n     * @param version The version of the template.\n     * @param functionCalls The abi-encoded function calls.\n     * @param sender The address of the message sender.\n     */\n    event TemplateCloned(\n        address indexed instance,\n        bytes32 indexed templateId,\n        uint256 version,\n        bytes[] functionCalls,\n        address indexed sender\n    );\n\n    /**\n     * @notice Emitted when a template function is called.\n     * @param target The address of the target contract.\n     * @param data The abi-encoded data.\n     * @param result The abi-encoded result.\n     * @param sender The address of the message sender.\n     */\n    event FunctionCalled(address indexed target, bytes data, bytes result, address indexed sender);\n\n    /**\n     * @notice Structure of a template version.\n     * @param exists True if the version exists, False if it does not.\n     * @param deprecated True if the version is deprecated, False if it is not.\n     * @param implementation The address of the version's implementation.\n     * @param creationCode The abi-encoded creation code.\n     * @param totalParts The total number of parts of the version.\n     * @param partsUploaded The number of parts uploaded.\n     * @param instances The array of instances.\n     */\n    struct Version {\n        bool deprecated;\n        address implementation;\n        bytes creationCode;\n        uint256 totalParts;\n        uint256 partsUploaded;\n        address[] instances;\n    }\n\n    /**\n     * @notice Structure of a template.\n     * @param disabled Boolean value indicating if the template is enabled.\n     * @param latestVersion The latest version of the template.\n     * @param deployRole The deployer role of the template.\n     * @param version The versions of the template.\n     * @param instances The instances of the template.\n     */\n    struct Template {\n        bool disabled;\n        bytes32 deployRole;\n        Version[] versions;\n        address[] instances;\n    }\n\n    /**\n     * @notice Structure of deployment information.\n     * @param exists Boolean value indicating if the deployment information exists.\n     * @param templateId The id of the template.\n     * @param version The version of the template.\n     * @param args The abi-encoded arguments.\n     * @param functionCalls The abi-encoded function calls.\n     * @param cloned Boolean indicating if the deployment information is cloned.\n     */\n    struct DeploymentInfo {\n        bool exists;\n        uint64 block;\n        uint64 timestamp;\n        address sender;\n        bytes32 templateId;\n        uint256 version;\n        bytes args;\n        bytes[] functionCalls;\n        bool cloned;\n    }\n\n    /**\n     * @notice Returns a version of a template.\n     * @param templateId The id of the template to return the version of.\n     * @param _version The version of the template to be returned.\n     * @return The version of the template.\n     */\n    function version(bytes32 templateId, uint256 _version) external view returns (Version memory);\n\n    /**\n     * @notice Returns the latest version of a template.\n     * @param templateId The id of the template to return the latest version of.\n     * @return The latest version of the template.\n     */\n    function latestVersion(bytes32 templateId) external view returns (uint256);\n\n    /**\n     * @notice Returns the instances of a template.\n     * @param templateId The id of the template to return the latest instance of.\n     * @return The instances of the template.\n     */\n    function templateInstances(bytes32 templateId) external view returns (address[] memory);\n\n    /**\n     * @notice Returns the deployment information of an instance.\n     * @param instance The instance of the template to return deployment information of.\n     * @return The deployment information of the template.\n     */\n    function deploymentInfo(address instance) external view returns (DeploymentInfo memory);\n\n    /**\n     * @notice Returns the deploy role of a template.\n     * @param templateId The id of the template to return the deploy role of.\n     * @return The deploy role of the template.\n     */\n    function deployRole(bytes32 templateId) external view returns (bytes32);\n\n    /**\n     * @notice Returns True if an instance has been deployed by the template factory, else returns False.\n     * @dev Returns `true` if `instance` has been deployed by the template factory, else returns `false`.\n     * @param instance The instance of the template to return True for, if it has been deployed by the factory, else False.\n     * @return Boolean value indicating if the instance has been deployed by the template factory.\n     */\n    function deployedByFactory(address instance) external view returns (bool);\n\n    /**\n     * @notice Uploads a new template and returns True.\n     * @param templateId The id of the template to upload.\n     * @param initialPart The initial part to upload.\n     * @param totalParts The number of total parts of the template.\n     * @param implementation The address of the implementation of the template.\n     * @custom:emits TemplateVersionCreated\n     * @custom:requirement `templateId` must not be equal to bytes32(0).\n     * @custom:requirement The length of `initialPart` must be greater than zero.\n     * @custom:requirement `totalParts` must be greater than zero.\n     */\n    function uploadTemplate(bytes32 templateId, bytes memory initialPart, uint256 totalParts, address implementation)\n        external\n        returns (bool);\n\n    /**\n     * @notice Uploads a part of a template.\n     * @param templateId The id of the template to upload a part to.\n     * @param version The version of the template to upload a part to.\n     * @param part The part to upload to the template.\n     * @custom:requirement The length of part must be greater than zero.\n     * @custom:requirement The version of the template must already exist.\n     * @custom:requirement The version's number of parts uploaded must be less than the version's total number of parts.\n     * @return Boolean value indicating if the operation was successful.\n     */\n    function uploadTemplatePart(bytes32 templateId, uint256 version, bytes memory part) external returns (bool);\n\n    /**\n     * @notice Updates the deploy role of a template.\n     * @param templateId The id of the template to update the deploy role for.\n     * @param _deployRole The deploy role to update to.\n     * @custom:emits DeployRoleUpdated\n     * @custom:requirement The template's existing deploy role cannot be equal to `deployRole`.\n     * @return Boolean value indicating if the operation was successful.\n     */\n    function updateDeployRole(bytes32 templateId, bytes32 _deployRole) external returns (bool);\n\n    /**\n     * @notice Disables a template and returns True.\n     * @dev Disables a template and returns `true`.\n     * @param templateId The id of the template to disable.\n     * @custom:emits TemplateDisabled\n     * @custom:requirement The template must be enabled when the function call is made.\n     * @return Boolean value indicating if the operation was successful.\n     */\n    function disableTemplate(bytes32 templateId) external returns (bool);\n\n    /**\n     * @notice Enables a template and returns True.\n     * @dev Enables a template and returns `true`.\n     * @param templateId The id of the template to enable.\n     * @custom:emits TemplateEnabled\n     * @custom:requirement The template must be disabled when the function call is made.\n     * @return Boolean value indicating if the operation was successful.\n     */\n    function enableTemplate(bytes32 templateId) external returns (bool);\n\n    /**\n     * @notice Deprecates a version of a template. A deprecated template version cannot be deployed.\n     * @param templateId The id of the template to deprecate the version for.\n     * @param _version The version of the template to deprecate.\n     * @custom:emits TemplateVersionDeprecated\n     * @custom:requirement The version must already exist.\n     * @custom:requirement The version must not be deprecated already.\n     * @return Boolean value indicating if the operation was successful.\n     */\n    function deprecateVersion(bytes32 templateId, uint256 _version) external returns (bool);\n\n    /**\n     * @notice Undeprecates a version of a template and returns True.\n     * @param templateId The id of the template to undeprecate a version for.\n     * @param _version The version of a template to undeprecate.\n     * @custom:emits TemplateVersionUndeprecated\n     * @custom:requirement The version must be deprecated already.\n     * @return Boolean value indicating if the operation was successful.\n     */\n    function undeprecateVersion(bytes32 templateId, uint256 _version) external returns (bool);\n\n    /**\n     * @notice Returns the Init Code Hash.\n     * @dev Returns the keccak256 hash of `templateId`, `version` and `args`.\n     * @param templateId The id of the template to return the init code hash of.\n     * @param _version The version of the template to return the init code hash of.\n     * @param args The abi-encoded constructor arguments.\n     * @return The abi-encoded init code hash.\n     */\n    function initCodeHash(bytes32 templateId, uint256 _version, bytes memory args) external view returns (bytes32);\n\n    /**\n     * @notice Overloaded predictDeployAddress function.\n     * @dev See {ITemplateFactory-predictDeployAddress}.\n     * @param templateId The id of the template to predict the deploy address for.\n     * @param _version The version of the template to predict the deploy address for.\n     * @param args The abi-encoded constructor arguments.\n     * @param salt The unique hash ot identify the contract.\n     */\n    function predictDeployAddress(bytes32 templateId, uint256 _version, bytes memory args, bytes32 salt)\n        external\n        view\n        returns (address);\n\n    /**\n     * @notice Predict the clone address.\n     * @param templateId The id of the template to predict the clone address for.\n     * @param _version The version of the template to predict the clone address for.\n     * @param salt The unique hash ot identify the contract.\n     * @return The predicted clone address.\n     */\n    function predictCloneAddress(bytes32 templateId, uint256 _version, bytes32 salt) external view returns (address);\n\n    /**\n     * @notice Deploys a version of a template.\n     * @param templateId The id of the template to deploy.\n     * @param _version The version of the template to deploy.\n     * @param args The abi-encoded constructor arguments.\n     * @param functionCalls The abi-encoded function calls.\n     * @param salt The unique hash to identify the contract.\n     * @custom:emits TemplateDeployed\n     * @custom:requirement The version's number of parts must be equal to the version's number of parts uploaded.\n     * @custom:requirement The length of the version's creation code must be greater than zero.\n     * @return instance The instance of the deployed template.\n     */\n    function deployTemplate(\n        bytes32 templateId,\n        uint256 _version,\n        bytes memory args,\n        bytes[] memory functionCalls,\n        bytes32 salt\n    ) external returns (address instance);\n\n    /**\n     * @notice Clones a version of a template.\n     * @param templateId The id of the template to clone.\n     * @param _version The version of the template to clone.\n     * @param functionCalls The abi-encoded function calls.\n     * @param salt The unique hash to identify the contract.\n     * @custom:emits TemplateCloned\n     * @custom:requirement The version's implementation must not equal `address(0)`.\n     * @return instance The address of the cloned template instance.\n     */\n    function cloneTemplate(bytes32 templateId, uint256 _version, bytes[] memory functionCalls, bytes32 salt)\n        external\n        returns (address instance);\n\n    /**\n     * @notice Calls a function on the target contract.\n     * @param target The target address of the function call.\n     * @param data Miscalaneous data associated with the transfer.\n     * @custom:emits FunctionCalled\n     * @return result The result of the function call.\n     */\n    function functionCall(address target, bytes memory data) external returns (bytes memory result);\n}\n"
      },
      "contracts/soma/Lockdrop/ILockdropFactory.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nimport \"./ILockdrop.sol\";\n\n/**\n * @title SOMA Lockdrop Factory Contract.\n * @author SOMA.finance.\n * @notice A factory that produces Lockdrop contracts.\n */\ninterface ILockdropFactory {\n    /**\n     * @notice Emitted when a Lockdrop is created.\n     * @param id The ID of the Lockdrop.\n     * @param asset The delegation asset of the Lockdrop.\n     * @param instance The address of the created Lockdrop.\n     */\n    event LockdropCreated(uint256 id, address asset, address instance);\n\n    /**\n     * @notice The Lockdrop's CREATE_ROLE.\n     * @dev Returns keccak256('Lockdrop.CREATE_ROLE').\n     */\n    function CREATE_ROLE() external pure returns (bytes32);\n\n    /**\n     * @notice Creates a Lockdrop instance.\n     * @param asset The address of the delegation asset.\n     * @param withdrawTo The address that delegated assets will be withdrawn to.\n     * @param dateConfig The date configuration of the Lockdrop.\n     * @custom:emits LockdropCreated\n     * @custom:requirement `asset` must not be equal to address zero.\n     * @custom:requirement `withdrawTo` must not be equal to address zero.\n     * @custom:requirement The function caller must have the CREATE_ROLE.\n     */\n    function create(address asset, address withdrawTo, ILockdrop.DateConfig calldata dateConfig) external;\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n *  Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.\n *  See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n *  In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastValue = set._values[lastIndex];\n\n                // Move the last value to the index where the value to delete is\n                set._values[toDeleteIndex] = lastValue;\n                // Update the index for the moved value\n                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n            }\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        return _values(set._inner);\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
      },
      "contracts/soma/Lockdrop/ILockdrop.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Lockdrop Contract.\n * @author SOMA.finance\n * @notice A fund raising contract for bootstrapping DEX liquidity pools.\n */\ninterface ILockdrop {\n    /**\n     * @notice Emitted when the {DelegationConfig} is updated.\n     * @param poolId The pool ID.\n     * @param prevLockDuration The previous lock duration.\n     * @param newLockDuration The new lock duration.\n     * @param sender The message sender that triggered the event.\n     */\n    event LockDurationUpdated(\n        bytes32 poolId, uint256 prevLockDuration, uint256 newLockDuration, address indexed sender\n    );\n\n    /**\n     * @notice Emitted when the {withdrawTo} address is updated.\n     * @param prevTo The previous withdraw to address.\n     * @param newTo The new withdraw to address.\n     * @param sender The message sender that triggered the event.\n     */\n    event WithdrawToUpdated(address prevTo, address newTo, address indexed sender);\n\n    /**\n     * @notice Emitted when a delegation is added to a pool.\n     * @param poolId The pool ID.\n     * @param amount The delegation amount denominated in the delegation asset.\n     * @param lockDuration The lock duration.\n     * @param sender The message sender that triggered the event.\n     */\n    event DelegationAdded(bytes32 indexed poolId, uint256 amount, uint256 lockDuration, address indexed sender);\n\n    /**\n     * @notice Emitted when someone calls {moveDelegation}, transferring their delegation to a different pool.\n     * @param fromPoolId The pool ID of the source pool.\n     * @param toPoolId The pool ID of the destination pool.\n     * @param amount The amount of the delegation asset to move.\n     * @param sender TThe message sender that triggered the event.\n     */\n    event DelegationMoved(bytes32 indexed fromPoolId, bytes32 indexed toPoolId, uint256 amount, address indexed sender);\n\n    /**\n     * @notice Emitted when the {DateConfig} is updated.\n     * @param prevDateConfig The previous date configuration.\n     * @param newDateConfig The new date configuration.\n     * @param sender The message sender that triggered the event.\n     */\n    event DatesUpdated(DateConfig prevDateConfig, DateConfig newDateConfig, address indexed sender);\n\n    /**\n     * @notice Emitted when the {Pool} is updated.\n     * @param poolId The pool ID.\n     * @param requiredPrivileges The new required privileges.\n     * @param enabled Boolean indicating if the pool is enabled.\n     * @param sender The message sender that triggered the event.\n     */\n    event PoolUpdated(bytes32 indexed poolId, bytes32 requiredPrivileges, bool enabled, address indexed sender);\n\n    /**\n     * @notice Emitted when a delegation is removed from a pool.\n     * @param poolId The pool ID.\n     * @param amount The removed delegation amount denominated in the delegation asset.\n     * @param sender The message sender that triggered the event.\n     */\n    event DelegationRemoved(bytes32 indexed poolId, uint256 amount, address indexed sender);\n\n    /**\n     * @notice Date Configuration structure.\n     * @param startDate The unix timestamp marking the start of the lockdrop.\n     * @param removeDelegationEnd The unix timestamp marking the end of delegation removals.\n     * @param endDate The unix timestamp marking the end of the lockdrop.\n     */\n    struct DateConfig {\n        uint48 startDate;\n        uint48 removeDelegationEnd;\n        uint48 endDate;\n    }\n\n    /**\n     * @notice Pool structure. Each pool will bootstrap liquidity for an upcoming DEX pair.\n     * E.g: sTSLA/USDC\n     * @param enabled Boolean indicating if the pool is enabled.\n     * @param requiredPrivileges The required privileges of the pool.\n     * @param balances The mapping of user addresses to delegation balances.\n     */\n    struct Pool {\n        bool enabled;\n        bytes32 requiredPrivileges;\n        mapping(address => uint256) balances;\n    }\n\n    /**\n     * @notice Returns the Lockdrop Global Admin Role.\n     * @dev Equivalent to `keccak256('Lockdrop.GLOBAL_ADMIN_ROLE')`.\n     */\n    function GLOBAL_ADMIN_ROLE() external pure returns (bytes32);\n\n    /**\n     * @notice Returns the Lockdrop Local Admin Role.\n     * @dev Equivalent to `keccak256(abi.encodePacked(address(this), GLOBAL_ADMIN_ROLE))`.\n     */\n    function LOCAL_ADMIN_ROLE() external view returns (bytes32);\n\n    /**\n     * @notice Returns the ID of the Lockdrop.\n     */\n    function id() external view returns (uint256);\n\n    /**\n     * @notice The address of the Lockdrop's delegation asset.\n     */\n    function asset() external view returns (address);\n\n    /**\n     * @notice The date configuration of the Lockdrop.\n     */\n    function dateConfig() external view returns (DateConfig memory);\n\n    /**\n     * @notice The address where the delegated funds will be withdrawn to.\n     */\n    function withdrawTo() external view returns (address);\n\n    /**\n     * @notice Initialize function for the Lockdrop contract.\n     * @param _id The ID of the Lockdrop.\n     * @param _asset The address of the delegation asset.\n     * @param _withdrawTo The address that receives withdrawn assets.\n     * @param _initDateConfig The initial date configuration.\n     */\n    function initialize(uint256 _id, address _asset, address _withdrawTo, DateConfig calldata _initDateConfig)\n        external;\n\n    /**\n     * @notice Updates the Lockdrop's date configuration.\n     * @param newConfig The updated date configuration.\n     * @custom:emits DatesUpdated\n     * @custom:requirement The function caller must have the GLOBAL_ADMIN_ROLE or LOCAL_ADMIN_ROLE.\n     */\n    function updateDateConfig(DateConfig calldata newConfig) external;\n\n    /**\n     * @notice Sets the `withdrawTo` address.\n     * @param account The updated address to receive withdrawn funds.\n     * @custom:emits WithdrawToUpdated\n     * @custom:requirement The function caller must be the master.\n     * @custom:requirement `account` must not be equal to address zero.\n     */\n    function setWithdrawTo(address account) external;\n\n    /**\n     * @notice Returns the delegation balance of an account, given a pool ID.\n     * @param poolId The pool ID to return the account's balance of.\n     * @param account The account to return the balance of.\n     * @return The delegation balance of `account` for the `poolId` pool.\n     */\n    function balanceOf(bytes32 poolId, address account) external view returns (uint256);\n\n    /**\n     * @notice Returns the lock duration of an account for a pool.\n     * @param poolId The poolId to return the user lock duration of.\n     * @param account The account to return the pool lock duration of.\n     * @return The lock duration.\n     */\n    function lockDuration(bytes32 poolId, address account) external view returns (uint256);\n\n    /**\n     * @notice Returns a boolean indicating if a pool is enabled.\n     * @param poolId The pool ID to check the enabled status of.\n     * @return True if the pool is enabled, False if the pool is disabled.\n     */\n    function enabled(bytes32 poolId) external view returns (bool);\n\n    /**\n     * @notice Returns the required privileges of the pool. These privileges are required in order to\n     * delegate.\n     * @param poolId The pool ID to check the enabled status of.\n     * @custom:requirement The pool must be enabled.\n     * @return The required privileges of the pool.\n     */\n    function requiredPrivileges(bytes32 poolId) external view returns (bytes32);\n\n    /**\n     * @notice Updates the lockdrop pool parameters.\n     * @param _poolId The ID of the pool to update.\n     * @param _requiredPrivileges The updated required privileges of the pool.\n     * @param _enabled The updated enabled or disabled state of the pool.\n     * @custom:emits PoolUpdated\n     * @custom:requirement The function caller must have the GLOBAL_ADMIN_ROLE or LOCAL_ADMIN_ROLE.\n     */\n    function updatePool(bytes32 _poolId, bytes32 _requiredPrivileges, bool _enabled) external;\n\n    /**\n     * @notice Updates the delegation configuration of an account.\n     * @param poolId The pool ID.\n     * @param newLockDuration The new lock duration.\n     * @custom:emits LockDurationUpdated\n     * @custom:requirement The `poolId` pool must be enabled.\n     * @custom:requirement The lockdrop must have started already.\n     * @custom:requirement The lockdrop must not have ended yet.\n     * @custom:requirement The contracts must not be paused.\n     */\n    function updateLockDuration(bytes32 poolId, uint256 newLockDuration) external;\n\n    /**\n     * @notice Withdraws tokens from the Lockdrop contract to the `withdrawTo` address.\n     * @param amount The amount of tokens to be withdrawn.\n     * @custom:requirement The function caller must have the GLOBAL_ADMIN_ROLE or LOCAL_ADMIN_ROLE.\n     */\n    function withdraw(uint256 amount) external;\n\n    /**\n     * @notice Moves the accounts' delegated tokens from one pool to another, and sets the `toPoolId` lock duration.\n     * @param fromPoolId The ID of the pool that the delegation will be moved from.\n     * @param toPoolId The ID of the pool that the delegation will be moved to.\n     * @param amount The amount of tokens to be moved.\n     * @param toPoolLockDuration The lock duration of the user for `toPoolId`.\n     * @custom:emits DelegationMoved\n     * @custom:requirement `fromPoolId` must not be equal to `toPoolId`.\n     * @custom:requirement The lockdrop must have started already.\n     * @custom:requirement The lockdrop must not have ended yet.\n     * @custom:requirement `amount` must be greater than zero.\n     * @custom:requirement The `fromPoolId` pool must be enabled.\n     * @custom:requirement The `toPoolId` pool must be enabled.\n     * @custom:requirement The delegation balance of the caller for the `fromPoolId` pool must be greater than\n     * or equal to `amount`.\n     * @custom:requirement The function caller must have the required privileges of the `fromPoolId` pool.\n     * @custom:requirement The function caller must have the required privileges of the `toPoolId` pool.\n     * @custom:requirement The contracts must not be paused.\n     */\n    function moveDelegation(bytes32 fromPoolId, bytes32 toPoolId, uint256 amount, uint256 toPoolLockDuration)\n        external;\n\n    /**\n     * @notice Removes the accounts' delegated tokens from the pool.\n     * @param poolId The ID of the pool that the delegation will be removed from.\n     * @param amount The amount of tokens to be removed.\n     * @custom:emits DelegationRemoved\n     * @custom:requirement The lockdrop must have started already.\n     * @custom:requirement The block timestamp must be less than or equal to the remove delegation end timestamp.\n     * @custom:requirement `amount` must be greater than zero.\n     * @custom:requirement `amount` must be less than the balance of the asset.\n     * @custom:requirement The `poolId` pool must be enabled.\n     * @custom:requirement The delegation balance of the caller for the `poolId` pool must be greater than\n     * or equal to `amount`.\n     * @custom:requirement The function caller must have the required privileges of the `poolId` pool.\n     * @custom:requirement The contracts must not be paused.\n     */\n    function removeDelegation(bytes32 poolId, uint256 amount) external;\n\n    /**\n     * @notice Delegates tokens to the a specific pool.\n     * @param poolId The ID of the pool to receive the delegation.\n     * @param amount The amount of tokens to be delegated.\n     * @param lockDuration_ The lock duration.\n     * @custom:emits DelegationAdded\n     * @custom:requirement `amount` must be greater than zero.\n     * @custom:requirement The `poolId` pool must be enabled.\n     * @custom:requirement The lockdrop must have started already.\n     * @custom:requirement The lockdrop must not have ended yet.\n     * @custom:requirement The function caller must have the `poolId` pool's required privileges.\n     * @custom:requirement The contracts must not be paused.\n     */\n    function delegate(bytes32 poolId, uint256 amount, uint256 lockDuration_) external;\n}\n"
      },
      "contracts/soma/SomaGuard/utils/IGuardable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Guardable Upgradeable Contract.\n * @author SOMA.finance\n * @notice Interface of the {GuardableUpgradeable} contract.\n */\ninterface IGuardable {\n    /**\n     * @notice Emitted when the required privileges are updated.\n     * @param prevPrivileges The previous required privileges.\n     * @param newPrivileges The new required privileges.\n     * @param sender The message sender that triggered the event.\n     */\n    event RequiredPrivilegesUpdated(bytes32 prevPrivileges, bytes32 newPrivileges, address indexed sender);\n\n    /**\n     * @notice Returns a boolean indicating if `account` has the required privileges.\n     * @param account The account to check against the required privileges.\n     * @return True if `account` has the required privileges, False otherwise.\n     */\n    function hasPrivileges(address account) external view returns (bool);\n\n    /**\n     * @notice Returns the required privileges.\n     */\n    function requiredPrivileges() external view returns (bytes32);\n\n    /**\n     * @notice Updates the required privileges.\n     * @param newRequiredPrivileges The new required privileges.\n     * @custom:emits RequiredPrivilegesUpdated\n     * @custom:requirement The message sender must have either the LOCAL_UPDATE_PRIVILEGES_ROLE or the\n     * GLOBAL_UPDATE_PRIVILEGES_ROLE role.\n     * @return True if the update was successful.\n     */\n    function updateRequiredPrivileges(bytes32 newRequiredPrivileges) external returns (bool);\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/IERC20Partition.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Partition {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event TransferPartition(\n        address indexed from, address indexed to, bytes32 indexed fromId, bytes32 toId, uint256 value, bytes data\n    );\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event ApprovalPartition(\n        address indexed owner, address indexed spender, bytes32 indexed id, uint256 value, bytes data\n    );\n\n    /**\n     * @dev Emitted when a partition has been deprecated\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event DeprecatePartition(bytes32 indexed id, bytes data);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply(bytes32 id) external view returns (uint256);\n\n    /**\n     * @dev Returns a boolean indicating if a partition is deprecated.\n     */\n    function deprecated(bytes32 id) external view returns (bool);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account, bytes32 id) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, bytes32 id, uint256 amount, bytes memory data) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender, bytes32 id) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, bytes32 id, uint256 amount, bytes memory data) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, bytes32 id, uint256 amount, bytes memory data)\n        external\n        returns (bool);\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/ISeizableSecurityPartition.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Seizable Security Partition Contract.\n * @author SOMA.finance.\n * @notice Interface of the {SeizableSecurityPartition} contract.\n */\ninterface ISeizableSecurityPartition {\n    /**\n     * @notice Emitted after a token is seized.\n     * @param operator The address of the operator.\n     * @param from The address that has had tokens seized from.\n     * @param to The seize to address that receives seized tokens.\n     * @param fromId The from partition id of the tokens.\n     * @param toId The to partition id of the tokens.\n     * @param value The amount of tokens seized.\n     * @param data Bytes data associated with the transaction.\n     */\n    event Seized(\n        address indexed operator,\n        address indexed from,\n        address indexed to,\n        bytes32 fromId,\n        bytes32 toId,\n        uint256 value,\n        bytes data\n    );\n\n    /**\n     * @notice Seizes tokens from an account.\n     * @param tokenHolder The account to seize tokens from.\n     * @param fromId The from partition id of the tokens.\n     * @param toId The to partition id of the tokens.\n     * @param amount The amount of tokens to seize from `tokenHolder`.\n     * @param data Bytes data associated with the transaction.\n     * @custom:emits Seized\n     * @custom:requirement The message sender must have the GLOBAL_SEIZE_ROLE or LOCAL_SEIZE_ROLE.\n     */\n    function seize(address tokenHolder, bytes32 fromId, bytes32 toId, uint256 amount, bytes memory data) external;\n}\n"
      },
      "contracts/soma/SomaGuard/utils/GuardableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity =0.8.18;\n\nimport \"../../SomaAccessControl/utils/AccessibleUpgradeable.sol\";\n\nimport \"../ISomaGuard.sol\";\n\nimport \"./GuardHelper.sol\";\nimport \"./IGuardable.sol\";\n\n/**\n * @notice Implementation of the {IGuardable} interface.\n */\nabstract contract GuardableUpgradeable is IGuardable, AccessibleUpgradeable {\n    /**\n     * @notice Initializer for extended contracts.\n     */\n    function __Guardable__init() internal {\n        __Context_init_unchained();\n        __ERC165_init_unchained();\n        __Guardable__init_unchained();\n        __SomaContract_init_unchained();\n        __Accessible_init_unchained();\n        __Multicall_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    /**\n     * @notice Unchained initializer for extended contracts.\n     */\n    function __Guardable__init_unchained() internal onlyInitializing {\n        LOCAL_UPDATE_PRIVILEGES_ROLE = keccak256(abi.encodePacked(address(this), GLOBAL_UPDATE_PRIVILEGES_ROLE));\n        _updateRequiredPrivileges(bytes32(type(uint256).max));\n    }\n\n    bytes32 public immutable DEFAULT_PRIVILEGES = GuardHelper.DEFAULT_PRIVILEGES;\n    bytes32 public constant GLOBAL_UPDATE_PRIVILEGES_ROLE = keccak256(\"Guardable.GLOBAL_UPDATE_PRIVILEGES_ROLE\");\n\n    bytes32 public LOCAL_UPDATE_PRIVILEGES_ROLE;\n    bytes32 private _requiredPrivileges;\n\n    /**\n     * @notice Modifier restricting a function call to accounts that have the required privileges.\n     */\n    modifier onlyApprovedPrivileges(address sender) {\n        require(hasPrivileges(sender), \"required privileges not met\");\n        _;\n    }\n\n    /**\n     * @inheritdoc IGuardable\n     */\n    function hasPrivileges(address account) public view virtual override returns (bool) {\n        return ISomaGuard(SOMA.guard()).check(account, requiredPrivileges());\n    }\n\n    /**\n     * @inheritdoc IGuardable\n     */\n    function requiredPrivileges() public view virtual override returns (bytes32) {\n        return _requiredPrivileges;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IGuardable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @inheritdoc IGuardable\n     */\n    function updateRequiredPrivileges(bytes32 newRequiredPrivileges) external virtual override returns (bool) {\n        require(\n            hasRole(LOCAL_UPDATE_PRIVILEGES_ROLE, _msgSender()) || hasRole(GLOBAL_UPDATE_PRIVILEGES_ROLE, _msgSender()),\n            \"Guardable: you do not have the required roles to do this\"\n        );\n        _updateRequiredPrivileges(newRequiredPrivileges);\n        return true;\n    }\n\n    function _updateRequiredPrivileges(bytes32 newRequiredPrivileges) internal {\n        emit RequiredPrivilegesUpdated(_requiredPrivileges, newRequiredPrivileges, _msgSender());\n        _requiredPrivileges = newRequiredPrivileges;\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/IDeprecatableSecurity.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Mintable Security Contract.\n * @author SOMA.finance.\n * @notice Interface of the {MintableSecurity} contract.\n */\ninterface IDeprecatableSecurity {\n    /**\n     * @notice Deprecates a given id for the token\n     * @param id the id of the token to deprecate\n     * @param data any data associated with the call\n     */\n    function deprecatePartition(bytes32 id, bytes memory data) external;\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/partitions/ITransferablePartition.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\ninterface ITransferablePartition {\n    event MovedPartition(address indexed account, bytes32 fromId, bytes32 toId, uint256 value, bytes data);\n\n    function transferPartition(address account, bytes32 fromId, bytes32 toId, uint256 amount, bytes memory data)\n        external\n        returns (bool);\n}\n"
      },
      "contracts/soma/SecurityTokens/extensions/IMintableSecurity.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Mintable Security Contract.\n * @author SOMA.finance.\n * @notice Interface of the {MintableSecurity} contract.\n */\ninterface IMintableSecurity {\n    /**\n     * @notice Emitted after a token is minted.\n     * @param operator The address of the operator.\n     * @param to The seize to address that receives minted tokens.\n     * @param value The amount of tokens minted.\n     */\n    event Minted(address indexed operator, address indexed to, bytes32 id, uint256 value, bytes data);\n\n    /**\n     * @notice Emitted after a token is burned.\n     * @param operator The address of the operator.\n     * @param from The seize to address that receives minted tokens.\n     * @param value The amount of tokens minted.\n     */\n    event Burned(address indexed operator, address indexed from, bytes32 id, uint256 value, bytes data);\n\n    /**\n     * @notice Mints a mintable security token.\n     * @param amount The amount of tokens to mint.\n     * @custom:emits Minted\n     * @custom:requirement The function caller must have the GLOBAL_MINT_ROLE or LOCAL_MINT_ROLE.\n     */\n    function mint(bytes32 id, uint256 amount, bytes memory data) external;\n\n    /**\n     * @notice Burns a mintable security token.\n     * @param amount The amount of tokens to burn.\n     * @custom:emits Burned\n     * @custom:requirement The function caller must have the GLOBAL_MINT_ROLE or LOCAL_MINT_ROLE.\n     */\n    function burn(bytes32 id, uint256 amount, bytes memory data) external;\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    function safeTransfer(\n        IERC20 token,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(\n        IERC20 token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            uint256 newAllowance = oldAllowance - value;\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n        }\n    }\n\n    function safePermit(\n        IERC20Permit token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) {\n            // Return data is optional\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
      },
      "contracts/soma/Lockdrop/extensions/ITokenRecoveryUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\n/**\n * @title SOMA Token Rewards Upgradeable Contract.\n * @author SOMA.finance\n * @notice Interface for the {TokenRecoveryUpgradeable} contract.\n */\ninterface ITokenRecoveryUpgradeable {\n    /**\n     * @notice Emitted when tokens are recovered.\n     * @param token The address of the recovered tokens.\n     * @param to The address that the tokens are being sent to.\n     * @param amount The amount of tokens recovered.\n     * @param sender The address of the message sender.\n     */\n    event TokensRecovered(address indexed token, address indexed to, uint256 amount, address indexed sender);\n\n    /**\n     * @notice Returns the Token Recovery Upgradeable TOKEN_RECOVERY_ROLE.\n     * @dev Returns keccak256('TokenRecovery.TOKEN_RECOVERY_ROLE').\n     */\n    function TOKEN_RECOVERY_ROLE() external pure returns (bytes32);\n\n    /**\n     * @notice Recovers tokens and transfers these tokens to `to`.\n     * @param token The address of the recovered tokens.\n     * @param to The address that the tokens are being sent to.\n     * @param amount The amount of tokens recovered.\n     * @custom:emits TokensRecovered\n     * @custom:requirement The function caller must have the TOKEN_RECOVERY_ROLE.\n     * @custom:requirement `token` must not be a disabled token.\n     */\n    function recoverTokens(address token, address to, uint256 amount) external;\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "@openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "evmVersion": "london",
      "metadata": {
        "bytecodeHash": "none"
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}