{"sources":{"contracts/token/DSToken.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./IDSToken.sol\";\nimport \"../utils/ProxyTarget.sol\";\nimport \"./StandardToken.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\ncontract DSToken is ProxyTarget, Initializable, StandardToken {\n    // using FeaturesLibrary for SupportedFeatures;\n    using TokenLibrary for TokenLibrary.SupportedFeatures;\n    uint256 internal constant OMNIBUS_NO_ACTION = 0;\n\n    function initialize(string memory _name, string memory _symbol, uint8 _decimals) public virtual initializer forceInitializeFromProxy {\n        StandardToken.initialize();\n\n        VERSIONS.push(5);\n        name = _name;\n        symbol = _symbol;\n        decimals = _decimals;\n    }\n\n    /******************************\n       TOKEN CONFIGURATION\n   *******************************/\n\n    function setFeature(uint8 featureIndex, bool enable) public onlyMaster {\n        supportedFeatures.setFeature(featureIndex, enable);\n    }\n\n    function setFeatures(uint256 features) public onlyMaster {\n        supportedFeatures.value = features;\n    }\n\n    function setCap(uint256 _cap) public override onlyTransferAgentOrAbove {\n        require(cap == 0, \"Token cap already set\");\n        require(_cap > 0);\n        cap = _cap;\n    }\n\n    function totalIssued() public view returns (uint256) {\n        return tokenData.totalIssued;\n    }\n\n    /******************************\n       TOKEN ISSUANCE (MINTING)\n   *******************************/\n\n    /**\n     * @dev Issues unlocked tokens\n     * @param _to address The address which is going to receive the newly issued tokens\n     * @param _value uint256 the value of tokens to issue\n     * @return true if successful\n     */\n    function issueTokens(\n        address _to,\n        uint256 _value /*onlyIssuerOrAbove*/\n    ) public override returns (bool) {\n        issueTokensCustom(_to, _value, block.timestamp, 0, \"\", 0);\n        return true;\n    }\n\n    /**\n     * @dev Issuing tokens from the fund\n     * @param _to address The address which is going to receive the newly issued tokens\n     * @param _value uint256 the value of tokens to issue\n     * @param _valueLocked uint256 value of tokens, from those issued, to lock immediately.\n     * @param _reason reason for token locking\n     * @param _releaseTime timestamp to release the lock (or 0 for locks which can only released by an unlockTokens call)\n     * @return true if successful\n     */\n    function issueTokensCustom(address _to, uint256 _value, uint256 _issuanceTime, uint256 _valueLocked, string memory _reason, uint64 _releaseTime)\n    public\n    virtual\n    override\n    returns (\n    /*onlyIssuerOrAbove*/\n        bool\n    )\n    {\n        uint256[] memory valuesLocked;\n        uint64[] memory releaseTimes;\n        if (_valueLocked > 0) {\n            valuesLocked = new uint256[](1);\n            releaseTimes = new uint64[](1);\n            valuesLocked[0] = _valueLocked;\n            releaseTimes[0] = _releaseTime;\n        }\n\n        issueTokensWithMultipleLocks(_to, _value, _issuanceTime, valuesLocked, _reason, releaseTimes);\n        return true;\n    }\n\n    function issueTokensWithMultipleLocks(address _to, uint256 _value, uint256 _issuanceTime, uint256[] memory _valuesLocked, string memory _reason, uint64[] memory _releaseTimes)\n    public\n    virtual\n    override\n    onlyIssuerOrAbove\n    returns (bool)\n    {\n        TokenLibrary.issueTokensCustom(tokenData, getCommonServices(), getLockManager(), _to, _value, _issuanceTime, _valuesLocked, _releaseTimes, _reason, cap);\n        emit Transfer(address(0), _to, _value);\n\n        checkWalletsForList(address(0), _to);\n        return true;\n    }\n\n    function issueTokensWithNoCompliance(address _to, uint256 _value) public virtual override onlyIssuerOrAbove {\n        require(getRegistryService().isWallet(_to), \"Unknown wallet\");\n        TokenLibrary.issueTokensWithNoCompliance(tokenData, getCommonServices(), _to, _value, block.timestamp, cap);\n        emit Transfer(address(0), _to, _value);\n    }\n\n    //*********************\n    // TOKEN BURNING\n    //*********************\n\n    function burn(address _who, uint256 _value, string memory _reason) public virtual override onlyIssuerOrTransferAgentOrAbove {\n        TokenLibrary.burn(tokenData, getCommonServices(), _who, _value);\n        emit Burn(_who, _value, _reason);\n        emit Transfer(_who, address(0), _value);\n        checkWalletsForList(_who, address(0));\n    }\n\n    function omnibusBurn(address _omnibusWallet, address _who, uint256 _value, string memory _reason) public override onlyTransferAgentOrAbove {\n        require(_value <= tokenData.walletsBalances[_omnibusWallet]);\n        TokenLibrary.omnibusBurn(tokenData, getCommonServices(), _omnibusWallet, _who, _value);\n        emit OmnibusBurn(_omnibusWallet, _who, _value, _reason, getAssetTrackingMode(_omnibusWallet));\n        emit Burn(_omnibusWallet, _value, _reason);\n        emit Transfer(_omnibusWallet, address(0), _value);\n        checkWalletsForList(_omnibusWallet, address(0));\n    }\n\n    //*********************\n    // TOKEN SEIZING\n    //*********************\n\n    function seize(address _from, address _to, uint256 _value, string memory _reason) public virtual override onlyTransferAgentOrAbove {\n        TokenLibrary.seize(tokenData, getCommonServices(), _from, _to, _value);\n        emit Seize(_from, _to, _value, _reason);\n        emit Transfer(_from, _to, _value);\n        checkWalletsForList(_from, _to);\n    }\n\n    function omnibusSeize(address _omnibusWallet, address _from, address _to, uint256 _value, string memory _reason) public override onlyTransferAgentOrAbove {\n        TokenLibrary.omnibusSeize(tokenData, getCommonServices(), _omnibusWallet, _from, _to, _value);\n        emit OmnibusSeize(_omnibusWallet, _from, _value, _reason, getAssetTrackingMode(_omnibusWallet));\n        emit Seize(_omnibusWallet, _to, _value, _reason);\n        emit Transfer(_omnibusWallet, _to, _value);\n        checkWalletsForList(_omnibusWallet, _to);\n    }\n\n    //*********************\n    // TRANSFER RESTRICTIONS\n    //*********************\n\n    /**\n     * @dev Checks whether it can transfer with the compliance manager, if not -throws.\n     */\n    modifier canTransfer(address _sender, address _receiver, uint256 _value) {\n        getComplianceService().validateTransfer(_sender, _receiver, _value, paused, super.balanceOf(_sender));\n        _;\n    }\n\n    /**\n     * @dev override for transfer with modifiers:\n     * whether the token is not paused (checked in super class)\n     * and that the sender is allowed to transfer tokens\n     * @param _to The address that will receive the tokens.\n     * @param _value The amount of tokens to be transferred.\n     */\n    function transfer(address _to, uint256 _value) public virtual override canTransfer(msg.sender, _to, _value) returns (bool) {\n        return postTransferImpl(super.transfer(_to, _value), msg.sender, _to, _value);\n    }\n\n    /**\n     * @dev override for transfer with modifiers:\n     * whether the token is not paused (checked in super class)\n     * and that the sender is allowed to transfer tokens\n     * @param _from The address that will send the tokens.\n     * @param _to The address that will receive the tokens.\n     * @param _value The amount of tokens to be transferred.\n     */\n    function transferFrom(address _from, address _to, uint256 _value) public virtual override canTransfer(_from, _to, _value) returns (bool) {\n        return postTransferImpl(super.transferFrom(_from, _to, _value), _from, _to, _value);\n    }\n\n    function postTransferImpl(bool _superResult, address _from, address _to, uint256 _value) internal returns (bool) {\n        if (_superResult) {\n            updateInvestorsBalancesOnTransfer(_from, _to, _value);\n        }\n\n        checkWalletsForList(_from, _to);\n\n        return _superResult;\n    }\n\n    //*********************\n    // WALLET ENUMERATION\n    //****\n\n    function getWalletAt(uint256 _index) public view override returns (address) {\n        require(_index > 0 && _index <= walletsCount);\n        return walletsList[_index];\n    }\n\n    function walletCount() public view override returns (uint256) {\n        return walletsCount;\n    }\n\n    function checkWalletsForList(address _from, address _to) private {\n        if (super.balanceOf(_from) == 0) {\n            removeWalletFromList(_from);\n        }\n        if (super.balanceOf(_to) > 0) {\n            addWalletToList(_to);\n        }\n    }\n\n    function addWalletToList(address _address) private {\n        //Check if it's already there\n        uint256 existingIndex = walletsToIndexes[_address];\n        if (existingIndex == 0) {\n            //If not - add it\n            uint256 index = walletsCount + 1;\n            walletsList[index] = _address;\n            walletsToIndexes[_address] = index;\n            walletsCount = index;\n        }\n    }\n\n    function removeWalletFromList(address _address) private {\n        //Make sure it's there\n        uint256 existingIndex = walletsToIndexes[_address];\n        if (existingIndex != 0) {\n            uint256 lastIndex = walletsCount;\n            if (lastIndex != existingIndex) {\n                //Put the last wallet instead of it (this will work even with 1 wallet in the list)\n                address lastWalletAddress = walletsList[lastIndex];\n                walletsList[existingIndex] = lastWalletAddress;\n                walletsToIndexes[lastWalletAddress] = existingIndex;\n            }\n\n            delete walletsToIndexes[_address];\n            delete walletsList[lastIndex];\n            walletsCount = lastIndex - 1;\n        }\n    }\n\n    //**************************************\n    // MISCELLANEOUS FUNCTIONS\n    //**************************************\n\n    function balanceOfInvestor(string memory _id) public view override returns (uint256) {\n        return tokenData.investorsBalances[_id];\n    }\n\n    function getAssetTrackingMode(address _omnibusWallet) internal view returns (uint8) {\n        return getRegistryService().getOmnibusWalletController(_omnibusWallet).getAssetTrackingMode();\n    }\n\n    function updateOmnibusInvestorBalance(address _omnibusWallet, address _wallet, uint256 _value, CommonUtils.IncDec _increase)\n    public\n    override\n    onlyOmnibusWalletController(_omnibusWallet, IDSOmnibusWalletController(msg.sender))\n    returns (bool)\n    {\n        return updateInvestorBalance(_wallet, _value, _increase);\n    }\n\n    function emitOmnibusTransferEvent(address _omnibusWallet, address _from, address _to, uint256 _value)\n    public\n    override\n    onlyOmnibusWalletController(_omnibusWallet, IDSOmnibusWalletController(msg.sender))\n    {\n        emit OmnibusTransfer(_omnibusWallet, _from, _to, _value, getAssetTrackingMode(_omnibusWallet));\n    }\n\n    function emitOmnibusTBEEvent(address omnibusWallet, int256 totalDelta, int256 accreditedDelta,\n        int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta) public override onlyTBEOmnibus {\n        emit OmnibusTBEOperation(omnibusWallet, totalDelta, accreditedDelta, usAccreditedDelta, usTotalDelta, jpTotalDelta);\n    }\n\n    function emitOmnibusTBETransferEvent(address omnibusWallet, string memory externalId) public override onlyTBEOmnibus {\n        emit OmnibusTBETransfer(omnibusWallet, externalId);\n    }\n\n    function updateInvestorsBalancesOnTransfer(address _from, address _to, uint256 _value) internal {\n        uint256 omnibusEvent = TokenLibrary.applyOmnibusBalanceUpdatesOnTransfer(tokenData, getRegistryService(), _from, _to, _value);\n        if (omnibusEvent == OMNIBUS_NO_ACTION) {\n            updateInvestorBalance(_from, _value, CommonUtils.IncDec.Decrease);\n            updateInvestorBalance(_to, _value, CommonUtils.IncDec.Increase);\n        }\n    }\n\n    function updateInvestorBalance(address _wallet, uint256 _value, CommonUtils.IncDec _increase) internal override returns (bool) {\n        string memory investor = getRegistryService().getInvestor(_wallet);\n        if (!CommonUtils.isEmptyString(investor)) {\n            uint256 balance = balanceOfInvestor(investor);\n            if (_increase == CommonUtils.IncDec.Increase) {\n                balance += _value;\n            } else {\n                balance -= _value;\n            }\n            tokenData.investorsBalances[investor] = balance;\n        }\n\n        return true;\n    }\n\n    function preTransferCheck(address _from, address _to, uint256 _value) public view override returns (uint256 code, string memory reason) {\n        return getComplianceService().preTransferCheck(_from, _to, _value);\n    }\n\n    function getCommonServices() internal view returns (address[] memory) {\n        address[] memory services = new address[](3);\n        services[0] = getDSService(COMPLIANCE_SERVICE);\n        services[1] = getDSService(REGISTRY_SERVICE);\n        services[2] = getDSService(OMNIBUS_TBE_CONTROLLER);\n        return services;\n    }\n}\n"},"contracts/utils/Ownable.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./Initializable.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract Ownable is Initializable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    function initialize() public virtual initializer {\n        _owner = msg.sender;\n        emit OwnershipTransferred(address(0), _owner);\n    }\n\n    //Legacy function\n    function owner() public view returns (address) {\n        return contractOwner();\n    }\n\n    function contractOwner() public view returns (address) {\n        return _owner;\n    }\n\n    modifier onlyOwner() {\n        require(isOwner(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    function isOwner() public view returns (bool) {\n        return msg.sender == _owner;\n    }\n\n    function renounceOwnership() public onlyOwner {\n        emit OwnershipTransferred(_owner, address(0));\n        _owner = address(0);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public onlyOwner {\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     */\n    function _transferOwnership(address newOwner) internal {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        emit OwnershipTransferred(_owner, newOwner);\n        _owner = newOwner;\n    }\n}\n"},"contracts/token/IDSToken.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/CommonUtils.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\nimport \"../omnibus/IDSOmnibusWalletController.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSToken is IERC20, Initializable, VersionedContract {\n    event Issue(address indexed to, uint256 value, uint256 valueLocked);\n    event Burn(address indexed burner, uint256 value, string reason);\n    event Seize(address indexed from, address indexed to, uint256 value, string reason);\n    event OmnibusDeposit(address indexed omnibusWallet, address to, uint256 value, uint8 assetTrackingMode);\n    event OmnibusWithdraw(address indexed omnibusWallet, address from, uint256 value, uint8 assetTrackingMode);\n    event OmnibusSeize(address indexed omnibusWallet, address from, uint256 value, string reason, uint8 assetTrackingMode);\n    event OmnibusBurn(address indexed omnibusWallet, address who, uint256 value, string reason, uint8 assetTrackingMode);\n    event OmnibusTransfer(address indexed omnibusWallet, address from, address to, uint256 value, uint8 assetTrackingMode);\n    event OmnibusTBEOperation(address indexed omnibusWallet, int256 totalDelta, int256 accreditedDelta,\n        int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta);\n    event OmnibusTBETransfer(address omnibusWallet, string externalId);\n\n    event WalletAdded(address wallet);\n    event WalletRemoved(address wallet);\n\n    function initialize() public virtual {\n        VERSIONS.push(3);\n    }\n\n    /******************************\n       CONFIGURATION\n   *******************************/\n\n    /**\n     * @dev Sets the total issuance cap\n     * Note: The cap is compared to the total number of issued token, not the total number of tokens available,\n     * So if a token is burned, it is not removed from the \"total number of issued\".\n     * This call cannot be called again after it was called once.\n     * @param _cap address The address which is going to receive the newly issued tokens\n     */\n    function setCap(\n        uint256 _cap /*onlyMaster*/\n    ) public virtual;\n\n    /******************************\n       TOKEN ISSUANCE (MINTING)\n   *******************************/\n\n    /**\n     * @dev Issues unlocked tokens\n     * @param _to address The address which is going to receive the newly issued tokens\n     * @param _value uint256 the value of tokens to issue\n     * @return true if successful\n     */\n    function issueTokens(\n        address _to,\n        uint256 _value /*onlyIssuerOrAbove*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev Issuing tokens from the fund\n     * @param _to address The address which is going to receive the newly issued tokens\n     * @param _value uint256 the value of tokens to issue\n     * @param _valueLocked uint256 value of tokens, from those issued, to lock immediately.\n     * @param _reason reason for token locking\n     * @param _releaseTime timestamp to release the lock (or 0 for locks which can only released by an unlockTokens call)\n     * @return true if successful\n     */\n    function issueTokensCustom(\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime,\n        uint256 _valueLocked,\n        string memory _reason,\n        uint64 _releaseTime /*onlyIssuerOrAbove*/\n    ) public virtual returns (bool);\n\n    function issueTokensWithMultipleLocks(\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime,\n        uint256[] memory _valuesLocked,\n        string memory _reason,\n        uint64[] memory _releaseTimes /*onlyIssuerOrAbove*/\n    ) public virtual returns (bool);\n\n    function issueTokensWithNoCompliance(address _to, uint256 _value) public virtual /*onlyIssuerOrAbove*/;\n\n    //*********************\n    // TOKEN BURNING\n    //*********************\n\n    function burn(\n        address _who,\n        uint256 _value,\n        string memory _reason /*onlyIssuerOrAbove*/\n    ) public virtual;\n\n    function omnibusBurn(\n        address _omnibusWallet,\n        address _who,\n        uint256 _value,\n        string memory _reason /*onlyIssuerOrAbove*/\n    ) public virtual;\n\n    //*********************\n    // TOKEN SIEZING\n    //*********************\n\n    function seize(\n        address _from,\n        address _to,\n        uint256 _value,\n        string memory _reason /*onlyIssuerOrAbove*/\n    ) public virtual;\n\n    function omnibusSeize(\n        address _omnibusWallet,\n        address _from,\n        address _to,\n        uint256 _value,\n        string memory _reason\n        /*onlyIssuerOrAbove*/\n    ) public virtual;\n\n    //*********************\n    // WALLET ENUMERATION\n    //*********************\n\n    function getWalletAt(uint256 _index) public view virtual returns (address);\n\n    function walletCount() public view virtual returns (uint256);\n\n    //**************************************\n    // MISCELLANEOUS FUNCTIONS\n    //**************************************\n    function isPaused() public view virtual returns (bool);\n\n    function balanceOfInvestor(string memory _id) public view virtual returns (uint256);\n\n    function updateOmnibusInvestorBalance(\n        address _omnibusWallet,\n        address _wallet,\n        uint256 _value,\n        CommonUtils.IncDec _increase /*onlyOmnibusWalletController*/\n    ) public virtual returns (bool);\n\n    function emitOmnibusTransferEvent(\n        address _omnibusWallet,\n        address _from,\n        address _to,\n        uint256 _value /*onlyOmnibusWalletController*/\n    ) public virtual;\n\n    function emitOmnibusTBEEvent(address omnibusWallet, int256 totalDelta, int256 accreditedDelta,\n        int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta /*onlyTBEOmnibus*/\n    ) public virtual;\n\n    function emitOmnibusTBETransferEvent(address omnibusWallet, string memory externalId) public virtual;\n\n    function updateInvestorBalance(address _wallet, uint256 _value, CommonUtils.IncDec _increase) internal virtual returns (bool);\n\n    function preTransferCheck(address _from, address _to, uint256 _value) public view virtual returns (uint256 code, string memory reason);\n}\n"},"contracts/utils/CommonUtils.sol":{"content":"pragma solidity ^0.8.13;\n\n//SPDX-License-Identifier: UNLICENSED\nlibrary CommonUtils {\n  enum IncDec { Increase, Decrease }\n\n  function encodeString(string memory _str) internal pure returns (bytes32) {\n    return keccak256(abi.encodePacked(_str));\n  }\n\n  function isEqualString(string memory _str1, string memory _str2) internal pure returns (bool) {\n    return encodeString(_str1) == encodeString(_str2);\n  }\n\n  function isEmptyString(string memory _str) internal pure returns (bool) {\n    return isEqualString(_str, \"\");\n  }\n}\n"},"contracts/utils/ProxyTarget.sol":{"content":"pragma solidity ^0.8.13;\n\n//SPDX-License-Identifier: UNLICENSED\ncontract ProxyTarget {\n    address internal ___t1;\n    address internal ___t2;\n\n    modifier forceInitializeFromProxy() {\n        require(___t1 != address(0x0), \"Must be initialized from proxy\");\n\n        _;\n    }\n}\n"},"contracts/token/TokenLibrary.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../service/ServiceConsumer.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nlibrary TokenLibrary {\n    event OmnibusDeposit(address indexed omnibusWallet, address to, uint256 value, uint8 assetTrackingMode);\n    event OmnibusWithdraw(address indexed omnibusWallet, address from, uint256 value, uint8 assetTrackingMode);\n    event Issue(address indexed to, uint256 value, uint256 valueLocked);\n\n    uint256 internal constant COMPLIANCE_SERVICE = 0;\n    uint256 internal constant REGISTRY_SERVICE = 1;\n    uint256 internal constant OMNIBUS_NO_ACTION = 0;\n    uint256 internal constant OMNIBUS_DEPOSIT = 1;\n    uint256 internal constant OMNIBUS_WITHDRAW = 2;\n    using SafeMath for uint256;\n\n    struct TokenData {\n        mapping(address => uint256) walletsBalances;\n        mapping(string => uint256) investorsBalances;\n        uint256 totalSupply;\n        uint256 totalIssued;\n    }\n\n    struct SupportedFeatures {\n        uint256 value;\n    }\n\n    function setFeature(SupportedFeatures storage supportedFeatures, uint8 featureIndex, bool enable) public {\n        uint256 base = 2;\n        uint256 mask = base**featureIndex;\n\n        // Enable only if the feature is turned off and disable only if the feature is turned on\n        if (enable && (supportedFeatures.value & mask == 0)) {\n            supportedFeatures.value = supportedFeatures.value ^ mask;\n        } else if (!enable && (supportedFeatures.value & mask >= 1)) {\n            supportedFeatures.value = supportedFeatures.value ^ mask;\n        }\n    }\n\n    function issueTokensCustom(\n        TokenData storage _tokenData,\n        address[] memory _services,\n        IDSLockManager _lockManager,\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime,\n        uint256[] memory _valuesLocked,\n        uint64[] memory _releaseTimes,\n        string memory _reason,\n        uint256 _cap\n    ) public returns (bool) {\n        //Check input values\n        require(_to != address(0), \"Invalid address\");\n        require(_value > 0, \"Value is zero\");\n        require(_valuesLocked.length == _releaseTimes.length, \"Wrong length of parameters\");\n\n        //Make sure we are not hitting the cap\n        require(_cap == 0 || _tokenData.totalIssued + _value <= _cap, \"Token Cap Hit\");\n\n        //Check issuance is allowed (and inform the compliance manager, possibly adding locks)\n        IDSComplianceService(_services[COMPLIANCE_SERVICE]).validateIssuance(_to, _value, _issuanceTime);\n\n        _tokenData.totalSupply += _value;\n        _tokenData.totalIssued += _value;\n        _tokenData.walletsBalances[_to] += _value;\n        updateInvestorBalance(_tokenData, IDSRegistryService(_services[REGISTRY_SERVICE]), _to, _value, CommonUtils.IncDec.Increase);\n\n        uint256 totalLocked = 0;\n        for (uint256 i = 0; i < _valuesLocked.length; i++) {\n            totalLocked += _valuesLocked[i];\n            _lockManager.addManualLockRecord(_to, _valuesLocked[i], _reason, _releaseTimes[i]);\n        }\n        require(totalLocked <= _value, \"valueLocked must be smaller than value\");\n        emit Issue(_to, _value, totalLocked);\n        return true;\n    }\n\n    function issueTokensWithNoCompliance(\n        TokenData storage _tokenData,\n        address[] memory _services,\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime,\n        uint256 _cap\n    ) public returns (bool) {\n        //Make sure we are not hitting the cap\n        require(_cap == 0 || _tokenData.totalIssued + _value <= _cap, \"Token Cap Hit\");\n\n        //Check and inform issuance\n        IDSComplianceService(_services[COMPLIANCE_SERVICE]).validateIssuanceWithNoCompliance(_to, _value, _issuanceTime);\n\n        _tokenData.totalSupply += _value;\n        _tokenData.totalIssued += _value;\n        _tokenData.walletsBalances[_to] += _value;\n        updateInvestorBalance(_tokenData, IDSRegistryService(_services[REGISTRY_SERVICE]), _to, _value, CommonUtils.IncDec.Increase);\n\n        emit Issue(_to, _value, 0);\n        return true;\n    }\n\n    modifier validSeizeParameters(TokenData storage _tokenData, address _from, address _to, uint256 _value) {\n        require(_from != address(0), \"Invalid address\");\n        require(_to != address(0), \"Invalid address\");\n        require(_value <= _tokenData.walletsBalances[_from], \"Not enough balance\");\n\n        _;\n    }\n\n    function burn(TokenData storage _tokenData, address[] memory _services, address _who, uint256 _value) public {\n        require(_value <= _tokenData.walletsBalances[_who], \"Not enough balance\");\n        // no need to require value <= totalSupply, since that would imply the\n        // sender's balance is greater than the totalSupply, which *should* be an assertion failure\n\n        IDSComplianceService(_services[COMPLIANCE_SERVICE]).validateBurn(_who, _value);\n\n        _tokenData.walletsBalances[_who] -= _value;\n        updateInvestorBalance(_tokenData, IDSRegistryService(_services[REGISTRY_SERVICE]), _who, _value, CommonUtils.IncDec.Decrease);\n        _tokenData.totalSupply -= _value;\n    }\n\n    function seize(TokenData storage _tokenData, address[] memory _services, address _from, address _to, uint256 _value)\n    public\n    validSeizeParameters(_tokenData, _from, _to, _value)\n    {\n        IDSRegistryService registryService = IDSRegistryService(_services[REGISTRY_SERVICE]);\n        IDSComplianceService(_services[COMPLIANCE_SERVICE]).validateSeize(_from, _to, _value);\n        _tokenData.walletsBalances[_from] -= _value;\n        _tokenData.walletsBalances[_to] += _value;\n        updateInvestorBalance(_tokenData, registryService, _from, _value, CommonUtils.IncDec.Decrease);\n        updateInvestorBalance(_tokenData, registryService, _to, _value, CommonUtils.IncDec.Increase);\n    }\n\n    function omnibusBurn(TokenData storage _tokenData, address[] memory _services, address _omnibusWallet, address _who, uint256 _value) public {\n        IDSRegistryService registryService = IDSRegistryService(_services[REGISTRY_SERVICE]);\n        IDSOmnibusWalletController omnibusController = IDSRegistryService(_services[REGISTRY_SERVICE]).getOmnibusWalletController(_omnibusWallet);\n        _tokenData.walletsBalances[_omnibusWallet] -= _value;\n        omnibusController.burn(_who, _value);\n        decreaseInvestorBalanceOnOmnibusSeizeOrBurn(_tokenData, registryService, omnibusController, _omnibusWallet, _who, _value);\n        _tokenData.totalSupply -= _value;\n    }\n\n    function omnibusSeize(TokenData storage _tokenData, address[] memory _services, address _omnibusWallet, address _from, address _to, uint256 _value)\n    public\n    validSeizeParameters(_tokenData, _omnibusWallet, _to, _value)\n    {\n        IDSRegistryService registryService = IDSRegistryService(_services[REGISTRY_SERVICE]);\n        IDSOmnibusWalletController omnibusController = registryService.getOmnibusWalletController(_omnibusWallet);\n\n        _tokenData.walletsBalances[_omnibusWallet] -= _value;\n        _tokenData.walletsBalances[_to] += _value;\n        omnibusController.seize(_from, _value);\n        decreaseInvestorBalanceOnOmnibusSeizeOrBurn(_tokenData, registryService, omnibusController, _omnibusWallet, _from, _value);\n        updateInvestorBalance(_tokenData, registryService, _to, _value, CommonUtils.IncDec.Increase);\n    }\n\n    function decreaseInvestorBalanceOnOmnibusSeizeOrBurn(\n        TokenData storage _tokenData,\n        IDSRegistryService _registryService,\n        IDSOmnibusWalletController _omnibusController,\n        address _omnibusWallet,\n        address _from,\n        uint256 _value\n    ) internal {\n        if (_omnibusController.isHolderOfRecord()) {\n            updateInvestorBalance(_tokenData, _registryService, _omnibusWallet, _value, CommonUtils.IncDec.Decrease);\n        } else {\n            updateInvestorBalance(_tokenData, _registryService, _from, _value, CommonUtils.IncDec.Decrease);\n        }\n    }\n\n    function applyOmnibusBalanceUpdatesOnTransfer(TokenData storage _tokenData, IDSRegistryService _registryService, address _from, address _to, uint256 _value)\n    public\n    returns (uint256)\n    {\n        if (_registryService.isOmnibusWallet(_to)) {\n            IDSOmnibusWalletController omnibusWalletController = _registryService.getOmnibusWalletController(_to);\n            omnibusWalletController.deposit(_from, _value);\n            emit OmnibusDeposit(_to, _from, _value, omnibusWalletController.getAssetTrackingMode());\n\n            if (omnibusWalletController.isHolderOfRecord()) {\n                updateInvestorBalance(_tokenData, _registryService, _from, _value, CommonUtils.IncDec.Decrease);\n                updateInvestorBalance(_tokenData, _registryService, _to, _value, CommonUtils.IncDec.Increase);\n            }\n            return OMNIBUS_DEPOSIT;\n        } else if (_registryService.isOmnibusWallet(_from)) {\n            IDSOmnibusWalletController omnibusWalletController = _registryService.getOmnibusWalletController(_from);\n            omnibusWalletController.withdraw(_to, _value);\n            emit OmnibusWithdraw(_from, _to, _value, omnibusWalletController.getAssetTrackingMode());\n\n            if (omnibusWalletController.isHolderOfRecord()) {\n                updateInvestorBalance(_tokenData, _registryService, _from, _value, CommonUtils.IncDec.Decrease);\n                updateInvestorBalance(_tokenData, _registryService, _to, _value, CommonUtils.IncDec.Increase);\n            }\n            return OMNIBUS_WITHDRAW;\n        }\n        return OMNIBUS_NO_ACTION;\n    }\n\n    function updateInvestorBalance(TokenData storage _tokenData, IDSRegistryService _registryService, address _wallet, uint256 _value, CommonUtils.IncDec _increase) internal returns (bool) {\n        string memory investor = _registryService.getInvestor(_wallet);\n        if (!CommonUtils.isEmptyString(investor)) {\n            uint256 balance = _tokenData.investorsBalances[investor];\n            if (_increase == CommonUtils.IncDec.Increase) {\n                balance += _value;\n            } else {\n                balance -= _value;\n            }\n            _tokenData.investorsBalances[investor] = balance;\n        }\n\n        return true;\n    }\n}\n"},"contracts/token/StandardToken.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../service/ServiceConsumer.sol\";\nimport \"../data-stores/TokenDataStore.sol\";\nimport \"../omnibus/OmnibusTBEController.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract StandardToken is IDSToken, ServiceConsumer, TokenDataStore {\n    event Pause();\n    event Unpause();\n\n    function initialize() public virtual override(IDSToken, ServiceConsumer) {\n        IDSToken.initialize();\n        ServiceConsumer.initialize();\n        VERSIONS.push(5);\n    }\n\n    modifier whenNotPaused() {\n        require(!paused, \"Contract is paused\");\n        _;\n    }\n\n    modifier whenPaused() {\n        require(paused, \"Contract is not paused\");\n        _;\n    }\n\n    function pause() public onlyTransferAgentOrAbove whenNotPaused {\n        paused = true;\n        emit Pause();\n    }\n\n    function unpause() public onlyTransferAgentOrAbove whenPaused {\n        paused = false;\n        emit Unpause();\n    }\n\n    function isPaused() public view override returns (bool) {\n        return paused;\n    }\n\n    /**\n     * @dev Gets the balance of the specified address.\n     * @param _owner The address to query the the balance of.\n     * @return An uint256 representing the amount owned by the passed address.\n     */\n    function balanceOf(address _owner) public view returns (uint256) {\n        return tokenData.walletsBalances[_owner];\n    }\n\n    function totalSupply() public view returns (uint256) {\n        return tokenData.totalSupply;\n    }\n\n    /**\n     * @dev transfer token for a specified address\n     * @param _to The address to transfer to.\n     * @param _value The amount to be transferred.\n     */\n    function transfer(address _to, uint256 _value) public virtual returns (bool) {\n        return transferImpl(msg.sender, _to, _value);\n    }\n\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _value\n    ) public virtual returns (bool) {\n        IDSOmnibusTBEController tbeController = getOmnibusTBEController();\n        if (!(msg.sender == address(tbeController) && _from == tbeController.getOmnibusWallet())) {\n            require(_value <= allowances[_from][msg.sender], \"Not enough allowance\");\n            allowances[_from][msg.sender] -= _value;\n        }\n        return transferImpl(_from, _to, _value);\n    }\n\n    function transferImpl(\n        address _from,\n        address _to,\n        uint256 _value\n    ) internal returns (bool) {\n        require(_to != address(0));\n        require(_value <= tokenData.walletsBalances[_from]);\n\n        tokenData.walletsBalances[_from] -= _value;\n        tokenData.walletsBalances[_to] += _value;\n\n        emit Transfer(_from, _to, _value);\n\n        return true;\n    }\n\n    function approve(address _spender, uint256 _value) public returns (bool) {\n        allowances[msg.sender][_spender] = _value;\n        emit Approval(msg.sender, _spender, _value);\n        return true;\n    }\n\n    function allowance(address _owner, address _spender) public view returns (uint256) {\n        return allowances[_owner][_spender];\n    }\n\n    function increaseApproval(address _spender, uint256 _addedValue) public returns (bool) {\n        allowances[msg.sender][_spender] = allowances[msg.sender][_spender] + _addedValue;\n        emit Approval(msg.sender, _spender, allowances[msg.sender][_spender]);\n        return true;\n    }\n\n    function decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool) {\n        uint256 oldValue = allowances[msg.sender][_spender];\n        if (_subtractedValue > oldValue) {\n            allowances[msg.sender][_spender] = 0;\n        } else {\n            allowances[msg.sender][_spender] = oldValue - _subtractedValue;\n        }\n        emit Approval(msg.sender, _spender, allowances[msg.sender][_spender]);\n        return true;\n    }\n}\n"},"contracts/utils/Initializable.sol":{"content":"pragma solidity ^0.8.13;\n\n//SPDX-License-Identifier: UNLICENSED\ncontract Initializable {\n    bool public initialized = false;\n\n    modifier initializer() {\n        require(!initialized, \"Contract instance has already been initialized\");\n\n        _;\n\n        initialized = true;\n    }\n}\n"},"contracts/trust/IDSTrustService.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\n\n\n/**\n * @title IDSTrustService\n * @dev An interface for a trust service which allows role-based access control for other contracts.\n */\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSTrustService is Initializable, VersionedContract {\n\n    function initialize() public virtual {\n        VERSIONS.push(4);\n    }\n\n    /**\n     * @dev Should be emitted when a role is set for a user.\n     */\n    event DSTrustServiceRoleAdded(address targetAddress, uint8 role, address sender);\n    /**\n     * @dev Should be emitted when a role is removed for a user.\n     */\n    event DSTrustServiceRoleRemoved(address targetAddress, uint8 role, address sender);\n\n    // Role constants\n    uint8 public constant NONE = 0;\n    uint8 public constant MASTER = 1;\n    uint8 public constant ISSUER = 2;\n    uint8 public constant EXCHANGE = 4;\n    uint8 public constant TRANSFER_AGENT = 8;\n\n    /**\n     * @dev Transfers the ownership (MASTER role) of the contract.\n     * @param _address The address which the ownership needs to be transferred to.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function setServiceOwner(\n        address _address /*onlyMaster*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev Sets a role for an array of wallets.\n     * @dev Should not be used for setting MASTER (use setServiceOwner) or role removal (use removeRole).\n     * @param _addresses The array of wallet whose role needs to be set.\n     * @param _roles The array of role to be set. The lenght and order must match with _addresses\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function setRoles(address[] memory _addresses, uint8[] memory _roles) public virtual returns (bool);\n\n    /**\n     * @dev Sets a role for a wallet.\n     * @dev Should not be used for setting MASTER (use setServiceOwner) or role removal (use removeRole).\n     * @param _address The wallet whose role needs to be set.\n     * @param _role The role to be set.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function setRole(\n        address _address,\n        uint8 _role /*onlyMasterOrIssuer*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev Removes the role for a wallet.\n     * @dev Should not be used to remove MASTER (use setServiceOwner).\n     * @param _address The wallet whose role needs to be removed.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function removeRole(\n        address _address /*onlyMasterOrIssuer*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev Gets the role for a wallet.\n     * @param _address The wallet whose role needs to be fetched.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function getRole(address _address) public view virtual returns (uint8);\n\n    function addEntity(\n        string memory _name,\n        address _owner /*onlyMasterOrIssuer onlyNewEntity onlyNewEntityOwner*/\n    ) public virtual;\n\n    function changeEntityOwner(\n        string memory _name,\n        address _oldOwner,\n        address _newOwner /*onlyMasterOrIssuer onlyExistingEntityOwner*/\n    ) public virtual;\n\n    function addOperator(\n        string memory _name,\n        address _operator /*onlyEntityOwnerOrAbove onlyNewOperator*/\n    ) public virtual;\n\n    function removeOperator(\n        string memory _name,\n        address _operator /*onlyEntityOwnerOrAbove onlyExistingOperator*/\n    ) public virtual;\n\n    function addResource(\n        string memory _name,\n        address _resource /*onlyMasterOrIssuer onlyExistingEntity onlyNewResource*/\n    ) public virtual;\n\n    function removeResource(\n        string memory _name,\n        address _resource /*onlyMasterOrIssuer onlyExistingResource*/\n    ) public virtual;\n\n    function getEntityByOwner(address _owner) public view virtual returns (string memory);\n\n    function getEntityByOperator(address _operator) public view virtual returns (string memory);\n\n    function getEntityByResource(address _resource) public view virtual returns (string memory);\n\n    function isResourceOwner(address _resource, address _owner) public view virtual returns (bool);\n\n    function isResourceOperator(address _resource, address _operator) public view virtual returns (bool);\n}\n"},"contracts/service/ServiceConsumer.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./IDSServiceConsumer.sol\";\nimport \"../data-stores/ServiceConsumerDataStore.sol\";\nimport \"../token/IDSToken.sol\";\nimport \"../token/IDSTokenPartitioned.sol\";\nimport \"../compliance/IDSWalletManager.sol\";\nimport \"../compliance/IDSLockManager.sol\";\nimport \"../compliance/IDSLockManagerPartitioned.sol\";\nimport \"../compliance/IDSComplianceService.sol\";\nimport \"../compliance/IDSComplianceServicePartitioned.sol\";\nimport \"../compliance/IDSPartitionsManager.sol\";\nimport \"../compliance/IDSComplianceConfigurationService.sol\";\nimport \"../registry/IDSRegistryService.sol\";\nimport \"../omnibus/IDSOmnibusTBEController.sol\";\nimport \"../trust/IDSTrustService.sol\";\nimport \"../utils/Ownable.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract ServiceConsumer is IDSServiceConsumer, Ownable, ServiceConsumerDataStore {\n\n    // Bring role constants to save gas both in deployment (less bytecode) and usage\n    uint8 public constant ROLE_NONE = 0;\n    uint8 public constant ROLE_MASTER = 1;\n    uint8 public constant ROLE_ISSUER = 2;\n    uint8 public constant ROLE_EXCHANGE = 4;\n    uint8 public constant ROLE_TRANSFER_AGENT = 8;\n\n    function initialize() public virtual override(IDSServiceConsumer, Ownable) {\n        IDSServiceConsumer.initialize();\n        Ownable.initialize();\n\n        VERSIONS.push(6);\n    }\n\n    modifier onlyMaster {\n        IDSTrustService trustManager = getTrustService();\n        require(this.contractOwner() == msg.sender || trustManager.getRole(msg.sender) == ROLE_MASTER, \"Insufficient trust level\");\n        _;\n    }\n\n    /**\n   * @dev Allow invoking functions only by the users who have the MASTER role or the ISSUER role or the TRANSFER AGENT role.\n   */\n    modifier onlyIssuerOrTransferAgentOrAbove() {\n        IDSTrustService trustManager = getTrustService();\n        require(trustManager.getRole(msg.sender) == ROLE_TRANSFER_AGENT || trustManager.getRole(msg.sender) == ROLE_ISSUER || trustManager.getRole(msg.sender) == ROLE_MASTER, \"Insufficient trust level\");\n        _;\n    }\n\n    modifier onlyIssuerOrAbove {\n        IDSTrustService trustManager = getTrustService();\n        require(trustManager.getRole(msg.sender) == ROLE_ISSUER || trustManager.getRole(msg.sender) == ROLE_MASTER, \"Insufficient trust level\");\n        _;\n    }\n\n    modifier onlyTransferAgentOrAbove {\n        IDSTrustService trustManager = getTrustService();\n        require(trustManager.getRole(msg.sender) == ROLE_TRANSFER_AGENT || trustManager.getRole(msg.sender) == ROLE_MASTER, \"Insufficient trust level\");\n        _;\n    }\n\n    modifier onlyExchangeOrAbove {\n        IDSTrustService trustManager = getTrustService();\n        require(\n            trustManager.getRole(msg.sender) == ROLE_EXCHANGE\n            || trustManager.getRole(msg.sender) == ROLE_ISSUER\n            || trustManager.getRole(msg.sender) == ROLE_TRANSFER_AGENT\n            || trustManager.getRole(msg.sender) == ROLE_MASTER,\n            \"Insufficient trust level\"\n        );\n        _;\n    }\n\n    modifier onlyToken {\n        require(msg.sender == getDSService(DS_TOKEN), \"This function can only called by the associated token\");\n        _;\n    }\n\n    modifier onlyRegistry {\n        require(msg.sender == getDSService(REGISTRY_SERVICE), \"This function can only called by the registry service\");\n        _;\n    }\n\n    modifier onlyIssuerOrAboveOrToken {\n        if (msg.sender != getDSService(DS_TOKEN)) {\n            IDSTrustService trustManager = IDSTrustService(getDSService(TRUST_SERVICE));\n            require(trustManager.getRole(msg.sender) == ROLE_ISSUER || trustManager.getRole(msg.sender) == ROLE_MASTER, \"Insufficient trust level\");\n        }\n        _;\n    }\n\n    modifier onlyTransferAgentOrAboveOrToken {\n        if (msg.sender != getDSService(DS_TOKEN)) {\n            IDSTrustService trustManager = IDSTrustService(getDSService(TRUST_SERVICE));\n            require(trustManager.getRole(msg.sender) == ROLE_TRANSFER_AGENT || trustManager.getRole(msg.sender) == ROLE_MASTER, \"Insufficient trust level\");\n        }\n        _;\n    }\n\n    modifier onlyOmnibusWalletController(address omnibusWallet, IDSOmnibusWalletController omnibusWalletController) {\n        require(getRegistryService().getOmnibusWalletController(omnibusWallet) == omnibusWalletController, \"Wrong controller address\");\n        _;\n    }\n\n    modifier onlyTBEOmnibus {\n        require(msg.sender == address(getOmnibusTBEController()), \"Not authorized\");\n        _;\n    }\n\n    modifier onlyMasterOrTBEOmnibus {\n        IDSTrustService trustManager = getTrustService();\n        require(msg.sender == address(getOmnibusTBEController()) ||\n        this.contractOwner() == msg.sender || trustManager.getRole(msg.sender) == ROLE_MASTER, \"Not authorized\");\n        _;\n    }\n\n    modifier onlyOwnerOrExchangeOrAbove {\n        if(!isOwner()) {\n            IDSTrustService trustManager = getTrustService();\n            require(\n                trustManager.getRole(msg.sender) == ROLE_EXCHANGE\n                || trustManager.getRole(msg.sender) == ROLE_ISSUER\n                || trustManager.getRole(msg.sender) == ROLE_TRANSFER_AGENT\n                || trustManager.getRole(msg.sender) == ROLE_MASTER,\n                \"Insufficient trust level\"\n            );\n        }\n        _;\n    }\n\n    function getDSService(uint256 _serviceId) public view override returns (address) {\n        return services[_serviceId];\n    }\n\n    function setDSService(uint256 _serviceId, address _address) public override onlyMaster returns (bool) {\n        services[_serviceId] = _address;\n        emit DSServiceSet(_serviceId, _address);\n        return true;\n    }\n\n    function getToken() internal view returns (IDSToken) {\n        return IDSToken(getDSService(DS_TOKEN));\n    }\n\n    function getTrustService() internal view returns (IDSTrustService) {\n        return IDSTrustService(getDSService(TRUST_SERVICE));\n    }\n\n    function getWalletManager() internal view returns (IDSWalletManager) {\n        return IDSWalletManager(getDSService(WALLET_MANAGER));\n    }\n\n    function getLockManager() internal view returns (IDSLockManager) {\n        return IDSLockManager(getDSService(LOCK_MANAGER));\n    }\n\n    function getLockManagerPartitioned() internal view returns (IDSLockManagerPartitioned) {\n        return IDSLockManagerPartitioned(getDSService(LOCK_MANAGER));\n    }\n\n    function getComplianceService() internal view returns (IDSComplianceService) {\n        return IDSComplianceService(getDSService(COMPLIANCE_SERVICE));\n    }\n\n    function getRegistryService() internal view returns (IDSRegistryService) {\n        return IDSRegistryService(getDSService(REGISTRY_SERVICE));\n    }\n\n    function getPartitionsManager() internal view returns (IDSPartitionsManager) {\n        return IDSPartitionsManager(getDSService(PARTITIONS_MANAGER));\n    }\n\n    function getTokenPartitioned() internal view returns (IDSTokenPartitioned) {\n        return IDSTokenPartitioned(getDSService(DS_TOKEN));\n    }\n\n    function getComplianceConfigurationService() internal view returns (IDSComplianceConfigurationService) {\n        return IDSComplianceConfigurationService(getDSService(COMPLIANCE_CONFIGURATION_SERVICE));\n    }\n\n    function getOmnibusTBEController() internal view returns (IDSOmnibusTBEController) {\n        return IDSOmnibusTBEController(getDSService(OMNIBUS_TBE_CONTROLLER));\n    }\n}\n"},"contracts/utils/VersionedContract.sol":{"content":"pragma solidity ^0.8.13;\n\n//SPDX-License-Identifier: UNLICENSED\ncontract VersionedContract {\n    uint256[] internal VERSIONS = [1];\n\n    function getVersion() public view returns (uint256[] memory) {\n        return VERSIONS;\n    }\n}\n"},"contracts/compliance/IDSLockManager.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSLockManager is Initializable, VersionedContract {\n\n    function initialize() public virtual;\n\n    modifier validLock(uint256 _valueLocked, uint256 _releaseTime) {\n        require(_valueLocked > 0, \"Value is zero\");\n        require(_releaseTime == 0 || _releaseTime > uint256(block.timestamp), \"Release time is in the past\");\n        _;\n    }\n\n    event Locked(address indexed who, uint256 value, uint256 indexed reason, string reasonString, uint256 releaseTime);\n    event Unlocked(address indexed who, uint256 value, uint256 indexed reason, string reasonString, uint256 releaseTime);\n\n    event HolderLocked(string holderId, uint256 value, uint256 indexed reason, string reasonString, uint256 releaseTime);\n    event HolderUnlocked(string holderId, uint256 value, uint256 indexed reason, string reasonString, uint256 releaseTime);\n    /**\n     * @dev creates a lock record for wallet address\n     * @param _to address to lock the tokens at\n     * @param _valueLocked value of tokens to lock\n     * @param _reason reason for lock\n     * @param _releaseTime timestamp to release the lock (or 0 for locks which can only released by an unlockTokens call)\n     * Note: The user MAY have at a certain time more locked tokens than actual tokens\n     */\n\n    function addManualLockRecord(\n        address _to,\n        uint256 _valueLocked,\n        string memory _reason,\n        uint256 _releaseTime /*issuerOrAboveOrToken*/\n    ) public virtual;\n\n    /**\n     * @dev creates a lock record for investor Id\n     * @param _investor investor id to lock the tokens at\n     * @param _valueLocked value of tokens to lock\n     * @param _reasonCode reason code for lock\n     * @param _reasonString reason for lock\n     * @param _releaseTime timestamp to release the lock (or 0 for locks which can only released by an unlockTokens call)\n     * Note: The user MAY have at a certain time more locked tokens than actual tokens\n     */\n\n    function createLockForInvestor(\n        string memory _investor,\n        uint256 _valueLocked,\n        uint256 _reasonCode,\n        string memory _reasonString,\n        uint256 _releaseTime /*onlyIssuerOrAboveOrToken*/\n    ) public virtual;\n\n    /**\n     * @dev Releases a specific lock record for a wallet\n     * @param _to address to release the tokens for\n     * @param _lockIndex the index of the lock to remove\n     *\n     * note - this may change the order of the locks on an address, so if iterating the iteration should be restarted.\n     * @return true on success\n     */\n    function removeLockRecord(\n        address _to,\n        uint256 _lockIndex /*issuerOrAbove*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev Releases a specific lock record for a investor\n     * @param _investorId investor id to release the tokens for\n     * @param _lockIndex the index of the lock to remove\n     *\n     * note - this may change the order of the locks on an address, so if iterating the iteration should be restarted.\n     * @return true on success\n     */\n    function removeLockRecordForInvestor(\n        string memory _investorId,\n        uint256 _lockIndex /*onlyIssuerOrAbove*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev Get number of locks currently associated with an address\n     * @param _who address to get count for\n     *\n     * @return number of locks\n     *\n     * Note - a lock can be inactive (due to its time expired) but still exists for a specific address\n     */\n    function lockCount(address _who) public view virtual returns (uint256);\n\n    /**\n     * @dev Get number of locks currently associated with a investor\n     * @param _investorId investor id to get count for\n     *\n     * @return number of locks\n     *\n     * Note - a lock can be inactive (due to its time expired) but still exists for a specific address\n     */\n\n    function lockCountForInvestor(string memory _investorId) public view virtual returns (uint256);\n\n    /**\n     * @dev Get details of a specific lock associated with an address\n     * can be used to iterate through the locks of a user\n     * @param _who address to get token lock for\n     * @param _lockIndex the 0 based index of the lock.\n     * @return reasonCode the reason code\n     * @return reasonString the reason for the lock\n     * @return value the value of tokens locked\n     * @return autoReleaseTime the timestamp in which the lock will be inactive (or 0 if it's always active until removed)\n     *\n     * Note - a lock can be inactive (due to its time expired) but still exists for a specific address\n     */\n    function lockInfo(address _who, uint256 _lockIndex) public view virtual returns (uint256 reasonCode, string memory reasonString, uint256 value, uint256 autoReleaseTime);\n\n    /**\n     * @dev Get details of a specific lock associated with a investor\n     * can be used to iterate through the locks of a user\n     * @param _investorId investorId to get token lock for\n     * @param _lockIndex the 0 based index of the lock.\n     * @return reasonCode the reason code\n     * @return reasonString the reason for the lock\n     * @return value the value of tokens locked\n     * @return autoReleaseTime the timestamp in which the lock will be inactive (or 0 if it's always active until removed)\n     *\n     * Note - a lock can be inactive (due to its time expired) but still exists for a specific address\n     */\n    function lockInfoForInvestor(\n        string memory _investorId,\n        uint256 _lockIndex\n    ) public view virtual  returns (uint256 reasonCode, string memory reasonString, uint256 value, uint256 autoReleaseTime);\n\n    /**\n     * @dev get total number of transferable tokens for a wallet, at a certain time\n     * @param _who address to get number of transferable tokens for\n     * @param _time time to calculate for\n     */\n    function getTransferableTokens(address _who, uint256 _time) public view virtual returns (uint256);\n\n    /**\n     * @dev get total number of transferable tokens for a investor, at a certain time\n     * @param _investorId investor id\n     * @param _time time to calculate for\n     */\n    function getTransferableTokensForInvestor(string memory _investorId, uint256 _time) public view virtual returns (uint256);\n\n    /**\n     * @dev pause investor\n     * @param _investorId investor id\n     */\n    function lockInvestor(\n        string memory _investorId /*issuerOrAbove*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev unpauses investor\n     * @param _investorId investor id\n     */\n    function unlockInvestor(\n        string memory _investorId /*issuerOrAbove*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev Returns true if paused, otherwise false\n     * @param _investorId investor id\n     */\n    function isInvestorLocked(string memory _investorId) public view virtual returns (bool);\n}\n"},"contracts/token/IDSTokenPartitioned.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./IDSToken.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSTokenPartitioned {\n\n    function balanceOfByPartition(address _who, bytes32 _partition) public view virtual returns (uint256);\n\n    function balanceOfInvestorByPartition(string memory _id, bytes32 _partition) public view virtual returns (uint256);\n\n    function partitionCountOf(address _who) public view virtual returns (uint256);\n\n    function partitionOf(address _who, uint256 _index) public view virtual returns (bytes32);\n\n    function transferByPartitions(address _to, uint256 _value, bytes32[] memory _partitions, uint256[] memory _values) public virtual returns (bool);\n\n    function transferFromByPartitions(address _from, address _to, uint256 _value, bytes32[] memory _partitions, uint256[] memory _values) public virtual returns (bool);\n\n    function burnByPartition(\n        address _who,\n        uint256 _value,\n        string memory _reason,\n        bytes32 _partition /*onlyIssuerOrAbove*/\n    ) public virtual;\n\n    function seizeByPartition(\n        address _from,\n        address _to,\n        uint256 _value,\n        string memory _reason,\n        bytes32 _partition /*onlyIssuerOrAbove*/\n    ) public virtual;\n\n    event TransferByPartition(address indexed from, address indexed to, uint256 value, bytes32 indexed partition);\n    event IssueByPartition(address indexed to, uint256 value, bytes32 indexed partition);\n    event BurnByPartition(address indexed burner, uint256 value, string reason, bytes32 indexed partition);\n    event SeizeByPartition(address indexed from, address indexed to, uint256 value, string reason, bytes32 indexed partition);\n}\n"},"contracts/data-stores/TokenDataStore.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./ServiceConsumerDataStore.sol\";\nimport '../token/TokenPartitionsLibrary.sol';\nimport '../token/TokenLibrary.sol';\n\n//SPDX-License-Identifier: UNLICENSED\ncontract TokenDataStore is ServiceConsumerDataStore {\n\n    TokenLibrary.TokenData internal tokenData;\n    mapping(address => mapping(address => uint256)) internal allowances;\n    mapping(uint256 => address) internal walletsList;\n    uint256 internal walletsCount;\n    mapping(address => uint256) internal walletsToIndexes;\n    TokenPartitionsLibrary.TokenPartitions internal partitionsManagement;\n    uint256 public cap;\n    string public name;\n    string public symbol;\n    uint8 public decimals;\n    TokenLibrary.SupportedFeatures public supportedFeatures;\n    bool internal paused;\n}\n"},"contracts/service/IDSServiceConsumer.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\nimport \"../omnibus/IDSOmnibusWalletController.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSServiceConsumer is Initializable, VersionedContract {\n\n    function initialize() public virtual {\n        VERSIONS.push(6);\n    }\n\n    uint256 public constant TRUST_SERVICE = 1;\n    uint256 public constant DS_TOKEN = 2;\n    uint256 public constant REGISTRY_SERVICE = 4;\n    uint256 public constant COMPLIANCE_SERVICE = 8;\n    uint256 public constant UNUSED_1 = 16;\n    uint256 public constant WALLET_MANAGER = 32;\n    uint256 public constant LOCK_MANAGER = 64;\n    uint256 public constant PARTITIONS_MANAGER = 128;\n    uint256 public constant COMPLIANCE_CONFIGURATION_SERVICE = 256;\n    uint256 public constant TOKEN_ISSUER = 512;\n    uint256 public constant WALLET_REGISTRAR = 1024;\n    uint256 public constant OMNIBUS_TBE_CONTROLLER = 2048;\n    uint256 public constant TRANSACTION_RELAYER = 4096;\n    uint256 public constant TOKEN_REALLOCATOR = 8192;\n    uint256 public constant SECURITIZE_SWAP = 16384;\n\n    function getDSService(uint256 _serviceId) public view virtual returns (address);\n\n    function setDSService(\n        uint256 _serviceId,\n        address _address /*onlyMaster*/\n    ) public virtual returns (bool);\n\n    event DSServiceSet(uint256 serviceId, address serviceAddress);\n}\n"},"contracts/compliance/IDSWalletManager.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSWalletManager is Initializable, VersionedContract {\n\n    function initialize() public virtual {\n        VERSIONS.push(5);\n    }\n\n    // Special wallets constants\n    uint8 public constant NONE = 0;\n    uint8 public constant ISSUER = 1;\n    uint8 public constant PLATFORM = 2;\n    uint8 public constant EXCHANGE = 4;\n\n    /**\n     * @dev should be emitted when a special wallet is added.\n     */\n    event DSWalletManagerSpecialWalletAdded(address wallet, uint8 walletType, address sender);\n    /**\n     * @dev should be emitted when a special wallet is removed.\n     */\n    event DSWalletManagerSpecialWalletRemoved(address wallet, uint8 walletType, address sender);\n    /**\n     * @dev should be emitted when the number of reserved slots is set for a wallet.\n     */\n    event DSWalletManagerReservedSlotsSet(address wallet, string country, uint8 accreditationStatus, uint256 slots, address sender);\n\n    /**\n     * @dev Sets a wallet to be an special wallet. (internal)\n     * @param _wallet The address of the wallet.\n     * @param _type The type of the wallet.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function setSpecialWallet(address _wallet, uint8 _type) internal virtual returns (bool);\n\n    /**\n     * @dev gets a wallet type\n     * @param _wallet the address of the wallet to check.\n     */\n    function getWalletType(address _wallet) public view virtual returns (uint8);\n\n    /**\n     * @dev Returns true if it is platform wallet\n     * @param _wallet the address of the wallet to check.\n     */\n    function isPlatformWallet(address _wallet) external view virtual returns (bool);\n\n    /**\n     * @dev Returns true if it is special wallet\n     * @param _wallet the address of the wallet to check.\n     */\n    function isSpecialWallet(address _wallet) external view virtual returns (bool);\n\n    /**\n     * @dev Returns true if it is issuer special wallet\n     * @param _wallet the address of the wallet to check.\n     */\n    function isIssuerSpecialWallet(address _wallet) external view virtual returns (bool);\n\n    /**\n     * @dev Sets a wallet to be an issuer wallet.\n     * @param _wallet The address of the wallet.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function addIssuerWallet(\n        address _wallet /*onlyIssuerOrAbove*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev Sets an array of wallets to be issuer wallets.\n     * @param _wallets The address of the wallets.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function addIssuerWallets(address[] memory _wallets) public virtual returns (bool);\n\n    /**\n     * @dev Sets a wallet to be a platform wallet.\n     * @param _wallet The address of the wallet.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function addPlatformWallet(\n        address _wallet /*onlyIssuerOrAbove*/\n    ) public virtual returns (bool);\n\n    /**\n     * @dev Sets an array of wallets to be platforms wallet.\n     * @param _wallets The address of the wallets.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function addPlatformWallets(address[] memory _wallets) public virtual returns (bool);\n\n    /**\n     * @dev Sets a wallet to be an exchange wallet.\n     * @param _wallet The address of the wallet.\n     * @param _owner The address of the owner.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function addExchangeWallet(address _wallet, address _owner) public virtual returns (bool);\n\n    /**\n     * @dev Removes a special wallet.\n     * @param _wallet The address of the wallet.\n     * @return A boolean that indicates if the operation was successful.\n     */\n    function removeSpecialWallet(\n        address _wallet /*onlyIssuerOrAbove*/\n    ) public virtual returns (bool);\n}\n"},"contracts/registry/IDSRegistryService.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/CommonUtils.sol\";\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\nimport \"../omnibus/IDSOmnibusWalletController.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSRegistryService is Initializable, VersionedContract {\n\n    function initialize() public virtual {\n        VERSIONS.push(6);\n    }\n\n    event DSRegistryServiceInvestorAdded(string investorId, address sender);\n    event DSRegistryServiceInvestorRemoved(string investorId, address sender);\n    event DSRegistryServiceInvestorCountryChanged(string investorId, string country, address sender);\n    event DSRegistryServiceInvestorAttributeChanged(string investorId, uint256 attributeId, uint256 value, uint256 expiry, string proofHash, address sender);\n    event DSRegistryServiceWalletAdded(address wallet, string investorId, address sender);\n    event DSRegistryServiceWalletRemoved(address wallet, string investorId, address sender);\n    event DSRegistryServiceOmnibusWalletAdded(address omnibusWallet, string investorId, IDSOmnibusWalletController omnibusWalletController);\n    event DSRegistryServiceOmnibusWalletRemoved(address omnibusWallet, string investorId);\n\n    uint8 public constant NONE = 0;\n    uint8 public constant KYC_APPROVED = 1;\n    uint8 public constant ACCREDITED = 2;\n    uint8 public constant QUALIFIED = 4;\n    uint8 public constant PROFESSIONAL = 8;\n\n    uint8 public constant PENDING = 0;\n    uint8 public constant APPROVED = 1;\n    uint8 public constant REJECTED = 2;\n\n    uint8 public constant EXCHANGE = 4;\n\n    modifier investorExists(string memory _id) {\n        require(isInvestor(_id), \"Unknown investor\");\n        _;\n    }\n\n    modifier newInvestor(string memory _id) {\n        require(!CommonUtils.isEmptyString(_id), \"Investor id must not be empty\");\n        require(!isInvestor(_id), \"Investor already exists\");\n        _;\n    }\n\n    modifier walletExists(address _address) {\n        require(isWallet(_address), \"Unknown wallet\");\n        _;\n    }\n\n    modifier newWallet(address _address) {\n        require(!isWallet(_address), \"Wallet already exists\");\n        _;\n    }\n\n    modifier newOmnibusWallet(address _omnibusWallet) {\n        require(!isOmnibusWallet(_omnibusWallet), \"Omnibus wallet already exists\");\n        _;\n    }\n\n    modifier omnibusWalletExists(address _omnibusWallet) {\n        require(isOmnibusWallet(_omnibusWallet), \"Unknown omnibus wallet\");\n        _;\n    }\n\n    modifier walletBelongsToInvestor(address _address, string memory _id) {\n        require(CommonUtils.isEqualString(getInvestor(_address), _id), \"Wallet does not belong to investor\");\n        _;\n    }\n\n    function registerInvestor(\n        string memory _id,\n        string memory _collision_hash /*onlyExchangeOrAbove newInvestor(_id)*/\n    ) public virtual returns (bool);\n\n    function updateInvestor(\n        string memory _id,\n        string memory _collisionHash,\n        string memory _country,\n        address[] memory _wallets,\n        uint8[] memory _attributeIds,\n        uint256[] memory _attributeValues,\n        uint256[] memory _attributeExpirations /*onlyIssuerOrAbove*/\n    ) public virtual returns (bool);\n\n    function removeInvestor(\n        string memory _id /*onlyExchangeOrAbove investorExists(_id)*/\n    ) public virtual returns (bool);\n\n    function setCountry(\n        string memory _id,\n        string memory _country /*onlyExchangeOrAbove investorExists(_id)*/\n    ) public virtual returns (bool);\n\n    function getCountry(string memory _id) public view virtual returns (string memory);\n\n    function getCollisionHash(string memory _id) public view virtual returns (string memory);\n\n    function setAttribute(\n        string memory _id,\n        uint8 _attributeId,\n        uint256 _value,\n        uint256 _expiry,\n        string memory _proofHash /*onlyExchangeOrAbove investorExists(_id)*/\n    ) public virtual returns (bool);\n\n    function getAttributeValue(string memory _id, uint8 _attributeId) public view virtual returns (uint256);\n\n    function getAttributeExpiry(string memory _id, uint8 _attributeId) public view virtual returns (uint256);\n\n    function getAttributeProofHash(string memory _id, uint8 _attributeId) public view virtual returns (string memory);\n\n    function addWallet(\n        address _address,\n        string memory _id /*onlyExchangeOrAbove newWallet(_address)*/\n    ) public virtual returns (bool);\n\n    function addWalletByInvestor(address _address) public virtual returns (bool);\n\n    function removeWallet(\n        address _address,\n        string memory _id /*onlyExchangeOrAbove walletExists walletBelongsToInvestor(_address, _id)*/\n    ) public virtual returns (bool);\n\n    function addOmnibusWallet(\n        string memory _id,\n        address _omnibusWallet,\n        IDSOmnibusWalletController _omnibusWalletController /*onlyIssuerOrAbove newOmnibusWallet*/\n    ) public virtual;\n\n    function removeOmnibusWallet(\n        string memory _id,\n        address _omnibusWallet /*onlyIssuerOrAbove omnibusWalletControllerExists*/\n    ) public virtual;\n\n    function getOmnibusWalletController(address _omnibusWallet) public view virtual returns (IDSOmnibusWalletController);\n\n    function isOmnibusWallet(address _omnibusWallet) public view virtual returns (bool);\n\n    function getInvestor(address _address) public view virtual returns (string memory);\n\n    function getInvestorDetails(address _address) public view virtual returns (string memory, string memory);\n\n    function getInvestorDetailsFull(string memory _id)\n        public\n        view\n        virtual\n        returns (string memory, uint256[] memory, uint256[] memory, string memory, string memory, string memory, string memory);\n\n    function isInvestor(string memory _id) public view virtual returns (bool);\n\n    function isWallet(address _address) public view virtual returns (bool);\n\n    function isAccreditedInvestor(string calldata _id) external view virtual returns (bool);\n\n    function isQualifiedInvestor(string calldata _id) external view virtual returns (bool);\n\n    function isAccreditedInvestor(address _wallet) external view virtual returns (bool);\n\n    function isQualifiedInvestor(address _wallet) external view virtual returns (bool);\n\n    function getInvestors(address _from, address _to) external view virtual returns (string memory, string memory);\n}\n"},"contracts/compliance/ComplianceService.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/ProxyTarget.sol\";\nimport \"./IDSComplianceService.sol\";\nimport \"../service/ServiceConsumer.sol\";\nimport \"../data-stores/ComplianceServiceDataStore.sol\";\n\n/**\n *   @title Compliance service main implementation.\n *\n *   Combines the different implementation files for the compliance service and serves as a base class for\n *   concrete implementation.\n *\n *   To create a concrete implementation of a compliance service, one should inherit from this contract,\n *   and implement the five functions - recordIssuance,checkTransfer,recordTransfer,recordBurn and recordSeize.\n *   The rest of the functions should only be overridden in rare circumstances.\n */\n//SPDX-License-Identifier: UNLICENSED\nabstract contract ComplianceService is ProxyTarget, Initializable, IDSComplianceService, ServiceConsumer, ComplianceServiceDataStore {\n    function initialize() public virtual override(IDSComplianceService, ServiceConsumer) forceInitializeFromProxy {\n        IDSComplianceService.initialize();\n        ServiceConsumer.initialize();\n        VERSIONS.push(7);\n    }\n\n    function validateTransfer(\n        address _from,\n        address _to,\n        uint256 _value\n    ) public override onlyToken returns (bool) {\n        uint256 code;\n        string memory reason;\n\n        (code, reason) = preTransferCheck(_from, _to, _value);\n        require(code == 0, reason);\n\n        return recordTransfer(_from, _to, _value);\n    }\n\n    function validateTransfer(\n        address _from,\n        address _to,\n        uint256 _value,\n        bool _paused,\n        uint256 _balanceFrom\n    ) public virtual override onlyToken returns (bool) {\n        uint256 code;\n        string memory reason;\n\n        (code, reason) = newPreTransferCheck(_from, _to, _value, _balanceFrom, _paused);\n        require(code == 0, reason);\n\n        return recordTransfer(_from, _to, _value);\n    }\n\n    function validateIssuance(\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime\n    ) public override onlyToken returns (bool) {\n        uint256 code;\n        string memory reason;\n\n        uint256 authorizedSecurities = getComplianceConfigurationService().getAuthorizedSecurities();\n\n        require(authorizedSecurities == 0 || getToken().totalSupply() + _value <= authorizedSecurities,\n            MAX_AUTHORIZED_SECURITIES_EXCEEDED);\n\n        (code, reason) = preIssuanceCheck(_to, _value);\n        require(code == 0, reason);\n\n        uint256 issuanceTime = validateIssuanceTime(_issuanceTime);\n        return recordIssuance(_to, _value, issuanceTime);\n    }\n\n    function validateIssuanceWithNoCompliance(\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime\n    ) public override onlyToken returns (bool) {\n        uint256 authorizedSecurities = getComplianceConfigurationService().getAuthorizedSecurities();\n\n        require(authorizedSecurities == 0 || getToken().totalSupply() + _value <= authorizedSecurities,\n            MAX_AUTHORIZED_SECURITIES_EXCEEDED);\n\n        uint256 issuanceTime = validateIssuanceTime(_issuanceTime);\n        return recordIssuance(_to, _value, issuanceTime);\n    }\n\n    function validateBurn(address _who, uint256 _value) public virtual override onlyToken returns (bool) {\n        return recordBurn(_who, _value);\n    }\n\n    function validateSeize(\n        address _from,\n        address _to,\n        uint256 _value\n    ) public virtual override onlyToken returns (bool) {\n        require(getWalletManager().isIssuerSpecialWallet(_to), \"Target wallet type error\");\n\n        return recordSeize(_from, _to, _value);\n    }\n\n    /**\n     * @dev Verify disallowBackDating compliance: if set to false returns _issuanceTime parameter, otherwise returns current timestamp\n     * @param _issuanceTime.\n     * @return issuanceTime\n     */\n    function validateIssuanceTime(uint256 _issuanceTime) public view override returns (uint256 issuanceTime) {\n        if (!getComplianceConfigurationService().getDisallowBackDating()) {\n            return _issuanceTime;\n        }\n        return block.timestamp;\n    }\n\n    function newPreTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value,\n        uint256 _balanceFrom,\n        bool _pausedToken\n    ) public view virtual returns (uint256 code, string memory reason) {\n        if (_pausedToken) {\n            return (10, TOKEN_PAUSED);\n        }\n\n        if (_balanceFrom < _value) {\n            return (15, NOT_ENOUGH_TOKENS);\n        }\n\n        if (getLockManager().getTransferableTokens(_from, block.timestamp) < _value) {\n            return (16, TOKENS_LOCKED);\n        }\n\n        return checkTransfer(_from, _to, _value);\n    }\n\n    function preTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value\n    ) public view virtual override returns (uint256 code, string memory reason) {\n        if (getToken().isPaused()) {\n            return (10, TOKEN_PAUSED);\n        }\n\n        if (getToken().balanceOf(_from) < _value) {\n            return (15, NOT_ENOUGH_TOKENS);\n        }\n\n        if (getLockManager().getTransferableTokens(_from, block.timestamp) < _value) {\n            return (16, TOKENS_LOCKED);\n        }\n\n        return checkTransfer(_from, _to, _value);\n    }\n\n    function preInternalTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value\n    ) public view virtual override returns (uint256 code, string memory reason) {\n        if (getToken().isPaused()) {\n            return (10, TOKEN_PAUSED);\n        }\n\n        return checkTransfer(_from, _to, _value);\n    }\n\n    function preIssuanceCheck(\n        address, /*_to*/\n        uint256 /*_value*/\n    ) public view virtual override returns (uint256 code, string memory reason) {\n        return (0, VALID);\n    }\n\n    function adjustInvestorCountsAfterCountryChange(\n        string memory, /*_id*/\n        string memory, /*_country*/\n        string memory /*_prevCountry*/\n    ) public virtual override returns (bool) {\n        return true;\n    }\n\n    // These functions should be implemented by the concrete compliance manager\n    function recordIssuance(\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime\n    ) internal virtual returns (bool);\n\n    function recordTransfer(\n        address _from,\n        address _to,\n        uint256 _value\n    ) internal virtual returns (bool);\n\n    function recordBurn(address _who, uint256 _value) internal virtual returns (bool);\n\n    function recordSeize(\n        address _from,\n        address _to,\n        uint256 _value\n    ) internal virtual returns (bool);\n\n    function checkTransfer(\n        address _from,\n        address _to,\n        uint256 _value\n    ) internal view virtual returns (uint256, string memory);\n}\n"},"contracts/omnibus/OmnibusTBEController.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../service/ServiceConsumer.sol\";\nimport \"../utils/ProxyTarget.sol\";\nimport \"../data-stores/OmnibusTBEControllerDataStore.sol\";\nimport \"../compliance/ComplianceServiceRegulated.sol\";\nimport \"../compliance/ComplianceConfigurationService.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\ncontract OmnibusTBEController is ProxyTarget, Initializable, IDSOmnibusTBEController, ServiceConsumer, OmnibusTBEControllerDataStore {\n\n    using SafeMath for uint256;\n    string internal constant MAX_INVESTORS_IN_CATEGORY = \"Max investors in category\";\n\n    function initialize(address _omnibusWallet, bool _isPartitionedToken) public override initializer forceInitializeFromProxy {\n        VERSIONS.push(4);\n        ServiceConsumer.initialize();\n\n        omnibusWallet = _omnibusWallet;\n        isPartitionedToken = _isPartitionedToken;\n    }\n\n    function bulkIssuance(uint256 value, uint256 issuanceTime, uint256 totalInvestors, uint256 accreditedInvestors,\n        uint256 usAccreditedInvestors, uint256 usTotalInvestors, uint256 jpTotalInvestors, bytes32[] memory euRetailCountries,\n        uint256[] memory euRetailCountryCounts) public override onlyIssuerOrAbove {\n        require(euRetailCountries.length == euRetailCountryCounts.length, 'EU Retail countries arrays do not match');\n        // Issue tokens\n        getToken().issueTokensCustom(omnibusWallet, value, issuanceTime, 0, '', 0);\n        addToCounters(totalInvestors, accreditedInvestors,\n            usAccreditedInvestors, usTotalInvestors, jpTotalInvestors, euRetailCountries, euRetailCountryCounts, true);\n        emitTBEOperationEvent(totalInvestors, accreditedInvestors, usAccreditedInvestors, usTotalInvestors, jpTotalInvestors, true);\n    }\n\n    function bulkBurn(uint256 value, uint256 totalInvestors, uint256 accreditedInvestors,\n        uint256 usAccreditedInvestors, uint256 usTotalInvestors, uint256 jpTotalInvestors, bytes32[] memory euRetailCountries,\n        uint256[] memory euRetailCountryCounts) public override onlyTransferAgentOrAbove {\n        require(euRetailCountries.length == euRetailCountryCounts.length, 'EU Retail countries arrays do not match');\n\n        if(isPartitionedToken) {\n            IDSTokenPartitioned token = getTokenPartitioned();\n            uint256 pendingBurn = value;\n            uint256 currentPartitionBalance;\n            bytes32 partition;\n            while(pendingBurn > 0) {\n                require(token.partitionCountOf(omnibusWallet) > 0, 'Not enough tokens in partitions to burn the required value');\n                partition = token.partitionOf(omnibusWallet, 0);\n                currentPartitionBalance = token.balanceOfByPartition(omnibusWallet, partition);\n                require(currentPartitionBalance > 0, 'Not enough tokens in remaining partitions to burn the required value');\n                uint256 amountToBurn = currentPartitionBalance >= pendingBurn ? pendingBurn : currentPartitionBalance;\n                token.burnByPartition(omnibusWallet, amountToBurn, 'Omnibus burn by partition', partition);\n                pendingBurn = pendingBurn - amountToBurn;\n            }\n        } else {\n            // Burn non partitioned tokens\n            getToken().burn(omnibusWallet, value, 'Omnibus');\n        }\n\n        emitTBEOperationEvent(totalInvestors, accreditedInvestors, usAccreditedInvestors, usTotalInvestors, jpTotalInvestors, false);\n    }\n\n    function bulkTransfer(address[] memory wallets, uint256[] memory values) public override onlyIssuerOrTransferAgentOrAbove {\n        require(wallets.length == values.length, 'Wallets and values lengths do not match');\n        for (uint i = 0; i < wallets.length; i++) {\n            getToken().transferFrom(omnibusWallet, wallets[i], values[i]);\n        }\n    }\n\n    function internalTBETransfer(string memory externalId, int256 totalDelta, int256 accreditedDelta,\n        int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta, bytes32[] memory euRetailCountries,\n        int256[] memory euRetailCountryDeltas) public onlyIssuerOrTransferAgentOrAbove {\n        adjustCounters(totalDelta, accreditedDelta, usAccreditedDelta, usTotalDelta, jpTotalDelta,\n            euRetailCountries, euRetailCountryDeltas);\n        getToken().emitOmnibusTBETransferEvent(omnibusWallet, externalId);\n    }\n\n    function adjustCounters(int256 totalDelta, int256 accreditedDelta,\n        int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta, bytes32[] memory euRetailCountries,\n        int256[] memory euRetailCountryDeltas) public override onlyIssuerOrTransferAgentOrAbove {\n        require(euRetailCountries.length == euRetailCountryDeltas.length, 'Array lengths do not match');\n\n        addToCounters(\n            totalDelta > 0 ? uint256(totalDelta) : 0,\n            accreditedDelta > 0 ? uint256(accreditedDelta) : 0,\n            usAccreditedDelta > 0 ? uint256(usAccreditedDelta) : 0,\n            usTotalDelta > 0 ? uint256(usTotalDelta) : 0,\n            jpTotalDelta > 0 ? uint256(jpTotalDelta) : 0,\n            euRetailCountries,\n            getUintEuCountriesDeltas(euRetailCountryDeltas, true),\n            true\n        );\n\n        getToken().emitOmnibusTBEEvent(\n            omnibusWallet,\n            totalDelta,\n            accreditedDelta,\n            usAccreditedDelta,\n            usTotalDelta,\n            jpTotalDelta);\n    }\n\n    function getOmnibusWallet() public view override returns (address) {\n        return omnibusWallet;\n    }\n\n    function addToCounters(uint256 _totalInvestors, uint256 _accreditedInvestors,\n        uint256 _usAccreditedInvestors, uint256 _usTotalInvestors, uint256 _jpTotalInvestors, bytes32[] memory _euRetailCountries,\n        uint256[] memory _euRetailCountryCounts,  bool _increase) internal returns (bool) {\n        if(_increase) {\n            ComplianceServiceRegulated cs = ComplianceServiceRegulated(getDSService(COMPLIANCE_SERVICE));\n            IDSComplianceConfigurationService ccs = IDSComplianceConfigurationService(getDSService(COMPLIANCE_CONFIGURATION_SERVICE));\n\n            require(ccs.getNonAccreditedInvestorsLimit() == 0 || (cs.getTotalInvestorsCount() - cs.getAccreditedInvestorsCount()\n             + _totalInvestors - _accreditedInvestors <= ccs.getNonAccreditedInvestorsLimit()), MAX_INVESTORS_IN_CATEGORY);\n\n            cs.setTotalInvestorsCount(increaseCounter(cs.getTotalInvestorsCount(), ccs.getTotalInvestorsLimit(), _totalInvestors));\n            cs.setAccreditedInvestorsCount(increaseCounter(cs.getAccreditedInvestorsCount(), ccs.getTotalInvestorsLimit(), _accreditedInvestors));\n            cs.setUSAccreditedInvestorsCount(increaseCounter(cs.getUSAccreditedInvestorsCount(), ccs.getUSAccreditedInvestorsLimit(), _usAccreditedInvestors));\n            cs.setUSInvestorsCount(increaseCounter(cs.getUSInvestorsCount(), ccs.getUSInvestorsLimit(), _usTotalInvestors));\n            cs.setJPInvestorsCount(increaseCounter(cs.getJPInvestorsCount(), ccs.getJPInvestorsLimit(), _jpTotalInvestors));\n            for (uint i = 0; i < _euRetailCountries.length; i++) {\n                string memory countryCode = bytes32ToString(_euRetailCountries[i]);\n                cs.setEURetailInvestorsCount(\n                    countryCode,\n                    increaseCounter(\n                            cs.getEURetailInvestorsCount(countryCode),\n                            ccs.getEURetailInvestorsLimit(),\n                            _euRetailCountryCounts[i]\n                   )\n                );\n            }\n        }\n\n        return true;\n    }\n\n    function emitTBEOperationEvent(uint256 _totalInvestors, uint256 _accreditedInvestors,\n        uint256 _usAccreditedInvestors, uint256 _usTotalInvestors, uint256 _jpTotalInvestors, bool /* _increase */) internal {\n        getToken().emitOmnibusTBEEvent(\n            omnibusWallet,\n            int256(_totalInvestors),\n            int256(_accreditedInvestors),\n            int256(_usAccreditedInvestors),\n            int256(_usTotalInvestors),\n            int256(_jpTotalInvestors)\n        );\n    }\n\n    function getUintEuCountriesDeltas(int256[] memory euCountryDeltas,  bool increase) internal pure returns (uint256[] memory) {\n        uint256[] memory result = new uint256[](euCountryDeltas.length);\n\n        for (uint i = 0; i < euCountryDeltas.length; i++) {\n            if (increase) {\n                result[i] = euCountryDeltas[i] > 0 ? uint256(euCountryDeltas[i]) : 0;\n            } else {\n                result[i] = euCountryDeltas[i] < 0 ? uint256(euCountryDeltas[i] * -1) : 0;\n            }\n        }\n        return result;\n    }\n\n    function increaseCounter(uint256 currentValue, uint256 currentLimit, uint256 delta) internal pure returns (uint256) {\n        uint256 result = currentValue + delta;\n        require(currentLimit == 0 || result <= currentLimit, MAX_INVESTORS_IN_CATEGORY);\n        return result;\n    }\n\n    function bytes32ToString(bytes32 _bytes32) internal pure returns (string memory) {\n        uint8 i = 0;\n        while(i < 32 && _bytes32[i] != 0) {\n            i++;\n        }\n        bytes memory bytesArray = new bytes(i);\n        for (i = 0; i < 32 && _bytes32[i] != 0; i++) {\n            bytesArray[i] = _bytes32[i];\n        }\n        return string(bytesArray);\n    }\n}\n"},"contracts/token/TokenPartitionsLibrary.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/CommonUtils.sol\";\nimport \"../compliance/IDSComplianceServicePartitioned.sol\";\nimport \"../compliance/IDSLockManagerPartitioned.sol\";\nimport \"../registry/IDSRegistryService.sol\";\nimport \"../compliance/IDSComplianceConfigurationService.sol\";\nimport \"../compliance/IDSPartitionsManager.sol\";\nimport \"../omnibus/IDSOmnibusTBEController.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nlibrary TokenPartitionsLibrary {\n    using SafeMath for uint256;\n\n    uint256 internal constant COMPLIANCE_SERVICE = 0;\n    uint256 internal constant REGISTRY_SERVICE = 1;\n    uint256 internal constant OMNIBUS_TBE_CONTROLLER = 2;\n\n    event IssueByPartition(address indexed to, uint256 value, bytes32 indexed partition);\n    event TransferByPartition(address indexed from, address indexed to, uint256 value, bytes32 indexed partition);\n    struct AddressPartitions {\n        uint256 count;\n        mapping(bytes32 => uint256) toIndex;\n        mapping(uint256 => bytes32) partitions;\n        mapping(bytes32 => uint256) balances;\n    }\n\n    struct TokenPartitions {\n        mapping(address => AddressPartitions) walletPartitions;\n        mapping(string => mapping(bytes32 => uint256)) investorPartitionsBalances;\n    }\n\n    function issueTokensCustom(\n        TokenPartitions storage self,\n        IDSRegistryService _registry,\n        IDSComplianceConfigurationService _compConf,\n        IDSPartitionsManager _partitionsManager,\n        IDSLockManagerPartitioned _lockManager,\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime,\n        uint256[] memory _valuesLocked,\n        string memory _reason,\n        uint64[] memory _releaseTimes\n    ) public returns (bool) {\n        string memory investor = _registry.getInvestor(_to);\n        string memory country = _registry.getCountry(investor);\n        bytes32 partition = _partitionsManager.ensurePartition(_issuanceTime, _compConf.getCountryCompliance(country));\n        emit IssueByPartition(_to, _value, partition);\n        transferPartition(self, _registry, address(0), _to, _value, partition);\n        uint256 totalLocked = 0;\n        for (uint256 i = 0; i < _valuesLocked.length; i++) {\n            totalLocked += _valuesLocked[i];\n            _lockManager.createLockForInvestor(investor, _valuesLocked[i], 0, _reason, _releaseTimes[i], partition);\n        }\n        require(totalLocked <= _value, \"valueLocked must be smaller than value\");\n\n        return true;\n    }\n\n    function issueTokensWithNoCompliance(\n        TokenPartitions storage self,\n        IDSRegistryService _registry,\n        IDSComplianceConfigurationService _compConf,\n        IDSPartitionsManager _partitionsManager,\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime\n    ) public returns (bool) {\n        string memory investor = _registry.getInvestor(_to);\n        string memory country = _registry.getCountry(investor);\n        bytes32 partition = _partitionsManager.ensurePartition(_issuanceTime, _compConf.getCountryCompliance(country));\n        emit IssueByPartition(_to, _value, partition);\n        transferPartition(self, _registry, address(0), _to, _value, partition);\n        return true;\n    }\n\n    function setPartitionToAddressImpl(TokenPartitions storage self, address _who, uint256 _index, bytes32 _partition) internal returns (bool) {\n        self.walletPartitions[_who].partitions[_index] = _partition;\n        self.walletPartitions[_who].toIndex[_partition] = _index;\n        return true;\n    }\n\n    function addPartitionToAddress(TokenPartitions storage self, address _who, bytes32 _partition) internal {\n        uint256 partitionCount = self.walletPartitions[_who].count;\n        setPartitionToAddressImpl(self, _who, self.walletPartitions[_who].count, _partition);\n        self.walletPartitions[_who].count = SafeMath.add(partitionCount, 1);\n    }\n\n    function removePartitionFromAddress(TokenPartitions storage self, address _from, bytes32 _partition) internal {\n        uint256 oldIndex = self.walletPartitions[_from].toIndex[_partition];\n        uint256 lastPartitionIndex = SafeMath.sub(self.walletPartitions[_from].count, 1);\n        bytes32 lastPartition = self.walletPartitions[_from].partitions[lastPartitionIndex];\n\n        setPartitionToAddressImpl(self, _from, oldIndex, lastPartition);\n\n        delete self.walletPartitions[_from].partitions[lastPartitionIndex];\n        delete self.walletPartitions[_from].toIndex[_partition];\n        delete self.walletPartitions[_from].balances[_partition];\n        self.walletPartitions[_from].count = SafeMath.sub(self.walletPartitions[_from].count, 1);\n    }\n\n    function transferPartition(TokenPartitions storage self, IDSRegistryService _registry, address _from, address _to, uint256 _value, bytes32 _partition) public {\n        if (_from != address(0)) {\n            self.walletPartitions[_from].balances[_partition] = SafeMath.sub(self.walletPartitions[_from].balances[_partition], _value);\n            updateInvestorPartitionBalance(self, _registry, _from, _value, CommonUtils.IncDec.Decrease, _partition);\n            if (self.walletPartitions[_from].balances[_partition] == 0) {\n                removePartitionFromAddress(self, _from, _partition);\n            }\n        }\n\n        if (_to != address(0)) {\n            if (self.walletPartitions[_to].balances[_partition] == 0 && _value > 0) {\n                addPartitionToAddress(self, _to, _partition);\n            }\n            self.walletPartitions[_to].balances[_partition] += _value;\n            updateInvestorPartitionBalance(self, _registry, _to, _value, CommonUtils.IncDec.Increase, _partition);\n        }\n        emit TransferByPartition(_from, _to, _value, _partition);\n    }\n\n    function transferPartitions(TokenPartitions storage self, address[] memory _services, address _from, address _to, uint256 _value) public returns (bool) {\n        uint256 partitionCount = partitionCountOf(self, _from);\n        uint256 index = 0;\n        bool skipComplianceCheck = shouldSkipComplianceCheck(IDSRegistryService(_services[REGISTRY_SERVICE]),\n            IDSOmnibusTBEController(_services[OMNIBUS_TBE_CONTROLLER]), _from, _to);\n        while (_value > 0 && index < partitionCount) {\n            bytes32 partition = partitionOf(self, _from, index);\n            uint256 transferableInPartition = skipComplianceCheck\n                ? self.walletPartitions[_from].balances[partition]\n                : IDSComplianceServicePartitioned(_services[COMPLIANCE_SERVICE]).getComplianceTransferableTokens(_from, block.timestamp, _to, partition);\n            uint256 transferable = Math.min(_value, transferableInPartition);\n            if (transferable > 0) {\n                if (self.walletPartitions[_from].balances[partition] == transferable) {\n                    unchecked {\n                        --index;\n                        --partitionCount;\n                    }\n                }\n                transferPartition(self, IDSRegistryService(_services[REGISTRY_SERVICE]), _from, _to, transferable, partition);\n                _value -= transferable;\n            }\n            unchecked {\n                ++index;\n            }\n        }\n\n        require(_value == 0);\n\n        return true;\n    }\n\n    function transferPartitions(\n        TokenPartitions storage self,\n        address[] memory _services,\n        address _from,\n        address _to,\n        uint256 _value,\n        bytes32[] memory _partitions,\n        uint256[] memory _values\n    ) public returns (bool) {\n        require(_partitions.length == _values.length);\n        bool skipComplianceCheck = shouldSkipComplianceCheck(IDSRegistryService(_services[REGISTRY_SERVICE]),\n            IDSOmnibusTBEController(_services[OMNIBUS_TBE_CONTROLLER]), _from, _to);\n        for (uint256 index = 0; index < _partitions.length; ++index) {\n            if (!skipComplianceCheck) {\n                require(_values[index] <= IDSComplianceServicePartitioned(_services[COMPLIANCE_SERVICE]).getComplianceTransferableTokens(_from, block.timestamp, _to, _partitions[index]));\n            }\n            transferPartition(self, IDSRegistryService(_services[REGISTRY_SERVICE]), _from, _to, _values[index], _partitions[index]);\n            _value -= _values[index];\n        }\n\n        require(_value == 0);\n        return true;\n    }\n\n    function balanceOfByPartition(TokenPartitions storage self, address _who, bytes32 _partition) internal view returns (uint256) {\n        return self.walletPartitions[_who].balances[_partition];\n    }\n\n    function balanceOfInvestorByPartition(TokenPartitions storage self, string memory _id, bytes32 _partition) internal view returns (uint256) {\n        return self.investorPartitionsBalances[_id][_partition];\n    }\n\n    function partitionCountOf(TokenPartitions storage self, address _who) internal view returns (uint256) {\n        return self.walletPartitions[_who].count;\n    }\n\n    function partitionOf(TokenPartitions storage self, address _who, uint256 _index) internal view returns (bytes32) {\n        return self.walletPartitions[_who].partitions[_index];\n    }\n\n    function updateInvestorPartitionBalance(TokenPartitions storage self, IDSRegistryService _registry, address _wallet, uint256 _value, CommonUtils.IncDec _increase, bytes32 _partition)\n        internal\n        returns (bool)\n    {\n        string memory investor = _registry.getInvestor(_wallet);\n        if (!CommonUtils.isEmptyString(investor)) {\n            uint256 balance = self.investorPartitionsBalances[investor][_partition];\n            if (_increase == CommonUtils.IncDec.Increase) {\n                balance = SafeMath.add(balance, _value);\n            } else {\n                balance = SafeMath.sub(balance, _value);\n            }\n            self.investorPartitionsBalances[investor][_partition] = balance;\n        }\n        return true;\n    }\n\n    function shouldSkipComplianceCheck(IDSRegistryService _registry, IDSOmnibusTBEController _omnibusTBEController, address _from, address _to) internal view returns (bool) {\n        return CommonUtils.isEqualString(_registry.getInvestor(_from), _registry.getInvestor(_to)) ||\n            (address(_omnibusTBEController) != address(0) && (_omnibusTBEController.getOmnibusWallet() == _from ||\n                _omnibusTBEController.getOmnibusWallet() == _to));\n    }\n}\n"},"@openzeppelin/contracts/utils/math/Math.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 Math {\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"},"contracts/compliance/IDSComplianceService.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSComplianceService is Initializable, VersionedContract {\n\n    function initialize() public virtual {\n        VERSIONS.push(7);\n    }\n\n    uint256 internal constant NONE = 0;\n    uint256 internal constant US = 1;\n    uint256 internal constant EU = 2;\n    uint256 internal constant FORBIDDEN = 4;\n    uint256 internal constant JP = 8;\n    string internal constant TOKEN_PAUSED = \"Token Paused\";\n    string internal constant NOT_ENOUGH_TOKENS = \"Not Enough Tokens\";\n    string internal constant TOKENS_LOCKED = \"Tokens Locked\";\n    string internal constant WALLET_NOT_IN_REGISTRY_SERVICE = \"Wallet not in registry Service\";\n    string internal constant DESTINATION_RESTRICTED = \"Destination restricted\";\n    string internal constant VALID = \"Valid\";\n    string internal constant HOLD_UP = \"Under lock-up\";\n    string internal constant ONLY_FULL_TRANSFER = \"Only Full Transfer\";\n    string internal constant FLOWBACK = \"Flowback\";\n    string internal constant MAX_INVESTORS_IN_CATEGORY = \"Max Investors in category\";\n    string internal constant AMOUNT_OF_TOKENS_UNDER_MIN = \"Amount of tokens under min\";\n    string internal constant AMOUNT_OF_TOKENS_ABOVE_MAX = \"Amount of tokens above max\";\n    string internal constant ONLY_ACCREDITED = \"Only accredited\";\n    string internal constant ONLY_US_ACCREDITED = \"Only us accredited\";\n    string internal constant NOT_ENOUGH_INVESTORS = \"Not enough investors\";\n    string internal constant MAX_AUTHORIZED_SECURITIES_EXCEEDED = \"Max authorized securities exceeded\";\n\n    function adjustInvestorCountsAfterCountryChange(\n        string memory _id,\n        string memory _country,\n        string memory _prevCountry\n    ) public virtual returns (bool);\n\n    //*****************************************\n    // TOKEN ACTION VALIDATIONS\n    //*****************************************\n\n    function validateTransfer(\n        address _from,\n        address _to,\n        uint256 _value /*onlyToken*/\n    ) public virtual returns (bool);\n\n    function validateTransfer(\n        address _from,\n        address _to,\n        uint256 _value, /*onlyToken*/\n        bool _pausedToken,\n        uint256 _balanceFrom\n    ) public virtual returns (bool);\n\n    function validateIssuance(\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime /*onlyToken*/\n    ) public virtual returns (bool);\n\n    function validateIssuanceWithNoCompliance(\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime /*onlyToken*/\n    ) public virtual returns (bool);\n\n    function validateBurn(\n        address _who,\n        uint256 _value /*onlyToken*/\n    ) public virtual returns (bool);\n\n    function validateSeize(\n        address _from,\n        address _to,\n        uint256 _value /*onlyToken*/\n    ) public virtual returns (bool);\n\n    function preIssuanceCheck(address _to, uint256 _value) public view virtual returns (uint256 code, string memory reason);\n\n    function preTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value\n    ) public view virtual returns (uint256 code, string memory reason);\n\n    function preInternalTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value\n    ) public view virtual returns (uint256 code, string memory reason);\n\n    function validateIssuanceTime(uint256 _issuanceTime) public view virtual returns (uint256 issuanceTime);\n}\n"},"contracts/compliance/IDSPartitionsManager.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../service/IDSServiceConsumer.sol\";\nimport \"../utils/Initializable.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSPartitionsManager is Initializable, IDSServiceConsumer {\n\n    event PartitionCreated(uint256 _date, uint256 _region, bytes32 _partition);\n\n    function initialize() public virtual override {\n        VERSIONS.push(2);\n    }\n\n    function ensurePartition(\n        uint256 _issuanceDate,\n        uint256 _region /*onlyIssuerOrAboveOrToken*/\n    ) public virtual returns (bytes32 partition);\n\n    function getPartition(bytes32 _partition) public view virtual returns (uint256 date, uint256 region);\n\n    function getPartitionIssuanceDate(bytes32 _partition) public view virtual returns (uint256);\n\n    function getPartitionRegion(bytes32 _partition) public view virtual returns (uint256);\n}\n"},"contracts/omnibus/IDSOmnibusTBEController.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../service/ServiceConsumer.sol\";\nimport \"../utils/ProxyTarget.sol\";\nimport \"../data-stores/OmnibusTBEControllerDataStore.sol\";\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSOmnibusTBEController is Initializable, VersionedContract {\n    using SafeMath for uint256;\n\n    function initialize(address _omnibusWallet, bool _isPartitionedToken) public virtual;\n\n    function bulkIssuance(uint256 value, uint256 issuanceTime, uint256 totalInvestors, uint256 accreditedInvestors,\n        uint256 usAccreditedInvestors, uint256 usTotalInvestors, uint256 jpTotalInvestors, bytes32[] memory euRetailCountries,\n        uint256[] memory euRetailCountryCounts) public virtual;\n\n    function bulkBurn(uint256 value, uint256 totalInvestors, uint256 accreditedInvestors,\n        uint256 usAccreditedInvestors, uint256 usTotalInvestors, uint256 jpTotalInvestors, bytes32[] memory euRetailCountries,\n        uint256[] memory euRetailCountryCounts) public virtual;\n\n    function bulkTransfer(address[] memory wallets, uint256[] memory values) public virtual;\n\n    function adjustCounters(int256 totalDelta, int256 accreditedDelta,\n        int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta, bytes32[] memory euRetailCountries,\n        int256[] memory euRetailCountryDeltas) public virtual;\n\n    function getOmnibusWallet() public view virtual returns (address);\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"},"@openzeppelin/contracts/utils/math/SafeMath.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)\n\npragma solidity ^0.8.0;\n\n// CAUTION\n// This version of SafeMath should only be used with Solidity 0.8 or later,\n// because it relies on the compiler's built in overflow checks.\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations.\n *\n * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\n * now has built in overflow checking.\n */\nlibrary SafeMath {\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     *\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a + b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     *\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a * b;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator.\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a % b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {trySub}.\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(\n        uint256 a,\n        uint256 b,\n        string memory errorMessage\n    ) internal pure returns (uint256) {\n        unchecked {\n            require(b <= a, errorMessage);\n            return a - b;\n        }\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(\n        uint256 a,\n        uint256 b,\n        string memory errorMessage\n    ) internal pure returns (uint256) {\n        unchecked {\n            require(b > 0, errorMessage);\n            return a / b;\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting with custom message when dividing by zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryMod}.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(\n        uint256 a,\n        uint256 b,\n        string memory errorMessage\n    ) internal pure returns (uint256) {\n        unchecked {\n            require(b > 0, errorMessage);\n            return a % b;\n        }\n    }\n}\n"},"contracts/omnibus/IDSOmnibusWalletController.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSOmnibusWalletController is Initializable, VersionedContract {\n    uint8 public constant BENEFICIARY = 0;\n    uint8 public constant HOLDER_OF_RECORD = 1;\n\n    function initialize(address _omnibusWallet) public virtual;\n\n    function setAssetTrackingMode(uint8 _assetTrackingMode) public virtual;\n\n    function getAssetTrackingMode() public view virtual returns (uint8);\n\n    function isHolderOfRecord() public view virtual returns (bool);\n\n    function balanceOf(address _who) public view virtual returns (uint256);\n\n    function transfer(\n        address _from,\n        address _to,\n        uint256 _value /*onlyOperator*/\n    ) public virtual;\n\n    function deposit(\n        address _to,\n        uint256 _value /*onlyToken*/\n    ) public virtual;\n\n    function withdraw(\n        address _from,\n        uint256 _value /*onlyToken*/\n    ) public virtual;\n\n    function seize(\n        address _from,\n        uint256 _value /*onlyToken*/\n    ) public virtual;\n\n    function burn(\n        address _from,\n        uint256 _value /*onlyToken*/\n    ) public virtual;\n}\n"},"contracts/compliance/IDSLockManagerPartitioned.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./IDSLockManager.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSLockManagerPartitioned is Initializable, VersionedContract {\n\n    event LockedPartition(address indexed who, uint256 value, uint256 indexed reason, string reasonString, uint256 releaseTime, bytes32 indexed partition);\n    event UnlockedPartition(address indexed who, uint256 value, uint256 indexed reason, string reasonString, uint256 releaseTime, bytes32 indexed partition);\n    event HolderLockedPartition(string investorId, uint256 value, uint256 indexed reason, string reasonString, uint256 releaseTime, bytes32 indexed partition);\n    event HolderUnlockedPartition(string investorId, uint256 value, uint256 indexed reason, string reasonString, uint256 releaseTime, bytes32 indexed partition);\n\n    function createLockForInvestor(\n        string memory _investorId,\n        uint256 _valueLocked,\n        uint256 _reasonCode,\n        string memory _reasonString,\n        uint256 _releaseTime,\n        bytes32 _partition\n    ) public virtual;\n\n    function addManualLockRecord(\n        address _to,\n        uint256 _valueLocked,\n        string memory _reason,\n        uint256 _releaseTime,\n        bytes32 _partition /*issuerOrAboveOrToken*/\n    ) public virtual;\n\n    function removeLockRecord(\n        address _to,\n        uint256 _lockIndex,\n        bytes32 _partition /*issuerOrAbove*/\n    ) public virtual returns (bool);\n\n    function removeLockRecordForInvestor(\n        string memory _investorId,\n        uint256 _lockIndex,\n        bytes32 _partition /*issuerOrAbove*/\n    ) public virtual returns (bool);\n\n    function lockCount(address _who, bytes32 _partition) public view virtual returns (uint256);\n\n    function lockInfo(\n        address _who,\n        uint256 _lockIndex,\n        bytes32 _partition\n    )\n        public\n        view\n        virtual\n        returns (\n            uint256 reasonCode,\n            string memory reasonString,\n            uint256 value,\n            uint256 autoReleaseTime\n        );\n\n    function lockCountForInvestor(string memory _investorId, bytes32 _partition) public view virtual returns (uint256);\n\n    function lockInfoForInvestor(\n        string memory _investorId,\n        uint256 _lockIndex,\n        bytes32 _partition\n    )\n        public\n        view\n        virtual\n        returns (\n            uint256 reasonCode,\n            string memory reasonString,\n            uint256 value,\n            uint256 autoReleaseTime\n        );\n\n    function getTransferableTokens(\n        address _who,\n        uint256 _time,\n        bytes32 _partition\n    ) public view virtual returns (uint256);\n\n    function getTransferableTokensForInvestor(\n        string memory _investorId,\n        uint256 _time,\n        bytes32 _partition\n    ) public view virtual returns (uint256);\n\n    /*************** Legacy functions ***************/\n    function createLockForHolder(\n        string memory _investorId,\n        uint256 _valueLocked,\n        uint256 _reasonCode,\n        string memory _reasonString,\n        uint256 _releaseTime,\n        bytes32 _partition\n    ) public virtual;\n\n    function removeLockRecordForHolder(\n        string memory _investorId,\n        uint256 _lockIndex,\n        bytes32 _partition\n    ) public virtual returns (bool);\n\n    function lockCountForHolder(string memory _holderId, bytes32 _partition) public view virtual returns (uint256);\n\n    function lockInfoForHolder(\n        string memory _holderId,\n        uint256 _lockIndex,\n        bytes32 _partition\n    )\n        public\n        view\n        virtual\n        returns (\n            uint256 reasonCode,\n            string memory reasonString,\n            uint256 value,\n            uint256 autoReleaseTime\n        );\n\n    function getTransferableTokensForHolder(\n        string memory _holderId,\n        uint256 _time,\n        bytes32 _partition\n    ) public view virtual returns (uint256);\n\n    /******************************/\n}\n"},"contracts/data-stores/ServiceConsumerDataStore.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\ncontract ServiceConsumerDataStore {\n    using SafeMath for uint256;\n\n    mapping(uint256 => address) internal services;\n}\n"},"contracts/compliance/ComplianceServiceRegulated.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./ComplianceServiceWhitelisted.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\n\nlibrary ComplianceServiceLibrary {\n    uint256 internal constant DS_TOKEN = 0;\n    uint256 internal constant REGISTRY_SERVICE = 1;\n    uint256 internal constant WALLET_MANAGER = 2;\n    uint256 internal constant COMPLIANCE_CONFIGURATION_SERVICE = 3;\n    uint256 internal constant LOCK_MANAGER = 4;\n    uint256 internal constant COMPLIANCE_SERVICE = 5;\n    uint256 internal constant OMNIBUS_TBE_CONTROLLER = 6;\n    uint256 internal constant NONE = 0;\n    uint256 internal constant US = 1;\n    uint256 internal constant EU = 2;\n    uint256 internal constant FORBIDDEN = 4;\n    uint256 internal constant JP = 8;\n    string internal constant TOKEN_PAUSED = \"Token paused\";\n    string internal constant NOT_ENOUGH_TOKENS = \"Not enough tokens\";\n    string internal constant VALID = \"Valid\";\n    string internal constant TOKENS_LOCKED = \"Tokens locked\";\n    string internal constant ONLY_FULL_TRANSFER = \"Only full transfer\";\n    string internal constant FLOWBACK = \"Flowback\";\n    string internal constant WALLET_NOT_IN_REGISTRY_SERVICE = \"Wallet not in registry service\";\n    string internal constant AMOUNT_OF_TOKENS_UNDER_MIN = \"Amount of tokens under min\";\n    string internal constant AMOUNT_OF_TOKENS_ABOVE_MAX = \"Amount of tokens above max\";\n    string internal constant HOLD_UP = \"Under lock-up\";\n    string internal constant DESTINATION_RESTRICTED = \"Destination restricted\";\n    string internal constant MAX_INVESTORS_IN_CATEGORY = \"Max investors in category\";\n    string internal constant ONLY_ACCREDITED = \"Only accredited\";\n    string internal constant ONLY_US_ACCREDITED = \"Only us accredited\";\n    string internal constant NOT_ENOUGH_INVESTORS = \"Not enough investors\";\n\n    struct CompletePreTransferCheckArgs {\n        address from;\n        address to;\n        uint256 value;\n        uint256 fromInvestorBalance;\n        uint256 fromRegion;\n        bool isPlatformWalletTo;\n    }\n\n    using SafeMath for uint256;\n\n    function isRetail(address[] memory _services, address _wallet) internal view returns (bool) {\n        IDSRegistryService registry = IDSRegistryService(_services[REGISTRY_SERVICE]);\n\n        return !registry.isQualifiedInvestor(_wallet);\n    }\n\n    function isAccredited(address[] memory _services, address _wallet) internal view returns (bool) {\n        IDSRegistryService registry = IDSRegistryService(_services[REGISTRY_SERVICE]);\n\n        return registry.isAccreditedInvestor(_wallet);\n    }\n\n    function balanceOfInvestor(address[] memory _services, address _wallet) internal view returns (uint256) {\n        IDSRegistryService registry = IDSRegistryService(_services[REGISTRY_SERVICE]);\n        IDSToken token = IDSToken(_services[DS_TOKEN]);\n\n        return token.balanceOfInvestor(registry.getInvestor(_wallet));\n    }\n\n    function isNewInvestor(address[] memory _services, address _to, uint256 _balanceOfInvestorTo) internal view returns (bool) {\n        IDSOmnibusTBEController omnibusTBEController = IDSOmnibusTBEController(_services[OMNIBUS_TBE_CONTROLLER]);\n\n        // Return whether this investor has 0 balance and is not an omnibus TBE wallet\n        return _balanceOfInvestorTo == 0 && !isOmnibusTBE(omnibusTBEController, _to);\n    }\n\n    function getCountry(address[] memory _services, address _wallet) internal view returns (string memory) {\n        IDSRegistryService registry = IDSRegistryService(_services[REGISTRY_SERVICE]);\n\n        return registry.getCountry(registry.getInvestor(_wallet));\n    }\n\n    function getCountryCompliance(address[] memory _services, address _wallet) internal view returns (uint256) {\n        return IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getCountryCompliance(getCountry(_services, _wallet));\n    }\n\n    function getUSInvestorsLimit(address[] memory _services) internal view returns (uint256) {\n        ComplianceServiceRegulated complianceService = ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]);\n        IDSComplianceConfigurationService compConfService = IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]);\n\n        if (compConfService.getMaxUSInvestorsPercentage() == 0) {\n            return compConfService.getUSInvestorsLimit();\n        }\n\n        if (compConfService.getUSInvestorsLimit() == 0) {\n            return compConfService.getMaxUSInvestorsPercentage().mul(complianceService.getTotalInvestorsCount()).div(100);\n        }\n\n        return Math.min(compConfService.getUSInvestorsLimit(), compConfService.getMaxUSInvestorsPercentage().mul(complianceService.getTotalInvestorsCount()).div(100));\n    }\n\n    function isOmnibusTBE(IDSOmnibusTBEController _omnibusTBE, address _from) public view returns (bool) {\n        if (address(_omnibusTBE) != address(0)) {\n            return _omnibusTBE.getOmnibusWallet() == _from;\n        }\n        return false;\n    }\n\n    function checkHoldUp(\n        address[] memory _services,\n        address _from,\n        uint256 _value,\n        bool _isUSLockPeriod,\n        bool _isPlatformWalletFrom\n    ) internal view returns (bool) {\n        ComplianceServiceRegulated complianceService = ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]);\n        uint64 lockPeriod;\n        if (_isUSLockPeriod) {\n            lockPeriod = uint64(IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getUSLockPeriod());\n        } else {\n            lockPeriod = uint64(IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getNonUSLockPeriod());\n        }\n\n        return\n        !_isPlatformWalletFrom &&\n        complianceService.getComplianceTransferableTokens(_from, block.timestamp, lockPeriod) < _value;\n    }\n\n    function maxInvestorsInCategoryForNonAccredited(\n        address[] memory _services,\n        address _from,\n        address _to,\n        uint256 _value,\n        uint256 fromInvestorBalance,\n        uint256 toInvestorBalance\n    ) internal view returns (bool) {\n        uint256 nonAccreditedInvestorLimit = IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getNonAccreditedInvestorsLimit();\n        return\n        nonAccreditedInvestorLimit != 0 &&\n        ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]).getTotalInvestorsCount() -\n            ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]).getAccreditedInvestorsCount()\n        >=\n        nonAccreditedInvestorLimit &&\n        isNewInvestor(_services, _to, toInvestorBalance) &&\n        (isAccredited(_services, _from) || fromInvestorBalance > _value);\n    }\n\n    function newPreTransferCheck(\n        address[] memory _services,\n        address _from,\n        address _to,\n        uint256 _value,\n        uint256 _balanceFrom,\n        bool _paused\n    ) public view returns (uint256 code, string memory reason) {\n        return doPreTransferCheckRegulated\n        (_services, _from, _to, _value, _balanceFrom, _paused);\n    }\n\n    function preTransferCheck(\n        address[] memory _services,\n        address _from,\n        address _to,\n        uint256 _value\n    ) public view returns (uint256 code, string memory reason) {\n        return doPreTransferCheckRegulated(_services, _from, _to, _value, IDSToken(_services[DS_TOKEN]).balanceOf(_from), IDSToken(_services[DS_TOKEN]).isPaused());\n    }\n\n    function doPreTransferCheckRegulated(\n        address[] memory _services,\n        address _from,\n        address _to,\n        uint256 _value,\n        uint256 _balanceFrom,\n        bool _paused\n    ) internal view returns (uint256 code, string memory reason) {\n\n        if (_balanceFrom < _value) {\n            return (15, NOT_ENOUGH_TOKENS);\n        }\n\n        uint256 fromInvestorBalance = balanceOfInvestor(_services, _from);\n        uint256 fromRegion = getCountryCompliance(_services, _from);\n        bool isPlatformWalletTo = IDSWalletManager(_services[WALLET_MANAGER]).isPlatformWallet(_to);\n        if (isPlatformWalletTo) {\n            if (\n                ((IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getForceFullTransfer()\n                && (fromRegion == US)) ||\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getWorldWideForceFullTransfer()) &&\n                fromInvestorBalance > _value\n            ) {\n                return (50, ONLY_FULL_TRANSFER);\n            }\n            return (0, VALID);\n        }\n\n        if (_paused && !(isOmnibusTBE(IDSOmnibusTBEController(_services[OMNIBUS_TBE_CONTROLLER]), _from))) {\n            return (10, TOKEN_PAUSED);\n        }\n\n        CompletePreTransferCheckArgs memory args = CompletePreTransferCheckArgs(_from, _to, _value, fromInvestorBalance, fromRegion, isPlatformWalletTo);\n        return completeTransferCheck(_services, args);\n    }\n\n    function completeTransferCheck(\n        address[] memory _services,\n        CompletePreTransferCheckArgs memory _args\n    ) internal view returns (uint256 code, string memory reason) {\n        (string memory investorFrom, string memory investorTo) = IDSRegistryService(_services[REGISTRY_SERVICE]).getInvestors(_args.from, _args.to);\n        if (\n            !CommonUtils.isEmptyString(investorFrom) && CommonUtils.isEqualString(investorFrom, investorTo)\n        ) {\n            return (0, VALID);\n        }\n\n        if (!ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]).checkWhitelisted(_args.to)) {\n            return (20, WALLET_NOT_IN_REGISTRY_SERVICE);\n        }\n\n        uint256 toRegion = getCountryCompliance(_services, _args.to);\n        if (toRegion == FORBIDDEN) {\n            return (26, DESTINATION_RESTRICTED);\n        }\n\n        if (isOmnibusTBE(IDSOmnibusTBEController(_services[OMNIBUS_TBE_CONTROLLER]), _args.from)) {\n            return(0, VALID);\n        }\n\n        bool isPlatformWalletFrom = IDSWalletManager(_services[WALLET_MANAGER]).isPlatformWallet(_args.from);\n        if (\n            !isPlatformWalletFrom &&\n        IDSLockManager(_services[LOCK_MANAGER]).getTransferableTokens(_args.from, block.timestamp) < _args.value\n        ) {\n            return (16, TOKENS_LOCKED);\n        }\n\n        if (_args.fromRegion == US) {\n            if (checkHoldUp(_services, _args.from, _args.value, true, isPlatformWalletFrom)) {\n                return (32, HOLD_UP);\n            }\n\n            if (\n                _args.fromInvestorBalance > _args.value &&\n                _args.fromInvestorBalance - _args.value < IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getMinUSTokens()\n            ) {\n                return (51, AMOUNT_OF_TOKENS_UNDER_MIN);\n            }\n\n            if (\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getForceFullTransfer() &&\n                _args.fromInvestorBalance > _args.value\n            ) {\n                return (50, ONLY_FULL_TRANSFER);\n            }\n        } else {\n            if (checkHoldUp(_services, _args.from, _args.value, false, isPlatformWalletFrom)) {\n                return (33, HOLD_UP);\n            }\n\n            if (\n                toRegion == US &&\n                !isPlatformWalletFrom &&\n                isBlockFlowbackEndTimeOk(IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getBlockFlowbackEndTime())\n            ) {\n                return (25, FLOWBACK);\n            }\n\n            if (\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getWorldWideForceFullTransfer() &&\n                _args.fromInvestorBalance > _args.value\n            ) {\n                return (50, ONLY_FULL_TRANSFER);\n            }\n        }\n\n        uint256 toInvestorBalance = balanceOfInvestor(_services, _args.to);\n        string memory toCountry = getCountry(_services, _args.to);\n\n        if (_args.fromRegion == EU) {\n            if (_args.fromInvestorBalance - _args.value < IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getMinEUTokens() &&\n                _args.fromInvestorBalance > _args.value) {\n                return (51, AMOUNT_OF_TOKENS_UNDER_MIN);\n            }\n        }\n\n        bool isAccreditedTo = isAccredited(_services, _args.to);\n        if (\n            IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getForceAccredited() && !isAccreditedTo\n        ) {\n            return (61, ONLY_ACCREDITED);\n        }\n\n        if (toRegion == JP) {\n            if (\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getJPInvestorsLimit() != 0 &&\n                ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]).getJPInvestorsCount() >=\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getJPInvestorsLimit() &&\n                isNewInvestor(_services, _args.to, toInvestorBalance) &&\n                (!CommonUtils.isEqualString(getCountry(_services, _args.from), toCountry) || (_args.fromInvestorBalance > _args.value))\n            ) {\n                return (40, MAX_INVESTORS_IN_CATEGORY);\n            }\n        } else if (toRegion == EU) {\n            if (\n                isRetail(_services, _args.to) &&\n                ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]).getEURetailInvestorsCount(toCountry) >=\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getEURetailInvestorsLimit() &&\n                isNewInvestor(_services, _args.to, toInvestorBalance) &&\n                (!CommonUtils.isEqualString(getCountry(_services, _args.from), toCountry) ||\n                (_args.fromInvestorBalance > _args.value && isRetail(_services, _args.from)))\n            ) {\n                return (40, MAX_INVESTORS_IN_CATEGORY);\n            }\n\n            if (\n                toInvestorBalance + _args.value < IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getMinEUTokens()\n            ) {\n                return (51, AMOUNT_OF_TOKENS_UNDER_MIN);\n            }\n        } else if (toRegion == US) {\n            if (\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getForceAccreditedUS() &&\n                !isAccreditedTo\n            ) {\n                return (62, ONLY_US_ACCREDITED);\n            }\n\n            uint256 usInvestorsLimit = getUSInvestorsLimit(_services);\n            if (\n                usInvestorsLimit != 0 &&\n                _args.fromInvestorBalance > _args.value &&\n                ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]).getUSInvestorsCount() >= usInvestorsLimit &&\n                isNewInvestor(_services, _args.to, toInvestorBalance)\n            ) {\n                return (40, MAX_INVESTORS_IN_CATEGORY);\n            }\n\n            if (\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getUSAccreditedInvestorsLimit() != 0 &&\n                isAccreditedTo &&\n                ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]).getUSAccreditedInvestorsCount() >=\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getUSAccreditedInvestorsLimit() &&\n                isNewInvestor(_services, _args.to, toInvestorBalance) &&\n                (_args.fromRegion != US || !isAccredited(_services, _args.from) || _args.fromInvestorBalance > _args.value)\n            ) {\n                return (40, MAX_INVESTORS_IN_CATEGORY);\n            }\n\n            if (\n                toInvestorBalance + _args.value < IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getMinUSTokens()\n            ) {\n                return (51, AMOUNT_OF_TOKENS_UNDER_MIN);\n            }\n        }\n\n        if (!isAccreditedTo) {\n            if (maxInvestorsInCategoryForNonAccredited(_services, _args.from, _args.to, _args.value, _args.fromInvestorBalance, toInvestorBalance)) {\n                return (40, MAX_INVESTORS_IN_CATEGORY);\n            }\n        }\n\n        if (\n            IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getTotalInvestorsLimit() != 0 &&\n            _args.fromInvestorBalance > _args.value &&\n            ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]).getTotalInvestorsCount() >=\n            IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getTotalInvestorsLimit() &&\n            isNewInvestor(_services, _args.to, toInvestorBalance)\n        ) {\n            return (40, MAX_INVESTORS_IN_CATEGORY);\n        }\n\n        if (\n            _args.fromInvestorBalance == _args.value &&\n            !isNewInvestor(_services, _args.to, toInvestorBalance) &&\n            ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]).getTotalInvestorsCount() <=\n            IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getMinimumTotalInvestors()\n        ) {\n            return (71, NOT_ENOUGH_INVESTORS);\n        }\n\n        if (\n            !isPlatformWalletFrom &&\n        _args.fromInvestorBalance - _args.value < IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getMinimumHoldingsPerInvestor() &&\n        _args.fromInvestorBalance > _args.value\n        ) {\n            return (51, AMOUNT_OF_TOKENS_UNDER_MIN);\n        }\n\n        if (\n            !_args.isPlatformWalletTo &&\n        toInvestorBalance + _args.value < IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getMinimumHoldingsPerInvestor()\n        ) {\n            return (51, AMOUNT_OF_TOKENS_UNDER_MIN);\n        }\n\n        if (\n            isMaximumHoldingsPerInvestorOk(\n                IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getMaximumHoldingsPerInvestor(),\n                toInvestorBalance, _args.value)\n        ) {\n            return (52, AMOUNT_OF_TOKENS_ABOVE_MAX);\n        }\n\n        return (0, VALID);\n    }\n\n\n    function preIssuanceCheck(\n        address[] memory _services,\n        address _to,\n        uint256 _value\n    ) public view returns (uint256 code, string memory reason) {\n        ComplianceServiceRegulated complianceService = ComplianceServiceRegulated(_services[COMPLIANCE_SERVICE]);\n        IDSComplianceConfigurationService complianceConfigurationService = IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]);\n        IDSWalletManager walletManager = IDSWalletManager(_services[WALLET_MANAGER]);\n        string memory toCountry = IDSRegistryService(_services[REGISTRY_SERVICE]).getCountry(IDSRegistryService(_services[REGISTRY_SERVICE]).getInvestor(_to));\n        uint256 toRegion = complianceConfigurationService.getCountryCompliance(toCountry);\n\n        if (toRegion == FORBIDDEN) {\n            return (26, DESTINATION_RESTRICTED);\n        }\n\n        if (!complianceService.checkWhitelisted(_to)) {\n            return (20, WALLET_NOT_IN_REGISTRY_SERVICE);\n        }\n\n        uint256 balanceOfInvestorTo = balanceOfInvestor(_services, _to);\n        if (isNewInvestor(_services, _to, balanceOfInvestorTo)) {\n            // verify global non accredited limit\n            if (!isAccredited(_services, _to)) {\n                if (\n                    complianceConfigurationService.getNonAccreditedInvestorsLimit() != 0 &&\n                    complianceService.getTotalInvestorsCount() - complianceService.getAccreditedInvestorsCount() >=\n                    complianceConfigurationService.getNonAccreditedInvestorsLimit()\n                ) {\n                    return (40, MAX_INVESTORS_IN_CATEGORY);\n                }\n            }\n            // verify global investors limit\n            if (\n                complianceConfigurationService.getTotalInvestorsLimit() != 0 &&\n                complianceService.getTotalInvestorsCount() >= complianceConfigurationService.getTotalInvestorsLimit()\n            ) {\n                return (40, MAX_INVESTORS_IN_CATEGORY);\n            }\n\n            if (toRegion == US) {\n                // verify US investors limit is not exceeded\n                if (complianceConfigurationService.getUSInvestorsLimit() != 0 && complianceService.getUSInvestorsCount() >= complianceConfigurationService.getUSInvestorsLimit()) {\n                    return (40, MAX_INVESTORS_IN_CATEGORY);\n                }\n                // verify accredited US limit is not exceeded\n                if (\n                    complianceConfigurationService.getUSAccreditedInvestorsLimit() != 0 &&\n                    isAccredited(_services, _to) &&\n                    complianceService.getUSAccreditedInvestorsCount() >= complianceConfigurationService.getUSAccreditedInvestorsLimit()\n                ) {\n                    return (40, MAX_INVESTORS_IN_CATEGORY);\n                }\n            } else if (toRegion == EU) {\n                if (\n                    isRetail(_services, _to) &&\n                    complianceService.getEURetailInvestorsCount(getCountry(_services, _to)) >= complianceConfigurationService.getEURetailInvestorsLimit()\n                ) {\n                    return (40, MAX_INVESTORS_IN_CATEGORY);\n                }\n            } else if (toRegion == JP) {\n                if (complianceConfigurationService.getJPInvestorsLimit() != 0 && complianceService.getJPInvestorsCount() >= complianceConfigurationService.getJPInvestorsLimit()) {\n                    return (40, MAX_INVESTORS_IN_CATEGORY);\n                }\n            }\n        }\n\n        if (\n            !walletManager.isPlatformWallet(_to) &&\n        balanceOfInvestorTo + _value < complianceConfigurationService.getMinimumHoldingsPerInvestor()\n        ) {\n            return (51, AMOUNT_OF_TOKENS_UNDER_MIN);\n        }\n        if (isMaximumHoldingsPerInvestorOk(\n                complianceConfigurationService.getMaximumHoldingsPerInvestor(),\n                balanceOfInvestorTo,\n                _value)\n        ) {\n            return (52, AMOUNT_OF_TOKENS_ABOVE_MAX);\n        }\n\n        return (0, VALID);\n    }\n\n    function isMaximumHoldingsPerInvestorOk(uint256 _maximumHoldingsPerInvestor, uint256 _balanceOfInvestorTo, uint256 _value) internal pure returns (bool) {\n        return _maximumHoldingsPerInvestor != 0 && _balanceOfInvestorTo + _value > _maximumHoldingsPerInvestor;\n    }\n\n    function isBlockFlowbackEndTimeOk(uint256 _blockFlowBackEndTime) private view returns (bool){\n        return  (_blockFlowBackEndTime == 0 || _blockFlowBackEndTime > block.timestamp);\n    }\n}\n\n/**\n *   @title Concrete compliance service for tokens with regulation\n *\n */\n//SPDX-License-Identifier: UNLICENSED\ncontract ComplianceServiceRegulated is ComplianceServiceWhitelisted {\n    function initialize() public virtual override initializer forceInitializeFromProxy {\n        super.initialize();\n        VERSIONS.push(13);\n    }\n\n    function compareInvestorBalance(\n        address _who,\n        uint256 _value,\n        uint256 _compareTo\n    ) internal view returns (bool) {\n        return (_value != 0 && getToken().balanceOfInvestor(getRegistryService().getInvestor(_who)) == _compareTo);\n    }\n\n    function recordTransfer(\n        address _from,\n        address _to,\n        uint256 _value\n    ) internal override returns (bool) {\n        if (!(ComplianceServiceLibrary.isOmnibusTBE(getOmnibusTBEController(), _from) ||\n        ComplianceServiceLibrary.isOmnibusTBE(getOmnibusTBEController(), _to))) {\n            if (compareInvestorBalance(_to, _value, 0)) {\n                adjustTransferCounts(_to, CommonUtils.IncDec.Increase);\n            }\n        }\n\n        return true;\n    }\n\n    function adjustTransferCounts(\n        address _from,\n        CommonUtils.IncDec _increase\n    ) internal {\n        adjustTotalInvestorsCounts(_from, _increase);\n    }\n\n    function recordIssuance(\n        address _to,\n        uint256 _value,\n        uint256 _issuanceTime\n    ) internal override returns (bool) {\n        if (compareInvestorBalance(_to, _value, 0)) {\n            adjustTotalInvestorsCounts(_to, CommonUtils.IncDec.Increase);\n        }\n\n        return createIssuanceInformation(getRegistryService().getInvestor(_to), _value, _issuanceTime);\n    }\n\n    function recordBurn(address /*_who*/, uint256 /*_value*/) internal pure override returns (bool) {\n        return true;\n    }\n\n    function recordSeize(\n        address _from,\n        address, /*_to*/\n        uint256 _value\n    ) internal pure override returns (bool) {\n        return recordBurn(_from, _value);\n    }\n\n    function adjustInvestorCountsAfterCountryChange(\n        string memory _id,\n        string memory _country,\n        string memory /*_prevCountry*/\n    ) public override onlyRegistry returns (bool) {\n        if (getToken().balanceOfInvestor(_id) == 0) {\n            return false;\n        }\n\n        adjustInvestorsCountsByCountry(_country, _id, CommonUtils.IncDec.Increase);\n\n        return true;\n    }\n\n    function adjustTotalInvestorsCounts(address _wallet, CommonUtils.IncDec _increase) internal {\n        if (!getWalletManager().isSpecialWallet(_wallet)) {\n            if (_increase == CommonUtils.IncDec.Increase) {\n                totalInvestors++;\n            }\n\n            string memory id = getRegistryService().getInvestor(_wallet);\n            string memory country = getRegistryService().getCountry(id);\n\n            adjustInvestorsCountsByCountry(country, id, _increase);\n        }\n    }\n\n    function adjustInvestorsCountsByCountry(\n        string memory _country,\n        string memory _id,\n        CommonUtils.IncDec _increase\n    ) internal {\n        uint256 countryCompliance = getComplianceConfigurationService().getCountryCompliance(_country);\n\n        if (getRegistryService().isAccreditedInvestor(_id)) {\n            if(_increase == CommonUtils.IncDec.Increase) {\n                accreditedInvestorsCount++;\n            }\n            if (countryCompliance == US) {\n                if(_increase == CommonUtils.IncDec.Increase) {\n                    usAccreditedInvestorsCount++;\n                }\n            }\n        }\n\n        if (countryCompliance == US) {\n            if(_increase == CommonUtils.IncDec.Increase) {\n                usInvestorsCount++;\n            }\n        } else if (countryCompliance == EU && !getRegistryService().isQualifiedInvestor(_id)) {\n            if(_increase == CommonUtils.IncDec.Increase) {\n                euRetailInvestorsCount[_country]++;\n            }\n        } else if (countryCompliance == JP) {\n            if(_increase == CommonUtils.IncDec.Increase) {\n                jpInvestorsCount++;\n            }\n        }\n    }\n\n    function createIssuanceInformation(\n        string memory _investor,\n        uint256 _value,\n        uint256 _issuanceTime\n    ) internal returns (bool) {\n        uint256 issuancesCount = issuancesCounters[_investor];\n\n        issuancesValues[_investor][issuancesCount] = _value;\n        issuancesTimestamps[_investor][issuancesCount] = _issuanceTime;\n        issuancesCounters[_investor] = issuancesCount + 1;\n\n        return true;\n    }\n\n    function preTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value\n    ) public view virtual override returns (uint256 code, string memory reason) {\n        return ComplianceServiceLibrary.preTransferCheck(getServices(), _from, _to, _value);\n    }\n\n    function newPreTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value,\n        uint256 _balanceFrom,\n        bool _pausedToken\n    ) public view virtual override returns (uint256 code, string memory reason) {\n        return ComplianceServiceLibrary.newPreTransferCheck(getServices(), _from, _to, _value, _balanceFrom, _pausedToken);\n    }\n\n    function preInternalTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value)\n    public view override returns (uint256 code, string memory reason) {\n        return ComplianceServiceLibrary.preTransferCheck(getServices(), _from, _to, _value);\n    }\n\n    function getComplianceTransferableTokens(\n        address _who,\n        uint256 _time,\n        uint64 _lockTime\n    ) public view returns (uint256) {\n        require(_time != 0, \"Time must be greater than zero\");\n        string memory investor = getRegistryService().getInvestor(_who);\n\n        uint256 balanceOfInvestor = getLockManager().getTransferableTokens(_who, _time);\n\n        uint256 investorIssuancesCount = issuancesCounters[investor];\n\n        //No locks, go to base class implementation\n        if (investorIssuancesCount == 0) {\n            return balanceOfInvestor;\n        }\n\n        uint256 totalLockedTokens = 0;\n        for (uint256 i = 0; i < investorIssuancesCount; i++) {\n            uint256 issuanceTimestamp = issuancesTimestamps[investor][i];\n\n            if (_lockTime > _time || issuanceTimestamp > SafeMath.sub(_time, _lockTime)) {\n                totalLockedTokens = totalLockedTokens + issuancesValues[investor][i];\n            }\n        }\n\n        //there may be more locked tokens than actual tokens, so the minimum between the two\n        uint256 transferable = SafeMath.sub(balanceOfInvestor, Math.min(totalLockedTokens, balanceOfInvestor));\n\n        return transferable;\n    }\n\n    function preIssuanceCheck(address _to, uint256 _value) public view override returns (uint256 code, string memory reason) {\n        return ComplianceServiceLibrary.preIssuanceCheck(getServices(), _to, _value);\n    }\n\n    function getTotalInvestorsCount() public view returns (uint256) {\n        return totalInvestors;\n    }\n\n    function getUSInvestorsCount() public view returns (uint256) {\n        return usInvestorsCount;\n    }\n\n    function getUSAccreditedInvestorsCount() public view returns (uint256) {\n        return usAccreditedInvestorsCount;\n    }\n\n    function getAccreditedInvestorsCount() public view returns (uint256) {\n        return accreditedInvestorsCount;\n    }\n\n    function getEURetailInvestorsCount(string memory _country) public view returns (uint256) {\n        return euRetailInvestorsCount[_country];\n    }\n\n    function getJPInvestorsCount() public view returns (uint256) {\n        return jpInvestorsCount;\n    }\n\n    function setTotalInvestorsCount(uint256 _value) public onlyMasterOrTBEOmnibus returns (bool) {\n        totalInvestors = _value;\n\n        return true;\n    }\n\n    function setUSInvestorsCount(uint256 _value) public onlyMasterOrTBEOmnibus returns (bool) {\n        usInvestorsCount = _value;\n\n        return true;\n    }\n\n    function setUSAccreditedInvestorsCount(uint256 _value) public onlyMasterOrTBEOmnibus returns (bool) {\n        usAccreditedInvestorsCount = _value;\n\n        return true;\n    }\n\n    function setAccreditedInvestorsCount(uint256 _value) public onlyMasterOrTBEOmnibus returns (bool) {\n        accreditedInvestorsCount = _value;\n\n        return true;\n    }\n\n    function setEURetailInvestorsCount(string memory _country, uint256 _value) public onlyMasterOrTBEOmnibus returns (bool) {\n        euRetailInvestorsCount[_country] = _value;\n\n        return true;\n    }\n\n    function setJPInvestorsCount(uint256 _value) public onlyMasterOrTBEOmnibus returns (bool) {\n        jpInvestorsCount = _value;\n\n        return true;\n    }\n\n    function getServices() internal view returns (address[] memory services) {\n        services = new address[](7);\n        services[0] = getDSService(DS_TOKEN);\n        services[1] = getDSService(REGISTRY_SERVICE);\n        services[2] = getDSService(WALLET_MANAGER);\n        services[3] = getDSService(COMPLIANCE_CONFIGURATION_SERVICE);\n        services[4] = getDSService(LOCK_MANAGER);\n        services[5] = address(this);\n        services[6] = getDSService(OMNIBUS_TBE_CONTROLLER);\n    }\n}\n"},"contracts/data-stores/ComplianceServiceDataStore.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./ServiceConsumerDataStore.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\ncontract ComplianceServiceDataStore is ServiceConsumerDataStore {\n    uint256 internal totalInvestors;\n    uint256 internal accreditedInvestorsCount;\n    uint256 internal usAccreditedInvestorsCount;\n    uint256 internal usInvestorsCount;\n    uint256 internal jpInvestorsCount;\n    mapping(string => uint256) internal euRetailInvestorsCount;\n    mapping(string => uint256) internal issuancesCounters;\n    mapping(string => mapping(uint256 => uint256)) issuancesValues;\n    mapping(string => mapping(uint256 => uint256)) issuancesTimestamps;\n}\n"},"contracts/compliance/ComplianceServiceWhitelisted.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./ComplianceService.sol\";\nimport \"../registry/IDSRegistryService.sol\";\n\n/**\n*   @title Concrete compliance service for tokens with whitelisted wallets.\n*\n*   This simple compliance service is meant to be used for tokens that only need to be validated against an investor registry.\n*/\n//SPDX-License-Identifier: UNLICENSED\ncontract ComplianceServiceWhitelisted is ComplianceService {\n    function initialize() public virtual override initializer forceInitializeFromProxy {\n        ComplianceService.initialize();\n        VERSIONS.push(5);\n    }\n    function newPreTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value,\n        uint256 _balanceFrom,\n        bool _pausedToken\n    ) public view virtual override returns (uint256 code, string memory reason) {\n        return doPreTransferCheckWhitelisted(_from, _to, _value, _balanceFrom, _pausedToken);\n    }\n\n    function preTransferCheck(\n        address _from,\n        address _to,\n        uint256 _value\n    ) public view virtual override returns (uint256 code, string memory reason) {\n        return doPreTransferCheckWhitelisted(_from, _to, _value, getToken().balanceOf(_from), getToken().isPaused());\n    }\n\n    function checkWhitelisted(address _who) public view returns (bool) {\n        return getWalletManager().isPlatformWallet(_who) || !CommonUtils.isEmptyString(getRegistryService().getInvestor(_who));\n    }\n\n    function recordIssuance(address, uint256, uint256) internal virtual override returns (bool) {\n        return true;\n    }\n\n    function recordTransfer(address, address, uint256) internal virtual override returns (bool) {\n        return true;\n    }\n\n    function checkTransfer(address, address _to, uint256) internal view override returns (uint256, string memory) {\n        if (!checkWhitelisted(_to)) {\n            return (20, WALLET_NOT_IN_REGISTRY_SERVICE);\n        }\n\n        return (0, VALID);\n    }\n\n    function preIssuanceCheck(address _to, uint256) public view virtual override returns (uint256, string memory) {\n        if (!checkWhitelisted(_to)) {\n            return (20, WALLET_NOT_IN_REGISTRY_SERVICE);\n        }\n\n        return (0, VALID);\n    }\n\n    function recordBurn(address, uint256) internal virtual override returns (bool) {\n        return true;\n    }\n\n    function recordSeize(address, address, uint256) internal virtual override returns (bool) {\n        return true;\n    }\n\n    function doPreTransferCheckWhitelisted(\n        address _from,\n        address _to,\n        uint256 _value,\n        uint256 _balanceFrom,\n        bool _pausedToken\n    ) internal view returns (uint256 code, string memory reason) {\n        if (_pausedToken) {\n            return (10, TOKEN_PAUSED);\n        }\n\n        if (_balanceFrom < _value) {\n            return (15, NOT_ENOUGH_TOKENS);\n        }\n\n        if (!getWalletManager().isPlatformWallet(_from) && getLockManager().getTransferableTokens(_from, block.timestamp) < _value) {\n            return (16, TOKENS_LOCKED);\n        }\n\n        return checkTransfer(_from, _to, _value);\n    }\n}\n"},"contracts/compliance/ComplianceConfigurationService.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./IDSComplianceConfigurationService.sol\";\nimport \"../data-stores/ComplianceConfigurationDataStore.sol\";\nimport \"../service/ServiceConsumer.sol\";\nimport \"../utils/ProxyTarget.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\ncontract ComplianceConfigurationService is ProxyTarget, IDSComplianceConfigurationService, ServiceConsumer, ComplianceConfigurationDataStore {\n    function initialize() public override(IDSComplianceConfigurationService, ServiceConsumer) initializer forceInitializeFromProxy {\n        IDSComplianceConfigurationService.initialize();\n        ServiceConsumer.initialize();\n        VERSIONS.push(8);\n    }\n\n    function setCountriesCompliance(string[] memory _countries, uint256[] memory _values) public override onlyTransferAgentOrAbove {\n        require(_countries.length <= 35, \"Exceeded the maximum number of countries\");\n        require(_countries.length == _values.length, \"Wrong length of parameters\");\n        for (uint i = 0; i < _countries.length; i++) {\n            setCountryCompliance(_countries[i], _values[i]);\n        }\n    }\n\n    function setCountryCompliance(string memory _country, uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceStringToUIntMapRuleSet(\"countryCompliance\", _country, countriesCompliances[_country], _value);\n        countriesCompliances[_country] = _value;\n    }\n\n    function getCountryCompliance(string memory _country) public view override returns (uint256) {\n        return countriesCompliances[_country];\n    }\n\n    function getTotalInvestorsLimit() public view override returns (uint256) {\n        return totalInvestorsLimit;\n    }\n\n    function setTotalInvestorsLimit(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"totalInvestorsLimit\", totalInvestorsLimit, _value);\n        totalInvestorsLimit = _value;\n    }\n\n    function getMinUSTokens() public view override returns (uint256) {\n        return minUSTokens;\n    }\n\n    function setMinUSTokens(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"minUSTokens\", minUSTokens, _value);\n        minUSTokens = _value;\n    }\n\n    function getMinEUTokens() public view override returns (uint256) {\n        return minEUTokens;\n    }\n\n    function setMinEUTokens(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"minEUTokens\", minEUTokens, _value);\n        minEUTokens = _value;\n    }\n\n    function getUSInvestorsLimit() public view override returns (uint256) {\n        return usInvestorsLimit;\n    }\n\n    function setUSInvestorsLimit(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"usInvestorsLimit\", usInvestorsLimit, _value);\n        usInvestorsLimit = _value;\n    }\n\n    function getJPInvestorsLimit() public view override returns (uint256) {\n        return jpInvestorsLimit;\n    }\n\n    function setJPInvestorsLimit(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"jpInvestorsLimit\", jpInvestorsLimit, _value);\n        jpInvestorsLimit = _value;\n    }\n\n    function getUSAccreditedInvestorsLimit() public view override returns (uint256) {\n        return usAccreditedInvestorsLimit;\n    }\n\n    function setUSAccreditedInvestorsLimit(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"usAccreditedInvestorsLimit\", usAccreditedInvestorsLimit, _value);\n        usAccreditedInvestorsLimit = _value;\n    }\n\n    function getNonAccreditedInvestorsLimit() public view override returns (uint256) {\n        return nonAccreditedInvestorsLimit;\n    }\n\n    function setNonAccreditedInvestorsLimit(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"nonAccreditedInvestorsLimit\", nonAccreditedInvestorsLimit, _value);\n        nonAccreditedInvestorsLimit = _value;\n    }\n\n    function getMaxUSInvestorsPercentage() public view override returns (uint256) {\n        return maxUSInvestorsPercentage;\n    }\n\n    function setMaxUSInvestorsPercentage(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"maxUSInvestorsPercentage\", maxUSInvestorsPercentage, _value);\n        maxUSInvestorsPercentage = _value;\n    }\n\n    function getBlockFlowbackEndTime() public view override returns (uint256) {\n        return blockFlowbackEndTime;\n    }\n\n    function setBlockFlowbackEndTime(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"blockFlowbackEndTime\", blockFlowbackEndTime, _value);\n        blockFlowbackEndTime = _value;\n    }\n\n    function getNonUSLockPeriod() public view override returns (uint256) {\n        return nonUSLockPeriod;\n    }\n\n    function setNonUSLockPeriod(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"nonUSLockPeriod\", nonUSLockPeriod, _value);\n        nonUSLockPeriod = _value;\n    }\n\n    function getMinimumTotalInvestors() public view override returns (uint256) {\n        return minimumTotalInvestors;\n    }\n\n    function setMinimumTotalInvestors(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"minimumTotalInvestors\", minimumTotalInvestors, _value);\n        minimumTotalInvestors = _value;\n    }\n\n    function getMinimumHoldingsPerInvestor() public view override returns (uint256) {\n        return minimumHoldingsPerInvestor;\n    }\n\n    function setMinimumHoldingsPerInvestor(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"minimumHoldingsPerInvestor\", minimumHoldingsPerInvestor, _value);\n        minimumHoldingsPerInvestor = _value;\n    }\n\n    function getMaximumHoldingsPerInvestor() public view override returns (uint256) {\n        return maximumHoldingsPerInvestor;\n    }\n\n    function setMaximumHoldingsPerInvestor(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"maximumHoldingsPerInvestor\", maximumHoldingsPerInvestor, _value);\n        maximumHoldingsPerInvestor = _value;\n    }\n\n    function getEURetailInvestorsLimit() public view override returns (uint256) {\n        return euRetailInvestorsLimit;\n    }\n\n    function setEURetailInvestorsLimit(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"euRetailInvestorsLimit\", euRetailInvestorsLimit, _value);\n        euRetailInvestorsLimit = _value;\n    }\n\n    function getUSLockPeriod() public view override returns (uint256) {\n        return usLockPeriod;\n    }\n\n    function setUSLockPeriod(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"usLockPeriod\", usLockPeriod, _value);\n        usLockPeriod = _value;\n    }\n\n    function getForceFullTransfer() public view override returns (bool) {\n        return forceFullTransfer;\n    }\n\n    function setForceFullTransfer(bool _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceBoolRuleSet(\"forceFullTransfer\", forceFullTransfer, _value);\n        forceFullTransfer = _value;\n    }\n\n    function getForceAccreditedUS() public view override returns (bool) {\n        return forceAccreditedUS;\n    }\n\n    function setForceAccreditedUS(bool _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceBoolRuleSet(\"forceAccreditedUS\", forceAccreditedUS, _value);\n        forceAccreditedUS = _value;\n    }\n\n    function getForceAccredited() public view override returns (bool) {\n        return forceAccredited;\n    }\n\n    function setForceAccredited(bool _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceBoolRuleSet(\"forceAccredited\", forceAccredited, _value);\n        forceAccredited = _value;\n    }\n\n    function getWorldWideForceFullTransfer() public view override returns (bool) {\n        return worldWideForceFullTransfer;\n    }\n\n    function setWorldWideForceFullTransfer(bool _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceBoolRuleSet(\"worldWideForceFullTransfer\", worldWideForceFullTransfer, _value);\n        worldWideForceFullTransfer = _value;\n    }\n\n    function getAuthorizedSecurities() public view override returns (uint256) {\n        return authorizedSecurities;\n    }\n\n    function setAuthorizedSecurities(uint256 _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceUIntRuleSet(\"authorizedSecurities\", authorizedSecurities, _value);\n        authorizedSecurities = _value;\n    }\n\n    function getDisallowBackDating() public view override returns (bool) {\n        return disallowBackDating;\n    }\n\n    function setDisallowBackDating(bool _value) public override onlyTransferAgentOrAbove {\n        emit DSComplianceBoolRuleSet(\"disallowBackDating\", disallowBackDating, _value);\n        disallowBackDating = _value;\n    }\n\n    function setAll(uint256[] memory _uint_values, bool[] memory _bool_values) public override onlyTransferAgentOrAbove {\n        require(_uint_values.length == 16, \"Wrong length of parameters\");\n        require(_bool_values.length == 5, \"Wrong length of parameters\");\n        setTotalInvestorsLimit(_uint_values[0]);\n        setMinUSTokens(_uint_values[1]);\n        setMinEUTokens(_uint_values[2]);\n        setUSInvestorsLimit(_uint_values[3]);\n        setUSAccreditedInvestorsLimit(_uint_values[4]);\n        setNonAccreditedInvestorsLimit(_uint_values[5]);\n        setMaxUSInvestorsPercentage(_uint_values[6]);\n        setBlockFlowbackEndTime(_uint_values[7]);\n        setNonUSLockPeriod(_uint_values[8]);\n        setMinimumTotalInvestors(_uint_values[9]);\n        setMinimumHoldingsPerInvestor(_uint_values[10]);\n        setMaximumHoldingsPerInvestor(_uint_values[11]);\n        setEURetailInvestorsLimit(_uint_values[12]);\n        setUSLockPeriod(_uint_values[13]);\n        setJPInvestorsLimit(_uint_values[14]);\n        setAuthorizedSecurities(_uint_values[15]);\n        setForceFullTransfer(_bool_values[0]);\n        setForceAccredited(_bool_values[1]);\n        setForceAccreditedUS(_bool_values[2]);\n        setWorldWideForceFullTransfer(_bool_values[3]);\n        setDisallowBackDating(_bool_values[4]);\n    }\n\n    function getAll() public view override returns (uint256[] memory, bool[] memory) {\n        uint256[] memory uintValues = new uint256[](16);\n        bool[] memory boolValues = new bool[](5);\n\n        uintValues[0] = getTotalInvestorsLimit();\n        uintValues[1] = getMinUSTokens();\n        uintValues[2] = getMinEUTokens();\n        uintValues[3] = getUSInvestorsLimit();\n        uintValues[4] = getUSAccreditedInvestorsLimit();\n        uintValues[5] = getNonAccreditedInvestorsLimit();\n        uintValues[6] = getMaxUSInvestorsPercentage();\n        uintValues[7] = getBlockFlowbackEndTime();\n        uintValues[8] = getNonUSLockPeriod();\n        uintValues[9] = getMinimumTotalInvestors();\n        uintValues[10] = getMinimumHoldingsPerInvestor();\n        uintValues[11] = getMaximumHoldingsPerInvestor();\n        uintValues[12] = getEURetailInvestorsLimit();\n        uintValues[13] = getUSLockPeriod();\n        uintValues[14] = getJPInvestorsLimit();\n        uintValues[15] = getAuthorizedSecurities();\n        boolValues[0] = getForceFullTransfer();\n        boolValues[1] = getForceAccredited();\n        boolValues[2] = getForceAccreditedUS();\n        boolValues[3] = getWorldWideForceFullTransfer();\n        boolValues[4] = getDisallowBackDating();\n        return (uintValues, boolValues);\n    }\n}\n"},"contracts/data-stores/OmnibusTBEControllerDataStore.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./ServiceConsumerDataStore.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\ncontract OmnibusTBEControllerDataStore is ServiceConsumerDataStore {\n    address internal omnibusWallet;\n    bool internal isPartitionedToken;\n}\n"},"contracts/compliance/IDSComplianceServicePartitioned.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./IDSComplianceService.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSComplianceServicePartitioned is IDSComplianceService {\n\n    function initialize() public virtual override {\n        VERSIONS.push(2);\n    }\n\n    function getComplianceTransferableTokens(\n        address _who,\n        uint256 _time,\n        bool _checkFlowback\n    ) public view virtual returns (uint256 transferable);\n\n    function getComplianceTransferableTokens(\n        address _who,\n        uint256 _time,\n        bool _checkFlowback,\n        bytes32 _partition\n    ) public view virtual returns (uint256);\n\n    function getComplianceTransferableTokens(\n        address _who,\n        uint256 _time,\n        address _to\n    ) public view virtual returns (uint256 transferable);\n\n    function getComplianceTransferableTokens(\n        address _who,\n        uint256 _time,\n        address _to,\n        bytes32 _partition\n    ) public view virtual returns (uint256);\n}\n"},"contracts/compliance/IDSComplianceConfigurationService.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"../utils/VersionedContract.sol\";\nimport \"../utils/Initializable.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\nabstract contract IDSComplianceConfigurationService is Initializable, VersionedContract {\n\n    function initialize() public virtual {\n        VERSIONS.push(7);\n    }\n\n    event DSComplianceUIntRuleSet(string ruleName, uint256 prevValue, uint256 newValue);\n    event DSComplianceBoolRuleSet(string ruleName, bool prevValue, bool newValue);\n    event DSComplianceStringToUIntMapRuleSet(string ruleName, string keyValue, uint256 prevValue, uint256 newValue);\n\n    function getCountryCompliance(string memory _country) public view virtual returns (uint256);\n\n    function setCountriesCompliance(string[] memory _countries, uint256[] memory _values) public virtual;\n\n    function setCountryCompliance(\n        string memory _country,\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getTotalInvestorsLimit() public view virtual returns (uint256);\n\n    function setTotalInvestorsLimit(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getMinUSTokens() public view virtual returns (uint256);\n\n    function setMinUSTokens(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getMinEUTokens() public view virtual returns (uint256);\n\n    function setMinEUTokens(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getUSInvestorsLimit() public view virtual returns (uint256);\n\n    function setUSInvestorsLimit(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getJPInvestorsLimit() public view virtual returns (uint256);\n\n    function setJPInvestorsLimit(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getUSAccreditedInvestorsLimit() public view virtual returns (uint256);\n\n    function setUSAccreditedInvestorsLimit(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getNonAccreditedInvestorsLimit() public view virtual returns (uint256);\n\n    function setNonAccreditedInvestorsLimit(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getMaxUSInvestorsPercentage() public view virtual returns (uint256);\n\n    function setMaxUSInvestorsPercentage(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getBlockFlowbackEndTime() public view virtual returns (uint256);\n\n    function setBlockFlowbackEndTime(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getNonUSLockPeriod() public view virtual returns (uint256);\n\n    function setNonUSLockPeriod(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getMinimumTotalInvestors() public view virtual returns (uint256);\n\n    function setMinimumTotalInvestors(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getMinimumHoldingsPerInvestor() public view virtual returns (uint256);\n\n    function setMinimumHoldingsPerInvestor(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getMaximumHoldingsPerInvestor() public view virtual returns (uint256);\n\n    function setMaximumHoldingsPerInvestor(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getEURetailInvestorsLimit() public view virtual returns (uint256);\n\n    function setEURetailInvestorsLimit(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getUSLockPeriod() public view virtual returns (uint256);\n\n    function setUSLockPeriod(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getForceFullTransfer() public view virtual returns (bool);\n\n    function setForceFullTransfer(\n        bool _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getForceAccredited() public view virtual returns (bool);\n\n    function setForceAccredited(\n        bool _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function setForceAccreditedUS(\n        bool _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getForceAccreditedUS() public view virtual returns (bool);\n\n    function setWorldWideForceFullTransfer(\n        bool _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getWorldWideForceFullTransfer() public view virtual returns (bool);\n\n    function getAuthorizedSecurities() public view virtual returns (uint256);\n\n    function setAuthorizedSecurities(\n        uint256 _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getDisallowBackDating() public view virtual returns (bool);\n\n    function setDisallowBackDating(\n        bool _value /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function setAll(\n        uint256[] memory _uint_values,\n        bool[] memory _bool_values /*onlyTransferAgentOrAbove*/\n    ) public virtual;\n\n    function getAll() public view virtual returns (uint256[] memory, bool[] memory);\n}\n"},"contracts/data-stores/ComplianceConfigurationDataStore.sol":{"content":"pragma solidity ^0.8.13;\n\nimport \"./ServiceConsumerDataStore.sol\";\n\n//SPDX-License-Identifier: UNLICENSED\ncontract ComplianceConfigurationDataStore is ServiceConsumerDataStore {\n    mapping(string => uint256) public countriesCompliances;\n    uint256 public totalInvestorsLimit;\n    uint256 public minUSTokens;\n    uint256 public minEUTokens;\n    uint256 public usInvestorsLimit;\n    uint256 public jpInvestorsLimit;\n    uint256 public usAccreditedInvestorsLimit;\n    uint256 public nonAccreditedInvestorsLimit;\n    uint256 public maxUSInvestorsPercentage;\n    uint256 public blockFlowbackEndTime;\n    uint256 public nonUSLockPeriod;\n    uint256 public minimumTotalInvestors;\n    uint256 public minimumHoldingsPerInvestor;\n    uint256 public maximumHoldingsPerInvestor;\n    uint256 public euRetailInvestorsLimit;\n    uint256 public usLockPeriod;\n    bool public forceFullTransfer;\n    bool public forceAccreditedUS;\n    bool public forceAccredited;\n    bool public worldWideForceFullTransfer;\n    uint256 public authorizedSecurities;\n    bool public disallowBackDating;\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"}},"matchId":"2811597","creationMatch":"match","runtimeMatch":"match","verifiedAt":"2024-08-08T16:35:51Z","match":"match","chainId":"1","address":"0x603Bb6909Be14f83282E03632280D91bE7fB83b2"}