ETH Price: $3,391.47 (+4.09%)

Contract

0xbAF9A5d4b0052359326A6CDAb54BABAa3a3A9643
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00
Transaction Hash
Method
Block
From
To
Deploy196323952024-04-11 12:31:11256 days ago1712838671IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.1322702728.66000462
Deploy170917992023-04-21 2:26:47612 days ago1682044007IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.185473640
Deploy170164542023-04-10 7:53:59623 days ago1681113239IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0868768818.64061206
Deploy170036302023-04-08 12:17:59625 days ago1680956279IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.1034225522.2984708
Deploy169069602023-03-25 20:50:11639 days ago1679777411IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0703796215.24586206
Deploy169065172023-03-25 19:21:35639 days ago1679772095IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0828232517.91295148
Deploy168050202023-03-11 13:03:59653 days ago1678539839IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.2714256158.36123579
Deploy167391512023-03-02 6:38:11662 days ago1677739091IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.087965719.05614291
Deploy166274112023-02-14 13:53:47678 days ago1676382827IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.1344625929.11330443
Deploy165645862023-02-05 19:11:23687 days ago1675624283IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.1073655823.11220205
Deploy165484592023-02-03 13:09:35689 days ago1675429775IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.1008616921.81281012
Deploy164477492023-01-20 11:34:35703 days ago1674214475IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0646233513.99955677
Deploy164325032023-01-18 8:29:59705 days ago1674030599IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0685782914.86422253
Deploy162938772022-12-30 0:03:59725 days ago1672358639IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0788549217.08185384
Deploy162614652022-12-25 11:29:23729 days ago1671967763IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0496561310.75718819
Deploy162556302022-12-24 15:56:35730 days ago1671897395IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0527692211.43104005
Default Fee Vote162467522022-12-23 10:14:11731 days ago1671790451IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0008617613.00703554
Default Fee Vote162332042022-12-21 12:53:59733 days ago1671627239IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0007952212.56937703
Default Decay Pe...162218682022-12-19 22:56:59735 days ago1671490619IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0010616817.16209103
Default Fee Vote162218652022-12-19 22:56:23735 days ago1671490583IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0011020417.4189711
Default Fee Vote161795302022-12-14 1:03:35741 days ago1670979815IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0010237915.44959557
Default Slippage...161795192022-12-14 1:01:23741 days ago1670979683IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0009437814.24222142
Governance Share...161795172022-12-14 1:00:59741 days ago1670979659IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0008292812.50955622
Deploy161746632022-12-13 8:42:59741 days ago1670920979IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0643854713.85846594
Default Decay Pe...161664772022-12-12 5:15:23742 days ago1670822123IN
1inch Liquidity Protocol: Factory Contract
0 ETH0.0008065413.0378677
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MooniswapFactory

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion, Audited
File 1 of 30 : MooniswapFactory.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "./interfaces/IMooniswapDeployer.sol";
import "./interfaces/IMooniswapFactory.sol";
import "./libraries/UniERC20.sol";
import "./Mooniswap.sol";
import "./governance/MooniswapFactoryGovernance.sol";


contract MooniswapFactory is IMooniswapFactory, MooniswapFactoryGovernance {
    using UniERC20 for IERC20;

    event Deployed(
        Mooniswap indexed mooniswap,
        IERC20 indexed token1,
        IERC20 indexed token2
    );

    IMooniswapDeployer public immutable mooniswapDeployer;
    address public immutable poolOwner;
    Mooniswap[] public allPools;
    mapping(Mooniswap => bool) public override isPool;
    mapping(IERC20 => mapping(IERC20 => Mooniswap)) private _pools;

    constructor (address _poolOwner, IMooniswapDeployer _mooniswapDeployer, address _governanceMothership) public MooniswapFactoryGovernance(_governanceMothership) {
        poolOwner = _poolOwner;
        mooniswapDeployer = _mooniswapDeployer;
    }

    function getAllPools() external view returns(Mooniswap[] memory) {
        return allPools;
    }

    function pools(IERC20 tokenA, IERC20 tokenB) external view override returns (Mooniswap pool) {
        (IERC20 token1, IERC20 token2) = sortTokens(tokenA, tokenB);
        return _pools[token1][token2];
    }

    function deploy(IERC20 tokenA, IERC20 tokenB) public returns(Mooniswap pool) {
        require(tokenA != tokenB, "Factory: not support same tokens");
        (IERC20 token1, IERC20 token2) = sortTokens(tokenA, tokenB);
        require(_pools[token1][token2] == Mooniswap(0), "Factory: pool already exists");

        string memory symbol1 = token1.uniSymbol();
        string memory symbol2 = token2.uniSymbol();

        pool = mooniswapDeployer.deploy(
            token1,
            token2,
            string(abi.encodePacked("1inch Liquidity Pool (", symbol1, "-", symbol2, ")")),
            string(abi.encodePacked("1LP-", symbol1, "-", symbol2)),
            poolOwner
        );

        _pools[token1][token2] = pool;
        allPools.push(pool);
        isPool[pool] = true;

        emit Deployed(pool, token1, token2);
    }

    function sortTokens(IERC20 tokenA, IERC20 tokenB) public pure returns(IERC20, IERC20) {
        if (tokenA < tokenB) {
            return (tokenA, tokenB);
        }
        return (tokenB, tokenA);
    }
}

File 2 of 30 : Mooniswap.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./interfaces/IFeeCollector.sol";
import "./libraries/UniERC20.sol";
import "./libraries/Sqrt.sol";
import "./libraries/VirtualBalance.sol";
import "./governance/MooniswapGovernance.sol";


contract Mooniswap is MooniswapGovernance {
    using Sqrt for uint256;
    using SafeMath for uint256;
    using UniERC20 for IERC20;
    using VirtualBalance for VirtualBalance.Data;

    struct Balances {
        uint256 src;
        uint256 dst;
    }

    struct SwapVolumes {
        uint128 confirmed;
        uint128 result;
    }

    struct Fees {
        uint256 fee;
        uint256 slippageFee;
    }

    event Error(string reason);

    event Deposited(
        address indexed sender,
        address indexed receiver,
        uint256 share,
        uint256 token0Amount,
        uint256 token1Amount
    );

    event Withdrawn(
        address indexed sender,
        address indexed receiver,
        uint256 share,
        uint256 token0Amount,
        uint256 token1Amount
    );

    event Swapped(
        address indexed sender,
        address indexed receiver,
        address indexed srcToken,
        address dstToken,
        uint256 amount,
        uint256 result,
        uint256 srcAdditionBalance,
        uint256 dstRemovalBalance,
        address referral
    );

    event Sync(
        uint256 srcBalance,
        uint256 dstBalance,
        uint256 fee,
        uint256 slippageFee,
        uint256 referralShare,
        uint256 governanceShare
    );

    uint256 private constant _BASE_SUPPLY = 1000;  // Total supply on first deposit

    IERC20 public immutable token0;
    IERC20 public immutable token1;
    mapping(IERC20 => SwapVolumes) public volumes;
    mapping(IERC20 => VirtualBalance.Data) public virtualBalancesForAddition;
    mapping(IERC20 => VirtualBalance.Data) public virtualBalancesForRemoval;

    modifier whenNotShutdown {
        require(mooniswapFactoryGovernance.isActive(), "Mooniswap: factory shutdown");
        _;
    }

    constructor(
        IERC20 _token0,
        IERC20 _token1,
        string memory name,
        string memory symbol,
        IMooniswapFactoryGovernance _mooniswapFactoryGovernance
    )
        public
        ERC20(name, symbol)
        MooniswapGovernance(_mooniswapFactoryGovernance)
    {
        require(bytes(name).length > 0, "Mooniswap: name is empty");
        require(bytes(symbol).length > 0, "Mooniswap: symbol is empty");
        require(_token0 != _token1, "Mooniswap: duplicate tokens");
        token0 = _token0;
        token1 = _token1;
    }

    function getTokens() external view returns(IERC20[] memory tokens) {
        tokens = new IERC20[](2);
        tokens[0] = token0;
        tokens[1] = token1;
    }

    function tokens(uint256 i) external view returns(IERC20) {
        if (i == 0) {
            return token0;
        } else if (i == 1) {
            return token1;
        } else {
            revert("Pool has two tokens");
        }
    }

    function getBalanceForAddition(IERC20 token) public view returns(uint256) {
        uint256 balance = token.uniBalanceOf(address(this));
        return Math.max(virtualBalancesForAddition[token].current(decayPeriod(), balance), balance);
    }

    function getBalanceForRemoval(IERC20 token) public view returns(uint256) {
        uint256 balance = token.uniBalanceOf(address(this));
        return Math.min(virtualBalancesForRemoval[token].current(decayPeriod(), balance), balance);
    }

    function getReturn(IERC20 src, IERC20 dst, uint256 amount) external view returns(uint256) {
        return _getReturn(src, dst, amount, getBalanceForAddition(src), getBalanceForRemoval(dst), fee(), slippageFee());
    }

    function deposit(uint256[2] memory maxAmounts, uint256[2] memory minAmounts) external payable returns(uint256 fairSupply, uint256[2] memory receivedAmounts) {
        return depositFor(maxAmounts, minAmounts, msg.sender);
    }

    function depositFor(uint256[2] memory maxAmounts, uint256[2] memory minAmounts, address target) public payable nonReentrant returns(uint256 fairSupply, uint256[2] memory receivedAmounts) {
        IERC20[2] memory _tokens = [token0, token1];
        require(msg.value == (_tokens[0].isETH() ? maxAmounts[0] : (_tokens[1].isETH() ? maxAmounts[1] : 0)), "Mooniswap: wrong value usage");

        uint256 totalSupply = totalSupply();

        if (totalSupply == 0) {
            fairSupply = _BASE_SUPPLY.mul(99);
            _mint(address(this), _BASE_SUPPLY); // Donate up to 1%

            for (uint i = 0; i < maxAmounts.length; i++) {
                fairSupply = Math.max(fairSupply, maxAmounts[i]);

                require(maxAmounts[i] > 0, "Mooniswap: amount is zero");
                require(maxAmounts[i] >= minAmounts[i], "Mooniswap: minAmount not reached");

                _tokens[i].uniTransferFrom(msg.sender, address(this), maxAmounts[i]);
                receivedAmounts[i] = maxAmounts[i];
            }
        }
        else {
            uint256[2] memory realBalances;
            for (uint i = 0; i < realBalances.length; i++) {
                realBalances[i] = _tokens[i].uniBalanceOf(address(this)).sub(_tokens[i].isETH() ? msg.value : 0);
            }

            // Pre-compute fair supply
            fairSupply = type(uint256).max;
            for (uint i = 0; i < maxAmounts.length; i++) {
                fairSupply = Math.min(fairSupply, totalSupply.mul(maxAmounts[i]).div(realBalances[i]));
            }

            uint256 fairSupplyCached = fairSupply;

            for (uint i = 0; i < maxAmounts.length; i++) {
                require(maxAmounts[i] > 0, "Mooniswap: amount is zero");
                uint256 amount = realBalances[i].mul(fairSupplyCached).add(totalSupply - 1).div(totalSupply);
                require(amount >= minAmounts[i], "Mooniswap: minAmount not reached");

                _tokens[i].uniTransferFrom(msg.sender, address(this), amount);
                receivedAmounts[i] = _tokens[i].uniBalanceOf(address(this)).sub(realBalances[i]);
                fairSupply = Math.min(fairSupply, totalSupply.mul(receivedAmounts[i]).div(realBalances[i]));
            }

            uint256 _decayPeriod = decayPeriod();  // gas savings
            for (uint i = 0; i < maxAmounts.length; i++) {
                virtualBalancesForRemoval[_tokens[i]].scale(_decayPeriod, realBalances[i], totalSupply.add(fairSupply), totalSupply);
                virtualBalancesForAddition[_tokens[i]].scale(_decayPeriod, realBalances[i], totalSupply.add(fairSupply), totalSupply);
            }
        }

        require(fairSupply > 0, "Mooniswap: result is not enough");
        _mint(target, fairSupply);

        emit Deposited(msg.sender, target, fairSupply, receivedAmounts[0], receivedAmounts[1]);
    }

    function withdraw(uint256 amount, uint256[] memory minReturns) external returns(uint256[2] memory withdrawnAmounts) {
        return withdrawFor(amount, minReturns, msg.sender);
    }

    function withdrawFor(uint256 amount, uint256[] memory minReturns, address payable target) public nonReentrant returns(uint256[2] memory withdrawnAmounts) {
        IERC20[2] memory _tokens = [token0, token1];

        uint256 totalSupply = totalSupply();
        uint256 _decayPeriod = decayPeriod();  // gas savings
        _burn(msg.sender, amount);

        for (uint i = 0; i < _tokens.length; i++) {
            IERC20 token = _tokens[i];

            uint256 preBalance = token.uniBalanceOf(address(this));
            uint256 value = preBalance.mul(amount).div(totalSupply);
            token.uniTransfer(target, value);
            withdrawnAmounts[i] = value;
            require(i >= minReturns.length || value >= minReturns[i], "Mooniswap: result is not enough");

            virtualBalancesForAddition[token].scale(_decayPeriod, preBalance, totalSupply.sub(amount), totalSupply);
            virtualBalancesForRemoval[token].scale(_decayPeriod, preBalance, totalSupply.sub(amount), totalSupply);
        }

        emit Withdrawn(msg.sender, target, amount, withdrawnAmounts[0], withdrawnAmounts[1]);
    }

    function swap(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address referral) external payable returns(uint256 result) {
        return swapFor(src, dst, amount, minReturn, referral, msg.sender);
    }

    function swapFor(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address referral, address payable receiver) public payable nonReentrant whenNotShutdown returns(uint256 result) {
        require(msg.value == (src.isETH() ? amount : 0), "Mooniswap: wrong value usage");

        Balances memory balances = Balances({
            src: src.uniBalanceOf(address(this)).sub(src.isETH() ? msg.value : 0),
            dst: dst.uniBalanceOf(address(this))
        });
        uint256 confirmed;
        Balances memory virtualBalances;
        Fees memory fees = Fees({
            fee: fee(),
            slippageFee: slippageFee()
        });
        (confirmed, result, virtualBalances) = _doTransfers(src, dst, amount, minReturn, receiver, balances, fees);
        emit Swapped(msg.sender, receiver, address(src), address(dst), confirmed, result, virtualBalances.src, virtualBalances.dst, referral);
        _mintRewards(confirmed, result, referral, balances, fees);

        // Overflow of uint128 is desired
        volumes[src].confirmed += uint128(confirmed);
        volumes[src].result += uint128(result);
    }

    function _doTransfers(IERC20 src, IERC20 dst, uint256 amount, uint256 minReturn, address payable receiver, Balances memory balances, Fees memory fees)
        private returns(uint256 confirmed, uint256 result, Balances memory virtualBalances)
    {
        uint256 _decayPeriod = decayPeriod();
        virtualBalances.src = virtualBalancesForAddition[src].current(_decayPeriod, balances.src);
        virtualBalances.src = Math.max(virtualBalances.src, balances.src);
        virtualBalances.dst = virtualBalancesForRemoval[dst].current(_decayPeriod, balances.dst);
        virtualBalances.dst = Math.min(virtualBalances.dst, balances.dst);
        src.uniTransferFrom(msg.sender, address(this), amount);
        confirmed = src.uniBalanceOf(address(this)).sub(balances.src);
        result = _getReturn(src, dst, confirmed, virtualBalances.src, virtualBalances.dst, fees.fee, fees.slippageFee);
        require(result > 0 && result >= minReturn, "Mooniswap: return is not enough");
        dst.uniTransfer(receiver, result);

        // Update virtual balances to the same direction only at imbalanced state
        if (virtualBalances.src != balances.src) {
            virtualBalancesForAddition[src].set(virtualBalances.src.add(confirmed));
        }
        if (virtualBalances.dst != balances.dst) {
            virtualBalancesForRemoval[dst].set(virtualBalances.dst.sub(result));
        }
        // Update virtual balances to the opposite direction
        virtualBalancesForRemoval[src].update(_decayPeriod, balances.src);
        virtualBalancesForAddition[dst].update(_decayPeriod, balances.dst);
    }

    function _mintRewards(uint256 confirmed, uint256 result, address referral, Balances memory balances, Fees memory fees) private {
        (uint256 referralShare, uint256 governanceShare, address govWallet, address feeCollector) = mooniswapFactoryGovernance.shareParameters();

        uint256 refReward;
        uint256 govReward;

        uint256 invariantRatio = uint256(1e36);
        invariantRatio = invariantRatio.mul(balances.src.add(confirmed)).div(balances.src);
        invariantRatio = invariantRatio.mul(balances.dst.sub(result)).div(balances.dst);
        if (invariantRatio > 1e36) {
            // calculate share only if invariant increased
            invariantRatio = invariantRatio.sqrt();
            uint256 invIncrease = totalSupply().mul(invariantRatio.sub(1e18)).div(invariantRatio);

            refReward = (referral != address(0)) ? invIncrease.mul(referralShare).div(MooniswapConstants._FEE_DENOMINATOR) : 0;
            govReward = (govWallet != address(0)) ? invIncrease.mul(governanceShare).div(MooniswapConstants._FEE_DENOMINATOR) : 0;

            if (feeCollector == address(0)) {
                if (refReward > 0) {
                    _mint(referral, refReward);
                }
                if (govReward > 0) {
                    _mint(govWallet, govReward);
                }
            }
            else if (refReward > 0 || govReward > 0) {
                uint256 len = (refReward > 0 ? 1 : 0) + (govReward > 0 ? 1 : 0);
                address[] memory wallets = new address[](len);
                uint256[] memory rewards = new uint256[](len);

                wallets[0] = referral;
                rewards[0] = refReward;
                if (govReward > 0) {
                    wallets[len - 1] = govWallet;
                    rewards[len - 1] = govReward;
                }

                try IFeeCollector(feeCollector).updateRewards(wallets, rewards) {
                    _mint(feeCollector, refReward.add(govReward));
                }
                catch {
                    emit Error("updateRewards() failed");
                }
            }
        }

        emit Sync(balances.src, balances.dst, fees.fee, fees.slippageFee, refReward, govReward);
    }

    /*
        spot_ret = dx * y / x
        uni_ret = dx * y / (x + dx)
        slippage = (spot_ret - uni_ret) / spot_ret
        slippage = dx * dx * y / (x * (x + dx)) / (dx * y / x)
        slippage = dx / (x + dx)
        ret = uni_ret * (1 - slip_fee * slippage)
        ret = dx * y / (x + dx) * (1 - slip_fee * dx / (x + dx))
        ret = dx * y / (x + dx) * (x + dx - slip_fee * dx) / (x + dx)

        x = amount * denominator
        dx = amount * (denominator - fee)
    */
    function _getReturn(IERC20 src, IERC20 dst, uint256 amount, uint256 srcBalance, uint256 dstBalance, uint256 fee, uint256 slippageFee) internal view returns(uint256) {
        if (src > dst) {
            (src, dst) = (dst, src);
        }
        if (amount > 0 && src == token0 && dst == token1) {
            uint256 taxedAmount = amount.sub(amount.mul(fee).div(MooniswapConstants._FEE_DENOMINATOR));
            uint256 srcBalancePlusTaxedAmount = srcBalance.add(taxedAmount);
            uint256 ret = taxedAmount.mul(dstBalance).div(srcBalancePlusTaxedAmount);
            uint256 feeNumerator = MooniswapConstants._FEE_DENOMINATOR.mul(srcBalancePlusTaxedAmount).sub(slippageFee.mul(taxedAmount));
            uint256 feeDenominator = MooniswapConstants._FEE_DENOMINATOR.mul(srcBalancePlusTaxedAmount);
            return ret.mul(feeNumerator).div(feeDenominator);
        }
    }

    function rescueFunds(IERC20 token, uint256 amount) external nonReentrant onlyOwner {
        uint256 balance0 = token0.uniBalanceOf(address(this));
        uint256 balance1 = token1.uniBalanceOf(address(this));

        token.uniTransfer(msg.sender, amount);

        require(token0.uniBalanceOf(address(this)) >= balance0, "Mooniswap: access denied");
        require(token1.uniBalanceOf(address(this)) >= balance1, "Mooniswap: access denied");
        require(balanceOf(address(this)) >= _BASE_SUPPLY, "Mooniswap: access denied");
    }
}

File 3 of 30 : BaseGovernanceModule.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../interfaces/IGovernanceModule.sol";


abstract contract BaseGovernanceModule is IGovernanceModule {
    address public immutable mothership;

    modifier onlyMothership {
        require(msg.sender == mothership, "Access restricted to mothership");

        _;
    }

    constructor(address _mothership) public {
        mothership = _mothership;
    }

    function notifyStakesChanged(address[] calldata accounts, uint256[] calldata newBalances) external override onlyMothership {
        require(accounts.length == newBalances.length, "Arrays length should be equal");

        for(uint256 i = 0; i < accounts.length; ++i) {
            _notifyStakeChanged(accounts[i], newBalances[i]);
        }
    }

    function notifyStakeChanged(address account, uint256 newBalance) external override onlyMothership {
        _notifyStakeChanged(account, newBalance);
    }

    function _notifyStakeChanged(address account, uint256 newBalance) internal virtual;
}

File 4 of 30 : MooniswapFactoryGovernance.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "../interfaces/IMooniswapFactoryGovernance.sol";
import "../libraries/ExplicitLiquidVoting.sol";
import "../libraries/MooniswapConstants.sol";
import "../libraries/SafeCast.sol";
import "../utils/BalanceAccounting.sol";
import "./BaseGovernanceModule.sol";


contract MooniswapFactoryGovernance is IMooniswapFactoryGovernance, BaseGovernanceModule, BalanceAccounting, Ownable, Pausable {
    using Vote for Vote.Data;
    using ExplicitLiquidVoting for ExplicitLiquidVoting.Data;
    using VirtualVote for VirtualVote.Data;
    using SafeMath for uint256;
    using SafeCast for uint256;

    event DefaultFeeVoteUpdate(address indexed user, uint256 fee, bool isDefault, uint256 amount);
    event DefaultSlippageFeeVoteUpdate(address indexed user, uint256 slippageFee, bool isDefault, uint256 amount);
    event DefaultDecayPeriodVoteUpdate(address indexed user, uint256 decayPeriod, bool isDefault, uint256 amount);
    event ReferralShareVoteUpdate(address indexed user, uint256 referralShare, bool isDefault, uint256 amount);
    event GovernanceShareVoteUpdate(address indexed user, uint256 governanceShare, bool isDefault, uint256 amount);
    event GovernanceWalletUpdate(address governanceWallet);
    event FeeCollectorUpdate(address feeCollector);

    ExplicitLiquidVoting.Data private _defaultFee;
    ExplicitLiquidVoting.Data private _defaultSlippageFee;
    ExplicitLiquidVoting.Data private _defaultDecayPeriod;
    ExplicitLiquidVoting.Data private _referralShare;
    ExplicitLiquidVoting.Data private _governanceShare;
    address public override governanceWallet;
    address public override feeCollector;

    mapping(address => bool) public override isFeeCollector;

    constructor(address _mothership) public BaseGovernanceModule(_mothership) {
        _defaultFee.data.result = MooniswapConstants._DEFAULT_FEE.toUint104();
        _defaultSlippageFee.data.result = MooniswapConstants._DEFAULT_SLIPPAGE_FEE.toUint104();
        _defaultDecayPeriod.data.result = MooniswapConstants._DEFAULT_DECAY_PERIOD.toUint104();
        _referralShare.data.result = MooniswapConstants._DEFAULT_REFERRAL_SHARE.toUint104();
        _governanceShare.data.result = MooniswapConstants._DEFAULT_GOVERNANCE_SHARE.toUint104();
    }

    function shutdown() external onlyOwner {
        _pause();
    }

    function isActive() external view override returns (bool) {
        return !paused();
    }

    function shareParameters() external view override returns(uint256, uint256, address, address) {
        return (_referralShare.data.current(), _governanceShare.data.current(), governanceWallet, feeCollector);
    }

    function defaults() external view override returns(uint256, uint256, uint256) {
        return (_defaultFee.data.current(), _defaultSlippageFee.data.current(), _defaultDecayPeriod.data.current());
    }

    function defaultFee() external view override returns(uint256) {
        return _defaultFee.data.current();
    }

    function defaultFeeVotes(address user) external view returns(uint256) {
        return _defaultFee.votes[user].get(MooniswapConstants._DEFAULT_FEE);
    }

    function virtualDefaultFee() external view returns(uint104, uint104, uint48) {
        return (_defaultFee.data.oldResult, _defaultFee.data.result, _defaultFee.data.time);
    }

    function defaultSlippageFee() external view override returns(uint256) {
        return _defaultSlippageFee.data.current();
    }

    function defaultSlippageFeeVotes(address user) external view returns(uint256) {
        return _defaultSlippageFee.votes[user].get(MooniswapConstants._DEFAULT_SLIPPAGE_FEE);
    }

    function virtualDefaultSlippageFee() external view returns(uint104, uint104, uint48) {
        return (_defaultSlippageFee.data.oldResult, _defaultSlippageFee.data.result, _defaultSlippageFee.data.time);
    }

    function defaultDecayPeriod() external view override returns(uint256) {
        return _defaultDecayPeriod.data.current();
    }

    function defaultDecayPeriodVotes(address user) external view returns(uint256) {
        return _defaultDecayPeriod.votes[user].get(MooniswapConstants._DEFAULT_DECAY_PERIOD);
    }

    function virtualDefaultDecayPeriod() external view returns(uint104, uint104, uint48) {
        return (_defaultDecayPeriod.data.oldResult, _defaultDecayPeriod.data.result, _defaultDecayPeriod.data.time);
    }

    function referralShare() external view override returns(uint256) {
        return _referralShare.data.current();
    }

    function referralShareVotes(address user) external view returns(uint256) {
        return _referralShare.votes[user].get(MooniswapConstants._DEFAULT_REFERRAL_SHARE);
    }

    function virtualReferralShare() external view returns(uint104, uint104, uint48) {
        return (_referralShare.data.oldResult, _referralShare.data.result, _referralShare.data.time);
    }

    function governanceShare() external view override returns(uint256) {
        return _governanceShare.data.current();
    }

    function governanceShareVotes(address user) external view returns(uint256) {
        return _governanceShare.votes[user].get(MooniswapConstants._DEFAULT_GOVERNANCE_SHARE);
    }

    function virtualGovernanceShare() external view returns(uint104, uint104, uint48) {
        return (_governanceShare.data.oldResult, _governanceShare.data.result, _governanceShare.data.time);
    }

    function setGovernanceWallet(address newGovernanceWallet) external onlyOwner {
        governanceWallet = newGovernanceWallet;
        isFeeCollector[newGovernanceWallet] = true;
        emit GovernanceWalletUpdate(newGovernanceWallet);
    }

    function setFeeCollector(address newFeeCollector) external onlyOwner {
        feeCollector = newFeeCollector;
        isFeeCollector[newFeeCollector] = true;
        emit FeeCollectorUpdate(newFeeCollector);
    }

    function defaultFeeVote(uint256 vote) external {
        require(vote <= MooniswapConstants._MAX_FEE, "Fee vote is too high");
        _defaultFee.updateVote(msg.sender, _defaultFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_FEE, _emitDefaultFeeVoteUpdate);
    }

    function discardDefaultFeeVote() external {
       _defaultFee.updateVote(msg.sender, _defaultFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_FEE, _emitDefaultFeeVoteUpdate);
    }

    function defaultSlippageFeeVote(uint256 vote) external {
        require(vote <= MooniswapConstants._MAX_SLIPPAGE_FEE, "Slippage fee vote is too high");
        _defaultSlippageFee.updateVote(msg.sender, _defaultSlippageFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_SLIPPAGE_FEE, _emitDefaultSlippageFeeVoteUpdate);
    }

   function discardDefaultSlippageFeeVote() external {
        _defaultSlippageFee.updateVote(msg.sender, _defaultSlippageFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_SLIPPAGE_FEE, _emitDefaultSlippageFeeVoteUpdate);
    }

    function defaultDecayPeriodVote(uint256 vote) external {
        require(vote <= MooniswapConstants._MAX_DECAY_PERIOD, "Decay period vote is too high");
        require(vote >= MooniswapConstants._MIN_DECAY_PERIOD, "Decay period vote is too low");
        _defaultDecayPeriod.updateVote(msg.sender, _defaultDecayPeriod.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_DECAY_PERIOD, _emitDefaultDecayPeriodVoteUpdate);
    }

    function discardDefaultDecayPeriodVote() external {
        _defaultDecayPeriod.updateVote(msg.sender, _defaultDecayPeriod.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_DECAY_PERIOD, _emitDefaultDecayPeriodVoteUpdate);
    }

    function referralShareVote(uint256 vote) external {
        require(vote <= MooniswapConstants._MAX_SHARE, "Referral share vote is too high");
        require(vote >= MooniswapConstants._MIN_REFERRAL_SHARE, "Referral share vote is too low");
        _referralShare.updateVote(msg.sender, _referralShare.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_REFERRAL_SHARE, _emitReferralShareVoteUpdate);
    }

    function discardReferralShareVote() external {
        _referralShare.updateVote(msg.sender, _referralShare.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_REFERRAL_SHARE, _emitReferralShareVoteUpdate);
    }

    function governanceShareVote(uint256 vote) external {
        require(vote <= MooniswapConstants._MAX_SHARE, "Gov share vote is too high");
        _governanceShare.updateVote(msg.sender, _governanceShare.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), MooniswapConstants._DEFAULT_GOVERNANCE_SHARE, _emitGovernanceShareVoteUpdate);
    }

    function discardGovernanceShareVote() external {
        _governanceShare.updateVote(msg.sender, _governanceShare.votes[msg.sender], Vote.init(), balanceOf(msg.sender), MooniswapConstants._DEFAULT_GOVERNANCE_SHARE, _emitGovernanceShareVoteUpdate);
    }

    function _notifyStakeChanged(address account, uint256 newBalance) internal override {
        uint256 balance = _set(account, newBalance);
        if (newBalance == balance) {
            return;
        }

        _defaultFee.updateBalance(account, _defaultFee.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_FEE, _emitDefaultFeeVoteUpdate);
        _defaultSlippageFee.updateBalance(account, _defaultSlippageFee.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_SLIPPAGE_FEE, _emitDefaultSlippageFeeVoteUpdate);
        _defaultDecayPeriod.updateBalance(account, _defaultDecayPeriod.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_DECAY_PERIOD, _emitDefaultDecayPeriodVoteUpdate);
        _referralShare.updateBalance(account, _referralShare.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_REFERRAL_SHARE, _emitReferralShareVoteUpdate);
        _governanceShare.updateBalance(account, _governanceShare.votes[account], balance, newBalance, MooniswapConstants._DEFAULT_GOVERNANCE_SHARE, _emitGovernanceShareVoteUpdate);
    }

    function _emitDefaultFeeVoteUpdate(address user, uint256 newDefaultFee, bool isDefault, uint256 balance) private {
        emit DefaultFeeVoteUpdate(user, newDefaultFee, isDefault, balance);
    }

    function _emitDefaultSlippageFeeVoteUpdate(address user, uint256 newDefaultSlippageFee, bool isDefault, uint256 balance) private {
        emit DefaultSlippageFeeVoteUpdate(user, newDefaultSlippageFee, isDefault, balance);
    }

    function _emitDefaultDecayPeriodVoteUpdate(address user, uint256 newDefaultDecayPeriod, bool isDefault, uint256 balance) private {
        emit DefaultDecayPeriodVoteUpdate(user, newDefaultDecayPeriod, isDefault, balance);
    }

    function _emitReferralShareVoteUpdate(address user, uint256 newReferralShare, bool isDefault, uint256 balance) private {
        emit ReferralShareVoteUpdate(user, newReferralShare, isDefault, balance);
    }

    function _emitGovernanceShareVoteUpdate(address user, uint256 newGovernanceShare, bool isDefault, uint256 balance) private {
        emit GovernanceShareVoteUpdate(user, newGovernanceShare, isDefault, balance);
    }
}

File 5 of 30 : MooniswapGovernance.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "../interfaces/IMooniswapFactoryGovernance.sol";
import "../libraries/LiquidVoting.sol";
import "../libraries/MooniswapConstants.sol";
import "../libraries/SafeCast.sol";


abstract contract MooniswapGovernance is ERC20, Ownable, ReentrancyGuard {
    using Vote for Vote.Data;
    using LiquidVoting for LiquidVoting.Data;
    using VirtualVote for VirtualVote.Data;
    using SafeCast for uint256;

    event FeeVoteUpdate(address indexed user, uint256 fee, bool isDefault, uint256 amount);
    event SlippageFeeVoteUpdate(address indexed user, uint256 slippageFee, bool isDefault, uint256 amount);
    event DecayPeriodVoteUpdate(address indexed user, uint256 decayPeriod, bool isDefault, uint256 amount);

    IMooniswapFactoryGovernance public mooniswapFactoryGovernance;
    LiquidVoting.Data private _fee;
    LiquidVoting.Data private _slippageFee;
    LiquidVoting.Data private _decayPeriod;

    constructor(IMooniswapFactoryGovernance _mooniswapFactoryGovernance) internal {
        mooniswapFactoryGovernance = _mooniswapFactoryGovernance;
        _fee.data.result = _mooniswapFactoryGovernance.defaultFee().toUint104();
        _slippageFee.data.result = _mooniswapFactoryGovernance.defaultSlippageFee().toUint104();
        _decayPeriod.data.result = _mooniswapFactoryGovernance.defaultDecayPeriod().toUint104();
    }

    function setMooniswapFactoryGovernance(IMooniswapFactoryGovernance newMooniswapFactoryGovernance) external onlyOwner {
        mooniswapFactoryGovernance = newMooniswapFactoryGovernance;
        this.discardFeeVote();
        this.discardSlippageFeeVote();
        this.discardDecayPeriodVote();
    }

    function fee() public view returns(uint256) {
        return _fee.data.current();
    }

    function slippageFee() public view returns(uint256) {
        return _slippageFee.data.current();
    }

    function decayPeriod() public view returns(uint256) {
        return _decayPeriod.data.current();
    }

    function virtualFee() external view returns(uint104, uint104, uint48) {
        return (_fee.data.oldResult, _fee.data.result, _fee.data.time);
    }

    function virtualSlippageFee() external view returns(uint104, uint104, uint48) {
        return (_slippageFee.data.oldResult, _slippageFee.data.result, _slippageFee.data.time);
    }

    function virtualDecayPeriod() external view returns(uint104, uint104, uint48) {
        return (_decayPeriod.data.oldResult, _decayPeriod.data.result, _decayPeriod.data.time);
    }

    function feeVotes(address user) external view returns(uint256) {
        return _fee.votes[user].get(mooniswapFactoryGovernance.defaultFee);
    }

    function slippageFeeVotes(address user) external view returns(uint256) {
        return _slippageFee.votes[user].get(mooniswapFactoryGovernance.defaultSlippageFee);
    }

    function decayPeriodVotes(address user) external view returns(uint256) {
        return _decayPeriod.votes[user].get(mooniswapFactoryGovernance.defaultDecayPeriod);
    }

    function feeVote(uint256 vote) external {
        require(vote <= MooniswapConstants._MAX_FEE, "Fee vote is too high");

        _fee.updateVote(msg.sender, _fee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultFee(), _emitFeeVoteUpdate);
    }

    function slippageFeeVote(uint256 vote) external {
        require(vote <= MooniswapConstants._MAX_SLIPPAGE_FEE, "Slippage fee vote is too high");

        _slippageFee.updateVote(msg.sender, _slippageFee.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultSlippageFee(), _emitSlippageFeeVoteUpdate);
    }

    function decayPeriodVote(uint256 vote) external {
        require(vote <= MooniswapConstants._MAX_DECAY_PERIOD, "Decay period vote is too high");
        require(vote >= MooniswapConstants._MIN_DECAY_PERIOD, "Decay period vote is too low");

        _decayPeriod.updateVote(msg.sender, _decayPeriod.votes[msg.sender], Vote.init(vote), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultDecayPeriod(), _emitDecayPeriodVoteUpdate);
    }

    function discardFeeVote() external {
        _fee.updateVote(msg.sender, _fee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultFee(), _emitFeeVoteUpdate);
    }

    function discardSlippageFeeVote() external {
        _slippageFee.updateVote(msg.sender, _slippageFee.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultSlippageFee(), _emitSlippageFeeVoteUpdate);
    }

    function discardDecayPeriodVote() external {
        _decayPeriod.updateVote(msg.sender, _decayPeriod.votes[msg.sender], Vote.init(), balanceOf(msg.sender), totalSupply(), mooniswapFactoryGovernance.defaultDecayPeriod(), _emitDecayPeriodVoteUpdate);
    }

    function _emitFeeVoteUpdate(address account, uint256 newFee, bool isDefault, uint256 newBalance) private {
        emit FeeVoteUpdate(account, newFee, isDefault, newBalance);
    }

    function _emitSlippageFeeVoteUpdate(address account, uint256 newSlippageFee, bool isDefault, uint256 newBalance) private {
        emit SlippageFeeVoteUpdate(account, newSlippageFee, isDefault, newBalance);
    }

    function _emitDecayPeriodVoteUpdate(address account, uint256 newDecayPeriod, bool isDefault, uint256 newBalance) private {
        emit DecayPeriodVoteUpdate(account, newDecayPeriod, isDefault, newBalance);
    }

    function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
        if (from == to) {
            // ignore transfers to self
            return;
        }

        IMooniswapFactoryGovernance _mooniswapFactoryGovernance = mooniswapFactoryGovernance;
        bool updateFrom = !(from == address(0) || _mooniswapFactoryGovernance.isFeeCollector(from));
        bool updateTo = !(to == address(0) || _mooniswapFactoryGovernance.isFeeCollector(to));

        if (!updateFrom && !updateTo) {
            // mint to feeReceiver or burn from feeReceiver
            return;
        }

        uint256 balanceFrom = (from != address(0)) ? balanceOf(from) : 0;
        uint256 balanceTo = (to != address(0)) ? balanceOf(to) : 0;
        uint256 newTotalSupply = totalSupply()
            .add(from == address(0) ? amount : 0)
            .sub(to == address(0) ? amount : 0);

        ParamsHelper memory params = ParamsHelper({
            from: from,
            to: to,
            updateFrom: updateFrom,
            updateTo: updateTo,
            amount: amount,
            balanceFrom: balanceFrom,
            balanceTo: balanceTo,
            newTotalSupply: newTotalSupply
        });

        (uint256 defaultFee, uint256 defaultSlippageFee, uint256 defaultDecayPeriod) = _mooniswapFactoryGovernance.defaults();

        _updateOnTransfer(params, defaultFee, _emitFeeVoteUpdate, _fee);
        _updateOnTransfer(params, defaultSlippageFee, _emitSlippageFeeVoteUpdate, _slippageFee);
        _updateOnTransfer(params, defaultDecayPeriod, _emitDecayPeriodVoteUpdate, _decayPeriod);
    }

    struct ParamsHelper {
        address from;
        address to;
        bool updateFrom;
        bool updateTo;
        uint256 amount;
        uint256 balanceFrom;
        uint256 balanceTo;
        uint256 newTotalSupply;
    }

    function _updateOnTransfer(
        ParamsHelper memory params,
        uint256 defaultValue,
        function(address, uint256, bool, uint256) internal emitEvent,
        LiquidVoting.Data storage votingData
    ) private {
        Vote.Data memory voteFrom = votingData.votes[params.from];
        Vote.Data memory voteTo = votingData.votes[params.to];

        if (voteFrom.isDefault() && voteTo.isDefault() && params.updateFrom && params.updateTo) {
            emitEvent(params.from, voteFrom.get(defaultValue), true, params.balanceFrom.sub(params.amount));
            emitEvent(params.to, voteTo.get(defaultValue), true, params.balanceTo.add(params.amount));
            return;
        }

        if (params.updateFrom) {
            votingData.updateBalance(params.from, voteFrom, params.balanceFrom, params.balanceFrom.sub(params.amount), params.newTotalSupply, defaultValue, emitEvent);
        }

        if (params.updateTo) {
            votingData.updateBalance(params.to, voteTo, params.balanceTo, params.balanceTo.add(params.amount), params.newTotalSupply, defaultValue, emitEvent);
        }
    }
}

File 6 of 30 : IFeeCollector.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;


interface IFeeCollector {
    function updateReward(address receiver, uint256 amount) external;
    function updateRewards(address[] calldata receivers, uint256[] calldata amounts) external;
}

File 7 of 30 : IGovernanceModule.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;


interface IGovernanceModule {
    function notifyStakeChanged(address account, uint256 newBalance) external;
    function notifyStakesChanged(address[] calldata accounts, uint256[] calldata newBalances) external;
}

File 8 of 30 : IMooniswapDeployer.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../Mooniswap.sol";

interface IMooniswapDeployer {
    function deploy(
        IERC20 token1,
        IERC20 token2,
        string calldata name,
        string calldata symbol,
        address poolOwner
    ) external returns(Mooniswap pool);
}

File 9 of 30 : IMooniswapFactory.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../Mooniswap.sol";

interface IMooniswapFactory is IMooniswapFactoryGovernance {
    function pools(IERC20 token0, IERC20 token1) external view returns (Mooniswap);
    function isPool(Mooniswap mooniswap) external view returns (bool);
}

File 10 of 30 : IMooniswapFactoryGovernance.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;


interface IMooniswapFactoryGovernance {
    function shareParameters() external view returns(uint256 referralShare, uint256 governanceShare, address governanceWallet, address referralFeeReceiver);
    function defaults() external view returns(uint256 defaultFee, uint256 defaultSlippageFee, uint256 defaultDecayPeriod);

    function defaultFee() external view returns(uint256);
    function defaultSlippageFee() external view returns(uint256);
    function defaultDecayPeriod() external view returns(uint256);
    function referralShare() external view returns(uint256);
    function governanceShare() external view returns(uint256);
    function governanceWallet() external view returns(address);
    function feeCollector() external view returns(address);

    function isFeeCollector(address) external view returns(bool);
    function isActive() external view returns (bool);
}

File 11 of 30 : ExplicitLiquidVoting.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "./SafeCast.sol";
import "./VirtualVote.sol";
import "./Vote.sol";


library ExplicitLiquidVoting {
    using SafeMath for uint256;
    using SafeCast for uint256;
    using Vote for Vote.Data;
    using VirtualVote for VirtualVote.Data;

    struct Data {
        VirtualVote.Data data;
        uint256 _weightedSum;
        uint256 _votedSupply;
        mapping(address => Vote.Data) votes;
    }

    function updateVote(
        ExplicitLiquidVoting.Data storage self,
        address user,
        Vote.Data memory oldVote,
        Vote.Data memory newVote,
        uint256 balance,
        uint256 defaultVote,
        function(address, uint256, bool, uint256) emitEvent
    ) internal {
        return _update(self, user, oldVote, newVote, balance, balance, defaultVote, emitEvent);
    }

    function updateBalance(
        ExplicitLiquidVoting.Data storage self,
        address user,
        Vote.Data memory oldVote,
        uint256 oldBalance,
        uint256 newBalance,
        uint256 defaultVote,
        function(address, uint256, bool, uint256) emitEvent
    ) internal {
        return _update(self, user, oldVote, newBalance == 0 ? Vote.init() : oldVote, oldBalance, newBalance, defaultVote, emitEvent);
    }

    function _update(
        ExplicitLiquidVoting.Data storage self,
        address user,
        Vote.Data memory oldVote,
        Vote.Data memory newVote,
        uint256 oldBalance,
        uint256 newBalance,
        uint256 defaultVote,
        function(address, uint256, bool, uint256) emitEvent
    ) private {
        uint256 oldWeightedSum = self._weightedSum;
        uint256 newWeightedSum = oldWeightedSum;
        uint256 oldVotedSupply = self._votedSupply;
        uint256 newVotedSupply = oldVotedSupply;

        if (!oldVote.isDefault()) {
            newWeightedSum = newWeightedSum.sub(oldBalance.mul(oldVote.get(defaultVote)));
            newVotedSupply = newVotedSupply.sub(oldBalance);
        }

        if (!newVote.isDefault()) {
            newWeightedSum = newWeightedSum.add(newBalance.mul(newVote.get(defaultVote)));
            newVotedSupply = newVotedSupply.add(newBalance);
        }

        if (newWeightedSum != oldWeightedSum) {
            self._weightedSum = newWeightedSum;
        }

        if (newVotedSupply != oldVotedSupply) {
            self._votedSupply = newVotedSupply;
        }

        {
            uint256 newResult = newVotedSupply == 0 ? defaultVote : newWeightedSum.div(newVotedSupply);
            VirtualVote.Data memory data = self.data;

            if (newResult != data.result) {
                VirtualVote.Data storage sdata = self.data;
                (sdata.oldResult, sdata.result, sdata.time) = (
                    data.current().toUint104(),
                    newResult.toUint104(),
                    block.timestamp.toUint48()
                );
            }
        }

        if (!newVote.eq(oldVote)) {
            self.votes[user] = newVote;
        }

        emitEvent(user, newVote.get(defaultVote), newVote.isDefault(), newBalance);
    }
}

File 12 of 30 : LiquidVoting.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "./SafeCast.sol";
import "./VirtualVote.sol";
import "./Vote.sol";


library LiquidVoting {
    using SafeMath for uint256;
    using SafeCast for uint256;
    using Vote for Vote.Data;
    using VirtualVote for VirtualVote.Data;

    struct Data {
        VirtualVote.Data data;
        uint256 _weightedSum;
        uint256 _defaultVotes;
        mapping(address => Vote.Data) votes;
    }

    function updateVote(
        LiquidVoting.Data storage self,
        address user,
        Vote.Data memory oldVote,
        Vote.Data memory newVote,
        uint256 balance,
        uint256 totalSupply,
        uint256 defaultVote,
        function(address, uint256, bool, uint256) emitEvent
    ) internal {
        return _update(self, user, oldVote, newVote, balance, balance, totalSupply, defaultVote, emitEvent);
    }

    function updateBalance(
        LiquidVoting.Data storage self,
        address user,
        Vote.Data memory oldVote,
        uint256 oldBalance,
        uint256 newBalance,
        uint256 newTotalSupply,
        uint256 defaultVote,
        function(address, uint256, bool, uint256) emitEvent
    ) internal {
        return _update(self, user, oldVote, newBalance == 0 ? Vote.init() : oldVote, oldBalance, newBalance, newTotalSupply, defaultVote, emitEvent);
    }

    function _update(
        LiquidVoting.Data storage self,
        address user,
        Vote.Data memory oldVote,
        Vote.Data memory newVote,
        uint256 oldBalance,
        uint256 newBalance,
        uint256 newTotalSupply,
        uint256 defaultVote,
        function(address, uint256, bool, uint256) emitEvent
    ) private {
        uint256 oldWeightedSum = self._weightedSum;
        uint256 newWeightedSum = oldWeightedSum;
        uint256 oldDefaultVotes = self._defaultVotes;
        uint256 newDefaultVotes = oldDefaultVotes;

        if (oldVote.isDefault()) {
            newDefaultVotes = newDefaultVotes.sub(oldBalance);
        } else {
            newWeightedSum = newWeightedSum.sub(oldBalance.mul(oldVote.get(defaultVote)));
        }

        if (newVote.isDefault()) {
            newDefaultVotes = newDefaultVotes.add(newBalance);
        } else {
            newWeightedSum = newWeightedSum.add(newBalance.mul(newVote.get(defaultVote)));
        }

        if (newWeightedSum != oldWeightedSum) {
            self._weightedSum = newWeightedSum;
        }

        if (newDefaultVotes != oldDefaultVotes) {
            self._defaultVotes = newDefaultVotes;
        }

        {
            uint256 newResult = newTotalSupply == 0 ? defaultVote : newWeightedSum.add(newDefaultVotes.mul(defaultVote)).div(newTotalSupply);
            VirtualVote.Data memory data = self.data;

            if (newResult != data.result) {
                VirtualVote.Data storage sdata = self.data;
                (sdata.oldResult, sdata.result, sdata.time) = (
                    data.current().toUint104(),
                    newResult.toUint104(),
                    block.timestamp.toUint48()
                );
            }
        }

        if (!newVote.eq(oldVote)) {
            self.votes[user] = newVote;
        }

        emitEvent(user, newVote.get(defaultVote), newVote.isDefault(), newBalance);
    }
}

File 13 of 30 : MooniswapConstants.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;


library MooniswapConstants {
    uint256 internal constant _FEE_DENOMINATOR = 1e18;

    uint256 internal constant _MIN_REFERRAL_SHARE = 0.05e18; // 5%
    uint256 internal constant _MIN_DECAY_PERIOD = 1 minutes;

    uint256 internal constant _MAX_FEE = 0.01e18; // 1%
    uint256 internal constant _MAX_SLIPPAGE_FEE = 1e18;  // 100%
    uint256 internal constant _MAX_SHARE = 0.1e18; // 10%
    uint256 internal constant _MAX_DECAY_PERIOD = 5 minutes;

    uint256 internal constant _DEFAULT_FEE = 0;
    uint256 internal constant _DEFAULT_SLIPPAGE_FEE = 1e18;  // 100%
    uint256 internal constant _DEFAULT_REFERRAL_SHARE = 0.1e18; // 10%
    uint256 internal constant _DEFAULT_GOVERNANCE_SHARE = 0;
    uint256 internal constant _DEFAULT_DECAY_PERIOD = 1 minutes;
}

File 14 of 30 : SafeCast.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

library SafeCast {
    function toUint216(uint256 value) internal pure returns (uint216) {
        require(value < 2**216, "value does not fit in 216 bits");
        return uint216(value);
    }

    function toUint104(uint256 value) internal pure returns (uint104) {
        require(value < 2**104, "value does not fit in 104 bits");
        return uint104(value);
    }

    function toUint48(uint256 value) internal pure returns (uint48) {
        require(value < 2**48, "value does not fit in 48 bits");
        return uint48(value);
    }

    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value < 2**40, "value does not fit in 40 bits");
        return uint40(value);
    }
}

File 15 of 30 : Sqrt.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;


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

File 16 of 30 : UniERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";


library UniERC20 {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    function isETH(IERC20 token) internal pure returns(bool) {
        return (address(token) == address(0));
    }

    function uniBalanceOf(IERC20 token, address account) internal view returns (uint256) {
        if (isETH(token)) {
            return account.balance;
        } else {
            return token.balanceOf(account);
        }
    }

    function uniTransfer(IERC20 token, address payable to, uint256 amount) internal {
        if (amount > 0) {
            if (isETH(token)) {
                to.transfer(amount);
            } else {
                token.safeTransfer(to, amount);
            }
        }
    }

    function uniTransferFrom(IERC20 token, address payable from, address to, uint256 amount) internal {
        if (amount > 0) {
            if (isETH(token)) {
                require(msg.value >= amount, "UniERC20: not enough value");
                require(from == msg.sender, "from is not msg.sender");
                require(to == address(this), "to is not this");
                if (msg.value > amount) {
                    // Return remainder if exist
                    from.transfer(msg.value.sub(amount));
                }
            } else {
                token.safeTransferFrom(from, to, amount);
            }
        }
    }

    function uniSymbol(IERC20 token) internal view returns(string memory) {
        if (isETH(token)) {
            return "ETH";
        }

        (bool success, bytes memory data) = address(token).staticcall{ gas: 20000 }(
            abi.encodeWithSignature("symbol()")
        );
        if (!success) {
            (success, data) = address(token).staticcall{ gas: 20000 }(
                abi.encodeWithSignature("SYMBOL()")
            );
        }

        if (success && data.length >= 96) {
            (uint256 offset, uint256 len) = abi.decode(data, (uint256, uint256));
            if (offset == 0x20 && len > 0 && len <= 256) {
                return string(abi.decode(data, (bytes)));
            }
        }

        if (success && data.length == 32) {
            uint len = 0;
            while (len < data.length && data[len] >= 0x20 && data[len] <= 0x7E) {
                len++;
            }

            if (len > 0) {
                bytes memory result = new bytes(len);
                for (uint i = 0; i < len; i++) {
                    result[i] = data[i];
                }
                return string(result);
            }
        }

        return _toHex(address(token));
    }

    function _toHex(address account) private pure returns(string memory) {
        return _toHex(abi.encodePacked(account));
    }

    function _toHex(bytes memory data) private pure returns(string memory) {
        bytes memory str = new bytes(2 + data.length * 2);
        str[0] = "0";
        str[1] = "x";
        uint j = 2;
        for (uint i = 0; i < data.length; i++) {
            uint a = uint8(data[i]) >> 4;
            uint b = uint8(data[i]) & 0x0f;
            str[j++] = byte(uint8(a + 48 + (a/10)*39));
            str[j++] = byte(uint8(b + 48 + (b/10)*39));
        }

        return string(str);
    }
}

File 17 of 30 : VirtualBalance.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;


import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/math/Math.sol";
import "./SafeCast.sol";


library VirtualBalance {
    using SafeMath for uint256;
    using SafeCast for uint256;

    struct Data {
        uint216 balance;
        uint40 time;
    }

    function set(VirtualBalance.Data storage self, uint256 balance) internal {
        (self.balance, self.time) = (
            balance.toUint216(),
            block.timestamp.toUint40()
        );
    }

    function update(VirtualBalance.Data storage self, uint256 decayPeriod, uint256 realBalance) internal {
        set(self, current(self, decayPeriod, realBalance));
    }

    function scale(VirtualBalance.Data storage self, uint256 decayPeriod, uint256 realBalance, uint256 num, uint256 denom) internal {
        set(self, current(self, decayPeriod, realBalance).mul(num).add(denom.sub(1)).div(denom));
    }

    function current(VirtualBalance.Data memory self, uint256 decayPeriod, uint256 realBalance) internal view returns(uint256) {
        uint256 timePassed = Math.min(decayPeriod, block.timestamp.sub(self.time));
        uint256 timeRemain = decayPeriod.sub(timePassed);
        return uint256(self.balance).mul(timeRemain).add(
            realBalance.mul(timePassed)
        ).div(decayPeriod);
    }
}

File 18 of 30 : VirtualVote.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";


library VirtualVote {
    using SafeMath for uint256;

    uint256 private constant _VOTE_DECAY_PERIOD = 1 days;

    struct Data {
        uint104 oldResult;
        uint104 result;
        uint48 time;
    }

    function current(VirtualVote.Data memory self) internal view returns(uint256) {
        uint256 timePassed = Math.min(_VOTE_DECAY_PERIOD, block.timestamp.sub(self.time));
        uint256 timeRemain = _VOTE_DECAY_PERIOD.sub(timePassed);
        return uint256(self.oldResult).mul(timeRemain).add(
            uint256(self.result).mul(timePassed)
        ).div(_VOTE_DECAY_PERIOD);
    }
}

File 19 of 30 : Vote.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;


library Vote {
    struct Data {
        uint256 value;
    }

    function eq(Vote.Data memory self, Vote.Data memory vote) internal pure returns(bool) {
        return self.value == vote.value;
    }

    function init() internal pure returns(Vote.Data memory data) {
        return Vote.Data({
            value: 0
        });
    }

    function init(uint256 vote) internal pure returns(Vote.Data memory data) {
        return Vote.Data({
            value: vote + 1
        });
    }

    function isDefault(Data memory self) internal pure returns(bool) {
        return self.value == 0;
    }

    function get(Data memory self, uint256 defaultVote) internal pure returns(uint256) {
        if (self.value > 0) {
            return self.value - 1;
        }
        return defaultVote;
    }

    function get(Data memory self, function() external view returns(uint256) defaultVoteFn) internal view returns(uint256) {
        if (self.value > 0) {
            return self.value - 1;
        }
        return defaultVoteFn();
    }
}

File 20 of 30 : BalanceAccounting.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/math/SafeMath.sol";


contract BalanceAccounting {
    using SafeMath for uint256;

    uint256 private _totalSupply;
    mapping(address => uint256) private _balances;

    function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) public view returns (uint256) {
        return _balances[account];
    }

    function _mint(address account, uint256 amount) internal virtual {
        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
    }

    function _burn(address account, uint256 amount) internal virtual {
        _balances[account] = _balances[account].sub(amount, "Burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
    }

    function _set(address account, uint256 amount) internal virtual returns(uint256 oldAmount) {
        oldAmount = _balances[account];
        if (oldAmount != amount) {
            _balances[account] = amount;
            _totalSupply = _totalSupply.add(amount).sub(oldAmount);
        }
    }
}

File 21 of 30 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address 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 22 of 30 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../GSN/Context.sol";
/**
 * @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.
 */
contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        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;
    }
}

File 23 of 30 : Math.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

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

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

File 24 of 30 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    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;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 25 of 30 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../../GSN/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.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}.
 */
contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;
    using Address for address;

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @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 (string memory name, string memory symbol) public {
        _name = name;
        _symbol = symbol;
        _decimals = 18;
    }

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

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

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

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

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

    /**
     * @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(_msgSender(), recipient, amount);
        return true;
    }

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), 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);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].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(_msgSender(), spender, _allowances[_msgSender()][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(_msgSender(), spender, _allowances[_msgSender()][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);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[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);
        _balances[account] = _balances[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);

        _balances[account] = _balances[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 is internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

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

    /**
     * @dev 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 26 of 30 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 27 of 30 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/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 {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @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 28 of 30 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

/**
 * @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) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @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");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        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 29 of 30 : Pausable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../GSN/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor () internal {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!_paused, "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(_paused, "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 30 of 30 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "evmVersion": "istanbul",
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_poolOwner","type":"address"},{"internalType":"contract IMooniswapDeployer","name":"_mooniswapDeployer","type":"address"},{"internalType":"address","name":"_governanceMothership","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"decayPeriod","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isDefault","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DefaultDecayPeriodVoteUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isDefault","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DefaultFeeVoteUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"slippageFee","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isDefault","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DefaultSlippageFeeVoteUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Mooniswap","name":"mooniswap","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"token1","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"token2","type":"address"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feeCollector","type":"address"}],"name":"FeeCollectorUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"governanceShare","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isDefault","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"GovernanceShareVoteUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"governanceWallet","type":"address"}],"name":"GovernanceWalletUpdate","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"referralShare","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isDefault","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ReferralShareVoteUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPools","outputs":[{"internalType":"contract Mooniswap","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultDecayPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vote","type":"uint256"}],"name":"defaultDecayPeriodVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"defaultDecayPeriodVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vote","type":"uint256"}],"name":"defaultFeeVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"defaultFeeVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultSlippageFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vote","type":"uint256"}],"name":"defaultSlippageFeeVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"defaultSlippageFeeVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaults","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"tokenA","type":"address"},{"internalType":"contract IERC20","name":"tokenB","type":"address"}],"name":"deploy","outputs":[{"internalType":"contract Mooniswap","name":"pool","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"discardDefaultDecayPeriodVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"discardDefaultFeeVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"discardDefaultSlippageFeeVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"discardGovernanceShareVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"discardReferralShareVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllPools","outputs":[{"internalType":"contract Mooniswap[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governanceShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vote","type":"uint256"}],"name":"governanceShareVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"governanceShareVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governanceWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isFeeCollector","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract Mooniswap","name":"","type":"address"}],"name":"isPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mooniswapDeployer","outputs":[{"internalType":"contract IMooniswapDeployer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mothership","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"notifyStakeChanged","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"newBalances","type":"uint256[]"}],"name":"notifyStakesChanged","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"tokenA","type":"address"},{"internalType":"contract IERC20","name":"tokenB","type":"address"}],"name":"pools","outputs":[{"internalType":"contract Mooniswap","name":"pool","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vote","type":"uint256"}],"name":"referralShareVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"referralShareVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newFeeCollector","type":"address"}],"name":"setFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newGovernanceWallet","type":"address"}],"name":"setGovernanceWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shareParameters","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"shutdown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"tokenA","type":"address"},{"internalType":"contract IERC20","name":"tokenB","type":"address"}],"name":"sortTokens","outputs":[{"internalType":"contract IERC20","name":"","type":"address"},{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"virtualDefaultDecayPeriod","outputs":[{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"virtualDefaultFee","outputs":[{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"virtualDefaultSlippageFee","outputs":[{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"virtualGovernanceShare","outputs":[{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"virtualReferralShare","outputs":[{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint104","name":"","type":"uint104"},{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"}]

60e06040523480156200001157600080fd5b50604051620034ee380380620034ee833981810160405260608110156200003757600080fd5b50805160208201516040909201516001600160601b0319606082901b166080529091908060006200006762000240565b600280546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506002805460ff60a01b19169055620000da600062000244602090811b6200201217901c565b6003600001600001600d6101000a8154816001600160681b0302191690836001600160681b0316021790555062000124670de0b6b3a76400006200024460201b620020121760201c565b6007600001600001600d6101000a8154816001600160681b0302191690836001600160681b0316021790555062000167603c6200024460201b620020121760201c565b600b600001600001600d6101000a8154816001600160681b0302191690836001600160681b03160217905550620001b167016345785d8a00006200024460201b620020121760201c565b600f600001600001600d6101000a8154816001600160681b0302191690836001600160681b03160217905550620001f460006200024460201b620020121760201c565b601380546001600160681b0392909216600160681b02600160681b600160d01b031990921691909117905550506001600160601b0319606092831b811660c052911b1660a052620002a3565b3390565b6000600160681b82106200029f576040805162461bcd60e51b815260206004820152601e60248201527f76616c756520646f6573206e6f742066697420696e2031303420626974730000604482015290519081900360640190fd5b5090565b60805160601c60a05160601c60c05160601c613201620002ed600039806111cf5280611af8525080610fa25280611a99525080610c2b5280610e01528061198052506132016000f3fe608060405234801561001057600080fd5b50600436106103415760003560e01c8063715018a6116101bd578063c415b95c116100f9578063e9f7e17b116100a2578063f2fde38b1161007c578063f2fde38b146108dc578063f383033514610902578063fb20b7d01461090a578063fc0e74d11461093057610341565b8063e9f7e17b14610891578063edb7a6fa146108ae578063ef54244b146108d457610341565b8063d8f4e0eb116100d3578063d8f4e0eb14610864578063e7a7b5a014610881578063e859e56c1461088957610341565b8063c415b95c146107fc578063cf0b227014610804578063d88ff1f41461080c57610341565b8063901754d711610166578063a42dce8011610140578063a42dce8014610704578063ad3333481461072a578063b0cb4b0a146107ec578063b8ffca32146107f457610341565b8063901754d7146106935780639725ff35146106c157806399fca7d9146106de57610341565b8063865e457311610197578063865e45731461065d5780638d424127146106835780638da5cb5b1461068b57610341565b8063715018a6146106275780637c4423a81461062f578063855559341461065557610341565b80633b90b9bf1161028c5780635a6c72d011610235578063607c219f1161020f578063607c219f146105cb578063612a9f76146105f157806370989330146105f957806370a082311461060157610341565b80635a6c72d0146105955780635b16ebb71461059d5780635c975abb146105c357610341565b806341d1de971161026657806341d1de97146104ed578063544caa561461050a578063545e7c611461056757610341565b80633b90b9bf1461049b5780633eed75c3146104c15780634187b7d6146104c957610341565b80631845f0db116102ee57806323662bb9116102c857806323662bb91461044a57806327a27433146104525780632ba653ec1461047e57610341565b80631845f0db1461041e57806322abd7b21461042657806322f3e2d41461042e57610341565b8063172886e71161031f578063172886e7146103a557806317901de3146103dc57806318160ddd1461041657610341565b8063117036d11461034657806314fd235a1461037e578063151359b41461039d575b600080fd5b61036c6004803603602081101561035c57600080fd5b50356001600160a01b0316610938565b60408051918252519081900360200190f35b61039b6004803603602081101561039457600080fd5b5035610978565b005b61039b610a1e565b6103ad610a65565b6040805194855260208501939093526001600160a01b0391821684840152166060830152519081900360800190f35b6103e4610b1b565b604080516001600160681b03948516815292909316602083015265ffffffffffff168183015290519081900360600190f35b61036c610b47565b61036c610b4d565b6103e4610b9b565b610436610bc7565b604080519115158252519081900360200190f35b61036c610bd7565b61039b6004803603604081101561046857600080fd5b506001600160a01b038135169060200135610c20565b61039b6004803603602081101561049457600080fd5b5035610cab565b610436600480360360208110156104b157600080fd5b50356001600160a01b0316610d9e565b61039b610db3565b6104d1610dff565b604080516001600160a01b039092168252519081900360200190f35b6104d16004803603602081101561050357600080fd5b5035610e23565b6105386004803603604081101561052057600080fd5b506001600160a01b0381358116916020013516610e4a565b60405180836001600160a01b03168152602001826001600160a01b031681526020019250505060405180910390f35b6104d16004803603604081101561057d57600080fd5b506001600160a01b0381358116916020013516610e7e565b61036c61140c565b610436600480360360208110156105b357600080fd5b50356001600160a01b0316611455565b61043661146a565b61039b600480360360208110156105e157600080fd5b50356001600160a01b031661147a565b61039b611553565b6104d161157f565b61036c6004803603602081101561061757600080fd5b50356001600160a01b031661158e565b61039b6115a9565b61036c6004803603602081101561064557600080fd5b50356001600160a01b031661165d565b61039b61168e565b61036c6004803603602081101561067357600080fd5b50356001600160a01b03166116ba565b61039b6116ea565b6104d1611736565b6104d1600480360360408110156106a957600080fd5b506001600160a01b0381358116916020013516611745565b61039b600480360360208110156106d757600080fd5b5035611786565b61036c600480360360208110156106f457600080fd5b50356001600160a01b031661186c565b61039b6004803603602081101561071a57600080fd5b50356001600160a01b031661189c565b61039b6004803603604081101561074057600080fd5b81019060208101813564010000000081111561075b57600080fd5b82018360208201111561076d57600080fd5b8035906020019184602083028401116401000000008311171561078f57600080fd5b9193909290916020810190356401000000008111156107ad57600080fd5b8201836020820111156107bf57600080fd5b803590602001918460208302840111640100000000831117156107e157600080fd5b509092509050611975565b6104d1611a97565b6103e4611abb565b6104d1611ae7565b6104d1611af6565b610814611b1a565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610850578181015183820152602001610838565b505050509050019250505060405180910390f35b61039b6004803603602081101561087a57600080fd5b5035611b7c565b6103e4611c05565b61036c611c31565b61039b600480360360208110156108a757600080fd5b5035611c7a565b6108b6611d04565b60408051938452602084019290925282820152519081900360600190f35b6103e4611de8565b61039b600480360360208110156108f257600080fd5b50356001600160a01b0316611e14565b61036c611f1f565b61036c6004803603602081101561092057600080fd5b50356001600160a01b0316611f68565b61039b611fa0565b6001600160a01b038116600090815260126020908152604080832081519283019091525481526109709067016345785d8a0000612070565b90505b919050565b67016345785d8a00008111156109d5576040805162461bcd60e51b815260206004820152601a60248201527f476f7620736861726520766f746520697320746f6f2068696768000000000000604482015290519081900360640190fd5b33600081815260166020908152604091829020825191820190925290548152610a1b9190610a028461208c565b610a0b3361158e565b60139392919060006120ab6120fe565b50565b33600081815260066020908152604091829020825191820190925290548152610a639190610a4a612117565b610a533361158e565b60039392919060006121326120fe565b565b60408051606081018252600f546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090819081908190610ab490612185565b604080516060810182526013546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152610afa90612185565b60175460185492979196506001600160a01b03908116955090911692509050565b600f546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b60005490565b60408051606081018252600b546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b905090565b6013546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b6000610bd161146a565b15905090565b604080516060810182526007546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610c9d576040805162461bcd60e51b815260206004820152601f60248201527f416363657373207265737472696374656420746f206d6f746865727368697000604482015290519081900360640190fd5b610ca78282612219565b5050565b61012c811115610d02576040805162461bcd60e51b815260206004820152601d60248201527f446563617920706572696f6420766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b603c811015610d58576040805162461bcd60e51b815260206004820152601c60248201527f446563617920706572696f6420766f746520697320746f6f206c6f7700000000604482015290519081900360640190fd5b336000818152600e6020908152604091829020825191820190925290548152610a1b9190610d858461208c565b610d8e3361158e565b600b93929190603c6123756120fe565b60196020526000908152604090205460ff1681565b33600081815260126020908152604091829020825191820190925290548152610a639190610ddf612117565b610de83361158e565b600f9392919067016345785d8a00006123c86120fe565b7f000000000000000000000000000000000000000000000000000000000000000081565b601a8181548110610e3057fe5b6000918252602090912001546001600160a01b0316905081565b600080826001600160a01b0316846001600160a01b03161015610e71575082905081610e77565b50819050825b9250929050565b6000816001600160a01b0316836001600160a01b03161415610ee7576040805162461bcd60e51b815260206004820181905260248201527f466163746f72793a206e6f7420737570706f72742073616d6520746f6b656e73604482015290519081900360640190fd5b600080610ef48585610e4a565b6001600160a01b038083166000908152601c6020908152604080832084861684529091529020549294509092501615610f74576040805162461bcd60e51b815260206004820152601c60248201527f466163746f72793a20706f6f6c20616c72656164792065786973747300000000604482015290519081900360640190fd5b6060610f88836001600160a01b031661241b565b90506060610f9e836001600160a01b031661241b565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b92440b08585858560405160200180807f31696e6368204c697175696469747920506f6f6c20280000000000000000000081525060160183805190602001908083835b6020831061102d5780518252601f19909201916020918201910161100e565b6001836020036101000a03801982511681845116808217855250505050505090500180602d60f81b81525060010182805190602001908083835b602083106110865780518252601f199092019160209182019101611067565b6001836020036101000a038019825116818451168082178552505050505050905001807f290000000000000000000000000000000000000000000000000000000000000081525060010192505050604051602081830303815290604052868660405160200180807f314c502d0000000000000000000000000000000000000000000000000000000081525060040183805190602001908083835b6020831061113f5780518252601f199092019160209182019101611120565b6001836020036101000a03801982511681845116808217855250505050505090500180602d60f81b81525060010182805190602001908083835b602083106111985780518252601f199092019160209182019101611179565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040527f00000000000000000000000000000000000000000000000000000000000000006040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b031681526020018060200180602001846001600160a01b03168152602001838103835286818151815260200191508051906020019080838360005b8381101561126b578181015183820152602001611253565b50505050905090810190601f1680156112985780820380516001836020036101000a031916815260200191505b50838103825285518152855160209182019187019080838360005b838110156112cb5781810151838201526020016112b3565b50505050905090810190601f1680156112f85780820380516001836020036101000a031916815260200191505b50975050505050505050602060405180830381600087803b15801561131c57600080fd5b505af1158015611330573d6000803e3d6000fd5b505050506040513d602081101561134657600080fd5b50516001600160a01b038086166000818152601c6020908152604080832089861680855290835281842080549688166001600160a01b03199788168117909155601a805460018181019092557f057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff63e0180549098168217909755808552601b909352818420805460ff19169096179095555194995092939192917fc95935a66d15e0da5e412aca0ad27ae891d20b2fb91cf3994b6a3bf2b81780829190a45050505092915050565b604080516060810182526003546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b601b6020526000908152604090205460ff1681565b600254600160a01b900460ff1690565b6114826128f6565b6002546001600160a01b039081169116146114e4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b601780546001600160a01b0319166001600160a01b038316908117909155600081815260196020908152604091829020805460ff19166001179055815192835290517fe348b7d1d8572de16c7301317890112a52bd7f6c3b713bd7d70e4cffb489ed9f9281900390910190a150565b33600081815260166020908152604091829020825191820190925290548152610a639190610a02612117565b6017546001600160a01b031681565b6001600160a01b031660009081526001602052604090205490565b6115b16128f6565b6002546001600160a01b03908116911614611613576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6002546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600280546001600160a01b0319169055565b6001600160a01b0381166000908152600e60209081526040808320815192830190915254815261097090603c612070565b336000818152600e6020908152604091829020825191820190925290548152610a639190610d85612117565b6001600160a01b038116600090815260166020908152604080832081519283019091525481526109709082612070565b336000818152600a6020908152604091829020825191820190925290548152610a639190611716612117565b61171f3361158e565b600793929190670de0b6b3a76400006128fa6120fe565b6002546001600160a01b031690565b60008060006117548585610e4a565b6001600160a01b039182166000908152601c602090815260408083209385168352929052205416925050505b92915050565b67016345785d8a00008111156117e3576040805162461bcd60e51b815260206004820152601f60248201527f526566657272616c20736861726520766f746520697320746f6f206869676800604482015290519081900360640190fd5b66b1a2bc2ec5000081101561183f576040805162461bcd60e51b815260206004820152601e60248201527f526566657272616c20736861726520766f746520697320746f6f206c6f770000604482015290519081900360640190fd5b33600081815260126020908152604091829020825191820190925290548152610a1b9190610ddf8461208c565b6001600160a01b038116600090815260066020908152604080832081519283019091525481526109709082612070565b6118a46128f6565b6002546001600160a01b03908116911614611906576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b601880546001600160a01b0319166001600160a01b038316908117909155600081815260196020908152604091829020805460ff19166001179055815192835290517ffa7dc4914c53d1cee4cf31f857b016d55f8c6d28d5f950e64c7258a4fa18de199281900390910190a150565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146119f2576040805162461bcd60e51b815260206004820152601f60248201527f416363657373207265737472696374656420746f206d6f746865727368697000604482015290519081900360640190fd5b828114611a46576040805162461bcd60e51b815260206004820152601d60248201527f417272617973206c656e6774682073686f756c6420626520657175616c000000604482015290519081900360640190fd5b60005b83811015611a9057611a88858583818110611a6057fe5b905060200201356001600160a01b0316848484818110611a7c57fe5b90506020020135612219565b600101611a49565b5050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6007546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b6018546001600160a01b031681565b7f000000000000000000000000000000000000000000000000000000000000000081565b6060601a805480602002602001604051908101604052809291908181526020018280548015611b7257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611b54575b5050505050905090565b662386f26fc10000811115611bd8576040805162461bcd60e51b815260206004820152601460248201527f46656520766f746520697320746f6f2068696768000000000000000000000000604482015290519081900360640190fd5b33600081815260066020908152604091829020825191820190925290548152610a1b9190610a4a8461208c565b6003546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b60408051606081018252600f546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b670de0b6b3a7640000811115611cd7576040805162461bcd60e51b815260206004820152601d60248201527f536c6970706167652066656520766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b336000818152600a6020908152604091829020825191820190925290548152610a1b91906117168461208c565b604080516060810182526003546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff169181019190915260009081908190611d5190612185565b604080516060810182526007546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152611d9790612185565b60408051606081018252600b546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152611ddd90612185565b925092509250909192565b600b546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b611e1c6128f6565b6002546001600160a01b03908116911614611e7e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116611ec35760405162461bcd60e51b81526004018080602001828103825260268152602001806131856026913960400191505060405180910390fd5b6002546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600280546001600160a01b0319166001600160a01b0392909216919091179055565b604080516060810182526013546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b6001600160a01b0381166000908152600a60209081526040808320815192830190915254815261097090670de0b6b3a7640000612070565b611fa86128f6565b6002546001600160a01b0390811691161461200a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610a6361294d565b6000600160681b821061206c576040805162461bcd60e51b815260206004820152601e60248201527f76616c756520646f6573206e6f742066697420696e2031303420626974730000604482015290519081900360640190fd5b5090565b8151600090156120865750815160001901611780565b50919050565b612094613151565b506040805160208101909152600182018152919050565b60408051848152831515602082015280820183905290516001600160a01b038616917f02540a8a88261967ef1c1a4ed50fde9f0a0a493922c069129e21961198e1b439919081900360600190a250505050565b61210e8787878787888888612a20565b50505050505050565b61211f613151565b5060408051602081019091526000815290565b60408051848152831515602082015280820183905290516001600160a01b038616917f28eed64d01e23014333abef902958309592b3cf9ce9da390f224467cfcaaf5b2919081900360600190a250505050565b6000806121b3620151806121ae856040015165ffffffffffff1642612c2990919063ffffffff16565b612c72565b905060006121c46201518083612c29565b90506122116201518061220b6121f08588602001516001600160681b0316612c8890919063ffffffff16565b8751612205906001600160681b031686612c88565b90612ce1565b90612d3b565b949350505050565b60006122258383612d7d565b9050808214156122355750610ca7565b6001600160a01b0383166000908152600660209081526040808320815192830190915254815261227091600391869185908790612132612dd8565b6001600160a01b0383166000908152600a60209081526040918290208251918201909252905481526122b49060079085908486670de0b6b3a76400006128fa612dd8565b6001600160a01b0383166000908152600e60209081526040918290208251918201909252905481526122f190600b9085908486603c612375612dd8565b6001600160a01b03831660009081526012602090815260409182902082519182019092529054815261233590600f908590848667016345785d8a00006123c8612dd8565b6001600160a01b03831660009081526016602090815260408083208151928301909152548152612370916013918691859087906120ab612dd8565b505050565b60408051848152831515602082015280820183905290516001600160a01b038616917f2d2d732aa884d37295a1b5995321d502ebc228d25e644eef0a435d4e5f245acd919081900360600190a250505050565b60408051848152831515602082015280820183905290516001600160a01b038616917ffa67c3ef5d30b2838a61d783cb71a076e17984d05840f2dfa1521135df49557b919081900360600190a250505050565b606061242682612dfb565b15612465575060408051808201909152600381527f45544800000000000000000000000000000000000000000000000000000000006020820152610973565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b4100000000000000000000000000000000000000000000000000000000178152915181516000936060936001600160a01b03881693614e2093919290918291908083835b602083106124fe5780518252601f1990920191602091820191016124df565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d806000811461255f576040519150601f19603f3d011682016040523d82523d6000602084013e612564565b606091505b50915091508161266c5760408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167ff76f8d7800000000000000000000000000000000000000000000000000000000178152915181516001600160a01b03881693614e209392918291908083835b602083106125ff5780518252601f1990920191602091820191016125e0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d8060008114612660576040519150601f19603f3d011682016040523d82523d6000602084013e612665565b606091505b5090925090505b81801561267b57506060815110155b1561279a5760008082806020019051604081101561269857600080fd5b5080516020918201519093509150821480156126b45750600081115b80156126c257506101008111155b15612797578280602001905160208110156126dc57600080fd5b81019080805160405193929190846401000000008211156126fc57600080fd5b90830190602082018581111561271157600080fd5b825164010000000081118282018810171561272b57600080fd5b82525081516020918201929091019080838360005b83811015612758578181015183820152602001612740565b50505050905090810190601f1680156127855780820380516001836020036101000a031916815260200191505b50604052505050945050505050610973565b50505b8180156127a8575080516020145b156128ed5760005b8151811080156127f65750602060f81b8282815181106127cc57fe5b01602001517fff000000000000000000000000000000000000000000000000000000000000001610155b80156128385750607e60f81b82828151811061280e57fe5b01602001517fff000000000000000000000000000000000000000000000000000000000000001611155b15612845576001016127b0565b80156128eb5760608167ffffffffffffffff8111801561286457600080fd5b506040519080825280601f01601f19166020018201604052801561288f576020820181803683370190505b50905060005b828110156128df578381815181106128a957fe5b602001015160f81c60f81b8282815181106128c057fe5b60200101906001600160f81b031916908160001a905350600101612895565b50935061097392505050565b505b61221184612e08565b3390565b60408051848152831515602082015280820183905290516001600160a01b038616917f214419d1bacc9564ca0fcf6552dad3ec0aa54c97de900de89dc202e6bbd9198a919081900360600190a250505050565b600254600160a01b900460ff16156129ac576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b600280547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612a036128f6565b604080516001600160a01b039092168252519081900360200190a1565b60018801546002890154819080612a368a612e3e565b612a6757612a58612a51612a4a8c89612070565b8a90612c88565b8490612c29565b9250612a648189612c29565b90505b612a7089612e3e565b612aa157612a92612a8b612a848b89612070565b8990612c88565b8490612ce1565b9250612a9e8188612ce1565b90505b838314612ab05760018c018390555b818114612abf5760028c018190555b60008115612ad657612ad18483612d3b565b612ad8565b865b9050612ae2613164565b50604080516060810182528e546001600160681b038082168352600160681b82041660208301819052600160d01b90910465ffffffffffff1692820192909252908214612bca578d612b3b612b3683612185565b612012565b612b4484612012565b612b4d42612e43565b835479ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b65ffffffffffff9290921691909102177fffffffffffff00000000000000000000000000ffffffffffffffffffffffffff16600160681b6001600160681b0392831602176cffffffffffffffffffffffffff191691161790555b50612bd79050898b612ea0565b612bfa576001600160a01b038b16600090815260038d0160205260409020895190555b612c1b8b612c088b89612070565b612c118c612e3e565b8a8963ffffffff16565b505050505050505050505050565b6000612c6b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612ea7565b9392505050565b6000818310612c815781612c6b565b5090919050565b600082612c9757506000611780565b82820282848281612ca457fe5b0414612c6b5760405162461bcd60e51b81526004018080602001828103825260218152602001806131ab6021913960400191505060405180910390fd5b600082820183811015612c6b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000612c6b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612f3e565b6001600160a01b038216600090815260016020526040902054818114611780576001600160a01b038316600090815260016020526040812083905554612dcf908290612dc99085612ce1565b90612c29565b60005592915050565b61210e8787878615612dea5788612df2565b612df2612117565b88888888612a20565b6001600160a01b03161590565b60606109708260405160200180826001600160a01b031660601b8152601401915050604051602081830303815290604052612fa3565b511590565b60006601000000000000821061206c576040805162461bcd60e51b815260206004820152601d60248201527f76616c756520646f6573206e6f742066697420696e2034382062697473000000604482015290519081900360640190fd5b5190511490565b60008184841115612f365760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612efb578181015183820152602001612ee3565b50505050905090810190601f168015612f285780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008183612f8d5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612efb578181015183820152602001612ee3565b506000838581612f9957fe5b0495945050505050565b606080825160020260020167ffffffffffffffff81118015612fc457600080fd5b506040519080825280601f01601f191660200182016040528015612fef576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061302057fe5b60200101906001600160f81b031916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061306557fe5b60200101906001600160f81b031916908160001a905350600260005b8451811015613148576000600486838151811061309a57fe5b602001015160f81c60f81b60f81c60ff16901c60ff16905060008683815181106130c057fe5b60209101015160f81c600f169050600a8204602702826030010160f81b8585806001019650815181106130ef57fe5b60200101906001600160f81b031916908160001a905350600a8104602702816030010160f81b85858060010196508151811061312757fe5b60200101906001600160f81b031916908160001a9053505050600101613081565b50909392505050565b6040518060200160405280600081525090565b60408051606081018252600080825260208201819052918101919091529056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212203055b0d734dca8615198a959a7d99698303ce19e8493d5730b98cd12bd00115a64736f6c634300060c00330000000000000000000000005e89f8d81c74e311458277ea1be3d3247c7cd7d1000000000000000000000000cb06df7f0be5b8bb261d294cf87c794eb9da85b1000000000000000000000000a0446d8804611944f1b527ecd37d7dcbe442caba

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106103415760003560e01c8063715018a6116101bd578063c415b95c116100f9578063e9f7e17b116100a2578063f2fde38b1161007c578063f2fde38b146108dc578063f383033514610902578063fb20b7d01461090a578063fc0e74d11461093057610341565b8063e9f7e17b14610891578063edb7a6fa146108ae578063ef54244b146108d457610341565b8063d8f4e0eb116100d3578063d8f4e0eb14610864578063e7a7b5a014610881578063e859e56c1461088957610341565b8063c415b95c146107fc578063cf0b227014610804578063d88ff1f41461080c57610341565b8063901754d711610166578063a42dce8011610140578063a42dce8014610704578063ad3333481461072a578063b0cb4b0a146107ec578063b8ffca32146107f457610341565b8063901754d7146106935780639725ff35146106c157806399fca7d9146106de57610341565b8063865e457311610197578063865e45731461065d5780638d424127146106835780638da5cb5b1461068b57610341565b8063715018a6146106275780637c4423a81461062f578063855559341461065557610341565b80633b90b9bf1161028c5780635a6c72d011610235578063607c219f1161020f578063607c219f146105cb578063612a9f76146105f157806370989330146105f957806370a082311461060157610341565b80635a6c72d0146105955780635b16ebb71461059d5780635c975abb146105c357610341565b806341d1de971161026657806341d1de97146104ed578063544caa561461050a578063545e7c611461056757610341565b80633b90b9bf1461049b5780633eed75c3146104c15780634187b7d6146104c957610341565b80631845f0db116102ee57806323662bb9116102c857806323662bb91461044a57806327a27433146104525780632ba653ec1461047e57610341565b80631845f0db1461041e57806322abd7b21461042657806322f3e2d41461042e57610341565b8063172886e71161031f578063172886e7146103a557806317901de3146103dc57806318160ddd1461041657610341565b8063117036d11461034657806314fd235a1461037e578063151359b41461039d575b600080fd5b61036c6004803603602081101561035c57600080fd5b50356001600160a01b0316610938565b60408051918252519081900360200190f35b61039b6004803603602081101561039457600080fd5b5035610978565b005b61039b610a1e565b6103ad610a65565b6040805194855260208501939093526001600160a01b0391821684840152166060830152519081900360800190f35b6103e4610b1b565b604080516001600160681b03948516815292909316602083015265ffffffffffff168183015290519081900360600190f35b61036c610b47565b61036c610b4d565b6103e4610b9b565b610436610bc7565b604080519115158252519081900360200190f35b61036c610bd7565b61039b6004803603604081101561046857600080fd5b506001600160a01b038135169060200135610c20565b61039b6004803603602081101561049457600080fd5b5035610cab565b610436600480360360208110156104b157600080fd5b50356001600160a01b0316610d9e565b61039b610db3565b6104d1610dff565b604080516001600160a01b039092168252519081900360200190f35b6104d16004803603602081101561050357600080fd5b5035610e23565b6105386004803603604081101561052057600080fd5b506001600160a01b0381358116916020013516610e4a565b60405180836001600160a01b03168152602001826001600160a01b031681526020019250505060405180910390f35b6104d16004803603604081101561057d57600080fd5b506001600160a01b0381358116916020013516610e7e565b61036c61140c565b610436600480360360208110156105b357600080fd5b50356001600160a01b0316611455565b61043661146a565b61039b600480360360208110156105e157600080fd5b50356001600160a01b031661147a565b61039b611553565b6104d161157f565b61036c6004803603602081101561061757600080fd5b50356001600160a01b031661158e565b61039b6115a9565b61036c6004803603602081101561064557600080fd5b50356001600160a01b031661165d565b61039b61168e565b61036c6004803603602081101561067357600080fd5b50356001600160a01b03166116ba565b61039b6116ea565b6104d1611736565b6104d1600480360360408110156106a957600080fd5b506001600160a01b0381358116916020013516611745565b61039b600480360360208110156106d757600080fd5b5035611786565b61036c600480360360208110156106f457600080fd5b50356001600160a01b031661186c565b61039b6004803603602081101561071a57600080fd5b50356001600160a01b031661189c565b61039b6004803603604081101561074057600080fd5b81019060208101813564010000000081111561075b57600080fd5b82018360208201111561076d57600080fd5b8035906020019184602083028401116401000000008311171561078f57600080fd5b9193909290916020810190356401000000008111156107ad57600080fd5b8201836020820111156107bf57600080fd5b803590602001918460208302840111640100000000831117156107e157600080fd5b509092509050611975565b6104d1611a97565b6103e4611abb565b6104d1611ae7565b6104d1611af6565b610814611b1a565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610850578181015183820152602001610838565b505050509050019250505060405180910390f35b61039b6004803603602081101561087a57600080fd5b5035611b7c565b6103e4611c05565b61036c611c31565b61039b600480360360208110156108a757600080fd5b5035611c7a565b6108b6611d04565b60408051938452602084019290925282820152519081900360600190f35b6103e4611de8565b61039b600480360360208110156108f257600080fd5b50356001600160a01b0316611e14565b61036c611f1f565b61036c6004803603602081101561092057600080fd5b50356001600160a01b0316611f68565b61039b611fa0565b6001600160a01b038116600090815260126020908152604080832081519283019091525481526109709067016345785d8a0000612070565b90505b919050565b67016345785d8a00008111156109d5576040805162461bcd60e51b815260206004820152601a60248201527f476f7620736861726520766f746520697320746f6f2068696768000000000000604482015290519081900360640190fd5b33600081815260166020908152604091829020825191820190925290548152610a1b9190610a028461208c565b610a0b3361158e565b60139392919060006120ab6120fe565b50565b33600081815260066020908152604091829020825191820190925290548152610a639190610a4a612117565b610a533361158e565b60039392919060006121326120fe565b565b60408051606081018252600f546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090819081908190610ab490612185565b604080516060810182526013546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152610afa90612185565b60175460185492979196506001600160a01b03908116955090911692509050565b600f546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b60005490565b60408051606081018252600b546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b905090565b6013546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b6000610bd161146a565b15905090565b604080516060810182526007546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b336001600160a01b037f000000000000000000000000a0446d8804611944f1b527ecd37d7dcbe442caba1614610c9d576040805162461bcd60e51b815260206004820152601f60248201527f416363657373207265737472696374656420746f206d6f746865727368697000604482015290519081900360640190fd5b610ca78282612219565b5050565b61012c811115610d02576040805162461bcd60e51b815260206004820152601d60248201527f446563617920706572696f6420766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b603c811015610d58576040805162461bcd60e51b815260206004820152601c60248201527f446563617920706572696f6420766f746520697320746f6f206c6f7700000000604482015290519081900360640190fd5b336000818152600e6020908152604091829020825191820190925290548152610a1b9190610d858461208c565b610d8e3361158e565b600b93929190603c6123756120fe565b60196020526000908152604090205460ff1681565b33600081815260126020908152604091829020825191820190925290548152610a639190610ddf612117565b610de83361158e565b600f9392919067016345785d8a00006123c86120fe565b7f000000000000000000000000a0446d8804611944f1b527ecd37d7dcbe442caba81565b601a8181548110610e3057fe5b6000918252602090912001546001600160a01b0316905081565b600080826001600160a01b0316846001600160a01b03161015610e71575082905081610e77565b50819050825b9250929050565b6000816001600160a01b0316836001600160a01b03161415610ee7576040805162461bcd60e51b815260206004820181905260248201527f466163746f72793a206e6f7420737570706f72742073616d6520746f6b656e73604482015290519081900360640190fd5b600080610ef48585610e4a565b6001600160a01b038083166000908152601c6020908152604080832084861684529091529020549294509092501615610f74576040805162461bcd60e51b815260206004820152601c60248201527f466163746f72793a20706f6f6c20616c72656164792065786973747300000000604482015290519081900360640190fd5b6060610f88836001600160a01b031661241b565b90506060610f9e836001600160a01b031661241b565b90507f000000000000000000000000cb06df7f0be5b8bb261d294cf87c794eb9da85b16001600160a01b031663b92440b08585858560405160200180807f31696e6368204c697175696469747920506f6f6c20280000000000000000000081525060160183805190602001908083835b6020831061102d5780518252601f19909201916020918201910161100e565b6001836020036101000a03801982511681845116808217855250505050505090500180602d60f81b81525060010182805190602001908083835b602083106110865780518252601f199092019160209182019101611067565b6001836020036101000a038019825116818451168082178552505050505050905001807f290000000000000000000000000000000000000000000000000000000000000081525060010192505050604051602081830303815290604052868660405160200180807f314c502d0000000000000000000000000000000000000000000000000000000081525060040183805190602001908083835b6020831061113f5780518252601f199092019160209182019101611120565b6001836020036101000a03801982511681845116808217855250505050505090500180602d60f81b81525060010182805190602001908083835b602083106111985780518252601f199092019160209182019101611179565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040527f0000000000000000000000005e89f8d81c74e311458277ea1be3d3247c7cd7d16040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b031681526020018060200180602001846001600160a01b03168152602001838103835286818151815260200191508051906020019080838360005b8381101561126b578181015183820152602001611253565b50505050905090810190601f1680156112985780820380516001836020036101000a031916815260200191505b50838103825285518152855160209182019187019080838360005b838110156112cb5781810151838201526020016112b3565b50505050905090810190601f1680156112f85780820380516001836020036101000a031916815260200191505b50975050505050505050602060405180830381600087803b15801561131c57600080fd5b505af1158015611330573d6000803e3d6000fd5b505050506040513d602081101561134657600080fd5b50516001600160a01b038086166000818152601c6020908152604080832089861680855290835281842080549688166001600160a01b03199788168117909155601a805460018181019092557f057c384a7d1c54f3a1b2e5e67b2617b8224fdfd1ea7234eea573a6ff665ff63e0180549098168217909755808552601b909352818420805460ff19169096179095555194995092939192917fc95935a66d15e0da5e412aca0ad27ae891d20b2fb91cf3994b6a3bf2b81780829190a45050505092915050565b604080516060810182526003546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b601b6020526000908152604090205460ff1681565b600254600160a01b900460ff1690565b6114826128f6565b6002546001600160a01b039081169116146114e4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b601780546001600160a01b0319166001600160a01b038316908117909155600081815260196020908152604091829020805460ff19166001179055815192835290517fe348b7d1d8572de16c7301317890112a52bd7f6c3b713bd7d70e4cffb489ed9f9281900390910190a150565b33600081815260166020908152604091829020825191820190925290548152610a639190610a02612117565b6017546001600160a01b031681565b6001600160a01b031660009081526001602052604090205490565b6115b16128f6565b6002546001600160a01b03908116911614611613576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6002546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600280546001600160a01b0319169055565b6001600160a01b0381166000908152600e60209081526040808320815192830190915254815261097090603c612070565b336000818152600e6020908152604091829020825191820190925290548152610a639190610d85612117565b6001600160a01b038116600090815260166020908152604080832081519283019091525481526109709082612070565b336000818152600a6020908152604091829020825191820190925290548152610a639190611716612117565b61171f3361158e565b600793929190670de0b6b3a76400006128fa6120fe565b6002546001600160a01b031690565b60008060006117548585610e4a565b6001600160a01b039182166000908152601c602090815260408083209385168352929052205416925050505b92915050565b67016345785d8a00008111156117e3576040805162461bcd60e51b815260206004820152601f60248201527f526566657272616c20736861726520766f746520697320746f6f206869676800604482015290519081900360640190fd5b66b1a2bc2ec5000081101561183f576040805162461bcd60e51b815260206004820152601e60248201527f526566657272616c20736861726520766f746520697320746f6f206c6f770000604482015290519081900360640190fd5b33600081815260126020908152604091829020825191820190925290548152610a1b9190610ddf8461208c565b6001600160a01b038116600090815260066020908152604080832081519283019091525481526109709082612070565b6118a46128f6565b6002546001600160a01b03908116911614611906576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b601880546001600160a01b0319166001600160a01b038316908117909155600081815260196020908152604091829020805460ff19166001179055815192835290517ffa7dc4914c53d1cee4cf31f857b016d55f8c6d28d5f950e64c7258a4fa18de199281900390910190a150565b336001600160a01b037f000000000000000000000000a0446d8804611944f1b527ecd37d7dcbe442caba16146119f2576040805162461bcd60e51b815260206004820152601f60248201527f416363657373207265737472696374656420746f206d6f746865727368697000604482015290519081900360640190fd5b828114611a46576040805162461bcd60e51b815260206004820152601d60248201527f417272617973206c656e6774682073686f756c6420626520657175616c000000604482015290519081900360640190fd5b60005b83811015611a9057611a88858583818110611a6057fe5b905060200201356001600160a01b0316848484818110611a7c57fe5b90506020020135612219565b600101611a49565b5050505050565b7f000000000000000000000000cb06df7f0be5b8bb261d294cf87c794eb9da85b181565b6007546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b6018546001600160a01b031681565b7f0000000000000000000000005e89f8d81c74e311458277ea1be3d3247c7cd7d181565b6060601a805480602002602001604051908101604052809291908181526020018280548015611b7257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611b54575b5050505050905090565b662386f26fc10000811115611bd8576040805162461bcd60e51b815260206004820152601460248201527f46656520766f746520697320746f6f2068696768000000000000000000000000604482015290519081900360640190fd5b33600081815260066020908152604091829020825191820190925290548152610a1b9190610a4a8461208c565b6003546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b60408051606081018252600f546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b670de0b6b3a7640000811115611cd7576040805162461bcd60e51b815260206004820152601d60248201527f536c6970706167652066656520766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b336000818152600a6020908152604091829020825191820190925290548152610a1b91906117168461208c565b604080516060810182526003546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff169181019190915260009081908190611d5190612185565b604080516060810182526007546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152611d9790612185565b60408051606081018252600b546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152611ddd90612185565b925092509250909192565b600b546001600160681b0380821692600160681b830490911691600160d01b900465ffffffffffff1690565b611e1c6128f6565b6002546001600160a01b03908116911614611e7e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116611ec35760405162461bcd60e51b81526004018080602001828103825260268152602001806131856026913960400191505060405180910390fd5b6002546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600280546001600160a01b0319166001600160a01b0392909216919091179055565b604080516060810182526013546001600160681b038082168352600160681b8204166020830152600160d01b900465ffffffffffff1691810191909152600090610b9690612185565b6001600160a01b0381166000908152600a60209081526040808320815192830190915254815261097090670de0b6b3a7640000612070565b611fa86128f6565b6002546001600160a01b0390811691161461200a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610a6361294d565b6000600160681b821061206c576040805162461bcd60e51b815260206004820152601e60248201527f76616c756520646f6573206e6f742066697420696e2031303420626974730000604482015290519081900360640190fd5b5090565b8151600090156120865750815160001901611780565b50919050565b612094613151565b506040805160208101909152600182018152919050565b60408051848152831515602082015280820183905290516001600160a01b038616917f02540a8a88261967ef1c1a4ed50fde9f0a0a493922c069129e21961198e1b439919081900360600190a250505050565b61210e8787878787888888612a20565b50505050505050565b61211f613151565b5060408051602081019091526000815290565b60408051848152831515602082015280820183905290516001600160a01b038616917f28eed64d01e23014333abef902958309592b3cf9ce9da390f224467cfcaaf5b2919081900360600190a250505050565b6000806121b3620151806121ae856040015165ffffffffffff1642612c2990919063ffffffff16565b612c72565b905060006121c46201518083612c29565b90506122116201518061220b6121f08588602001516001600160681b0316612c8890919063ffffffff16565b8751612205906001600160681b031686612c88565b90612ce1565b90612d3b565b949350505050565b60006122258383612d7d565b9050808214156122355750610ca7565b6001600160a01b0383166000908152600660209081526040808320815192830190915254815261227091600391869185908790612132612dd8565b6001600160a01b0383166000908152600a60209081526040918290208251918201909252905481526122b49060079085908486670de0b6b3a76400006128fa612dd8565b6001600160a01b0383166000908152600e60209081526040918290208251918201909252905481526122f190600b9085908486603c612375612dd8565b6001600160a01b03831660009081526012602090815260409182902082519182019092529054815261233590600f908590848667016345785d8a00006123c8612dd8565b6001600160a01b03831660009081526016602090815260408083208151928301909152548152612370916013918691859087906120ab612dd8565b505050565b60408051848152831515602082015280820183905290516001600160a01b038616917f2d2d732aa884d37295a1b5995321d502ebc228d25e644eef0a435d4e5f245acd919081900360600190a250505050565b60408051848152831515602082015280820183905290516001600160a01b038616917ffa67c3ef5d30b2838a61d783cb71a076e17984d05840f2dfa1521135df49557b919081900360600190a250505050565b606061242682612dfb565b15612465575060408051808201909152600381527f45544800000000000000000000000000000000000000000000000000000000006020820152610973565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b4100000000000000000000000000000000000000000000000000000000178152915181516000936060936001600160a01b03881693614e2093919290918291908083835b602083106124fe5780518252601f1990920191602091820191016124df565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d806000811461255f576040519150601f19603f3d011682016040523d82523d6000602084013e612564565b606091505b50915091508161266c5760408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167ff76f8d7800000000000000000000000000000000000000000000000000000000178152915181516001600160a01b03881693614e209392918291908083835b602083106125ff5780518252601f1990920191602091820191016125e0565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d8060008114612660576040519150601f19603f3d011682016040523d82523d6000602084013e612665565b606091505b5090925090505b81801561267b57506060815110155b1561279a5760008082806020019051604081101561269857600080fd5b5080516020918201519093509150821480156126b45750600081115b80156126c257506101008111155b15612797578280602001905160208110156126dc57600080fd5b81019080805160405193929190846401000000008211156126fc57600080fd5b90830190602082018581111561271157600080fd5b825164010000000081118282018810171561272b57600080fd5b82525081516020918201929091019080838360005b83811015612758578181015183820152602001612740565b50505050905090810190601f1680156127855780820380516001836020036101000a031916815260200191505b50604052505050945050505050610973565b50505b8180156127a8575080516020145b156128ed5760005b8151811080156127f65750602060f81b8282815181106127cc57fe5b01602001517fff000000000000000000000000000000000000000000000000000000000000001610155b80156128385750607e60f81b82828151811061280e57fe5b01602001517fff000000000000000000000000000000000000000000000000000000000000001611155b15612845576001016127b0565b80156128eb5760608167ffffffffffffffff8111801561286457600080fd5b506040519080825280601f01601f19166020018201604052801561288f576020820181803683370190505b50905060005b828110156128df578381815181106128a957fe5b602001015160f81c60f81b8282815181106128c057fe5b60200101906001600160f81b031916908160001a905350600101612895565b50935061097392505050565b505b61221184612e08565b3390565b60408051848152831515602082015280820183905290516001600160a01b038616917f214419d1bacc9564ca0fcf6552dad3ec0aa54c97de900de89dc202e6bbd9198a919081900360600190a250505050565b600254600160a01b900460ff16156129ac576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b600280547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612a036128f6565b604080516001600160a01b039092168252519081900360200190a1565b60018801546002890154819080612a368a612e3e565b612a6757612a58612a51612a4a8c89612070565b8a90612c88565b8490612c29565b9250612a648189612c29565b90505b612a7089612e3e565b612aa157612a92612a8b612a848b89612070565b8990612c88565b8490612ce1565b9250612a9e8188612ce1565b90505b838314612ab05760018c018390555b818114612abf5760028c018190555b60008115612ad657612ad18483612d3b565b612ad8565b865b9050612ae2613164565b50604080516060810182528e546001600160681b038082168352600160681b82041660208301819052600160d01b90910465ffffffffffff1692820192909252908214612bca578d612b3b612b3683612185565b612012565b612b4484612012565b612b4d42612e43565b835479ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b65ffffffffffff9290921691909102177fffffffffffff00000000000000000000000000ffffffffffffffffffffffffff16600160681b6001600160681b0392831602176cffffffffffffffffffffffffff191691161790555b50612bd79050898b612ea0565b612bfa576001600160a01b038b16600090815260038d0160205260409020895190555b612c1b8b612c088b89612070565b612c118c612e3e565b8a8963ffffffff16565b505050505050505050505050565b6000612c6b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612ea7565b9392505050565b6000818310612c815781612c6b565b5090919050565b600082612c9757506000611780565b82820282848281612ca457fe5b0414612c6b5760405162461bcd60e51b81526004018080602001828103825260218152602001806131ab6021913960400191505060405180910390fd5b600082820183811015612c6b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000612c6b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612f3e565b6001600160a01b038216600090815260016020526040902054818114611780576001600160a01b038316600090815260016020526040812083905554612dcf908290612dc99085612ce1565b90612c29565b60005592915050565b61210e8787878615612dea5788612df2565b612df2612117565b88888888612a20565b6001600160a01b03161590565b60606109708260405160200180826001600160a01b031660601b8152601401915050604051602081830303815290604052612fa3565b511590565b60006601000000000000821061206c576040805162461bcd60e51b815260206004820152601d60248201527f76616c756520646f6573206e6f742066697420696e2034382062697473000000604482015290519081900360640190fd5b5190511490565b60008184841115612f365760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612efb578181015183820152602001612ee3565b50505050905090810190601f168015612f285780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008183612f8d5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612efb578181015183820152602001612ee3565b506000838581612f9957fe5b0495945050505050565b606080825160020260020167ffffffffffffffff81118015612fc457600080fd5b506040519080825280601f01601f191660200182016040528015612fef576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061302057fe5b60200101906001600160f81b031916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061306557fe5b60200101906001600160f81b031916908160001a905350600260005b8451811015613148576000600486838151811061309a57fe5b602001015160f81c60f81b60f81c60ff16901c60ff16905060008683815181106130c057fe5b60209101015160f81c600f169050600a8204602702826030010160f81b8585806001019650815181106130ef57fe5b60200101906001600160f81b031916908160001a905350600a8104602702816030010160f81b85858060010196508151811061312757fe5b60200101906001600160f81b031916908160001a9053505050600101613081565b50909392505050565b6040518060200160405280600081525090565b60408051606081018252600080825260208201819052918101919091529056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212203055b0d734dca8615198a959a7d99698303ce19e8493d5730b98cd12bd00115a64736f6c634300060c0033

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

0000000000000000000000005e89f8d81c74e311458277ea1be3d3247c7cd7d1000000000000000000000000cb06df7f0be5b8bb261d294cf87c794eb9da85b1000000000000000000000000a0446d8804611944f1b527ecd37d7dcbe442caba

-----Decoded View---------------
Arg [0] : _poolOwner (address): 0x5E89f8d81C74E311458277EA1Be3d3247c7cd7D1
Arg [1] : _mooniswapDeployer (address): 0xCB06dF7F0Be5B8Bb261d294Cf87C794EB9Da85b1
Arg [2] : _governanceMothership (address): 0xA0446D8804611944F1B527eCD37d7dcbE442caba

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000005e89f8d81c74e311458277ea1be3d3247c7cd7d1
Arg [1] : 000000000000000000000000cb06df7f0be5b8bb261d294cf87c794eb9da85b1
Arg [2] : 000000000000000000000000a0446d8804611944f1b527ecd37d7dcbe442caba


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.