Contract 0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb8

 
 
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0x92ab252257beb4870282669d5234ee6a58c87e9878ced5eb07638858b95dd81bApprove398631172023-03-02 2:07:4823 days 4 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.009230029028 199.628623341
0xd5aa21e281bb32f2f57d3c1a6d4c176aa71b07921da135c5a7a2d3726029a98cApprove390265572023-02-07 17:59:5145 days 12 hrs ago0xf2d72b1906f5acda9a5c6d0d331109bba385637e IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.012117836961 260.464211195
0xb7158f3b253ef81c65722c468e0ec7ee7782bb5c5b70a02c0f15e25e0946fcefApprove390177132023-02-07 12:44:2445 days 18 hrs ago0x8b9b2aca4911eff59b10664d3d4608a09ce6f02d IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.010757463257 231.702060331
0x7abfc6966456eda022bf22f03cbf068760ab1ee97e9c61cd2ca95553c2c019aeApprove378024182023-01-08 0:39:5676 days 6 hrs ago0xa3be222eeaede55029871733d71f82bc0da7b2de IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.003210156 69
0x841b90e056b7ebb110956e815b14e54925cced94b8dacebe7338e540076f29ffApprove377593242023-01-06 22:53:1677 days 8 hrs ago0xb027818c1209dd4d8e6b7d172c61ef9840724a1d IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.002419056975 51.99589407
0x27fa0718f9b2f492b981505ec70d3c4c02dc39a590779ecdce926e3345f2bc0bTransfer376781662023-01-04 22:26:2579 days 8 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.002705360579 49.515174329
0xa941d434a3ceaa8191d584af97fbb45c8d72db85cb5c45521179652cde49fde5Transfer376780702023-01-04 22:23:0279 days 8 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.002605581276 47.688952115
0x4a3a9da2cf8d50322ea55d73ded69f311fda6f9f5631cccf7744d76401af51abTransfer375587222023-01-01 22:49:4682 days 8 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.001960653839 35.885093239
0xcde9d3d1106097b125934d1e56a6b2b86df359397fc1759c7aa90c780d7008e7Transfer363546112022-12-03 0:31:54112 days 6 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.002239069324 40.980824801
0x0c25bfaeee6e8e44b1350ee5e5e8f982faaa96c29bb00c3adaa60d32dcd44132Transfer363545292022-12-03 0:29:06112 days 6 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.001974093063 36.131066187
0xb528c4a0c4df744998eb0206d84057eb2b32c6962c055a30ff4d2084c7da31f8Transfer363544632022-12-03 0:26:50112 days 6 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.002191460193 40.109453184
0xfeef6509922869a308474f9e6980374a6bfeb7a81a7510167c9061e54b1cdaedApprove354528592022-11-10 21:33:59134 days 9 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.007523736052 161.717308315
0x241297296885f64a4d5b6c6e4ad26e86278ce06420389b25fb5a128a643014c3Transfer352877802022-11-06 21:20:25138 days 9 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.006572069301 120.259644309
0x846e1fe74ac584a8adec12980f1fbde972e0406b6eb91268423178cc2ce9788fTransfer349265762022-10-29 1:32:46147 days 5 hrs ago0xb5f06e016c8ffe9e3308274eb0e8efcc3865efb5 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.002659046999 51.089342314
0x582d31979e9e17ce328f23ea942f7d8eb14a23674596af1d8cd76c4cc52a778dTransfer347215712022-10-24 0:53:11152 days 6 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.0052637 100
0x414a69020581f312cc9948f7d666c91f6ead0b17324115f31c35b57b7d44234eTransfer346803452022-10-23 0:50:38153 days 6 hrs ago0xb5f06e016c8ffe9e3308274eb0e8efcc3865efb5 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.0056835 100
0xd9edef1cfb55f3f15a1e4f11b82db9004313a85d9e967e5100f02a369e2fd2cdTransfer343959282022-10-16 0:44:07160 days 6 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.0382543 700
0xbe7ddde146bb788286c729e2cd9d8a0edf781deadc2833e32dd606acd35f824eTransfer343577782022-10-15 2:29:35161 days 4 hrs ago0xb5f06e016c8ffe9e3308274eb0e8efcc3865efb5 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.009632338344 169.478989091
0x7c92210aee3113454713a1338e16521a91b9ba5460ae8c040c0e64b951e299c3Approve340595772022-10-07 21:18:06168 days 9 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.00369792 80.000000012
0x4b5c08e18e48ede10d705296f34584c79528386f7327c5d575fdf789ece55132Transfer340595372022-10-07 21:16:46168 days 9 hrs ago0xb5f06e016c8ffe9e3308274eb0e8efcc3865efb5 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.0045468 80.000000012
0xe1bfafeb5bf1c50a6dd1a57ea52247cac432c1bafad538e1af996570c27d02ebTransfer338124982022-10-01 22:21:04174 days 8 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.00437192 80.000000013
0xaf0d73ce260b2f2adae68073d869489fddc4cec6540028d37e1c8fde141b0119Approve334430262022-09-22 23:07:03183 days 7 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.00369696 80.00000002
0xb9a96b205c96421af5e23dafc179790384fa40e4aae399db3d0692616ad349eaTransfer332796532022-09-18 23:38:30187 days 7 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.00437096 80.000000011
0x18ec3efbe6ecc774c5d6452b7bb0b02261109e6729c0fae9ba957046009dc1fcTransfer331157992022-09-15 0:38:21191 days 6 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.009771283344 80.003957465
0x962474ca67c5c5d30fb392847b98542460098962911c056e6198263d9c03641eTransfer329034952022-09-09 21:46:40196 days 9 hrs ago0x4f0f5547be4d3d58a35dba7f6c0b36656a6f5f05 IN  0xd7ffa295e4e2df471a80a1ac90e76e5d30e1fcb80 MATIC0.00437096 80.000000018
[ Download CSV Export 
Latest 1 internal transaction
Parent Txn Hash Block From To Value
0x38a1ccacfcc5f1b04629e58d13c49d8bacb6b31b6eb7c3f512d886cde7c9b6ad295043882022-06-13 4:56:29285 days 2 hrs ago 0x675365475d327855a2337807f58f3552fa065f7d  Contract Creation0 MATIC
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RootedToken

Compiler Version
v0.7.4+commit.3f05b770

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity Multiple files format)

File 1 of 55: 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 2 of 55: 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 3 of 55: 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) {
    return new EliteFloorCalculatorV1(root, _pancakeFactory);
}
 function createCalculator(RootedToken root, EliteToken elite) public onlyFactory() returns (EliteFloorCalculator) {
    return new EliteFloorCalculator(root, elite, wrappedToken, _pancakeFactory, _router);
}

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

File 4 of 55: 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 5 of 55: 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) {
    return new LiquidityController(dev, _router, wrappedToken, root, elite, calc, gate);
}

function createTokenTimelock(address dev) public onlyFactory() returns (TokenTimelock) {
    return new TokenTimelock(dev);
}
}

File 6 of 55: 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 7 of 55: 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 8 of 55: 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 9 of 55: 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 10 of 55: 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 11 of 55: 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 12 of 55: 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 {

    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;
    }

    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 rootAddress;
        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].rootAddress = 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].rootAddress));
        RootedTransferGate _transGate = calculatorFactory.createTransferGate(address(this),RootedToken(tokenDeployments[counter].rootAddress));
        EliteFloorCalculatorV1 _calcV1 = calculatorFactory.createCalculatorV1(RootedToken(tokenDeployments[counter].rootAddress));
        EliteFloorCalculator _calc = calculatorFactory.createCalculator(RootedToken(tokenDeployments[counter].rootAddress), 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].rootAddress), 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].rootAddress), 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].rootAddress), xName, xSymbol);
        RoyaltyPump _pump = feeSplitterFactory.createRoyaltyPump(address(this), address(_staking), address(RootedToken(tokenDeployments[counter].rootAddress)), 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].rootAddress), 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].rootAddress).setTransferGate(RootedTransferGate(deployData[counter].transGate));
        RootedToken(tokenDeployments[counter].rootAddress).setMinter(tokenDeployments[counter].MGD);
        RootedToken(tokenDeployments[counter].rootAddress).setLiquidityController(address(this), true);
        RootedToken(tokenDeployments[counter].rootAddress).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].rootAddress);
         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);

    }

    function feeLiqSetup(address _artist) public onlySignedAdmin() {
        
        //TODO UPDATE BELOW
        uint16[5] memory _collectRates = [
            1000,
            5000,
            500,
            500,
            3000
        ];
        //TODO UPDATE BELOW
        address[5] memory _collectors = [
            signedLiquidityController,
            deployData[counter].staking,
            address(0x0000000000000000000000000000000000000001),
            deployData[counter].liquidityController,
            _artist

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

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

        FeeSplitter(deployData[counter].feeSplitter).setRootedTokenFeeCollectors(RootedToken(tokenDeployments[counter].rootAddress),_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);
        //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].rootAddress), _burn, _sell, _keep);
    }

    function setChainTokenFeeCollectors(uint deploymentId, address[5] memory _collectors, uint16[5]  memory _collectRates) public onlySignedAdmin(){
        FeeSplitter(deployData[deploymentId].feeSplitter).setChainTokenFeeCollectors(RootedToken(tokenDeployments[deploymentId].rootAddress), _collectors, _collectRates);
    }

    function setRootedTokenFeeCollectors(uint deploymentId, address[5] memory _collectors, uint16[5]  memory _collectRates) public onlySignedAdmin(){
        FeeSplitter(deployData[deploymentId].feeSplitter).setRootedTokenFeeCollectors(RootedToken(tokenDeployments[deploymentId].rootAddress), _collectors, _collectRates);
    }

    function payOutFeeSplitter(uint deploymentId) public onlySignedAdmin(){
        FeeSplitter(deployData[deploymentId].feeSplitter).payFees(IGatedERC20(tokenDeployments[deploymentId].rootAddress));
    }
    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 FUNCTION?
    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].rootAddress).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));



    }



    //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].rootAddress).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 13 of 55: 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[5] memory collectors, uint16[5] 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[5] memory collectors, uint16[5] 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 14 of 55: FeeSplitterFactory.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 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) {
    return new FeeSplitter(_factory, _router);
}
function createStaking(address dev, RootedToken root, string calldata xToken, string calldata xSymbol) public onlyFactory() returns (StakingToken) {
    return new StakingToken(dev, root, xToken, xSymbol);
}

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

File 15 of 55: 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)
    {
    }
    modifier onlyController {
    require(msg.sender == dev || msg.sender == owner);
    _;
}

    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 16 of 55: 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 17 of 55: 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 18 of 55: 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 19 of 55: 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 20 of 55: 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 21 of 55: 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 22 of 55: 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 23 of 55: 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 24 of 55: 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 25 of 55: IPancakeCallee.sol
pragma solidity >=0.5.0;

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

File 26 of 55: 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 27 of 55: 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 28 of 55: 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 29 of 55: 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 30 of 55: 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 31 of 55: 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 55: 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 55: IWBNB.sol
// SPDX-License-Identifier: J-J-J-JENGA!!!
pragma solidity ^0.7.4;

interface IWBNB
{    
    function deposit() external payable;
}

File 34 of 55: 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 55: 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 55: 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 55: 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 55: 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 55: 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 55: 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 55: 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 55: 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.setMGEController(owner, true);
   return newGen;
}

function createMGD(address _factoryAddress) public onlyFactory() returns(MarketDistribution) {
    return new MarketDistribution(_factoryAddress);
}
 
    
}

File 43 of 55: 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 55: 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 55: 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 55: 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 47 of 55: 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 48 of 55: 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";

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;
    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;
    }
   
    //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 addLiquidity() private {
        gate.setUnrestricted(true);
        addLiq(chainToken.balanceOf(address(this)));
        gate.setUnrestricted(false);
    }
    //rates out of 10,000

//todo make below private
    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 49 of 55: 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 50 of 55: 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 51 of 55: 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 52 of 55: 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) {
    return new RootedToken(dev, name, ticker);
}

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

File 53 of 55: 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;

    function recoverTokens(IERC20 token) public override ownerOnly() 
    {
        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 54 of 55: 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 55 of 55: 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;
    }
    modifier onlyController {
    require(msg.sender == dev || msg.sender == owner);
    _;
}

    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":"_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"}]

608060405260058054600960a11b60ff60a01b19909116179055600680546001600160a01b031916331790556000600a553480156200003d57600080fd5b506040516200256438038062002564833981810160405260608110156200006357600080fd5b8151602083018051604051929492938301929190846401000000008211156200008b57600080fd5b908301906020820185811115620000a157600080fd5b8251640100000000811182820188101715620000bc57600080fd5b82525081516020918201929091019080838360005b83811015620000eb578181015183820152602001620000d1565b50505050905090810190601f168015620001195780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200013d57600080fd5b9083019060208201858111156200015357600080fd5b82516401000000008111828201881017156200016e57600080fd5b82525081516020918201929091019080838360005b838110156200019d57818101518382015260200162000183565b50505050905090810190601f168015620001cb5780820380516001836020036101000a031916815260200191505b506040525050600580546001600160a01b0319166001600160a01b038616179055508151839083908390839083908390839083908390620002149060039060208501906200023d565b5080516200022a9060049060208401906200023d565b50505050505050505050505050620002e9565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620002755760008555620002c0565b82601f106200029057805160ff1916838001178555620002c0565b82800160010185558215620002c0579182015b82811115620002c0578251825591602001919060010190620002a3565b50620002ce929150620002d2565b5090565b5b80821115620002ce5760008155600101620002d3565b61226b80620002f96000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c806361d8c81711610104578063a457c2d7116100a2578063b834aa2011610071578063b834aa201461054a578063dd62ed3e14610570578063f2fde38b1461059e578063fca3b5aa146105c4576101cf565b8063a457c2d7146104c4578063a9059cbb146104f0578063ab27c58b1461051c578063b497534314610542576101cf565b80638da5cb5b116100de5780638da5cb5b1461048f57806391cca3db1461049757806395d89b411461049f578063a0712d68146104a7576101cf565b806361d8c8171461042657806370a082311461044c578063862a4bf214610472576101cf565b8063313ce56711610171578063449113f21161014b578063449113f21461039c5780634dfefc4b146103ca5780634e71e0c8146103f0578063528d8b21146103f8576101cf565b8063313ce56714610335578063395093511461035357806342966c681461037f576101cf565b806316114acd116101ad57806316114acd146102b5578063178ef307146102dd57806318160ddd146102f757806323b872dd146102ff576101cf565b806306fdde03146101d45780630754617214610251578063095ea7b314610275575b600080fd5b6101dc6105ea565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102165781810151838201526020016101fe565b50505050905090810190601f1680156102435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610259610678565b604080516001600160a01b039092168252519081900360200190f35b6102a16004803603604081101561028b57600080fd5b506001600160a01b038135169060200135610687565b604080519115158252519081900360200190f35b6102db600480360360208110156102cb57600080fd5b50356001600160a01b031661069d565b005b6102e561078c565b60408051918252519081900360200190f35b6102e5610792565b6102a16004803603606081101561031557600080fd5b506001600160a01b03813581169160208101359091169060400135610798565b61033d61081f565b6040805160ff9092168252519081900360200190f35b6102a16004803603604081101561036957600080fd5b506001600160a01b03813516906020013561082f565b6102db6004803603602081101561039557600080fd5b503561086a565b6102db600480360360408110156103b257600080fd5b506001600160a01b0381351690602001351515610874565b6102a1600480360360208110156103e057600080fd5b50356001600160a01b0316610a4d565b6102db610a62565b6102db6004803603604081101561040e57600080fd5b506001600160a01b0381351690602001351515610ad5565b6102db6004803603602081101561043c57600080fd5b50356001600160a01b0316610b2c565b6102e56004803603602081101561046257600080fd5b50356001600160a01b0316610b7a565b6102596004803603602081101561048857600080fd5b5035610f99565b610259610fc3565b610259610fd2565b6101dc610fe1565b6102db600480360360208110156104bd57600080fd5b503561103c565b6102a1600480360360408110156104da57600080fd5b506001600160a01b03813516906020013561115c565b6102a16004803603604081101561050657600080fd5b506001600160a01b0381351690602001356111ab565b6102a16004803603602081101561053257600080fd5b50356001600160a01b031661121e565b610259611233565b6102a16004803603602081101561056057600080fd5b50356001600160a01b0316611242565b6102e56004803603604081101561058657600080fd5b506001600160a01b0381358116916020013516611257565b6102db600480360360208110156105b457600080fd5b50356001600160a01b0316611274565b6102db600480360360208110156105da57600080fd5b50356001600160a01b03166112e2565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156106705780601f1061064557610100808354040283529160200191610670565b820191906000526020600020905b81548152906001019060200180831161065357829003601f168201915b505050505081565b600f546001600160a01b031681565b6000610694338484611330565b50600192915050565b6006546001600160a01b031633146106e9576040805162461bcd60e51b815260206004820152600a6024820152694f776e6572206f6e6c7960b01b604482015290519081900360640190fd5b6106f28161141c565b6106fb57600080fd5b61078933826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561074c57600080fd5b505afa158015610760573d6000803e3d6000fd5b505050506040513d602081101561077657600080fd5b50516001600160a01b038416919061142e565b50565b600a5481565b60025481565b6001600160a01b0382166000908152600c602052604081205460ff16156107c8576107c360016114b3565b61080a565b60408051606081018252600080825260208201819052910152600e80547fffffffffffffff000000000000000000000000000000000000000000000000001690555b61081584848461163d565b90505b9392505050565b600554600160a01b900460ff1681565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161069491859061086590866116ac565b611330565b6107893382611706565b336000908152600d602052604090205460ff166108d8576040805162461bcd60e51b815260206004820152601960248201527f4c697175696469747920636f6e74726f6c6c6572206f6e6c7900000000000000604482015290519081900360640190fd5b306001600160a01b0316826001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561091b57600080fd5b505afa15801561092f573d6000803e3d6000fd5b505050506040513d602081101561094557600080fd5b50516001600160a01b031614806109d15750306001600160a01b0316826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b15801561099a57600080fd5b505afa1580156109ae573d6000803e3d6000fd5b505050506040513d60208110156109c457600080fd5b50516001600160a01b0316145b610a22576040805162461bcd60e51b815260206004820152600e60248201527f556e72656c617465642070616972000000000000000000000000000000000000604482015290519081900360640190fd5b6001600160a01b03919091166000908152600c60205260409020805460ff1916911515919091179055565b600b6020526000908152604090205460ff1681565b6007546001600160a01b03163314610a7957600080fd5b600780546001600160a01b031916905560065460405133916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600680546001600160a01b03191633179055565b6005546001600160a01b0316331480610af857506006546001600160a01b031633145b610b0157600080fd5b6001600160a01b03919091166000908152600d60205260409020805460ff1916911515919091179055565b6005546001600160a01b0316331480610b4f57506006546001600160a01b031633145b610b5857600080fd5b600880546001600160a01b0319166001600160a01b0392909216919091179055565b336000818152600c602052604081205490919060ff1615610f9057610b9d611f92565b5060408051606081018252600e546001600160a01b038116808352600160a01b820463ffffffff166020840152600160c01b90910460ff161515928201929092529032148015610bf6575043816020015163ffffffff16145b610c47576040805162461bcd60e51b815260206004820152601360248201527f4c6971756964697479206973206c6f636b656400000000000000000000000000604482015290519081900360640190fd5b806040015115610f8e57600080836001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610c8d57600080fd5b505afa158015610ca1573d6000803e3d6000fd5b505050506040513d6060811015610cb757600080fd5b508051602091820151604080517f0dfe168100000000000000000000000000000000000000000000000000000000815290516dffffffffffffffffffffffffffff93841696509290911693506000926001600160a01b03881692630dfe1681926004808201939291829003018186803b158015610d3357600080fd5b505afa158015610d47573d6000803e3d6000fd5b505050506040513d6020811015610d5d57600080fd5b505190506001600160a01b038116301415610ebe5781856001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015610dac57600080fd5b505afa158015610dc0573d6000803e3d6000fd5b505050506040513d6020811015610dd657600080fd5b5051604080517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038981166004830152915191909216916370a08231916024808301926020929190829003018186803b158015610e3b57600080fd5b505afa158015610e4f573d6000803e3d6000fd5b505050506040513d6020811015610e6557600080fd5b505110610eb9576040805162461bcd60e51b815260206004820152601360248201527f4c6971756964697479206973206c6f636b656400000000000000000000000000604482015290519081900360640190fd5b610f8a565b82816001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610f0c57600080fd5b505afa158015610f20573d6000803e3d6000fd5b505050506040513d6020811015610f3657600080fd5b505110610f8a576040805162461bcd60e51b815260206004820152601360248201527f4c6971756964697479206973206c6f636b656400000000000000000000000000604482015290519081900360640190fd5b5050505b505b61081883611802565b60098181548110610fa957600080fd5b6000918252602090912001546001600160a01b0316905081565b6006546001600160a01b031681565b6005546001600160a01b031681565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156106705780601f1061064557610100808354040283529160200191610670565b600f546001600160a01b0316331461109b576040805162461bcd60e51b815260206004820152600c60248201527f4e6f742061206d696e7465720000000000000000000000000000000000000000604482015290519081900360640190fd5b306001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110d457600080fd5b505afa1580156110e8573d6000803e3d6000fd5b505050506040513d60208110156110fe57600080fd5b505115611152576040805162461bcd60e51b815260206004820152600e60248201527f416c7265616479206d696e746564000000000000000000000000000000000000604482015290519081900360640190fd5b610789338261181d565b6000610694338461086585604051806060016040528060258152602001612211602591393360009081526001602090815260408083206001600160a01b038d168452909152902054919061190d565b336000908152600c602052604081205460ff16156111d2576111cd60006114b3565b611214565b60408051606081018252600080825260208201819052910152600e80547fffffffffffffff000000000000000000000000000000000000000000000000001690555b61081883836119a4565b600c6020526000908152604090205460ff1681565b6008546001600160a01b031681565b600d6020526000908152604090205460ff1681565b600160209081526000928352604080842090915290825290205481565b6006546001600160a01b031633146112c0576040805162461bcd60e51b815260206004820152600a6024820152694f776e6572206f6e6c7960b01b604482015290519081900360640190fd5b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633148061130557506006546001600160a01b031633145b61130e57600080fd5b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166113755760405162461bcd60e51b81526004018080602001828103825260248152602001806121c36024913960400191505060405180910390fd5b6001600160a01b0382166113ba5760405162461bcd60e51b81526004018080602001828103825260228152602001806121016022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038116301415919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526114ae9084906119b1565b505050565b6114bb611f92565b5060408051606081018252600e546001600160a01b0381168252600160a01b810463ffffffff166020830152600160c01b900460ff16151591810191909152611502611f92565b5060408051606081018252328082524363ffffffff16602083015284151592820192909252825190916001600160a01b039091161415806115575750806020015163ffffffff16826020015163ffffffff1614155b8061156e5750806040015115158260400151151514155b6115a95760405162461bcd60e51b81526004018080602001828103825260318152602001806121496031913960400191505060405180910390fd5b8051600e805460208401516040909401511515600160c01b027fffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffff63ffffffff909516600160a01b027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff6001600160a01b039095166001600160a01b0319909316929092179390931617929092161790555050565b600061164a848484611a62565b6001600160a01b038416600090815260016020908152604080832033845290915290205460001981146116a1576116a185336108658660405180606001604052806028815260200161217a6028913986919061190d565b506001949350505050565b600082820183811015610818576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b03821661174b5760405162461bcd60e51b81526004018080602001828103825260218152602001806121a26021913960400191505060405180910390fd5b611757826000836114ae565b611794816040518060600160405280602281526020016120df602291396001600160a01b038516600090815260208190526040902054919061190d565b6001600160a01b0383166000908152602081905260409020556002546117ba9082611dbe565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b031660009081526020819052604090205490565b6001600160a01b038216611878576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b611884600083836114ae565b60025461189190826116ac565b6002556001600160a01b0382166000908152602081905260409020546118b790826116ac565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818484111561199c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611961578181015183820152602001611949565b50505050905090810190601f16801561198e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000610694338484611a62565b6060611a06826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611e009092919063ffffffff16565b8051909150156114ae57808060200190516020811015611a2557600080fd5b50516114ae5760405162461bcd60e51b815260040180806020018281038252602a8152602001806121e7602a913960400191505060405180910390fd5b6001600160a01b038316611a915760405162461bcd60e51b8152600401611a8890612078565b60405180910390fd5b6001600160a01b038216611ab75760405162461bcd60e51b8152600401611a889061201b565b611ac28383836114ae565b6001600160a01b0382166000908152600b602052604090205460ff16611b4e576009805460018082019092557f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319166001600160a01b038516908117909155600a8054830190556000908152600b60205260409020805460ff191690911790555b6008546001600160a01b0316818115611cf1576000826001600160a01b0316636052970c6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b9c57600080fd5b505afa158015611bb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd49190611fb2565b90506000836001600160a01b03166395c47d06338989896040518563ffffffff1660e01b8152600401611c0a9493929190611ff1565b602060405180830381600087803b158015611c2457600080fd5b505af1158015611c38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c5c9190611fd9565b90508015611cee576001600160a01b038216600090815260208190526040902054611c8790826116ac565b6001600160a01b0380841660008181526020819052604090819020939093559151908916907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611cd99085906120d5565b60405180910390a3611ceb8382611dbe565b92505b50505b611d2e83604051806060016040528060268152602001612123602691396001600160a01b038816600090815260208190526040902054919061190d565b6001600160a01b038087166000908152602081905260408082209390935590861681522054611d5d90826116ac565b6001600160a01b0380861660008181526020819052604090819020939093559151908716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611daf9085906120d5565b60405180910390a35050505050565b600061081883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061190d565b6060610815848460008585611e1485611f26565b611e65576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310611ea45780518252601f199092019160209182019101611e85565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611f06576040519150601f19603f3d011682016040523d82523d6000602084013e611f0b565b606091505b5091509150611f1b828286611f2c565b979650505050505050565b3b151590565b60608315611f3b575081610818565b825115611f4b5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315611961578181015183820152602001611949565b604080516060810182526000808252602082018190529181019190915290565b600060208284031215611fc3578081fd5b81516001600160a01b0381168114610818578182fd5b600060208284031215611fea578081fd5b5051919050565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201527f6573730000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460408201527f6472657373000000000000000000000000000000000000000000000000000000606082015260800190565b9081526020019056fe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654c6971756964697479206973206c6f636b65642028506c656173652074727920616761696e206e65787420626c6f636b2945524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212208f956bd1215697511d1291fdd0441e4d52f78cba42d70809bd7335ebc2f6b44364736f6c6343000704003300000000000000000000000084408536ca42b100fab80b3a8f3bb8280efcedd4000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000850686174436f696e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045048415400000000000000000000000000000000000000000000000000000000

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

00000000000000000000000084408536ca42b100fab80b3a8f3bb8280efcedd4000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000850686174436f696e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045048415400000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _dev (address): 0x84408536ca42b100fab80b3a8f3bb8280efcedd4
Arg [1] : _name (string): PhatCoin
Arg [2] : _symbol (string): PHAT

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 00000000000000000000000084408536ca42b100fab80b3a8f3bb8280efcedd4
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000008
Arg [4] : 50686174436f696e000000000000000000000000000000000000000000000000
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [6] : 5048415400000000000000000000000000000000000000000000000000000000


Deployed ByteCode Sourcemap

504:580:45:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1663:27:4;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;734:21:45;;;:::i;:::-;;;;-1:-1:-1;;;;;734:21:45;;;;;;;;;;;;;;2926:167:4;;;;;;;;;;;;;;;;-1:-1:-1;2926:167:4;;-1:-1:-1;;;;;2926:167:4;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;428:196:53;;;;;;;;;;;;;;;;-1:-1:-1;428:196:53;-1:-1:-1;;;;;428:196:53;;:::i;:::-;;582:39:13;;;:::i;:::-;;;;;;;;;;;;;;;;1619:35:4;;;:::i;3148:424:36:-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;3148:424:36;;;;;;;;;;;;;;;;;:::i;1758:35:4:-;;;:::i;:::-;;;;;;;;;;;;;;;;;;;4404:212;;;;;;;;;;;;;;;;-1:-1:-1;4404:212:4;;-1:-1:-1;;;;;4404:212:4;;;;;;:::i;2333:95:13:-;;;;;;;;;;;;;;;;-1:-1:-1;2333:95:13;;:::i;716:358:36:-;;;;;;;;;;;;;;;;-1:-1:-1;716:358:36;;-1:-1:-1;;;;;716:358:36;;;;;;;;:::i;628:37:13:-;;;;;;;;;;;;;;;;-1:-1:-1;628:37:13;-1:-1:-1;;;;;628:37:13;;:::i;653:222:43:-;;;:::i;1082:183:36:-;;;;;;;;;;;;;;;;-1:-1:-1;1082:183:36;;-1:-1:-1;;;;;1082:183:36;;;;;;;;:::i;889:139:13:-;;;;;;;;;;;;;;;;-1:-1:-1;889:139:13;-1:-1:-1;;;;;889:139:13;;:::i;1273:926:36:-;;;;;;;;;;;;;;;;-1:-1:-1;1273:926:36;-1:-1:-1;;;;;1273:926:36;;:::i;546:29:13:-;;;;;;;;;;;;;;;;-1:-1:-1;546:29:13;;:::i;330:42:43:-;;;:::i;1733:18:4:-;;;:::i;1697:29::-;;;:::i;878:203:45:-;;;;;;;;;;;;;;;;-1:-1:-1;878:203:45;;:::i;5119:263:4:-;;;;;;;;;;;;;;;;-1:-1:-1;5119:263:4;;-1:-1:-1;;;;;5119:263:4;;;;;;:::i;2729:411:36:-;;;;;;;;;;;;;;;;-1:-1:-1;2729:411:36;;-1:-1:-1;;;;;2729:411:36;;;;;;:::i;301:57::-;;;;;;;;;;;;;;;;-1:-1:-1;301:57:36;-1:-1:-1;;;;;301:57:36;;:::i;497:42:13:-;;;:::i;365:52:36:-;;;;;;;;;;;;;;;;-1:-1:-1;365:52:36;-1:-1:-1;;;;;365:52:36;;:::i;1535:75:4:-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;1535:75:4;;;;;;;;;;:::i;525:120:43:-;;;;;;;;;;;;;;;;-1:-1:-1;525:120:43;-1:-1:-1;;;;;525:120:43;;:::i;770:100:45:-;;;;;;;;;;;;;;;;-1:-1:-1;770:100:45;-1:-1:-1;;;;;770:100:45;;:::i;1663:27:4:-;;;;;;;;;;;;;;;-1:-1:-1;;1663:27:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;734:21:45:-;;;-1:-1:-1;;;;;734:21:45;;:::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;428:196:53:-;477:5:43;;-1:-1:-1;;;;;477:5:43;463:10;:19;454:43;;;;;-1:-1:-1;;;454:43:43;;;;;;;;;;;;-1:-1:-1;;;454:43:43;;;;;;;;;;;;;;;519:23:53::1;536:5;519:16;:23::i;:::-;510:33;;;::::0;::::1;;585:30;::::0;;-1:-1:-1;;;585:30:53;;609:4:::1;585:30;::::0;::::1;::::0;;;554:62:::1;::::0;573:10:::1;::::0;-1:-1:-1;;;;;585:15:53;::::1;::::0;::::1;::::0;:30;;;;;::::1;::::0;;;;;;;;:15;:30;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;585:30:53;-1:-1:-1;;;;;554:18:53;::::1;::::0;;::::1;:62::i;:::-;428:196:::0;:::o;582:39:13:-;;;;:::o;1619:35:4:-;;;;:::o;3148:424:36:-;-1:-1:-1;;;;;3281:44:36;;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:36;;;;;;;;;;;;3402:14;:88;;;;;;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;2333:95:13:-;2395:25;2401:10;2413:6;2395:5;:25::i;716:358:36:-;846:10;826:31;;;;:19;:31;;;;;;;;817:70;;;;;-1:-1:-1;;;817:70:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;907:23;;;-1:-1:-1;;;907:23:36;;;;942:4;;-1:-1:-1;;;;;907:21:36;;;;;:23;;;;;;;;;;;;;;;:21;:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;907:23:36;-1:-1:-1;;;;;907:40:36;;;:84;;-1:-1:-1;951:23:36;;;;;;;;986:4;;-1:-1:-1;;;;;951:21:36;;;;;:23;;;;;;;;;;;;;;;:21;:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;951:23:36;-1:-1:-1;;;;;951:40:36;;907:84;898:112;;;;;-1:-1:-1;;;898:112:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;1021:35:36;;;;;;;;:19;:35;;;;;:45;;-1:-1:-1;;1021:45:36;;;;;;;;;;716:358::o;628:37:13:-;;;;;;;;;;;;;;;:::o;653:222:43:-;720:12;;-1:-1:-1;;;;;720:12:43;736:10;720:26;711:36;;;;;;758:12;:25;;-1:-1:-1;;;;;;758:25:43;;;820:5;;799:39;;827:10;;-1:-1:-1;;;;;820:5:43;;799:39;;-1:-1:-1;;799:39:43;849:5;:18;;-1:-1:-1;;;;;;849:18:43;857:10;849:18;;;653:222::o;1082:183:36:-;842:3:13;;-1:-1:-1;;;;;842:3:13;828:10;:17;;:40;;-1:-1:-1;863:5:13;;-1:-1:-1;;;;;863:5:13;849:10;:19;828:40;820:49;;;;;;-1:-1:-1;;;;;1202:41:36;;;::::1;;::::0;;;:19:::1;:41;::::0;;;;:55;;-1:-1:-1;;1202:55:36::1;::::0;::::1;;::::0;;;::::1;::::0;;1082:183::o;889:139:13:-;842:3;;-1:-1:-1;;;;;842:3:13;828:10;:17;;:40;;-1:-1:-1;863:5:13;;-1:-1:-1;;;;;863:5:13;849:10;:19;828:40;820:49;;;;;;992:12:::1;:28:::0;;-1:-1:-1;;;;;;992:28:13::1;-1:-1:-1::0;;;;;992:28:13;;;::::1;::::0;;;::::1;::::0;;889:139::o;1273:926:36:-;1406:10;1339:7;1433:25;;;:19;:25;;;;;;1339:7;;1406:10;1433:25;;1429:721;;;1475:22;;:::i;:::-;-1:-1:-1;1475:39:36;;;;;;;;1500:14;1475:39;-1:-1:-1;;;;;1475:39:36;;;;;-1:-1:-1;;;1475:39:36;;;;;;;;-1:-1:-1;;;1475:39:36;;;;;;;;;;;;;;;1553:9;1538:24;:60;;;;;1586:12;1566:4;:16;;;:32;;;1538:60;1529:93;;;;;-1:-1:-1;;;1529:93:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;1641:4;:17;;;1637:502;;;1680:16;1698;1719:4;-1:-1:-1;;;;;1719:16:36;;:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1719:18:36;;;;;;;;1779:13;;-1:-1:-1;;;1779:13:36;;;;1679:58;;;;;-1:-1:-1;1679:58:36;;;;;-1:-1:-1;1756:13:36;;-1:-1:-1;;;;;1779:11:36;;;;;:13;;;;;1719:18;1779:13;;;;;;:11;:13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1779:13:36;;-1:-1:-1;1843:4:36;-1:-1:-1;;;;;1816:32:36;;;1812:312;;;1931:8;1889:4;-1:-1:-1;;;;;1889:11:36;;:13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1889:13:36;1882:46;;;-1:-1:-1;;;1882:46:36;;-1:-1:-1;;;;;1882:46:36;;;;;;;;;:31;;;;;;;:46;;;;;1889:13;;1882:46;;;;;;;:31;:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1882:46:36;:57;1873:90;;;;;-1:-1:-1;;;1873:90:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;1812:312;;;2038:31;;;-1:-1:-1;;;2038:31:36;;-1:-1:-1;;;;;2038:31:36;;;;;;;;;2072:8;;2038:16;;;;;:31;;;;;;;;;;;;;;:16;:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2038:31:36;:42;2029:75;;;;;-1:-1:-1;;;2029:75:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;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:43:-;;;-1:-1:-1;;;;;330:42:43;;:::o;1733:18:4:-;;;-1:-1:-1;;;;;1733:18:4;;:::o;1697:29::-;;;;;;;;;;;;;;;-1:-1:-1;;1697:29:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;878:203:45;953:6;;-1:-1:-1;;;;;953:6:45;939:10;:20;931:45;;;;;-1:-1:-1;;;931:45:45;;;;;;;;;;;;;;;;;;;;;;;;;;;;995:4;-1:-1:-1;;;;;995:16:45;;:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;995:18:45;:23;987:50;;;;;-1:-1:-1;;;987:50:45;;;;;;;;;;;;;;;;;;;;;;;;;;;;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:36:-;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:36;;;;;;;;;;;;2982:14;:88;;;;;;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:36:-;;;;;;;;;;;;;;;:::o;1535:75:4:-;;;;;;;;;;;;;;;;;;;;;;;;:::o;525:120:43:-;477:5;;-1:-1:-1;;;;;477:5:43;463:10;:19;454:43;;;;;-1:-1:-1;;;454:43:43;;;;;;;;;;;;-1:-1:-1;;;454:43:43;;;;;;;;;;;;;;;614:12:::1;:23:::0;;-1:-1:-1;;;;;;614:23:43::1;-1:-1:-1::0;;;;;614:23:43;;;::::1;::::0;;;::::1;::::0;;525:120::o;770:100:45:-;842:3:13;;-1:-1:-1;;;;;842:3:13;828:10;:17;;:40;;-1:-1:-1;863:5:13;;-1:-1:-1;;;;;863:5:13;849:10;:19;828:40;820:49;;;;;;846:6:45::1;:16:::0;;-1:-1:-1;;;;;;846:16:45::1;-1:-1:-1::0;;;;;846:16:45;;;::::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;632:142:53:-;-1:-1:-1;;;;;734:31:53;760:4;734:31;;;632:142::o;829:177:48:-;939:58;;;-1:-1:-1;;;;;939:58:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;962:23;939:58;;;912:86;;932:5;;912:19;:86::i;:::-;829:177;;;:::o;2207:514:36:-;2273:22;;:::i;:::-;-1:-1:-1;2273:39:36;;;;;;;;2298:14;2273:39;-1:-1:-1;;;;;2273:39:36;;;;-1:-1:-1;;;2273:39:36;;;;;;;;-1:-1:-1;;;2273:39:36;;;;;;;;;;;;;2323:23;;:::i;:::-;-1:-1:-1;2349:146:36;;;;;;;;2384:9;2349:146;;;;2428:12;2349:146;;;;;;;;;;;;;;;2515:11;;2349:146;;-1:-1:-1;;;;;2515:27:36;;;;;;: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:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2691:22;;:14;:22;;;;;;;;;;;;;-1:-1:-1;;;2691:22:36;;;;;;-1:-1:-1;;;2691:22:36;;-1:-1:-1;;;;;2691:22:36;;;-1:-1:-1;;;;;;2691:22:36;;;;;;;;;;;;;;;;;;;-1:-1:-1;;2207:514:36: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:49:-;156:7;194:5;;;218:6;;;;210:46;;;;;-1:-1:-1;;;210:46:49;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;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;;;;;;;6961:19;;:10;;7030:37;;;;;;;;;;6697:378;;:::o;441:196:49:-;527:7;569:12;561:6;;;;553:29;;;;-1:-1:-1;;;553:29:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;605:5:49;;;441:196::o;2606:173:4:-;2692:4;2709:40;2719:10;2731:9;2742:6;2709:9;:40::i;2072:761:48:-;2522:69;;;;;;;;;;;;;;;;;;2496:23;;2522:69;;-1:-1:-1;;;;;2522:27:48;;;2550:4;;2522:27;:69::i;:::-;2606:17;;2496:95;;-1:-1:-1;2606:21:48;2602:224;;2748:10;2737:30;;;;;;;;;;;;;;;-1:-1:-1;2737:30:48;2729:85;;;;-1:-1:-1;;;2729:85:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1036:1289:13;-1:-1:-1;;;;;1157:20:13;;1149:70;;;;-1:-1:-1;;;1149:70:13;;;;;;;:::i;:::-;;;;;;;;;-1:-1:-1;;;;;1238:23:13;;1230:71;;;;-1:-1:-1;;;1230:71:13;;;;;;;:::i;:::-;1314:47;1335:6;1343:9;1354:6;1314:20;:47::i;:::-;-1:-1:-1;;;;;1376:16:13;;;;;;:5;:16;;;;;;;;1372:150;;1408:11;:27;;;;;;;;;;;;;-1:-1:-1;;;;;;1408:27:13;-1:-1:-1;;;;;1408:27:13;;;;;;;;1450:20;:22;;;;;;-1:-1:-1;1487:16:13;;;:5;1408:27;1487:16;;;;:23;;-1:-1:-1;;1487:23:13;;;;;;1372:150;1562:12;;-1:-1:-1;;;;;1562:12:13;1605:6;1626:36;;1622:467;;1689:16;1708:13;-1:-1:-1;;;;;1708:25:13;;:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1765:67;;;;;1689:46;;-1:-1:-1;1750:12:13;;-1:-1:-1;;;;;1765:28:13;;;;;:67;;1794:10;;1806:6;;1814:9;;1825:6;;1765:67;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;1750:82;-1:-1:-1;1851:8:13;;1847:220;;-1:-1:-1;;;;;1915:20:13;;:10;:20;;;;;;;;;;;:30;;1940:4;1915:24;:30::i;:::-;-1:-1:-1;;;;;1892:20:13;;;:10;:20;;;;;;;;;;;;:53;;;;1969:32;;;;;;;;;;1996:4;;1969:32;:::i;:::-;;;;;;;;2032:19;:9;2046:4;2032:13;:19::i;:::-;2020:31;;1847:220;1622:467;;;2120:72;2143:6;2120:72;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;2120:18:13;;:10;:18;;;;;;;;;;;;;:22;:72::i;:::-;-1:-1:-1;;;;;2099:18:13;;;:10;:18;;;;;;;;;;;:93;;;;2227:21;;;;;;;:36;;2253:9;2227:25;:36::i;:::-;-1:-1:-1;;;;;2203:21:13;;;:10;:21;;;;;;;;;;;;:60;;;;2279:38;;;;;;;;;;2307:9;;2279:38;:::i;:::-;;;;;;;;1036:1289;;;;;:::o;291:142:49:-;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:333:55:-;;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:54:55;;224:65;;214:2;;308:6;300;293:22;352:194;;475:2;463:9;454:7;450:23;446:32;443:2;;;496:6;488;481:22;443:2;-1:-1:-1;524:16:55;;433:113;-1:-1:-1;433:113:55:o;551:487::-;-1:-1:-1;;;;;869:15:55;;;851:34;;921:15;;;916:2;901:18;;894:43;973:15;;968:2;953:18;;946:43;1020:2;1005:18;;998:34;;;;777:3;762:19;;744:294::o;1043:399::-;1245:2;1227:21;;;1284:2;1264:18;;;1257:30;1323:34;1318:2;1303:18;;1296:62;1394:5;1389:2;1374:18;;1367:33;1432:3;1417:19;;1217:225::o;1447:401::-;1649:2;1631:21;;;1688:2;1668:18;;;1661:30;1727:34;1722:2;1707:18;;1700:62;1798:7;1793:2;1778:18;;1771:35;1838:3;1823:19;;1621:227::o;1853:177::-;1999:25;;;1987:2;1972:18;;1954:76::o

Swarm Source

ipfs://8f956bd1215697511d1291fdd0441e4d52f78cba42d70809bd7335ebc2f6b443
Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.