Token $igil Token

 

Overview ERC-20

Price
$0.00 @ 0.000000 MATIC
Fully Diluted Market Cap
Total Supply:
1,000,000 IGIL

Holders:
29 addresses

Transfers:
-

Contract:
0x6686C5DE82D9F101b0520681FC6b1937EdB12c8e0x6686C5DE82D9F101b0520681FC6b1937EdB12c8e

Decimals:
18

Social Profiles:
Not Available, Update ?

 
Loading
[ Download CSV Export  ] 
Loading
[ Download CSV Export  ] 
Loading

Click here to update the token ICO / general information
# Exchange Pair Price  24H Volume % Volume
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RootedToken

Compiler Version
v0.7.4+commit.3f05b770

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity Multiple files format)

File 47 of 56: RootedToken.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/* ROOTKIT: upToken

An upToken is a token that gains in value
against whatever token it is paired with.

- Raise any token using the Market Generation
and Market Distribution contracts
- An equal amount of upToken will be minted
- combine with an ERC-31337 version of the 
raised token.
- Send LP tokens to the Liquidity Controller
for efficent access to market features

*/

import "./LiquidityLockedERC20.sol";

contract RootedToken is LiquidityLockedERC20
{
    
    constructor(
        address _dev,
        string memory _name,
        string memory _symbol
    )
    LiquidityLockedERC20(_dev, _name, _symbol)
    {
    }
    address public minter;
    

    function setMinter(address _minter) public onlyController()
    {
        minter = _minter;
    }

    function mint(uint256 amount) public
    {
        require(msg.sender == minter, "Not a minter");
        require(this.totalSupply() == 0, "Already minted");
        _mint(msg.sender, amount);
    }
}

File 1 of 56: Address.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.3._
     */
    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.3._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 2 of 56: CalculatorFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./RootedToken.sol";
import "./Owned.sol";
import "./EliteToken.sol";
import "./MarketGeneration.sol";
import "./MarketDistribution.sol";
import "./LazarusPit.sol";
import "./RootedTransferGate.sol";
import "./EliteFloorCalculator.sol";
import "./EliteFloorCalculatorV1.sol";
import "./FeeSplitter.sol";
import "./LiquidityController.sol";
import "./StakingToken.sol";
import "./RoyaltyPump.sol";
import "./TokenTimelock.sol";

contract CalculatorFactory is Owned {
address factory;
//WETH MATIC MAINNET
IERC20 wrappedToken = IERC20(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270);
IPancakeFactory _pancakeFactory = IPancakeFactory(0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32);
IPancakeRouter02 _router = IPancakeRouter02(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff);

modifier onlyFactory {
    require(msg.sender == factory || msg.sender == owner);
    _;
}
function setFactory(address _factory) public ownerOnly() {
    factory = _factory;
}

function createCalculatorV1(RootedToken root) public onlyFactory() returns (EliteFloorCalculatorV1) {
    EliteFloorCalculatorV1 calc = new EliteFloorCalculatorV1(root, _pancakeFactory);
    calc.setController(factory);
    return calc;
}
 function createCalculator(RootedToken root, EliteToken elite) public onlyFactory() returns (EliteFloorCalculator) {
    EliteFloorCalculator calc = new EliteFloorCalculator(root, elite, wrappedToken, _pancakeFactory, _router);
    calc.setController(factory);
    return calc;
}

function createLazarusPit(RootedToken root) public onlyFactory() returns (LazarusPit) {
    return new LazarusPit(root);
}
function createTransferGate(address dev, RootedToken root) public onlyFactory() returns (RootedTransferGate) {
    RootedTransferGate gate = new RootedTransferGate(dev, root, _router);
    gate.setController(factory);
    return gate;
    
}
    
}

File 3 of 56: Context.sol
pragma solidity ^0.7.4;

abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 4 of 56: ControllerFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./RootedToken.sol";
import "./Owned.sol";
import "./EliteToken.sol";
import "./MarketGeneration.sol";
import "./MarketDistribution.sol";
import "./LazarusPit.sol";
import "./RootedTransferGate.sol";
import "./EliteFloorCalculator.sol";
import "./EliteFloorCalculatorV1.sol";
import "./FeeSplitter.sol";
import "./LiquidityController.sol";
import "./StakingToken.sol";
import "./RoyaltyPump.sol";
import "./TokenTimelock.sol";

contract ControllerFactory is Owned {
address factory;
//WETH MATIC MAINNET
IERC20 wrappedToken = IERC20(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270);
IPancakeFactory _pancakeFactory = IPancakeFactory(0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32);
IPancakeRouter02 _router = IPancakeRouter02(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff);
address public signedLiquidityController = 0x6cFd1B788ecC0900b6e1f352FF73BEf58FeEc88a;

modifier onlyFactory {
    require(msg.sender == factory || msg.sender == owner);
    _;
}
function setFactory(address _factory) public ownerOnly() {
    factory = _factory;
}

function createLiquidityController(address dev, RootedToken root, EliteToken elite, EliteFloorCalculator calc, RootedTransferGate gate) public onlyFactory() returns (LiquidityController) {
    LiquidityController controller = new LiquidityController(dev, _router, wrappedToken, root, elite, calc, gate);
    controller.setController(factory);
    return controller;
}

function createTokenTimelock(address dev) public onlyFactory() returns (TokenTimelock) {
    TokenTimelock timelock = new TokenTimelock(dev);
    timelock.setController(factory);
    return timelock;
}
}

File 5 of 56: EliteFloorCalculator.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/* ROOTKIT:
A floor calculator to use with ERC31337 AMM pairs
Ensures 100% of accessible funds are backed at all times
*/

import "./IFloorCalculator.sol";
import "./SafeMath.sol";
import "./IPancakeRouter02.sol";
import "./IPancakeFactory.sol";
import "./TokensRecoverable.sol";
import "./EnumerableSet.sol";

contract EliteFloorCalculator is IFloorCalculator, TokensRecoverable
{
    using SafeMath for uint256;
    using EnumerableSet for EnumerableSet.AddressSet;

    IERC20 immutable rootedToken;
    address immutable rootedElitePair;
    address immutable rootedBasePair;
    IPancakeRouter02 immutable internal pancakeRouter;
    IPancakeFactory immutable internal pancakeFactory;
    EnumerableSet.AddressSet ignoredAddresses;

    constructor(IERC20 _rootedToken, IERC20 _eliteToken, IERC20 _baseToken, IPancakeFactory _pancakeFactory, IPancakeRouter02 _pancakeRouter)
    {
        rootedToken = _rootedToken;
        pancakeFactory = _pancakeFactory;
        pancakeRouter = _pancakeRouter;

        rootedElitePair = _pancakeFactory.getPair(address(_eliteToken), address(_rootedToken));
        rootedBasePair = _pancakeFactory.getPair(address(_baseToken), address(_rootedToken));
    }    


    function setIgnoreAddresses(address ignoredAddress, bool add) public ownerOnly()
    {
        if (add) 
        { 
            ignoredAddresses.add(ignoredAddress); 
        } 
        else 
        { 
            ignoredAddresses.remove(ignoredAddress); 
        }
    }

    function isIgnoredAddress(address ignoredAddress) public view returns (bool)
    {
        return ignoredAddresses.contains(ignoredAddress);
    }

    function ignoredAddressCount() public view returns (uint256)
    {
        return ignoredAddresses.length();
    }

    function ignoredAddressAt(uint256 index) public view returns (address)
    {
        return ignoredAddresses.at(index);
    }

    function ignoredAddressesTotalBalance() public view returns (uint256)
    {
        uint256 total = 0;
        for (uint i = 0; i < ignoredAddresses.length(); i++) 
        {
            total = total.add(rootedToken.balanceOf(ignoredAddresses.at(i)));
        }

        return total;
    }

    function calculateSubFloor(IERC20 baseToken, IERC20 eliteToken) public override view returns (uint256)
    {
        uint256 totalRootedInPairs = rootedToken.balanceOf(rootedElitePair).add(rootedToken.balanceOf(rootedBasePair));
        uint256 totalBaseAndEliteInPairs = eliteToken.balanceOf(rootedElitePair).add(baseToken.balanceOf(rootedBasePair));
        uint256 rootedCirculatingSupply = rootedToken.totalSupply().sub(totalRootedInPairs).sub(ignoredAddressesTotalBalance());
        uint256 amountUntilFloor = pancakeRouter.getAmountOut(rootedCirculatingSupply, totalRootedInPairs, totalBaseAndEliteInPairs);

        uint256 totalExcessInPools = totalBaseAndEliteInPairs.sub(amountUntilFloor);
        uint256 previouslySwept = eliteToken.totalSupply().sub(baseToken.balanceOf(address(eliteToken)));
        
        if (previouslySwept >= totalExcessInPools) { return 0; }

        return totalExcessInPools.sub(previouslySwept);
    }
}

File 6 of 56: EliteFloorCalculatorV1.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/* ROOTKIT:
A floor calculator to use with ERC31337 AMM pairs
Ensures 100% of accessible funds are backed at all times
*/

import "./IFloorCalculator.sol";
import "./SafeMath.sol";
import "./PancakeLibrary.sol";
import "./IPancakeFactory.sol";
import "./TokensRecoverable.sol";
import "./EnumerableSet.sol";

contract EliteFloorCalculatorV1 is IFloorCalculator, TokensRecoverable
{
    using SafeMath for uint256;
    using EnumerableSet for EnumerableSet.AddressSet;

    IERC20 immutable rootedToken;
    IPancakeFactory immutable pancakeFactory;
    EnumerableSet.AddressSet ignoredAddresses;

    constructor(IERC20 _rootedToken, IPancakeFactory _pancakeFactory)
    {
        rootedToken = _rootedToken;
        pancakeFactory = _pancakeFactory;
    }    

    function setIgnoreAddresses(address ignoredAddress, bool add) public ownerOnly()
    {
        if (add) 
        { 
            ignoredAddresses.add(ignoredAddress); 
        } 
        else 
        { 
            ignoredAddresses.remove(ignoredAddress); 
        }
    }

    function isIgnoredAddress(address ignoredAddress) public view returns (bool)
    {
        return ignoredAddresses.contains(ignoredAddress);
    }

    function ignoredAddressCount() public view returns (uint256)
    {
        return ignoredAddresses.length();
    }

    function ignoredAddressAt(uint256 index) public view returns (address)
    {
        return ignoredAddresses.at(index);
    }

    function ignoredAddressesTotalBalance() public view returns (uint256)
    {
        uint256 total = 0;
        for (uint i = 0; i < ignoredAddresses.length(); i++) 
        {
            total = total.add(rootedToken.balanceOf(ignoredAddresses.at(i)));
        }

        return total;
    }

    function calculateExcessInPool(IERC20 token, address pair, uint256 liquidityShare, uint256 rootedTokenTotalSupply, uint256 rootedTokenPoolsLiquidity) internal view returns (uint256)
    {
        uint256 freeRootedToken = (rootedTokenTotalSupply.sub(rootedTokenPoolsLiquidity)).mul(liquidityShare).div(1e12);

        uint256 sellAllProceeds = 0;
        if (freeRootedToken > 0) 
        {
            address[] memory path = new address[](2);
            path[0] = address(rootedToken);
            path[1] = address(token);
            uint256[] memory amountsOut = PancakeLibrary.getAmountsOut(address(pancakeFactory), freeRootedToken, path);
            sellAllProceeds = amountsOut[1];
        }

        uint256 backingInPool = token.balanceOf(pair);
        if (backingInPool <= sellAllProceeds) { return 0; }
        uint256 excessInPool = backingInPool - sellAllProceeds;

        return excessInPool;
    }

    function calculateExcessInPools(IERC20 baseToken, IERC20 eliteToken) public view returns (uint256)
    {
        address rootedElitePair = PancakeLibrary.pairFor(address(pancakeFactory), address(rootedToken), address(eliteToken));
        address rootedBasePair = PancakeLibrary.pairFor(address(pancakeFactory), address(rootedToken), address(baseToken));   
        
        uint256 rootedTokenTotalSupply = rootedToken.totalSupply().sub(ignoredAddressesTotalBalance());
        uint256 rootedTokenPoolsLiquidity = rootedToken.balanceOf(rootedElitePair).add(rootedToken.balanceOf(rootedBasePair));
        uint256 baseTokenPoolsLiquidity = eliteToken.balanceOf(rootedElitePair).add(baseToken.balanceOf(rootedBasePair));

        uint256 rootedLiquidityShareInElitePair = rootedToken.balanceOf(rootedElitePair).mul(1e12).div(rootedTokenPoolsLiquidity);
        uint256 eliteLiquidityShareInElitePair = eliteToken.balanceOf(rootedElitePair).mul(1e12).div(baseTokenPoolsLiquidity);
        uint256 avgLiquidityShareInElitePair = (rootedLiquidityShareInElitePair.add(eliteLiquidityShareInElitePair)).div(2);
        uint256 one = 1e12;

        uint256 excessInElitePool = calculateExcessInPool(eliteToken, rootedElitePair, avgLiquidityShareInElitePair, rootedTokenTotalSupply, rootedTokenPoolsLiquidity);
        uint256 excessInBasePool = calculateExcessInPool(baseToken, rootedBasePair, (one).sub(avgLiquidityShareInElitePair), rootedTokenTotalSupply, rootedTokenPoolsLiquidity);
        return excessInElitePool.add(excessInBasePool);
    }

    function calculateSubFloor(IERC20 baseToken, IERC20 eliteToken) public override view returns (uint256)
    {        
        uint256 excessInPools = calculateExcessInPools(baseToken, eliteToken);

        uint256 requiredBacking = eliteToken.totalSupply().sub(excessInPools);
        uint256 currentBacking = baseToken.balanceOf(address(eliteToken));
        if (requiredBacking >= currentBacking) { return 0; }
        return currentBacking - requiredBacking;
    }
}

File 7 of 56: EliteToken.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./ERC31337.sol";
import "./IERC20.sol";

contract EliteToken is ERC31337
{
    using Address for address;
    using SafeMath for uint256;
    
    mapping (address => bool) public freeParticipantControllers;
    mapping (address => bool) public freeParticipants; 

    mapping (address => bool) public burnRateControllers;
    uint16 burnRate;   
    address devAddress;


    constructor (IERC20 _wrappedToken, address _devAddress) ERC31337(_devAddress, _wrappedToken, "eToken", "eToke")
    {
        devAddress = _devAddress;
        freeParticipantControllers[devAddress] = true;
        burnRateControllers[devAddress] = true;
    }    

    
    function setFreeParticipantController(address freeParticipantController, bool allow) public onlyController()
    {
        freeParticipantControllers[freeParticipantController] = allow;
    }

    function setFreeParticipant(address participant, bool free) public
    {
        require (msg.sender == owner || freeParticipantControllers[msg.sender], "Not an owner or free participant controller");
        freeParticipants[participant] = free;
    }

    function setBurnRateController(address burnRateController, bool allow) public onlyController()
    {
        burnRateControllers[burnRateController] = allow;
    }

    function setBurnRate(uint16 _burnRate) public // 10000 = 100%
    {
        require (msg.sender == owner || burnRateControllers[msg.sender], "Not an owner or burn rate controller");
        require (_burnRate <= 10000, "But rate must be less or equal to 100%");
       
        burnRate = _burnRate;
    }

    function _transfer(address sender, address recipient, uint256 amount) internal virtual override 
    {
        require(sender != address(0), "EliteToken: transfer from the zero address");
        require(recipient != address(0), "EliteToken: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);
        uint256 remaining = amount;

        if (!freeParticipants[sender] && !freeParticipants[recipient] && burnRate > 0)
        {
            uint256 burn = amount * burnRate / 10000;
            amount = remaining = remaining.sub(burn, "Burn too much");
            _burn(sender, burn);
        }
        
        _balanceOf[sender] = _balanceOf[sender].sub(amount, "EliteToken: transfer amount exceeds balance");
        _balanceOf[recipient] = _balanceOf[recipient].add(remaining);
        
        emit Transfer(sender, recipient, remaining);
    }
}

File 8 of 56: EnumerableSet.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint256(_at(set._inner, index)));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

File 9 of 56: ERC20.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/* ROOTKIT:
Simplified thanks to higher solidity version
But same functionality
*/

import "./IERC20.sol";
import "./SafeMath.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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of 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}.
 */
abstract contract ERC20 is IERC20 
{
    using SafeMath for uint256;

    mapping (address => uint256) internal _balanceOf;
    mapping (address => mapping (address => uint256)) public override allowance;

    uint256 public override totalSupply;

    string public override name;
    string public override symbol;
    address public dev;
    uint8 public override decimals = 18;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (address _dev, string memory _name, string memory _symbol) 
    {
        dev = _dev;
        name = _name;
        symbol = _symbol;
    }

    function balanceOf(address a) public virtual override view returns (uint256) { return _balanceOf[a]; }

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(msg.sender, 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}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        uint256 oldAllowance = allowance[sender][msg.sender];
        if (oldAllowance != uint256(-1)) {
            _approve(sender, msg.sender, oldAllowance.sub(amount, "ERC20: transfer amount exceeds allowance"));
        }
        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) {
        _approve(msg.sender, spender, allowance[msg.sender][spender].add(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) {
        _approve(msg.sender, spender, allowance[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is 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:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balanceOf[sender] = _balanceOf[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balanceOf[recipient] = _balanceOf[recipient].add(amount);
        emit Transfer(sender, recipient, 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:
     *
     * - `to` 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 = totalSupply.add(amount);
        _balanceOf[account] = _balanceOf[account].add(amount);
        emit Transfer(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);

        _balanceOf[account] = _balanceOf[account].sub(amount, "ERC20: burn amount exceeds balance");
        totalSupply = totalSupply.sub(amount);
        emit Transfer(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");

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

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 _decimals) internal {
        decimals = _decimals;
    }

    /**
     * @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 to 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 { }
}

File 10 of 56: ERC31337.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/* ROOTKIT:
A wrapped token, where the underlying token can be swept
and used for other purposes
Governed by an installable floor calculator contract
Sweepable by designated sweeper addresses
*/

import "./IERC20.sol";
import "./SafeERC20.sol";
import "./IFloorCalculator.sol";
import "./WrappedERC20.sol";
import "./IERC31337.sol";

contract ERC31337 is WrappedERC20, IERC31337
{
    using SafeERC20 for IERC20;

    IFloorCalculator public override floorCalculator;
    
    mapping (address => bool) public override sweepers;

    constructor(address _dev, IERC20 _wrappedToken, string memory _name, string memory _symbol)
        WrappedERC20(_dev, _wrappedToken, _name, _symbol)
    {
    }

    function setFloorCalculator(IFloorCalculator _floorCalculator) public override onlyController()
    {
        floorCalculator = _floorCalculator;
    }

    function setSweeper(address sweeper, bool allow) public override onlyController()
    {
        sweepers[sweeper] = allow;
    }

    function sweepFloor(address to) public override returns (uint256 amountSwept)
    {
        require (to != address(0),  " transfer to the zero address");
        require (sweepers[msg.sender], "Sweepers only");
        amountSwept = floorCalculator.calculateSubFloor(wrappedToken, this);
        if (amountSwept > 0) {
            wrappedToken.safeTransfer(to, amountSwept);
        }
    }
}

File 11 of 56: FactoryManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./RootedToken.sol";
import "./Owned.sol";
import "./EliteToken.sol";
import "./MarketGeneration.sol";
import "./MarketDistribution.sol";
import "./LazarusPit.sol";
import "./RootedTransferGate.sol";
import "./EliteFloorCalculator.sol";
import "./EliteFloorCalculatorV1.sol";
import "./FeeSplitter.sol";
import "./LiquidityController.sol";
import "./StakingToken.sol";
import "./RoyaltyPump.sol";
import "./TokenTimelock.sol";
import "./TokenFactory.sol";
import "./MGEFactory.sol";
import "./CalculatorFactory.sol";
import "./FeeSplitterFactory.sol";
import "./ControllerFactory.sol";
import "./IGatedERC20.sol";

contract FactoryManager is Owned, TokensRecoverable {
    using SafeMath for uint;

    TokenFactory tokenFactory;
    MGEFactory mgeFactory;
    CalculatorFactory calculatorFactory;
    FeeSplitterFactory feeSplitterFactory;
    ControllerFactory controllerFactory;

    constructor(TokenFactory _tokenFactory, MGEFactory _mgeFactory ,CalculatorFactory _calculatorFactory, FeeSplitterFactory _feeSplitterFactory, ControllerFactory _controllerFactory) {
        tokenFactory = _tokenFactory;
        mgeFactory = _mgeFactory;
        calculatorFactory = _calculatorFactory;
        feeSplitterFactory = _feeSplitterFactory;
        controllerFactory = _controllerFactory;
    }

    //set factories function
    function setFactories(address _tokenFactory, address _mgeFactory, address _calculatorFactory, address _feeSplitterFactory, address _controllerFactory) public onlySignedAdmin(){
        tokenFactory = TokenFactory(_tokenFactory);
        mgeFactory = MGEFactory(_mgeFactory);
        calculatorFactory = CalculatorFactory(_calculatorFactory);
        feeSplitterFactory = FeeSplitterFactory(_feeSplitterFactory);
        controllerFactory = ControllerFactory(_controllerFactory);
    }

    address public signedAdmin;
    address public signedLiquidityController = 0x6cFd1B788ecC0900b6e1f352FF73BEf58FeEc88a;

    //WETH MATIC MAINNET
    IERC20 wrappedToken = IERC20(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270);
    //Pancake MATIC MAINNET
    IPancakeRouter02 _router = IPancakeRouter02(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff);
    IPancakeFactory _factory = IPancakeFactory(0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32);
    struct TokenDeployment {
        string name;
        uint ID;
        address signedAdministrator;
        address rootToken;
        address eliteToken;
        address payable MGE;
        address MGD;
        
    }
    struct MGEInfo {
        address MGE;
        address artist;
        uint raisedMatic;
    }
    struct deployInfo {
        address burnPit;
        address transGate;
        address calcV1;
        address calc;
        address feeSplitter;
        address liquidityController;
        address staking;
        address royaltyPump;
        address tokenLock;
    }
    
    mapping (uint => TokenDeployment) public tokenDeployments;
    mapping (uint => deployInfo) public deployData;
    mapping (uint => MGEInfo) public mgeInfo;

    uint public counter = 0;

    event ERC20TokenCreated(address tokenAddress);

    modifier onlySignedAdmin()
    {
        require(msg.sender == signedAdmin|| msg.sender == owner);
        _;
    }
    

    function updateSignedAddress(address _signedAddress) public ownerOnly() {
        signedAdmin = _signedAddress;
    }

    function deployNewTokens(
        string calldata name,
        string calldata symbol) public onlySignedAdmin() {
            RootedToken _rootToken = tokenFactory.createRooted(address(this), name, symbol);
            EliteToken _eliteToken = tokenFactory.createElite(address(this));
            tokenDeployments[counter].name = name;
            tokenDeployments[counter].ID = counter;
            tokenDeployments[counter].signedAdministrator = signedAdmin;
            tokenDeployments[counter].rootToken = address(_rootToken);
            tokenDeployments[counter].eliteToken = address(_eliteToken);

        }

    function deployNewMGE() public onlySignedAdmin() {
            //set manager as owner of mge
        MarketGeneration _MGE = mgeFactory.createMGE(address(this));
        MarketDistribution _MGD = mgeFactory.createMGD(address(this));
        tokenDeployments[counter].MGE = address(_MGE);
        tokenDeployments[counter].MGD = address(_MGD);
        //MarketGeneration(tokenDeployments[counter].MGE).setMGEController(address(this));
        
    
    }

    function deployGates() public onlySignedAdmin() {
        LazarusPit _burnPit = calculatorFactory.createLazarusPit(RootedToken(tokenDeployments[counter].rootToken));
        RootedTransferGate _transGate = calculatorFactory.createTransferGate(address(this),RootedToken(tokenDeployments[counter].rootToken));
        EliteFloorCalculatorV1 _calcV1 = calculatorFactory.createCalculatorV1(RootedToken(tokenDeployments[counter].rootToken));
        EliteFloorCalculator _calc = calculatorFactory.createCalculator(RootedToken(tokenDeployments[counter].rootToken), EliteToken(tokenDeployments[counter].eliteToken));
        deployData[counter].burnPit = address(_burnPit);
        deployData[counter].transGate = address(_transGate);
        deployData[counter].calcV1 = address(_calcV1);
        deployData[counter].calc = address(_calc);
    }
    function deployFeeSplitter() public onlySignedAdmin() {
     FeeSplitter _feeSplitter = feeSplitterFactory.createFeeSplitter(address(this));
     MarketDistribution(tokenDeployments[counter].MGD).init(RootedToken(tokenDeployments[counter].rootToken), EliteToken(tokenDeployments[counter].eliteToken), deployData[counter].burnPit, address(_router), _router, MarketGeneration(tokenDeployments[counter].MGE), 1, 100);
     LiquidityController _liquidityController = controllerFactory.createLiquidityController(address(this),RootedToken(tokenDeployments[counter].rootToken), EliteToken(tokenDeployments[counter].eliteToken), EliteFloorCalculator(deployData[counter].calc), RootedTransferGate(deployData[counter].transGate));
     deployData[counter].feeSplitter = address(_feeSplitter);
     deployData[counter].liquidityController = address(_liquidityController);
    
    }
    function deployStaking(string calldata xName, string calldata xSymbol) public onlySignedAdmin(){
        StakingToken _staking = feeSplitterFactory.createStaking(address(this), RootedToken(tokenDeployments[counter].rootToken), xName, xSymbol);
        RoyaltyPump _pump = feeSplitterFactory.createRoyaltyPump(address(this), address(_staking), address(RootedToken(tokenDeployments[counter].rootToken)), RootedTransferGate(deployData[counter].transGate));
        TokenTimelock _tokenLock = controllerFactory.createTokenTimelock(address(this));
        deployData[counter].staking = address(_staking);
        deployData[counter].royaltyPump = address(_pump);
        deployData[counter].tokenLock = address(_tokenLock);
    }

    function MGESetup() public onlySignedAdmin() {
         MarketGeneration(tokenDeployments[counter].MGE).init(wrappedToken);
        //TODO Update signed admin before deeploying any contracts
        
        MarketGeneration(tokenDeployments[counter].MGE).setMGEController(signedAdmin, true);
        MarketDistribution(tokenDeployments[counter].MGD).init(RootedToken(tokenDeployments[counter].rootToken), EliteToken(tokenDeployments[counter].eliteToken), deployData[counter].burnPit, deployData[counter].liquidityController, _router, MarketGeneration(tokenDeployments[counter].MGE), 1, 100);
        MarketDistribution(tokenDeployments[counter].MGD).setupEliteRooted();
        MarketDistribution(tokenDeployments[counter].MGD).setupBaseRooted();
        MarketDistribution(tokenDeployments[counter].MGD).completeSetup(); 
    }

    function rootSetup() public onlySignedAdmin() {
        RootedToken(tokenDeployments[counter].rootToken).setTransferGate(RootedTransferGate(deployData[counter].transGate));
        RootedToken(tokenDeployments[counter].rootToken).setMinter(tokenDeployments[counter].MGD);
        RootedToken(tokenDeployments[counter].rootToken).setLiquidityController(address(this), true);
        RootedToken(tokenDeployments[counter].rootToken).setLiquidityController(deployData[counter].transGate, true);

    }
    function eliteSetup() public onlySignedAdmin() {

        EliteToken(tokenDeployments[counter].eliteToken).setBurnRateController(deployData[counter].transGate, true);
        EliteToken(tokenDeployments[counter].eliteToken).setBurnRate(9000);
        EliteToken(tokenDeployments[counter].eliteToken).setFreeParticipantController(address(this), true);
        EliteToken(tokenDeployments[counter].eliteToken).setFreeParticipant(deployData[counter].liquidityController, true);
        EliteToken(tokenDeployments[counter].eliteToken).setFreeParticipant(tokenDeployments[counter].MGE, true);
        EliteToken(tokenDeployments[counter].eliteToken).setFreeParticipant(tokenDeployments[counter].MGD, true);
        EliteToken(tokenDeployments[counter].eliteToken).setFreeParticipant(deployData[counter].burnPit, true);
        EliteToken(tokenDeployments[counter].eliteToken).setFreeParticipant(address(this), true);
        RootedTransferGate(deployData[counter].transGate).setUnrestrictedController(tokenDeployments[counter].MGD, true);
        EliteToken(tokenDeployments[counter].eliteToken).setFloorCalculator(EliteFloorCalculatorV1(deployData[counter].calcV1));
        EliteToken(tokenDeployments[counter].eliteToken).setSweeper(address(this), true);
        EliteToken(tokenDeployments[counter].eliteToken).setSweeper(tokenDeployments[counter].MGD, true);
        EliteToken(tokenDeployments[counter].eliteToken).setSweeper(deployData[counter].liquidityController, true);
        EliteToken(tokenDeployments[counter].eliteToken).setSweeper(tokenDeployments[counter].MGE, true);

    }

    function transGateSetup() public onlySignedAdmin(){

        

         address _pool = _factory.getPair(address(wrappedToken), tokenDeployments[counter].rootToken);
         IPancakePair _mainPool = IPancakePair(_pool);

        RootedTransferGate(deployData[counter].transGate).setFeeSplitter(deployData[counter].feeSplitter);
        RootedTransferGate(deployData[counter].transGate).setFeeControllers(deployData[counter].liquidityController, true);
        RootedTransferGate(deployData[counter].transGate).setFees(500);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(deployData[counter].liquidityController, true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(address(this), true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(deployData[counter].burnPit, true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(tokenDeployments[counter].MGD, true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(tokenDeployments[counter].MGE, true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(deployData[counter].feeSplitter, true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(deployData[counter].staking, true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(deployData[counter].royaltyPump, true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(signedAdmin, true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(signedLiquidityController, true);
        RootedTransferGate(deployData[counter].transGate).setFreeParticipant(deployData[counter].tokenLock, true);
        RootedTransferGate(deployData[counter].transGate).setMainPool(_mainPool);
        RootedTransferGate(deployData[counter].transGate).setPoolTaxRate(_pool, 500);
        RootedTransferGate(deployData[counter].transGate).setUnrestrictedController(deployData[counter].liquidityController, true);
        RootedTransferGate(deployData[counter].transGate).setUnrestrictedController(address(this), true);
        RootedTransferGate(deployData[counter].transGate).setUnrestrictedController(deployData[counter].royaltyPump, true);
        RootedTransferGate(deployData[counter].transGate).setUnrestrictedController(address(signedAdmin), true);
        RootedTransferGate(deployData[counter].transGate).setFeeControllers(address(this), true);

    }

        uint16[] _collectRates = new uint16[](5);
        address[] _collectors = new address[](5);
        function initializeFeeRates() public onlySignedAdmin() {
            _collectRates[0] = 1000;//signed lc
            _collectRates[1] = 500; //burn
            _collectRates[2] = 5000; //staking
            _collectRates[3] = 500; //artist LC
            _collectRates[4] = 3000; //ARTIST
            _collectors[0] = signedLiquidityController; //LC STATIC -- can be removed
            _collectors[1] = address(0x0000000000000000000000000000000000000001); //burn STATIC -- can be removed
            _collectors[2] = address(0x0000000000000000000000000000000000000001); //staking CHANGES -- always going to be on feeSplitters
            _collectors[3] = address(0x0000000000000000000000000000000000000001); //artist lc CHANGES -- always going to be on feeSplitters
            _collectors[4] = address(0x0000000000000000000000000000000000000001); //artist CHANGES -- always going to be on feeSplitters
        }

        function updateCollectRatesOnDeploy(uint16[] memory rates) public onlySignedAdmin(){
            _collectRates = rates;
        }
        function updateCollectorsOnDeploy(address[] memory collectors) public onlySignedAdmin(){
            _collectors = collectors;
        }
        

    function feeLiqSetup(address _artist) public onlySignedAdmin() {

        uint len = _collectors.length;
        _collectors[len.sub(1)] = _artist;
        _collectors[len.sub(2)] = deployData[counter].liquidityController;
        _collectors[len.sub(3)] = deployData[counter].staking;



        FeeSplitter(deployData[counter].feeSplitter).setFees(RootedToken(tokenDeployments[counter].rootToken), 0, 0, 10000);

        //FeeSplitter(deployData[counter].feeSplitter).setChainTokenFeeCollectors(RootedToken(tokenDeployments[counter].rootToken), _collectors, _collectRates);

        FeeSplitter(deployData[counter].feeSplitter).setRootedTokenFeeCollectors(RootedToken(tokenDeployments[counter].rootToken), _collectors, _collectRates);
        
        LiquidityController(deployData[counter].liquidityController).setLiquidityController(address(this), true);
        LiquidityController(deployData[counter].liquidityController).setLiquidityController(tokenDeployments[counter].MGD, true);
        LiquidityController(deployData[counter].liquidityController).setLiquidityController(deployData[counter].transGate, true);
        
        RoyaltyPump(deployData[counter].royaltyPump).setRoyaltyCollector(signedAdmin);

        mgeInfo[counter].artist = _artist;
    }

     function CompleteTokenSetup(
    ) public onlySignedAdmin() {
        counter++;
    } 

 
    //MGE FUNCTIONS

    function setMGELength(uint256 _seconds, uint mgeID) public onlySignedAdmin(){
        MarketGeneration(tokenDeployments[mgeID].MGE).setMGELength(_seconds);
    }

    function setMGECap(uint256 value, uint mgeID) public onlySignedAdmin(){
        MarketGeneration(tokenDeployments[mgeID].MGE).setHardCap(value);
    }

    function activateMGE(uint mgeID, uint mgeLength) public onlySignedAdmin(){
        MarketGeneration(tokenDeployments[mgeID].MGE).activate(MarketDistribution(tokenDeployments[mgeID].MGD), mgeLength);
    }

    function CompleteMGE(uint mgeID) public onlySignedAdmin(){
        MarketGeneration(tokenDeployments[mgeID].MGE).complete(0, 9000, 500);
        stakeAndLockArtistTokens(mgeID);

        
        liquidityRecovery(mgeID);
        //log MGEInfo to mapping
        mgeInfo[mgeID].MGE = tokenDeployments[mgeID].MGE;
        mgeInfo[mgeID].raisedMatic = MarketGeneration(tokenDeployments[mgeID].MGE).totalContribution();
    }  

    function allowRefunds(uint mgeID) public onlySignedAdmin(){
        MarketGeneration(tokenDeployments[mgeID].MGE).allowRefunds();
    }

    //FEESPLITTER FUNCTIONS
    function setFeeSplitterController(uint deploymentID, address _controller) public onlySignedAdmin(){
        FeeSplitter(deployData[deploymentID].feeSplitter).setRoyaltyCollector(_controller);
    }

    function setFeeSplitterFees(uint deploymentID, uint _burn, uint _sell, uint _keep) public onlySignedAdmin(){
        FeeSplitter(deployData[deploymentID].feeSplitter).setFees(RootedToken(tokenDeployments[deploymentID].rootToken), _burn, _sell, _keep);
    }

    function setChainTokenFeeCollectors(uint deploymentId, address[] memory collectors, uint16[]  memory collectRates) public onlySignedAdmin(){
        FeeSplitter(deployData[deploymentId].feeSplitter).setChainTokenFeeCollectors(RootedToken(tokenDeployments[deploymentId].rootToken), collectors, collectRates);
    }

    function setRootedTokenFeeCollectors(uint deploymentId, address[] memory collectors, uint16[]  memory collectRates) public onlySignedAdmin(){
        FeeSplitter(deployData[deploymentId].feeSplitter).setRootedTokenFeeCollectors(RootedToken(tokenDeployments[deploymentId].rootToken), collectors, collectRates);
    }

    function payOutFeeSplitter(uint deploymentId) public onlySignedAdmin(){
        FeeSplitter(deployData[deploymentId].feeSplitter).payFees(IGatedERC20(tokenDeployments[deploymentId].rootToken));
    }
    function recoverTokensFeeSplitter(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        FeeSplitter(deployData[deploymentId].feeSplitter).recoverTokens(IERC20(tokenAddress));
    }

    //liquidity Controller functions
    function setLiquidityController(uint deploymentId, address _controller) public onlySignedAdmin(){
        LiquidityController(deployData[deploymentId].liquidityController).setLiquidityController(_controller, true);
    }
    function addLiquidity(uint deploymentId, address eliteOrBase, uint256 baseAmount) public onlySignedAdmin(){
        LiquidityController(deployData[deploymentId].liquidityController).addLiquidity(eliteOrBase, baseAmount);
    }
    function removeLiquidity(uint deploymentId, address eliteOrBase, uint256 baseAmount) public onlySignedAdmin(){
        LiquidityController(deployData[deploymentId].liquidityController).removeLiquidity(eliteOrBase, baseAmount);
    }
    

    //TRANSFER GATE
    function setFreeParticipant(uint deploymentId, address _participant, bool allow) public onlySignedAdmin(){
        RootedTransferGate(deployData[deploymentId].transGate).setFreeParticipant(_participant, allow);
    }
    function setUnrestrictedController(uint deploymentId, address _controller, bool _allow) public onlySignedAdmin(){
        RootedTransferGate(deployData[deploymentId].transGate).setUnrestrictedController(_controller, _allow);
    }

    //ROYALTY PUMP functions
    function setRoyaltyCollector(uint deploymentId, address _collector) public onlySignedAdmin(){
        RoyaltyPump(deployData[deploymentId].royaltyPump).setRoyaltyCollector(_collector);
    }

    function depositRoyalties(uint deploymentId) public payable onlySignedAdmin(){
        RoyaltyPump(deployData[deploymentId].royaltyPump).depositRoyalties{value: msg.value}();
    }

    //PRIVATE FUNCTIONS
    function stakeAndLockArtistTokens(uint mgeID) private {
        //artist gets 9% of wmatic raised
        uint256 artistWmatic = mgeInfo[mgeID].raisedMatic * 9 / 100;
        //transfer wmatic to artist
        wrappedToken.transfer(mgeInfo[mgeID].artist, artistWmatic);

        //approve stakingtoken contract to spend rooted tokens
        RootedToken(tokenDeployments[mgeID].rootToken).approve(deployData[mgeID].staking, uint256(-1));
        //stake 100k root tokens
        StakingToken(deployData[mgeID].staking).stake(100000000000000000000000);

        //approve tokenlock contract to spend staking tokens
        StakingToken(deployData[mgeID].staking).approve(deployData[mgeID].tokenLock, uint256(-1));

        //lock staking tokens balance
        TokenTimelock(deployData[mgeID].tokenLock).lockTokens(deployData[mgeID].staking, mgeInfo[mgeID].artist, (uint256(100000000000000000000)*1000));
    }
    
    function liquidityRecovery(uint deploymentId) private {
        address _elitePool = _factory.getPair(tokenDeployments[deploymentId].eliteToken, tokenDeployments[deploymentId].rootToken);
        uint256 amountToRemove = IERC20(_elitePool).balanceOf(deployData[deploymentId].liquidityController);
        
        LiquidityController(deployData[deploymentId].liquidityController).removeLiquidity(tokenDeployments[deploymentId].eliteToken, amountToRemove);
        LiquidityController(deployData[deploymentId].liquidityController).recoverTokens(IERC20(tokenDeployments[deploymentId].rootToken));

        //transfer recovered tokens to owner
        uint256 balance = IERC20(tokenDeployments[deploymentId].rootToken).balanceOf(address(this));
        IERC20(tokenDeployments[deploymentId].rootToken).transfer(owner, balance);

         //IPancakePair _mainPool = IPancakePair(_pool);
    }



    //RECOVER FUNCTIONS

    function recoverTokensLiquidityController(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        LiquidityController(deployData[deploymentId].liquidityController).recoverTokens(IERC20(tokenAddress));
    }

    function recoverTokensTransferGate(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        RootedTransferGate(deployData[deploymentId].transGate).recoverTokens(IERC20(tokenAddress));
    }
    function recoverTokensRooted(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        RootedToken(tokenDeployments[deploymentId].rootToken).recoverTokens(IERC20(tokenAddress));
    }
    function recoverTokensElite(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        EliteToken(tokenDeployments[deploymentId].eliteToken).recoverTokens(IERC20(tokenAddress));
    }
    function recoverTokensMGE(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        MarketGeneration(tokenDeployments[deploymentId].MGE).recoverTokens(IERC20(tokenAddress));
    }
    function recoverTokensMGD(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        MarketDistribution(tokenDeployments[deploymentId].MGD).recoverTokens(IERC20(tokenAddress));
    }
    function recoverTokensRoyaltyPump(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        RoyaltyPump(deployData[deploymentId].royaltyPump).recoverTokens(IERC20(tokenAddress));
    }
    function recoverTokensTimelock(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        TokenTimelock(deployData[deploymentId].tokenLock).recoverTokens(IERC20(tokenAddress));
    }
    function recoverTokensStaking(uint deploymentId, address tokenAddress) public onlySignedAdmin(){
        StakingToken(deployData[deploymentId].staking).recoverTokens(IERC20(tokenAddress));
    }


    
}

File 12 of 56: FeeSplitter.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./IGatedERC20.sol";
import "./SafeMath.sol";
import "./SafeERC20.sol";
import "./Address.sol";
import "./TokensRecoverable.sol";
import './IPancakeRouter02.sol';

contract FeeSplitter is TokensRecoverable
{
    using SafeMath for uint256;
    using SafeERC20 for IERC20;
    using Address for address;
    
    address public devAddress;  
    mapping (address => bool) public royaltyCollector;
    
    address public immutable deployerAddress;
    IPancakeRouter02 public immutable router;
    IERC20 public immutable chainToken;
   
    mapping (IGatedERC20 => uint256) public burnRates;
    mapping (IGatedERC20 => uint256) public sellRates;
    mapping (IGatedERC20 => uint256) public keepRates;

    mapping (IGatedERC20 => address[]) public chainTokenFeeCollectors;
    mapping (IGatedERC20 => uint256[]) public chainTokenFeeRates;

    mapping (IGatedERC20 => address[]) public rootedTokenFeeCollectors;
    mapping (IGatedERC20 => uint256[]) public rootedTokenFeeRates;
    mapping (address => uint256) public totalRoyaltiesCollected; //map royalties by token address

    constructor(address _devAddress, IPancakeRouter02 _router)
    {
        deployerAddress = msg.sender;
        devAddress = _devAddress;
        royaltyCollector[msg.sender] = true;
        router = _router;
        chainToken = IERC20(_router.WETH());   
    }
    modifier onlyRoyaltyCollector()
    {
        require(royaltyCollector[msg.sender] || msg.sender == devAddress || msg.sender == owner);
        _;
    }
    function setDevAddress(address _devAddress) public
    {
        require (msg.sender == deployerAddress || msg.sender == devAddress, "Not a deployer or dev address");
        devAddress = _devAddress;
    }
    function setRoyaltyCollector(address _royaltyCollector) public
    {
        require (msg.sender == deployerAddress || msg.sender == devAddress, "Not a deployer or dev address");
        royaltyCollector[_royaltyCollector] = true;
    }

    function setFees(IGatedERC20 token, uint256 burnRate, uint256 sellRate, uint256 keepRate) public onlyRoyaltyCollector() // 100% = 10000
    {
        require (burnRate + sellRate + keepRate == 10000, "Total fee rate must be 100%");
        
        burnRates[token] = burnRate;
        sellRates[token] = sellRate;
        keepRates[token] = keepRate;
        
        token.approve(address(router), uint256(-1));
    }
    //todo update below
    function setChainTokenFeeCollectors(IGatedERC20 token, address[] memory collectors, uint16[] memory rates) public onlyRoyaltyCollector() // 100% = 10000
    {
        require (collectors.length == rates.length, "Fee Collectors and Rates must be the same size");
        require (collectors[0] == devAddress, "First address must be dev address");
        
        uint256 totalRate = 0;
        for (uint256 i = 0; i < rates.length; i++)
        {
            totalRate = totalRate + rates[i];
        }
        
        require (totalRate == 10000, "Total fee rate must be 100%");

        chainTokenFeeCollectors[token] = collectors;
        chainTokenFeeRates[token] = rates;
    }

    function setRootedTokenFeeCollectors(IGatedERC20 token, address[] memory collectors, uint16[] memory rates) public onlyRoyaltyCollector() // 100% = 10000
    {
        require (collectors.length == rates.length, "Fee Collectors and Rates must be the same size");
        
        uint256 totalRate = 0;
        for (uint256 i = 0; i < rates.length; i++)
        {
            totalRate = totalRate + rates[i];
        }

        require (totalRate == 10000, "Total fee rate must be 100%");

        rootedTokenFeeCollectors[token] = collectors;
        rootedTokenFeeRates[token] = rates;
    }

    function payFees(IGatedERC20 token) public
    {
        uint256 balance = token.balanceOf(address(this));
        require (balance > 0, "Nothing to pay");

        if (burnRates[token] > 0)
        {
            uint256 burnAmount = burnRates[token] * balance / 10000;
            token.burn(burnAmount);
        }

        if (sellRates[token] > 0)
        {
            uint256 sellAmount = sellRates[token] * balance / 10000;
            
            address[] memory path = new address[](2);
            path[0] = address(token);
            path[1] = address(chainToken);
            uint256[] memory amounts = router.swapExactTokensForTokens(sellAmount, 0, path, address(this), block.timestamp);

            address[] memory collectors = chainTokenFeeCollectors[token];
            uint256[] memory rates = chainTokenFeeRates[token];
            distribute(chainToken, amounts[1], collectors, rates);
        }

        if (keepRates[token] > 0)
        {
            uint256 keepAmount = keepRates[token] * balance / 10000;
            address[] memory collectors = rootedTokenFeeCollectors[token];
            uint256[] memory rates = rootedTokenFeeRates[token];
            distribute(token, keepAmount, collectors, rates);
        }
    }
    
    function distribute(IERC20 token, uint256 amount, address[] memory collectors, uint256[] memory rates) private
    {
        for (uint256 i = 0; i < collectors.length; i++)
        {
            address collector = collectors[i];
            uint256 rate = rates[i];

            if (rate > 0)
            {
                uint256 feeAmount = rate * amount / 10000;
                token.transfer(collector, feeAmount);
            }
        }
    }
}

File 13 of 56: FeeSplitterFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./RootedToken.sol";
import "./Owned.sol";
import "./RootedTransferGate.sol";
import "./EliteFloorCalculator.sol";
import "./EliteFloorCalculatorV1.sol";
import "./FeeSplitter.sol";
import "./LiquidityController.sol";
import "./StakingToken.sol";
import "./RoyaltyPump.sol";
import "./TokenTimelock.sol";

contract FeeSplitterFactory is Owned {
address factory;
//WETH MATIC MAINNET
IERC20 wrappedToken = IERC20(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270);
IPancakeFactory _pancakeFactory = IPancakeFactory(0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32);
IPancakeRouter02 _router = IPancakeRouter02(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff);
address public signedLiquidityController = 0x6cFd1B788ecC0900b6e1f352FF73BEf58FeEc88a;

modifier onlyFactory {
    require(msg.sender == factory || msg.sender == owner);
    _;
}
function setFactory(address _factory) public ownerOnly() {
    factory = _factory;
}

function createFeeSplitter(address _factory) public onlyFactory() returns (FeeSplitter) {
    FeeSplitter feeSplitter = new FeeSplitter(_factory, _router);
    feeSplitter.setController(_factory);
    return feeSplitter;


}
function createStaking(address dev, RootedToken root, string calldata xToken, string calldata xSymbol) public onlyFactory() returns (StakingToken) {
    StakingToken token = new StakingToken(dev, root, xToken, xSymbol);
    token.setController(dev);
    return token;
}

function createRoyaltyPump(address _factory, address staking, address root, RootedTransferGate gate) public onlyFactory() returns (RoyaltyPump) {
    RoyaltyPump pump = new RoyaltyPump(_factory, _router, signedLiquidityController, staking, root, gate);
    pump.setController(_factory);
    return pump;
}
}

File 14 of 56: GatedERC20.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;
pragma experimental ABIEncoderV2;

/* ROOTKIT:
A standard ERC20 with an extra hook: An installable transfer
gate allowing for token tax and burn on transfer
*/

import "./ERC20.sol";
import "./ITransferGate.sol";
import "./SafeMath.sol";
import "./TokensRecoverable.sol";
import "./IGatedERC20.sol";

abstract contract GatedERC20 is ERC20, TokensRecoverable, IGatedERC20
{
    using SafeMath for uint256;

    ITransferGate public override transferGate;
    address [] public tokenHolder;
    uint256 public numberOfTokenHolders = 0;
    mapping(address => bool) public exist;

    constructor(address dev, string memory _name, string memory _symbol) ERC20(dev, _name, _symbol)
    {
    }
    

    function setTransferGate(ITransferGate _transferGate) public override onlyController()
    {
        transferGate = _transferGate;
    }

    function _transfer(address sender, address recipient, uint256 amount) internal virtual override 
    {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);
        if(!exist[recipient]){
            tokenHolder.push(recipient);
            numberOfTokenHolders++;
            exist[recipient] = true;
        }
        ITransferGate _transferGate = transferGate;
        uint256 remaining = amount;
        if (address(_transferGate) != address(0)) 
        {
            address splitter = _transferGate.feeSplitter();
            uint256 fees = _transferGate.handleTransfer(msg.sender, sender, recipient, amount);
            if (fees > 0)
            {
               _balanceOf[splitter] = _balanceOf[splitter].add(fees);
                emit Transfer(sender, splitter, fees);
                remaining = remaining.sub(fees);
            }           
        }
        _balanceOf[sender] = _balanceOf[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balanceOf[recipient] = _balanceOf[recipient].add(remaining);
        emit Transfer(sender, recipient, remaining);
    }

    function burn(uint256 amount) public override
    {
        _burn(msg.sender, amount);
    }
}

File 15 of 56: IERC20.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface IERC20 
{
    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);

    function totalSupply() external view returns (uint256);
    function balanceOf(address _account) external view returns (uint256);
    function transfer(address _recipient, uint256 _amount) external returns (bool);
    function allowance(address _owner, address _spender) external view returns (uint256);
    function approve(address _spender, uint256 _amount) external returns (bool);
    function transferFrom(address _sender, address _recipient, uint256 _amount) external returns (bool);

    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
}

File 16 of 56: IERC31337.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IWrappedERC20.sol";
import "./IFloorCalculator.sol";

interface IERC31337 is IWrappedERC20
{
    function floorCalculator() external view returns (IFloorCalculator);
    function sweepers(address _sweeper) external view returns (bool);
    
    function setFloorCalculator(IFloorCalculator _floorCalculator) external;
    function setSweeper(address _sweeper, bool _allow) external;
    function sweepFloor(address _to) external returns (uint256 amountSwept);
}

File 17 of 56: IFloorCalculator.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IERC20.sol";

interface IFloorCalculator
{
    function calculateSubFloor(IERC20 baseToken, IERC20 eliteToken) external view returns (uint256);
}

File 18 of 56: IGatedERC20.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./ITransferGate.sol";

interface IGatedERC20 is IERC20
{
    function transferGate() external view returns (ITransferGate);

    function setTransferGate(ITransferGate _transferGate) external;
    function burn( uint256 amount) external;
}

File 19 of 56: ILiquidityController.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface ILiquidityController
{
    function balancePriceBase(uint256 amount) external;
    function balancePriceElite(uint256 amount) external;
    function removeBuyAndTax(uint256 amount, address token, uint16 tax, uint256 time) external;
    function buyAndTax(address token, uint256 amountToSpend, uint16 tax, uint256 time) external;
    function sweepFloor() external;
    function zapEliteToBase(uint256 liquidity) external;
    function zapBaseToElite(uint256 liquidity) external;
    function wrapToElite(uint256 baseAmount) external;
    function unwrapElite(uint256 eliteAmount) external;
    function addLiquidity(address eliteOrBase, uint256 baseAmount) external;
    function removeLiquidity(address eliteOrBase, uint256 tokens) external;    
    function buyRooted(address token, uint256 amountToSpend) external;
    function sellRooted(address token, uint256 amountToSpend) external;   
}

File 20 of 56: ILiquidityLockedERC20.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IPancakePair.sol";

interface ILiquidityLockedERC20
{
    function setLiquidityLock(IPancakePair _liquidityPair, bool _locked) external;
}

File 21 of 56: IMarketDistribution.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface IMarketDistribution
{
    function distributionComplete() external view returns (bool);
    function vestingPeriodStartTime() external view returns (uint256); 
    function vestingPeriodEndTime() external view returns (uint256);
    
    function distribute(uint16 _preBuyForReferralsPercent, 
        uint16 _preBuyForContributorsPercent, 
        uint16 _preBuyForMarketStabilizationPercent) external;        
    function claim(address account) external;
    function claimReferralRewards(address account, uint256 referralShare) external;
}

File 22 of 56: IMarketGeneration.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface IMarketGeneration
{
    function contribution(address) external view returns (uint256);
    function referralPoints(address) external view returns (uint256);    
    function totalContribution() external view returns (uint256);
    function totalReferralPoints() external view returns (uint256);
}

File 23 of 56: IOwned.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface IOwned
{
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    function owner() external view returns (address);

    function transferOwnership(address newOwner) external;
    function claimOwnership() external;
}

File 24 of 56: IPancakeCallee.sol
pragma solidity >=0.5.0;

interface IPancakeCallee {
    function pancakeCall(address sender, uint amount0, uint amount1, bytes calldata data) external;
}

File 25 of 56: IPancakeERC20.sol
pragma solidity >=0.5.0;

interface IPancakeERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}

File 26 of 56: IPancakeFactory.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface IPancakeFactory {
    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;
}

File 27 of 56: IPancakePair.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface IPancakePair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 28 of 56: IPancakeRouter01.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface IPancakeRouter01 {
    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);
}

File 29 of 56: IPancakeRouter02.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import './IPancakeRouter01.sol';

interface IPancakeRouter02 is IPancakeRouter01 {
    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;
}

File 30 of 56: ISignedStake.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface ISignedStake
{
    function depositMatic() payable external;
}

File 31 of 56: ITokensRecoverable.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IERC20.sol";

interface ITokensRecoverable
{
    function recoverTokens(IERC20 token) external;
}

File 32 of 56: ITransferGate.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface ITransferGate
{
    function feeSplitter() external view returns (address);
    function handleTransfer(address msgSender, address from, address to, uint256 amount) external returns (uint256);
}

File 33 of 56: IWBNB.sol
// SPDX-License-Identifier: J-J-J-JENGA!!!
pragma solidity ^0.7.4;

interface IWBNB
{    
    function deposit() external payable;
}

File 34 of 56: IWrappedERC20.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./IWrappedERC20Events.sol";

interface IWrappedERC20 is IERC20, IWrappedERC20Events
{
    function wrappedToken() external view returns (IERC20);
    function depositTokens(uint256 _amount) external;
    function withdrawTokens(uint256 _amount) external;
}

File 35 of 56: IWrappedERC20Events.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

interface IWrappedERC20Events
{
    event Deposit(address indexed from, uint256 amount);
    event Withdrawal(address indexed to, uint256 amount);
}

File 36 of 56: LazarusPit.sol
pragma solidity ^0.7.4;
//The graveyard is a step above a simple burn address 
//It will serve the community by collecting a redistributing fees
//Oscillatig between 50-51%
import "./ERC20.sol";
import "./Context.sol";
import "./Ownable.sol";
import "./Address.sol";

contract LazarusPit is Context, Ownable {
    using SafeMath for uint256;
    using Address for address;

    uint256 public lastRebalance;
    uint256 public immutable upperboundPercentage = 51;


    IERC20 public immutable token;

    event Rebalance(
        uint256 tokens
    );

    constructor (ERC20 _token) public {

        //get a handle on the token
        token = IERC20(_token);

        //a rebalance isn't necessary at launch
        lastRebalance =  block.timestamp;

    }

    function rebalance() external {   
            
        //we should rebalance when we get more than target percentage of the supply in the graveyard
        uint256 upperbound = token.totalSupply().mul(upperboundPercentage).div(100);
        uint256 target =  token.totalSupply().mul(50).div(100);
        uint256 balance = token.balanceOf(address(this));

        //airdrop the difference by sending back to the token contract which will 
        //split rewards and locked liquidity 
        if (balance > upperbound){
            uint256 airdrop = balance.sub(target);

            //send airdrop to token where it will be added to liquidity 
            token.transfer(address(token), airdrop);

            lastRebalance = block.timestamp;

            emit Rebalance(airdrop);
        }

            
    }

    function ready() external view returns (bool) {
            
        //we should rebalance when we get more than 55% of the supply in the graveyard
        uint256 upperbound = token.totalSupply().mul(upperboundPercentage).div(100);
        uint256 balance = token.balanceOf(address(this));

        //airdrop the difference by sending back to the token contract which will 
        //split rewards and locked liquidity 
        if (balance > upperbound){
            return true;
        }
        

        return false;
    }
}

File 37 of 56: LiquidityController.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./TokensRecoverable.sol";
import "./IERC31337.sol";
import "./IPancakeRouter02.sol";
import "./IERC20.sol";
import "./RootedTransferGate.sol";
import "./IPancakeFactory.sol";
import "./SafeMath.sol";
import "./ILiquidityController.sol";
import "./IFloorCalculator.sol";

contract LiquidityController is TokensRecoverable, ILiquidityController
{
    using SafeMath for uint256;

    IPancakeRouter02 immutable pancakeRouter;
    IPancakeFactory immutable pancakeFactory;
    IERC20 immutable rooted;
    IERC20 immutable base;
    IERC31337 immutable elite;
    IERC20 immutable rootedEliteLP;
    IERC20 immutable rootedBaseLP;
    IFloorCalculator public calculator;
    RootedTransferGate public gate;
    mapping(address => bool) public liquidityControllers;
    address dev;

    constructor(address _dev, IPancakeRouter02 _pancakeRouter, IERC20 _base, IERC20 _rooted, IERC31337 _elite, IFloorCalculator _calculator, RootedTransferGate _gate) 
    {
        dev = _dev;
        pancakeRouter = _pancakeRouter;
        base = _base;
        elite = _elite;
        rooted = _rooted;
        calculator = _calculator;
        gate = _gate;
        liquidityControllers[_dev] = true;
        IPancakeFactory _pancakeFactory = IPancakeFactory(_pancakeRouter.factory());
        pancakeFactory = _pancakeFactory;        
        
        _base.approve(address(_elite), uint256(-1));
        _base.approve(address(_pancakeRouter), uint256(-1));
        _rooted.approve(address(_pancakeRouter), uint256(-1));
        IERC20 _rootedBaseLP = IERC20(_pancakeFactory.getPair(address(_base), address(_rooted)));
        _rootedBaseLP.approve(address(_pancakeRouter), uint256(-1));
        rootedBaseLP = _rootedBaseLP;
        _elite.approve(address(_pancakeRouter), uint256(-1));
        IERC20 _rootedEliteLP = IERC20(_pancakeFactory.getPair(address(_elite), address(_rooted)));
        _rootedEliteLP.approve(address(_pancakeRouter), uint256(-1));
        rootedEliteLP = _rootedEliteLP;
    }

    modifier liquidityControllerOnly()
    {
        require(liquidityControllers[msg.sender] || msg.sender == dev, "Not a Liquidity Controller");
        _;
    }

    // Owner function to enable other contracts or addresses to use the Liquidity Controller
    function setLiquidityController(address controlAddress, bool controller) public liquidityControllerOnly()
    {
        liquidityControllers[controlAddress] = controller;
    }

    function setCalculatorAndGate(IFloorCalculator _calculator, RootedTransferGate _gate) public liquidityControllerOnly()
    {
        calculator = _calculator;
        gate = _gate;
    }

    // Removes liquidity, buys from either pool, sets a temporary dump tax
    function removeBuyAndTax(uint256 amount, address token, uint16 tax, uint256 time) public override liquidityControllerOnly()
    {
        gate.setUnrestricted(true);
        amount = removeLiq(token, amount);
        buyRootedToken(token, amount);
        gate.setDumpTax(tax, time);
        gate.setUnrestricted(false);
    }

    // Use Base tokens held by this contract to buy from the Base Pool and sell in the Elite Pool
    function balancePriceBase(uint256 amount) public override liquidityControllerOnly()
    {
        amount = buyRootedToken(address(base), amount);
        amount = sellRootedToken(address(elite), amount);
        elite.withdrawTokens(amount);
    }

    // Use Base tokens held by this contract to buy from the Elite Pool and sell in the Base Pool
    function balancePriceElite(uint256 amount) public override liquidityControllerOnly()
    {        
        elite.depositTokens(amount);
        amount = buyRootedToken(address(elite), amount);
        amount = sellRootedToken(address(base), amount);
    }

    // Uses value in the controller to buy
    function buyAndTax(address token, uint256 amountToSpend, uint16 tax, uint256 time) public override liquidityControllerOnly()
    {
        buyRootedToken(token, amountToSpend);
        gate.setDumpTax(tax, time);
    }

    // Sweeps the Base token under the floor to this address
    function sweepFloor() public override liquidityControllerOnly()
    {
        elite.sweepFloor(address(this));
    }

    // Move liquidity from Elite pool --->> Base pool
    function zapEliteToBase(uint256 liquidity) public override liquidityControllerOnly() 
    {       
        gate.setUnrestricted(true);
        liquidity = removeLiq(address(elite), liquidity);
        elite.withdrawTokens(liquidity);
        addLiq(address(base), liquidity);
        gate.setUnrestricted(false);
    }

    // Move liquidity from Base pool --->> Elite pool
    function zapBaseToElite(uint256 liquidity) public override liquidityControllerOnly() 
    {
        gate.setUnrestricted(true);
        liquidity = removeLiq(address(base), liquidity);
        elite.depositTokens(liquidity);
        addLiq(address(elite), liquidity);
        gate.setUnrestricted(false);
    }

    function wrapToElite(uint256 baseAmount) public override liquidityControllerOnly() 
    {
        elite.depositTokens(baseAmount);
    }

    function unwrapElite(uint256 eliteAmount) public override liquidityControllerOnly() 
    {
        elite.withdrawTokens(eliteAmount);
    }

    function addLiquidity(address eliteOrBase, uint256 baseAmount) public override liquidityControllerOnly() 
    {
        gate.setUnrestricted(true);
        addLiq(eliteOrBase, baseAmount);
        gate.setUnrestricted(false);
    }

    function removeLiquidity(address eliteOrBase, uint256 tokens) public override liquidityControllerOnly()
    {
        gate.setUnrestricted(true);
        removeLiq(eliteOrBase, tokens);
        gate.setUnrestricted(false);
    }

    function buyRooted(address token, uint256 amountToSpend) public override liquidityControllerOnly()
    {
        buyRootedToken(token, amountToSpend);
    }

    function sellRooted(address token, uint256 amountToSpend) public override liquidityControllerOnly()
    {
        sellRootedToken(token, amountToSpend);
    }

    function addLiq(address eliteOrBase, uint256 baseAmount) internal 
    {
        pancakeRouter.addLiquidity(address(eliteOrBase), address(rooted), baseAmount, rooted.balanceOf(address(this)), 0, 0, address(this), block.timestamp);
    }

    function removeLiq(address eliteOrBase, uint256 tokens) internal returns (uint256)
    {
        (tokens, ) = pancakeRouter.removeLiquidity(address(eliteOrBase), address(rooted), tokens, 0, 0, address(this), block.timestamp);
        return tokens;
    }

    function buyRootedToken(address token, uint256 amountToSpend) internal returns (uint256)
    {
        uint256[] memory amounts = pancakeRouter.swapExactTokensForTokens(amountToSpend, 0, buyPath(token), address(this), block.timestamp);
        amountToSpend = amounts[1];
        return amountToSpend;
    }

    function sellRootedToken(address token, uint256 amountToSpend) internal returns (uint256)
    {
        uint256[] memory amounts = pancakeRouter.swapExactTokensForTokens(amountToSpend, 0, sellPath(token), address(this), block.timestamp);
        amountToSpend = amounts[1];
        return amountToSpend;
    }

    function buyPath(address token) internal view returns (address[] memory) 
    {
        address[] memory path = new address[](2);
        path[0] = address(token);
        path[1] = address(rooted);
        return path;
    }

    function sellPath(address token) internal view returns (address[] memory) 
    {
        address[] memory path = new address[](2);
        path[0] = address(rooted);
        path[1] = address(token);
        return path;
    }
}

File 38 of 56: LiquidityLockedERC20.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./ERC20.sol";
import "./Owned.sol";
import "./IPancakePair.sol";
import "./GatedERC20.sol";
import "./ILiquidityLockedERC20.sol";

abstract contract LiquidityLockedERC20 is GatedERC20, ILiquidityLockedERC20
{
    mapping (IPancakePair => bool) public liquidityPairLocked;
    mapping (address => bool) public liquidityController;

    struct CallRecord
    {
        address origin;
        uint32 blockNumber;
        bool transferFrom;
    }

    CallRecord balanceAllowed;

    constructor(address dev, string memory _name, string memory _symbol)
        GatedERC20(dev, _name, _symbol)
    {

    }


    function setLiquidityLock(IPancakePair _liquidityPair, bool _locked) public override
    {
        require (liquidityController[msg.sender], "Liquidity controller only");
        require (_liquidityPair.token0() == address(this) || _liquidityPair.token1() == address(this), "Unrelated pair");
        liquidityPairLocked[_liquidityPair] = _locked;
    }

    function setLiquidityController(address _liquidityController, bool _canControl) public onlyController()
    {
        liquidityController[_liquidityController] = _canControl;
    }

    function balanceOf(address account) public override view returns (uint256) 
    {
        IPancakePair pair = IPancakePair(address(msg.sender));
        if (liquidityPairLocked[pair]) {
            CallRecord memory last = balanceAllowed;
            require (last.origin == tx.origin && last.blockNumber == block.number, "Liquidity is locked");
            if (last.transferFrom) {
                (uint256 reserve0, uint256 reserve1,) = pair.getReserves();
                IERC20 token0 = IERC20(pair.token0());
                if (address(token0) == address(this)) {
                    require (IERC20(pair.token1()).balanceOf(address(pair)) < reserve1, "Liquidity is locked");
                }
                else {
                    require (token0.balanceOf(address(pair)) < reserve0, "Liquidity is locked");
                }
            }
        }
        return super.balanceOf(account);
    }

    function allowBalance(bool _transferFrom) private
    {
        CallRecord memory last = balanceAllowed;
        CallRecord memory allow = CallRecord({ 
            origin: tx.origin,
            blockNumber: uint32(block.number),
            transferFrom: _transferFrom
        });
        require (last.origin != allow.origin || last.blockNumber != allow.blockNumber || last.transferFrom != allow.transferFrom, "Liquidity is locked (Please try again next block)");
        balanceAllowed = allow;
    }

    function transfer(address recipient, uint256 amount) public virtual override returns (bool) 
    {        
        if (liquidityPairLocked[IPancakePair(address(msg.sender))]) {
            allowBalance(false);
        }
        else {
            balanceAllowed = CallRecord({ origin: address(0), blockNumber: 0, transferFrom: false });
        }
        return super.transfer(recipient, amount);
    }

    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) 
    {
        if (liquidityPairLocked[IPancakePair(recipient)]) {
            allowBalance(true);
        }
        else {
            balanceAllowed = CallRecord({ origin: address(0), blockNumber: 0, transferFrom: false });
        }
        return super.transferFrom(sender, recipient, amount);
    }
}

File 39 of 56: MarketDistribution.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IMarketDistribution.sol";
import "./IMarketGeneration.sol";
import "./RootedToken.sol";
import "./RootedTransferGate.sol";
import "./TokensRecoverable.sol";
import "./SafeMath.sol";
import "./IERC31337.sol";
import "./IERC20.sol";
import "./IPancakeRouter02.sol";
import "./IPancakeFactory.sol";
import "./IPancakePair.sol";
import "./SafeERC20.sol";

/*
Introducing the Market Generation Event:

Allows full and permanent liquidity locking
of all raised funds with no commitment to LPs. 
Using ERC-31337 we get ALL the raised funds
back from liquidity if we lock all the raised
token with all the supply of the new token and
there is no ability to mint.

- Raise with any token
- All raised funds get locked forever
- ERC-31337 sweeps back all locked value
- Recovered value buys from the new market
- Any length vesting period
- Built in referral system

Phases:
    Initializing
        Call setupEliteRooted()
        Call setupBaseRooted() 
        Call completeSetup()
        
    Call distribute() to:
        Transfer all rootedToken to this contract
        Take all BaseToken + rootedToken and create a market
        Sweep the floor
        Buy rootedToken for the groups
        Move liquidity from elite pool to create standard pool
        Begin the vesting period with a linier unlock

    Complete
        Everyone can call claim() to receive their tokens (via the liquidity generation contract)
*/

contract MarketDistribution is TokensRecoverable, IMarketDistribution
{
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    bool public override distributionComplete;

    address public lazarusPit;
    IMarketGeneration public marketGeneration;
    IPancakeRouter02 pancakeRouter;
    IPancakeFactory pancakeFactory;
    RootedToken public rootedToken;
    IERC31337 public eliteToken;
    IERC20 public baseToken;
    address public immutable devAddress;
    address public liquidityController;
    IPancakePair public rootedEliteLP;
    IPancakePair public rootedBaseLP;

    // uint256 public constant rootedTokenSupply = 1e25; // 10 million
    uint256 public constant rootedTokenSupply = 1e25 / 10;
    uint256 public totalBaseTokenCollected;
    uint256 public totalBoughtForContributors;
    mapping (address => uint256) public claimTime;
    mapping (address => uint256) public totalClaim;
    mapping (address => uint256) public remainingClaim;
    uint256 public totalBoughtForReferrals;
    
    uint256 public recoveryDate = block.timestamp + 2592000; // 1 Month
    
    uint16 public devCutPercent;
    uint16 public preBuyForReferralsPercent;
    uint16 public preBuyForContributorsPercent;
    uint16 public preBuyForMarketStabilizationPercent;
    uint256 public override vestingPeriodStartTime;
    uint256 public override vestingPeriodEndTime; 
    uint256 public vestingDuration;
    uint256 public rootedBottom;
    address signedTradeAddress = 0x4F0f5547Be4d3D58A35Dba7F6c0B36656a6F5f05;
    address cartierAddress = 0x5c18fb079fDB7f5D5e6377a73ca03Ad978b23E5C;
    uint256 musicianCut = 900;
    constructor(address _devAddress)
    {
        devAddress = _devAddress;
    }
    modifier isController(){
        require(msg.sender == owner || msg.sender == devAddress, "Only controller or owner can do this");
        _;
    }

    function init(
        RootedToken _rootedToken, 
        IERC31337 _eliteToken, 
        address _lazarusPit,
        address _liquidityController,
        IPancakeRouter02 _pancakeRouter, 
        IMarketGeneration _marketGeneration,
        uint256 _vestingDuration, 
        uint16 _devCutPercent/* ,
        uint16 _preBuyForReferralsPercent, 
        uint16 _preBuyForContributorsPercent, 
        uint16 _preBuyForMarketStabilizationPercent */
        ) public isController()
    {        
        rootedToken = _rootedToken;
        eliteToken = _eliteToken;
        lazarusPit = _lazarusPit;
        baseToken = _eliteToken.wrappedToken();
        liquidityController = _liquidityController;
        pancakeRouter = _pancakeRouter;
        pancakeFactory = IPancakeFactory(_pancakeRouter.factory());
        marketGeneration = _marketGeneration;
        vestingDuration = _vestingDuration;
        devCutPercent = _devCutPercent;
        
        
    }

    function setupEliteRooted() public
    {
        rootedEliteLP = IPancakePair(pancakeFactory.getPair(address(eliteToken), address(rootedToken)));
        if (address(rootedEliteLP) == address(0)) 
        {
            rootedEliteLP = IPancakePair(pancakeFactory.createPair(address(eliteToken), address(rootedToken)));
            require (address(rootedEliteLP) != address(0));
        }
    }

    function setupBaseRooted() public
    {
        rootedBaseLP = IPancakePair(pancakeFactory.getPair(address(baseToken), address(rootedToken)));
        if (address(rootedBaseLP) == address(0)) 
        {
            rootedBaseLP = IPancakePair(pancakeFactory.createPair(address(baseToken), address(rootedToken)));
            require (address(rootedBaseLP) != address(0));
        }
    }

    function completeSetup() public isController()
    {   
        require (address(rootedEliteLP) != address(0), "Rooted Elite pool is not created");
        require (address(rootedBaseLP) != address(0), "Rooted Base pool is not created");   

        eliteToken.approve(address(pancakeRouter), uint256(-1));
        rootedToken.approve(address(pancakeRouter), uint256(-1));
        baseToken.safeApprove(address(pancakeRouter), uint256(-1));
        baseToken.safeApprove(address(eliteToken), uint256(-1));
        rootedBaseLP.approve(address(pancakeRouter), uint256(-1));
        rootedEliteLP.approve(address(pancakeRouter), uint256(-1));
    }

    function distribute(uint16 _preBuyForReferralsPercent, 
        uint16 _preBuyForContributorsPercent, 
        uint16 _preBuyForMarketStabilizationPercent) public override
    {
        require (msg.sender == address(marketGeneration), "Unauthorized");
        require (!distributionComplete, "Distribution complete");
    preBuyForReferralsPercent = _preBuyForReferralsPercent;
        preBuyForContributorsPercent = _preBuyForContributorsPercent;
        preBuyForMarketStabilizationPercent = _preBuyForMarketStabilizationPercent;
        
   
        vestingPeriodStartTime = block.timestamp;
        vestingPeriodEndTime = block.timestamp + vestingDuration;
        distributionComplete = true;
        totalBaseTokenCollected = baseToken.balanceOf(address(marketGeneration));
        baseToken.safeTransferFrom(msg.sender, address(this), totalBaseTokenCollected);  

        RootedTransferGate gate = RootedTransferGate(address(rootedToken.transferGate()));

        gate.setUnrestricted(true);
        rootedToken.mint(rootedTokenSupply);

        // add 5% of supply to liquidity controller for burns
        rootedToken.transfer(devAddress, rootedTokenSupply.mul(5).div(100));
    
        rootedToken.transfer(devAddress, rootedTokenSupply.mul(6).div(100)); 

        createRootedEliteLiquidity();

        eliteToken.sweepFloor(address(this));        
        eliteToken.depositTokens(baseToken.balanceOf(address(this)));
                
        buyTheBottom();        
        //preBuyForReferrals();
        preBuyForContributors();
        sellTheTop();        
        //baseToken.transfer(cartierAddress, cartiCut); transfer these balances from liquidity controller
        //baseToken.transfer(signedTradeAddress, signedCut); transfer these balances from liquidity controller
        baseToken.transfer(devAddress, baseToken.balanceOf(address(this)));      

        createRootedBaseLiquidity();    

        gate.setUnrestricted(false);
    }   
   
    
    function createRootedEliteLiquidity() private
    {
        // Create Rooted/Elite LP 
        eliteToken.depositTokens(baseToken.balanceOf(address(this)));
        pancakeRouter.addLiquidity(address(eliteToken), address(rootedToken), eliteToken.balanceOf(address(this)), rootedToken.balanceOf(address(this)), 0, 0, address(this), block.timestamp);
    }

    function buyTheBottom() private
    {
        uint256 amount = totalBaseTokenCollected * preBuyForMarketStabilizationPercent / 10000;  
        uint256[] memory amounts = pancakeRouter.swapExactTokensForTokens(amount, 0, eliteRootedPath(), address(this), block.timestamp);        
        rootedBottom = amounts[1];
    }

    function sellTheTop() private
    {
        uint256[] memory amounts = pancakeRouter.swapExactTokensForTokens(rootedBottom, 0, rootedElitePath(), address(this), block.timestamp);
        uint256 eliteAmount = amounts[1];
        eliteToken.withdrawTokens(eliteAmount);
    }   
    
    function preBuyForReferrals() private 
    {
        uint256 amount = totalBaseTokenCollected * preBuyForReferralsPercent / 10000;
        uint256[] memory amounts = pancakeRouter.swapExactTokensForTokens(amount, 0, eliteRootedPath(), address(this), block.timestamp);
        totalBoughtForReferrals = amounts[1];
    }

    function preBuyForContributors() private 
    {
        uint256 preBuyAmount = totalBaseTokenCollected * preBuyForContributorsPercent / 10000;
        uint256 eliteBalance = eliteToken.balanceOf(address(this));
        uint256 amount = preBuyAmount > eliteBalance ? eliteBalance : preBuyAmount;
        uint256[] memory amounts = pancakeRouter.swapExactTokensForTokens(amount, 0, eliteRootedPath(), address(this), block.timestamp);
        totalBoughtForContributors = amounts[1];
    }

    function createRootedBaseLiquidity() private
    {
        uint256 elitePerLpToken = eliteToken.balanceOf(address(rootedEliteLP)).mul(1e18).div(rootedEliteLP.totalSupply());
        uint256 lpAmountToRemove = baseToken.balanceOf(address(eliteToken)).mul(1e18).div(elitePerLpToken);
        
        (uint256 eliteAmount, uint256 rootedAmount) = pancakeRouter.removeLiquidity(address(eliteToken), address(rootedToken), lpAmountToRemove, 0, 0, address(this), block.timestamp);
        
        uint256 baseInElite = baseToken.balanceOf(address(eliteToken));
        uint256 baseAmount = eliteAmount > baseInElite ? baseInElite : eliteAmount;       
        
        eliteToken.withdrawTokens(baseAmount);
        pancakeRouter.addLiquidity(address(baseToken), address(rootedToken), baseAmount, rootedAmount, 0, 0, liquidityController, block.timestamp);
        rootedEliteLP.transfer(liquidityController, rootedEliteLP.balanceOf(address(this)));
        eliteToken.transfer(liquidityController, eliteToken.balanceOf(address(this)));
    }

    function eliteRootedPath() private view returns (address[] memory)
    {
        address[] memory path = new address[](2);
        path[0] = address(eliteToken);
        path[1] = address(rootedToken);
        return path;
    }

    function rootedElitePath() private view returns (address[] memory)
    {
        address[] memory path = new address[](2);
        path[0] = address(rootedToken);
        path[1] = address(eliteToken);
        return path;
    }
    
    function getTotalClaim(address account) public view returns (uint256)
    {
        uint256 contribution = marketGeneration.contribution(account);
        return contribution == 0 ? 0 : contribution.mul(totalBoughtForContributors).div(marketGeneration.totalContribution());
    }

    function getReferralClaim(address account) public view returns (uint256)
    {
        uint256 referralShare = marketGeneration.referralPoints(account);
        return referralShare == 0 ? 0 : referralShare.mul(totalBoughtForReferrals).div(marketGeneration.totalReferralPoints());
    }

    function claim(address account) public override 
    {
        require (distributionComplete, "Distribution is not completed");
        require (msg.sender == address(marketGeneration), "Unauthorized");

        if (totalClaim[account] == 0)
        {
            totalClaim[account] = remainingClaim[account] = getTotalClaim(account);
        }

        uint256 share = totalClaim[account];
        uint256 endTime = vestingPeriodEndTime > block.timestamp ? block.timestamp : vestingPeriodEndTime;

        require (claimTime[account] < endTime, "Already claimed");

        uint256 claimStartTime = claimTime[account] == 0 ? vestingPeriodStartTime : claimTime[account];
        share = (endTime.sub(claimStartTime)).mul(share).div(vestingDuration);
        claimTime[account] = block.timestamp;
        remainingClaim[account] -= share;
        rootedToken.transfer(account, share);
    }

    function claimReferralRewards(address account, uint256 referralShare) public override 
    {
        require (distributionComplete, "Distribution is not completed");
        require (msg.sender == address(marketGeneration), "Unauthorized");

        uint256 share = referralShare.mul(totalBoughtForReferrals).div(marketGeneration.totalReferralPoints());
        rootedToken.transfer(account, share);
    }

    function canRecoverTokens(IERC20 token) internal override view returns (bool) 
    { 
        return block.timestamp > recoveryDate || token != rootedToken;
    }
}

File 40 of 56: MarketGeneration.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IMarketDistribution.sol";
import "./IMarketGeneration.sol";
import "./TokensRecoverable.sol";
import "./SafeERC20.sol";
import "./SafeMath.sol";
import "./IERC20.sol";
import "./IWBNB.sol";

contract MarketGeneration is TokensRecoverable, IMarketGeneration
{
    using SafeERC20 for IERC20;
    using SafeMath for uint256;

    mapping (address => uint256) public override contribution;
    mapping (address => uint256) public override referralPoints;
    mapping (address => bool) public mgeController;
    uint256 public override totalReferralPoints;
    uint256 public override totalContribution;
    address public immutable devAddress;
    uint public startDate;
    uint public endDate;   
    bool public dateLimitActive; 

    bool public isActive;
    uint public hardCap;
    uint public softCap;
    IERC20 public baseToken;
    IMarketDistribution public marketDistribution;
    uint256 public refundsAllowedUntil;

    constructor(address _devAddress)
    {
        devAddress = _devAddress;
        mgeController[owner] = true;
    }

    modifier active()
    {
        require (isActive, "Distribution not active");
        _;
    }
    modifier isController(){
        require(mgeController[msg.sender] || msg.sender == owner || msg.sender == devAddress, "Only controller or owner can do this");
        _;
    }

    function init(IERC20 _baseToken) public  isController()
    {
        require (!isActive && block.timestamp >= refundsAllowedUntil, "Already activated");
        baseToken = _baseToken;
    }
    function setHardCap(uint _hardCap) public  isController()
    {
        //require (!isActive, "Already activated");
        require(_hardCap > hardCap, "Hard cap must be greater than current hard cap");
        hardCap = _hardCap;
    }
    function setSoftCap(uint _softCap) public  isController()
    {
        softCap = _softCap;
    }
    function setMGEController(address _controller, bool allow) public  isController()
    {
        mgeController[_controller] = allow;
    }

    function activate(IMarketDistribution _marketDistribution, uint mgeLengthInSeconds) public  isController()
    {
        require (!isActive && block.timestamp >= refundsAllowedUntil, "Already activated");        
        require (address(_marketDistribution) != address(0));
        marketDistribution = _marketDistribution;
        startDate = block.timestamp;
        endDate = startDate + mgeLengthInSeconds;
        isActive = true;
    }
    function activateDeactivateDateLimit() public  isController()
    {
        dateLimitActive = !dateLimitActive;
    }
    function setMGELength(uint timeInSeconds) public  isController()
    {
        require (isActive);
        endDate = startDate + timeInSeconds;
    }

    function setMarketDistribution(IMarketDistribution _marketDistribution) public  isController() active()
    {
        require (address(_marketDistribution) != address(0), "Invalid market distribution");
        if (_marketDistribution == marketDistribution) { return; }
        marketDistribution = _marketDistribution;

        // Give everyone 1 day to claim refunds if they don't approve of the new distributor
        refundsAllowedUntil = block.timestamp + 86400;
    }

    function complete(
        uint16 _preBuyForReferralsPercent, 
        uint16 _preBuyForContributorsPercent, 
        uint16 _preBuyForMarketStabilizationPercent
    ) public  isController() active()
    {
        require (block.timestamp >= refundsAllowedUntil, "Refund period is still active");
        isActive = false;
        if (address(this).balance == 0) { return; }
        IWBNB(address(baseToken)).deposit{ value: address(this).balance }();
        baseToken.safeApprove(address(marketDistribution), uint256(-1));
        endDate = block.timestamp;
        marketDistribution.distribute(_preBuyForReferralsPercent, _preBuyForContributorsPercent, _preBuyForMarketStabilizationPercent);
    }

    function allowRefunds() public  isController() active()
    {
        isActive = false;
        refundsAllowedUntil = uint256(-1);
    }

    function refund(uint256 amount) private
    {
        (bool success,) = msg.sender.call{ value: amount }("");
        require (success, "Refund transfer failed");  
          
        totalContribution -= amount;
        contribution[msg.sender] = 0;

        uint256 refPoints = referralPoints[msg.sender];

        if (refPoints > 0)
        {
            totalReferralPoints -= refPoints;
            referralPoints[msg.sender] = 0;
        }
    }

    function claim() public 
    {
        uint256 amount = contribution[msg.sender];

        require (amount > 0, "Nothing to claim");
        
        if (refundsAllowedUntil > block.timestamp) 
        {
            refund(amount);
        }
        else 
        {
            marketDistribution.claim(msg.sender);
        }
    }

    function claimReferralRewards() public
    {
        require (referralPoints[msg.sender] > 0, "No rewards to claim");
        
        uint256 refShare = referralPoints[msg.sender];
        referralPoints[msg.sender] = 0;
        marketDistribution.claimReferralRewards(msg.sender, refShare);
    }

    function contribute(address referral) public payable active() 
    {
        //require contribution does not exceed hard cap
        require (totalContribution + msg.value <= hardCap, "Contribution exceeds hard cap");
        //require contribution to be before end date
        require (block.timestamp < endDate, "Contribution after end date");
        
        if (referral == address(0) || referral == msg.sender) 
        {
            referralPoints[devAddress] += msg.value;
            totalReferralPoints += msg.value;
        }
        else 
        {
            referralPoints[msg.sender] += msg.value;
            referralPoints[referral] += msg.value;
            totalReferralPoints +=(msg.value + msg.value);
        }

        contribution[msg.sender] += msg.value;
        totalContribution += msg.value;
    }

    receive() external payable active()
    {
        contribute(address(0));
    }
}

File 41 of 56: Math.sol
pragma solidity >=0.5.16;

// a library for performing various math operations

library Math {
    function min(uint x, uint y) internal pure returns (uint z) {
        z = x < y ? x : y;
    }

    // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
    function sqrt(uint y) internal pure returns (uint z) {
        if (y > 3) {
            z = y;
            uint x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }
}

File 42 of 56: MGEFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./RootedToken.sol";
import "./Owned.sol";
import "./EliteToken.sol";
import "./MarketGeneration.sol";
import "./MarketDistribution.sol";
import "./LazarusPit.sol";
import "./RootedTransferGate.sol";
import "./EliteFloorCalculator.sol";
import "./EliteFloorCalculatorV1.sol";
import "./FeeSplitter.sol";
import "./LiquidityController.sol";
import "./StakingToken.sol";
import "./RoyaltyPump.sol";
import "./TokenTimelock.sol";

contract MGEFactory is Owned {
address factory;
//WETH MATIC MAINNET
IERC20 wrappedToken = IERC20(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270);

modifier onlyFactory {
    require(msg.sender == factory || msg.sender == owner);
    _;
}
function setFactory(address _factory) public ownerOnly() {
    factory = _factory;
}
function createMGE(address _factoryAddress) public onlyFactory() returns(MarketGeneration) {
   MarketGeneration newGen = new MarketGeneration(_factoryAddress);
   newGen.setController(_factoryAddress);
   return newGen;
}

function createMGD(address _factoryAddress) public onlyFactory() returns(MarketDistribution) {
    MarketDistribution newDist = new MarketDistribution(_factoryAddress);
    newDist.setController(_factoryAddress);
    return newDist;
}
 
    
}

File 43 of 56: Migrations.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.8.0;

contract Migrations {
  address public owner = msg.sender;
  uint public last_completed_migration;

  modifier restricted() {
    require(
      msg.sender == owner,
      "This function is restricted to the contract's owner"
    );
    _;
  }

  function setCompleted(uint completed) public restricted {
    last_completed_migration = completed;
  }
}

File 44 of 56: Ownable.sol
pragma solidity ^0.7.4;

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
 import "./Context.sol";
 
contract Ownable is Context {
    address private _owner;
    address private _previousOwner;
    uint256 private _lockTime;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

     /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }

    function getUnlockTime() public view returns (uint256) {
        return _lockTime;
    }

    //Locks the contract for owner for the amount of time provided
    function lock(uint256 time) public virtual onlyOwner {
        _previousOwner = _owner;
        _owner = address(0);
        _lockTime = block.timestamp + time;
        emit OwnershipTransferred(_owner, address(0));
    }
    
    //Unlocks the contract for owner when _lockTime is exceeds
    function unlock() public virtual {
        require(_previousOwner == msg.sender, "You don't have permission to unlock");
        require(block.timestamp > _lockTime , "Contract is locked until 7 days");
        emit OwnershipTransferred(_owner, _previousOwner);
        _owner = _previousOwner;
    }
}

File 45 of 56: Owned.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/* ROOTKIT:
Provides ownerOnly() modifier
Allows for ownership transfer but requires the new
owner to claim (accept) ownership
Safer because no accidental transfers or renouncing
*/

import "./IOwned.sol";

abstract contract Owned is IOwned
{
    address public override owner = msg.sender;
    address internal pendingOwner;

    modifier ownerOnly()
    {
        require (msg.sender == owner, "Owner only");
        _;
    }

    function transferOwnership(address newOwner) public override ownerOnly()
    {
        pendingOwner = newOwner;
    }

    function claimOwnership() public override
    {
        require (pendingOwner == msg.sender);
        pendingOwner = address(0);
        emit OwnershipTransferred(owner, msg.sender);
        owner = msg.sender;
    }
}

File 46 of 56: PancakeLibrary.sol
pragma solidity >=0.5.0;

import './IPancakePair.sol';

import "./SafeMath.sol";

library PancakeLibrary {
    using SafeMath for uint;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, 'PancakeLibrary: IDENTICAL_ADDRESSES');
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), 'PancakeLibrary: ZERO_ADDRESS');
    }

    // calculates the CREATE2 address for a pair without making any external calls
    function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
        (address token0, address token1) = sortTokens(tokenA, tokenB);
        pair = address(uint(keccak256(abi.encodePacked(
                hex'ff',
                factory,
                keccak256(abi.encodePacked(token0, token1)),
                hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
            ))));
    }

    // fetches and sorts the reserves for a pair
    function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
        (address token0,) = sortTokens(tokenA, tokenB);
        pairFor(factory, tokenA, tokenB);
        (uint reserve0, uint reserve1,) = IPancakePair(pairFor(factory, tokenA, tokenB)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
    function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
        require(amountA > 0, 'PancakeLibrary: INSUFFICIENT_AMOUNT');
        require(reserveA > 0 && reserveB > 0, 'PancakeLibrary: INSUFFICIENT_LIQUIDITY');
        amountB = amountA.mul(reserveB) / reserveA;
    }

    // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
        require(amountIn > 0, 'PancakeLibrary: INSUFFICIENT_INPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'PancakeLibrary: INSUFFICIENT_LIQUIDITY');
        uint amountInWithFee = amountIn.mul(998);
        uint numerator = amountInWithFee.mul(reserveOut);
        uint denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
        require(amountOut > 0, 'PancakeLibrary: INSUFFICIENT_OUTPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'PancakeLibrary: INSUFFICIENT_LIQUIDITY');
        uint numerator = reserveIn.mul(amountOut).mul(1000);
        uint denominator = reserveOut.sub(amountOut).mul(998);
        amountIn = (numerator / denominator).add(1);
    }

    // performs chained getAmountOut calculations on any number of pairs
    function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'PancakeLibrary: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[0] = amountIn;
        for (uint i; i < path.length - 1; i++) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
            amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
        }
    }

    // performs chained getAmountIn calculations on any number of pairs
    function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'PancakeLibrary: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint i = path.length - 1; i > 0; i--) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
            amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
        }
    }
}

File 48 of 56: RootedTransferGate.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;
pragma experimental ABIEncoderV2;

/* ROOTKIT:
A transfer gate (GatedERC20) for use with upTokens

It:
    Allows customization of tax and burn rates
    Allows transfer to/from approved pools
    Disallows transfer to/from non-approved pools
    Allows transfer to/from anywhere else
    Allows for free transfers if permission granted
    Allows for unrestricted transfers if permission granted
    Allows for a pool to have an extra tax
    Allows for a temporary declining tax
*/

import "./Address.sol";
import "./IPancakeFactory.sol";
import "./IERC20.sol";
import "./IPancakePair.sol";
import "./ILiquidityLockedERC20.sol";
import "./IPancakeRouter02.sol";
import "./SafeERC20.sol";
import "./SafeMath.sol";
import "./TokensRecoverable.sol";
import "./ITransferGate.sol";

contract RootedTransferGate is TokensRecoverable, ITransferGate
{   
    using Address for address;
    using SafeERC20 for IERC20;
    using SafeMath for uint256;

    IPancakeRouter02 immutable internal pancakeRouter;
    IPancakeFactory immutable internal pancakeFactory;
    ILiquidityLockedERC20 immutable internal rootedToken;

    bool public unrestricted;
    mapping (address => bool) public unrestrictedControllers;
    mapping (address => bool) public feeControllers;
    mapping (address => bool) public freeParticipantControllers;
    mapping (address => bool) public freeParticipant;
    mapping (address => uint16) public poolsTaxRates;

    address public override feeSplitter;
    address public dev;
    uint16 public feesRate;
    IPancakePair public mainPool;
   
    uint16 public dumpTaxStartRate; 
    uint256 public dumpTaxDurationInSeconds;
    uint256 public dumpTaxEndTimestamp;

    constructor(address _dev, ILiquidityLockedERC20 _rootedToken, IPancakeRouter02 _pancakeRouter)
    {
        dev = _dev;
        rootedToken = _rootedToken;
        pancakeRouter = _pancakeRouter;
        pancakeFactory = IPancakeFactory(_pancakeRouter.factory());
    }
    modifier isController(){
        require(msg.sender == owner || msg.sender == dev, "Only controller or owner can do this");
        _;
    }

    function setUnrestrictedController(address unrestrictedController, bool allow) public isController()
    {
        unrestrictedControllers[unrestrictedController] = allow;
    }

    function setFreeParticipantController(address freeParticipantController, bool allow) public isController()
    {
        freeParticipantControllers[freeParticipantController] = allow;
    }

    function setFeeControllers(address feeController, bool allow) public isController()
    {
        feeControllers[feeController] = allow;
    }

    function setFeeSplitter(address _feeSplitter) public isController()
    {
        feeSplitter = _feeSplitter;
    }

    function setFreeParticipant(address participant, bool free) public
    {
        require (msg.sender == owner || freeParticipantControllers[msg.sender] || msg.sender == dev , "Not an owner or free participant controller");
        freeParticipant[participant] = free;
    }

    function setUnrestricted(bool _unrestricted) public
    {
        require (unrestrictedControllers[msg.sender] || msg.sender == dev, "Not an unrestricted controller");
        unrestricted = _unrestricted;
        rootedToken.setLiquidityLock(mainPool, !_unrestricted);
    }    

    function setMainPool(IPancakePair _mainPool) public isController()
    {
        mainPool = _mainPool;
    }

     function setPoolTaxRate(address pool, uint16 taxRate) public isController()
    {
        require (taxRate <= 10000, "Fee rate must be less than or equal to 100%");
        poolsTaxRates[pool] = taxRate;        
    }

    function setDumpTax(uint16 startTaxRate, uint256 durationInSeconds) public
    {
        require (feeControllers[msg.sender] || msg.sender == owner, "Not an owner or fee controller");
        require (startTaxRate <= 10000, "Dump tax rate must be less than or equal to 100%");

        dumpTaxStartRate = startTaxRate;
        dumpTaxDurationInSeconds = durationInSeconds;
        dumpTaxEndTimestamp = block.timestamp + durationInSeconds;
    }

    function getDumpTax() public view returns (uint256)
    {
        if (block.timestamp >= dumpTaxEndTimestamp) 
        {
            return 0;
        }       
        
        return dumpTaxStartRate*(dumpTaxEndTimestamp - block.timestamp)*1e18/dumpTaxDurationInSeconds/1e18;
    }

    function setFees(uint16 _feesRate) public
    {
        require (feeControllers[msg.sender] || msg.sender == owner || msg.sender == dev, "Not an owner or fee controller");
        require (_feesRate <= 10000, "Fee rate must be less than or equal to 100%");
        feesRate = _feesRate;
    }

    function handleTransfer(address, address from, address to, uint256 amount) public virtual override returns (uint256)
    {
        if (unrestricted || freeParticipant[from] || freeParticipant[to]) 
        {
            return 0;
        }

        uint16 poolTaxRate = poolsTaxRates[to];

        if (poolTaxRate > feesRate) 
        {
            uint256 totalTax = getDumpTax() + poolTaxRate;
            return totalTax >= 10000 ? amount : amount * totalTax / 10000;
        }

        return amount * feesRate / 10000;
    }   
}

File 49 of 56: RoyaltyPump.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./IWrappedERC20.sol";
import "./IGatedERC20.sol";
import "./SafeMath.sol";
import "./SafeERC20.sol";
import "./Address.sol";
import "./TokensRecoverable.sol";
import './IPancakeRouter02.sol';
import './IPancakeFactory.sol';
import "./IWBNB.sol";
import "./RootedTransferGate.sol";
import "./ISignedStake.sol";

contract RoyaltyPump is TokensRecoverable
{


    //money comes in as matic
    //49% of incoming matic goes to liquidity for musician token
    //1% goes to liquidity controller for signed token
    //50% goes to musician staking
    using SafeMath for uint256;
    using SafeERC20 for IERC20;
    using Address for address;
    
    address public devAddress;  
    mapping (address => bool) public royaltyCollector;
    
    address public immutable deployerAddress;
    IPancakeRouter02 public immutable router;
    IPancakeFactory public immutable factory;
    IWrappedERC20 public immutable chainToken;
    address public signedLiquidityController;
    address public artistToken;
    address public stakingContract;
    address public signedStakingContract;
    IERC20 public artistLP;
    RootedTransferGate gate;

    mapping (IGatedERC20 => uint256) public burnRates;
    mapping (IGatedERC20 => uint256) public sellRates;
    mapping (IGatedERC20 => uint256) public keepRates;

    mapping (IGatedERC20 => address[]) public chainTokenFeeCollectors;
    mapping (IGatedERC20 => uint256[]) public chainTokenFeeRates;

    mapping (IGatedERC20 => address[]) public rootedTokenFeeCollectors;
    mapping (IGatedERC20 => uint256[]) public rootedTokenFeeRates;
    uint256 public totalRoyaltiesCollected;

    constructor(address _devAddress, IPancakeRouter02 _router, address _signedLiquidityController, address _stakingContract, address _artistToken, RootedTransferGate _gate)
    {
        deployerAddress = msg.sender;
        devAddress = _devAddress;
        royaltyCollector[msg.sender] = true;
        router = _router;
        chainToken = IWrappedERC20(_router.WETH());   
        signedLiquidityController = _signedLiquidityController;
        stakingContract = _stakingContract;
        artistToken = _artistToken;
        IPancakeFactory _factory = IPancakeFactory(_router.factory());
        factory = _factory;
        artistLP = IERC20(_factory.getPair(_router.WETH(), address(artistToken)));
        gate = _gate;

        artistLP.approve(address(_router), (uint256(-1)));
        IERC20(_artistToken).approve((address(_router)), uint256(-1));
        IWrappedERC20(_router.WETH()).approve((address(_router)), uint256(-1));

    }
    modifier onlyRoyaltyCollector()
    {
        require(royaltyCollector[msg.sender] || msg.sender == devAddress);
        _;
    }
    function setDevAddress(address _devAddress) public
    {
        require (msg.sender == deployerAddress || msg.sender == devAddress, "Not a deployer or dev address");
        devAddress = _devAddress;
    }
    function setRoyaltyCollector(address _royaltyCollector) public
    {
        require (msg.sender == deployerAddress || msg.sender == devAddress, "Not a deployer or dev address");
        royaltyCollector[_royaltyCollector] = true;
    }
    //set signed staking contract address
    function setSignedStakingContract(address _signedStakingContract) public onlyRoyaltyCollector()
    {
        signedStakingContract = _signedStakingContract;
    }
    
   
    //rates out of 10,000
    function depositRoyalties() public payable onlyRoyaltyCollector() 
    {
        require (msg.value > 0, "Must deposit some amount");
        totalRoyaltiesCollected = totalRoyaltiesCollected + msg.value;
        uint256 stakingRate = 5000;
        uint256 signedRate = 100;
        uint256 liquidityRate = 4900;

        uint256 stakingAmount = msg.value * stakingRate / 10000;
        uint256 signedAmount = msg.value * signedRate / 10000;
        uint256 liquidityAmount = msg.value * liquidityRate / 10000;

        IWBNB(address(chainToken)).deposit{ value: address(this).balance}();

        //chainToken.transfer(stakingContract, stakingAmount);
        chainToken.transfer(signedLiquidityController, signedAmount);

        uint256 amountToSpend = liquidityAmount.div(2) + stakingAmount;
        
        buyArtistToken(amountToSpend);

        addLiquidity();

        uint256 amountForStaking = IERC20(artistToken).balanceOf(address(this));
        IERC20(artistToken).transfer(stakingContract, amountForStaking);
    }

    function depositRoyaltiesStaking() public payable onlyRoyaltyCollector() 
    {
        require (msg.value > 0, "Must deposit some amount");
        totalRoyaltiesCollected = totalRoyaltiesCollected + msg.value;
        uint256 stakingRate = 4000;
        uint256 signedRate = 100;
        uint256 liquidityRate = 4900;
        

        uint256 stakingAmount = msg.value * stakingRate / 10000;
        uint256 signedAmount = msg.value * signedRate / 10000;
        uint256 liquidityAmount = msg.value * liquidityRate / 10000;
        
        ISignedStake(signedStakingContract).depositMatic{value: signedAmount}();
        
        IWBNB(address(chainToken)).deposit{ value: address(this).balance}();

        //chainToken.transfer(stakingContract, stakingAmount);
        //chainToken.transfer(signedLiquidityController, signedAmount);

        uint256 amountToSpend = liquidityAmount.div(2) + stakingAmount;
        
        buyArtistToken(amountToSpend);

        addLiquidity();

        uint256 amountForStaking = IERC20(artistToken).balanceOf(address(this));
        IERC20(artistToken).transfer(stakingContract, amountForStaking);
    }

    function addLiquidity() private {
        gate.setUnrestricted(true);
        addLiq(chainToken.balanceOf(address(this)));
        gate.setUnrestricted(false);
    }
    //rates out of 10,000


    function buyArtistToken(uint256 amountToSpend) private returns (uint256)
    {
        uint256[] memory amounts = router.swapExactTokensForTokens(amountToSpend, 0, buyPath(), address(this), block.timestamp);
        amountToSpend = amounts[1];
        return amountToSpend;
    }
    function addLiq(uint256 chainTokenAmount) private
    {
        router.addLiquidity(address(chainToken), address(artistToken), chainTokenAmount, IERC20(artistToken).balanceOf(address(this)), 0, 0, address(this), block.timestamp);
    }

    function buyPath() private view returns (address[] memory) 
    {
        address[] memory path = new address[](2);
        path[0] = address(chainToken);
        path[1] = address(artistToken);
        return path;
    }

    
}

File 50 of 56: SafeERC20.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/* ROOTKIT:
Modified to remove some junk
Also modified to remove silly restrictions (traps!) within safeApprove
*/

import "./IERC20.sol";
import "./SafeMath.sol";
import "./Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {        
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 51 of 56: SafeMath.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

library SafeMath 
{
    function add(uint256 a, uint256 b) internal pure returns (uint256) 
    {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256) 
    {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) 
    {
        require(b <= a, errorMessage);
        uint256 c = a - b;
        return c;
    }

    function mul(uint256 a, uint256 b) internal pure returns (uint256) 
    {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) 
        {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }
    
    function div(uint256 a, uint256 b) internal pure returns (uint256) 
    {
        return div(a, b, "SafeMath: division by zero");
    }

    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) 
    {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        return c;
    }

    function mod(uint256 a, uint256 b) internal pure returns (uint256) 
    {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) 
    {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 52 of 56: StakingToken.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

import "./SafeMath.sol";
import "./IERC20.sol";
import "./ERC20.sol";
import "./TokensRecoverable.sol";

contract StakingToken is ERC20, TokensRecoverable
{
    
    using SafeMath for uint256;
    IERC20 public immutable rooted;

    constructor(address _dev, IERC20 _rooted, string memory _name, string memory _symbol)
    ERC20(_dev, _name, _symbol)
    {
        rooted = _rooted;
    }

    // Stake rooted, get staking shares
    function stake(uint256 amount) public 
    {
        uint256 totalRooted = rooted.balanceOf(address(this));
        uint256 totalShares = this.totalSupply();

        if (totalShares == 0 || totalRooted == 0) 
        {
            _mint(msg.sender, amount);
        } 
        else 
        {
            uint256 mintAmount = amount.mul(totalShares).div(totalRooted);
            _mint(msg.sender, mintAmount);
        }

        rooted.transferFrom(msg.sender, address(this), amount);
    }

    // Unstake shares, claim back rooted
    function unstake(uint256 share) public 
    {
        uint256 totalShares = this.totalSupply();
        uint256 unstakeAmount = share.mul(rooted.balanceOf(address(this))).div(totalShares);

        _burn(msg.sender, share);
        rooted.transfer(msg.sender, unstakeAmount);
    }

    function canRecoverTokens(IERC20 token) internal override view returns (bool) 
    { 
        return address(token) != address(this) && address(token) != address(rooted); 
    }
}

File 53 of 56: TokenFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;

import "./IERC20.sol";
import "./RootedToken.sol";
import "./Owned.sol";
import "./EliteToken.sol";
import "./MarketGeneration.sol";
import "./MarketDistribution.sol";
import "./LazarusPit.sol";
import "./RootedTransferGate.sol";
import "./EliteFloorCalculator.sol";
import "./EliteFloorCalculatorV1.sol";
import "./FeeSplitter.sol";
import "./LiquidityController.sol";
import "./StakingToken.sol";
import "./RoyaltyPump.sol";
import "./TokenTimelock.sol";

contract TokenFactory is Owned {
address factory;
//WETH MATIC MAINNET
IERC20 wrappedToken = IERC20(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270);

modifier onlyFactory {
    require(msg.sender == factory || msg.sender == owner);
    _;
}
function setFactory(address _factory) public ownerOnly() {
    factory = _factory;
}
function createRooted(address dev, string memory name, string memory ticker) public onlyFactory() returns(RootedToken) {
    RootedToken newToken = new RootedToken(dev, name, ticker);
    newToken.setController(dev);
    return newToken;
}

function createElite(address dev) public onlyFactory() returns(EliteToken) {
    EliteToken newToken = new EliteToken(wrappedToken, dev);
    newToken.setController(dev);
    return newToken;
}
 
    
}

File 54 of 56: TokensRecoverable.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/* ROOTKIT:
Allows recovery of unexpected tokens (airdrops, etc)
Inheriters can customize logic by overriding canRecoverTokens
*/

import "./IERC20.sol";
import "./SafeERC20.sol";
import "./Owned.sol";
import "./ITokensRecoverable.sol";

abstract contract TokensRecoverable is Owned, ITokensRecoverable
{
    using SafeERC20 for IERC20;
    address controller;
    modifier onlyController() 
    {
    require(msg.sender == controller || msg.sender == owner);
    _;
}

    function setController(address _controller) public ownerOnly()
    {
        controller = _controller;
    }

    function recoverTokens(IERC20 token) public override onlyController() 
    {
        require (canRecoverTokens(token));
        token.safeTransfer(msg.sender, token.balanceOf(address(this)));
    }

    function canRecoverTokens(IERC20 token) internal virtual view returns (bool) 
    { 
        return address(token) != address(this); 
    }
}

File 55 of 56: TokenTimelock.sol
// SPDX-License-Identifier: lol
pragma solidity ^0.7.4;

import "./SafeMath.sol";
import "./IERC20.sol";
import "./TokensRecoverable.sol";
import "./Owned.sol";

contract TokenTimelock is Owned, TokensRecoverable {

    using SafeMath for uint256;
    address dev;

    constructor(address _dev){
        dev = _dev; 
    }

    struct Timelock {
        address tokenOwner;
        uint256 amount;
        uint256 lockedTimestamp;
        uint256 claims;
        uint256 timeLocked;
    }
    modifier onlyDev() {
    require(msg.sender == dev|| msg.sender == owner);
    _;
}

    //uint256 sixMonthsInSeconds = 15552000;
    uint256 sixMonthsInSeconds = 15552000; //set to 10 minutes for testing
    
    
    mapping (address => Timelock) tokenTimelock;

    function claimAvailable(address _token) public view returns (uint256) {
        uint unlockTime = tokenTimelock[_token].lockedTimestamp + tokenTimelock[_token].timeLocked;
        //if the full timelocked amount is up, transfer full balance of tokens to artist
        if (unlockTime <= block.timestamp) {
            return tokenTimelock[_token].amount;
        }

        //if 3 months is up, transfer half the amount to artist only if they havent already claimed
        else if (tokenTimelock[_token].lockedTimestamp + (tokenTimelock[_token].timeLocked.div(2)) <= block.timestamp && block.timestamp < unlockTime) {
            if (tokenTimelock[_token].claims < 1) {
                uint256 halfAmount = tokenTimelock[_token].amount.div(2);
                return halfAmount;
            }
        }
        
    }

    function lockTokens(address _token, address _artist, uint256 _amount) public onlyDev() {
        require(_amount > 0, 'Amount must be greater than 0');
        require(tokenTimelock[_token].amount == 0, 'Token is already locked');
        tokenTimelock[_token] = Timelock(_artist, _amount, block.timestamp, 0, sixMonthsInSeconds);
        IERC20(_token).transferFrom(msg.sender, address(this), _amount);
    }

    function claimTokens(address _token) public {
        require(msg.sender == tokenTimelock[_token].tokenOwner, 'Only token owner can claim tokens');
        require(tokenTimelock[_token].lockedTimestamp + (tokenTimelock[_token].timeLocked.div(2)) <= block.timestamp, 'Token is still locked');
        require(tokenTimelock[_token].amount > 0, 'Token is already claimed');
        
        uint unlockTime = tokenTimelock[_token].lockedTimestamp + tokenTimelock[_token].timeLocked;
        //if the full timelocked amount is up, transfer full balance of tokens to artist
        if (unlockTime <= block.timestamp) {
            
            IERC20(_token).transfer(msg.sender, tokenTimelock[_token].amount);
            //tokenTimelock[_token].amount = 0;
        }

        //if 3 months is up, transfer half the amount to artist only if they havent already claimed
        else if (tokenTimelock[_token].lockedTimestamp + (tokenTimelock[_token].timeLocked.div(2)) <= block.timestamp && block.timestamp < unlockTime) {
            if (tokenTimelock[_token].claims < 1) {
                uint256 halfAmount = tokenTimelock[_token].amount.div(2);
                tokenTimelock[_token] = Timelock(tokenTimelock[_token].tokenOwner, halfAmount, tokenTimelock[_token].lockedTimestamp, 1, tokenTimelock[_token].timeLocked);
                IERC20(_token).transfer(msg.sender, halfAmount);
            }
        }
    }
  
    //Emergency function to unlock tokens
    function canRecoverTokens(IERC20 token) internal override view returns (bool) 
    { 
        return msg.sender == owner || msg.sender == dev; 
    }
}

File 56 of 56: WrappedERC20.sol
// SPDX-License-Identifier: U-U-U-UPPPPP!!!
pragma solidity ^0.7.4;

/* ROOTKIT:
Wraps any ERC20
Similar to WETH except for ERC20 tokens instead of ETH
depositTokens/withdrawTokens are like deposit/withdraw in WETH
Inheriters can hook into depositTokens and withdrawTokens
by overriding _beforeDepositTokens and _beforeWithdrawTokens
*/

import "./IERC20.sol";
import "./ERC20.sol";
import "./IWrappedERC20.sol";
import "./TokensRecoverable.sol";
import "./SafeERC20.sol";
import "./SafeMath.sol";

contract WrappedERC20 is ERC20, IWrappedERC20, TokensRecoverable
{
    using SafeERC20 for IERC20;
    using SafeMath for uint256;

    IERC20 public immutable override wrappedToken;

    constructor (address _dev, IERC20 _wrappedToken, string memory _name, string memory _symbol)
        ERC20(_dev, _name, _symbol)
    {        
        if (_wrappedToken.decimals() != 18) {
            _setupDecimals(_wrappedToken.decimals());
        }
        wrappedToken = _wrappedToken;
    }

    function depositTokens(uint256 _amount) public override
    {
        _beforeDepositTokens(_amount);
        uint256 myBalance = wrappedToken.balanceOf(address(this));
        wrappedToken.safeTransferFrom(msg.sender, address(this), _amount);
        uint256 received = wrappedToken.balanceOf(address(this)).sub(myBalance);
        _mint(msg.sender, received);
        emit Deposit(msg.sender, _amount);
    }

    function withdrawTokens(uint256 _amount) public override
    {
        _beforeWithdrawTokens(_amount);
        _burn(msg.sender, _amount);
        uint256 myBalance = wrappedToken.balanceOf(address(this));
        wrappedToken.safeTransfer(msg.sender, _amount);
        require (wrappedToken.balanceOf(address(this)) == myBalance.sub(_amount), "Transfer not exact");
        emit Withdrawal(msg.sender, _amount);
    }

    function canRecoverTokens(IERC20 token) internal virtual override view returns (bool) 
    {
        return token != this && token != wrappedToken;
    }

    function _beforeDepositTokens(uint256 _amount) internal virtual view { }
    function _beforeWithdrawTokens(uint256 _amount) internal virtual view { }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_dev","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dev","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"exist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"liquidityController","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IPancakePair","name":"","type":"address"}],"name":"liquidityPairLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numberOfTokenHolders","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"recoverTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_liquidityController","type":"address"},{"internalType":"bool","name":"_canControl","type":"bool"}],"name":"setLiquidityController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPancakePair","name":"_liquidityPair","type":"address"},{"internalType":"bool","name":"_locked","type":"bool"}],"name":"setLiquidityLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"setMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITransferGate","name":"_transferGate","type":"address"}],"name":"setTransferGate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenHolder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"transferGate","outputs":[{"internalType":"contract ITransferGate","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405260058054600960a11b60ff60a01b19909116179055600680546001600160a01b031916331790556000600b553480156200003d57600080fd5b506040516200247938038062002479833981810160405260608110156200006357600080fd5b8151602083018051604051929492938301929190846401000000008211156200008b57600080fd5b908301906020820185811115620000a157600080fd5b8251640100000000811182820188101715620000bc57600080fd5b82525081516020918201929091019080838360005b83811015620000eb578181015183820152602001620000d1565b50505050905090810190601f168015620001195780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200013d57600080fd5b9083019060208201858111156200015357600080fd5b82516401000000008111828201881017156200016e57600080fd5b82525081516020918201929091019080838360005b838110156200019d57818101518382015260200162000183565b50505050905090810190601f168015620001cb5780820380516001836020036101000a031916815260200191505b506040525050600580546001600160a01b0319166001600160a01b038616179055508151839083908390839083908390839083908390620002149060039060208501906200023d565b5080516200022a9060049060208401906200023d565b50505050505050505050505050620002e9565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620002755760008555620002c0565b82601f106200029057805160ff1916838001178555620002c0565b82800160010185558215620002c0579182015b82811115620002c0578251825591602001919060010190620002a3565b50620002ce929150620002d2565b5090565b5b80821115620002ce5760008155600101620002d3565b61218080620002f96000396000f3fe608060405234801561001057600080fd5b50600436106101da5760003560e01c806370a0823111610104578063a457c2d7116100a2578063b834aa2011610071578063b834aa201461057b578063dd62ed3e146105a1578063f2fde38b146105cf578063fca3b5aa146105f5576101da565b8063a457c2d7146104f5578063a9059cbb14610521578063ab27c58b1461054d578063b497534314610573576101da565b806391cca3db116100de57806391cca3db146104a257806392eefe9b146104aa57806395d89b41146104d0578063a0712d68146104d8576101da565b806370a0823114610457578063862a4bf21461047d5780638da5cb5b1461049a576101da565b8063313ce5671161017c5780634dfefc4b1161014b5780634dfefc4b146103d55780634e71e0c8146103fb578063528d8b211461040357806361d8c81714610431576101da565b8063313ce56714610340578063395093511461035e57806342966c681461038a578063449113f2146103a7576101da565b806316114acd116101b857806316114acd146102c0578063178ef307146102e857806318160ddd1461030257806323b872dd1461030a576101da565b806306fdde03146101df578063075461721461025c578063095ea7b314610280575b600080fd5b6101e761061b565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610221578181015183820152602001610209565b50505050905090810190601f16801561024e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102646106a9565b604080516001600160a01b039092168252519081900360200190f35b6102ac6004803603604081101561029657600080fd5b506001600160a01b0381351690602001356106b8565b604080519115158252519081900360200190f35b6102e6600480360360208110156102d657600080fd5b50356001600160a01b03166106ce565b005b6102f061079d565b60408051918252519081900360200190f35b6102f06107a3565b6102ac6004803603606081101561032057600080fd5b506001600160a01b038135811691602081013590911690604001356107a9565b610348610818565b6040805160ff9092168252519081900360200190f35b6102ac6004803603604081101561037457600080fd5b506001600160a01b038135169060200135610828565b6102e6600480360360208110156103a057600080fd5b5035610863565b6102e6600480360360408110156103bd57600080fd5b506001600160a01b038135169060200135151561086d565b6102ac600480360360208110156103eb57600080fd5b50356001600160a01b0316610a37565b6102e6610a4c565b6102e66004803603604081101561041957600080fd5b506001600160a01b0381351690602001351515610abf565b6102e66004803603602081101561044757600080fd5b50356001600160a01b0316610b16565b6102f06004803603602081101561046d57600080fd5b50356001600160a01b0316610b64565b6102646004803603602081101561049357600080fd5b5035610f33565b610264610f5d565b610264610f6c565b6102e6600480360360208110156104c057600080fd5b50356001600160a01b0316610f7b565b6101e7610fe9565b6102e6600480360360208110156104ee57600080fd5b5035611044565b6102ac6004803603604081101561050b57600080fd5b506001600160a01b038135169060200135611144565b6102ac6004803603604081101561053757600080fd5b506001600160a01b038135169060200135611193565b6102ac6004803603602081101561056357600080fd5b50356001600160a01b03166111ee565b610264611203565b6102ac6004803603602081101561059157600080fd5b50356001600160a01b0316611212565b6102f0600480360360408110156105b757600080fd5b506001600160a01b0381358116916020013516611227565b6102e6600480360360208110156105e557600080fd5b50356001600160a01b0316611244565b6102e66004803603602081101561060b57600080fd5b50356001600160a01b03166112b2565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156106a15780601f10610676576101008083540402835291602001916106a1565b820191906000526020600020905b81548152906001019060200180831161068457829003601f168201915b505050505081565b6010546001600160a01b031681565b60006106c5338484611300565b50600192915050565b6008546001600160a01b03163314806106f157506006546001600160a01b031633145b6106fa57600080fd5b610703816113ec565b61070c57600080fd5b61079a33826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561075d57600080fd5b505afa158015610771573d6000803e3d6000fd5b505050506040513d602081101561078757600080fd5b50516001600160a01b03841691906113fe565b50565b600b5481565b60025481565b6001600160a01b0382166000908152600d602052604081205460ff16156107d9576107d46001611455565b610803565b60408051606081018252600080825260208201819052910152600f80546001600160c81b03191690555b61080e8484846115ac565b90505b9392505050565b600554600160a01b900460ff1681565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916106c591859061085e908661161b565b611300565b61079a3382611675565b336000908152600e602052604090205460ff166108d1576040805162461bcd60e51b815260206004820152601960248201527f4c697175696469747920636f6e74726f6c6c6572206f6e6c7900000000000000604482015290519081900360640190fd5b306001600160a01b0316826001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561091457600080fd5b505afa158015610928573d6000803e3d6000fd5b505050506040513d602081101561093e57600080fd5b50516001600160a01b031614806109ca5750306001600160a01b0316826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561099357600080fd5b505afa1580156109a7573d6000803e3d6000fd5b505050506040513d60208110156109bd57600080fd5b50516001600160a01b0316145b610a0c576040805162461bcd60e51b815260206004820152600e60248201526d2ab73932b630ba32b2103830b4b960911b604482015290519081900360640190fd5b6001600160a01b03919091166000908152600d60205260409020805460ff1916911515919091179055565b600c6020526000908152604090205460ff1681565b6007546001600160a01b03163314610a6357600080fd5b600780546001600160a01b031916905560065460405133916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600680546001600160a01b03191633179055565b6008546001600160a01b0316331480610ae257506006546001600160a01b031633145b610aeb57600080fd5b6001600160a01b03919091166000908152600e60205260409020805460ff1916911515919091179055565b6008546001600160a01b0316331480610b3957506006546001600160a01b031633145b610b4257600080fd5b600980546001600160a01b0319166001600160a01b0392909216919091179055565b336000818152600d602052604081205490919060ff1615610f2a57610b87611eb9565b5060408051606081018252600f546001600160a01b038116808352600160a01b820463ffffffff166020840152600160c01b90910460ff161515928201929092529032148015610be0575043816020015163ffffffff16145b610c27576040805162461bcd60e51b8152602060048201526013602482015272131a5c5d5a591a5d1e481a5cc81b1bd8dad959606a1b604482015290519081900360640190fd5b806040015115610f2857600080836001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610c6d57600080fd5b505afa158015610c81573d6000803e3d6000fd5b505050506040513d6060811015610c9757600080fd5b50805160209182015160408051630dfe168160e01b815290516dffffffffffffffffffffffffffff93841696509290911693506000926001600160a01b03881692630dfe1681926004808201939291829003018186803b158015610cfa57600080fd5b505afa158015610d0e573d6000803e3d6000fd5b505050506040513d6020811015610d2457600080fd5b505190506001600160a01b038116301415610e625781856001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015610d7357600080fd5b505afa158015610d87573d6000803e3d6000fd5b505050506040513d6020811015610d9d57600080fd5b5051604080516370a0823160e01b81526001600160a01b038981166004830152915191909216916370a08231916024808301926020929190829003018186803b158015610de957600080fd5b505afa158015610dfd573d6000803e3d6000fd5b505050506040513d6020811015610e1357600080fd5b505110610e5d576040805162461bcd60e51b8152602060048201526013602482015272131a5c5d5a591a5d1e481a5cc81b1bd8dad959606a1b604482015290519081900360640190fd5b610f24565b82816001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610eb057600080fd5b505afa158015610ec4573d6000803e3d6000fd5b505050506040513d6020811015610eda57600080fd5b505110610f24576040805162461bcd60e51b8152602060048201526013602482015272131a5c5d5a591a5d1e481a5cc81b1bd8dad959606a1b604482015290519081900360640190fd5b5050505b505b6108118361175f565b600a8181548110610f4357600080fd5b6000918252602090912001546001600160a01b0316905081565b6006546001600160a01b031681565b6005546001600160a01b031681565b6006546001600160a01b03163314610fc7576040805162461bcd60e51b815260206004820152600a6024820152694f776e6572206f6e6c7960b01b604482015290519081900360640190fd5b600880546001600160a01b0319166001600160a01b0392909216919091179055565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156106a15780601f10610676576101008083540402835291602001916106a1565b6010546001600160a01b03163314611092576040805162461bcd60e51b815260206004820152600c60248201526b2737ba10309036b4b73a32b960a11b604482015290519081900360640190fd5b306001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110cb57600080fd5b505afa1580156110df573d6000803e3d6000fd5b505050506040513d60208110156110f557600080fd5b50511561113a576040805162461bcd60e51b815260206004820152600e60248201526d105b1c9958591e481b5a5b9d195960921b604482015290519081900360640190fd5b61079a338261177a565b60006106c5338461085e85604051806060016040528060258152602001612126602591393360009081526001602090815260408083206001600160a01b038d1684529091529020549190611858565b336000908152600d602052604081205460ff16156111ba576111b56000611455565b6111e4565b60408051606081018252600080825260208201819052910152600f80546001600160c81b03191690555b61081183836118ef565b600d6020526000908152604090205460ff1681565b6009546001600160a01b031681565b600e6020526000908152604090205460ff1681565b600160209081526000928352604080842090915290825290205481565b6006546001600160a01b03163314611290576040805162461bcd60e51b815260206004820152600a6024820152694f776e6572206f6e6c7960b01b604482015290519081900360640190fd5b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6008546001600160a01b03163314806112d557506006546001600160a01b031633145b6112de57600080fd5b601080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166113455760405162461bcd60e51b81526004018080602001828103825260248152602001806120d86024913960400191505060405180910390fd5b6001600160a01b03821661138a5760405162461bcd60e51b8152600401808060200182810382526022815260200180611ff66022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038116301415919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526114509084906118fc565b505050565b61145d611eb9565b5060408051606081018252600f546001600160a01b0381168252600160a01b810463ffffffff166020830152600160c01b900460ff161515918101919091526114a4611eb9565b5060408051606081018252328082524363ffffffff16602083015284151592820192909252825190916001600160a01b039091161415806114f95750806020015163ffffffff16826020015163ffffffff1614155b806115105750806040015115158260400151151514155b61154b5760405162461bcd60e51b815260040180806020018281038252603181526020018061203e6031913960400191505060405180910390fd5b8051600f805460208401516040909401511515600160c01b0260ff60c01b1963ffffffff909516600160a01b0263ffffffff60a01b196001600160a01b039095166001600160a01b0319909316929092179390931617929092161790555050565b60006115b98484846119ad565b6001600160a01b0384166000908152600160209081526040808320338452909152902054600019811461161057611610853361085e8660405180606001604052806028815260200161206f60289139869190611858565b506001949350505050565b600082820183811015610811576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b0382166116ba5760405162461bcd60e51b81526004018080602001828103825260218152602001806120b76021913960400191505060405180910390fd5b6116c682600083611450565b61170381604051806060016040528060228152602001611fd4602291396001600160a01b0385166000908152602081905260409020549190611858565b6001600160a01b0383166000908152602081905260409020556002546117299082611ce5565b6002556040805182815290516000916001600160a01b038516916000805160206120978339815191529181900360200190a35050565b6001600160a01b031660009081526020819052604090205490565b6001600160a01b0382166117d5576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6117e160008383611450565b6002546117ee908261161b565b6002556001600160a01b038216600090815260208190526040902054611814908261161b565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391926000805160206120978339815191529281900390910190a35050565b600081848411156118e75760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156118ac578181015183820152602001611894565b50505050905090810190601f1680156118d95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60006106c53384846119ad565b6060611951826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611d279092919063ffffffff16565b8051909150156114505780806020019051602081101561197057600080fd5b50516114505760405162461bcd60e51b815260040180806020018281038252602a8152602001806120fc602a913960400191505060405180910390fd5b6001600160a01b0383166119dc5760405162461bcd60e51b81526004016119d390611f85565b60405180910390fd5b6001600160a01b038216611a025760405162461bcd60e51b81526004016119d390611f42565b611a0d838383611450565b6001600160a01b0382166000908152600c602052604090205460ff16611a9957600a805460018082019092557fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b0319166001600160a01b038516908117909155600b8054830190556000908152600c60205260409020805460ff191690911790555b6009546001600160a01b0316818115611c2a576000826001600160a01b0316636052970c6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ae757600080fd5b505afa158015611afb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1f9190611ed9565b90506000836001600160a01b03166395c47d06338989896040518563ffffffff1660e01b8152600401611b559493929190611f18565b602060405180830381600087803b158015611b6f57600080fd5b505af1158015611b83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba79190611f00565b90508015611c27576001600160a01b038216600090815260208190526040902054611bd2908261161b565b6001600160a01b03808416600081815260208190526040908190209390935591519089169060008051602061209783398151915290611c12908590611fca565b60405180910390a3611c248382611ce5565b92505b50505b611c6783604051806060016040528060268152602001612018602691396001600160a01b0388166000908152602081905260409020549190611858565b6001600160a01b038087166000908152602081905260408082209390935590861681522054611c96908261161b565b6001600160a01b03808616600081815260208190526040908190209390935591519087169060008051602061209783398151915290611cd6908590611fca565b60405180910390a35050505050565b600061081183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611858565b606061080e848460008585611d3b85611e4d565b611d8c576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310611dcb5780518252601f199092019160209182019101611dac565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611e2d576040519150601f19603f3d011682016040523d82523d6000602084013e611e32565b606091505b5091509150611e42828286611e53565b979650505050505050565b3b151590565b60608315611e62575081610811565b825115611e725782518084602001fd5b60405162461bcd60e51b81526020600482018181528451602484015284518593919283926044019190850190808383600083156118ac578181015183820152602001611894565b604080516060810182526000808252602082018190529181019190915290565b600060208284031215611eea578081fd5b81516001600160a01b0381168114610811578182fd5b600060208284031215611f11578081fd5b5051919050565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b9081526020019056fe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654c6971756964697479206973206c6f636b65642028506c656173652074727920616761696e206e65787420626c6f636b2945524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef45524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220725999c0ca07b422acb3d9bcb83ad290268d7af848cd1dec21d747a017a39ca164736f6c63430007040033000000000000000000000000a7ede04461d260536d32431dba5312a1d766f062000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000b246967696c20546f6b656e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044947494c00000000000000000000000000000000000000000000000000000000

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000a7ede04461d260536d32431dba5312a1d766f062000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000b246967696c20546f6b656e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044947494c00000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _dev (address): 0xa7ede04461d260536d32431dba5312a1d766f062
Arg [1] : _name (string): $igil Token
Arg [2] : _symbol (string): IGIL

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 000000000000000000000000a7ede04461d260536d32431dba5312a1d766f062
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [3] : 000000000000000000000000000000000000000000000000000000000000000b
Arg [4] : 246967696c20546f6b656e000000000000000000000000000000000000000000
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [6] : 4947494c00000000000000000000000000000000000000000000000000000000


Deployed ByteCode Sourcemap

504:580:46:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1663:27:4;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;734:21:46;;;:::i;:::-;;;;-1:-1:-1;;;;;734:21:46;;;;;;;;;;;;;;2926:167:4;;;;;;;;;;;;;;;;-1:-1:-1;2926:167:4;;-1:-1:-1;;;;;2926:167:4;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;685:201:54;;;;;;;;;;;;;;;;-1:-1:-1;685:201:54;-1:-1:-1;;;;;685:201:54;;:::i;:::-;;582:39:13;;;:::i;:::-;;;;;;;;;;;;;;;;1619:35:4;;;:::i;3148:424:37:-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;3148:424:37;;;;;;;;;;;;;;;;;:::i;1758:35:4:-;;;:::i;:::-;;;;;;;;;;;;;;;;;;;4404:212;;;;;;;;;;;;;;;;-1:-1:-1;4404:212:4;;-1:-1:-1;;;;;4404:212:4;;;;;;:::i;2241:95:13:-;;;;;;;;;;;;;;;;-1:-1:-1;2241:95:13;;:::i;716:358:37:-;;;;;;;;;;;;;;;;-1:-1:-1;716:358:37;;-1:-1:-1;;;;;716:358:37;;;;;;;;:::i;628:37:13:-;;;;;;;;;;;;;;;;-1:-1:-1;628:37:13;-1:-1:-1;;;;;628:37:13;;:::i;653:222:44:-;;;:::i;1082:183:37:-;;;;;;;;;;;;;;;;-1:-1:-1;1082:183:37;;-1:-1:-1;;;;;1082:183:37;;;;;;;;:::i;797:139:13:-;;;;;;;;;;;;;;;;-1:-1:-1;797:139:13;-1:-1:-1;;;;;797:139:13;;:::i;1273:926:37:-;;;;;;;;;;;;;;;;-1:-1:-1;1273:926:37;-1:-1:-1;;;;;1273:926:37;;:::i;546:29:13:-;;;;;;;;;;;;;;;;-1:-1:-1;546:29:13;;:::i;330:42:44:-;;;:::i;1733:18:4:-;;;:::i;566:111:54:-;;;;;;;;;;;;;;;;-1:-1:-1;566:111:54;-1:-1:-1;;;;;566:111:54;;:::i;1697:29:4:-;;;:::i;878:203:46:-;;;;;;;;;;;;;;;;-1:-1:-1;878:203:46;;:::i;5119:263:4:-;;;;;;;;;;;;;;;;-1:-1:-1;5119:263:4;;-1:-1:-1;;;;;5119:263:4;;;;;;:::i;2729:411:37:-;;;;;;;;;;;;;;;;-1:-1:-1;2729:411:37;;-1:-1:-1;;;;;2729:411:37;;;;;;:::i;301:57::-;;;;;;;;;;;;;;;;-1:-1:-1;301:57:37;-1:-1:-1;;;;;301:57:37;;:::i;497:42:13:-;;;:::i;365:52:37:-;;;;;;;;;;;;;;;;-1:-1:-1;365:52:37;-1:-1:-1;;;;;365:52:37;;:::i;1535:75:4:-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;1535:75:4;;;;;;;;;;:::i;525:120:44:-;;;;;;;;;;;;;;;;-1:-1:-1;525:120:44;-1:-1:-1;;;;;525:120:44;;:::i;770:100:46:-;;;;;;;;;;;;;;;;-1:-1:-1;770:100:46;-1:-1:-1;;;;;770:100:46;;:::i;1663:27:4:-;;;;;;;;;;;;;;;-1:-1:-1;;1663:27:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;734:21:46:-;;;-1:-1:-1;;;;;734:21:46;;:::o;2926:167:4:-;3009:4;3026:37;3035:10;3047:7;3056:6;3026:8;:37::i;:::-;-1:-1:-1;3081:4:4;2926:167;;;;:::o;685:201:54:-;512:10;;-1:-1:-1;;;;;512:10:54;498;:24;;:47;;-1:-1:-1;540:5:54;;-1:-1:-1;;;;;540:5:54;526:10;:19;498:47;490:56;;;;;;781:23:::1;798:5;781:16;:23::i;:::-;772:33;;;::::0;::::1;;847:30;::::0;;-1:-1:-1;;;847:30:54;;871:4:::1;847:30;::::0;::::1;::::0;;;816:62:::1;::::0;835:10:::1;::::0;-1:-1:-1;;;;;847:15:54;::::1;::::0;::::1;::::0;:30;;;;;::::1;::::0;;;;;;;;:15;:30;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;847:30:54;-1:-1:-1;;;;;816:18:54;::::1;::::0;;::::1;:62::i;:::-;685:201:::0;:::o;582:39:13:-;;;;:::o;1619:35:4:-;;;;:::o;3148:424:37:-;-1:-1:-1;;;;;3281:44:37;;3254:4;3281:44;;;:19;:44;;;;;;;;3277:225;;;3342:18;3355:4;3342:12;:18::i;:::-;3277:225;;;3419:71;;;;;;;;-1:-1:-1;3419:71:37;;;;;;;;;;;;3402:14;:88;;-1:-1:-1;;;;;;3402:88:37;;;3277:225;3519:45;3538:6;3546:9;3557:6;3519:18;:45::i;:::-;3512:52;;3148:424;;;;;;:::o;1758:35:4:-;;;-1:-1:-1;;;1758:35:4;;;;;:::o;4404:212::-;4518:10;4492:4;4539:21;;;:9;:21;;;;;;;;-1:-1:-1;;;;;4539:30:4;;;;;;;;;;4492:4;;4509:77;;4539:30;;:46;;4574:10;4539:34;:46::i;:::-;4509:8;:77::i;2241:95:13:-;2303:25;2309:10;2321:6;2303:5;:25::i;716:358:37:-;846:10;826:31;;;;:19;:31;;;;;;;;817:70;;;;;-1:-1:-1;;;817:70:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;907:23;;;-1:-1:-1;;;907:23:37;;;;942:4;;-1:-1:-1;;;;;907:21:37;;;;;:23;;;;;;;;;;;;;;;:21;:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;907:23:37;-1:-1:-1;;;;;907:40:37;;;:84;;-1:-1:-1;951:23:37;;;-1:-1:-1;;;951:23:37;;;;986:4;;-1:-1:-1;;;;;951:21:37;;;;;:23;;;;;;;;;;;;;;;:21;:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;951:23:37;-1:-1:-1;;;;;951:40:37;;907:84;898:112;;;;;-1:-1:-1;;;898:112:37;;;;;;;;;;;;-1:-1:-1;;;898:112:37;;;;;;;;;;;;;;;-1:-1:-1;;;;;1021:35:37;;;;;;;;:19;:35;;;;;:45;;-1:-1:-1;;1021:45:37;;;;;;;;;;716:358::o;628:37:13:-;;;;;;;;;;;;;;;:::o;653:222:44:-;720:12;;-1:-1:-1;;;;;720:12:44;736:10;720:26;711:36;;;;;;758:12;:25;;-1:-1:-1;;;;;;758:25:44;;;820:5;;799:39;;827:10;;-1:-1:-1;;;;;820:5:44;;799:39;;-1:-1:-1;;799:39:44;849:5;:18;;-1:-1:-1;;;;;;849:18:44;857:10;849:18;;;653:222::o;1082:183:37:-;512:10:54;;-1:-1:-1;;;;;512:10:54;498;:24;;:47;;-1:-1:-1;540:5:54;;-1:-1:-1;;;;;540:5:54;526:10;:19;498:47;490:56;;;;;;-1:-1:-1;;;;;1202:41:37;;;::::1;;::::0;;;:19:::1;:41;::::0;;;;:55;;-1:-1:-1;;1202:55:37::1;::::0;::::1;;::::0;;;::::1;::::0;;1082:183::o;797:139:13:-;512:10:54;;-1:-1:-1;;;;;512:10:54;498;:24;;:47;;-1:-1:-1;540:5:54;;-1:-1:-1;;;;;540:5:54;526:10;:19;498:47;490:56;;;;;;900:12:13::1;:28:::0;;-1:-1:-1;;;;;;900:28:13::1;-1:-1:-1::0;;;;;900:28:13;;;::::1;::::0;;;::::1;::::0;;797:139::o;1273:926:37:-;1406:10;1339:7;1433:25;;;:19;:25;;;;;;1339:7;;1406:10;1433:25;;1429:721;;;1475:22;;:::i;:::-;-1:-1:-1;1475:39:37;;;;;;;;1500:14;1475:39;-1:-1:-1;;;;;1475:39:37;;;;;-1:-1:-1;;;1475:39:37;;;;;;;;-1:-1:-1;;;1475:39:37;;;;;;;;;;;;;;;1553:9;1538:24;:60;;;;;1586:12;1566:4;:16;;;:32;;;1538:60;1529:93;;;;;-1:-1:-1;;;1529:93:37;;;;;;;;;;;;-1:-1:-1;;;1529:93:37;;;;;;;;;;;;;;;1641:4;:17;;;1637:502;;;1680:16;1698;1719:4;-1:-1:-1;;;;;1719:16:37;;:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1719:18:37;;;;;;;;1779:13;;-1:-1:-1;;;1779:13:37;;;;1679:58;;;;;-1:-1:-1;1679:58:37;;;;;-1:-1:-1;1756:13:37;;-1:-1:-1;;;;;1779:11:37;;;-1:-1:-1;;1779:13:37;;;;;1719:18;1779:13;;;;;;:11;:13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1779:13:37;;-1:-1:-1;1843:4:37;-1:-1:-1;;;;;1816:32:37;;;1812:312;;;1931:8;1889:4;-1:-1:-1;;;;;1889:11:37;;:13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1889:13:37;1882:46;;;-1:-1:-1;;;1882:46:37;;-1:-1:-1;;;;;1882:46:37;;;;;;;;;:31;;;;;-1:-1:-1;;1882:46:37;;;;;1889:13;;1882:46;;;;;;;:31;:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1882:46:37;:57;1873:90;;;;;-1:-1:-1;;;1873:90:37;;;;;;;;;;;;-1:-1:-1;;;1873:90:37;;;;;;;;;;;;;;;1812:312;;;2038:31;;;-1:-1:-1;;;2038:31:37;;-1:-1:-1;;;;;2038:31:37;;;;;;;;;2072:8;;2038:16;;;;;:31;;;;;;;;;;;;;;:16;:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2038:31:37;:42;2029:75;;;;;-1:-1:-1;;;2029:75:37;;;;;;;;;;;;-1:-1:-1;;;2029:75:37;;;;;;;;;;;;;;;1637:502;;;;1429:721;;2167:24;2183:7;2167:15;:24::i;546:29:13:-;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;546:29:13;;-1:-1:-1;546:29:13;:::o;330:42:44:-;;;-1:-1:-1;;;;;330:42:44;;:::o;1733:18:4:-;;;-1:-1:-1;;;;;1733:18:4;;:::o;566:111:54:-;477:5:44;;-1:-1:-1;;;;;477:5:44;463:10;:19;454:43;;;;;-1:-1:-1;;;454:43:44;;;;;;;;;;;;-1:-1:-1;;;454:43:44;;;;;;;;;;;;;;;645:10:54::1;:24:::0;;-1:-1:-1;;;;;;645:24:54::1;-1:-1:-1::0;;;;;645:24:54;;;::::1;::::0;;;::::1;::::0;;566:111::o;1697:29:4:-;;;;;;;;;;;;;;;-1:-1:-1;;1697:29:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;878:203:46;953:6;;-1:-1:-1;;;;;953:6:46;939:10;:20;931:45;;;;;-1:-1:-1;;;931:45:46;;;;;;;;;;;;-1:-1:-1;;;931:45:46;;;;;;;;;;;;;;;995:4;-1:-1:-1;;;;;995:16:46;;:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;995:18:46;:23;987:50;;;;;-1:-1:-1;;;987:50:46;;;;;;;;;;;;-1:-1:-1;;;987:50:46;;;;;;;;;;;;;;;1048:25;1054:10;1066:6;1048:5;:25::i;5119:263:4:-;5212:4;5229:123;5238:10;5250:7;5259:92;5294:15;5259:92;;;;;;;;;;;;;;;;;5269:10;5259:21;;;;:9;:21;;;;;;;;-1:-1:-1;;;;;5259:30:4;;;;;;;;;;;;:34;:92::i;2729:411:37:-;2891:10;2815:4;2850:54;;;:19;:54;;;;;;;;2846:236;;;2921:19;2934:5;2921:12;:19::i;:::-;2846:236;;;2999:71;;;;;;;;-1:-1:-1;2999:71:37;;;;;;;;;;;;2982:14;:88;;-1:-1:-1;;;;;;2982:88:37;;;2846:236;3099:33;3114:9;3125:6;3099:14;:33::i;301:57::-;;;;;;;;;;;;;;;:::o;497:42:13:-;;;-1:-1:-1;;;;;497:42:13;;:::o;365:52:37:-;;;;;;;;;;;;;;;:::o;1535:75:4:-;;;;;;;;;;;;;;;;;;;;;;;;:::o;525:120:44:-;477:5;;-1:-1:-1;;;;;477:5:44;463:10;:19;454:43;;;;;-1:-1:-1;;;454:43:44;;;;;;;;;;;;-1:-1:-1;;;454:43:44;;;;;;;;;;;;;;;614:12:::1;:23:::0;;-1:-1:-1;;;;;;614:23:44::1;-1:-1:-1::0;;;;;614:23:44;;;::::1;::::0;;;::::1;::::0;;525:120::o;770:100:46:-;512:10:54;;-1:-1:-1;;;;;512:10:54;498;:24;;:47;;-1:-1:-1;540:5:54;;-1:-1:-1;;;;;540:5:54;526:10;:19;498:47;490:56;;;;;;846:6:46::1;:16:::0;;-1:-1:-1;;;;;;846:16:46::1;-1:-1:-1::0;;;;;846:16:46;;;::::1;::::0;;;::::1;::::0;;770:100::o;8264:344:4:-;-1:-1:-1;;;;;8366:19:4;;8358:68;;;;-1:-1:-1;;;8358:68:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;8445:21:4;;8437:68;;;;-1:-1:-1;;;8437:68:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;8518:16:4;;;;;;;-1:-1:-1;8518:16:4;;;;;;;;:25;;;;;;;;;;;;;:34;;;8568:32;;;;;;;;;;;;;;;;;8264:344;;;:::o;894:142:54:-;-1:-1:-1;;;;;996:31:54;1022:4;996:31;;;894:142::o;829:177:49:-;939:58;;;-1:-1:-1;;;;;939:58:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;939:58:49;-1:-1:-1;;;939:58:49;;;912:86;;932:5;;912:19;:86::i;:::-;829:177;;;:::o;2207:514:37:-;2273:22;;:::i;:::-;-1:-1:-1;2273:39:37;;;;;;;;2298:14;2273:39;-1:-1:-1;;;;;2273:39:37;;;;-1:-1:-1;;;2273:39:37;;;;;;;;-1:-1:-1;;;2273:39:37;;;;;;;;;;;;;2323:23;;:::i;:::-;-1:-1:-1;2349:146:37;;;;;;;;2384:9;2349:146;;;;2428:12;2349:146;;;;;;;;;;;;;;;2515:11;;2349:146;;-1:-1:-1;;;;;2515:27:37;;;;;;:68;;;2566:5;:17;;;2546:37;;:4;:16;;;:37;;;;2515:68;:111;;;;2608:5;:18;;;2587:39;;:4;:17;;;:39;;;;2515:111;2506:174;;;;-1:-1:-1;;;2506:174:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2691:22;;:14;:22;;;;;;;;;;;;;-1:-1:-1;;;2691:22:37;-1:-1:-1;;;;2691:22:37;;;;-1:-1:-1;;;2691:22:37;-1:-1:-1;;;;;;;;;2691:22:37;;;-1:-1:-1;;;;;;2691:22:37;;;;;;;;;;;;;;;;;;;-1:-1:-1;;2207:514:37:o;3575:420:4:-;3681:4;3698:36;3708:6;3716:9;3727:6;3698:9;:36::i;:::-;-1:-1:-1;;;;;3768:17:4;;3745:20;3768:17;;;-1:-1:-1;3768:17:4;;;;;;;;3786:10;3768:29;;;;;;;;-1:-1:-1;;3812:27:4;;3808:158;;3856:98;3865:6;3873:10;3885:68;3902:6;3885:68;;;;;;;;;;;;;;;;;:12;;:68;:16;:68::i;3856:98::-;-1:-1:-1;3983:4:4;;3575:420;-1:-1:-1;;;;3575:420:4:o;98:185:50:-;156:7;194:5;;;218:6;;;;210:46;;;;;-1:-1:-1;;;210:46:50;;;;;;;;;;;;;;;;;;;;;;;;;;;7408:418:4;-1:-1:-1;;;;;7492:21:4;;7484:67;;;;-1:-1:-1;;;7484:67:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7564:49;7585:7;7602:1;7606:6;7564:20;:49::i;:::-;7648:69;7672:6;7648:69;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;7648:19:4;;:10;:19;;;;;;;;;;;;;:23;:69::i;:::-;-1:-1:-1;;;;;7626:19:4;;:10;:19;;;;;;;;;;:91;7742:11;;:23;;7758:6;7742:15;:23::i;:::-;7728:11;:37;7781;;;;;;;;7807:1;;-1:-1:-1;;;;;7781:37:4;;;-1:-1:-1;;;;;;;;;;;7781:37:4;;;;;;;;7408:418;;:::o;2291:102::-;-1:-1:-1;;;;;2377:13:4;2359:7;2377:13;;;;;;;;;;;;2291:102::o;6697:378::-;-1:-1:-1;;;;;6781:21:4;;6773:65;;;;;-1:-1:-1;;;6773:65:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;6851:49;6880:1;6884:7;6893:6;6851:20;:49::i;:::-;6927:11;;:23;;6943:6;6927:15;:23::i;:::-;6913:11;:37;-1:-1:-1;;;;;6983:19:4;;:10;:19;;;;;;;;;;;:31;;7007:6;6983:23;:31::i;:::-;-1:-1:-1;;;;;6961:19:4;;:10;:19;;;;;;;;;;;:53;;;;7030:37;;;;;;;-1:-1:-1;;6961:19:4;;:10;;;;:19;-1:-1:-1;6961:10:4;-1:-1:-1;;;;;7030:37:4;;;;;;;;;6697:378;;:::o;441:196:50:-;527:7;569:12;561:6;;;;553:29;;;;-1:-1:-1;;;553:29:50;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;605:5:50;;;441:196::o;2606:173:4:-;2692:4;2709:40;2719:10;2731:9;2742:6;2709:9;:40::i;2072:761:49:-;2522:69;;;;;;;;;;;;;;;;;;2496:23;;2522:69;;-1:-1:-1;;;;;2522:27:49;;;2550:4;;2522:27;:69::i;:::-;2606:17;;2496:95;;-1:-1:-1;2606:21:49;2602:224;;2748:10;2737:30;;;;;;;;;;;;;;;-1:-1:-1;2737:30:49;2729:85;;;;-1:-1:-1;;;2729:85:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;944:1289:13;-1:-1:-1;;;;;1065:20:13;;1057:70;;;;-1:-1:-1;;;1057:70:13;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;;;;;1146:23:13;;1138:71;;;;-1:-1:-1;;;1138:71:13;;;;;;;:::i;:::-;1222:47;1243:6;1251:9;1262:6;1222:20;:47::i;:::-;-1:-1:-1;;;;;1284:16:13;;;;;;:5;:16;;;;;;;;1280:150;;1316:11;:27;;;;;;;;;;;;;-1:-1:-1;;;;;;1316:27:13;-1:-1:-1;;;;;1316:27:13;;;;;;;;1358:20;:22;;;;;;-1:-1:-1;1395:16:13;;;:5;1316:27;1395:16;;;;:23;;-1:-1:-1;;1395:23:13;;;;;;1280:150;1470:12;;-1:-1:-1;;;;;1470:12:13;1513:6;1534:36;;1530:467;;1597:16;1616:13;-1:-1:-1;;;;;1616:25:13;;:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1673:67;;-1:-1:-1;;;1673:67:13;;1597:46;;-1:-1:-1;1658:12:13;;-1:-1:-1;;;;;1673:28:13;;;;;:67;;1702:10;;1714:6;;1722:9;;1733:6;;1673:67;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1658:82;-1:-1:-1;1759:8:13;;1755:220;;-1:-1:-1;;;;;1823:20:13;;:10;:20;;;;;;;;;;;:30;;1848:4;1823:24;:30::i;:::-;-1:-1:-1;;;;;1800:20:13;;;:10;:20;;;;;;;;;;;:53;;;;1877:32;;1800:20;;1877:32;;;;1800:20;;-1:-1:-1;1800:10:13;-1:-1:-1;;;;;1877:32:13;;;1904:4;;1877:32;:::i;:::-;;;;;;;;1940:19;:9;1954:4;1940:13;:19::i;:::-;1928:31;;1755:220;1530:467;;;2028:72;2051:6;2028:72;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;2028:18:13;;:10;:18;;;;;;;;;;;;;:22;:72::i;:::-;-1:-1:-1;;;;;2007:18:13;;;:10;:18;;;;;;;;;;;:93;;;;2135:21;;;;;;;:36;;2161:9;2135:25;:36::i;:::-;-1:-1:-1;;;;;2111:21:13;;;:10;:21;;;;;;;;;;;:60;;;;2187:38;;2111:21;;2187:38;;;;2111:21;;-1:-1:-1;2111:10:13;-1:-1:-1;;;;;2187:38:13;;;2215:9;;2187:38;:::i;:::-;;;;;;;;944:1289;;;;;:::o;291:142:50:-;349:7;382:43;386:1;389;382:43;;;;;;;;;;;;;;;;;:3;:43::i;3671:195:0:-;3774:12;3806:52;3828:6;3836:4;3842:1;3845:12;3774;4975:18;4986:6;4975:10;:18::i;:::-;4967:60;;;;;-1:-1:-1;;;4967:60:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;5101:12;5115:23;5142:6;-1:-1:-1;;;;;5142:11:0;5162:5;5170:4;5142:33;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;5142:33:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5100:75;;;;5193:52;5211:7;5220:10;5232:12;5193:17;:52::i;:::-;5186:59;4723:530;-1:-1:-1;;;;;;;4723:530:0:o;753:422::-;1120:20;1159:8;;;753:422::o;7263:742::-;7378:12;7407:7;7403:595;;;-1:-1:-1;7438:10:0;7431:17;;7403:595;7552:17;;:21;7548:439;;7815:10;7809:17;7876:15;7863:10;7859:2;7855:19;7848:44;7763:148;7951:20;;-1:-1:-1;;;7951:20:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;7951:20:0;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;14:310:56:-;;137:2;125:9;116:7;112:23;108:32;105:2;;;158:6;150;143:22;105:2;189:16;;-1:-1:-1;;;;;234:31:56;;224:42;;214:2;;285:6;277;270:22;329:194;;452:2;440:9;431:7;427:23;423:32;420:2;;;473:6;465;458:22;420:2;-1:-1:-1;501:16:56;;410:113;-1:-1:-1;410:113:56:o;528:464::-;-1:-1:-1;;;;;823:15:56;;;805:34;;875:15;;;870:2;855:18;;848:43;927:15;;922:2;907:18;;900:43;974:2;959:18;;952:34;;;;754:3;739:19;;721:271::o;997:399::-;1199:2;1181:21;;;1238:2;1218:18;;;1211:30;1277:34;1272:2;1257:18;;1250:62;-1:-1:-1;;;1343:2:56;1328:18;;1321:33;1386:3;1371:19;;1171:225::o;1401:401::-;1603:2;1585:21;;;1642:2;1622:18;;;1615:30;1681:34;1676:2;1661:18;;1654:62;-1:-1:-1;;;1747:2:56;1732:18;;1725:35;1792:3;1777:19;;1575:227::o;1807:177::-;1953:25;;;1941:2;1926:18;;1908:76::o

Swarm Source

ipfs://725999c0ca07b422acb3d9bcb83ad290268d7af848cd1dec21d747a017a39ca1
Loading