ETH Price: $3,288.86 (+1.45%)
Gas: 1 Gwei

Token

Farming: 1inch Liquidity Pool (ETH-1INCH) (farm-1LP-ETH-1INCH)
 

Overview

Max Total Supply

18,596.694557043669764186 farm-1LP-ETH-1INCH

Holders

48

Market

Onchain Market Cap

$0.00

Circulating Supply Market Cap

-

Other Info

Token Contract (WITH 18 Decimals)

Balance
47.740927483034622857 farm-1LP-ETH-1INCH

Value
$0.00
0x7026b36cBA78bd76621D2F0559D2a57dBa71F741
Loading...
Loading
Loading...
Loading
Loading...
Loading

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

Contract Source Code Verified (Exact Match)

Contract Name:
FarmingRewards

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 25 : FarmingRewards.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

import "../../Mooniswap.sol";
import "../../libraries/MooniswapConstants.sol";
import "../../libraries/Voting.sol";
import "../../libraries/UniERC20.sol";
import "../../utils/BaseRewards.sol";


contract FarmingRewards is BaseRewards {
    using Vote for Vote.Data;
    using Voting for Voting.Data;
    using UniERC20 for IERC20;

    event Staked(address indexed user, uint256 amount);
    event Withdrawn(address indexed user, uint256 amount);
    event FeeVoteUpdate(address indexed user, uint256 fee, bool isDefault, uint256 amount);

    event Transfer(address indexed from, address indexed to, uint256 value);
    event SlippageFeeVoteUpdate(address indexed user, uint256 slippageFee, bool isDefault, uint256 amount);
    event DecayPeriodVoteUpdate(address indexed user, uint256 decayPeriod, bool isDefault, uint256 amount);

    Mooniswap public immutable mooniswap;
    IMooniswapFactoryGovernance public immutable mooniswapFactoryGovernance;
    Voting.Data private _fee;
    Voting.Data private _slippageFee;
    Voting.Data private _decayPeriod;

    constructor(Mooniswap _mooniswap, IERC20 _gift, uint256 _duration, address _rewardDistribution) public {
        mooniswap = _mooniswap;
        mooniswapFactoryGovernance = _mooniswap.mooniswapFactoryGovernance();
        addGift(_gift, _duration, _rewardDistribution);
    }

    function name() external view returns(string memory) {
        return string(abi.encodePacked("Farming: ", mooniswap.name()));
    }

    function symbol() external view returns(string memory) {
        return string(abi.encodePacked("farm-", mooniswap.symbol()));
    }

    function decimals() external view returns(uint8) {
        return mooniswap.decimals();
    }

    function stake(uint256 amount) public updateReward(msg.sender) {
        require(amount > 0, "Cannot stake 0");
        mooniswap.transferFrom(msg.sender, address(this), amount);
        _mint(msg.sender, amount);
        emit Staked(msg.sender, amount);
        emit Transfer(address(0), msg.sender, amount);
    }

    function withdraw(uint256 amount) public updateReward(msg.sender) {
        require(amount > 0, "Cannot withdraw 0");
        _burn(msg.sender, amount);
        mooniswap.transfer(msg.sender, amount);
        emit Withdrawn(msg.sender, amount);
        emit Transfer(msg.sender, address(0), amount);
    }

    function exit() external {
        withdraw(balanceOf(msg.sender));
        getAllRewards();
    }

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

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

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

    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);
        _vote(_fee, mooniswap.feeVote, mooniswap.discardFeeVote);
    }

    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);
        _vote(_slippageFee, mooniswap.slippageFeeVote, mooniswap.discardSlippageFeeVote);
    }

    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);
        _vote(_decayPeriod, mooniswap.decayPeriodVote, mooniswap.discardDecayPeriodVote);
    }

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

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

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

    function _mint(address account, uint256 amount) internal override {
        super._mint(account, amount);

        uint256 newBalance = balanceOf(account);
        _updateVotes(account, newBalance.sub(amount), newBalance, totalSupply());
    }

    function _burn(address account, uint256 amount) internal override {
        super._burn(account, amount);

        uint256 newBalance = balanceOf(account);
        _updateVotes(account, newBalance.add(amount), newBalance, totalSupply());
    }

    function _updateVotes(address account, uint256 balance, uint256 newBalance, uint256 newTotalSupply) private {
        _fee.updateBalance(account, _fee.votes[account], balance, newBalance, newTotalSupply, mooniswapFactoryGovernance.defaultFee(), _emitFeeVoteUpdate);
        _vote(_fee, mooniswap.feeVote, mooniswap.discardFeeVote);
        _slippageFee.updateBalance(account, _slippageFee.votes[account], balance, newBalance, newTotalSupply, mooniswapFactoryGovernance.defaultSlippageFee(), _emitSlippageFeeVoteUpdate);
        _vote(_slippageFee, mooniswap.slippageFeeVote, mooniswap.discardSlippageFeeVote);
        _decayPeriod.updateBalance(account, _decayPeriod.votes[account], balance, newBalance, newTotalSupply, mooniswapFactoryGovernance.defaultDecayPeriod(), _emitDecayPeriodVoteUpdate);
        _vote(_decayPeriod, mooniswap.decayPeriodVote, mooniswap.discardDecayPeriodVote);
    }

    function _vote(Voting.Data storage votingData, function(uint256) external vote, function() external discardVote) private {
        if (votingData._weightedSum == 0) {
            discardVote();
        } else {
            vote(votingData.result);
        }
    }

    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 rescueFunds(IERC20 token, uint256 amount) external onlyOwner {
        for (uint i = 0; i < tokenRewards.length; i++) {
            require(token != tokenRewards[i].gift, "Can't rescue gift");
        }

        token.uniTransfer(msg.sender, amount);
        if (token == mooniswap) {
            require(token.uniBalanceOf(address(this)) == totalSupply(), "Can't withdraw staked tokens");
        }
    }
}

File 2 of 25 : 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 25 : 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 4 of 25 : Voting.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

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


library Voting {
    using SafeMath for uint256;
    using Vote for Vote.Data;

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

    function updateVote(
        Voting.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(
        Voting.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(
        Voting.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);

        if (newResult != self.result) {
            self.result = newResult;
        }

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

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

File 5 of 25 : 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 6 of 25 : BaseRewards.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./BalanceAccounting.sol";


contract BaseRewards is Ownable, BalanceAccounting {
    using SafeERC20 for IERC20;

    event RewardAdded(uint256 indexed i, uint256 reward);
    event RewardPaid(uint256 indexed i, address indexed user, uint256 reward);
    event DurationUpdated(uint256 indexed i, uint256 duration);
    event RewardDistributionChanged(uint256 indexed i, address rewardDistribution);
    event NewGift(uint256 indexed i, IERC20 gift);

    struct TokenRewards {
        IERC20 gift;
        uint256 duration;
        address rewardDistribution;

        uint256 periodFinish;
        uint256 rewardRate;
        uint256 lastUpdateTime;
        uint256 rewardPerTokenStored;
        mapping(address => uint256) userRewardPerTokenPaid;
        mapping(address => uint256) rewards;
    }

    TokenRewards[] public tokenRewards;

    modifier updateReward(address account) {
        uint256 len = tokenRewards.length;
        for (uint i = 0; i < len; i++) {
            TokenRewards storage tr = tokenRewards[i];
            tr.rewardPerTokenStored = rewardPerToken(i);
            tr.lastUpdateTime = lastTimeRewardApplicable(i);
            if (account != address(0)) {
                tr.rewards[account] = earned(i, account);
                tr.userRewardPerTokenPaid[account] = tr.rewardPerTokenStored;
            }
        }
        _;
    }

    modifier onlyRewardDistribution(uint i) {
        require(msg.sender == tokenRewards[i].rewardDistribution, "Access denied");
        _;
    }

    function lastTimeRewardApplicable(uint i) public view returns (uint256) {
        return Math.min(block.timestamp, tokenRewards[i].periodFinish);
    }

    function rewardPerToken(uint i) public view returns (uint256) {
        TokenRewards storage tr = tokenRewards[i];
        if (totalSupply() == 0) {
            return tr.rewardPerTokenStored;
        }
        return tr.rewardPerTokenStored.add(
            lastTimeRewardApplicable(i)
                .sub(tr.lastUpdateTime)
                .mul(tr.rewardRate)
                .mul(1e18)
                .div(totalSupply())
        );
    }

    function earned(uint i, address account) public view returns (uint256) {
        TokenRewards storage tr = tokenRewards[i];
        return balanceOf(account)
            .mul(rewardPerToken(i).sub(tr.userRewardPerTokenPaid[account]))
            .div(1e18)
            .add(tr.rewards[account]);
    }

    function getReward(uint i) public updateReward(msg.sender) {
        TokenRewards storage tr = tokenRewards[i];
        uint256 reward = tr.rewards[msg.sender];
        if (reward > 0) {
            tr.rewards[msg.sender] = 0;
            tr.gift.safeTransfer(msg.sender, reward);
            emit RewardPaid(i, msg.sender, reward);
        }
    }

    function getAllRewards() public {
        uint256 len = tokenRewards.length;
        for (uint i = 0; i < len; i++) {
            getReward(i);
        }
    }

    function notifyRewardAmount(uint i, uint256 reward) external onlyRewardDistribution(i) updateReward(address(0)) {
        require(reward < uint(-1).div(1e18), "Reward overlow");

        TokenRewards storage tr = tokenRewards[i];
        uint256 duration = tr.duration;

        if (block.timestamp >= tr.periodFinish) {
            require(reward >= duration, "Reward is too small");
            tr.rewardRate = reward.div(duration);
        } else {
            uint256 remaining = tr.periodFinish.sub(block.timestamp);
            uint256 leftover = remaining.mul(tr.rewardRate);
            require(reward.add(leftover) >= duration, "Reward is too small");
            tr.rewardRate = reward.add(leftover).div(duration);
        }

        uint balance = tr.gift.balanceOf(address(this));
        require(tr.rewardRate <= balance.div(duration), "Reward is too big");

        tr.lastUpdateTime = block.timestamp;
        tr.periodFinish = block.timestamp.add(duration);
        emit RewardAdded(i, reward);
    }

    function setRewardDistribution(uint i, address _rewardDistribution) external onlyOwner {
        TokenRewards storage tr = tokenRewards[i];
        tr.rewardDistribution = _rewardDistribution;
        emit RewardDistributionChanged(i, _rewardDistribution);
    }

    function setDuration(uint i, uint256 _duration) external onlyRewardDistribution(i) {
        TokenRewards storage tr = tokenRewards[i];
        require(block.timestamp >= tr.periodFinish, "Not finished yet");
        tr.duration = _duration;
        emit DurationUpdated(i, _duration);
    }

    function addGift(IERC20 gift, uint256 duration, address rewardDistribution) public onlyOwner {
        uint256 len = tokenRewards.length;
        for (uint i = 0; i < len; i++) {
            require(gift != tokenRewards[i].gift, "Gift is already added");
        }

        TokenRewards storage tr = tokenRewards.push();
        tr.gift = gift;
        tr.duration = duration;
        tr.rewardDistribution = rewardDistribution;

        emit NewGift(len, gift);
        emit DurationUpdated(len, duration);
        emit RewardDistributionChanged(len, rewardDistribution);
    }
}

File 7 of 25 : Math.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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 8 of 25 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @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) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @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) {
        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, reverting 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) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * 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);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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 9 of 25 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";

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

    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 virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual 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 virtual returns (uint8) {
        return _decimals;
    }

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

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

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `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 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 virtual {
        _decimals = decimals_;
    }

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

File 10 of 25 : 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 11 of 25 : 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 12 of 25 : 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 13 of 25 : 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 14 of 25 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with 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 15 of 25 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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 16 of 25 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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 17 of 25 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

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

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

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

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

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 18 of 25 : 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 19 of 25 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../utils/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.
 */
abstract 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 virtual 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 20 of 25 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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].
 */
abstract 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;
    }
}

File 21 of 25 : 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 virtualDefaultFee() external view returns(uint104, uint104, uint48);
    function virtualDefaultSlippageFee() external view returns(uint104, uint104, uint48);
    function virtualDefaultDecayPeriod() external view returns(uint104, uint104, uint48);

    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 22 of 25 : 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 23 of 25 : 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 24 of 25 : 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 25 of 25 : 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);
        }
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract Mooniswap","name":"_mooniswap","type":"address"},{"internalType":"contract IERC20","name":"_gift","type":"address"},{"internalType":"uint256","name":"_duration","type":"uint256"},{"internalType":"address","name":"_rewardDistribution","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":"DecayPeriodVoteUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"i","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"DurationUpdated","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":"FeeVoteUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"i","type":"uint256"},{"indexed":false,"internalType":"contract IERC20","name":"gift","type":"address"}],"name":"NewGift","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"i","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"i","type":"uint256"},{"indexed":false,"internalType":"address","name":"rewardDistribution","type":"address"}],"name":"RewardDistributionChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"i","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","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":"SlippageFeeVoteUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[{"internalType":"contract IERC20","name":"gift","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"address","name":"rewardDistribution","type":"address"}],"name":"addGift","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decayPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vote","type":"uint256"}],"name":"decayPeriodVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"decayPeriodVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"discardDecayPeriodVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"discardFeeVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"discardSlippageFeeVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vote","type":"uint256"}],"name":"feeVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"feeVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"}],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mooniswap","outputs":[{"internalType":"contract Mooniswap","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mooniswapFactoryGovernance","outputs":[{"internalType":"contract IMooniswapFactoryGovernance","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"}],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"name":"setDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"address","name":"_rewardDistribution","type":"address"}],"name":"setRewardDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slippageFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"vote","type":"uint256"}],"name":"slippageFeeVote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"slippageFeeVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenRewards","outputs":[{"internalType":"contract IERC20","name":"gift","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"address","name":"rewardDistribution","type":"address"},{"internalType":"uint256","name":"periodFinish","type":"uint256"},{"internalType":"uint256","name":"rewardRate","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"},{"internalType":"uint256","name":"rewardPerTokenStored","type":"uint256"}],"stateMutability":"view","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":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c06040523480156200001157600080fd5b50604051620039be380380620039be833981810160405260808110156200003757600080fd5b508051602082015160408301516060909301519192909160006200005a62000150565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350836001600160a01b03166080816001600160a01b031660601b81525050836001600160a01b031663d9a0c2176040518163ffffffff1660e01b815260040160206040518083038186803b158015620000fb57600080fd5b505afa15801562000110573d6000803e3d6000fd5b505050506040513d60208110156200012757600080fd5b505160601b6001600160601b03191660a0526200014683838362000154565b50505050620003d0565b3390565b6200015e62000150565b6001600160a01b031662000171620003c1565b6001600160a01b031614620001cd576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60035460005b81811015620002655760038181548110620001ea57fe5b60009182526020909120600990910201546001600160a01b03868116911614156200025c576040805162461bcd60e51b815260206004820152601560248201527f4769667420697320616c72656164792061646465640000000000000000000000604482015290519081900360640190fd5b600101620001d3565b50600380546001810182556000919091526009027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b810180546001600160a01b038088166001600160a01b0319928316811784557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85c85018890557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d9094018054918716919092161790556040805192835251909183917f64cc71b17412354fc7654b3a032c59b8aacbcc955fa02aecfec3be41d7350f249181900360200190a260408051858152905183917ff899c6d536e6cda78c5f4dce43ca0e8c47167deb2875ea8b777f21cc85899b1f919081900360200190a2604080516001600160a01b0385168152905183917f68898541a3500520160dc4a025aaabdb318ec2d614c236a5fb88f523d76a8d8a919081900360200190a25050505050565b6000546001600160a01b031690565b60805160601c60a05160601c61354c620004726000398061091e5280610ae65280611739528061189b5280611a96528061208952806123365280612e4a5280612f62528061307a5250806106aa52806109c05280610b88528061122952806113125280611338528061142a5280611664528061183b52806118c95280611bfb52806123d8528061258e5280612eec5280613004528061311c525061354c6000f3fe608060405234801561001057600080fd5b506004361061025c5760003560e01c8063874c120b11610145578063d9a0c217116100bd578063e9fad8ee1161008c578063eeca156211610071578063eeca15621461065b578063f2fde38b14610678578063f76d13b41461069e5761025c565b8063e9fad8ee14610636578063eaadf8481461063e5761025c565b8063d9a0c217146105ce578063ddca3f43146105d6578063e2b01a5e146105de578063e39c08fc1461060a5761025c565b806395d89b4111610114578063a694fc3a116100f9578063a694fc3a14610558578063a93a085714610575578063cd7ea095146105ab5761025c565b806395d89b411461052a5780639aad141b146105325761025c565b8063874c120b146104d75780638da5cb5b146104f457806393028d83146104fc57806395cad3c7146105045761025c565b8063313ce567116101d85780636669302a116101a7578063715018a61161018c578063715018a61461047d57806378e3214f146104855780637e82a6f3146104b15761025c565b80636669302a1461044f57806370a08231146104575761025c565b8063313ce567146104195780633732b3941461043757806345b35f561461043f57806348d67e1b146104475761025c565b806318160ddd1161022f578063246132f911610214578063246132f9146103b55780632e1a7d4d146103d8578063303bfdae146103f55761025c565b806318160ddd1461037e5780631c4b774b146103985761025c565b806306fdde031461026157806307a80070146102de57806310eee734146102fd57806311212d6614610361575b600080fd5b6102696106a6565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102a357818101518382015260200161028b565b50505050905090810190601f1680156102d05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102fb600480360360208110156102f457600080fd5b5035610881565b005b61031a6004803603602081101561031357600080fd5b50356109f3565b604080516001600160a01b039889168152602081019790975294909616858501526060850192909252608084015260a083015260c082019290925290519081900360e00190f35b6102fb6004803603602081101561037757600080fd5b5035610a4a565b610386610bb8565b60408051918252519081900360200190f35b6102fb600480360360208110156103ae57600080fd5b5035610bbe565b6102fb600480360360408110156103cb57600080fd5b5080359060200135610cff565b6102fb600480360360208110156103ee57600080fd5b5035611103565b6103fd611310565b604080516001600160a01b039092168252519081900360200190f35b610421611334565b6040805160ff9092168252519081900360200190f35b6103866113c0565b6102fb6113c6565b6103866113e9565b6102fb6113ef565b6103866004803603602081101561046d57600080fd5b50356001600160a01b031661145c565b6102fb61147b565b6102fb6004803603604081101561049b57600080fd5b506001600160a01b038135169060200135611546565b610386600480360360208110156104c757600080fd5b50356001600160a01b0316611709565b610386600480360360208110156104ed57600080fd5b5035611769565b6103fd6117f1565b6102fb611800565b6103866004803603602081101561051a57600080fd5b50356001600160a01b031661186b565b6102696118c5565b6103866004803603602081101561054857600080fd5b50356001600160a01b0316611a66565b6102fb6004803603602081101561056e57600080fd5b5035611ac0565b6102fb6004803603606081101561058b57600080fd5b506001600160a01b03813581169160208101359160409091013516611ced565b6102fb600480360360408110156105c157600080fd5b5080359060200135611f5e565b6103fd612087565b6103866120ab565b6102fb600480360360408110156105f457600080fd5b50803590602001356001600160a01b03166120b1565b6103866004803603604081101561062057600080fd5b50803590602001356001600160a01b03166121ae565b6102fb612230565b6102fb6004803603602081101561065457600080fd5b5035612249565b6103866004803603602081101561067157600080fd5b5035612408565b6102fb6004803603602081101561068e57600080fd5b50356001600160a01b0316612432565b6102fb612553565b60607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b15801561070157600080fd5b505afa158015610715573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561073e57600080fd5b810190808051604051939291908464010000000082111561075e57600080fd5b90830190602082018581111561077357600080fd5b825164010000000081118282018810171561078d57600080fd5b82525081516020918201929091019080838360005b838110156107ba5781810151838201526020016107a2565b50505050905090810190601f1680156107e75780820380516001836020036101000a031916815260200191505b5060405250505060405160200180807f4661726d696e673a20000000000000000000000000000000000000000000000081525060090182805190602001908083835b602083106108485780518252601f199092019160209182019101610829565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052905090565b670de0b6b3a76400008111156108de576040805162461bcd60e51b815260206004820152601d60248201527f536c6970706167652066656520766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b336000818152600b60209081526040918290208251918201909252905481526109b1919061090b846125be565b6109143361145c565b61091c610bb8565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166323662bb96040518163ffffffff1660e01b815260040160206040518083038186803b15801561097557600080fd5b505afa158015610989573d6000803e3d6000fd5b505050506040513d602081101561099f57600080fd5b505160089594939291906125dd612630565b6109f060086001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166307a8007081636669302a61264b565b50565b60038181548110610a0057fe5b600091825260209091206009909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b03958616975093959490921693909287565b662386f26fc10000811115610aa6576040805162461bcd60e51b815260206004820152601460248201527f46656520766f746520697320746f6f2068696768000000000000000000000000604482015290519081900360640190fd5b33600081815260076020908152604091829020825191820190925290548152610b799190610ad3846125be565b610adc3361145c565b610ae4610bb8565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635a6c72d06040518163ffffffff1660e01b815260040160206040518083038186803b158015610b3d57600080fd5b505afa158015610b51573d6000803e3d6000fd5b505050506040513d6020811015610b6757600080fd5b505160049594939291906126fb612630565b6109f060046001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166311212d66816393028d8361264b565b60015490565b600354339060005b81811015610c5d57600060038281548110610bdd57fe5b90600052602060002090600902019050610bf682611769565b6006820155610c0482612408565b60058201556001600160a01b03841615610c5457610c2282856121ae565b6001600160a01b0385166000908152600883016020908152604080832093909355600684015460078501909152919020555b50600101610bc6565b50600060038481548110610c6d57fe5b60009182526020808320338452600860099093020191820190526040909120549091508015610cf8573360008181526008840160205260408120558254610cc0916001600160a01b03909116908361274e565b604080518281529051339187917f04492fab062412e7e4e5f46c9e919f1640652946a5e163ad6e6c1c03d87954d29181900360200190a35b5050505050565b8160038181548110610d0d57fe5b60009182526020909120600990910201600201546001600160a01b03163314610d6d576040805162461bcd60e51b815260206004820152600d60248201526c1058d8d95cdcc819195b9a5959609a1b604482015290519081900360640190fd5b600354600090815b81811015610e0c57600060038281548110610d8c57fe5b90600052602060002090600902019050610da582611769565b6006820155610db382612408565b60058201556001600160a01b03841615610e0357610dd182856121ae565b6001600160a01b0385166000908152600883016020908152604080832093909355600684015460078501909152919020555b50600101610d75565b50610e21600019670de0b6b3a76400006127ba565b8410610e74576040805162461bcd60e51b815260206004820152600e60248201527f526577617264206f7665726c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b600060038681548110610e8357fe5b9060005260206000209060090201905060008160010154905081600301544210610f105780861015610efc576040805162461bcd60e51b815260206004820152601360248201527f52657761726420697320746f6f20736d616c6c00000000000000000000000000604482015290519081900360640190fd5b610f0686826127ba565b6004830155610fb9565b6003820154600090610f229042612821565b90506000610f3d84600401548361287e90919063ffffffff16565b905082610f4a89836128d7565b1015610f9d576040805162461bcd60e51b815260206004820152601360248201527f52657761726420697320746f6f20736d616c6c00000000000000000000000000604482015290519081900360640190fd5b610fb183610fab8a846128d7565b906127ba565b600485015550505b8154604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561101c57600080fd5b505afa158015611030573d6000803e3d6000fd5b505050506040513d602081101561104657600080fd5b5051905061105481836127ba565b836004015411156110ac576040805162461bcd60e51b815260206004820152601160248201527f52657761726420697320746f6f20626967000000000000000000000000000000604482015290519081900360640190fd5b42600584018190556110be90836128d7565b600384015560408051888152905189917f6c07ee05dcf262f13abf9d87b846ee789d2f90fe991d495acd7d7fc109ee1f55919081900360200190a25050505050505050565b600354339060005b818110156111a25760006003828154811061112257fe5b9060005260206000209060090201905061113b82611769565b600682015561114982612408565b60058201556001600160a01b038416156111995761116782856121ae565b6001600160a01b0385166000908152600883016020908152604080832093909355600684015460078501909152919020555b5060010161110b565b50600083116111f8576040805162461bcd60e51b815260206004820152601160248201527f43616e6e6f742077697468647261772030000000000000000000000000000000604482015290519081900360640190fd5b6112023384612931565b6040805163a9059cbb60e01b81523360048201526024810185905290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163a9059cbb9160448083019260209291908290030181600087803b15801561127157600080fd5b505af1158015611285573d6000803e3d6000fd5b505050506040513d602081101561129b57600080fd5b505060408051848152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a260408051848152905160009133917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561138f57600080fd5b505afa1580156113a3573d6000803e3d6000fd5b505050506040513d60208110156113b957600080fd5b5051905090565b60085490565b60035460005b818110156113e5576113dd81610bbe565b6001016113cc565b5050565b600c5490565b336000818152600b602090815260409182902082519182019092529054815261141b919061090b612964565b61145a60086001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166307a8007081636669302a61264b565b565b6001600160a01b0381166000908152600260205260409020545b919050565b61148361297f565b6001600160a01b03166114946117f1565b6001600160a01b0316146114ef576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b61154e61297f565b6001600160a01b031661155f6117f1565b6001600160a01b0316146115ba576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60005b60035481101561164d57600381815481106115d457fe5b60009182526020909120600990910201546001600160a01b0384811691161415611645576040805162461bcd60e51b815260206004820152601160248201527f43616e2774207265736375652067696674000000000000000000000000000000604482015290519081900360640190fd5b6001016115bd565b506116626001600160a01b0383163383612983565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156113e5576116a4610bb8565b6116b76001600160a01b038416306129e7565b146113e5576040805162461bcd60e51b815260206004820152601c60248201527f43616e2774207769746864726177207374616b656420746f6b656e7300000000604482015290519081900360640190fd5b6001600160a01b038181166000908152600f602090815260408083208151928301909152548152909161176391907f000000000000000000000000000000000000000000000000000000000000000016631845f0db612a88565b92915050565b6000806003838154811061177957fe5b90600052602060002090600902019050611791610bb8565b6117a057600601549050611476565b6117ea6117df6117ae610bb8565b610fab670de0b6b3a76400006117d986600401546117d988600501546117d38c612408565b90612821565b9061287e565b6006830154906128d7565b9392505050565b6000546001600160a01b031690565b3360008181526007602090815260409182902082519182019092529054815261182c9190610ad3612964565b61145a60046001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166311212d66816393028d8361264b565b6001600160a01b038181166000908152600b602090815260408083208151928301909152548152909161176391907f0000000000000000000000000000000000000000000000000000000000000000166323662bb9612a88565b60607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561192057600080fd5b505afa158015611934573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561195d57600080fd5b810190808051604051939291908464010000000082111561197d57600080fd5b90830190602082018581111561199257600080fd5b82516401000000008111828201881017156119ac57600080fd5b82525081516020918201929091019080838360005b838110156119d95781810151838201526020016119c1565b50505050905090810190601f168015611a065780820380516001836020036101000a031916815260200191505b5060405250505060405160200180807f6661726d2d0000000000000000000000000000000000000000000000000000008152506005018280519060200190808383602083106108485780518252601f199092019160209182019101610829565b6001600160a01b0381811660009081526007602090815260408083208151928301909152548152909161176391907f000000000000000000000000000000000000000000000000000000000000000016635a6c72d0612a88565b600354339060005b81811015611b5f57600060038281548110611adf57fe5b90600052602060002090600902019050611af882611769565b6006820155611b0682612408565b60058201556001600160a01b03841615611b5657611b2482856121ae565b6001600160a01b0385166000908152600883016020908152604080832093909355600684015460078501909152919020555b50600101611ac8565b5060008311611bb5576040805162461bcd60e51b815260206004820152600e60248201527f43616e6e6f74207374616b652030000000000000000000000000000000000000604482015290519081900360640190fd5b604080517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810185905290516001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916323b872dd9160648083019260209291908290030181600087803b158015611c4357600080fd5b505af1158015611c57573d6000803e3d6000fd5b505050506040513d6020811015611c6d57600080fd5b50611c7a90503384612afe565b60408051848152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a260408051848152905133916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3505050565b611cf561297f565b6001600160a01b0316611d066117f1565b6001600160a01b031614611d61576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60035460005b81811015611df55760038181548110611d7c57fe5b60009182526020909120600990910201546001600160a01b0386811691161415611ded576040805162461bcd60e51b815260206004820152601560248201527f4769667420697320616c72656164792061646465640000000000000000000000604482015290519081900360640190fd5b600101611d67565b50600380546001810182556000919091526009027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b810180546001600160a01b0380881673ffffffffffffffffffffffffffffffffffffffff19928316811784557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85c85018890557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d9094018054918716919092161790556040805192835251909183917f64cc71b17412354fc7654b3a032c59b8aacbcc955fa02aecfec3be41d7350f249181900360200190a260408051858152905183917ff899c6d536e6cda78c5f4dce43ca0e8c47167deb2875ea8b777f21cc85899b1f919081900360200190a2604080516001600160a01b0385168152905183917f68898541a3500520160dc4a025aaabdb318ec2d614c236a5fb88f523d76a8d8a919081900360200190a25050505050565b8160038181548110611f6c57fe5b60009182526020909120600990910201600201546001600160a01b03163314611fcc576040805162461bcd60e51b815260206004820152600d60248201526c1058d8d95cdcc819195b9a5959609a1b604482015290519081900360640190fd5b600060038481548110611fdb57fe5b906000526020600020906009020190508060030154421015612044576040805162461bcd60e51b815260206004820152601060248201527f4e6f742066696e69736865642079657400000000000000000000000000000000604482015290519081900360640190fd5b6001810183905560408051848152905185917ff899c6d536e6cda78c5f4dce43ca0e8c47167deb2875ea8b777f21cc85899b1f919081900360200190a250505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60045490565b6120b961297f565b6001600160a01b03166120ca6117f1565b6001600160a01b031614612125576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60006003838154811061213457fe5b60009182526020918290206009919091020160028101805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038616908117909155604080519182525191935085927f68898541a3500520160dc4a025aaabdb318ec2d614c236a5fb88f523d76a8d8a92918290030190a2505050565b600080600384815481106121be57fe5b600091825260208083206001600160a01b0387168452600860099093020191820181526040808420546007840190925290922054909250612228919061222290670de0b6b3a764000090610fab90612219906117d38b611769565b6117d98961145c565b906128d7565b949350505050565b61224161223c3361145c565b611103565b61145a6113c6565b61012c8111156122a0576040805162461bcd60e51b815260206004820152601d60248201527f446563617920706572696f6420766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b603c8110156122f6576040805162461bcd60e51b815260206004820152601c60248201527f446563617920706572696f6420766f746520697320746f6f206c6f7700000000604482015290519081900360640190fd5b336000818152600f60209081526040918290208251918201909252905481526123c99190612323846125be565b61232c3361145c565b612334610bb8565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631845f0db6040518163ffffffff1660e01b815260040160206040518083038186803b15801561238d57600080fd5b505afa1580156123a1573d6000803e3d6000fd5b505050506040513d60208110156123b757600080fd5b5051600c959493929190612b23612630565b6109f0600c6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663eaadf8488163f76d13b461264b565b6000611763426003848154811061241b57fe5b906000526020600020906009020160030154612b76565b61243a61297f565b6001600160a01b031661244b6117f1565b6001600160a01b0316146124a6576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166124eb5760405162461bcd60e51b81526004018080602001828103825260268152602001806134806026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b336000818152600f602090815260409182902082519182019092529054815261257f9190612323612964565b61145a600c6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663eaadf8488163f76d13b461264b565b6125c661346c565b506040805160208101909152600182018152919050565b60408051848152831515602082015280820183905290516001600160a01b038616917fce0cf859d853e1944032294143a1bf3ad799998ae77acbeb6c4d9b20d6910240919081900360600190a250505050565b612641888888888889898989612b8c565b5050505050505050565b600185015461269f5781816040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561268257600080fd5b505af1158015612696573d6000803e3d6000fd5b50505050610cf8565b838386600001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156126dc57600080fd5b505af11580156126f0573d6000803e3d6000fd5b505050505050505050565b60408051848152831515602082015280820183905290516001600160a01b038616917fe117cae46817b894b41a4412b73ae0ba746a5707b94e02d83b4c6502010b11ac919081900360600190a250505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b1790526127b5908490612ccb565b505050565b6000808211612810576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161281957fe5b049392505050565b600082821115612878576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261288d57506000611763565b8282028284828161289a57fe5b04146117ea5760405162461bcd60e51b81526004018080602001828103825260218152602001806134cc6021913960400191505060405180910390fd5b6000828201838110156117ea576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b61293b8282612d7c565b60006129468361145c565b90506127b58361295683856128d7565b8361295f610bb8565b612e04565b61296c61346c565b5060408051602081019091526000815290565b3390565b80156127b55761299283613152565b156129d3576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156129cd573d6000803e3d6000fd5b506127b5565b6127b56001600160a01b038416838361274e565b60006129f283613152565b15612a0857506001600160a01b03811631611763565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612a5557600080fd5b505afa158015612a69573d6000803e3d6000fd5b505050506040513d6020811015612a7f57600080fd5b50519050611763565b825160009015612a9e57508251600019016117ea565b82826040518163ffffffff1660e01b815260040160206040518083038186803b158015612aca57600080fd5b505afa158015612ade573d6000803e3d6000fd5b505050506040513d6020811015612af457600080fd5b5051949350505050565b612b08828261315f565b6000612b138361145c565b90506127b5836129568385612821565b60408051848152831515602082015280820183905290516001600160a01b038616917fd0784d105a7412ffec29813ff8401f04f3d1cdbe6aca756974b1a31f830e5cb7919081900360600190a250505050565b6000818310612b8557816117ea565b5090919050565b600189015460028a0154819080612ba28b6131b2565b15612bb857612bb1818a612821565b9050612bd9565b612bd6612bcf612bc88d896131b7565b8b9061287e565b8490612821565b92505b612be28a6131b2565b15612bf857612bf181896128d7565b9050612c19565b612c16612c0f612c088c896131b7565b8a9061287e565b84906128d7565b92505b838314612c285760018d018390555b818114612c375760028d018190555b60008715612c5c57612c5788610fab612c50858b61287e565b87906128d7565b612c5e565b865b8e549091508114612c6d57808e555b612c778b8d6131d3565b612c9a576001600160a01b038d16600090815260038f01602052604090208b5190555b612cbb8d612ca88d8a6131b7565b612cb18e6131b2565b8c8a63ffffffff16565b5050505050505050505050505050565b6060612d20826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131da9092919063ffffffff16565b8051909150156127b557808060200190516020811015612d3f57600080fd5b50516127b55760405162461bcd60e51b815260040180806020018281038252602a8152602001806134ed602a913960400191505060405180910390fd5b604080518082018252601b81527f4275726e20616d6f756e7420657863656564732062616c616e636500000000006020808301919091526001600160a01b038516600090815260029091529190912054612dd79183906131e9565b6001600160a01b038316600090815260026020526040902055600154612dfd9082612821565b6001555050565b612edd8460046003016000876001600160a01b03166001600160a01b031681526020019081526020016000206040518060200160405290816000820154815250508585857f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635a6c72d06040518163ffffffff1660e01b815260040160206040518083038186803b158015612ea157600080fd5b505afa158015612eb5573d6000803e3d6000fd5b505050506040513d6020811015612ecb57600080fd5b505160049594939291906126fb613280565b612f1c60046001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166311212d66816393028d8361264b565b612ff58460086003016000876001600160a01b03166001600160a01b031681526020019081526020016000206040518060200160405290816000820154815250508585857f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166323662bb96040518163ffffffff1660e01b815260040160206040518083038186803b158015612fb957600080fd5b505afa158015612fcd573d6000803e3d6000fd5b505050506040513d6020811015612fe357600080fd5b505160089594939291906125dd613280565b61303460086001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166307a8007081636669302a61264b565b61310d84600c6003016000876001600160a01b03166001600160a01b031681526020019081526020016000206040518060200160405290816000820154815250508585857f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631845f0db6040518163ffffffff1660e01b815260040160206040518083038186803b1580156130d157600080fd5b505afa1580156130e5573d6000803e3d6000fd5b505050506040513d60208110156130fb57600080fd5b5051600c959493929190612b23613280565b61314c600c6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663eaadf8488163f76d13b461264b565b50505050565b6001600160a01b03161590565b60015461316c90826128d7565b6001556001600160a01b03821660009081526002602052604090205461319290826128d7565b6001600160a01b0390921660009081526002602052604090209190915550565b511590565b8151600090156131cd5750815160001901611763565b50919050565b5190511490565b606061222884846000856132a4565b600081848411156132785760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561323d578181015183820152602001613225565b50505050905090810190601f16801561326a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6126418888888715613292578961329a565b61329a612964565b8989898989612b8c565b6060824710156132e55760405162461bcd60e51b81526004018080602001828103825260268152602001806134a66026913960400191505060405180910390fd5b6132ee85613400565b61333f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061337e5780518252601f19909201916020918201910161335f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146133e0576040519150601f19603f3d011682016040523d82523d6000602084013e6133e5565b606091505b50915091506133f5828286613406565b979650505050505050565b3b151590565b606083156134155750816117ea565b8251156134255782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561323d578181015183820152602001613225565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220d555af1510d56317149f1f9033129c1bd364b4d77ca35c1b4107e5f8239b4f8d64736f6c634300060c00330000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210000000000000000000000000111111111117dc0aa78b770fa6a738034120c302000000000000000000000000000000000000000000000000000000000024ea000000000000000000000000005e89f8d81c74e311458277ea1be3d3247c7cd7d1

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061025c5760003560e01c8063874c120b11610145578063d9a0c217116100bd578063e9fad8ee1161008c578063eeca156211610071578063eeca15621461065b578063f2fde38b14610678578063f76d13b41461069e5761025c565b8063e9fad8ee14610636578063eaadf8481461063e5761025c565b8063d9a0c217146105ce578063ddca3f43146105d6578063e2b01a5e146105de578063e39c08fc1461060a5761025c565b806395d89b4111610114578063a694fc3a116100f9578063a694fc3a14610558578063a93a085714610575578063cd7ea095146105ab5761025c565b806395d89b411461052a5780639aad141b146105325761025c565b8063874c120b146104d75780638da5cb5b146104f457806393028d83146104fc57806395cad3c7146105045761025c565b8063313ce567116101d85780636669302a116101a7578063715018a61161018c578063715018a61461047d57806378e3214f146104855780637e82a6f3146104b15761025c565b80636669302a1461044f57806370a08231146104575761025c565b8063313ce567146104195780633732b3941461043757806345b35f561461043f57806348d67e1b146104475761025c565b806318160ddd1161022f578063246132f911610214578063246132f9146103b55780632e1a7d4d146103d8578063303bfdae146103f55761025c565b806318160ddd1461037e5780631c4b774b146103985761025c565b806306fdde031461026157806307a80070146102de57806310eee734146102fd57806311212d6614610361575b600080fd5b6102696106a6565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102a357818101518382015260200161028b565b50505050905090810190601f1680156102d05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102fb600480360360208110156102f457600080fd5b5035610881565b005b61031a6004803603602081101561031357600080fd5b50356109f3565b604080516001600160a01b039889168152602081019790975294909616858501526060850192909252608084015260a083015260c082019290925290519081900360e00190f35b6102fb6004803603602081101561037757600080fd5b5035610a4a565b610386610bb8565b60408051918252519081900360200190f35b6102fb600480360360208110156103ae57600080fd5b5035610bbe565b6102fb600480360360408110156103cb57600080fd5b5080359060200135610cff565b6102fb600480360360208110156103ee57600080fd5b5035611103565b6103fd611310565b604080516001600160a01b039092168252519081900360200190f35b610421611334565b6040805160ff9092168252519081900360200190f35b6103866113c0565b6102fb6113c6565b6103866113e9565b6102fb6113ef565b6103866004803603602081101561046d57600080fd5b50356001600160a01b031661145c565b6102fb61147b565b6102fb6004803603604081101561049b57600080fd5b506001600160a01b038135169060200135611546565b610386600480360360208110156104c757600080fd5b50356001600160a01b0316611709565b610386600480360360208110156104ed57600080fd5b5035611769565b6103fd6117f1565b6102fb611800565b6103866004803603602081101561051a57600080fd5b50356001600160a01b031661186b565b6102696118c5565b6103866004803603602081101561054857600080fd5b50356001600160a01b0316611a66565b6102fb6004803603602081101561056e57600080fd5b5035611ac0565b6102fb6004803603606081101561058b57600080fd5b506001600160a01b03813581169160208101359160409091013516611ced565b6102fb600480360360408110156105c157600080fd5b5080359060200135611f5e565b6103fd612087565b6103866120ab565b6102fb600480360360408110156105f457600080fd5b50803590602001356001600160a01b03166120b1565b6103866004803603604081101561062057600080fd5b50803590602001356001600160a01b03166121ae565b6102fb612230565b6102fb6004803603602081101561065457600080fd5b5035612249565b6103866004803603602081101561067157600080fd5b5035612408565b6102fb6004803603602081101561068e57600080fd5b50356001600160a01b0316612432565b6102fb612553565b60607f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f2106001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b15801561070157600080fd5b505afa158015610715573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561073e57600080fd5b810190808051604051939291908464010000000082111561075e57600080fd5b90830190602082018581111561077357600080fd5b825164010000000081118282018810171561078d57600080fd5b82525081516020918201929091019080838360005b838110156107ba5781810151838201526020016107a2565b50505050905090810190601f1680156107e75780820380516001836020036101000a031916815260200191505b5060405250505060405160200180807f4661726d696e673a20000000000000000000000000000000000000000000000081525060090182805190602001908083835b602083106108485780518252601f199092019160209182019101610829565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052905090565b670de0b6b3a76400008111156108de576040805162461bcd60e51b815260206004820152601d60248201527f536c6970706167652066656520766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b336000818152600b60209081526040918290208251918201909252905481526109b1919061090b846125be565b6109143361145c565b61091c610bb8565b7f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96436001600160a01b03166323662bb96040518163ffffffff1660e01b815260040160206040518083038186803b15801561097557600080fd5b505afa158015610989573d6000803e3d6000fd5b505050506040513d602081101561099f57600080fd5b505160089594939291906125dd612630565b6109f060086001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210166307a8007081636669302a61264b565b50565b60038181548110610a0057fe5b600091825260209091206009909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b03958616975093959490921693909287565b662386f26fc10000811115610aa6576040805162461bcd60e51b815260206004820152601460248201527f46656520766f746520697320746f6f2068696768000000000000000000000000604482015290519081900360640190fd5b33600081815260076020908152604091829020825191820190925290548152610b799190610ad3846125be565b610adc3361145c565b610ae4610bb8565b7f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96436001600160a01b0316635a6c72d06040518163ffffffff1660e01b815260040160206040518083038186803b158015610b3d57600080fd5b505afa158015610b51573d6000803e3d6000fd5b505050506040513d6020811015610b6757600080fd5b505160049594939291906126fb612630565b6109f060046001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210166311212d66816393028d8361264b565b60015490565b600354339060005b81811015610c5d57600060038281548110610bdd57fe5b90600052602060002090600902019050610bf682611769565b6006820155610c0482612408565b60058201556001600160a01b03841615610c5457610c2282856121ae565b6001600160a01b0385166000908152600883016020908152604080832093909355600684015460078501909152919020555b50600101610bc6565b50600060038481548110610c6d57fe5b60009182526020808320338452600860099093020191820190526040909120549091508015610cf8573360008181526008840160205260408120558254610cc0916001600160a01b03909116908361274e565b604080518281529051339187917f04492fab062412e7e4e5f46c9e919f1640652946a5e163ad6e6c1c03d87954d29181900360200190a35b5050505050565b8160038181548110610d0d57fe5b60009182526020909120600990910201600201546001600160a01b03163314610d6d576040805162461bcd60e51b815260206004820152600d60248201526c1058d8d95cdcc819195b9a5959609a1b604482015290519081900360640190fd5b600354600090815b81811015610e0c57600060038281548110610d8c57fe5b90600052602060002090600902019050610da582611769565b6006820155610db382612408565b60058201556001600160a01b03841615610e0357610dd182856121ae565b6001600160a01b0385166000908152600883016020908152604080832093909355600684015460078501909152919020555b50600101610d75565b50610e21600019670de0b6b3a76400006127ba565b8410610e74576040805162461bcd60e51b815260206004820152600e60248201527f526577617264206f7665726c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b600060038681548110610e8357fe5b9060005260206000209060090201905060008160010154905081600301544210610f105780861015610efc576040805162461bcd60e51b815260206004820152601360248201527f52657761726420697320746f6f20736d616c6c00000000000000000000000000604482015290519081900360640190fd5b610f0686826127ba565b6004830155610fb9565b6003820154600090610f229042612821565b90506000610f3d84600401548361287e90919063ffffffff16565b905082610f4a89836128d7565b1015610f9d576040805162461bcd60e51b815260206004820152601360248201527f52657761726420697320746f6f20736d616c6c00000000000000000000000000604482015290519081900360640190fd5b610fb183610fab8a846128d7565b906127ba565b600485015550505b8154604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561101c57600080fd5b505afa158015611030573d6000803e3d6000fd5b505050506040513d602081101561104657600080fd5b5051905061105481836127ba565b836004015411156110ac576040805162461bcd60e51b815260206004820152601160248201527f52657761726420697320746f6f20626967000000000000000000000000000000604482015290519081900360640190fd5b42600584018190556110be90836128d7565b600384015560408051888152905189917f6c07ee05dcf262f13abf9d87b846ee789d2f90fe991d495acd7d7fc109ee1f55919081900360200190a25050505050505050565b600354339060005b818110156111a25760006003828154811061112257fe5b9060005260206000209060090201905061113b82611769565b600682015561114982612408565b60058201556001600160a01b038416156111995761116782856121ae565b6001600160a01b0385166000908152600883016020908152604080832093909355600684015460078501909152919020555b5060010161110b565b50600083116111f8576040805162461bcd60e51b815260206004820152601160248201527f43616e6e6f742077697468647261772030000000000000000000000000000000604482015290519081900360640190fd5b6112023384612931565b6040805163a9059cbb60e01b81523360048201526024810185905290516001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210169163a9059cbb9160448083019260209291908290030181600087803b15801561127157600080fd5b505af1158015611285573d6000803e3d6000fd5b505050506040513d602081101561129b57600080fd5b505060408051848152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a260408051848152905160009133917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3505050565b7f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f21081565b60007f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f2106001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561138f57600080fd5b505afa1580156113a3573d6000803e3d6000fd5b505050506040513d60208110156113b957600080fd5b5051905090565b60085490565b60035460005b818110156113e5576113dd81610bbe565b6001016113cc565b5050565b600c5490565b336000818152600b602090815260409182902082519182019092529054815261141b919061090b612964565b61145a60086001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210166307a8007081636669302a61264b565b565b6001600160a01b0381166000908152600260205260409020545b919050565b61148361297f565b6001600160a01b03166114946117f1565b6001600160a01b0316146114ef576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b61154e61297f565b6001600160a01b031661155f6117f1565b6001600160a01b0316146115ba576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60005b60035481101561164d57600381815481106115d457fe5b60009182526020909120600990910201546001600160a01b0384811691161415611645576040805162461bcd60e51b815260206004820152601160248201527f43616e2774207265736375652067696674000000000000000000000000000000604482015290519081900360640190fd5b6001016115bd565b506116626001600160a01b0383163383612983565b7f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f2106001600160a01b0316826001600160a01b031614156113e5576116a4610bb8565b6116b76001600160a01b038416306129e7565b146113e5576040805162461bcd60e51b815260206004820152601c60248201527f43616e2774207769746864726177207374616b656420746f6b656e7300000000604482015290519081900360640190fd5b6001600160a01b038181166000908152600f602090815260408083208151928301909152548152909161176391907f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a964316631845f0db612a88565b92915050565b6000806003838154811061177957fe5b90600052602060002090600902019050611791610bb8565b6117a057600601549050611476565b6117ea6117df6117ae610bb8565b610fab670de0b6b3a76400006117d986600401546117d988600501546117d38c612408565b90612821565b9061287e565b6006830154906128d7565b9392505050565b6000546001600160a01b031690565b3360008181526007602090815260409182902082519182019092529054815261182c9190610ad3612964565b61145a60046001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210166311212d66816393028d8361264b565b6001600160a01b038181166000908152600b602090815260408083208151928301909152548152909161176391907f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a9643166323662bb9612a88565b60607f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f2106001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561192057600080fd5b505afa158015611934573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561195d57600080fd5b810190808051604051939291908464010000000082111561197d57600080fd5b90830190602082018581111561199257600080fd5b82516401000000008111828201881017156119ac57600080fd5b82525081516020918201929091019080838360005b838110156119d95781810151838201526020016119c1565b50505050905090810190601f168015611a065780820380516001836020036101000a031916815260200191505b5060405250505060405160200180807f6661726d2d0000000000000000000000000000000000000000000000000000008152506005018280519060200190808383602083106108485780518252601f199092019160209182019101610829565b6001600160a01b0381811660009081526007602090815260408083208151928301909152548152909161176391907f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a964316635a6c72d0612a88565b600354339060005b81811015611b5f57600060038281548110611adf57fe5b90600052602060002090600902019050611af882611769565b6006820155611b0682612408565b60058201556001600160a01b03841615611b5657611b2482856121ae565b6001600160a01b0385166000908152600883016020908152604080832093909355600684015460078501909152919020555b50600101611ac8565b5060008311611bb5576040805162461bcd60e51b815260206004820152600e60248201527f43616e6e6f74207374616b652030000000000000000000000000000000000000604482015290519081900360640190fd5b604080517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810185905290516001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f21016916323b872dd9160648083019260209291908290030181600087803b158015611c4357600080fd5b505af1158015611c57573d6000803e3d6000fd5b505050506040513d6020811015611c6d57600080fd5b50611c7a90503384612afe565b60408051848152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a260408051848152905133916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3505050565b611cf561297f565b6001600160a01b0316611d066117f1565b6001600160a01b031614611d61576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60035460005b81811015611df55760038181548110611d7c57fe5b60009182526020909120600990910201546001600160a01b0386811691161415611ded576040805162461bcd60e51b815260206004820152601560248201527f4769667420697320616c72656164792061646465640000000000000000000000604482015290519081900360640190fd5b600101611d67565b50600380546001810182556000919091526009027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b810180546001600160a01b0380881673ffffffffffffffffffffffffffffffffffffffff19928316811784557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85c85018890557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d9094018054918716919092161790556040805192835251909183917f64cc71b17412354fc7654b3a032c59b8aacbcc955fa02aecfec3be41d7350f249181900360200190a260408051858152905183917ff899c6d536e6cda78c5f4dce43ca0e8c47167deb2875ea8b777f21cc85899b1f919081900360200190a2604080516001600160a01b0385168152905183917f68898541a3500520160dc4a025aaabdb318ec2d614c236a5fb88f523d76a8d8a919081900360200190a25050505050565b8160038181548110611f6c57fe5b60009182526020909120600990910201600201546001600160a01b03163314611fcc576040805162461bcd60e51b815260206004820152600d60248201526c1058d8d95cdcc819195b9a5959609a1b604482015290519081900360640190fd5b600060038481548110611fdb57fe5b906000526020600020906009020190508060030154421015612044576040805162461bcd60e51b815260206004820152601060248201527f4e6f742066696e69736865642079657400000000000000000000000000000000604482015290519081900360640190fd5b6001810183905560408051848152905185917ff899c6d536e6cda78c5f4dce43ca0e8c47167deb2875ea8b777f21cc85899b1f919081900360200190a250505050565b7f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a964381565b60045490565b6120b961297f565b6001600160a01b03166120ca6117f1565b6001600160a01b031614612125576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60006003838154811061213457fe5b60009182526020918290206009919091020160028101805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038616908117909155604080519182525191935085927f68898541a3500520160dc4a025aaabdb318ec2d614c236a5fb88f523d76a8d8a92918290030190a2505050565b600080600384815481106121be57fe5b600091825260208083206001600160a01b0387168452600860099093020191820181526040808420546007840190925290922054909250612228919061222290670de0b6b3a764000090610fab90612219906117d38b611769565b6117d98961145c565b906128d7565b949350505050565b61224161223c3361145c565b611103565b61145a6113c6565b61012c8111156122a0576040805162461bcd60e51b815260206004820152601d60248201527f446563617920706572696f6420766f746520697320746f6f2068696768000000604482015290519081900360640190fd5b603c8110156122f6576040805162461bcd60e51b815260206004820152601c60248201527f446563617920706572696f6420766f746520697320746f6f206c6f7700000000604482015290519081900360640190fd5b336000818152600f60209081526040918290208251918201909252905481526123c99190612323846125be565b61232c3361145c565b612334610bb8565b7f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96436001600160a01b0316631845f0db6040518163ffffffff1660e01b815260040160206040518083038186803b15801561238d57600080fd5b505afa1580156123a1573d6000803e3d6000fd5b505050506040513d60208110156123b757600080fd5b5051600c959493929190612b23612630565b6109f0600c6001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f2101663eaadf8488163f76d13b461264b565b6000611763426003848154811061241b57fe5b906000526020600020906009020160030154612b76565b61243a61297f565b6001600160a01b031661244b6117f1565b6001600160a01b0316146124a6576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166124eb5760405162461bcd60e51b81526004018080602001828103825260268152602001806134806026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b336000818152600f602090815260409182902082519182019092529054815261257f9190612323612964565b61145a600c6001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f2101663eaadf8488163f76d13b461264b565b6125c661346c565b506040805160208101909152600182018152919050565b60408051848152831515602082015280820183905290516001600160a01b038616917fce0cf859d853e1944032294143a1bf3ad799998ae77acbeb6c4d9b20d6910240919081900360600190a250505050565b612641888888888889898989612b8c565b5050505050505050565b600185015461269f5781816040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561268257600080fd5b505af1158015612696573d6000803e3d6000fd5b50505050610cf8565b838386600001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156126dc57600080fd5b505af11580156126f0573d6000803e3d6000fd5b505050505050505050565b60408051848152831515602082015280820183905290516001600160a01b038616917fe117cae46817b894b41a4412b73ae0ba746a5707b94e02d83b4c6502010b11ac919081900360600190a250505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b1790526127b5908490612ccb565b505050565b6000808211612810576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161281957fe5b049392505050565b600082821115612878576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261288d57506000611763565b8282028284828161289a57fe5b04146117ea5760405162461bcd60e51b81526004018080602001828103825260218152602001806134cc6021913960400191505060405180910390fd5b6000828201838110156117ea576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b61293b8282612d7c565b60006129468361145c565b90506127b58361295683856128d7565b8361295f610bb8565b612e04565b61296c61346c565b5060408051602081019091526000815290565b3390565b80156127b55761299283613152565b156129d3576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156129cd573d6000803e3d6000fd5b506127b5565b6127b56001600160a01b038416838361274e565b60006129f283613152565b15612a0857506001600160a01b03811631611763565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612a5557600080fd5b505afa158015612a69573d6000803e3d6000fd5b505050506040513d6020811015612a7f57600080fd5b50519050611763565b825160009015612a9e57508251600019016117ea565b82826040518163ffffffff1660e01b815260040160206040518083038186803b158015612aca57600080fd5b505afa158015612ade573d6000803e3d6000fd5b505050506040513d6020811015612af457600080fd5b5051949350505050565b612b08828261315f565b6000612b138361145c565b90506127b5836129568385612821565b60408051848152831515602082015280820183905290516001600160a01b038616917fd0784d105a7412ffec29813ff8401f04f3d1cdbe6aca756974b1a31f830e5cb7919081900360600190a250505050565b6000818310612b8557816117ea565b5090919050565b600189015460028a0154819080612ba28b6131b2565b15612bb857612bb1818a612821565b9050612bd9565b612bd6612bcf612bc88d896131b7565b8b9061287e565b8490612821565b92505b612be28a6131b2565b15612bf857612bf181896128d7565b9050612c19565b612c16612c0f612c088c896131b7565b8a9061287e565b84906128d7565b92505b838314612c285760018d018390555b818114612c375760028d018190555b60008715612c5c57612c5788610fab612c50858b61287e565b87906128d7565b612c5e565b865b8e549091508114612c6d57808e555b612c778b8d6131d3565b612c9a576001600160a01b038d16600090815260038f01602052604090208b5190555b612cbb8d612ca88d8a6131b7565b612cb18e6131b2565b8c8a63ffffffff16565b5050505050505050505050505050565b6060612d20826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131da9092919063ffffffff16565b8051909150156127b557808060200190516020811015612d3f57600080fd5b50516127b55760405162461bcd60e51b815260040180806020018281038252602a8152602001806134ed602a913960400191505060405180910390fd5b604080518082018252601b81527f4275726e20616d6f756e7420657863656564732062616c616e636500000000006020808301919091526001600160a01b038516600090815260029091529190912054612dd79183906131e9565b6001600160a01b038316600090815260026020526040902055600154612dfd9082612821565b6001555050565b612edd8460046003016000876001600160a01b03166001600160a01b031681526020019081526020016000206040518060200160405290816000820154815250508585857f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96436001600160a01b0316635a6c72d06040518163ffffffff1660e01b815260040160206040518083038186803b158015612ea157600080fd5b505afa158015612eb5573d6000803e3d6000fd5b505050506040513d6020811015612ecb57600080fd5b505160049594939291906126fb613280565b612f1c60046001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210166311212d66816393028d8361264b565b612ff58460086003016000876001600160a01b03166001600160a01b031681526020019081526020016000206040518060200160405290816000820154815250508585857f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96436001600160a01b03166323662bb96040518163ffffffff1660e01b815260040160206040518083038186803b158015612fb957600080fd5b505afa158015612fcd573d6000803e3d6000fd5b505050506040513d6020811015612fe357600080fd5b505160089594939291906125dd613280565b61303460086001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210166307a8007081636669302a61264b565b61310d84600c6003016000876001600160a01b03166001600160a01b031681526020019081526020016000206040518060200160405290816000820154815250508585857f000000000000000000000000baf9a5d4b0052359326a6cdab54babaa3a3a96436001600160a01b0316631845f0db6040518163ffffffff1660e01b815260040160206040518083038186803b1580156130d157600080fd5b505afa1580156130e5573d6000803e3d6000fd5b505050506040513d60208110156130fb57600080fd5b5051600c959493929190612b23613280565b61314c600c6001600160a01b037f0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f2101663eaadf8488163f76d13b461264b565b50505050565b6001600160a01b03161590565b60015461316c90826128d7565b6001556001600160a01b03821660009081526002602052604090205461319290826128d7565b6001600160a01b0390921660009081526002602052604090209190915550565b511590565b8151600090156131cd5750815160001901611763565b50919050565b5190511490565b606061222884846000856132a4565b600081848411156132785760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561323d578181015183820152602001613225565b50505050905090810190601f16801561326a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6126418888888715613292578961329a565b61329a612964565b8989898989612b8c565b6060824710156132e55760405162461bcd60e51b81526004018080602001828103825260268152602001806134a66026913960400191505060405180910390fd5b6132ee85613400565b61333f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061337e5780518252601f19909201916020918201910161335f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146133e0576040519150601f19603f3d011682016040523d82523d6000602084013e6133e5565b606091505b50915091506133f5828286613406565b979650505050505050565b3b151590565b606083156134155750816117ea565b8251156134255782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561323d578181015183820152602001613225565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220d555af1510d56317149f1f9033129c1bd364b4d77ca35c1b4107e5f8239b4f8d64736f6c634300060c0033

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

0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210000000000000000000000000111111111117dc0aa78b770fa6a738034120c302000000000000000000000000000000000000000000000000000000000024ea000000000000000000000000005e89f8d81c74e311458277ea1be3d3247c7cd7d1

-----Decoded View---------------
Arg [0] : _mooniswap (address): 0x0EF1B8a0E726Fc3948E15b23993015eB1627f210
Arg [1] : _gift (address): 0x111111111117dC0aa78b770fA6A738034120C302
Arg [2] : _duration (uint256): 2419200
Arg [3] : _rewardDistribution (address): 0x5E89f8d81C74E311458277EA1Be3d3247c7cd7D1

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000000ef1b8a0e726fc3948e15b23993015eb1627f210
Arg [1] : 000000000000000000000000111111111117dc0aa78b770fa6a738034120c302
Arg [2] : 000000000000000000000000000000000000000000000000000000000024ea00
Arg [3] : 0000000000000000000000005e89f8d81c74e311458277ea1be3d3247c7cd7d1


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.