ETH Price: $2,290.52 (-6.27%)

Contract

0xDd34467a9Fb2E0c273Dff0d90fb11e601B68A1D6
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Emergency Withdr...193327292024-02-29 10:59:23368 days ago1709204363IN
0xDd34467a...01B68A1D6
0 ETH0.0037880276.97514246
Withdraw138036402021-12-14 13:47:561175 days ago1639489676IN
0xDd34467a...01B68A1D6
0 ETH0.0076815698.82364028
Deposit137832772021-12-11 10:18:271178 days ago1639217907IN
0xDd34467a...01B68A1D6
0 ETH0.0041815942.98824619
Withdraw134092492021-10-13 9:36:001237 days ago1634117760IN
0xDd34467a...01B68A1D6
0 ETH0.0084616567.29535824
Withdraw134023732021-10-12 7:41:571238 days ago1634024517IN
0xDd34467a...01B68A1D6
0 ETH0.0019649874.57517485
Withdraw134023732021-10-12 7:41:571238 days ago1634024517IN
0xDd34467a...01B68A1D6
0 ETH0.0019649874.57517485
Withdraw134023732021-10-12 7:41:571238 days ago1634024517IN
0xDd34467a...01B68A1D6
0 ETH0.0057949374.57517485
Deposit133475172021-10-03 17:14:201246 days ago1633281260IN
0xDd34467a...01B68A1D6
0 ETH0.01262591110.3924294
Withdraw132651572021-09-20 21:45:491259 days ago1632174349IN
0xDd34467a...01B68A1D6
0 ETH0.0053904269.34806833
Withdraw132373672021-09-16 14:41:211264 days ago1631803281IN
0xDd34467a...01B68A1D6
0 ETH0.0075514360.06218834
Withdraw132081702021-09-12 2:12:241268 days ago1631412744IN
0xDd34467a...01B68A1D6
0 ETH0.0054461644.01758444
Withdraw131939262021-09-09 21:10:201270 days ago1631221820IN
0xDd34467a...01B68A1D6
0 ETH0.0083469466.40211272
Withdraw131390282021-09-01 9:43:021279 days ago1630489382IN
0xDd34467a...01B68A1D6
0 ETH0.0101026580.35389303
Withdraw131068832021-08-27 10:10:561284 days ago1630059056IN
0xDd34467a...01B68A1D6
0 ETH0.0057541174.02698363
Withdraw130946852021-08-25 12:58:191286 days ago1629896299IN
0xDd34467a...01B68A1D6
0 ETH0.009806778
Withdraw130884742021-08-24 14:06:451287 days ago1629814005IN
0xDd34467a...01B68A1D6
0 ETH0.0096688789
Withdraw130802522021-08-23 7:37:061288 days ago1629704226IN
0xDd34467a...01B68A1D6
0 ETH0.0031087240
Deposit130801202021-08-23 7:06:541288 days ago1629702414IN
0xDd34467a...01B68A1D6
0 ETH0.0017830436.78664734
Deposit130801122021-08-23 7:05:041288 days ago1629702304IN
0xDd34467a...01B68A1D6
0 ETH0.0044770139.14402026
Withdraw130773612021-08-22 20:43:591288 days ago1629665039IN
0xDd34467a...01B68A1D6
0 ETH0.0049033539
Withdraw130649162021-08-20 22:33:131290 days ago1629498793IN
0xDd34467a...01B68A1D6
0 ETH0.0039457731.38369167
Withdraw130635682021-08-20 17:48:511290 days ago1629481731IN
0xDd34467a...01B68A1D6
0 ETH0.0033973943.70090161
Deposit130635612021-08-20 17:47:181290 days ago1629481638IN
0xDd34467a...01B68A1D6
0 ETH0.0043517544.73757765
Withdraw130622922021-08-20 13:04:091291 days ago1629464649IN
0xDd34467a...01B68A1D6
0 ETH0.0049822639.62766778
Withdraw130621932021-08-20 12:42:041291 days ago1629463324IN
0xDd34467a...01B68A1D6
0 ETH0.0025653633.0035817
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block
From
To
193327292024-02-29 10:59:23368 days ago1709204363
0xDd34467a...01B68A1D6
0 ETH
138036402021-12-14 13:47:561175 days ago1639489676
0xDd34467a...01B68A1D6
0 ETH
138036402021-12-14 13:47:561175 days ago1639489676
0xDd34467a...01B68A1D6
0 ETH
137832772021-12-11 10:18:271178 days ago1639217907
0xDd34467a...01B68A1D6
0 ETH
137832772021-12-11 10:18:271178 days ago1639217907
0xDd34467a...01B68A1D6
0 ETH
137832772021-12-11 10:18:271178 days ago1639217907
0xDd34467a...01B68A1D6
0 ETH
134092492021-10-13 9:36:001237 days ago1634117760
0xDd34467a...01B68A1D6
0 ETH
134092492021-10-13 9:36:001237 days ago1634117760
0xDd34467a...01B68A1D6
0 ETH
134092492021-10-13 9:36:001237 days ago1634117760
0xDd34467a...01B68A1D6
0 ETH
134092492021-10-13 9:36:001237 days ago1634117760
0xDd34467a...01B68A1D6
0 ETH
134023732021-10-12 7:41:571238 days ago1634024517
0xDd34467a...01B68A1D6
0 ETH
134023732021-10-12 7:41:571238 days ago1634024517
0xDd34467a...01B68A1D6
0 ETH
133475172021-10-03 17:14:201246 days ago1633281260
0xDd34467a...01B68A1D6
0 ETH
133475172021-10-03 17:14:201246 days ago1633281260
0xDd34467a...01B68A1D6
0 ETH
133475172021-10-03 17:14:201246 days ago1633281260
0xDd34467a...01B68A1D6
0 ETH
132651572021-09-20 21:45:491259 days ago1632174349
0xDd34467a...01B68A1D6
0 ETH
132651572021-09-20 21:45:491259 days ago1632174349
0xDd34467a...01B68A1D6
0 ETH
132373672021-09-16 14:41:211264 days ago1631803281
0xDd34467a...01B68A1D6
0 ETH
132373672021-09-16 14:41:211264 days ago1631803281
0xDd34467a...01B68A1D6
0 ETH
132373672021-09-16 14:41:211264 days ago1631803281
0xDd34467a...01B68A1D6
0 ETH
132373672021-09-16 14:41:211264 days ago1631803281
0xDd34467a...01B68A1D6
0 ETH
132081702021-09-12 2:12:241268 days ago1631412744
0xDd34467a...01B68A1D6
0 ETH
132081702021-09-12 2:12:241268 days ago1631412744
0xDd34467a...01B68A1D6
0 ETH
132081702021-09-12 2:12:241268 days ago1631412744
0xDd34467a...01B68A1D6
0 ETH
132081702021-09-12 2:12:241268 days ago1631412744
0xDd34467a...01B68A1D6
0 ETH
View All Internal Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x4d8E075b...B10beb9F0
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
LaunchPoolStakingWithGuild

Compiler Version
v0.8.0+commit.c7dfd78e

Optimization Enabled:
Yes with 200 runs

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

pragma solidity 0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import { Guild } from "./Guild.sol";

/// @title Staking contract for farming generic rewards in return for staking a whitelisted token(s)
/// @author BlockRocket.tech
/// @dev Fork of MasterChef.sol from SushiSwap
/// @dev Only the owner can add new pools
contract LaunchPoolStakingWithGuild is Ownable {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    /// @dev Details about each user in a pool
    struct UserInfo {
        uint256 amount;     // How many tokens the user has provided to a pool
        uint256 rewardDebt; // Reward debt. See explanation below.
        //
        // We do some fancy math here. Basically, any point in time, the amount of reward tokens
        // entitled to a user but is pending to be distributed is:
        //
        //   pending reward = (user.amount * pool.accRewardPerShare) - user.rewardDebt
        //
        // Whenever a user deposits or withdraws ERC20 tokens to a pool. Here's what happens:
        //   1. The pool's `accRewardPerShare` (and `lastRewardBlock`) gets updated.
        //   2. User receives the pending reward sent to his/her address.
        //   3. User's `amount` gets updated.
        //   4. User's `rewardDebt` gets updated.
    }

    /// @dev Info of each pool.
    struct PoolInfo {
        IERC20 erc20Token; // Address of token contract.
        uint256 allocPoint; // How many allocation points assigned to this pool; this is a weighting for rewards.
        uint256 lastRewardBlock; // Last block number that reward token distribution has occurred up to endBlock.
        uint256 accRewardPerShare; // Per LP token staked, how much reward token earned in pool that users will get
        uint256 maxStakingAmountPerUser; // Max. amount of tokens that can be staked per account/user
    }

    /// @dev Container for holding all rewards
    Guild public rewardGuildBank;

    /// @dev Number of reward tokens distributed per block, across all pools.
    uint256 public rewardPerBlock;

    /// @dev The total amount of reward token available for farming across all pools between start and end block.
    uint256 public maxRewardTokenAvailableForFarming;

    /// @dev List of pools that users can stake into
    PoolInfo[] public poolInfo;

    /// @dev Per pool, info of each user that stakes ERC20 tokens.
    /// @dev Pool ID => User Address => User Info
    mapping(uint256 => mapping(address => UserInfo)) public userInfo;

    /// @dev Total allocation points. Must be the sum of all allocation points in all pools.
    uint256 public totalAllocPoint;

    /// @dev The block number when rewards starts across all pools.
    uint256 public startBlock;

    /// @dev The block number when rewards ends.
    uint256 public endBlock;

    /// @dev Tracks ERC20 tokens added by owner
    mapping(address => bool) isErc20TokenWhitelisted;

    event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
    event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);

    /// @param _rewardToken Address of the reward token
    /// @param _maxRewardTokenAvailableForFarming Maximum number of reward token that will be distributed between the start and end of farming
    /// @param _startBlock Block number when farming will begin for all pools
    /// @param _endBlock Block number when farming will end for all pools
    constructor(
        IERC20 _rewardToken,
        uint256 _maxRewardTokenAvailableForFarming,
        uint256 _startBlock,
        uint256 _endBlock
    ) public {
        require(address(_rewardToken) != address(0), "constructor: _rewardToken must not be zero address");
        require(_maxRewardTokenAvailableForFarming > 0, "constructor: _maxRewardTokenAvailableForFarming must be greater than zero");

        maxRewardTokenAvailableForFarming = _maxRewardTokenAvailableForFarming;
        startBlock = _startBlock;
        endBlock = _endBlock;

        uint256 numberOfBlocksForFarming = endBlock.sub(startBlock);
        rewardPerBlock = maxRewardTokenAvailableForFarming.div(numberOfBlocksForFarming);

        rewardGuildBank = new Guild(IERC20(address(_rewardToken)), address(this));
    }

    /// @dev Returns the number of pools that have been added by the owner
    /// @return Number of pools
    function numberOfPools() external view returns (uint256) {
        return poolInfo.length;
    }

    /// @dev Create a new reward pool by whitelisting a new ERC20 token.
    /// @dev Can only be called by the contract owner
    /// @param _allocPoint Governs what percentage of the total rewards this pool and other pools will get
    /// @param _erc20Token Address of the staking token being whitelisted
    /// @param _maxStakingAmountPerUser For this pool, maximum amount per user that can be staked
    /// @param _withUpdate Set to true for updating all pools before adding this one
    function add(uint256 _allocPoint, IERC20 _erc20Token, uint256 _maxStakingAmountPerUser, bool _withUpdate) public onlyOwner {
        require(block.number < endBlock, "add: must be before end");
        address erc20TokenAddress = address(_erc20Token);
        require(erc20TokenAddress != address(0), "add: _erc20Token must not be zero address");
        require(isErc20TokenWhitelisted[erc20TokenAddress] == false, "add: already whitelisted");
        require(_maxStakingAmountPerUser > 0, "add: _maxStakingAmountPerUser must be greater than zero");

        if (_withUpdate) {
            massUpdatePools();
        }

        uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
        totalAllocPoint = totalAllocPoint.add(_allocPoint);
        poolInfo.push(PoolInfo({
            erc20Token : _erc20Token,
            allocPoint : _allocPoint,
            lastRewardBlock : lastRewardBlock,
            accRewardPerShare : 0,
            maxStakingAmountPerUser: _maxStakingAmountPerUser
        }));

        isErc20TokenWhitelisted[erc20TokenAddress] = true;
    }

    /// @dev Update a pool's allocation point to increase or decrease its share of contract-level rewards
    /// @dev Can also update the max amount that can be staked per user
    /// @dev Can only be called by the owner
    /// @param _pid ID of the pool being updated
    /// @param _allocPoint New allocation point
    /// @param _maxStakingAmountPerUser Maximum amount that a user can deposit into the far
    /// @param _withUpdate Set to true if you want to update all pools before making this change - it will checkpoint those rewards
    function set(uint256 _pid, uint256 _allocPoint, uint256 _maxStakingAmountPerUser, bool _withUpdate) public onlyOwner {
        require(block.number < endBlock, "set: must be before end");
        require(_pid < poolInfo.length, "set: invalid _pid");
        require(_maxStakingAmountPerUser > 0, "set: _maxStakingAmountPerUser must be greater than zero");

        if (_withUpdate) {
            massUpdatePools();
        }

        totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);

        poolInfo[_pid].allocPoint = _allocPoint;
        poolInfo[_pid].maxStakingAmountPerUser = _maxStakingAmountPerUser;
    }

    /// @dev View function to see pending and unclaimed reward tokens for a given user
    /// @param _pid ID of the pool where a user has a stake
    /// @param _user Account being queried
    /// @return Amount of reward tokens due to a user
    function pendingRewards(uint256 _pid, address _user) external view returns (uint256) {
        require(_pid < poolInfo.length, "pendingRewards: invalid _pid");

        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];

        uint256 accRewardPerShare = pool.accRewardPerShare;
        uint256 lpSupply = pool.erc20Token.balanceOf(address(this));

        if (block.number > pool.lastRewardBlock && lpSupply != 0) {
            uint256 maxEndBlock = block.number <= endBlock ? block.number : endBlock;
            uint256 multiplier = getMultiplier(pool.lastRewardBlock, maxEndBlock);
            uint256 reward = multiplier.mul(rewardPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
            accRewardPerShare = accRewardPerShare.add(reward.mul(1e18).div(lpSupply));
        }

        return user.amount.mul(accRewardPerShare).div(1e18).sub(user.rewardDebt);
    }

    /// @dev Cycles through the pools to update all of the rewards accrued
    function massUpdatePools() public {
        uint256 length = poolInfo.length;
        for (uint256 pid = 0; pid < length; ++pid) {
            updatePool(pid);
        }
    }

    /// @dev Updates a specific pool to track all of the rewards accrued up to the TX block
    /// @param _pid ID of the pool
    function updatePool(uint256 _pid) public {
        require(_pid < poolInfo.length, "updatePool: invalid _pid");

        PoolInfo storage pool = poolInfo[_pid];
        if (block.number <= pool.lastRewardBlock) {
            return;
        }

        uint256 erc20Supply = pool.erc20Token.balanceOf(address(this));
        if (erc20Supply == 0) {
            pool.lastRewardBlock = block.number;
            return;
        }

        uint256 maxEndBlock = block.number <= endBlock ? block.number : endBlock;
        uint256 multiplier = getMultiplier(pool.lastRewardBlock, maxEndBlock);

        // No point in doing any more logic as the rewards have ended
        if (multiplier == 0) {
            return;
        }

        uint256 reward = multiplier.mul(rewardPerBlock).mul(pool.allocPoint).div(totalAllocPoint);

        pool.accRewardPerShare = pool.accRewardPerShare.add(reward.mul(1e18).div(erc20Supply));
        pool.lastRewardBlock = maxEndBlock;
    }

    /// @dev Where any user can stake their ERC20 tokens into a pool in order to farm rewards
    /// @param _pid ID of the pool
    /// @param _amount Amount of ERC20 being staked
    function deposit(uint256 _pid, uint256 _amount) external {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];

        require(user.amount.add(_amount) <= pool.maxStakingAmountPerUser, "deposit: can not exceed max staking amount per user");

        updatePool(_pid);

        if (user.amount > 0) {
            uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e18).sub(user.rewardDebt);
            if (pending > 0) {
                safeRewardTransfer(msg.sender, pending);
            }
        }

        if (_amount > 0) {
            pool.erc20Token.safeTransferFrom(address(msg.sender), address(this), _amount);
            user.amount = user.amount.add(_amount);
        }

        user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e18);
        emit Deposit(msg.sender, _pid, _amount);
    }

    /// @dev Allows a user to withdraw any ERC20 tokens staked in a pool
    /// @dev Partial withdrawals permitted
    /// @param _pid Pool ID
    /// @param _amount Being withdrawn
    function withdraw(uint256 _pid, uint256 _amount) external {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];

        require(user.amount >= _amount, "withdraw: _amount not good");

        updatePool(_pid);

        uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e18).sub(user.rewardDebt);
        if (pending > 0) {
            safeRewardTransfer(msg.sender, pending);
        }

        if (_amount > 0) {
            user.amount = user.amount.sub(_amount);
            pool.erc20Token.safeTransfer(address(msg.sender), _amount);
        }

        user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e18);
        emit Withdraw(msg.sender, _pid, _amount);
    }

    /// @dev Emergency only. Should the rewards issuance mechanism fail, people can still withdraw their stake
    /// @param _pid Pool ID
    function emergencyWithdraw(uint256 _pid) external {
        require(_pid < poolInfo.length, "updatePool: invalid _pid");

        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];

        uint256 amount = user.amount;
        user.amount = 0;
        user.rewardDebt = 0;

        pool.erc20Token.safeTransfer(address(msg.sender), amount);
        emit EmergencyWithdraw(msg.sender, _pid, amount);
    }

    ////////////
    // Private /
    ////////////

    /// @dev Safe reward transfer function, just in case if rounding error causes pool to not have enough rewards.
    /// @param _to Whom to send reward into
    /// @param _amount of reward to send
    function safeRewardTransfer(address _to, uint256 _amount) private {
        uint256 bal = rewardGuildBank.tokenBalance();
        if (_amount > bal) {
            rewardGuildBank.withdrawTo(_to, bal);
        } else {
            rewardGuildBank.withdrawTo(_to, _amount);
        }
    }

    /// @dev Return reward multiplier over the given _from to _to block.
    /// @param _from Block number
    /// @param _to Block number
    /// @return Number of blocks that have passed
    function getMultiplier(uint256 _from, uint256 _to) private view returns (uint256) {
        return _to.sub(_from);
    }
}

File 2 of 9 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^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 3 of 9 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.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 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'
        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) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _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
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 4 of 9 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

File 5 of 9 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
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) {
        unchecked {
            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) {
        unchecked {
            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) {
        unchecked {
            // 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) {
        unchecked {
            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) {
        unchecked {
            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) {
        return a + b;
    }

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

    /**
     * @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.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        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) {
        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) {
        unchecked {
            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.
     *
     * 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) {
        unchecked {
            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) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 6 of 9 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^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() {
        _setOwner(_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 {
        _setOwner(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");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 7 of 9 : Guild.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.0;

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

contract Guild {
    using SafeERC20 for IERC20;

    IERC20 public token;

    address public stakingContract;

    constructor(IERC20 _token, address _stakingContract) public {
        token = _token;
        stakingContract = _stakingContract;
    }

    function withdrawTo(address _recipient, uint256 _amount) external {
        require(msg.sender == stakingContract, "Guild.withdrawTo: Only staking contract");
        token.safeTransfer(_recipient, _amount);
    }

    function tokenBalance() external returns (uint256) {
        return token.balanceOf(address(this));
    }
}

File 8 of 9 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^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;
        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");

        (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");

        (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");

        (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");

        (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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IERC20","name":"_rewardToken","type":"address"},{"internalType":"uint256","name":"_maxRewardTokenAvailableForFarming","type":"uint256"},{"internalType":"uint256","name":"_startBlock","type":"uint256"},{"internalType":"uint256","name":"_endBlock","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"contract IERC20","name":"_erc20Token","type":"address"},{"internalType":"uint256","name":"_maxStakingAmountPerUser","type":"uint256"},{"internalType":"bool","name":"_withUpdate","type":"bool"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"massUpdatePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxRewardTokenAvailableForFarming","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numberOfPools","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"pendingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolInfo","outputs":[{"internalType":"contract IERC20","name":"erc20Token","type":"address"},{"internalType":"uint256","name":"allocPoint","type":"uint256"},{"internalType":"uint256","name":"lastRewardBlock","type":"uint256"},{"internalType":"uint256","name":"accRewardPerShare","type":"uint256"},{"internalType":"uint256","name":"maxStakingAmountPerUser","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardGuildBank","outputs":[{"internalType":"contract Guild","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"uint256","name":"_maxStakingAmountPerUser","type":"uint256"},{"internalType":"bool","name":"_withUpdate","type":"bool"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAllocPoint","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":"_pid","type":"uint256"}],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061012c5760003560e01c80637c57c31e116100ad578063988d7a6011610071578063988d7a601461022f578063ce99ad4214610242578063d18df53c1461024a578063e2bbb1581461025d578063f2fde38b146102705761012c565b80637c57c31e146101d65780638862445a146101de5780638ae39cac146101f15780638da5cb5b146101f957806393f1a40b1461020e5761012c565b806351eb05a6116100f457806351eb05a6146101985780635312ea8e146101ab578063630b5ba1146101be5780636f682a53146101c6578063715018a6146101ce5761012c565b8063083c6323146101315780631526fe271461014f57806317caf6f114610173578063441a3e701461017b57806348cd4cb114610190575b600080fd5b610139610283565b60405161014691906118cf565b60405180910390f35b61016261015d366004611302565b610289565b60405161014695949392919061146d565b6101396102d4565b61018e6101893660046113aa565b6102da565b005b610139610439565b61018e6101a6366004611302565b61043f565b61018e6101b9366004611302565b6105d6565b61018e6106af565b6101396106da565b61018e6106e0565b61013961072b565b61018e6101ec3660046113cb565b610731565b6101396108ab565b6102016108b1565b604051610146919061141c565b61022161021c366004611332565b6108c0565b6040516101469291906118d8565b61018e61023d366004611361565b6108e4565b610201610b31565b610139610258366004611332565b610b40565b61018e61026b3660046113aa565b610cff565b61018e61027e3660046112ca565b610e53565b60085481565b6004818154811061029957600080fd5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b0390931694509092909185565b60065481565b6000600483815481106102fd57634e487b7160e01b600052603260045260246000fd5b60009182526020808320868452600580835260408086203387529093529190932080549290910290920192508311156103515760405162461bcd60e51b815260040161034890611582565b60405180910390fd5b61035a8461043f565b60006103978260010154610391670de0b6b3a764000061038b87600301548760000154610ee090919063ffffffff16565b90610ed4565b90610ec1565b905080156103a9576103a93382610eec565b83156103d35781546103bb9085610ec1565b825582546103d3906001600160a01b03163386611047565b600383015482546103f191670de0b6b3a76400009161038b91610ee0565b6001830155604051859033907ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689061042a9088906118cf565b60405180910390a35050505050565b60075481565b60045481106104605760405162461bcd60e51b81526004016103489061168d565b60006004828154811061048357634e487b7160e01b600052603260045260246000fd5b90600052602060002090600502019050806002015443116104a457506105d3565b80546040516370a0823160e01b81526000916001600160a01b0316906370a08231906104d490309060040161141c565b60206040518083038186803b1580156104ec57600080fd5b505afa158015610500573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610524919061131a565b9050806105385750436002909101556105d3565b600060085443111561054c5760085461054e565b435b9050600061056084600201548361109d565b90508061057057505050506105d3565b600061059b60065461038b876001015461059560025487610ee090919063ffffffff16565b90610ee0565b90506105c16105b68561038b84670de0b6b3a7640000610ee0565b6003870154906110a9565b60038601555050600290920191909155505b50565b60045481106105f75760405162461bcd60e51b81526004016103489061168d565b60006004828154811061061a57634e487b7160e01b600052603260045260246000fd5b60009182526020808320858452600580835260408086203380885294528520805486825560018201969096559302018054909450919291610667916001600160a01b039091169083611047565b83336001600160a01b03167fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae0595836040516106a191906118cf565b60405180910390a350505050565b60045460005b818110156106d6576106c68161043f565b6106cf81611980565b90506106b5565b5050565b60045490565b6106e86110b5565b6001600160a01b03166106f96108b1565b6001600160a01b03161461071f5760405162461bcd60e51b81526004016103489061174e565b61072960006110b9565b565b60035481565b6107396110b5565b6001600160a01b031661074a6108b1565b6001600160a01b0316146107705760405162461bcd60e51b81526004016103489061174e565b60085443106107915760405162461bcd60e51b815260040161034890611656565b60045484106107b25760405162461bcd60e51b81526004016103489061185b565b600082116107d25760405162461bcd60e51b8152600401610348906115ff565b80156107e0576107e06106af565b6108318361082b6004878154811061080857634e487b7160e01b600052603260045260246000fd5b906000526020600020906005020160010154600654610ec190919063ffffffff16565b906110a9565b600681905550826004858154811061085957634e487b7160e01b600052603260045260246000fd5b906000526020600020906005020160010181905550816004858154811061089057634e487b7160e01b600052603260045260246000fd5b90600052602060002090600502016004018190555050505050565b60025481565b6000546001600160a01b031690565b60056020908152600092835260408084209091529082529020805460019091015482565b6108ec6110b5565b6001600160a01b03166108fd6108b1565b6001600160a01b0316146109235760405162461bcd60e51b81526004016103489061174e565b60085443106109445760405162461bcd60e51b8152600401610348906116c4565b826001600160a01b03811661096b5760405162461bcd60e51b815260040161034890611886565b6001600160a01b03811660009081526009602052604090205460ff16156109a45760405162461bcd60e51b81526004016103489061154b565b600083116109c45760405162461bcd60e51b815260040161034890611783565b81156109d2576109d26106af565b600060075443116109e5576007546109e7565b435b6006549091506109f790876110a9565b6006556040805160a0810182526001600160a01b039687168152602080820198895281830193845260006060830181815260808401988952600480546001808201835591845294517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b600590960295860180546001600160a01b031916918d169190911790559a517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c85015594517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d84015593517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e83015595517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19f909101559190941684526009909252509020805460ff19169091179055565b6001546001600160a01b031681565b6004546000908310610b645760405162461bcd60e51b815260040161034890611514565b600060048481548110610b8757634e487b7160e01b600052603260045260246000fd5b60009182526020808320878452600580835260408086206001600160a01b038a811688529452808620949091029091016003810154815492516370a0823160e01b815291965093949291909116906370a0823190610be990309060040161141c565b60206040518083038186803b158015610c0157600080fd5b505afa158015610c15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c39919061131a565b9050836002015443118015610c4d57508015155b15610cc9576000600854431115610c6657600854610c68565b435b90506000610c7a86600201548361109d565b90506000610ca160065461038b896001015461059560025487610ee090919063ffffffff16565b9050610cc3610cbc8561038b84670de0b6b3a7640000610ee0565b86906110a9565b94505050505b610cf48360010154610391670de0b6b3a764000061038b868860000154610ee090919063ffffffff16565b979650505050505050565b600060048381548110610d2257634e487b7160e01b600052603260045260246000fd5b60009182526020808320868452600580835260408086203387529093529190932091029091016004810154825491935090610d5d90856110a9565b1115610d7b5760405162461bcd60e51b8152600401610348906116fb565b610d848461043f565b805415610dd0576000610dbc8260010154610391670de0b6b3a764000061038b87600301548760000154610ee090919063ffffffff16565b90508015610dce57610dce3382610eec565b505b8215610dfc578154610ded906001600160a01b0316333086611109565b8054610df990846110a9565b81555b60038201548154610e1a91670de0b6b3a76400009161038b91610ee0565b6001820155604051849033907f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15906106a19087906118cf565b610e5b6110b5565b6001600160a01b0316610e6c6108b1565b6001600160a01b031614610e925760405162461bcd60e51b81526004016103489061174e565b6001600160a01b038116610eb85760405162461bcd60e51b8152600401610348906114ce565b6105d3816110b9565b6000610ecd828461193d565b9392505050565b6000610ecd82846118fe565b6000610ecd828461191e565b60015460408051639e1a4d1960e01b815290516000926001600160a01b031691639e1a4d1991600480830192602092919082900301818787803b158015610f3257600080fd5b505af1158015610f46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6a919061131a565b905080821115610fdd5760015460405163040b850f60e31b81526001600160a01b039091169063205c287890610fa69086908590600401611454565b600060405180830381600087803b158015610fc057600080fd5b505af1158015610fd4573d6000803e3d6000fd5b50505050611042565b60015460405163040b850f60e31b81526001600160a01b039091169063205c28789061100f9086908690600401611454565b600060405180830381600087803b15801561102957600080fd5b505af115801561103d573d6000803e3d6000fd5b505050505b505050565b6110428363a9059cbb60e01b8484604051602401611066929190611454565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611130565b6000610ecd8284610ec1565b6000610ecd82846118e6565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61112a846323b872dd60e01b85858560405160240161106693929190611430565b50505050565b6000611185826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111bf9092919063ffffffff16565b80519091501561104257808060200190518101906111a391906112e6565b6110425760405162461bcd60e51b815260040161034890611811565b60606111ce84846000856111d6565b949350505050565b6060824710156111f85760405162461bcd60e51b8152600401610348906115b9565b6112018561128b565b61121d5760405162461bcd60e51b8152600401610348906117da565b600080866001600160a01b031685876040516112399190611400565b60006040518083038185875af1925050503d8060008114611276576040519150601f19603f3d011682016040523d82523d6000602084013e61127b565b606091505b5091509150610cf4828286611291565b3b151590565b606083156112a0575081610ecd565b8251156112b05782518084602001fd5b8160405162461bcd60e51b8152600401610348919061149b565b6000602082840312156112db578081fd5b8135610ecd816119b1565b6000602082840312156112f7578081fd5b8151610ecd816119c6565b600060208284031215611313578081fd5b5035919050565b60006020828403121561132b578081fd5b5051919050565b60008060408385031215611344578081fd5b823591506020830135611356816119b1565b809150509250929050565b60008060008060808587031215611376578182fd5b843593506020850135611388816119b1565b925060408501359150606085013561139f816119c6565b939692955090935050565b600080604083850312156113bc578182fd5b50508035926020909101359150565b600080600080608085870312156113e0578384fd5b843593506020850135925060408501359150606085013561139f816119c6565b60008251611412818460208701611954565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b03959095168552602085019390935260408401919091526060830152608082015260a00190565b60006020825282518060208401526114ba816040850160208701611954565b601f01601f19169190910160400192915050565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f70656e64696e67526577617264733a20696e76616c6964205f70696400000000604082015260600190565b60208082526018908201527f6164643a20616c72656164792077686974656c69737465640000000000000000604082015260600190565b6020808252601a908201527f77697468647261773a205f616d6f756e74206e6f7420676f6f64000000000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b60208082526037908201527f7365743a205f6d61785374616b696e67416d6f756e7450657255736572206d7560408201527673742062652067726561746572207468616e207a65726f60481b606082015260800190565b60208082526017908201527f7365743a206d757374206265206265666f726520656e64000000000000000000604082015260600190565b60208082526018908201527f757064617465506f6f6c3a20696e76616c6964205f7069640000000000000000604082015260600190565b60208082526017908201527f6164643a206d757374206265206265666f726520656e64000000000000000000604082015260600190565b60208082526033908201527f6465706f7369743a2063616e206e6f7420657863656564206d6178207374616b60408201527234b7339030b6b7bab73a103832b9103ab9b2b960691b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526037908201527f6164643a205f6d61785374616b696e67416d6f756e7450657255736572206d7560408201527673742062652067726561746572207468616e207a65726f60481b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601190820152701cd95d0e881a5b9d985b1a590817dc1a59607a1b604082015260600190565b60208082526029908201527f6164643a205f6572633230546f6b656e206d757374206e6f74206265207a65726040820152686f206164647265737360b81b606082015260800190565b90815260200190565b918252602082015260400190565b600082198211156118f9576118f961199b565b500190565b60008261191957634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156119385761193861199b565b500290565b60008282101561194f5761194f61199b565b500390565b60005b8381101561196f578181015183820152602001611957565b8381111561112a5750506000910152565b60006000198214156119945761199461199b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b03811681146105d357600080fd5b80151581146105d357600080fdfea264697066735822122074f2dcad2ed8879ddee9ab880761d6a2db079e6be6155fe434987db35b3881b264736f6c63430008000033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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