{"sources":{"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/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/draggable/IOffer.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../ERC20/IERC20.sol\";\n\ninterface IOffer {\n\tfunction makeCompetingOffer(IOffer newOffer) external;\n\n\t// if there is a token transfer while an offer is open, the votes get transfered too\n\tfunction notifyMoved(address from, address to, uint256 value) external;\n\n\tfunction currency() external view returns (IERC20);\n\n\tfunction price() external view returns (uint256);\n\n\tfunction isWellFunded() external view returns (bool);\n\n\tfunction voteYes() external;\n\n\tfunction voteNo() external;\n}"},"src/ERC20/IERC20Permit.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n// Copied from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit is IERC20 {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}"},"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/draggable/IDraggable.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../ERC20/IERC20.sol\";\nimport \"./IOffer.sol\";\ninterface IDraggable {\n    \n    function wrapped() external view returns (IERC20);\n    function unwrap(uint256 amount) external;\n    function offer() external view returns (IOffer);\n    function oracle() external view returns (address);\n    function drag(address buyer, IERC20 currency) external;\n    function notifyOfferEnded() external;\n    function votingPower(address voter) external returns (uint256);\n    function totalVotingTokens() external view returns (uint256);\n    function notifyVoted(address voter) external;\n    function setTerms(string calldata _terms) external;\n\n}"},"src/ERC20/IERC677Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// Given that development on ERC 677 has stalled, we should consider supporting EIP 1363: https://eips.ethereum.org/EIPS/eip-1363\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\";\nimport \"./IRecoveryHub.sol\";\n\ninterface IRecoverable is IERC20{\n\n    // returns the recovery hub\n    function recovery() external view returns (IRecoveryHub);\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/recovery/IRecoveryHub.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./IRecoverable.sol\";\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    function clearClaimFromUser(IRecoverable token) external;\n\n}"},"src/ERC20/ERC20PermitLight.sol":{"content":"// SPDX-License-Identifier: MIT\n// Copied from https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol\n// and modified it.\n\npragma solidity ^0.8.0;\n\nimport \"./ERC20Flaggable.sol\";\nimport \"./IERC20Permit.sol\";\n\nabstract contract ERC20PermitLight is ERC20Flaggable, IERC20Permit {\n   \n   /*//////////////////////////////////////////////////////////////\n                            EIP-2612 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    mapping(address => uint256) public override nonces;\n\n  /*//////////////////////////////////////////////////////////////\n                             EIP-2612 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public override {\n        require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n        unchecked { // unchecked to save a little gas with the nonce increment...\n            address recoveredAddress = ecrecover(\n                keccak256(\n                    abi.encodePacked(\n                        \"\\x19\\x01\",\n                        DOMAIN_SEPARATOR(),\n                        keccak256(\n                            abi.encode(\n                                // keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"),\n                                bytes32(0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9),\n                                owner,\n                                spender,\n                                value,\n                                nonces[owner]++,\n                                deadline\n                            )\n                        )\n                    )\n                ),\n                v,\n                r,\n                s\n            );\n\n            require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n            _approve(recoveredAddress, spender, value);\n        }\n    }\n\n    function DOMAIN_SEPARATOR() public view override returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    //keccak256(\"EIP712Domain(uint256 chainId,address verifyingContract)\");\n                    bytes32(0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218),\n                    block.chainid,\n                    address(this)\n                )\n            );\n    }\n\n}"},"src/shares/DraggableShares.sol":{"content":"/**\n* SPDX-License-Identifier: LicenseRef-Aktionariat\n*\n* MIT License with Automated License Fee Payments\n*\n* Copyright (c) 2022 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 \"../draggable/ERC20Draggable.sol\";\nimport \"../ERC20/ERC20PermitLight.sol\";\n\n/**\n * @title CompanyName AG Shares SHA\n * @author Luzius Meisser, luzius@aktionariat.com\n *\n * This is an ERC-20 token representing share tokens of CompanyName AG that are bound to\n * a shareholder agreement that can be found at the URL defined in the constant 'terms'.\n */\ncontract DraggableShares is ERC20Draggable, ERC20Recoverable, ERC20PermitLight {\n\n    string public terms;\n\n    event ChangeTerms(string terms); \n\n    constructor(\n        string memory _terms,\n        IERC20 _wrappedToken,\n        uint256 _quorumBps,\n        uint256 _quorumMigration,\n        uint256 _votePeriodSeconds,\n        IRecoveryHub _recoveryHub,\n        IOfferFactory _offerFactory,\n        address _oracle\n    )\n        ERC20Draggable(_wrappedToken, _quorumBps, _quorumMigration, _votePeriodSeconds, _offerFactory, _oracle)\n        ERC20Recoverable(_recoveryHub)\n        ERC20PermitLight() \n    {\n        terms = _terms; // oracle can change the terms\n        _recoveryHub.setRecoverable(false);\n    }\n\n    function transfer(address to, uint256 value) virtual override(ERC20Flaggable, ERC20Recoverable) public returns (bool) {\n        return super.transfer(to, value);\n    }\n\n    /**\n     * Let the oracle act as deleter of invalid claims. In earlier versions, this was referring to the claim deleter\n     * of the wrapped token. But that stops working after a successful acquisition as the acquisition currency most\n     * likely does not have a claim deleter.\n     */\n    function getClaimDeleter() public view override returns (address) {\n        return oracle;\n    }\n\n    function getCollateralRate(IERC20 collateralType) public view override returns (uint256) {\n        uint256 rate = super.getCollateralRate(collateralType);\n        if (rate > 0) {\n            return rate;\n        } else {\n            // as long as it is binding, the conversion rate is 1:1\n            uint256 factor = isBinding() ? 1 : unwrapConversionFactor;\n            if (address(collateralType) == address(wrapped)) {\n                // allow wrapped token as collateral\n                return factor;\n            } else {\n                // If the wrapped contract allows for a specific collateral, we should too.\n                // If the wrapped contract is not IRecoverable, we will fail here, but would fail anyway.\n                return IRecoverable(address(wrapped)).getCollateralRate(collateralType) * factor;\n            }\n        }\n    }\n\n    function setTerms(string calldata _terms) external override {\n        require(msg.sender == oracle, \"not oracle\");\n        terms = _terms;\n        emit ChangeTerms(terms);\n    }\n\n    function _beforeTokenTransfer(address from, address to, uint256 amount) virtual override(ERC20Flaggable, ERC20Draggable) internal {\n        super._beforeTokenTransfer(from, to, amount);\n    }\n\n}"},"src/draggable/IOfferFactory.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"../ERC20/IERC20.sol\";\nimport \"./IOffer.sol\";\n\ninterface IOfferFactory {\n\n\tfunction create(\n\t\tbytes32 salt, address buyer, uint256 pricePerShare,\tIERC20 currency,\tuint256 quorum,\tuint256 votePeriod\n\t) external payable returns (IOffer);\n}"},"src/draggable/ERC20Draggable.sol":{"content":"/**\n * SPDX-License-Identifier: LicenseRef-Aktionariat\n *\n * MIT License with Automated License Fee Payments\n *\n * Copyright (c) 2022 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/**\n * @title ERC-20 tokens subject to a drag-along agreement\n * @author Luzius Meisser, luzius@aktionariat.com\n *\n * This is an ERC-20 token that is bound to a shareholder or other agreement that contains\n * a drag-along clause. The smart contract can help enforce this drag-along clause in case\n * an acquirer makes an offer using the provided functionality. If a large enough quorum of\n * token holders agree, the remaining token holders can be automatically \"dragged along\" or\n * squeezed out. For shares non-tokenized shares, the contract relies on an external Oracle\n * to provide the votes of those.\n *\n * Subclasses should provide a link to a human-readable form of the agreement.\n */\n\nimport \"./IDraggable.sol\";\nimport \"../ERC20/ERC20Flaggable.sol\";\nimport \"../ERC20/IERC20.sol\";\nimport \"../ERC20/IERC677Receiver.sol\";\nimport \"./IOffer.sol\";\nimport \"./IOfferFactory.sol\";\nimport \"../shares/IShares.sol\";\n\nabstract contract ERC20Draggable is IERC677Receiver, IDraggable, ERC20Flaggable {\n    \n\t// If flag is not present, one can be sure that the address did not vote. If the \n\t// flag is present, the address might have voted and one needs to check with the\n\t// current offer (if any) when transferring tokens.\n\tuint8 private constant FLAG_VOTE_HINT = 1;\n\n\tIERC20 public override wrapped; // The wrapped contract\n\tIOfferFactory public immutable factory;\n\n\t// If the wrapped tokens got replaced in an acquisition, unwrapping might yield many currency tokens\n\tuint256 public unwrapConversionFactor = 0;\n\n\t// The current acquisition attempt, if any. See initiateAcquisition to see the requirements to make a public offer.\n\tIOffer public override offer;\n\n\tuint256 private constant QUORUM_MULTIPLIER = 10000;\n\n\tuint256 public immutable quorumMigration; // used for contract migartion, in BPS (out of 10'000) \n\tuint256 public immutable quorum; // used for drag-along at acquisition offers, in BPS (out of 10'000)\n\tuint256 public immutable votePeriod; // In seconds\n\n\taddress public override oracle;\n\n\tevent MigrationSucceeded(address newContractAddress, uint256 yesVotes, uint256 oracleVotes, uint256 totalVotingPower);\n\tevent ChangeOracle(address oracle);\n\n    /**\n\t * Note that the Brokerbot only supports tokens that revert on failure and where transfer never returns false.\n     */\n\tconstructor(\n\t\tIERC20 _wrappedToken,\n\t\tuint256 _quorum,\n\t\tuint256 _quorumMigration,\n\t\tuint256 _votePeriod,\n\t\tIOfferFactory _offerFactory,\n\t\taddress _oracle\n\t) \n\t\tERC20Flaggable(0)\n\t{\n\t\twrapped = _wrappedToken;\n\t\tquorum = _quorum;\n\t\tquorumMigration = _quorumMigration;\n\t\tvotePeriod = _votePeriod;\n\t\tfactory = _offerFactory;\n\t\toracle = _oracle;\n\t}\n\n\tfunction onTokenTransfer(\n\t\taddress from, \n\t\tuint256 amount, \n\t\tbytes calldata\n\t) external override returns (bool) {\n\t\trequire(msg.sender == address(wrapped), \"sender\");\n\t\t_mint(from, amount);\n\t\treturn true;\n\t}\n\n\t/** Wraps additional tokens, thereby creating more ERC20Draggable tokens. */\n\tfunction wrap(address shareholder, uint256 amount) external {\n\t\trequire(wrapped.transferFrom(msg.sender, address(this), amount), \"transfer\");\n\t\t_mint(shareholder, amount);\n\t}\n\n\t/**\n\t * Indicates that the token holders are bound to the token terms and that:\n\t * - Conversion back to the wrapped token (unwrap) is not allowed\n\t * - A drag-along can be performed by making an according offer\n\t * - They can be migrated to a new version of this contract in accordance with the terms\n\t */\n\tfunction isBinding() public view returns (bool) {\n\t\treturn unwrapConversionFactor == 0;\n\t}\n\n    /**\n\t * Current recommended naming convention is to add the postfix \"SHA\" to the plain shares\n\t * in order to indicate that this token represents shares bound to a shareholder agreement.\n\t */\n\tfunction name() public view override returns (string memory) {\n\t\tstring memory wrappedName = wrapped.name();\n\t\tif (isBinding()) {\n\t\t\treturn string(abi.encodePacked(wrappedName, \" SHA\"));\n\t\t} else {\n\t\t\treturn string(abi.encodePacked(wrappedName, \" (Wrapped)\"));\n\t\t}\n\t}\n\n\tfunction symbol() public view override returns (string memory) {\n\t\t// ticker should be less dynamic than name\n\t\treturn string(abi.encodePacked(wrapped.symbol(), \"S\"));\n\t}\n\n\t/**\n\t * Deactivates the drag-along mechanism and enables the unwrap function.\n\t */\n\tfunction deactivate(uint256 factor) internal {\n\t\trequire(factor >= 1, \"factor\");\n\t\tunwrapConversionFactor = factor;\n\t\temit NameChanged(name(), symbol());\n\t}\n\n\t/** Decrease the number of drag-along tokens. The user gets back their shares in return */\n\tfunction unwrap(uint256 amount) external override{\n\t\trequire(!isBinding(), \"factor\");\n\t\tunwrap(msg.sender, amount, unwrapConversionFactor);\n\t}\n\n\tfunction unwrap(address owner, uint256 amount, uint256 factor) internal {\n\t\t_burn(owner, amount);\n\t\trequire(wrapped.transfer(owner, amount * factor), \"transfer\");\n\t}\n\n\t/**\n\t * Burns both the token itself as well as the wrapped token!\n\t * If you want to get out of the shareholder agreement, use unwrap after it has been\n\t * deactivated by a majority vote or acquisition.\n\t *\n\t * Burning only works if wrapped token supports burning. Also, the exact meaning of this\n\t * operation might depend on the circumstances. Burning and reussing the wrapped token\n\t * does not free the sender from the legal obligations of the shareholder agreement.\n\t */\n\tfunction burn(uint256 amount) external {\n\t\t_burn(msg.sender, amount);\n\t\tIShares(address(wrapped)).burn (isBinding() ? amount : amount * unwrapConversionFactor);\n\t}\n\n\tfunction makeAcquisitionOffer(\n\t\tbytes32 salt, \n\t\tuint256 pricePerShare, \n\t\tIERC20 currency\n\t) external payable {\n\t\trequire(isBinding(), \"factor\");\n\t\tIOffer newOffer = factory.create{value: msg.value}(\n\t\t\tsalt, msg.sender, pricePerShare, currency, quorum, votePeriod);\n\n\t\tif (offerExists()) {\n\t\t\toffer.makeCompetingOffer(newOffer);\n\t\t}\n\t\toffer = newOffer;\n\t}\n\n\tfunction drag(address buyer, IERC20 currency) external override offerOnly {\n\t\tunwrap(buyer, balanceOf(buyer), 1);\n\t\treplaceWrapped(currency, buyer);\n\t}\n\n\tfunction notifyOfferEnded() external override offerOnly {\n\t\toffer = IOffer(address(0));\n\t}\n\n\tfunction replaceWrapped(IERC20 newWrapped, address oldWrappedDestination) internal {\n\t\trequire(isBinding(), \"factor\");\n\t\t// Free all old wrapped tokens we have\n\t\trequire(wrapped.transfer(oldWrappedDestination, wrapped.balanceOf(address(this))), \"transfer\");\n\t\t// Count the new wrapped tokens\n\t\twrapped = newWrapped;\n\t\tdeactivate(newWrapped.balanceOf(address(this)) / totalSupply());\n\t}\n\n\tfunction setOracle(address newOracle) external {\n\t\trequire(msg.sender == oracle, \"not oracle\");\n\t\toracle = newOracle;\n\t\temit ChangeOracle(oracle);\n\t}\n\n\tfunction migrateWithExternalApproval(address successor, uint256 additionalVotes) external {\n\t\trequire(msg.sender == oracle, \"not oracle\");\n\t\t// Additional votes cannot be higher than the votes not represented by these tokens.\n\t\t// The assumption here is that more shareholders are bound to the shareholder agreement\n\t\t// that this contract helps enforce and a vote among all parties is necessary to change\n\t\t// it, with an oracle counting and reporting the votes of the others.\n\t\trequire(totalSupply() + additionalVotes <= totalVotingTokens(), \"votes\");\n\t\tmigrate(successor, additionalVotes);\n\t}\n\n\tfunction migrate() external {\n\t\tmigrate(msg.sender, 0);\n\t}\n\n\tfunction migrate(address successor, uint256 additionalVotes) internal {\n\t\tuint256 yesVotes = additionalVotes + balanceOf(successor);\n\t\tuint256 totalVotes = totalVotingTokens();\n\t\trequire(yesVotes <= totalVotes, \"votes\");\n\t\trequire(!offerExists(), \"no offer\"); // if you have the quorum, you can cancel the offer first if necessary\n\t\trequire(yesVotes * QUORUM_MULTIPLIER >= totalVotes * quorumMigration, \"quorum\");\n\t\treplaceWrapped(IERC20(successor), successor);\n\t\temit MigrationSucceeded(successor, yesVotes, additionalVotes, totalVotes);\n\t}\n\n\tfunction votingPower(address voter) external view override returns (uint256) {\n\t\treturn balanceOf(voter);\n\t}\n\n\tfunction totalVotingTokens() public view override returns (uint256) {\n\t\treturn IShares(address(wrapped)).totalShares();\n\t}\n\n\tfunction hasVoted(address voter) internal view returns (bool) {\n\t\treturn hasFlagInternal(voter, FLAG_VOTE_HINT);\n\t}\n\n\tfunction notifyVoted(address voter) external override offerOnly {\n\t\tsetFlag(voter, FLAG_VOTE_HINT, true);\n\t}\n\n\tmodifier offerOnly(){\n\t\trequire(msg.sender == address(offer), \"sender\");\n\t\t_;\n\t}\n\n\tfunction _beforeTokenTransfer(address from, address to,\tuint256 amount) internal virtual override {\n\t\tif (hasVoted(from) || hasVoted(to)) {\n\t\t\tif (offerExists()) {\n\t\t\t\toffer.notifyMoved(from, to, amount);\n\t\t\t} else {\n\t\t\t\tsetFlag(from, FLAG_VOTE_HINT, false);\n\t\t\t\tsetFlag(to, FLAG_VOTE_HINT, false);\n\t\t\t}\n\t\t}\n\t\tsuper._beforeTokenTransfer(from, to, amount);\n\t}\n\n\tfunction offerExists() internal view returns (bool) {\n\t\treturn address(offer) != address(0);\n\t}\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) 2022 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 override 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}"}},"matchId":"1956346","creationMatch":"exact_match","runtimeMatch":"exact_match","verifiedAt":"2024-08-08T14:15:13Z","match":"exact_match","chainId":"1","address":"0x343324F53CBEEE3Ee6d171f2a20F005964C98047"}