MATIC Price: $1.00 (-0.63%)
Gas: 64 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Token Holdings

Sponsored

Transaction Hash
Method
Block
From
To
Value
Exit457951932023-08-01 21:51:09239 days ago1690926669IN
0x68D2443D...14385A907
0 MATIC0.0087090280.22019032
Exit425494042023-05-10 21:46:52322 days ago1683755212IN
0x68D2443D...14385A907
0 MATIC0.01587641146.24012711
Exit420810932023-04-29 2:45:29334 days ago1682736329IN
0x68D2443D...14385A907
0 MATIC0.0392087361.15749374
Exit404063202023-03-16 9:22:46378 days ago1678958566IN
0x68D2443D...14385A907
0 MATIC0.0066694261.4331128
Exit393935002023-02-17 12:02:08405 days ago1676635328IN
0x68D2443D...14385A907
0 MATIC0.01846788234.06694705
Get Reward393934782023-02-17 12:01:22405 days ago1676635282IN
0x68D2443D...14385A907
0 MATIC0.0192205207.4617949
Get Reward370165012022-12-19 11:16:03465 days ago1671448563IN
0x68D2443D...14385A907
0 MATIC0.01129798147.96269081
Exit356910062022-11-16 19:48:23497 days ago1668628103IN
0x68D2443D...14385A907
0 MATIC0.0025833632.74221997
Get Reward356909762022-11-16 19:47:23497 days ago1668628043IN
0x68D2443D...14385A907
0 MATIC0.0030364732.77500612
Exit355954282022-11-14 12:08:11500 days ago1668427691IN
0x68D2443D...14385A907
0 MATIC0.0032094435.87419981
Exit355649332022-11-13 18:30:33501 days ago1668364233IN
0x68D2443D...14385A907
0 MATIC0.0024414130.94310607
Get Reward355649092022-11-13 18:29:41501 days ago1668364181IN
0x68D2443D...14385A907
0 MATIC0.0028993831.29529911
Exit355340742022-11-13 0:28:22501 days ago1668299302IN
0x68D2443D...14385A907
0 MATIC0.0026448433.52145538
Get Reward355340402022-11-13 0:27:14501 days ago1668299234IN
0x68D2443D...14385A907
0 MATIC0.0018298239.03801897
Get Reward355340402022-11-13 0:27:14501 days ago1668299234IN
0x68D2443D...14385A907
0 MATIC0.0031605434.11416785
Exit354073322022-11-09 19:22:12504 days ago1668021732IN
0x68D2443D...14385A907
0 MATIC0.06464924606.67057117
Exit353492002022-11-08 9:20:44506 days ago1667899244IN
0x68D2443D...14385A907
0 MATIC0.01867715236.71930192
Get Reward353491492022-11-08 9:18:58506 days ago1667899138IN
0x68D2443D...14385A907
0 MATIC0.02167382239.1040404
Exit353152442022-11-07 13:16:09507 days ago1667826969IN
0x68D2443D...14385A907
0 MATIC0.01905716175.53856788
Exit352474172022-11-05 21:54:33508 days ago1667685273IN
0x68D2443D...14385A907
0 MATIC0.0095907690
Exit348284202022-10-26 15:55:33519 days ago1666799733IN
0x68D2443D...14385A907
0 MATIC0.01697194156.3312082
Exit347052562022-10-23 15:28:24522 days ago1666538904IN
0x68D2443D...14385A907
0 MATIC0.0074434268.56256717
Exit343432262022-10-14 18:02:48531 days ago1665770568IN
0x68D2443D...14385A907
0 MATIC0.02022051186.25429032
Exit336377302022-09-27 17:04:42548 days ago1664298282IN
0x68D2443D...14385A907
0 MATIC0.0091985884.72956592
Exit336188272022-09-27 5:27:31548 days ago1664256451IN
0x68D2443D...14385A907
0 MATIC0.0032569230.00000001
View all transactions

Latest 1 internal transaction

Parent Txn Hash Block From To Value
244938642022-02-03 8:13:45784 days ago1643876025  Contract Creation0 MATIC
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StakingRewards

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity)

/**
 *Submitted for verification at polygonscan.com on 2023-07-24
*/

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.7.6;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
 * the optional functions; to access them see `ERC20Detailed`.
 */
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.
     *
     * > 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
    );
}

/**
 * @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.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be aplied to your functions to restrict their use to
 * the owner.
 */
contract Ownable {
    address private _owner;

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

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

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

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

    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return msg.sender == _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 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 onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(
            newOwner != address(0),
            "Ownable: new owner is the zero address"
        );
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

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

        return c;
    }

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

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

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

        return c;
    }

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

/**
 * @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);
    }
}

/**
 * @dev Optional functions from the ERC20 standard.
 */
abstract contract ERC20Detailed is IERC20 {
    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
     * these values are immutable: they can only be set once during
     * construction.
     */
    constructor(
        string memory name_,
        string memory symbol_,
        uint8 decimals_
    ) {
        _name = name_;
        _symbol = symbol_;
        _decimals = decimals_;
    }

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

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

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

/**
 * @dev Collection of functions related to the address type,
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * This test is non-exhaustive, and there may be false-negatives: during the
     * execution of a contract's constructor, its address will be reported as
     * not containing a contract.
     *
     * > It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies in 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;
    }
}

/**
 * @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 ERC20;` 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)
        );
    }

    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
        );
        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.

        // A Solidity high level call has three parts:
        //  1. The target address is checked to verify it contains contract code
        //  2. The call itself is made, and success asserted
        //  3. The return value is decoded, which in turn checks the size of the returned data.
        // solhint-disable-next-line max-line-length
        require(address(token).isContract(), "SafeERC20: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = address(token).call(data);
        require(success, "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"
            );
        }
    }
}

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier
 * available, which can be aplied 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.
 */
contract ReentrancyGuard {
    /// @dev counter to allow mutex lock with only one SSTORE operation
    uint256 private _guardCounter;

    constructor() {
        // The counter starts at one to prevent changing it from zero to a non-zero
        // value, which is a more expensive operation.
        _guardCounter = 1;
    }

    /**
     * @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() {
        _guardCounter += 1;
        uint256 localCounter = _guardCounter;
        _;
        require(
            localCounter == _guardCounter,
            "ReentrancyGuard: reentrant call"
        );
    }
}

// Inheritance
interface IStakingRewards {
    // Views
    function lastTimeRewardApplicable() external view returns (uint256);

    function rewardPerToken() external view returns (uint256);

    function earned(address account) external view returns (uint256);

    function getRewardForDuration() external view returns (uint256);

    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    // Mutative

    function stake(uint256 amount) external;

    function withdraw(uint256 amount) external;

    function getReward() external;

    function exit() external;
}

abstract contract RewardsDistributionRecipient {
    address public rewardsDistribution;

    function notifyRewardAmount(uint256 reward) external virtual;

    modifier onlyRewardsDistribution() {
        require(
            msg.sender == rewardsDistribution,
            "Caller is not RewardsDistribution contract"
        );
        _;
    }
}

contract StakingRewards is
    IStakingRewards,
    RewardsDistributionRecipient,
    ReentrancyGuard
{
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    /* ========== STATE VARIABLES ========== */

    IERC20 public rewardsToken;
    IERC20 public stakingToken;
    uint256 public periodFinish = 0;
    uint256 public rewardRate = 0;
    uint256 public rewardsDuration;
    uint256 public lastUpdateTime;
    uint256 public rewardPerTokenStored;

    mapping(address => uint256) public userRewardPerTokenPaid;
    mapping(address => uint256) public rewards;

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

    /* ========== CONSTRUCTOR ========== */

    constructor(
        address _rewardsDistribution,
        address _rewardsToken,
        address _stakingToken,
        uint256 _rewardsDuration
    ) {
        rewardsToken = IERC20(_rewardsToken);
        stakingToken = IERC20(_stakingToken);
        rewardsDistribution = _rewardsDistribution;
        rewardsDuration = _rewardsDuration;
    }

    /* ========== VIEWS ========== */

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

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

    function lastTimeRewardApplicable() public view override returns (uint256) {
        return Math.min(block.timestamp, periodFinish);
    }

    function rewardPerToken() public view override returns (uint256) {
        if (_totalSupply == 0) {
            return rewardPerTokenStored;
        }
        return
            rewardPerTokenStored.add(
                lastTimeRewardApplicable()
                    .sub(lastUpdateTime)
                    .mul(rewardRate)
                    .mul(1e18)
                    .div(_totalSupply)
            );
    }

    function earned(address account) public view override returns (uint256) {
        return
            _balances[account]
                .mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
                .div(1e18)
                .add(rewards[account]);
    }

    function getRewardForDuration() external view override returns (uint256) {
        return rewardRate.mul(rewardsDuration);
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    function stakeWithPermit(
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external nonReentrant updateReward(msg.sender) {
        require(amount > 0, "Cannot stake 0");
        _totalSupply = _totalSupply.add(amount);
        _balances[msg.sender] = _balances[msg.sender].add(amount);

        // permit
        IUniswapV2ERC20(address(stakingToken)).permit(
            msg.sender,
            address(this),
            amount,
            deadline,
            v,
            r,
            s
        );

        stakingToken.safeTransferFrom(msg.sender, address(this), amount);
        emit Staked(msg.sender, amount);
    }

    function stake(uint256 amount)
        external
        override
        nonReentrant
        updateReward(msg.sender)
    {
        require(amount > 0, "Cannot stake 0");
        _totalSupply = _totalSupply.add(amount);
        _balances[msg.sender] = _balances[msg.sender].add(amount);
        stakingToken.safeTransferFrom(msg.sender, address(this), amount);
        emit Staked(msg.sender, amount);
    }

    function withdraw(uint256 amount)
        public
        override
        nonReentrant
        updateReward(msg.sender)
    {
        require(amount > 0, "Cannot withdraw 0");
        _totalSupply = _totalSupply.sub(amount);
        _balances[msg.sender] = _balances[msg.sender].sub(amount);
        stakingToken.safeTransfer(msg.sender, amount);
        emit Withdrawn(msg.sender, amount);
    }

    function getReward() public override nonReentrant updateReward(msg.sender) {
        uint256 reward = rewards[msg.sender];
        if (reward > 0) {
            rewards[msg.sender] = 0;
            rewardsToken.safeTransfer(msg.sender, reward);
            emit RewardPaid(msg.sender, reward);
        }
    }

    function exit() external override {
        withdraw(_balances[msg.sender]);
        getReward();
    }

    /* ========== RESTRICTED FUNCTIONS ========== */

    function notifyRewardAmount(uint256 reward)
        external
        override
        onlyRewardsDistribution
        updateReward(address(0))
    {
        if (block.timestamp >= periodFinish) {
            rewardRate = reward.div(rewardsDuration);
        } else {
            uint256 remaining = periodFinish.sub(block.timestamp);
            uint256 leftover = remaining.mul(rewardRate);
            rewardRate = reward.add(leftover).div(rewardsDuration);
        }

        // Ensure the provided reward amount is not more than the balance in the contract.
        // This keeps the reward rate in the right range, preventing overflows due to
        // very high values of rewardRate in the earned and rewardsPerToken functions;
        // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
        uint256 balance = rewardsToken.balanceOf(address(this));
        require(
            rewardRate <= balance.div(rewardsDuration),
            "Provided reward too high"
        );

        lastUpdateTime = block.timestamp;
        periodFinish = block.timestamp.add(rewardsDuration);
        emit RewardAdded(reward);
    }

    /* ========== MODIFIERS ========== */

    modifier updateReward(address account) {
        rewardPerTokenStored = rewardPerToken();
        lastUpdateTime = lastTimeRewardApplicable();
        if (account != address(0)) {
            rewards[account] = earned(account);
            userRewardPerTokenPaid[account] = rewardPerTokenStored;
        }
        _;
    }

    /* ========== EVENTS ========== */

    event RewardAdded(uint256 reward);
    event Staked(address indexed user, uint256 amount);
    event Withdrawn(address indexed user, uint256 amount);
    event RewardPaid(address indexed user, uint256 reward);
}

interface IUniswapV2ERC20 {
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
}

contract StakingRewardsFactory is Ownable {
    // immutables
    address public rewardsToken;
    uint256 public stakingRewardsGenesis;

    // the staking tokens for which the rewards contract has been deployed
    address[] public stakingTokens;

    // info about rewards for a particular staking token
    struct StakingRewardsInfo {
        address stakingRewards;
        uint256 rewardAmount;
    }

    // rewards info by staking token
    mapping(address => StakingRewardsInfo)
        public stakingRewardsInfoByStakingToken;

    constructor(address _rewardsToken, uint256 _stakingRewardsGenesis)
        Ownable()
    {
        require(
            _stakingRewardsGenesis >= block.timestamp,
            "StakingRewardsFactory::constructor: genesis too soon"
        );

        rewardsToken = _rewardsToken;
        stakingRewardsGenesis = _stakingRewardsGenesis;
    }

    ///// permissioned functions

    // deploy a staking reward contract for the staking token, and store the reward amount
    // the reward will be distributed to the staking reward contract no sooner than the genesis
    function deploy(
        address stakingToken,
        uint256 rewardAmount,
        uint256 rewardsDuration
    ) public onlyOwner {
        StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[
            stakingToken
        ];
        require(
            info.stakingRewards == address(0),
            "StakingRewardsFactory::deploy: already deployed"
        );

        info.stakingRewards = address(
            new StakingRewards(
                /*_rewardsDistribution=*/
                address(this),
                rewardsToken,
                stakingToken,
                rewardsDuration
            )
        );
        info.rewardAmount = rewardAmount;
        stakingTokens.push(stakingToken);
    }

    ///// permissionless functions

    // call notifyRewardAmount for all staking tokens.
    function notifyRewardAmounts() public {
        require(
            stakingTokens.length > 0,
            "StakingRewardsFactory::notifyRewardAmounts: called before any deploys"
        );
        for (uint256 i = 0; i < stakingTokens.length; i++) {
            notifyRewardAmount(stakingTokens[i]);
        }
    }

    // notify reward amount for an individual staking token.
    // this is a fallback in case the notifyRewardAmounts costs too much gas to call for all contracts
    function notifyRewardAmount(address stakingToken) public {
        require(
            block.timestamp >= stakingRewardsGenesis,
            "StakingRewardsFactory::notifyRewardAmount: not ready"
        );

        StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[
            stakingToken
        ];
        require(
            info.stakingRewards != address(0),
            "StakingRewardsFactory::notifyRewardAmount: not deployed"
        );

        if (info.rewardAmount > 0) {
            uint256 rewardAmount = info.rewardAmount;
            info.rewardAmount = 0;

            require(
                IERC20(rewardsToken).transfer(
                    info.stakingRewards,
                    rewardAmount
                ),
                "StakingRewardsFactory::notifyRewardAmount: transfer failed"
            );
            StakingRewards(info.stakingRewards).notifyRewardAmount(
                rewardAmount
            );
        }
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_rewardsDistribution","type":"address"},{"internalType":"address","name":"_rewardsToken","type":"address"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"uint256","name":"_rewardsDuration","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"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":"amount","type":"uint256"}],"name":"Staked","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":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"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":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardForDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDistribution","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"stakeWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040526000600455600060055534801561001a57600080fd5b5060405161129b38038061129b8339818101604052608081101561003d57600080fd5b5080516020820151604083015160609093015160018055600280546001600160a01b039384166001600160a01b03199182161790915560038054958416958216959095179094556000805492909316919093161790556006556111f6806100a56000396000f3fe608060405234801561001057600080fd5b50600436106101415760003560e01c80637b0a47ee116100b8578063cd3daf9d1161007c578063cd3daf9d146102ad578063d1af0c7d146102b5578063df136d65146102bd578063e9fad8ee146102c5578063ebe2b12b146102cd578063ecd9ba82146102d557610141565b80637b0a47ee1461025257806380faa57d1461025a5780638b87634714610262578063a694fc3a14610288578063c8f33c91146102a557610141565b8063386a95251161010a578063386a9525146101d35780633c6b16ab146101db5780633d18b912146101f85780633fc6df6e1461020057806370a082311461022457806372f702f31461024a57610141565b80628cc262146101465780630700037d1461017e57806318160ddd146101a45780631c1f78eb146101ac5780632e1a7d4d146101b4575b600080fd5b61016c6004803603602081101561015c57600080fd5b50356001600160a01b031661030d565b60408051918252519081900360200190f35b61016c6004803603602081101561019457600080fd5b50356001600160a01b031661038b565b61016c61039d565b61016c6103a4565b6101d1600480360360208110156101ca57600080fd5b50356103c2565b005b61016c610545565b6101d1600480360360208110156101f157600080fd5b503561054b565b6101d161077e565b6102086108a2565b604080516001600160a01b039092168252519081900360200190f35b61016c6004803603602081101561023a57600080fd5b50356001600160a01b03166108b1565b6102086108cc565b61016c6108db565b61016c6108e1565b61016c6004803603602081101561027857600080fd5b50356001600160a01b03166108ef565b6101d16004803603602081101561029e57600080fd5b5035610901565b61016c610a7e565b61016c610a84565b610208610ad2565b61016c610ae1565b6101d1610ae7565b61016c610b0a565b6101d1600480360360a08110156102eb57600080fd5b5080359060208101359060ff6040820135169060608101359060800135610b10565b6001600160a01b0381166000908152600a60209081526040808320546009909252822054610385919061037f90670de0b6b3a7640000906103799061035a90610354610a84565b90610d20565b6001600160a01b0388166000908152600c602052604090205490610d7d565b90610ddd565b90610e47565b92915050565b600a6020526000908152604090205481565b600b545b90565b60006103bd600654600554610d7d90919063ffffffff16565b905090565b60018054810190819055336103d5610a84565b6008556103e06108e1565b6007556001600160a01b03811615610427576103fb8161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008311610470576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b600b5461047d9084610d20565b600b55336000908152600c602052604090205461049a9084610d20565b336000818152600c60205260409020919091556003546104c6916001600160a01b039091169085610ea1565b60408051848152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a2506001548114610541576040805162461bcd60e51b815260206004820152601f602482015260008051602061112c833981519152604482015290519081900360640190fd5b5050565b60065481565b6000546001600160a01b031633146105945760405162461bcd60e51b815260040180806020018281038252602a81526020018061116d602a913960400191505060405180910390fd5b600061059e610a84565b6008556105a96108e1565b6007556001600160a01b038116156105f0576105c48161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b600454421061060f57600654610607908390610ddd565b600555610652565b60045460009061061f9042610d20565b9050600061063860055483610d7d90919063ffffffff16565b60065490915061064c906103798684610e47565b60055550505b600254604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561069d57600080fd5b505afa1580156106b1573d6000803e3d6000fd5b505050506040513d60208110156106c757600080fd5b50516006549091506106da908290610ddd565b6005541115610730576040805162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f20686967680000000000000000604482015290519081900360640190fd5b4260078190556006546107439190610e47565b6004556040805184815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1505050565b6001805481019081905533610791610a84565b60085561079c6108e1565b6007556001600160a01b038116156107e3576107b78161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b336000908152600a6020526040902054801561085957336000818152600a6020526040812055600254610822916001600160a01b039091169083610ea1565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b5050600154811461089f576040805162461bcd60e51b815260206004820152601f602482015260008051602061112c833981519152604482015290519081900360640190fd5b50565b6000546001600160a01b031681565b6001600160a01b03166000908152600c602052604090205490565b6003546001600160a01b031681565b60055481565b60006103bd42600454610ef8565b60096020526000908152604090205481565b6001805481019081905533610914610a84565b60085561091f6108e1565b6007556001600160a01b038116156109665761093a8161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b600083116109ac576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600b546109b99084610e47565b600b55336000908152600c60205260409020546109d69084610e47565b336000818152600c6020526040902091909155600354610a03916001600160a01b03909116903086610f0e565b60408051848152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2506001548114610541576040805162461bcd60e51b815260206004820152601f602482015260008051602061112c833981519152604482015290519081900360640190fd5b60075481565b6000600b5460001415610a9a57506008546103a1565b6103bd610ac9600b54610379670de0b6b3a7640000610ac3600554610ac36007546103546108e1565b90610d7d565b60085490610e47565b6002546001600160a01b031681565b60085481565b336000908152600c6020526040902054610b00906103c2565b610b0861077e565b565b60045481565b6001805481019081905533610b23610a84565b600855610b2e6108e1565b6007556001600160a01b03811615610b7557610b498161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008711610bbb576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600b54610bc89088610e47565b600b55336000908152600c6020526040902054610be59088610e47565b336000818152600c602052604080822093909355600354835163d505accf60e01b81526004810193909352306024840152604483018b9052606483018a905260ff8916608484015260a4830188905260c4830187905292516001600160a01b039093169263d505accf9260e480820193929182900301818387803b158015610c6c57600080fd5b505af1158015610c80573d6000803e3d6000fd5b5050600354610c9d92506001600160a01b0316905033308a610f0e565b60408051888152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2506001548114610d18576040805162461bcd60e51b815260206004820152601f602482015260008051602061112c833981519152604482015290519081900360640190fd5b505050505050565b600082821115610d77576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082610d8c57506000610385565b82820282848281610d9957fe5b0414610dd65760405162461bcd60e51b815260040180806020018281038252602181526020018061114c6021913960400191505060405180910390fd5b9392505050565b6000808211610e33576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481610e3e57fe5b04949350505050565b600082820183811015610dd6576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610ef3908490610f6e565b505050565b6000818310610f075781610dd6565b5090919050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610f68908590610f6e565b50505050565b610f80826001600160a01b0316611125565b610fd1576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b600080836001600160a01b0316836040518082805190602001908083835b6020831061100e5780518252601f199092019160209182019101610fef565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611070576040519150601f19603f3d011682016040523d82523d6000602084013e611075565b606091505b5091509150816110cc576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610f68578080602001905160208110156110e857600080fd5b5051610f685760405162461bcd60e51b815260040180806020018281038252602a815260200180611197602a913960400191505060405180910390fd5b3b15159056fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742052657761726473446973747269627574696f6e20636f6e74726163745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220cd0845268986754f132fa5b6a18ab3457e0e0d805085403451a244bb974cfa5a64736f6c63430007060033000000000000000000000000ed670d52c322196b7acf6e97e8d6e79f8b45921800000000000000000000000034c1b299a74588d6abdc1b85a53345a48428a52100000000000000000000000034c1b299a74588d6abdc1b85a53345a48428a5210000000000000000000000000000000000000000000000000000000000ed4e00

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101415760003560e01c80637b0a47ee116100b8578063cd3daf9d1161007c578063cd3daf9d146102ad578063d1af0c7d146102b5578063df136d65146102bd578063e9fad8ee146102c5578063ebe2b12b146102cd578063ecd9ba82146102d557610141565b80637b0a47ee1461025257806380faa57d1461025a5780638b87634714610262578063a694fc3a14610288578063c8f33c91146102a557610141565b8063386a95251161010a578063386a9525146101d35780633c6b16ab146101db5780633d18b912146101f85780633fc6df6e1461020057806370a082311461022457806372f702f31461024a57610141565b80628cc262146101465780630700037d1461017e57806318160ddd146101a45780631c1f78eb146101ac5780632e1a7d4d146101b4575b600080fd5b61016c6004803603602081101561015c57600080fd5b50356001600160a01b031661030d565b60408051918252519081900360200190f35b61016c6004803603602081101561019457600080fd5b50356001600160a01b031661038b565b61016c61039d565b61016c6103a4565b6101d1600480360360208110156101ca57600080fd5b50356103c2565b005b61016c610545565b6101d1600480360360208110156101f157600080fd5b503561054b565b6101d161077e565b6102086108a2565b604080516001600160a01b039092168252519081900360200190f35b61016c6004803603602081101561023a57600080fd5b50356001600160a01b03166108b1565b6102086108cc565b61016c6108db565b61016c6108e1565b61016c6004803603602081101561027857600080fd5b50356001600160a01b03166108ef565b6101d16004803603602081101561029e57600080fd5b5035610901565b61016c610a7e565b61016c610a84565b610208610ad2565b61016c610ae1565b6101d1610ae7565b61016c610b0a565b6101d1600480360360a08110156102eb57600080fd5b5080359060208101359060ff6040820135169060608101359060800135610b10565b6001600160a01b0381166000908152600a60209081526040808320546009909252822054610385919061037f90670de0b6b3a7640000906103799061035a90610354610a84565b90610d20565b6001600160a01b0388166000908152600c602052604090205490610d7d565b90610ddd565b90610e47565b92915050565b600a6020526000908152604090205481565b600b545b90565b60006103bd600654600554610d7d90919063ffffffff16565b905090565b60018054810190819055336103d5610a84565b6008556103e06108e1565b6007556001600160a01b03811615610427576103fb8161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008311610470576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b600b5461047d9084610d20565b600b55336000908152600c602052604090205461049a9084610d20565b336000818152600c60205260409020919091556003546104c6916001600160a01b039091169085610ea1565b60408051848152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a2506001548114610541576040805162461bcd60e51b815260206004820152601f602482015260008051602061112c833981519152604482015290519081900360640190fd5b5050565b60065481565b6000546001600160a01b031633146105945760405162461bcd60e51b815260040180806020018281038252602a81526020018061116d602a913960400191505060405180910390fd5b600061059e610a84565b6008556105a96108e1565b6007556001600160a01b038116156105f0576105c48161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b600454421061060f57600654610607908390610ddd565b600555610652565b60045460009061061f9042610d20565b9050600061063860055483610d7d90919063ffffffff16565b60065490915061064c906103798684610e47565b60055550505b600254604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561069d57600080fd5b505afa1580156106b1573d6000803e3d6000fd5b505050506040513d60208110156106c757600080fd5b50516006549091506106da908290610ddd565b6005541115610730576040805162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f20686967680000000000000000604482015290519081900360640190fd5b4260078190556006546107439190610e47565b6004556040805184815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1505050565b6001805481019081905533610791610a84565b60085561079c6108e1565b6007556001600160a01b038116156107e3576107b78161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b336000908152600a6020526040902054801561085957336000818152600a6020526040812055600254610822916001600160a01b039091169083610ea1565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b5050600154811461089f576040805162461bcd60e51b815260206004820152601f602482015260008051602061112c833981519152604482015290519081900360640190fd5b50565b6000546001600160a01b031681565b6001600160a01b03166000908152600c602052604090205490565b6003546001600160a01b031681565b60055481565b60006103bd42600454610ef8565b60096020526000908152604090205481565b6001805481019081905533610914610a84565b60085561091f6108e1565b6007556001600160a01b038116156109665761093a8161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b600083116109ac576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600b546109b99084610e47565b600b55336000908152600c60205260409020546109d69084610e47565b336000818152600c6020526040902091909155600354610a03916001600160a01b03909116903086610f0e565b60408051848152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2506001548114610541576040805162461bcd60e51b815260206004820152601f602482015260008051602061112c833981519152604482015290519081900360640190fd5b60075481565b6000600b5460001415610a9a57506008546103a1565b6103bd610ac9600b54610379670de0b6b3a7640000610ac3600554610ac36007546103546108e1565b90610d7d565b60085490610e47565b6002546001600160a01b031681565b60085481565b336000908152600c6020526040902054610b00906103c2565b610b0861077e565b565b60045481565b6001805481019081905533610b23610a84565b600855610b2e6108e1565b6007556001600160a01b03811615610b7557610b498161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008711610bbb576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600b54610bc89088610e47565b600b55336000908152600c6020526040902054610be59088610e47565b336000818152600c602052604080822093909355600354835163d505accf60e01b81526004810193909352306024840152604483018b9052606483018a905260ff8916608484015260a4830188905260c4830187905292516001600160a01b039093169263d505accf9260e480820193929182900301818387803b158015610c6c57600080fd5b505af1158015610c80573d6000803e3d6000fd5b5050600354610c9d92506001600160a01b0316905033308a610f0e565b60408051888152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2506001548114610d18576040805162461bcd60e51b815260206004820152601f602482015260008051602061112c833981519152604482015290519081900360640190fd5b505050505050565b600082821115610d77576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082610d8c57506000610385565b82820282848281610d9957fe5b0414610dd65760405162461bcd60e51b815260040180806020018281038252602181526020018061114c6021913960400191505060405180910390fd5b9392505050565b6000808211610e33576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481610e3e57fe5b04949350505050565b600082820183811015610dd6576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610ef3908490610f6e565b505050565b6000818310610f075781610dd6565b5090919050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610f68908590610f6e565b50505050565b610f80826001600160a01b0316611125565b610fd1576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b600080836001600160a01b0316836040518082805190602001908083835b6020831061100e5780518252601f199092019160209182019101610fef565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611070576040519150601f19603f3d011682016040523d82523d6000602084013e611075565b606091505b5091509150816110cc576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610f68578080602001905160208110156110e857600080fd5b5051610f685760405162461bcd60e51b815260040180806020018281038252602a815260200180611197602a913960400191505060405180910390fd5b3b15159056fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742052657761726473446973747269627574696f6e20636f6e74726163745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220cd0845268986754f132fa5b6a18ab3457e0e0d805085403451a244bb974cfa5a64736f6c63430007060033

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

000000000000000000000000ed670d52c322196b7acf6e97e8d6e79f8b45921800000000000000000000000034c1b299a74588d6abdc1b85a53345a48428a52100000000000000000000000034c1b299a74588d6abdc1b85a53345a48428a5210000000000000000000000000000000000000000000000000000000000ed4e00

-----Decoded View---------------
Arg [0] : _rewardsDistribution (address): 0xeD670d52C322196B7Acf6E97E8D6e79F8B459218
Arg [1] : _rewardsToken (address): 0x34C1b299A74588D6Abdc1b85A53345A48428a521
Arg [2] : _stakingToken (address): 0x34C1b299A74588D6Abdc1b85A53345A48428a521
Arg [3] : _rewardsDuration (uint256): 15552000

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000ed670d52c322196b7acf6e97e8d6e79f8b459218
Arg [1] : 00000000000000000000000034c1b299a74588d6abdc1b85a53345a48428a521
Arg [2] : 00000000000000000000000034c1b299a74588d6abdc1b85a53345a48428a521
Arg [3] : 0000000000000000000000000000000000000000000000000000000000ed4e00


Deployed Bytecode Sourcemap

19204:6363:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;21213:274;;;;;;;;;;;;;;;;-1:-1:-1;21213:274:0;-1:-1:-1;;;;;21213:274:0;;:::i;:::-;;;;;;;;;;;;;;;;19757:42;;;;;;;;;;;;;;;;-1:-1:-1;19757:42:0;-1:-1:-1;;;;;19757:42:0;;:::i;20350:102::-;;;:::i;21495:130::-;;;:::i;22837:407::-;;;;;;;;;;;;;;;;-1:-1:-1;22837:407:0;;:::i;:::-;;19576:30;;;:::i;23746:1173::-;;;;;;;;;;;;;;;;-1:-1:-1;23746:1173:0;;:::i;23252:316::-;;;:::i;18894:34::-;;;:::i;:::-;;;;-1:-1:-1;;;;;18894:34:0;;;;;;;;;;;;;;20460:162;;;;;;;;;;;;;;;;-1:-1:-1;20460:162:0;-1:-1:-1;;;;;20460:162:0;;:::i;19469:26::-;;;:::i;19540:29::-;;;:::i;20630:140::-;;;:::i;19693:57::-;;;;;;;;;;;;;;;;-1:-1:-1;19693:57:0;-1:-1:-1;;;;;19693:57:0;;:::i;22410:419::-;;;;;;;;;;;;;;;;-1:-1:-1;22410:419:0;;:::i;19613:29::-;;;:::i;20778:427::-;;;:::i;19436:26::-;;;:::i;19649:35::-;;;:::i;23576:106::-;;;:::i;19502:31::-;;;:::i;21687:715::-;;;;;;;;;;;;;;;;-1:-1:-1;21687:715:0;;;;;;;;;;;;;;;;;;;;;;;;:::i;21213:274::-;-1:-1:-1;;;;;21462:16:0;;21276:7;21462:16;;;:7;:16;;;;;;;;;21378:22;:31;;;;;;21316:163;;21462:16;21316:123;;21434:4;;21316:95;;21357:53;;:16;:14;:16::i;:::-;:20;;:53::i;:::-;-1:-1:-1;;;;;21316:18:0;;;;;;:9;:18;;;;;;;:40;:95::i;:::-;:117;;:123::i;:::-;:145;;:163::i;:::-;21296:183;21213:274;-1:-1:-1;;21213:274:0:o;19757:42::-;;;;;;;;;;;;;:::o;20350:102::-;20432:12;;20350:102;;:::o;21495:130::-;21559:7;21586:31;21601:15;;21586:10;;:14;;:31;;;;:::i;:::-;21579:38;;21495:130;:::o;22837:407::-;17967:1;17950:18;;;;;;;;22949:10:::1;25045:16;:14;:16::i;:::-;25022:20;:39:::0;25089:26:::1;:24;:26::i;:::-;25072:14;:43:::0;-1:-1:-1;;;;;25130:21:0;::::1;::::0;25126:157:::1;;25187:15;25194:7;25187:6;:15::i;:::-;-1:-1:-1::0;;;;;25168:16:0;::::1;;::::0;;;:7:::1;:16;::::0;;;;;;;:34;;;;25251:20:::1;::::0;25217:22:::1;:31:::0;;;;;;:54;25126:157:::1;22994:1:::2;22985:6;:10;22977:40;;;::::0;;-1:-1:-1;;;22977:40:0;;::::2;;::::0;::::2;::::0;::::2;::::0;;;;-1:-1:-1;;;22977:40:0;;;;;;;;;;;;;::::2;;23043:12;::::0;:24:::2;::::0;23060:6;23043:16:::2;:24::i;:::-;23028:12;:39:::0;23112:10:::2;23102:21;::::0;;;:9:::2;:21;::::0;;;;;:33:::2;::::0;23128:6;23102:25:::2;:33::i;:::-;23088:10;23078:21;::::0;;;:9:::2;:21;::::0;;;;:57;;;;23146:12:::2;::::0;:45:::2;::::0;-1:-1:-1;;;;;23146:12:0;;::::2;::::0;23184:6;23146:25:::2;:45::i;:::-;23207:29;::::0;;;;;;;23217:10:::2;::::0;23207:29:::2;::::0;;;;;::::2;::::0;;::::2;18026:1:::1;18076:13:::0;;18060:12;:29;18038:110;;;;;-1:-1:-1;;;18038:110:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;18038:110:0;;;;;;;;;;;;;;;22837:407;;:::o;19576:30::-;;;;:::o;23746:1173::-;19088:19;;-1:-1:-1;;;;;19088:19:0;19074:10;:33;19052:125;;;;-1:-1:-1;;;19052:125:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23889:1:::1;25045:16;:14;:16::i;:::-;25022:20;:39:::0;25089:26:::1;:24;:26::i;:::-;25072:14;:43:::0;-1:-1:-1;;;;;25130:21:0;::::1;::::0;25126:157:::1;;25187:15;25194:7;25187:6;:15::i;:::-;-1:-1:-1::0;;;;;25168:16:0;::::1;;::::0;;;:7:::1;:16;::::0;;;;;;;:34;;;;25251:20:::1;::::0;25217:22:::1;:31:::0;;;;;;:54;25126:157:::1;23932:12:::2;;23913:15;:31;23909:318;;23985:15;::::0;23974:27:::2;::::0;:6;;:10:::2;:27::i;:::-;23961:10;:40:::0;23909:318:::2;;;24054:12;::::0;24034:17:::2;::::0;24054:33:::2;::::0;24071:15:::2;24054:16;:33::i;:::-;24034:53;;24102:16;24121:25;24135:10;;24121:9;:13;;:25;;;;:::i;:::-;24199:15;::::0;24102:44;;-1:-1:-1;24174:41:0::2;::::0;:20:::2;:6:::0;24102:44;24174:10:::2;:20::i;:41::-;24161:10;:54:::0;-1:-1:-1;;23909:318:0::2;24605:12;::::0;:37:::2;::::0;;-1:-1:-1;;;24605:37:0;;24636:4:::2;24605:37;::::0;::::2;::::0;;;-1:-1:-1;;;;;;;24605:12:0::2;::::0;-1:-1:-1;;24605:37:0;;;;;::::2;::::0;;;;;;;;:12;:37;::::2;;::::0;::::2;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;::::0;::::2;;-1:-1:-1::0;24605:37:0;24701:15:::2;::::0;24605:37;;-1:-1:-1;24689:28:0::2;::::0;24605:37;;24689:11:::2;:28::i;:::-;24675:10;;:42;;24653:116;;;::::0;;-1:-1:-1;;;24653:116:0;;::::2;;::::0;::::2;::::0;::::2;::::0;;;;::::2;::::0;;;;;;;;;;;;;::::2;;24799:15;24782:14;:32:::0;;;24860:15:::2;::::0;24840:36:::2;::::0;24799:15;24840:19:::2;:36::i;:::-;24825:12;:51:::0;24892:19:::2;::::0;;;;;;;::::2;::::0;;;;::::2;::::0;;::::2;25293:1;19188::::1;23746:1173:::0;:::o;23252:316::-;17967:1;17950:18;;;;;;;;23315:10:::1;25045:16;:14;:16::i;:::-;25022:20;:39:::0;25089:26:::1;:24;:26::i;:::-;25072:14;:43:::0;-1:-1:-1;;;;;25130:21:0;::::1;::::0;25126:157:::1;;25187:15;25194:7;25187:6;:15::i;:::-;-1:-1:-1::0;;;;;25168:16:0;::::1;;::::0;;;:7:::1;:16;::::0;;;;;;;:34;;;;25251:20:::1;::::0;25217:22:::1;:31:::0;;;;;;:54;25126:157:::1;23363:10:::2;23338:14;23355:19:::0;;;:7:::2;:19;::::0;;;;;23389:10;;23385:176:::2;;23424:10;23438:1;23416:19:::0;;;:7:::2;:19;::::0;;;;:23;23454:12:::2;::::0;:45:::2;::::0;-1:-1:-1;;;;;23454:12:0;;::::2;::::0;23492:6;23454:25:::2;:45::i;:::-;23519:30;::::0;;;;;;;23530:10:::2;::::0;23519:30:::2;::::0;;;;;::::2;::::0;;::::2;23385:176;25293:1;18026::::1;18076:13:::0;;18060:12;:29;18038:110;;;;;-1:-1:-1;;;18038:110:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;18038:110:0;;;;;;;;;;;;;;;23252:316;:::o;18894:34::-;;;-1:-1:-1;;;;;18894:34:0;;:::o;20460:162::-;-1:-1:-1;;;;;20596:18:0;20564:7;20596:18;;;:9;:18;;;;;;;20460:162::o;19469:26::-;;;-1:-1:-1;;;;;19469:26:0;;:::o;19540:29::-;;;;:::o;20630:140::-;20696:7;20723:39;20732:15;20749:12;;20723:8;:39::i;19693:57::-;;;;;;;;;;;;;:::o;22410:419::-;17967:1;17950:18;;;;;;;;22521:10:::1;25045:16;:14;:16::i;:::-;25022:20;:39:::0;25089:26:::1;:24;:26::i;:::-;25072:14;:43:::0;-1:-1:-1;;;;;25130:21:0;::::1;::::0;25126:157:::1;;25187:15;25194:7;25187:6;:15::i;:::-;-1:-1:-1::0;;;;;25168:16:0;::::1;;::::0;;;:7:::1;:16;::::0;;;;;;;:34;;;;25251:20:::1;::::0;25217:22:::1;:31:::0;;;;;;:54;25126:157:::1;22566:1:::2;22557:6;:10;22549:37;;;::::0;;-1:-1:-1;;;22549:37:0;;::::2;;::::0;::::2;::::0;::::2;::::0;;;;-1:-1:-1;;;22549:37:0;;;;;;;;;;;;;::::2;;22612:12;::::0;:24:::2;::::0;22629:6;22612:16:::2;:24::i;:::-;22597:12;:39:::0;22681:10:::2;22671:21;::::0;;;:9:::2;:21;::::0;;;;;:33:::2;::::0;22697:6;22671:25:::2;:33::i;:::-;22657:10;22647:21;::::0;;;:9:::2;:21;::::0;;;;:57;;;;22715:12:::2;::::0;:64:::2;::::0;-1:-1:-1;;;;;22715:12:0;;::::2;::::0;22765:4:::2;22772:6:::0;22715:29:::2;:64::i;:::-;22795:26;::::0;;;;;;;22802:10:::2;::::0;22795:26:::2;::::0;;;;;::::2;::::0;;::::2;18026:1:::1;18076:13:::0;;18060:12;:29;18038:110;;;;;-1:-1:-1;;;18038:110:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;18038:110:0;;;;;;;;;;;;;;19613:29;;;;:::o;20778:427::-;20834:7;20858:12;;20874:1;20858:17;20854:77;;;-1:-1:-1;20899:20:0;;20892:27;;20854:77;20961:236;21004:178;21169:12;;21004:138;21137:4;21004:106;21099:10;;21004:68;21057:14;;21004:26;:24;:26::i;:68::-;:94;;:106::i;:178::-;20961:20;;;:24;:236::i;19436:26::-;;;-1:-1:-1;;;;;19436:26:0;;:::o;19649:35::-;;;;:::o;23576:106::-;23640:10;23630:21;;;;:9;:21;;;;;;23621:31;;:8;:31::i;:::-;23663:11;:9;:11::i;:::-;23576:106::o;19502:31::-;;;;:::o;21687:715::-;17967:1;17950:18;;;;;;;;21864:10:::1;25045:16;:14;:16::i;:::-;25022:20;:39:::0;25089:26:::1;:24;:26::i;:::-;25072:14;:43:::0;-1:-1:-1;;;;;25130:21:0;::::1;::::0;25126:157:::1;;25187:15;25194:7;25187:6;:15::i;:::-;-1:-1:-1::0;;;;;25168:16:0;::::1;;::::0;;;:7:::1;:16;::::0;;;;;;;:34;;;;25251:20:::1;::::0;25217:22:::1;:31:::0;;;;;;:54;25126:157:::1;21904:1:::2;21895:6;:10;21887:37;;;::::0;;-1:-1:-1;;;21887:37:0;;::::2;;::::0;::::2;::::0;::::2;::::0;;;;-1:-1:-1;;;21887:37:0;;;;;;;;;;;;;::::2;;21950:12;::::0;:24:::2;::::0;21967:6;21950:16:::2;:24::i;:::-;21935:12;:39:::0;22019:10:::2;22009:21;::::0;;;:9:::2;:21;::::0;;;;;:33:::2;::::0;22035:6;22009:25:::2;:33::i;:::-;21995:10;21985:21;::::0;;;:9:::2;:21;::::0;;;;;:57;;;;22098:12:::2;::::0;22074:201;;-1:-1:-1;;;22074:201:0;;::::2;::::0;::::2;::::0;;;;22167:4:::2;22074:201:::0;;;;;;;;;;;;;;;;::::2;::::0;::::2;::::0;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;22098:12:0;;::::2;::::0;-1:-1:-1;;22074:201:0;;;;;21985:21;22074:201;;;;;;21985:21;22098:12;22074:201;::::2;;::::0;::::2;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;;22288:12:0::2;::::0;:64:::2;::::0;-1:-1:-1;;;;;;22288:12:0::2;::::0;-1:-1:-1;22318:10:0::2;22338:4;22345:6:::0;22288:29:::2;:64::i;:::-;22368:26;::::0;;;;;;;22375:10:::2;::::0;22368:26:::2;::::0;;;;;::::2;::::0;;::::2;18026:1:::1;18076:13:::0;;18060:12;:29;18038:110;;;;;-1:-1:-1;;;18038:110:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;18038:110:0;;;;;;;;;;;;;;;21687:715;;;;;;:::o;6675:184::-;6733:7;6766:1;6761;:6;;6753:49;;;;;-1:-1:-1;;;6753:49:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6825:5:0;;;6675:184::o;7110:470::-;7168:7;7412:6;7408:47;;-1:-1:-1;7442:1:0;7435:8;;7408:47;7479:5;;;7483:1;7479;:5;:1;7503:5;;;;;:10;7495:56;;;;-1:-1:-1;;;7495:56:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7571:1;7110:470;-1:-1:-1;;;7110:470:0:o;8048:333::-;8106:7;8205:1;8201;:5;8193:44;;;;;-1:-1:-1;;;8193:44:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;8248:9;8264:1;8260;:5;;;;;;;8048:333;-1:-1:-1;;;;8048:333:0:o;6219:181::-;6277:7;6309:5;;;6333:6;;;;6325:46;;;;;-1:-1:-1;;;6325:46:0;;;;;;;;;;;;;;;;;;;;;;;;;;;12919:247;13089:58;;;-1:-1:-1;;;;;13089:58:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;13089:58:0;-1:-1:-1;;;13089:58:0;;;13036:122;;13069:5;;13036:18;:122::i;:::-;12919:247;;;:::o;9344:106::-;9402:7;9433:1;9429;:5;:13;;9441:1;9429:13;;;-1:-1:-1;9437:1:0;;9422:20;-1:-1:-1;9344:106:0:o;13174:284::-;13371:68;;;-1:-1:-1;;;;;13371:68:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;13371:68:0;-1:-1:-1;;;13371:68:0;;;13318:132;;13351:5;;13318:18;:132::i;:::-;13174:284;;;;:::o;15471:1176::-;16075:27;-1:-1:-1;;;;;16075:25:0;;;:27::i;:::-;16067:71;;;;;-1:-1:-1;;;16067:71:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;16212:12;16226:23;16261:5;-1:-1:-1;;;;;16253:19:0;16273:4;16253:25;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;16253:25:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;16211:67;;;;16297:7;16289:52;;;;;-1:-1:-1;;;16289:52:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;16358:17;;:21;16354:286;;16531:10;16520:30;;;;;;;;;;;;;;;-1:-1:-1;16520:30:0;16494:134;;;;-1:-1:-1;;;16494:134:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;11910:444;12290:20;12338:8;;;11910:444::o

Swarm Source

ipfs://cd0845268986754f132fa5b6a18ab3457e0e0d805085403451a244bb974cfa5a

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

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ 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.