{"sources":{"src/shares/IShares.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IShares {\n\tfunction burn(uint256) external;\n\n\tfunction totalShares() external view returns (uint256);\n}"},"src/shares/Shares.sol":{"content":"/**\n* SPDX-License-Identifier: LicenseRef-Aktionariat\n*\n* MIT License with Automated License Fee Payments\n*\n* Copyright (c) 2020 Aktionariat AG (aktionariat.com)\n*\n* Permission is hereby granted to any person obtaining a copy of this software\n* and associated documentation files (the \"Software\"), to deal in the Software\n* without restriction, including without limitation the rights to use, copy,\n* modify, merge, publish, distribute, sublicense, and/or sell copies of the\n* Software, and to permit persons to whom the Software is furnished to do so,\n* subject to the following conditions:\n*\n* - The above copyright notice and this permission notice shall be included in\n*   all copies or substantial portions of the Software.\n* - All automated license fee payments integrated into this and related Software\n*   are preserved.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n* SOFTWARE.\n*/\npragma solidity ^0.8.0;\n\nimport \"../ERC20/ERC20Named.sol\";\nimport \"../ERC20/IERC677Receiver.sol\";\nimport \"../recovery/ERC20Recoverable.sol\";\nimport \"../shares/IShares.sol\";\n\n/**\n * @title CompanyName AG Shares\n * @author Luzius Meisser, luzius@aktionariat.com\n *\n * These tokens represent ledger-based securities according to article 973d of the Swiss Code of Obligations.\n * This smart contract serves as an ownership registry, enabling the token holders to register them as\n * shareholders in the issuer's shareholder registry. This is equivalent to the traditional system\n * of having physical share certificates kept at home by the shareholders and a shareholder registry run by\n * the company. Just like with physical certificates, the owners of the tokens are the owners of the shares.\n * However, in order to exercise their rights (for example receive a dividend), shareholders must register\n * themselves. For example, in case the company pays out a dividend to a previous shareholder because\n * the current shareholder did not register, the company cannot be held liable for paying the dividend to\n * the \"wrong\" shareholder. In relation to the company, only the registered shareholders count as such.\n */\ncontract Shares is ERC20Recoverable, ERC20Named, IShares{\n\n    string public terms;\n\n    uint256 public override totalShares; // total number of shares, maybe not all tokenized\n    uint256 public invalidTokens;\n\n    event Announcement(string message);\n    event TokensDeclaredInvalid(address indexed holder, uint256 amount, string message);\n    event ChangeTerms(string terms);\n    event ChangeTotalShares(uint256 total);\n\n    constructor(\n        string memory _symbol,\n        string memory _name,\n        string memory _terms,\n        uint256 _totalShares,\n        address _owner,\n        IRecoveryHub _recoveryHub\n    )\n        ERC20Named(_symbol, _name, 0, _owner) \n        ERC20Recoverable(_recoveryHub)\n    {\n        totalShares = _totalShares;\n        terms = _terms;\n        invalidTokens = 0;\n        _recoveryHub.setRecoverable(false); \n    }\n\n    function setTerms(string memory _terms) external onlyOwner {\n        terms = _terms;\n        emit ChangeTerms(_terms);\n    }\n\n    /**\n     * Declares the number of total shares, including those that have not been tokenized and those\n     * that are held by the company itself. This number can be substiantially higher than totalSupply()\n     * in case not all shares have been tokenized. Also, it can be lower than totalSupply() in case some\n     * tokens have become invalid.\n     */\n    function setTotalShares(uint256 _newTotalShares) external onlyOwner() {\n        require(_newTotalShares >= totalValidSupply(), \"below supply\");\n        totalShares = _newTotalShares;\n        emit ChangeTotalShares(_newTotalShares);\n    }\n\n    /**\n     * Allows the issuer to make public announcements that are visible on the blockchain.\n     */\n    function announcement(string calldata message) external onlyOwner() {\n        emit Announcement(message);\n    }\n\n    /**\n     * See parent method for collateral requirements.\n     */\n    function setCustomClaimCollateral(IERC20 collateral, uint256 rate) external onlyOwner() {\n        super._setCustomClaimCollateral(collateral, rate);\n    }\n\n    function getClaimDeleter() public override view returns (address) {\n        return owner;\n    }\n\n    /**\n     * Signals that the indicated tokens have been declared invalid (e.g. by a court ruling in accordance\n     * with article 973g of the Swiss Code of Obligations) and got detached from\n     * the underlying shares. Invalid tokens do not carry any shareholder rights any more.\n     *\n     * This function is purely declarative. It does not technically immobilize the affected tokens as\n     * that would give the issuer too much power.\n     */\n    function declareInvalid(address holder, uint256 amount, string calldata message) external onlyOwner() {\n        uint256 holderBalance = balanceOf(holder);\n        require(amount <= holderBalance, \"amount too high\");\n        invalidTokens += amount;\n        emit TokensDeclaredInvalid(holder, amount, message);\n    }\n\n    /**\n     * The total number of valid tokens in circulation. In case some tokens have been declared invalid, this\n     * number might be lower than totalSupply(). Also, it will always be lower than or equal to totalShares().\n     */\n    function totalValidSupply() public view returns (uint256) {\n        return totalSupply() - invalidTokens;\n    }\n\n    /**\n     * Allows the company to tokenize shares and transfer them e.g to the draggable contract and wrap them.\n     * If these shares are newly created, setTotalShares must be called first in order to adjust the total number of shares.\n     */\n    function mintAndCall(address shareholder, address callee, uint256 amount, bytes calldata data) external {\n        mint(callee, amount);\n        require(IERC677Receiver(callee).onTokenTransfer(shareholder, amount, data));\n    }\n\n    function mint(address target, uint256 amount) public onlyOwner {\n        _mint(target, amount);\n    }\n\n    function _mint(address account, uint256 amount) internal virtual override {\n        require(totalValidSupply() + amount <= totalShares, \"total\");\n        super._mint(account, amount);\n    }\n\n    function transfer(address to, uint256 value) virtual override(ERC20Recoverable, ERC20Flaggable) public returns (bool) {\n        return super.transfer(to, value);\n    }\n\n    /**\n     * Transfers _amount tokens to the company and burns them.\n     * The meaning of this operation depends on the circumstances and the fate of the shares does\n     * not necessarily follow the fate of the tokens. For example, the company itself might call\n     * this function to implement a formal decision to destroy some of the outstanding shares.\n     * Also, this function might be called by an owner to return the shares to the company and\n     * get them back in another form under an according agreement (e.g. printed certificates or\n     * tokens on a different blockchain). It is not recommended to call this function without\n     * having agreed with the company on the further fate of the shares in question.\n     */\n    function burn(uint256 _amount) override external {\n        _transfer(msg.sender, address(this), _amount);\n        _burn(address(this), _amount);\n    }\n\n}"},"src/ERC20/ERC20Allowlistable.sol":{"content":"/**\n* SPDX-License-Identifier: LicenseRef-Aktionariat\n*\n* MIT License with Automated License Fee Payments\n*\n* Copyright (c) 2021 Aktionariat AG (aktionariat.com)\n*\n* Permission is hereby granted to any person obtaining a copy of this software\n* and associated documentation files (the \"Software\"), to deal in the Software\n* without restriction, including without limitation the rights to use, copy,\n* modify, merge, publish, distribute, sublicense, and/or sell copies of the\n* Software, and to permit persons to whom the Software is furnished to do so,\n* subject to the following conditions:\n*\n* - The above copyright notice and this permission notice shall be included in\n*   all copies or substantial portions of the Software.\n* - All automated license fee payments integrated into this and related Software\n*   are preserved.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n* SOFTWARE.\n*/\npragma solidity ^0.8.0;\n\n\nimport \"./ERC20Flaggable.sol\";\nimport \"../utils/Ownable.sol\";\n\n/**\n * A very flexible and efficient form to subject ERC-20 tokens to an allowlisting.\n * See ../../doc/allowlist.md for more information.\n */\nabstract contract ERC20Allowlistable is ERC20Flaggable, Ownable {\n\n  uint8 private constant TYPE_DEFAULT = 0x0;\n  uint8 private constant TYPE_ALLOWLISTED = 0x1;\n  uint8 private constant TYPE_FORBIDDEN = 0x2;\n  uint8 private constant TYPE_POWERLISTED = 0x4;\n  // I think TYPE_POWERLISTED should have been 0x3. :) But MOP was deployed like this so we keep it. Does not hurt.\n\n  uint8 private constant FLAG_INDEX_ALLOWLIST = 20;\n  uint8 private constant FLAG_INDEX_FORBIDDEN = 21;\n  uint8 private constant FLAG_INDEX_POWERLIST = 22;\n\n  event AddressTypeUpdate(address indexed account, uint8 addressType);\n\n  bool public restrictTransfers;\n\n  constructor(){\n  }\n\n  /**\n   * Configures whether the allowlisting is applied.\n   * Also sets the powerlist and allowlist flags on the null address accordingly.\n   * It is recommended to also deactivate the powerlist flag on other addresses.\n   */\n  function setApplicable(bool transferRestrictionsApplicable) external onlyOwner {\n    setApplicableInternal(transferRestrictionsApplicable);\n  }\n\n  function setApplicableInternal(bool transferRestrictionsApplicable) internal {\n    restrictTransfers = transferRestrictionsApplicable;\n    // if transfer restrictions are applied, we guess that should also be the case for newly minted tokens\n    // if the admin disagrees, it is still possible to change the type of the null address\n    if (transferRestrictionsApplicable){\n      setTypeInternal(address(0x0), TYPE_POWERLISTED);\n    } else {\n      setTypeInternal(address(0x0), TYPE_DEFAULT);\n    }\n  }\n\n  function setType(address account, uint8 typeNumber) public onlyOwner {\n    setTypeInternal(account, typeNumber);\n  }\n\n  /**\n   * If TYPE_DEFAULT all flags are set to 0\n   */\n  function setTypeInternal(address account, uint8 typeNumber) internal {\n    setFlag(account, FLAG_INDEX_ALLOWLIST, typeNumber == TYPE_ALLOWLISTED);\n    setFlag(account, FLAG_INDEX_FORBIDDEN, typeNumber == TYPE_FORBIDDEN);\n    setFlag(account, FLAG_INDEX_POWERLIST, typeNumber == TYPE_POWERLISTED);\n    emit AddressTypeUpdate(account, typeNumber);\n  }\n\n  function setType(address[] calldata addressesToAdd, uint8 value) public onlyOwner {\n    for (uint i=0; i<addressesToAdd.length; i++){\n      setType(addressesToAdd[i], value);\n    }\n  }\n\n  /**\n   * If true, this address is allowlisted and can only transfer tokens to other allowlisted addresses.\n   */\n  function canReceiveFromAnyone(address account) public view returns (bool) {\n    return hasFlagInternal(account, FLAG_INDEX_ALLOWLIST) || hasFlagInternal(account, FLAG_INDEX_POWERLIST);\n  }\n\n  /**\n   * If true, this address can only transfer tokens to allowlisted addresses and not receive from anyone.\n   */\n  function isForbidden(address account) public view returns (bool){\n    return hasFlagInternal(account, FLAG_INDEX_FORBIDDEN);\n  }\n\n  /**\n   * If true, this address can automatically allowlist target addresses if necessary.\n   */\n  function isPowerlisted(address account) public view returns (bool) {\n    return hasFlagInternal(account, FLAG_INDEX_POWERLIST);\n  }\n\n  function _beforeTokenTransfer(address from, address to, uint256 amount) override virtual internal {\n    super._beforeTokenTransfer(from, to, amount);\n    // empty block for gas saving fall through\n    // solhint-disable-next-line no-empty-blocks\n    if (canReceiveFromAnyone(to)){\n      // ok, transfers to allowlisted addresses are always allowed\n    } else if (isForbidden(to)){\n      // Target is forbidden, but maybe restrictions have been removed and we can clean the flag\n      require(!restrictTransfers, \"not allowed\");\n      setFlag(to, FLAG_INDEX_FORBIDDEN, false);\n    } else {\n      if (isPowerlisted(from)){\n        // it is not allowlisted, but we can make it so\n        // we know the recipient is neither forbidden, allowlisted or powerlisted, so we can set flag directly\n        setFlag(to, FLAG_INDEX_ALLOWLIST, true);\n      }\n      // if we made it to here, the target must be a free address and we are not powerlisted\n      else if (hasFlagInternal(from, FLAG_INDEX_ALLOWLIST)){\n        // We cannot send to free addresses, but maybe the restrictions have been removed and we can clean the flag?\n        require(!restrictTransfers, \"not allowed\");\n        setFlag(from, FLAG_INDEX_ALLOWLIST, false);\n      } else if (isForbidden(from)){\n        require(!restrictTransfers, \"not allowed\");\n        setFlag(from, FLAG_INDEX_FORBIDDEN, false);\n      }\n    }\n  }\n\n}\n"},"src/ERC20/ERC20Named.sol":{"content":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./ERC20Flaggable.sol\";\nimport \"../utils/Ownable.sol\";\n\ncontract ERC20Named is ERC20Flaggable, Ownable {\n\n    string public override name;\n    string public override symbol;\n\n    constructor(string memory _symbol, string memory _name, uint8 _decimals, address _admin) ERC20Flaggable(_decimals) Ownable(_admin) {\n        setNameInternal(_symbol, _name);\n    }\n\n    function setName(string memory _symbol, string memory _name) external onlyOwner {\n        setNameInternal(_symbol, _name);\n    }\n\n    function setNameInternal(string memory _symbol, string memory _name) internal {\n        symbol = _symbol;\n        name = _name;\n        emit NameChanged(_name, _symbol);\n    }\n\n}"},"src/ERC20/IERC677Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IERC677Receiver {\n    \n    function onTokenTransfer(address from, uint256 amount, bytes calldata data) external returns (bool);\n\n}"},"src/recovery/IRecoverable.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../ERC20/IERC20.sol\";\n\ninterface IRecoverable is IERC20{\n\n    function claimPeriod() external view returns (uint256);\n    \n    function notifyClaimMade(address target) external;\n\n    function notifyClaimDeleted(address target) external;\n\n    function getCollateralRate(IERC20 collateral) external view returns(uint256);\n\n    function recover(address oldAddress, address newAddress) external;\n\n}"},"src/shares/AllowlistShares.sol":{"content":"/**\n* SPDX-License-Identifier: LicenseRef-Aktionariat\n*\n* MIT License with Automated License Fee Payments\n*\n* Copyright (c) 2020 Aktionariat AG (aktionariat.com)\n*\n* Permission is hereby granted to any person obtaining a copy of this software\n* and associated documentation files (the \"Software\"), to deal in the Software\n* without restriction, including without limitation the rights to use, copy,\n* modify, merge, publish, distribute, sublicense, and/or sell copies of the\n* Software, and to permit persons to whom the Software is furnished to do so,\n* subject to the following conditions:\n*\n* - The above copyright notice and this permission notice shall be included in\n*   all copies or substantial portions of the Software.\n* - All automated license fee payments integrated into this and related Software\n*   are preserved.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n* SOFTWARE.\n*/\npragma solidity ^0.8.0;\n\nimport \"../recovery/ERC20Recoverable.sol\";\nimport \"../ERC20/ERC20Allowlistable.sol\";\nimport \"./Shares.sol\";\n\ncontract AllowlistShares is Shares, ERC20Allowlistable {\n\n  constructor(\n    string memory _symbol,\n    string memory _name,\n    string memory _terms,\n    uint256 _totalShares,\n    IRecoveryHub _recoveryHub,\n    address _owner\n  )\n    Shares(_symbol, _name, _terms, _totalShares, _owner, _recoveryHub)\n    ERC20Allowlistable()\n  {\n    // initialization in shares\n  }\n\n  function transfer(address recipient, uint256 amount) override(ERC20Flaggable, Shares) virtual public returns (bool) {\n    return super.transfer(recipient, amount); \n  }\n\n  function _mint(address account, uint256 amount) internal override(ERC20Flaggable, Shares) {\n      super._mint(account, amount);\n  }\n\n  function _beforeTokenTransfer(address from, address to, uint256 amount) virtual override(ERC20Flaggable, ERC20Allowlistable) internal {\n    super._beforeTokenTransfer(from, to, amount);\n  }\n\n}"},"src/ERC20/ERC20Flaggable.sol":{"content":"// SPDX-License-Identifier: MIT\n// Copied and adjusted from OpenZeppelin\n// Adjustments:\n// - modifications to support ERC-677\n// - removed unnecessary require statements\n// - removed GSN Context\n// - upgraded to 0.8 to drop SafeMath\n// - let name() and symbol() be implemented by subclass\n// - infinite allowance support, with 2^255 and above considered infinite\n// - use upper 32 bits of balance for flags\n// - add a global settings variable\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./IERC677Receiver.sol\";\n\n/**\n * @dev Implementation of the `IERC20` interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using `_mint`.\n * For a generic mechanism see `ERC20Mintable`.\n *\n * *For a detailed writeup see our guide [How to implement supply\n * mechanisms](https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226).*\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an `Approval` event is emitted on calls to `transferFrom`.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard `decreaseAllowance` and `increaseAllowance`\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See `IERC20.approve`.\n */\n\nabstract contract ERC20Flaggable is IERC20 {\n\n    // as Documented in /doc/infiniteallowance.md\n    // 0x8000000000000000000000000000000000000000000000000000000000000000\n    uint256 constant private INFINITE_ALLOWANCE = 2**255;\n\n    uint256 private constant FLAGGING_MASK = 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000;\n\n    // Documentation of flags used by subclasses:\n    // NOTE: flags denote the bit number that is being used and must be smaller than 32\n    // ERC20Draggable: uint8 private constant FLAG_INDEX_VOTED = 1;\n    // ERC20Recoverable: uint8 private constant FLAG_INDEX_CLAIM_PRESENT = 10;\n    // ERCAllowlistable: uint8 private constant FLAG_INDEX_ALLOWLIST = 20;\n    // ERCAllowlistable: uint8 private constant FLAG_INDEX_FORBIDDEN = 21;\n    // ERCAllowlistable: uint8 private constant FLAG_INDEX_POWERLIST = 22;\n\n    mapping (address => uint256) private _balances; // upper 32 bits reserved for flags\n\n    mapping (address => mapping (address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    uint8 public override decimals;\n\n    event NameChanged(string name, string symbol);\n\n    constructor(uint8 _decimals) {\n        decimals = _decimals;\n    }\n\n    /**\n     * @dev See `IERC20.totalSupply`.\n     */\n    function totalSupply() public view override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See `IERC20.balanceOf`.\n     */\n    function balanceOf(address account) public view override returns (uint256) {\n        return uint224 (_balances [account]);\n    }\n\n    function hasFlag(address account, uint8 number) external view returns (bool) {\n        return hasFlagInternal(account, number);\n    }\n\n    function setFlag(address account, uint8 index, bool value) internal {\n        uint256 flagMask = 1 << (index + 224);\n        uint256 balance = _balances [account];\n        if ((balance & flagMask == flagMask) != value) {\n            _balances [account] = balance ^ flagMask;\n        }\n    }\n\n    function hasFlagInternal(address account, uint8 number) internal view returns (bool) {\n        uint256 flag = 0x1 << (number + 224);\n        return _balances[account] & flag == flag;\n    }\n\n    /**\n     * @dev See `IERC20.transfer`.\n     *\n     * Requirements:\n     *\n     * - `recipient` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n        _transfer(msg.sender, recipient, amount);\n        return true;\n    }\n\n    /**\n     * @dev See `IERC20.allowance`.\n     */\n    function allowance(address owner, address spender) external view override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See `IERC20.approve`.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 value) external override returns (bool) {\n        _approve(msg.sender, spender, value);\n        return true;\n    }\n\n    /**\n     * @dev See `IERC20.transferFrom`.\n     *\n     * Emits an `Approval` event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of `ERC20`;\n     *\n     * Requirements:\n     * - `sender` and `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `value`.\n     * - the caller must have allowance for `sender`'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {\n        _transfer(sender, recipient, amount);\n        uint256 currentAllowance = _allowances[sender][msg.sender];\n        if (currentAllowance < INFINITE_ALLOWANCE){\n            // Only decrease the allowance if it was not set to 'infinite'\n            // Documented in /doc/infiniteallowance.md\n            _allowances[sender][msg.sender] = currentAllowance - amount;\n        }\n        return true;\n    }\n\n    /**\n     * @dev Moves tokens `amount` from `sender` to `recipient`.\n     *\n     * This is internal function is equivalent to `transfer`, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a `Transfer` event.\n     *\n     * Requirements:\n     *\n     * - `sender` cannot be the zero address.\n     * - `recipient` cannot be the zero address.\n     * - `sender` must have a balance of at least `amount`.\n     */\n    function _transfer(address sender, address recipient, uint256 amount) internal virtual {\n        _beforeTokenTransfer(sender, recipient, amount);\n        decreaseBalance(sender, amount);\n        increaseBalance(recipient, amount);\n        emit Transfer(sender, recipient, amount);\n    }\n\n    // ERC-677 functionality, can be useful for swapping and wrapping tokens\n    function transferAndCall(address recipient, uint amount, bytes calldata data) external virtual returns (bool) {\n        return transfer (recipient, amount) \n            && IERC677Receiver (recipient).onTokenTransfer (msg.sender, amount, data);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a `Transfer` event with `from` set to the zero address.\n     *\n     * Requirements\n     *\n     * - `to` cannot be the zero address.\n     */\n    function _mint(address recipient, uint256 amount) internal virtual {\n        _beforeTokenTransfer(address(0), recipient, amount);\n        _totalSupply += amount;\n        increaseBalance(recipient, amount);\n        emit Transfer(address(0), recipient, amount);\n    }\n\n    function increaseBalance(address recipient, uint256 amount) private {\n        require(recipient != address(0x0), \"0x0\"); // use burn instead\n        uint256 oldBalance = _balances[recipient];\n        uint256 newBalance = oldBalance + amount;\n        require(oldBalance & FLAGGING_MASK == newBalance & FLAGGING_MASK, \"overflow\");\n        _balances[recipient] = newBalance;\n    }\n\n     /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a `Transfer` event with `to` set to the zero address.\n     *\n     * Requirements\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        _beforeTokenTransfer(account, address(0), amount);\n\n        _totalSupply -= amount;\n        decreaseBalance(account, amount);\n        emit Transfer(account, address(0), amount);\n    }\n\n    function decreaseBalance(address sender, uint256 amount) private {\n        uint256 oldBalance = _balances[sender];\n        uint256 newBalance = oldBalance - amount;\n        require(oldBalance & FLAGGING_MASK == newBalance & FLAGGING_MASK, \"underflow\");\n        _balances[sender] = newBalance;\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.\n     *\n     * This is internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an `Approval` event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(address owner, address spender, uint256 value) internal {\n        _allowances[owner][spender] = value;\n        emit Approval(owner, spender, value);\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be to transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n     // solhint-disable-next-line no-empty-blocks\n    function _beforeTokenTransfer(address from, address to, uint256 amount) virtual internal {\n        // intentionally left blank\n    }\n\n}"},"src/ERC20/IERC20.sol":{"content":"/**\n* SPDX-License-Identifier: MIT\n*\n* Copyright (c) 2016-2019 zOS Global Limited\n*\n*/\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP. Does not include\n * the optional functions; to access them see `ERC20Detailed`.\n */\n\ninterface IERC20 {\n\n    // Optional functions\n    function name() external view returns (string memory);\n\n    function symbol() external view returns (string memory);\n\n    function decimals() external view returns (uint8);\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 `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a `Transfer` event.\n     */\n    function transfer(address recipient, 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     * > 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 `sender` to `recipient` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a `Transfer` event.\n     */\n    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\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}"},"src/recovery/ERC20Recoverable.sol":{"content":"/**\n* SPDX-License-Identifier: LicenseRef-Aktionariat\n*\n* MIT License with Automated License Fee Payments\n*\n* Copyright (c) 2020 Aktionariat AG (aktionariat.com)\n*\n* Permission is hereby granted to any person obtaining a copy of this software\n* and associated documentation files (the \"Software\"), to deal in the Software\n* without restriction, including without limitation the rights to use, copy,\n* modify, merge, publish, distribute, sublicense, and/or sell copies of the\n* Software, and to permit persons to whom the Software is furnished to do so,\n* subject to the following conditions:\n*\n* - The above copyright notice and this permission notice shall be included in\n*   all copies or substantial portions of the Software.\n* - All automated license fee payments integrated into this and related Software\n*   are preserved.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n* SOFTWARE.\n*/\npragma solidity ^0.8.0;\n\nimport \"../ERC20/ERC20Flaggable.sol\";\nimport \"./IRecoveryHub.sol\";\nimport \"./IRecoverable.sol\";\n\n/**\n * @title Recoverable\n * In case of tokens that represent real-world assets such as shares of a company, one needs a way\n * to handle lost private keys. With physical certificates, courts can declare share certificates as\n * invalid so the company can issue replacements. Here, we want a solution that does not depend on\n * third parties to resolve such cases. Instead, when someone has lost a private key, he can use the\n * declareLost function on the recovery hub to post a deposit and claim that the shares assigned to a\n * specific address are lost.\n * If an attacker trying to claim shares belonging to someone else, they risk losing the deposit\n * as it can be claimed at anytime by the rightful owner.\n * Furthermore, if \"getClaimDeleter\" is defined in the subclass, the returned address is allowed to\n * delete claims, returning the collateral. This can help to prevent obvious cases of abuse of the claim\n * function, e.g. cases of front-running.\n * Most functionality is implemented in a shared RecoveryHub.\n */\nabstract contract ERC20Recoverable is ERC20Flaggable, IRecoverable {\n\n    uint8 private constant FLAG_CLAIM_PRESENT = 10;\n\n    // ERC-20 token that can be used as collateral or 0x0 if disabled\n    IERC20 public customCollateralAddress;\n    // Rate the custom collateral currency is multiplied to be valued like one share.\n    uint256 public customCollateralRate;\n\n    uint256 constant CLAIM_PERIOD = 180 days;\n\n    IRecoveryHub public immutable recovery;\n\n    constructor(IRecoveryHub recoveryHub){\n        recovery = recoveryHub;\n    }\n\n    /**\n     * Returns the collateral rate for the given collateral type and 0 if that type\n     * of collateral is not accepted. By default, only the token itself is accepted at\n     * a rate of 1:1.\n     *\n     * Subclasses should override this method if they want to add additional types of\n     * collateral.\n     */\n    function getCollateralRate(IERC20 collateralType) public override virtual view returns (uint256) {\n        if (address(collateralType) == address(this)) {\n            return 1;\n        } else if (collateralType == customCollateralAddress) {\n            return customCollateralRate;\n        } else {\n            return 0;\n        }\n    }\n\n    function claimPeriod() external pure override returns (uint256){\n        return CLAIM_PERIOD;\n    }\n\n    /**\n     * Allows subclasses to set a custom collateral besides the token itself.\n     * The collateral must be an ERC-20 token that returns true on successful transfers and\n     * throws an exception or returns false on failure.\n     * Also, do not forget to multiply the rate in accordance with the number of decimals of the collateral.\n     * For example, rate should be 7*10**18 for 7 units of a collateral with 18 decimals.\n     */\n    function _setCustomClaimCollateral(IERC20 collateral, uint256 rate) internal {\n        customCollateralAddress = collateral;\n        if (address(customCollateralAddress) == address(0)) {\n            customCollateralRate = 0; // disabled\n        } else {\n            require(rate > 0, \"zero\");\n            customCollateralRate = rate;\n        }\n    }\n\n    function getClaimDeleter() virtual public view returns (address);\n\n    function transfer(address recipient, uint256 amount) override(ERC20Flaggable, IERC20) virtual public returns (bool) {\n        require(super.transfer(recipient, amount), \"transfer\");\n        if (hasFlagInternal(msg.sender, FLAG_CLAIM_PRESENT)){\n            recovery.clearClaimFromToken(msg.sender);\n        }\n        return true;\n    }\n\n    function notifyClaimMade(address target) external override {\n        require(msg.sender == address(recovery), \"not recovery\");\n        setFlag(target, FLAG_CLAIM_PRESENT, true);\n    }\n\n    function notifyClaimDeleted(address target) external override {\n        require(msg.sender == address(recovery), \"not recovery\");\n        setFlag(target, FLAG_CLAIM_PRESENT, false);\n    }\n\n    function deleteClaim(address lostAddress) external {\n        require(msg.sender == getClaimDeleter(), \"not claim deleter\");\n        recovery.deleteClaim(lostAddress);\n    }\n\n    function recover(address oldAddress, address newAddress) external override {\n        require(msg.sender == address(recovery), \"not recovery\");\n        _transfer(oldAddress, newAddress, balanceOf(oldAddress));\n    }\n\n}"},"src/recovery/IRecoveryHub.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IRecoveryHub {\n\n    function setRecoverable(bool flag) external;\n    \n    // deletes claim and transfers collateral back to claimer\n    function deleteClaim(address target) external;\n\n    // clears claim and transfers collateral to holder\n    function clearClaimFromToken(address holder) external;\n\n}"},"src/utils/Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\n//\n// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol\n//\n// Modifications:\n// - Replaced Context._msgSender() with msg.sender\n// - Made leaner\n// - Extracted interface\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\ncontract Ownable {\n\n    address public owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor (address initialOwner) {\n        owner = initialOwner;\n        emit OwnershipTransferred(address(0), owner);\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) external onlyOwner {\n        emit OwnershipTransferred(owner, newOwner);\n        owner = newOwner;\n    }\n\n    modifier onlyOwner() {\n        require(owner == msg.sender, \"not owner\");\n        _;\n    }\n}"}},"matchId":"6557131","creationMatch":"exact_match","runtimeMatch":"exact_match","verifiedAt":"2025-06-22T05:50:29Z","match":"exact_match","chainId":"1","address":"0x553C7f9C780316FC1D34b8e14ac2465Ab22a090B"}