false
true
0

Contract Address Details

0x9A374916ECEA53F84f846c78950150E3BeE0E59a

Contract Name
ManagedTokenFactory
Creator
0xc4c206–b63a0d at 0xd6031e–01377b
Balance
0 PLS ( )
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
25964263
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
ManagedTokenFactory




Optimization enabled
true
Compiler version
v0.8.16+commit.07a7930e




Optimization runs
200
EVM Version
london




Verified at
2026-03-07T12:51:15.965522Z

Constructor Arguments

000000000000000000000000d284be0f68fb78771dc4cd8fc11ba39b56bf4df1

Arg [0] (address) : 0xd284be0f68fb78771dc4cd8fc11ba39b56bf4df1

              

src/contracts/ManagedTokenFactory.sol

// SPDX-License-Identifier: MIT

/*
  A Managed Token, part of the AI Managed Token Suite - AIMM.

  AIMM is a DeFi market maker with community engagement tooling built in, anyone can create a ManagedToken using our factories
  permissionlessly onchain, and benefit from our on and offchain tooling to provide intelligent tax settings, buyback and liquidity
  functions. By deriving your project's ERC20 token from a ManagedToken, users can be sure by checking the verified Solidity code of:
   - Tax is hard coded as max 5/5.
   - Visibility of Maximum Tx Amount is surfaced
   - Check whether Maximum Tx Amount is frozen.
   - Check whether Tax is frozen.

  Using our ManagedTokenTreasury, users can be sure that the portion of Tax's raised to be part of the protocol cannot be rugged by
  project owners, as there are no functions to withdraw either ETH or ERC20 from the Treasury. Protocols have to enter, before Tax is taken
  on a sale, the portion they are taking for their project. This is hard coded to be capped at 50%.

  AIMM takes a revenue share of 1% of the Tax collected by the treasury, for future development of the protocol and maintence costs.

  Website: https://aimm.tech/
  Twitter: https://twitter.com/AIMMtech
  Telegram: https://t.me/AIMMtech
  GitHub: https://github.com/aimm-evm/
*/

pragma solidity >=0.8.16;

import "openzeppelin/token/ERC20/extensions/ERC20Burnable.sol";
import "openzeppelin/proxy/Clones.sol";
import "uniswap/periphery/interfaces/IUniswapV2Router02.sol";
import "uniswap/core/interfaces/IUniswapV2Factory.sol";

import "src/contracts/ManagedToken.sol";
import "src/contracts/ManagedTokenTaxProvider.sol";

import "src/interfaces/IManagedTokenTreasury.sol";
import "src/interfaces/IManagedTokenTreasuryFactory.sol";
import "src/interfaces/IManagedTokenFactory.sol";

contract ManagedTokenFactory is IManagedTokenFactory {
    event ManagedTokenSuiteCreated(
        address indexed token, address indexed taxProvider, address indexed treasury, address executor
    );

    IManagedTokenTreasuryFactory public treasuryFactory;

    bytes32 private constant DEFAULT_ADMIN_ROLE = 0x00;

    constructor(IManagedTokenTreasuryFactory treasuryFactory_) {
        treasuryFactory = treasuryFactory_;
    }

    function createManagedTokenSuite(CreateSuiteParams calldata params)
        public
        payable
        returns (ManagedToken managedToken, IManagedTokenTreasury treasury, IManagedTokenTaxProvider taxProvider)
    {
        managedToken = _newManagedToken(params.token, params.owner);
        treasury = _newTreasury(managedToken, params);
        address pair = IUniswapV2Factory(params.treasury.uniswapRouter.factory()).createPair(
            address(managedToken), params.treasury.uniswapRouter.WETH()
        );
        taxProvider = _newTaxProvider(params, treasury, pair);

        managedToken.setTreasury(treasury);
        managedToken.setTaxProvider(taxProvider);

        emit ManagedTokenSuiteCreated(
            address(managedToken), address(taxProvider), address(treasury), params.treasury.executor
            );
    }

    function _newManagedToken(TokenParams memory tokenParams, address owner)
        internal
        virtual
        returns (ManagedToken managedToken)
    {
        return new ManagedToken(tokenParams.name, tokenParams.symbol, tokenParams.totalSupply, owner);
    }

    function _newTreasury(ManagedToken managedToken, CreateSuiteParams memory params)
        internal
        virtual
        returns (IManagedTokenTreasury treasury)
    {
        treasury = treasuryFactory.createTreasury{value: msg.value}(
            managedToken, params.treasury.uniswapRouter, params.treasury.executor
        );
        treasury.grantRole(treasury.PROTOCOL_OWNER_ROLE(), address(this));
        treasury.grantRole(treasury.AI_EXECUTOR_ROLE(), address(this));
        treasury.setMinTokensToSwap(params.treasury.minimumTokensToSwap);
        if (params.treasury.protocolRevenueAddress != address(0)) {
            treasury.setProtocolRevenueAddress(params.treasury.protocolRevenueAddress);
            treasury.setProtocolRevenueBips(params.treasury.protocolRevenueBips);
        }
        treasury.grantRole(DEFAULT_ADMIN_ROLE, params.owner);
        treasury.grantRole(treasury.PROTOCOL_OWNER_ROLE(), params.owner);

        treasury.revokeRole(treasury.PROTOCOL_OWNER_ROLE(), address(this));
        treasury.revokeRole(treasury.AI_EXECUTOR_ROLE(), address(this));
        treasury.revokeRole(DEFAULT_ADMIN_ROLE, address(this));
    }

    function _newTaxProvider(CreateSuiteParams memory params, IManagedTokenTreasury treasury, address pair)
        internal
        virtual
        returns (IManagedTokenTaxProvider taxProvider)
    {
        taxProvider = new ManagedTokenTaxProvider();
        taxProvider.grantRole(taxProvider.MANAGE_TAX_ROLE(), address(this));
        taxProvider.grantRole(taxProvider.MANAGE_EXEMPTIONS_ROLE(), address(this));
        taxProvider.setTax(params.tax.buyTax, params.tax.sellTax);
        taxProvider.addExemptions(address(treasury));
        taxProvider.addExemptions(params.owner);
        taxProvider.addDex(pair);

        taxProvider.grantRole(DEFAULT_ADMIN_ROLE, params.owner);
        taxProvider.grantRole(taxProvider.MANAGE_TAX_ROLE(), params.owner);
        taxProvider.grantRole(taxProvider.MANAGE_EXEMPTIONS_ROLE(), params.owner);
        taxProvider.grantRole(taxProvider.MANAGE_TAX_ROLE(), params.treasury.executor);

        taxProvider.revokeRole(taxProvider.MANAGE_TAX_ROLE(), address(this));
        taxProvider.revokeRole(taxProvider.MANAGE_EXEMPTIONS_ROLE(), address(this));
        taxProvider.revokeRole(DEFAULT_ADMIN_ROLE, address(this));
    }
}
        

/IUniswapV2Router01.sol

pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
          

/

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.16;

import "openzeppelin/access/IAccessControl.sol";

interface IManagedTokenTaxProvider is IAccessControl {
    function MANAGE_EXEMPTIONS_ROLE() external returns (bytes32);
    function MANAGE_TAX_ROLE() external returns (bytes32);

    function getTax(address from, address to, uint256 amount) external returns (uint256);
    function setTax(uint16 buyBips, uint16 sellBips) external;
    function freezeTax() external;

    function setMaxTxAmount(uint256 amount) external;
    function freezeMaxTxAmount() external;

    function addExemptions(address account) external;
    function removeExemptions(address account) external;

    function addDex(address account) external;
    function removeDex(address account) external;
}
          

/Multicall.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)

pragma solidity ^0.8.0;

import "./Address.sol";

/**
 * @dev Provides a function to batch together multiple calls in a single external call.
 *
 * _Available since v4.1._
 */
abstract contract Multicall {
    /**
     * @dev Receives and executes a batch of function calls on this contract.
     */
    function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            results[i] = Address.functionDelegateCall(address(this), data[i]);
        }
        return results;
    }
}
          

/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
          

/introspection/ERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
          

/Address.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
          

/

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.16;

import "uniswap/periphery/interfaces/IUniswapV2Router02.sol";

import "src/contracts/ManagedToken.sol";

interface IManagedTokenFactory {
    struct CreateSuiteParams {
        TokenParams token;
        TreasuryParams treasury;
        TaxParams tax;
        address owner;
    }

    struct TokenParams {
        string name;
        string symbol;
        uint256 totalSupply;
    }

    struct TreasuryParams {
        IUniswapV2Router02 uniswapRouter;
        address executor;
        uint256 minimumTokensToSwap;
        address protocolRevenueAddress;
        uint16 protocolRevenueBips;
    }

    struct TaxParams {
        uint16 buyTax;
        uint16 sellTax;
    }

    function createManagedTokenSuite(CreateSuiteParams calldata params)
        external
        payable
        returns (ManagedToken managedToken, IManagedTokenTreasury treasury, IManagedTokenTaxProvider taxProvider);
}
          

/

// SPDX-License-Identifier: MIT

/*
  A Managed Token, part of the AI Managed Token Suite - AIMM.

  AIMM is a DeFi market maker with community engagement tooling built in, anyone can create a ManagedToken using our factories
  permissionlessly onchain, and benefit from our on and offchain tooling to provide intelligent tax settings, buyback and liquidity
  functions. By deriving your project's ERC20 token from a ManagedToken, users can be sure by checking the verified Solidity code of:
   - Tax is hard coded as max 5/5.
   - Visibility of Maximum Tx Amount is surfaced
   - Check whether Maximum Tx Amount is frozen.
   - Check whether Tax is frozen.

  Using our ManagedTokenTreasury, users can be sure that the portion of Tax's raised to be part of the protocol cannot be rugged by
  project owners, as there are no functions to withdraw either ETH or ERC20 from the Treasury. Protocols have to enter, before Tax is taken
  on a sale, the portion they are taking for their project. This is hard coded to be capped at 50%.

  AIMM takes a revenue share of 1% of the Tax collected by the treasury, for future development of the protocol and maintence costs.

  Website: https://aimm.tech/
  Twitter: https://twitter.com/AIMMtech
  Telegram: https://t.me/AIMMtech
  GitHub: https://github.com/aimm-evm/
*/

pragma solidity >=0.8.16;

import "openzeppelin/token/ERC20/extensions/ERC20Burnable.sol";
import "openzeppelin/access/AccessControl.sol";
import "openzeppelin/utils/Multicall.sol";

import "src/interfaces/IManagedTokenTaxProvider.sol";

contract ManagedTokenTaxProvider is AccessControl, Multicall, IManagedTokenTaxProvider {
    uint16 public constant TAX_BIPS_MAX = 500;
    uint16 public constant BIPS_DEMONINATOR = 10_000;

    bool public TAX_FROZEN = false;
    bool public MAX_TX_AMOUNT_FROZEN = false;

    bytes32 public constant MANAGE_EXEMPTIONS_ROLE = keccak256("EXEMPTION_MANAGER");
    bytes32 public constant MANAGE_TAX_ROLE = keccak256("TAX_MANAGER");

    mapping(address => bool) private _addressTaxExempt;

    uint16 public taxBuyBips = 0;
    uint16 public taxSellBips = 0;
    mapping(address => bool) private _addressIsDex;
    uint256 public maxTxAmount;
    uint256 public version = 1;

    modifier notTaxFrozen() {
        require(!TAX_FROZEN, "ManagedTokenTaxProvider: Tax has been frozen.");
        _;
    }

    modifier notMaxTxFrozen() {
        require(!MAX_TX_AMOUNT_FROZEN, "ManagedTokenTaxProvider: Max Tx Amount has been frozen.");
        _;
    }

    constructor() {
        _addressTaxExempt[address(this)] = true;
        _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
    }

    function getTax(address from, address to, uint256 amount) public view returns (uint256) {
        require(maxTxAmount == 0 || amount <= maxTxAmount, "ManagedTokenTaxProvider: Max transfer amount exceeded.");

        if (_addressIsDex[to]) {
            if (!_addressTaxExempt[from]) {
                return amount * taxSellBips / BIPS_DEMONINATOR;
            }
        } else if (_addressIsDex[from]) {
            if (!_addressTaxExempt[from]) {
                return amount * taxBuyBips / BIPS_DEMONINATOR;
            }
        }

        return 0;
    }

    function setMaxTxAmount(uint256 amount) public onlyRole(MANAGE_TAX_ROLE) notMaxTxFrozen {
        maxTxAmount = amount;
    }

    function addExemptions(address account) public onlyRole(MANAGE_EXEMPTIONS_ROLE) {
        _addressTaxExempt[account] = true;
    }

    function removeExemptions(address account) public onlyRole(MANAGE_EXEMPTIONS_ROLE) {
        _addressTaxExempt[account] = false;
    }

    function addDex(address account) public onlyRole(MANAGE_EXEMPTIONS_ROLE) {
        _addressIsDex[account] = true;
    }

    function removeDex(address account) public onlyRole(MANAGE_EXEMPTIONS_ROLE) {
        _addressIsDex[account] = false;
    }

    function setTax(uint16 buyBips, uint16 sellBips) public onlyRole(MANAGE_TAX_ROLE) notTaxFrozen {
        require(buyBips <= TAX_BIPS_MAX, "Requested new Buy Tax Bips exceeds maximum");
        require(sellBips <= TAX_BIPS_MAX, "Requested new Sell Tax Bips exceeds maximum");
        taxBuyBips = buyBips;
        taxSellBips = sellBips;
    }

    function freezeTax() public onlyRole(MANAGE_TAX_ROLE) {
        TAX_FROZEN = true;
    }

    function freezeMaxTxAmount() public onlyRole(MANAGE_TAX_ROLE) {
        MAX_TX_AMOUNT_FROZEN = true;
    }
}
          

/math/Math.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}
          

/IAccessControl.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}
          

/AccessControl.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
          

/

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.16;

import "openzeppelin/token/ERC20/extensions/ERC20Burnable.sol";
import "uniswap/periphery/interfaces/IUniswapV2Router02.sol";

import "src/interfaces/IManagedTokenTreasury.sol";

interface IManagedTokenTreasuryFactory {
    function feeAddress() external view returns (address);

    function createTreasury(ERC20Burnable token, IUniswapV2Router02 uniswapV2Router, address executor)
        external
        payable
        returns (IManagedTokenTreasury treasury_);
}
          

/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
          

/Strings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}
          

/IUniswapV2Factory.sol

pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}
          

/ERC20/ERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}
          

/ERC20/extensions/IERC20Metadata.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
          

/Clones.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create(0, 0x09, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create2(0, 0x09, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(add(ptr, 0x38), deployer)
            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
            mstore(add(ptr, 0x14), implementation)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
            mstore(add(ptr, 0x58), salt)
            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
            predicted := keccak256(add(ptr, 0x43), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}
          

/ERC20/extensions/ERC20Burnable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)

pragma solidity ^0.8.0;

import "../ERC20.sol";
import "../../../utils/Context.sol";

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        _spendAllowance(account, _msgSender(), amount);
        _burn(account, amount);
    }
}
          

/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}
          

/

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.16;

import "openzeppelin/access/IAccessControl.sol";

interface IManagedTokenTreasury is IAccessControl {
    function AI_EXECUTOR_ROLE() external returns (bytes32);
    function PROTOCOL_OWNER_ROLE() external returns (bytes32);

    function onTaxSent(uint256 amount, address sender) external;

    function setMinTokensToSwap(uint256 minTokensToSwap) external;
    function setProtocolRevenueAddress(address protocolAddress) external;
    function setProtocolRevenueBips(uint16 bips) external;
    function sell(uint256 tokenAmount, uint256 minAmountOut) external;
    function addLiquidity(uint256 tokenAmount, uint256 ethAmount) external;
    function buyBackAndBurn(uint256 amountEth) external;
    function buyBack(uint256 amountEth) external returns (uint256 amountToken);
    function burn(uint256 amount) external;
}
          

/

// SPDX-License-Identifier: MIT

/*
  A Managed Token, part of the AI Managed Token Suite - AIMM.

  AIMM is a DeFi market maker with community engagement tooling built in, anyone can create a ManagedToken using our factories
  permissionlessly onchain, and benefit from our on and offchain tooling to provide intelligent tax settings, buyback and liquidity
  functions. By deriving your project's ERC20 token from a ManagedToken, users can be sure by checking the verified Solidity code of:
   - Tax is hard coded as max 5/5.
   - Visibility of Maximum Tx Amount is surfaced
   - Check whether Maximum Tx Amount is frozen.
   - Check whether Tax is frozen.

  Using our ManagedTokenTreasury, users can be sure that the portion of Tax's raised to be part of the protocol cannot be rugged by
  project owners, as there are no functions to withdraw either ETH or ERC20 from the Treasury. Protocols have to enter, before Tax is taken
  on a sale, the portion they are taking for their project. This is hard coded to be capped at 50%.

  AIMM takes a revenue share of 1% of the Tax collected by the treasury, for future development of the protocol and maintence costs.

  Website: https://aimm.tech/
  Twitter: https://twitter.com/AIMMtech
  Telegram: https://t.me/AIMMtech
  GitHub: https://github.com/aimm-evm/
*/

pragma solidity >=0.8.16;

import "openzeppelin/token/ERC20/extensions/ERC20Burnable.sol";
import {IManagedTokenTreasury} from "src/interfaces/IManagedTokenTreasury.sol";
import {IManagedTokenTaxProvider} from "src/interfaces/IManagedTokenTaxProvider.sol";

contract ManagedToken is ERC20Burnable {
    IManagedTokenTreasury public treasury;
    IManagedTokenTaxProvider public taxProvider;

    constructor(string memory name_, string memory symbol_, uint256 totalSupply, address mintTo)
        ERC20(name_, symbol_)
    {
        if (totalSupply > 0) {
            _mint(mintTo, totalSupply);
        }
    }

    function setTreasury(IManagedTokenTreasury treasury_) public {
        require(address(treasury) == address(0), "Treasury is already set.");
        treasury = treasury_;
    }

    function setTaxProvider(IManagedTokenTaxProvider taxProvider_) public {
        require(address(taxProvider) == address(0), "Tax Provider is already set.");
        taxProvider = taxProvider_;
    }

    /**
     * This overridden internal function `_transfer` uses the `IManagedTokenTaxProvider` to calculate the tax,
     * then uses the default `_transfer` function to send the tax and original transfer.
     * The `onTaxSent` function is invoked to allow the `IManagedTokenTreasury` to process any sent funds.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual override {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        IManagedTokenTaxProvider _taxProvider = taxProvider;
        if (address(_taxProvider) != address(0)) {
            uint256 tax = _taxProvider.getTax(from, to, amount);
            uint256 amountTransferring = amount - tax;

            if (tax > 0) {
                IManagedTokenTreasury _treasury = treasury;
                super._transfer(from, address(_treasury), tax);
                _treasury.onTaxSent(tax, _msgSender());
            }

            super._transfer(from, to, amountTransferring);
        } else {
            super._transfer(from, to, amount);
        }
    }
}
          

/IUniswapV2Router02.sol

pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}
          

Compiler Settings

{"remappings":[":ds-test/=lib/forge-std/lib/ds-test/src/",":forge-std/=lib/forge-std/src/",":openzeppelin/=lib/openzeppelin-contracts/contracts/",":uniswap/core/=lib/v2-core/contracts/",":uniswap/periphery/=lib/v2-periphery/contracts/",":v2-core/=lib/v2-core/contracts/",":v2-periphery/=lib/v2-periphery/contracts/"],"optimizer":{"runs":200,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"london","compilationTarget":{"src/contracts/ManagedTokenFactory.sol":"ManagedTokenFactory"}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"treasuryFactory_","internalType":"contract IManagedTokenTreasuryFactory"}]},{"type":"event","name":"ManagedTokenSuiteCreated","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"address","name":"taxProvider","internalType":"address","indexed":true},{"type":"address","name":"treasury","internalType":"address","indexed":true},{"type":"address","name":"executor","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"payable","outputs":[{"type":"address","name":"managedToken","internalType":"contract ManagedToken"},{"type":"address","name":"treasury","internalType":"contract IManagedTokenTreasury"},{"type":"address","name":"taxProvider","internalType":"contract IManagedTokenTaxProvider"}],"name":"createManagedTokenSuite","inputs":[{"type":"tuple","name":"params","internalType":"struct IManagedTokenFactory.CreateSuiteParams","components":[{"type":"tuple","name":"token","internalType":"struct IManagedTokenFactory.TokenParams","components":[{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"symbol","internalType":"string"},{"type":"uint256","name":"totalSupply","internalType":"uint256"}]},{"type":"tuple","name":"treasury","internalType":"struct IManagedTokenFactory.TreasuryParams","components":[{"type":"address","name":"uniswapRouter","internalType":"contract IUniswapV2Router02"},{"type":"address","name":"executor","internalType":"address"},{"type":"uint256","name":"minimumTokensToSwap","internalType":"uint256"},{"type":"address","name":"protocolRevenueAddress","internalType":"address"},{"type":"uint16","name":"protocolRevenueBips","internalType":"uint16"}]},{"type":"tuple","name":"tax","internalType":"struct IManagedTokenFactory.TaxParams","components":[{"type":"uint16","name":"buyTax","internalType":"uint16"},{"type":"uint16","name":"sellTax","internalType":"uint16"}]},{"type":"address","name":"owner","internalType":"address"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IManagedTokenTreasuryFactory"}],"name":"treasuryFactory","inputs":[]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50604051613edf380380613edf83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b613e4c806100936000396000f3fe6080604052600436106200002c5760003560e01c806324f9cd321462000031578063bd985e7b1462000077575b600080fd5b62000048620000423660046200135e565b620000b2565b604080516001600160a01b03948516815292841660208401529216918101919091526060015b60405180910390f35b3480156200008457600080fd5b5060005462000099906001600160a01b031681565b6040516001600160a01b0390911681526020016200006e565b60008080620000eb620000c68580620013a4565b620000d19062001560565b620000e5610120870161010088016200159f565b620003b5565b92506200010383620000fd8662001638565b62000409565b915060006200011960408601602087016200159f565b6001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000157573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200017d91906200172d565b6001600160a01b031663c9c65396856200019e6040890160208a016200159f565b6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020291906200172d565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af115801562000250573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200027691906200172d565b90506200028f620002878662001638565b848362000adb565b604051630787a21360e51b81526001600160a01b0385811660048301529193509085169063f0f4426090602401600060405180830381600087803b158015620002d757600080fd5b505af1158015620002ec573d6000803e3d6000fd5b505060405163fe7ba03560e01b81526001600160a01b0385811660048301528716925063fe7ba0359150602401600060405180830381600087803b1580156200033457600080fd5b505af115801562000349573d6000803e3d6000fd5b50506001600160a01b038086169250848116915086167f2cffee806f838b8853ca01334dd72feadd5f57a6f88a88213bb12a022b90a8f06200039260608a0160408b016200159f565b6040516001600160a01b03909116815260200160405180910390a4509193909250565b600082600001518360200151846040015184604051620003d59062001342565b620003e4949392919062001795565b604051809103906000f08015801562000401573d6000803e3d6000fd5b509392505050565b6000805460208381015180519101516040516305c45f7160e11b81526001600160a01b03878116600483015292831660248201529082166044820152911690630b88bee290349060640160206040518083038185885af115801562000472573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906200049991906200172d565b9050806001600160a01b0316632f2ff15d826001600160a01b031663e5cd63b16040518163ffffffff1660e01b81526004016020604051808303816000875af1158015620004eb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005119190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b1580156200055157600080fd5b505af115801562000566573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b0316630f71e1656040518163ffffffff1660e01b81526004016020604051808303816000875af1158015620005ba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005e09190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b1580156200062057600080fd5b505af115801562000635573d6000803e3d6000fd5b5050506020830151604090810151905163110430bb60e01b81526001600160a01b038416925063110430bb91620006729160040190815260200190565b600060405180830381600087803b1580156200068d57600080fd5b505af1158015620006a2573d6000803e3d6000fd5b505050506020820151606001516001600160a01b0316156200078f57602082015160600151604051636588f9d560e11b81526001600160a01b0391821660048201529082169063cb11f3aa90602401600060405180830381600087803b1580156200070c57600080fd5b505af115801562000721573d6000803e3d6000fd5b505050506020820151608001516040516392893aa160e01b815261ffff90911660048201526001600160a01b038216906392893aa190602401600060405180830381600087803b1580156200077557600080fd5b505af11580156200078a573d6000803e3d6000fd5b505050505b6060820151604051632f2ff15d60e01b8152600060048201526001600160a01b03918216602482015290821690632f2ff15d90604401600060405180830381600087803b158015620007e057600080fd5b505af1158015620007f5573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663e5cd63b16040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000849573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200086f9190620017e0565b60608501516040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b158015620008bc57600080fd5b505af1158015620008d1573d6000803e3d6000fd5b50505050806001600160a01b031663d547741f826001600160a01b031663e5cd63b16040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000925573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200094b9190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b1580156200098b57600080fd5b505af1158015620009a0573d6000803e3d6000fd5b50505050806001600160a01b031663d547741f826001600160a01b0316630f71e1656040518163ffffffff1660e01b81526004016020604051808303816000875af1158015620009f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000a1a9190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b15801562000a5a57600080fd5b505af115801562000a6f573d6000803e3d6000fd5b505060405163d547741f60e01b8152600060048201523060248201526001600160a01b038416925063d547741f9150604401600060405180830381600087803b15801562000abc57600080fd5b505af115801562000ad1573d6000803e3d6000fd5b5050505092915050565b600060405162000aeb9062001350565b604051809103906000f08015801562000b08573d6000803e3d6000fd5b509050806001600160a01b0316632f2ff15d826001600160a01b031663682fc8186040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000b5b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b819190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b15801562000bc157600080fd5b505af115801562000bd6573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663662ecf666040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000c2a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c509190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b15801562000c9057600080fd5b505af115801562000ca5573d6000803e3d6000fd5b5050505060408481015180516020909101519151632bb2a73f60e11b815261ffff9182166004820152911660248201526001600160a01b038216906357654e7e90604401600060405180830381600087803b15801562000d0457600080fd5b505af115801562000d19573d6000803e3d6000fd5b505060405163fe7ed03360e01b81526001600160a01b0386811660048301528416925063fe7ed0339150602401600060405180830381600087803b15801562000d6157600080fd5b505af115801562000d76573d6000803e3d6000fd5b50505050606084015160405163fe7ed03360e01b81526001600160a01b0391821660048201529082169063fe7ed03390602401600060405180830381600087803b15801562000dc457600080fd5b505af115801562000dd9573d6000803e3d6000fd5b50506040516329b6d93360e11b81526001600160a01b0385811660048301528416925063536db2669150602401600060405180830381600087803b15801562000e2157600080fd5b505af115801562000e36573d6000803e3d6000fd5b505050506060840151604051632f2ff15d60e01b8152600060048201526001600160a01b03918216602482015290821690632f2ff15d90604401600060405180830381600087803b15801562000e8b57600080fd5b505af115801562000ea0573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663682fc8186040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000ef4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000f1a9190620017e0565b60608701516040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b15801562000f6757600080fd5b505af115801562000f7c573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663662ecf666040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000fd0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ff69190620017e0565b60608701516040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b1580156200104357600080fd5b505af115801562001058573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663682fc8186040518163ffffffff1660e01b81526004016020604051808303816000875af1158015620010ac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620010d29190620017e0565b60208088015101516040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b1580156200112257600080fd5b505af115801562001137573d6000803e3d6000fd5b50505050806001600160a01b031663d547741f826001600160a01b031663682fc8186040518163ffffffff1660e01b81526004016020604051808303816000875af11580156200118b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620011b19190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b158015620011f157600080fd5b505af115801562001206573d6000803e3d6000fd5b50505050806001600160a01b031663d547741f826001600160a01b031663662ecf666040518163ffffffff1660e01b81526004016020604051808303816000875af11580156200125a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620012809190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b158015620012c057600080fd5b505af1158015620012d5573d6000803e3d6000fd5b505060405163d547741f60e01b8152600060048201523060248201526001600160a01b038416925063d547741f9150604401600060405180830381600087803b1580156200132257600080fd5b505af115801562001337573d6000803e3d6000fd5b505050509392505050565b6111ae80620017fb83390190565b61146e80620029a983390190565b6000602082840312156200137157600080fd5b813567ffffffffffffffff8111156200138957600080fd5b820161012081850312156200139d57600080fd5b9392505050565b60008235605e19833603018112620013bb57600080fd5b9190910192915050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715620014015762001401620013c5565b60405290565b60405160a0810167ffffffffffffffff81118282101715620014015762001401620013c5565b600082601f8301126200143f57600080fd5b813567ffffffffffffffff808211156200145d576200145d620013c5565b604051601f8301601f19908116603f01168101908282118183101715620014885762001488620013c5565b81604052838152866020858801011115620014a257600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060608284031215620014d557600080fd5b6040516060810167ffffffffffffffff8282108183111715620014fc57620014fc620013c5565b8160405282935084359150808211156200151557600080fd5b62001523868387016200142d565b835260208501359150808211156200153a57600080fd5b5062001549858286016200142d565b602083015250604083013560408201525092915050565b60006200156e3683620014c2565b92915050565b6001600160a01b03811681146200158a57600080fd5b50565b80356200159a8162001574565b919050565b600060208284031215620015b257600080fd5b81356200139d8162001574565b803561ffff811681146200159a57600080fd5b600060408284031215620015e557600080fd5b6040516040810181811067ffffffffffffffff821117156200160b576200160b620013c5565b6040529050806200161c83620015bf565b81526200162c60208401620015bf565b60208201525092915050565b60008136036101208112156200164d57600080fd5b62001657620013db565b833567ffffffffffffffff8111156200166f57600080fd5b6200167d36828701620014c2565b82525060a0601f19830112156200169357600080fd5b6200169d62001407565b91506020840135620016af8162001574565b82526040840135620016c18162001574565b6020830152606084013560408301526080840135620016e08162001574565b6060830152620016f360a08501620015bf565b60808301528160208201526200170d3660c08601620015d2565b60408201526200172161010085016200158d565b60608201529392505050565b6000602082840312156200174057600080fd5b81516200139d8162001574565b6000815180845260005b81811015620017755760208185018101518683018201520162001757565b506000602082860101526020601f19601f83011685010191505092915050565b608081526000620017aa60808301876200174d565b8281036020840152620017be81876200174d565b604084019590955250506001600160a01b039190911660609091015292915050565b600060208284031215620017f357600080fd5b505191905056fe60806040523480156200001157600080fd5b50604051620011ae380380620011ae833981016040819052620000349162000204565b8383600362000044838262000327565b50600462000053828262000327565b5050821590506200006a576200006a818362000074565b505050506200041b565b6001600160a01b038216620000cf5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b8060026000828254620000e39190620003f3565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200016757600080fd5b81516001600160401b03808211156200018457620001846200013f565b604051601f8301601f19908116603f01168101908282118183101715620001af57620001af6200013f565b81604052838152602092508683858801011115620001cc57600080fd5b600091505b83821015620001f05785820183015181830184015290820190620001d1565b600093810190920192909252949350505050565b600080600080608085870312156200021b57600080fd5b84516001600160401b03808211156200023357600080fd5b620002418883890162000155565b955060208701519150808211156200025857600080fd5b50620002678782880162000155565b60408701516060880151919550935090506001600160a01b03811681146200028e57600080fd5b939692955090935050565b600181811c90821680620002ae57607f821691505b602082108103620002cf57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200013a57600081815260208120601f850160051c81016020861015620002fe5750805b601f850160051c820191505b818110156200031f578281556001016200030a565b505050505050565b81516001600160401b038111156200034357620003436200013f565b6200035b8162000354845462000299565b84620002d5565b602080601f8311600181146200039357600084156200037a5750858301515b600019600386901b1c1916600185901b1785556200031f565b600085815260208120601f198616915b82811015620003c457888601518255948401946001909101908401620003a3565b5085821015620003e35787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200041557634e487b7160e01b600052601160045260246000fd5b92915050565b610d83806200042b6000396000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c806370a08231116100a2578063a457c2d711610071578063a457c2d71461022f578063a9059cbb14610242578063dd62ed3e14610255578063f0f4426014610268578063fe7ba0351461027b57600080fd5b806370a08231146101d857806379cc6790146102015780638921e9711461021457806395d89b411461022757600080fd5b8063313ce567116100de578063313ce56714610176578063395093511461018557806342966c681461019857806361d027b3146101ad57600080fd5b806306fdde0314610110578063095ea7b31461012e57806318160ddd1461015157806323b872dd14610163575b600080fd5b61011861028e565b6040516101259190610af0565b60405180910390f35b61014161013c366004610b53565b610320565b6040519015158152602001610125565b6002545b604051908152602001610125565b610141610171366004610b7f565b61033a565b60405160128152602001610125565b610141610193366004610b53565b61035e565b6101ab6101a6366004610bc0565b610380565b005b6005546101c0906001600160a01b031681565b6040516001600160a01b039091168152602001610125565b6101556101e6366004610bd9565b6001600160a01b031660009081526020819052604090205490565b6101ab61020f366004610b53565b61038d565b6006546101c0906001600160a01b031681565b6101186103a6565b61014161023d366004610b53565b6103b5565b610141610250366004610b53565b610435565b610155610263366004610bfd565b610443565b6101ab610276366004610bd9565b61046e565b6101ab610289366004610bd9565b6104e9565b60606003805461029d90610c36565b80601f01602080910402602001604051908101604052809291908181526020018280546102c990610c36565b80156103165780601f106102eb57610100808354040283529160200191610316565b820191906000526020600020905b8154815290600101906020018083116102f957829003601f168201915b5050505050905090565b60003361032e818585610564565b60019150505b92915050565b600033610348858285610689565b610353858585610703565b506001949350505050565b60003361032e8185856103718383610443565b61037b9190610c86565b610564565b61038a338261089c565b50565b610398823383610689565b6103a2828261089c565b5050565b60606004805461029d90610c36565b600033816103c38286610443565b9050838110156104285760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b6103538286868403610564565b60003361032e818585610703565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6005546001600160a01b0316156104c75760405162461bcd60e51b815260206004820152601860248201527f547265617375727920697320616c7265616479207365742e0000000000000000604482015260640161041f565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b0316156105425760405162461bcd60e51b815260206004820152601c60248201527f5461782050726f766964657220697320616c7265616479207365742e00000000604482015260640161041f565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166105c65760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161041f565b6001600160a01b0382166106275760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161041f565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b60006106958484610443565b905060001981146106fd57818110156106f05760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161041f565b6106fd8484848403610564565b50505050565b6001600160a01b0383166107295760405162461bcd60e51b815260040161041f90610c99565b6001600160a01b03821661074f5760405162461bcd60e51b815260040161041f90610cde565b6006546001600160a01b03168015610891576040516335eb486b60e21b81526001600160a01b0385811660048301528481166024830152604482018490526000919083169063d7ad21ac906064016020604051808303816000875af11580156107bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e09190610d21565b905060006107ee8285610d3a565b9050811561087f576005546001600160a01b031661080d8782856109c6565b6001600160a01b038116636e13539d84336040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b15801561086557600080fd5b505af1158015610879573d6000803e3d6000fd5b50505050505b61088a8686836109c6565b50506106fd565b6106fd8484846109c6565b6001600160a01b0382166108fc5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161041f565b6001600160a01b038216600090815260208190526040902054818110156109705760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161041f565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910161067c565b6001600160a01b0383166109ec5760405162461bcd60e51b815260040161041f90610c99565b6001600160a01b038216610a125760405162461bcd60e51b815260040161041f90610cde565b6001600160a01b03831660009081526020819052604090205481811015610a8a5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161041f565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36106fd565b600060208083528351808285015260005b81811015610b1d57858101830151858201604001528201610b01565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461038a57600080fd5b60008060408385031215610b6657600080fd5b8235610b7181610b3e565b946020939093013593505050565b600080600060608486031215610b9457600080fd5b8335610b9f81610b3e565b92506020840135610baf81610b3e565b929592945050506040919091013590565b600060208284031215610bd257600080fd5b5035919050565b600060208284031215610beb57600080fd5b8135610bf681610b3e565b9392505050565b60008060408385031215610c1057600080fd5b8235610c1b81610b3e565b91506020830135610c2b81610b3e565b809150509250929050565b600181811c90821680610c4a57607f821691505b602082108103610c6a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561033457610334610c70565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b600060208284031215610d3357600080fd5b5051919050565b8181038181111561033457610334610c7056fea2646970667358221220a57b3a70ee0e097ef0c4b97da9e2f0f74269ee7c2a08b26a8374fe83fccf56a564736f6c6343000810003360806040526001805461ffff191681556003805463ffffffff1916905560065534801561002b57600080fd5b50306000908152600260205260408120805460ff19166001179055610056906100513390565b61005b565b6100fa565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166100f6576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556100b53390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b611365806101096000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80636589f6de116100f9578063ac9650d811610097578063d7ad21ac11610071578063d7ad21ac1461036e578063ec28438a14610381578063fd66c2e414610394578063fe7ed033146103a157600080fd5b8063ac9650d814610333578063beea724614610353578063d547741f1461035b57600080fd5b80637effd482116100d35780637effd482146102fb5780638c0b5e221461030f57806391d1485414610318578063a217fddf1461032b57600080fd5b80636589f6de146102c8578063662ecf66146102d1578063682fc818146102e657600080fd5b806340cbcbe311610166578063536db26611610140578063536db2661461028b57806354fd4d501461029e57806357654e7e146102a75780635e7c2d1c146102ba57600080fd5b806340cbcbe314610254578063413ebc2a1461026757806348f59db71461028357600080fd5b806301ffc9a7146101ae578063124f1ead146101d6578063248a9ca3146101eb5780632f2ff15d1461021c57806336568abe1461022f5780633b55302e14610242575b600080fd5b6101c16101bc366004610ecb565b6103b4565b60405190151581526020015b60405180910390f35b6101e96101e4366004610f11565b6103eb565b005b61020e6101f9366004610f2c565b60009081526020819052604090206001015490565b6040519081526020016101cd565b6101e961022a366004610f45565b610425565b6101e961023d366004610f45565b61044f565b6001546101c190610100900460ff1681565b6101e9610262366004610f11565b6104d2565b61027061271081565b60405161ffff90911681526020016101cd565b6101e961050c565b6101e9610299366004610f11565b610533565b61020e60065481565b6101e96102b5366004610f83565b610570565b6003546102709061ffff1681565b6102706101f481565b61020e60008051602061131083398151915281565b61020e6000805160206112c983398151915281565b6003546102709062010000900461ffff1681565b61020e60055481565b6101c1610326366004610f45565b6106ed565b61020e600081565b610346610341366004610fad565b610716565b6040516101cd9190611072565b6101e961080b565b6101e9610369366004610f45565b610835565b61020e61037c3660046110d4565b61085a565b6101e961038f366004610f2c565b6109ad565b6001546101c19060ff1681565b6101e96103af366004610f11565b610a49565b60006001600160e01b03198216637965db0b60e01b14806103e557506301ffc9a760e01b6001600160e01b03198316145b92915050565b60008051602061131083398151915261040381610a86565b506001600160a01b03166000908152600460205260409020805460ff19169055565b60008281526020819052604090206001015461044081610a86565b61044a8383610a93565b505050565b6001600160a01b03811633146104c45760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6104ce8282610b17565b5050565b6000805160206113108339815191526104ea81610a86565b506001600160a01b03166000908152600260205260409020805460ff19169055565b6000805160206112c983398151915261052481610a86565b506001805460ff191681179055565b60008051602061131083398151915261054b81610a86565b506001600160a01b03166000908152600460205260409020805460ff19166001179055565b6000805160206112c983398151915261058881610a86565b60015460ff16156105f15760405162461bcd60e51b815260206004820152602d60248201527f4d616e61676564546f6b656e54617850726f76696465723a205461782068617360448201526c103132b2b710333937bd32b71760991b60648201526084016104bb565b6101f461ffff8416111561065a5760405162461bcd60e51b815260206004820152602a60248201527f526571756573746564206e6577204275792054617820426970732065786365656044820152696473206d6178696d756d60b01b60648201526084016104bb565b6101f461ffff831611156106c45760405162461bcd60e51b815260206004820152602b60248201527f526571756573746564206e65772053656c6c205461782042697073206578636560448201526a656473206d6178696d756d60a81b60648201526084016104bb565b506003805461ffff928316620100000263ffffffff199091169290931691909117919091179055565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60608167ffffffffffffffff81111561073157610731611110565b60405190808252806020026020018201604052801561076457816020015b606081526020019060019003908161074f5790505b50905060005b82811015610804576107d43085858481811061078857610788611126565b905060200281019061079a919061113c565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610b7c92505050565b8282815181106107e6576107e6611126565b602002602001018190525080806107fc906111a0565b91505061076a565b5092915050565b6000805160206112c983398151915261082381610a86565b506001805461ff001916610100179055565b60008281526020819052604090206001015461085081610a86565b61044a8383610b17565b60006005546000148061086f57506005548211155b6108da5760405162461bcd60e51b815260206004820152603660248201527f4d616e61676564546f6b656e54617850726f76696465723a204d6178207472616044820152753739b332b91030b6b7bab73a1032bc31b2b2b232b21760511b60648201526084016104bb565b6001600160a01b03831660009081526004602052604090205460ff161561094c576001600160a01b03841660009081526002602052604090205460ff1661094757600354612710906109369062010000900461ffff16846111b9565b61094091906111d8565b90506109a6565b6109a2565b6001600160a01b03841660009081526004602052604090205460ff16156109a2576001600160a01b03841660009081526002602052604090205460ff166109a257600354612710906109369061ffff16846111b9565b5060005b9392505050565b6000805160206112c98339815191526109c581610a86565b600154610100900460ff1615610a435760405162461bcd60e51b815260206004820152603760248201527f4d616e61676564546f6b656e54617850726f76696465723a204d61782054782060448201527f416d6f756e7420686173206265656e2066726f7a656e2e00000000000000000060648201526084016104bb565b50600555565b600080516020611310833981519152610a6181610a86565b506001600160a01b03166000908152600260205260409020805460ff19166001179055565b610a908133610ba1565b50565b610a9d82826106ed565b6104ce576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610ad33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610b2182826106ed565b156104ce576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606109a683836040518060600160405280602781526020016112e960279139610bfa565b610bab82826106ed565b6104ce57610bb881610c72565b610bc3836020610c84565b604051602001610bd49291906111fa565b60408051601f198184030181529082905262461bcd60e51b82526104bb9160040161126f565b6060600080856001600160a01b031685604051610c179190611282565b600060405180830381855af49150503d8060008114610c52576040519150601f19603f3d011682016040523d82523d6000602084013e610c57565b606091505b5091509150610c6886838387610e20565b9695505050505050565b60606103e56001600160a01b03831660145b60606000610c938360026111b9565b610c9e90600261129e565b67ffffffffffffffff811115610cb657610cb6611110565b6040519080825280601f01601f191660200182016040528015610ce0576020820181803683370190505b509050600360fc1b81600081518110610cfb57610cfb611126565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110610d2a57610d2a611126565b60200101906001600160f81b031916908160001a9053506000610d4e8460026111b9565b610d5990600161129e565b90505b6001811115610dd1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110610d8d57610d8d611126565b1a60f81b828281518110610da357610da3611126565b60200101906001600160f81b031916908160001a90535060049490941c93610dca816112b1565b9050610d5c565b5083156109a65760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016104bb565b60608315610e8f578251600003610e88576001600160a01b0385163b610e885760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104bb565b5081610e99565b610e998383610ea1565b949350505050565b815115610eb15781518083602001fd5b8060405162461bcd60e51b81526004016104bb919061126f565b600060208284031215610edd57600080fd5b81356001600160e01b0319811681146109a657600080fd5b80356001600160a01b0381168114610f0c57600080fd5b919050565b600060208284031215610f2357600080fd5b6109a682610ef5565b600060208284031215610f3e57600080fd5b5035919050565b60008060408385031215610f5857600080fd5b82359150610f6860208401610ef5565b90509250929050565b803561ffff81168114610f0c57600080fd5b60008060408385031215610f9657600080fd5b610f9f83610f71565b9150610f6860208401610f71565b60008060208385031215610fc057600080fd5b823567ffffffffffffffff80821115610fd857600080fd5b818501915085601f830112610fec57600080fd5b813581811115610ffb57600080fd5b8660208260051b850101111561101057600080fd5b60209290920196919550909350505050565b60005b8381101561103d578181015183820152602001611025565b50506000910152565b6000815180845261105e816020860160208601611022565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156110c757603f198886030184526110b5858351611046565b94509285019290850190600101611099565b5092979650505050505050565b6000806000606084860312156110e957600080fd5b6110f284610ef5565b925061110060208501610ef5565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261115357600080fd5b83018035915067ffffffffffffffff82111561116e57600080fd5b60200191503681900382131561118357600080fd5b9250929050565b634e487b7160e01b600052601160045260246000fd5b6000600182016111b2576111b261118a565b5060010190565b60008160001904831182151516156111d3576111d361118a565b500290565b6000826111f557634e487b7160e01b600052601260045260246000fd5b500490565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611232816017850160208801611022565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611263816028840160208801611022565b01602801949350505050565b6020815260006109a66020830184611046565b60008251611294818460208701611022565b9190910192915050565b808201808211156103e5576103e561118a565b6000816112c0576112c061118a565b50600019019056fe860ad3e446dfd5e02b4764f88e672dd1008a1bf89b2edc1bdfa963c7c81230e5416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564139a5952d24700661f8938da058f7dc812f6ce44f991182c24c1c1d487dd1ddba2646970667358221220592a39c04d63190df3e3a2b5989cc9f96b5a04e55fb2f940c9440adc72d6122b64736f6c63430008100033a26469706673582212202f61132d9e3eaa7ffb4388d77b2b085d2d0a62c1b300265004fa9d370735594464736f6c63430008100033000000000000000000000000d284be0f68fb78771dc4cd8fc11ba39b56bf4df1

Deployed ByteCode

0x6080604052600436106200002c5760003560e01c806324f9cd321462000031578063bd985e7b1462000077575b600080fd5b62000048620000423660046200135e565b620000b2565b604080516001600160a01b03948516815292841660208401529216918101919091526060015b60405180910390f35b3480156200008457600080fd5b5060005462000099906001600160a01b031681565b6040516001600160a01b0390911681526020016200006e565b60008080620000eb620000c68580620013a4565b620000d19062001560565b620000e5610120870161010088016200159f565b620003b5565b92506200010383620000fd8662001638565b62000409565b915060006200011960408601602087016200159f565b6001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000157573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200017d91906200172d565b6001600160a01b031663c9c65396856200019e6040890160208a016200159f565b6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020291906200172d565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af115801562000250573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200027691906200172d565b90506200028f620002878662001638565b848362000adb565b604051630787a21360e51b81526001600160a01b0385811660048301529193509085169063f0f4426090602401600060405180830381600087803b158015620002d757600080fd5b505af1158015620002ec573d6000803e3d6000fd5b505060405163fe7ba03560e01b81526001600160a01b0385811660048301528716925063fe7ba0359150602401600060405180830381600087803b1580156200033457600080fd5b505af115801562000349573d6000803e3d6000fd5b50506001600160a01b038086169250848116915086167f2cffee806f838b8853ca01334dd72feadd5f57a6f88a88213bb12a022b90a8f06200039260608a0160408b016200159f565b6040516001600160a01b03909116815260200160405180910390a4509193909250565b600082600001518360200151846040015184604051620003d59062001342565b620003e4949392919062001795565b604051809103906000f08015801562000401573d6000803e3d6000fd5b509392505050565b6000805460208381015180519101516040516305c45f7160e11b81526001600160a01b03878116600483015292831660248201529082166044820152911690630b88bee290349060640160206040518083038185885af115801562000472573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906200049991906200172d565b9050806001600160a01b0316632f2ff15d826001600160a01b031663e5cd63b16040518163ffffffff1660e01b81526004016020604051808303816000875af1158015620004eb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005119190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b1580156200055157600080fd5b505af115801562000566573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b0316630f71e1656040518163ffffffff1660e01b81526004016020604051808303816000875af1158015620005ba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005e09190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b1580156200062057600080fd5b505af115801562000635573d6000803e3d6000fd5b5050506020830151604090810151905163110430bb60e01b81526001600160a01b038416925063110430bb91620006729160040190815260200190565b600060405180830381600087803b1580156200068d57600080fd5b505af1158015620006a2573d6000803e3d6000fd5b505050506020820151606001516001600160a01b0316156200078f57602082015160600151604051636588f9d560e11b81526001600160a01b0391821660048201529082169063cb11f3aa90602401600060405180830381600087803b1580156200070c57600080fd5b505af115801562000721573d6000803e3d6000fd5b505050506020820151608001516040516392893aa160e01b815261ffff90911660048201526001600160a01b038216906392893aa190602401600060405180830381600087803b1580156200077557600080fd5b505af11580156200078a573d6000803e3d6000fd5b505050505b6060820151604051632f2ff15d60e01b8152600060048201526001600160a01b03918216602482015290821690632f2ff15d90604401600060405180830381600087803b158015620007e057600080fd5b505af1158015620007f5573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663e5cd63b16040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000849573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200086f9190620017e0565b60608501516040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b158015620008bc57600080fd5b505af1158015620008d1573d6000803e3d6000fd5b50505050806001600160a01b031663d547741f826001600160a01b031663e5cd63b16040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000925573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200094b9190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b1580156200098b57600080fd5b505af1158015620009a0573d6000803e3d6000fd5b50505050806001600160a01b031663d547741f826001600160a01b0316630f71e1656040518163ffffffff1660e01b81526004016020604051808303816000875af1158015620009f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000a1a9190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b15801562000a5a57600080fd5b505af115801562000a6f573d6000803e3d6000fd5b505060405163d547741f60e01b8152600060048201523060248201526001600160a01b038416925063d547741f9150604401600060405180830381600087803b15801562000abc57600080fd5b505af115801562000ad1573d6000803e3d6000fd5b5050505092915050565b600060405162000aeb9062001350565b604051809103906000f08015801562000b08573d6000803e3d6000fd5b509050806001600160a01b0316632f2ff15d826001600160a01b031663682fc8186040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000b5b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b819190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b15801562000bc157600080fd5b505af115801562000bd6573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663662ecf666040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000c2a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c509190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b15801562000c9057600080fd5b505af115801562000ca5573d6000803e3d6000fd5b5050505060408481015180516020909101519151632bb2a73f60e11b815261ffff9182166004820152911660248201526001600160a01b038216906357654e7e90604401600060405180830381600087803b15801562000d0457600080fd5b505af115801562000d19573d6000803e3d6000fd5b505060405163fe7ed03360e01b81526001600160a01b0386811660048301528416925063fe7ed0339150602401600060405180830381600087803b15801562000d6157600080fd5b505af115801562000d76573d6000803e3d6000fd5b50505050606084015160405163fe7ed03360e01b81526001600160a01b0391821660048201529082169063fe7ed03390602401600060405180830381600087803b15801562000dc457600080fd5b505af115801562000dd9573d6000803e3d6000fd5b50506040516329b6d93360e11b81526001600160a01b0385811660048301528416925063536db2669150602401600060405180830381600087803b15801562000e2157600080fd5b505af115801562000e36573d6000803e3d6000fd5b505050506060840151604051632f2ff15d60e01b8152600060048201526001600160a01b03918216602482015290821690632f2ff15d90604401600060405180830381600087803b15801562000e8b57600080fd5b505af115801562000ea0573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663682fc8186040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000ef4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000f1a9190620017e0565b60608701516040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b15801562000f6757600080fd5b505af115801562000f7c573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663662ecf666040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000fd0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ff69190620017e0565b60608701516040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b1580156200104357600080fd5b505af115801562001058573d6000803e3d6000fd5b50505050806001600160a01b0316632f2ff15d826001600160a01b031663682fc8186040518163ffffffff1660e01b81526004016020604051808303816000875af1158015620010ac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620010d29190620017e0565b60208088015101516040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b1580156200112257600080fd5b505af115801562001137573d6000803e3d6000fd5b50505050806001600160a01b031663d547741f826001600160a01b031663682fc8186040518163ffffffff1660e01b81526004016020604051808303816000875af11580156200118b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620011b19190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b158015620011f157600080fd5b505af115801562001206573d6000803e3d6000fd5b50505050806001600160a01b031663d547741f826001600160a01b031663662ecf666040518163ffffffff1660e01b81526004016020604051808303816000875af11580156200125a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620012809190620017e0565b6040516001600160e01b031960e084901b1681526004810191909152306024820152604401600060405180830381600087803b158015620012c057600080fd5b505af1158015620012d5573d6000803e3d6000fd5b505060405163d547741f60e01b8152600060048201523060248201526001600160a01b038416925063d547741f9150604401600060405180830381600087803b1580156200132257600080fd5b505af115801562001337573d6000803e3d6000fd5b505050509392505050565b6111ae80620017fb83390190565b61146e80620029a983390190565b6000602082840312156200137157600080fd5b813567ffffffffffffffff8111156200138957600080fd5b820161012081850312156200139d57600080fd5b9392505050565b60008235605e19833603018112620013bb57600080fd5b9190910192915050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715620014015762001401620013c5565b60405290565b60405160a0810167ffffffffffffffff81118282101715620014015762001401620013c5565b600082601f8301126200143f57600080fd5b813567ffffffffffffffff808211156200145d576200145d620013c5565b604051601f8301601f19908116603f01168101908282118183101715620014885762001488620013c5565b81604052838152866020858801011115620014a257600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060608284031215620014d557600080fd5b6040516060810167ffffffffffffffff8282108183111715620014fc57620014fc620013c5565b8160405282935084359150808211156200151557600080fd5b62001523868387016200142d565b835260208501359150808211156200153a57600080fd5b5062001549858286016200142d565b602083015250604083013560408201525092915050565b60006200156e3683620014c2565b92915050565b6001600160a01b03811681146200158a57600080fd5b50565b80356200159a8162001574565b919050565b600060208284031215620015b257600080fd5b81356200139d8162001574565b803561ffff811681146200159a57600080fd5b600060408284031215620015e557600080fd5b6040516040810181811067ffffffffffffffff821117156200160b576200160b620013c5565b6040529050806200161c83620015bf565b81526200162c60208401620015bf565b60208201525092915050565b60008136036101208112156200164d57600080fd5b62001657620013db565b833567ffffffffffffffff8111156200166f57600080fd5b6200167d36828701620014c2565b82525060a0601f19830112156200169357600080fd5b6200169d62001407565b91506020840135620016af8162001574565b82526040840135620016c18162001574565b6020830152606084013560408301526080840135620016e08162001574565b6060830152620016f360a08501620015bf565b60808301528160208201526200170d3660c08601620015d2565b60408201526200172161010085016200158d565b60608201529392505050565b6000602082840312156200174057600080fd5b81516200139d8162001574565b6000815180845260005b81811015620017755760208185018101518683018201520162001757565b506000602082860101526020601f19601f83011685010191505092915050565b608081526000620017aa60808301876200174d565b8281036020840152620017be81876200174d565b604084019590955250506001600160a01b039190911660609091015292915050565b600060208284031215620017f357600080fd5b505191905056fe60806040523480156200001157600080fd5b50604051620011ae380380620011ae833981016040819052620000349162000204565b8383600362000044838262000327565b50600462000053828262000327565b5050821590506200006a576200006a818362000074565b505050506200041b565b6001600160a01b038216620000cf5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b8060026000828254620000e39190620003f3565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200016757600080fd5b81516001600160401b03808211156200018457620001846200013f565b604051601f8301601f19908116603f01168101908282118183101715620001af57620001af6200013f565b81604052838152602092508683858801011115620001cc57600080fd5b600091505b83821015620001f05785820183015181830184015290820190620001d1565b600093810190920192909252949350505050565b600080600080608085870312156200021b57600080fd5b84516001600160401b03808211156200023357600080fd5b620002418883890162000155565b955060208701519150808211156200025857600080fd5b50620002678782880162000155565b60408701516060880151919550935090506001600160a01b03811681146200028e57600080fd5b939692955090935050565b600181811c90821680620002ae57607f821691505b602082108103620002cf57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200013a57600081815260208120601f850160051c81016020861015620002fe5750805b601f850160051c820191505b818110156200031f578281556001016200030a565b505050505050565b81516001600160401b038111156200034357620003436200013f565b6200035b8162000354845462000299565b84620002d5565b602080601f8311600181146200039357600084156200037a5750858301515b600019600386901b1c1916600185901b1785556200031f565b600085815260208120601f198616915b82811015620003c457888601518255948401946001909101908401620003a3565b5085821015620003e35787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200041557634e487b7160e01b600052601160045260246000fd5b92915050565b610d83806200042b6000396000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c806370a08231116100a2578063a457c2d711610071578063a457c2d71461022f578063a9059cbb14610242578063dd62ed3e14610255578063f0f4426014610268578063fe7ba0351461027b57600080fd5b806370a08231146101d857806379cc6790146102015780638921e9711461021457806395d89b411461022757600080fd5b8063313ce567116100de578063313ce56714610176578063395093511461018557806342966c681461019857806361d027b3146101ad57600080fd5b806306fdde0314610110578063095ea7b31461012e57806318160ddd1461015157806323b872dd14610163575b600080fd5b61011861028e565b6040516101259190610af0565b60405180910390f35b61014161013c366004610b53565b610320565b6040519015158152602001610125565b6002545b604051908152602001610125565b610141610171366004610b7f565b61033a565b60405160128152602001610125565b610141610193366004610b53565b61035e565b6101ab6101a6366004610bc0565b610380565b005b6005546101c0906001600160a01b031681565b6040516001600160a01b039091168152602001610125565b6101556101e6366004610bd9565b6001600160a01b031660009081526020819052604090205490565b6101ab61020f366004610b53565b61038d565b6006546101c0906001600160a01b031681565b6101186103a6565b61014161023d366004610b53565b6103b5565b610141610250366004610b53565b610435565b610155610263366004610bfd565b610443565b6101ab610276366004610bd9565b61046e565b6101ab610289366004610bd9565b6104e9565b60606003805461029d90610c36565b80601f01602080910402602001604051908101604052809291908181526020018280546102c990610c36565b80156103165780601f106102eb57610100808354040283529160200191610316565b820191906000526020600020905b8154815290600101906020018083116102f957829003601f168201915b5050505050905090565b60003361032e818585610564565b60019150505b92915050565b600033610348858285610689565b610353858585610703565b506001949350505050565b60003361032e8185856103718383610443565b61037b9190610c86565b610564565b61038a338261089c565b50565b610398823383610689565b6103a2828261089c565b5050565b60606004805461029d90610c36565b600033816103c38286610443565b9050838110156104285760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b6103538286868403610564565b60003361032e818585610703565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6005546001600160a01b0316156104c75760405162461bcd60e51b815260206004820152601860248201527f547265617375727920697320616c7265616479207365742e0000000000000000604482015260640161041f565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b0316156105425760405162461bcd60e51b815260206004820152601c60248201527f5461782050726f766964657220697320616c7265616479207365742e00000000604482015260640161041f565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166105c65760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161041f565b6001600160a01b0382166106275760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161041f565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b60006106958484610443565b905060001981146106fd57818110156106f05760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161041f565b6106fd8484848403610564565b50505050565b6001600160a01b0383166107295760405162461bcd60e51b815260040161041f90610c99565b6001600160a01b03821661074f5760405162461bcd60e51b815260040161041f90610cde565b6006546001600160a01b03168015610891576040516335eb486b60e21b81526001600160a01b0385811660048301528481166024830152604482018490526000919083169063d7ad21ac906064016020604051808303816000875af11580156107bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e09190610d21565b905060006107ee8285610d3a565b9050811561087f576005546001600160a01b031661080d8782856109c6565b6001600160a01b038116636e13539d84336040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b15801561086557600080fd5b505af1158015610879573d6000803e3d6000fd5b50505050505b61088a8686836109c6565b50506106fd565b6106fd8484846109c6565b6001600160a01b0382166108fc5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161041f565b6001600160a01b038216600090815260208190526040902054818110156109705760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161041f565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910161067c565b6001600160a01b0383166109ec5760405162461bcd60e51b815260040161041f90610c99565b6001600160a01b038216610a125760405162461bcd60e51b815260040161041f90610cde565b6001600160a01b03831660009081526020819052604090205481811015610a8a5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161041f565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36106fd565b600060208083528351808285015260005b81811015610b1d57858101830151858201604001528201610b01565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461038a57600080fd5b60008060408385031215610b6657600080fd5b8235610b7181610b3e565b946020939093013593505050565b600080600060608486031215610b9457600080fd5b8335610b9f81610b3e565b92506020840135610baf81610b3e565b929592945050506040919091013590565b600060208284031215610bd257600080fd5b5035919050565b600060208284031215610beb57600080fd5b8135610bf681610b3e565b9392505050565b60008060408385031215610c1057600080fd5b8235610c1b81610b3e565b91506020830135610c2b81610b3e565b809150509250929050565b600181811c90821680610c4a57607f821691505b602082108103610c6a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561033457610334610c70565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b600060208284031215610d3357600080fd5b5051919050565b8181038181111561033457610334610c7056fea2646970667358221220a57b3a70ee0e097ef0c4b97da9e2f0f74269ee7c2a08b26a8374fe83fccf56a564736f6c6343000810003360806040526001805461ffff191681556003805463ffffffff1916905560065534801561002b57600080fd5b50306000908152600260205260408120805460ff19166001179055610056906100513390565b61005b565b6100fa565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166100f6576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556100b53390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b611365806101096000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80636589f6de116100f9578063ac9650d811610097578063d7ad21ac11610071578063d7ad21ac1461036e578063ec28438a14610381578063fd66c2e414610394578063fe7ed033146103a157600080fd5b8063ac9650d814610333578063beea724614610353578063d547741f1461035b57600080fd5b80637effd482116100d35780637effd482146102fb5780638c0b5e221461030f57806391d1485414610318578063a217fddf1461032b57600080fd5b80636589f6de146102c8578063662ecf66146102d1578063682fc818146102e657600080fd5b806340cbcbe311610166578063536db26611610140578063536db2661461028b57806354fd4d501461029e57806357654e7e146102a75780635e7c2d1c146102ba57600080fd5b806340cbcbe314610254578063413ebc2a1461026757806348f59db71461028357600080fd5b806301ffc9a7146101ae578063124f1ead146101d6578063248a9ca3146101eb5780632f2ff15d1461021c57806336568abe1461022f5780633b55302e14610242575b600080fd5b6101c16101bc366004610ecb565b6103b4565b60405190151581526020015b60405180910390f35b6101e96101e4366004610f11565b6103eb565b005b61020e6101f9366004610f2c565b60009081526020819052604090206001015490565b6040519081526020016101cd565b6101e961022a366004610f45565b610425565b6101e961023d366004610f45565b61044f565b6001546101c190610100900460ff1681565b6101e9610262366004610f11565b6104d2565b61027061271081565b60405161ffff90911681526020016101cd565b6101e961050c565b6101e9610299366004610f11565b610533565b61020e60065481565b6101e96102b5366004610f83565b610570565b6003546102709061ffff1681565b6102706101f481565b61020e60008051602061131083398151915281565b61020e6000805160206112c983398151915281565b6003546102709062010000900461ffff1681565b61020e60055481565b6101c1610326366004610f45565b6106ed565b61020e600081565b610346610341366004610fad565b610716565b6040516101cd9190611072565b6101e961080b565b6101e9610369366004610f45565b610835565b61020e61037c3660046110d4565b61085a565b6101e961038f366004610f2c565b6109ad565b6001546101c19060ff1681565b6101e96103af366004610f11565b610a49565b60006001600160e01b03198216637965db0b60e01b14806103e557506301ffc9a760e01b6001600160e01b03198316145b92915050565b60008051602061131083398151915261040381610a86565b506001600160a01b03166000908152600460205260409020805460ff19169055565b60008281526020819052604090206001015461044081610a86565b61044a8383610a93565b505050565b6001600160a01b03811633146104c45760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6104ce8282610b17565b5050565b6000805160206113108339815191526104ea81610a86565b506001600160a01b03166000908152600260205260409020805460ff19169055565b6000805160206112c983398151915261052481610a86565b506001805460ff191681179055565b60008051602061131083398151915261054b81610a86565b506001600160a01b03166000908152600460205260409020805460ff19166001179055565b6000805160206112c983398151915261058881610a86565b60015460ff16156105f15760405162461bcd60e51b815260206004820152602d60248201527f4d616e61676564546f6b656e54617850726f76696465723a205461782068617360448201526c103132b2b710333937bd32b71760991b60648201526084016104bb565b6101f461ffff8416111561065a5760405162461bcd60e51b815260206004820152602a60248201527f526571756573746564206e6577204275792054617820426970732065786365656044820152696473206d6178696d756d60b01b60648201526084016104bb565b6101f461ffff831611156106c45760405162461bcd60e51b815260206004820152602b60248201527f526571756573746564206e65772053656c6c205461782042697073206578636560448201526a656473206d6178696d756d60a81b60648201526084016104bb565b506003805461ffff928316620100000263ffffffff199091169290931691909117919091179055565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60608167ffffffffffffffff81111561073157610731611110565b60405190808252806020026020018201604052801561076457816020015b606081526020019060019003908161074f5790505b50905060005b82811015610804576107d43085858481811061078857610788611126565b905060200281019061079a919061113c565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610b7c92505050565b8282815181106107e6576107e6611126565b602002602001018190525080806107fc906111a0565b91505061076a565b5092915050565b6000805160206112c983398151915261082381610a86565b506001805461ff001916610100179055565b60008281526020819052604090206001015461085081610a86565b61044a8383610b17565b60006005546000148061086f57506005548211155b6108da5760405162461bcd60e51b815260206004820152603660248201527f4d616e61676564546f6b656e54617850726f76696465723a204d6178207472616044820152753739b332b91030b6b7bab73a1032bc31b2b2b232b21760511b60648201526084016104bb565b6001600160a01b03831660009081526004602052604090205460ff161561094c576001600160a01b03841660009081526002602052604090205460ff1661094757600354612710906109369062010000900461ffff16846111b9565b61094091906111d8565b90506109a6565b6109a2565b6001600160a01b03841660009081526004602052604090205460ff16156109a2576001600160a01b03841660009081526002602052604090205460ff166109a257600354612710906109369061ffff16846111b9565b5060005b9392505050565b6000805160206112c98339815191526109c581610a86565b600154610100900460ff1615610a435760405162461bcd60e51b815260206004820152603760248201527f4d616e61676564546f6b656e54617850726f76696465723a204d61782054782060448201527f416d6f756e7420686173206265656e2066726f7a656e2e00000000000000000060648201526084016104bb565b50600555565b600080516020611310833981519152610a6181610a86565b506001600160a01b03166000908152600260205260409020805460ff19166001179055565b610a908133610ba1565b50565b610a9d82826106ed565b6104ce576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610ad33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610b2182826106ed565b156104ce576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606109a683836040518060600160405280602781526020016112e960279139610bfa565b610bab82826106ed565b6104ce57610bb881610c72565b610bc3836020610c84565b604051602001610bd49291906111fa565b60408051601f198184030181529082905262461bcd60e51b82526104bb9160040161126f565b6060600080856001600160a01b031685604051610c179190611282565b600060405180830381855af49150503d8060008114610c52576040519150601f19603f3d011682016040523d82523d6000602084013e610c57565b606091505b5091509150610c6886838387610e20565b9695505050505050565b60606103e56001600160a01b03831660145b60606000610c938360026111b9565b610c9e90600261129e565b67ffffffffffffffff811115610cb657610cb6611110565b6040519080825280601f01601f191660200182016040528015610ce0576020820181803683370190505b509050600360fc1b81600081518110610cfb57610cfb611126565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110610d2a57610d2a611126565b60200101906001600160f81b031916908160001a9053506000610d4e8460026111b9565b610d5990600161129e565b90505b6001811115610dd1576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110610d8d57610d8d611126565b1a60f81b828281518110610da357610da3611126565b60200101906001600160f81b031916908160001a90535060049490941c93610dca816112b1565b9050610d5c565b5083156109a65760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016104bb565b60608315610e8f578251600003610e88576001600160a01b0385163b610e885760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104bb565b5081610e99565b610e998383610ea1565b949350505050565b815115610eb15781518083602001fd5b8060405162461bcd60e51b81526004016104bb919061126f565b600060208284031215610edd57600080fd5b81356001600160e01b0319811681146109a657600080fd5b80356001600160a01b0381168114610f0c57600080fd5b919050565b600060208284031215610f2357600080fd5b6109a682610ef5565b600060208284031215610f3e57600080fd5b5035919050565b60008060408385031215610f5857600080fd5b82359150610f6860208401610ef5565b90509250929050565b803561ffff81168114610f0c57600080fd5b60008060408385031215610f9657600080fd5b610f9f83610f71565b9150610f6860208401610f71565b60008060208385031215610fc057600080fd5b823567ffffffffffffffff80821115610fd857600080fd5b818501915085601f830112610fec57600080fd5b813581811115610ffb57600080fd5b8660208260051b850101111561101057600080fd5b60209290920196919550909350505050565b60005b8381101561103d578181015183820152602001611025565b50506000910152565b6000815180845261105e816020860160208601611022565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156110c757603f198886030184526110b5858351611046565b94509285019290850190600101611099565b5092979650505050505050565b6000806000606084860312156110e957600080fd5b6110f284610ef5565b925061110060208501610ef5565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261115357600080fd5b83018035915067ffffffffffffffff82111561116e57600080fd5b60200191503681900382131561118357600080fd5b9250929050565b634e487b7160e01b600052601160045260246000fd5b6000600182016111b2576111b261118a565b5060010190565b60008160001904831182151516156111d3576111d361118a565b500290565b6000826111f557634e487b7160e01b600052601260045260246000fd5b500490565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611232816017850160208801611022565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611263816028840160208801611022565b01602801949350505050565b6020815260006109a66020830184611046565b60008251611294818460208701611022565b9190910192915050565b808201808211156103e5576103e561118a565b6000816112c0576112c061118a565b50600019019056fe860ad3e446dfd5e02b4764f88e672dd1008a1bf89b2edc1bdfa963c7c81230e5416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564139a5952d24700661f8938da058f7dc812f6ce44f991182c24c1c1d487dd1ddba2646970667358221220592a39c04d63190df3e3a2b5989cc9f96b5a04e55fb2f940c9440adc72d6122b64736f6c63430008100033a26469706673582212202f61132d9e3eaa7ffb4388d77b2b085d2d0a62c1b300265004fa9d370735594464736f6c63430008100033