Contract 0x923c88f0aa5998953c01a23cdd1d82852f94aeea

 

Contract Overview

Dopex: Staking Rewards Factory
Balance:
0 ETH

ETH Value:
$0.00
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x9b2edd56bc70976c04889316dbe296be202e0116b891ca9810426e8346b25ae7Withdraw Reward ...166608112022-06-30 23:40:1538 days 4 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.00028600413 ETH
0x2d8d33b8c0e003cc46cc7c0b867d07128cd917cb5cdb91258dacc20d46f522e1Withdraw Reward ...162940672022-06-28 21:51:3440 days 6 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000378072834 ETH
0x1b8d1411be62d25e80bec889728d795a7d43483225235431fabe7ca136b220c2Withdraw Reward ...162607232022-06-28 18:45:1140 days 9 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000380579108 ETH
0xd2feef5c596b3275c1a7a397b21b835cd150d2518d379e3c5e80664eb21ca52dWithdraw Reward ...162477562022-06-28 16:46:3340 days 11 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000264542254 ETH
0xd5e582926bb00e54359fd715aca4ccafe37fcfbf0423f4f403226429b1650da1Withdraw Reward ...162477532022-06-28 16:46:3340 days 11 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.00026378235 ETH
0x49f2071b26ce121f3bc4d17964d2504c386b40db86e78c234fd2ce4ac02605e0Withdraw Reward ...162477202022-06-28 16:46:3340 days 11 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000263769959 ETH
0x5c57cb49ea9bae9efcc814e236d5d9220a54a80ec439e4f9f80e329dfecb60f7Withdraw Reward ...161376542022-06-27 23:49:2341 days 4 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000557940795 ETH
0x57694604fe94d3121a9515a1c76f387584bca61bd53e749b38ce2d520124e52fRemove From Cont...161371892022-06-27 23:43:0641 days 4 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000555212591 ETH
0x62036e709a7fc32ca7d35b43147055ba8af20d62d2b75ddea6b564bad45fc21cWithdraw Reward ...161282002022-06-27 21:30:0341 days 6 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000657753876 ETH
0x3dde560d8c2be2493c4c29204bb5c0e330abd772539148fd1bbe87ea82b74c30Withdraw Reward ...161268932022-06-27 21:09:3741 days 6 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000706053874 ETH
0x5f7b41fa9f8369d41b7539d674cbbc77b43aab548e012e491a232be645cb8214Withdraw Reward ...161268882022-06-27 21:09:3741 days 6 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000704137286 ETH
0xadf2026914313a9563a3d5c8c7bcef85afbcd23593cdaa0a6ab7e1cc799d9afeWithdraw Reward ...161268832022-06-27 21:09:3741 days 6 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000849292732 ETH
0x0b2e26797ba065a9daa4c2e95e647b839e505e73c1a65a6b282e5b849dd910caRemove From Cont...145104272022-06-13 14:14:1655 days 13 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000557133823 ETH
0xb8598a50ab6e929aa8917bc17bb3303da1e48ffae515adf1ffbfd37a201a7dc2Add To Contract ...125796312022-05-20 17:46:5579 days 10 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000179093703 ETH
0x4cc29751e7e6ee2f6881822cf24b5563d6215477c833d08229c25c6a23180dd4Add To Contract ...124890542022-05-19 14:23:0280 days 13 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000136154786 ETH
0x63a6cc92085b04f6121cc541b4eba6596db94beea5be9c0789e2d4cfffe94116Add To Contract ...115791352022-05-09 8:34:0290 days 19 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000138224607 ETH
0x29541f3d0c4acc1fdf3423e4c06f53951e600582cc0d6ec2b416bb9455ac36e0Add To Contract ...113941862022-05-07 7:45:1792 days 20 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000195510358 ETH
0x5c5381e3d5ccf20cd01dc1f434ffc224e395ba2a61faa0a1644cbe76df0463edAdd To Contract ...113941802022-05-07 7:45:1792 days 20 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000195518084 ETH
0x1e9a215a26ab638c7739a67875f474488e924ca5ff0aad01d75e822ebd2cc0cdAdd To Contract ...113941702022-05-07 7:45:1792 days 20 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000196017656 ETH
0xb416344f1f6efd9a7366cda1dedc4a9deb11c63878dbf3542cbaf875a1ca5c85Add To Contract ...112104232022-05-04 23:13:4695 days 4 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000291189649 ETH
0xa33e328859d97e04b1d2c18c4020b14732613444f1793772fbd639b98e72473eAdd To Contract ...109531652022-05-01 3:58:2199 days 9 mins ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.0009591138 ETH
0xed2afc562cd88e3eeb1846c49d49680d21884769ff13ea816d310c93f2830c8bAdd To Contract ...98109942022-04-14 19:19:46115 days 8 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000253986991 ETH
0x14525b7a2502454b999ab3d0fbc233fc08f4a837b78d9cc465ce3d37ca6ad39fAdd To Contract ...96512752022-04-11 17:35:50118 days 10 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000236682408 ETH
0x8d6a0e5d82e634548b4aa5688fa8f23efd36ae015e7a29f28c2fecf7cc4157edAdd To Contract ...95135832022-04-08 17:34:38121 days 10 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000355983175 ETH
0x79780a125ce5422a2b460cf84cde94a8f57b44d27d164c51b8b2d57bcd4cc4d5Add To Contract ...94204382022-04-06 23:09:33123 days 4 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Dopex: Staking Rewards Factory0 ETH0.000369654462 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x9b2edd56bc70976c04889316dbe296be202e0116b891ca9810426e8346b25ae7166608112022-06-30 23:40:1538 days 4 hrs ago Dopex: Staking Rewards Factory Dopex: rDPX Token0 ETH
0x9b2edd56bc70976c04889316dbe296be202e0116b891ca9810426e8346b25ae7166608112022-06-30 23:40:1538 days 4 hrs ago Dopex: Staking Rewards FactoryDopex: DPX Token0 ETH
0x2d8d33b8c0e003cc46cc7c0b867d07128cd917cb5cdb91258dacc20d46f522e1162940672022-06-28 21:51:3440 days 6 hrs ago Dopex: Staking Rewards Factory Dopex: rDPX Token0 ETH
0x2d8d33b8c0e003cc46cc7c0b867d07128cd917cb5cdb91258dacc20d46f522e1162940672022-06-28 21:51:3440 days 6 hrs ago Dopex: Staking Rewards FactoryDopex: DPX Token0 ETH
0x1b8d1411be62d25e80bec889728d795a7d43483225235431fabe7ca136b220c2162607232022-06-28 18:45:1140 days 9 hrs ago Dopex: Staking Rewards Factory Dopex: rDPX Token0 ETH
0x1b8d1411be62d25e80bec889728d795a7d43483225235431fabe7ca136b220c2162607232022-06-28 18:45:1140 days 9 hrs ago Dopex: Staking Rewards FactoryDopex: DPX Token0 ETH
0xd2feef5c596b3275c1a7a397b21b835cd150d2518d379e3c5e80664eb21ca52d162477562022-06-28 16:46:3340 days 11 hrs ago Dopex: Staking Rewards FactoryDopex: rDPX-WETH Staking Rewards0 ETH
0xd5e582926bb00e54359fd715aca4ccafe37fcfbf0423f4f403226429b1650da1162477532022-06-28 16:46:3340 days 11 hrs ago Dopex: Staking Rewards FactoryDopex: DPX/ETH Farm0 ETH
0x49f2071b26ce121f3bc4d17964d2504c386b40db86e78c234fd2ce4ac02605e0162477202022-06-28 16:46:3340 days 11 hrs ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
0x5c57cb49ea9bae9efcc814e236d5d9220a54a80ec439e4f9f80e329dfecb60f7161376542022-06-27 23:49:2341 days 4 hrs ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
0x57694604fe94d3121a9515a1c76f387584bca61bd53e749b38ce2d520124e52f161371892022-06-27 23:43:0641 days 4 hrs ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
0x62036e709a7fc32ca7d35b43147055ba8af20d62d2b75ddea6b564bad45fc21c161282002022-06-27 21:30:0341 days 6 hrs ago Dopex: Staking Rewards Factory Dopex: rDPX Token0 ETH
0x62036e709a7fc32ca7d35b43147055ba8af20d62d2b75ddea6b564bad45fc21c161282002022-06-27 21:30:0341 days 6 hrs ago Dopex: Staking Rewards FactoryDopex: DPX Token0 ETH
0x3dde560d8c2be2493c4c29204bb5c0e330abd772539148fd1bbe87ea82b74c30161268932022-06-27 21:09:3741 days 6 hrs ago Dopex: Staking Rewards FactoryDopex: rDPX-WETH Staking Rewards0 ETH
0x5f7b41fa9f8369d41b7539d674cbbc77b43aab548e012e491a232be645cb8214161268882022-06-27 21:09:3741 days 6 hrs ago Dopex: Staking Rewards FactoryDopex: DPX/ETH Farm0 ETH
0xadf2026914313a9563a3d5c8c7bcef85afbcd23593cdaa0a6ab7e1cc799d9afe161268832022-06-27 21:09:3741 days 6 hrs ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
0x0b2e26797ba065a9daa4c2e95e647b839e505e73c1a65a6b282e5b849dd910ca145104272022-06-13 14:14:1655 days 13 hrs ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
0xb8598a50ab6e929aa8917bc17bb3303da1e48ffae515adf1ffbfd37a201a7dc2125796312022-05-20 17:46:5579 days 10 hrs ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
0x4cc29751e7e6ee2f6881822cf24b5563d6215477c833d08229c25c6a23180dd4124890542022-05-19 14:23:0280 days 13 hrs ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
0x63a6cc92085b04f6121cc541b4eba6596db94beea5be9c0789e2d4cfffe94116115791352022-05-09 8:34:0290 days 19 hrs ago Dopex: Staking Rewards FactoryDopex: rDPX-WETH Staking Rewards0 ETH
0x29541f3d0c4acc1fdf3423e4c06f53951e600582cc0d6ec2b416bb9455ac36e0113941862022-05-07 7:45:1792 days 20 hrs ago Dopex: Staking Rewards FactoryDopex: rDPX-WETH Staking Rewards0 ETH
0x5c5381e3d5ccf20cd01dc1f434ffc224e395ba2a61faa0a1644cbe76df0463ed113941802022-05-07 7:45:1792 days 20 hrs ago Dopex: Staking Rewards FactoryDopex: DPX/ETH Farm0 ETH
0x1e9a215a26ab638c7739a67875f474488e924ca5ff0aad01d75e822ebd2cc0cd113941702022-05-07 7:45:1792 days 20 hrs ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
0xb416344f1f6efd9a7366cda1dedc4a9deb11c63878dbf3542cbaf875a1ca5c85112104232022-05-04 23:13:4695 days 4 hrs ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
0xa33e328859d97e04b1d2c18c4020b14732613444f1793772fbd639b98e72473e109531652022-05-01 3:58:2199 days 9 mins ago Dopex: Staking Rewards FactoryDopex: Retired DPX Farm0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StakingRewardsFactory

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 12 : StakingRewardsFactory.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.7.6;

// Libraries
import '@openzeppelin/contracts/math/SafeMath.sol';
import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';

// Interfaces
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

// Contracts
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';
import './StakingRewards.sol';

contract StakingRewardsFactory is Ownable, ReentrancyGuard {
  using SafeMath for uint256;
  using SafeERC20 for IERC20;

  // immutables
  address public immutable rewardsTokenDPX;
  address public immutable rewardsTokenRDPX;
  uint256 public immutable stakingRewardsGenesis;

  // the staking tokens for which the rewards contract has been deployed
  uint256[] public stakingID;

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

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

  constructor(
    address _rewardsTokenDPX,
    address _rewardsTokenRDPX,
    uint256 _stakingRewardsGenesis
  ) Ownable() {
    require(
      _stakingRewardsGenesis >= block.timestamp,
      'StakingRewardsFactory::constructor: genesis too soon'
    );
    rewardsTokenDPX = _rewardsTokenDPX;
    rewardsTokenRDPX = _rewardsTokenRDPX;
    stakingRewardsGenesis = _stakingRewardsGenesis;
  }

  // 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 rewardAmountDPX,
    uint256 rewardAmountRDPX,
    uint256 rewardsDuration,
    uint256 boostedTimePeriod,
    uint256 boost,
    uint256 id
  ) public onlyOwner {
    StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[id];
    require(info.id != id, 'StakingID already taken');
    require(rewardAmountDPX > 0, 'Invalid DPX reward amount');
    require(rewardAmountRDPX > 0, 'Invalid rDPX reward amount');
    info.stakingRewards = address(
      new StakingRewards(
        address(this),
        rewardsTokenDPX,
        rewardsTokenRDPX,
        stakingToken,
        rewardsDuration,
        boostedTimePeriod,
        boost,
        id
      )
    );
    info.rewardAmountDPX = rewardAmountDPX;
    info.rewardAmountRDPX = rewardAmountRDPX;
    info.id = id;
    stakingID.push(id);
  }

  // Withdraw tokens in case functions exceed gas cost
  function withdrawRewardToken(uint256 amountDPX, uint256 amountRDPX)
    public
    onlyOwner
    returns (uint256, uint256)
  {
    address OwnerAddress = owner();
    if (OwnerAddress == msg.sender) {
      IERC20(rewardsTokenDPX).transfer(OwnerAddress, amountDPX);
      IERC20(rewardsTokenRDPX).transfer(OwnerAddress, amountRDPX);
    }
    return (amountDPX, amountRDPX);
  }

  function withdrawRewardTokensFromContract(
    uint256 amountDPX,
    uint256 amountRDPX,
    uint256 id
  ) public onlyOwner {
    address OwnerAddress = owner();
    if (OwnerAddress == msg.sender) {
      StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[id];
      require(
        info.stakingRewards != address(0),
        'StakingRewardsFactory::notifyRewardAmount: not deployed'
      );
      StakingRewards(info.stakingRewards).withdrawRewardTokens(amountDPX, amountRDPX);
    }
  }

  // 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(uint256 id) public onlyOwner {
    require(
      block.timestamp >= stakingRewardsGenesis,
      'StakingRewardsFactory::notifyRewardAmount: not ready'
    );
    StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[id];
    require(
      info.stakingRewards != address(0),
      'StakingRewardsFactory::notifyRewardAmount: not deployed'
    );
    require(info.rewardAmountDPX > 0, 'Reward amount must be greater than 0');
    uint256 rewardAmountDPX = 0;
    uint256 rewardAmountRDPX = 0;
    if (info.rewardAmountDPX > 0) {
      rewardAmountDPX = info.rewardAmountDPX;
      info.rewardAmountDPX = 0;
      require(
        IERC20(rewardsTokenDPX).transfer(info.stakingRewards, rewardAmountDPX),
        'StakingRewardsFactory::notifyRewardAmount: transfer failed'
      );
    }
    if (info.rewardAmountRDPX > 0) {
      rewardAmountRDPX = info.rewardAmountRDPX;
      info.rewardAmountRDPX = 0;
      require(
        IERC20(rewardsTokenRDPX).transfer(info.stakingRewards, rewardAmountRDPX),
        'StakingRewardsFactory::notifyRewardAmount: transfer failed'
      );
    }
    StakingRewards(info.stakingRewards).notifyRewardAmount(rewardAmountDPX, rewardAmountRDPX);
  }

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

  function addToContractWhitelist(address _contract, uint256 id) external onlyOwner {
    StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[id];
    require(
      info.stakingRewards != address(0),
      'StakingRewardsFactory: StakingRewards not deployed'
    );
    StakingRewards(info.stakingRewards).addToContractWhitelist(_contract);
  }

  function removeFromContractWhitelist(address _contract, uint256 id) external onlyOwner {
    StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[id];
    require(
      info.stakingRewards != address(0),
      'StakingRewardsFactory: StakingRewards not deployed'
    );
    StakingRewards(info.stakingRewards).removeFromContractWhitelist(_contract);
  }
}

File 2 of 12 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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

File 3 of 12 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

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

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

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 4 of 12 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

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

File 5 of 12 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../GSN/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

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

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

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

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

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

pragma solidity >=0.6.0 <0.8.0;

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

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

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

File 7 of 12 : StakingRewards.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.7.6;

// Libraries
import '@openzeppelin/contracts/math/Math.sol';
import '@openzeppelin/contracts/math/SafeMath.sol';
import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';

// Interfaces
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import './interfaces/IStakingRewards.sol';

// Contracts
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import './RewardsDistributionRecipient.sol';

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

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

  IERC20 public rewardsTokenDPX;
  IERC20 public rewardsTokenRDPX;
  IERC20 public stakingToken;
  uint256 public boost = 0;
  uint256 public periodFinish = 0;
  uint256 public boostedFinish = 0;
  uint256 public rewardRateDPX = 0;
  uint256 public rewardRateRDPX = 0;
  uint256 public rewardsDuration;
  uint256 public lastUpdateTime;
  uint256 public rewardPerTokenStoredDPX;
  uint256 public rewardPerTokenStoredRDPX;
  uint256 public boostedTimePeriod;
  uint256 public id;

  mapping(address => bool) public whitelistedContracts;
  mapping(address => uint256) public userDPXRewardPerTokenPaid;
  mapping(address => uint256) public userRDPXRewardPerTokenPaid;
  mapping(address => uint256) public rewardsDPX;
  mapping(address => uint256) public rewardsRDPX;
  mapping(address => uint256) private _balances;

  uint256 private _totalSupply;

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

  constructor(
    address _rewardsDistribution,
    address _rewardsTokenDPX,
    address _rewardsTokenRDPX,
    address _stakingToken,
    uint256 _rewardsDuration,
    uint256 _boostedTimePeriod,
    uint256 _boost,
    uint256 _id
  ) Ownable() {
    rewardsTokenDPX = IERC20(_rewardsTokenDPX);
    rewardsTokenRDPX = IERC20(_rewardsTokenRDPX);
    stakingToken = IERC20(_stakingToken);
    rewardsDistribution = _rewardsDistribution;
    rewardsDuration = _rewardsDuration;
    boostedTimePeriod = _boostedTimePeriod;
    boost = _boost;
    id = _id;
  }

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

  function isContract(address addr) public view returns (bool) {
    uint256 size;
    assembly {
      size := extcodesize(addr)
    }
    return size > 0;
  }

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

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

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

  function rewardPerToken() public view returns (uint256, uint256) {
    if (_totalSupply == 0) {
      uint256 perTokenRateDPX = rewardPerTokenStoredDPX;
      uint256 perTokenRateRDPX = rewardPerTokenStoredRDPX;
      return (perTokenRateDPX, perTokenRateRDPX);
    }
    if (block.timestamp < boostedFinish) {
      uint256 perTokenRateDPX = rewardPerTokenStoredDPX.add(
        lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRateDPX.mul(boost)).mul(1e18).div(
          _totalSupply
        )
      );
      uint256 perTokenRateRDPX = rewardPerTokenStoredRDPX.add(
        lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRateRDPX.mul(boost)).mul(1e18).div(
          _totalSupply
        )
      );
      return (perTokenRateDPX, perTokenRateRDPX);
    } else {
      if (lastUpdateTime < boostedFinish) {
        uint256 perTokenRateDPX = rewardPerTokenStoredDPX
          .add(
            boostedFinish.sub(lastUpdateTime).mul(rewardRateDPX.mul(boost)).mul(1e18).div(
              _totalSupply
            )
          )
          .add(
            lastTimeRewardApplicable().sub(boostedFinish).mul(rewardRateDPX).mul(1e18).div(
              _totalSupply
            )
          );
        uint256 perTokenRateRDPX = rewardPerTokenStoredRDPX
          .add(
            boostedFinish.sub(lastUpdateTime).mul(rewardRateRDPX.mul(boost)).mul(1e18).div(
              _totalSupply
            )
          )
          .add(
            lastTimeRewardApplicable().sub(boostedFinish).mul(rewardRateRDPX).mul(1e18).div(
              _totalSupply
            )
          );
        return (perTokenRateDPX, perTokenRateRDPX);
      } else {
        uint256 perTokenRateDPX = rewardPerTokenStoredDPX.add(
          lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRateDPX).mul(1e18).div(
            _totalSupply
          )
        );
        uint256 perTokenRateRDPX = rewardPerTokenStoredRDPX.add(
          lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRateRDPX).mul(1e18).div(
            _totalSupply
          )
        );
        return (perTokenRateDPX, perTokenRateRDPX);
      }
    }
  }

  function earned(address account)
    public
    view
    returns (uint256 DPXtokensEarned, uint256 RDPXtokensEarned)
  {
    uint256 perTokenRateDPX;
    uint256 perTokenRateRDPX;
    (perTokenRateDPX, perTokenRateRDPX) = rewardPerToken();
    DPXtokensEarned = _balances[account]
      .mul(perTokenRateDPX.sub(userDPXRewardPerTokenPaid[account]))
      .div(1e18)
      .add(rewardsDPX[account]);
    RDPXtokensEarned = _balances[account]
      .mul(perTokenRateRDPX.sub(userRDPXRewardPerTokenPaid[account]))
      .div(1e18)
      .add(rewardsRDPX[account]);
  }

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

  function stake(uint256 amount)
    external
    payable
    isEligibleSender
    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 nonReentrant updateReward(msg.sender) {
    require(amount > 0, 'Cannot withdraw 0');
    require(amount <= _balances[msg.sender], 'Insufficent balance');
    _totalSupply = _totalSupply.sub(amount);
    _balances[msg.sender] = _balances[msg.sender].sub(amount);
    stakingToken.safeTransfer(msg.sender, amount);
    emit Withdrawn(msg.sender, amount);
  }

  function withdrawRewardTokens(uint256 amountDPX, uint256 amountRDPX)
    public
    onlyOwner
    returns (uint256, uint256)
  {
    address OwnerAddress = owner();
    if (OwnerAddress == msg.sender) {
      IERC20(rewardsTokenDPX).safeTransfer(OwnerAddress, amountDPX);
      IERC20(rewardsTokenRDPX).safeTransfer(OwnerAddress, amountRDPX);
    }
    return (amountDPX, amountRDPX);
  }

  function compound() public nonReentrant updateReward(msg.sender) {
    uint256 rewardDPX = rewardsDPX[msg.sender];
    require(rewardDPX > 0, 'stake address not found');
    require(rewardsTokenDPX == stakingToken, "Can't stake the reward token.");
    rewardsDPX[msg.sender] = 0;
    _totalSupply = _totalSupply.add(rewardDPX);
    _balances[msg.sender] = _balances[msg.sender].add(rewardDPX);
    emit RewardCompounded(msg.sender, rewardDPX);
  }

  function getReward(uint256 rewardsTokenID) public nonReentrant updateReward(msg.sender) {
    if (rewardsTokenID == 0) {
      uint256 rewardDPX = rewardsDPX[msg.sender];
      require(rewardDPX > 0, 'can not withdraw 0 DPX reward');
      rewardsDPX[msg.sender] = 0;
      rewardsTokenDPX.safeTransfer(msg.sender, rewardDPX);
      emit RewardPaid(msg.sender, rewardDPX);
    } else if (rewardsTokenID == 1) {
      uint256 rewardRDPX = rewardsRDPX[msg.sender];
      require(rewardRDPX > 0, 'can not withdraw 0 RDPX reward');
      rewardsRDPX[msg.sender] = 0;
      rewardsTokenRDPX.safeTransfer(msg.sender, rewardRDPX);
      emit RewardPaid(msg.sender, rewardRDPX);
    } else {
      uint256 rewardDPX = rewardsDPX[msg.sender];
      uint256 rewardRDPX = rewardsRDPX[msg.sender];
      if (rewardDPX > 0) {
        rewardsDPX[msg.sender] = 0;
        rewardsTokenDPX.safeTransfer(msg.sender, rewardDPX);
      }
      if (rewardRDPX > 0) {
        rewardsRDPX[msg.sender] = 0;
        rewardsTokenRDPX.safeTransfer(msg.sender, rewardRDPX);
      }
      emit RewardPaid(msg.sender, rewardDPX);
      emit RewardPaid(msg.sender, rewardRDPX);
    }
  }

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

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

  function notifyRewardAmount(uint256 rewardDPX, uint256 rewardRDPX)
    external
    override
    onlyRewardsDistribution
    setReward(address(0))
  {
    if (periodFinish == 0) {
      rewardRateDPX = rewardDPX.div(rewardsDuration.add(boostedTimePeriod));
      rewardRateRDPX = rewardRDPX.div(rewardsDuration.add(boostedTimePeriod));
      lastUpdateTime = block.timestamp;
      periodFinish = block.timestamp.add(rewardsDuration);
      boostedFinish = block.timestamp.add(boostedTimePeriod);
    } else {
      uint256 remaining = periodFinish.sub(block.timestamp);
      uint256 leftoverDPX = remaining.mul(rewardRateDPX);
      uint256 leftoverRDPX = remaining.mul(rewardRateRDPX);
      rewardRateDPX = rewardDPX.add(leftoverDPX).div(rewardsDuration);
      rewardRateRDPX = rewardRDPX.add(leftoverRDPX).div(rewardsDuration);
      lastUpdateTime = block.timestamp;
      periodFinish = block.timestamp.add(rewardsDuration);
    }
    emit RewardAdded(rewardDPX, rewardRDPX);
  }

  function addToContractWhitelist(address _contract) external onlyOwner returns (bool) {
    require(isContract(_contract), 'StakingRewards: Address must be a contract address');
    require(!whitelistedContracts[_contract], 'StakingRewards: Contract already whitelisted');

    whitelistedContracts[_contract] = true;

    emit AddToContractWhitelist(_contract);

    return true;
  }

  function removeFromContractWhitelist(address _contract) external onlyOwner returns (bool) {
    require(whitelistedContracts[_contract], 'StakingRewards: Contract not whitelisted');

    whitelistedContracts[_contract] = false;

    emit RemoveFromContractWhitelist(_contract);

    return true;
  }

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

  // Modifier is eligible sender modifier
  modifier isEligibleSender() {
    if (isContract(msg.sender))
      require(whitelistedContracts[msg.sender], 'StakingRewards: Contract must be whitelisted');
    _;
  }

  // Modifier Set Reward modifier
  modifier setReward(address account) {
    (rewardPerTokenStoredDPX, rewardPerTokenStoredRDPX) = rewardPerToken();
    lastUpdateTime = lastTimeRewardApplicable();
    if (account != address(0)) {
      (rewardsDPX[account], rewardsRDPX[account]) = earned(account);
      userDPXRewardPerTokenPaid[account] = rewardPerTokenStoredDPX;
      userRDPXRewardPerTokenPaid[account] = rewardPerTokenStoredRDPX;
    }
    _;
  }

  // Modifier *Update Reward modifier*
  modifier updateReward(address account) {
    (rewardPerTokenStoredDPX, rewardPerTokenStoredRDPX) = rewardPerToken();
    lastUpdateTime = lastTimeRewardApplicable();
    if (account != address(0)) {
      (rewardsDPX[account], rewardsRDPX[account]) = earned(account);
      userDPXRewardPerTokenPaid[account] = rewardPerTokenStoredDPX;
      userRDPXRewardPerTokenPaid[account] = rewardPerTokenStoredRDPX;
    }
    _;
  }

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

  event RewardUpdated(uint256 rewardDPX, uint256 rewardRDPX);
  event RewardAdded(uint256 rewardDPX, uint256 rewardRDPX);
  event Staked(address indexed user, uint256 amount);
  event Withdrawn(address indexed user, uint256 amount);
  event RewardPaid(address indexed user, uint256 reward);
  event RewardCompounded(address indexed user, uint256 rewardDPX);
  event AddToContractWhitelist(address indexed _contract);
  event RemoveFromContractWhitelist(address indexed _contract);
}

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

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

pragma solidity >=0.6.2 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity >=0.6.0 <0.8.0;

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

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 10 of 12 : Math.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

File 11 of 12 : IStakingRewards.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.7.6;

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

  function rewardPerToken() external view returns (uint256, uint256);

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

  function getRewardForDuration() external view returns (uint256, uint256);

  function totalSupply() external view returns (uint256);

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

  // Mutative

  function stake(uint256 amount) external payable;

  function withdraw(uint256 amount) external;

  function getReward(uint256 rewardsTokenID) external;

  function exit() external;
}

File 12 of 12 : RewardsDistributionRecipient.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity =0.7.6;

abstract contract RewardsDistributionRecipient {
  address public rewardsDistribution;

  function notifyRewardAmount(uint256 rewardDPX, uint256 rewardRDPX) external virtual;

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

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_rewardsTokenDPX","type":"address"},{"internalType":"address","name":"_rewardsTokenRDPX","type":"address"},{"internalType":"uint256","name":"_stakingRewardsGenesis","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"addToContractWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"stakingToken","type":"address"},{"internalType":"uint256","name":"rewardAmountDPX","type":"uint256"},{"internalType":"uint256","name":"rewardAmountRDPX","type":"uint256"},{"internalType":"uint256","name":"rewardsDuration","type":"uint256"},{"internalType":"uint256","name":"boostedTimePeriod","type":"uint256"},{"internalType":"uint256","name":"boost","type":"uint256"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"deploy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"notifyRewardAmounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"removeFromContractWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardsTokenDPX","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsTokenRDPX","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakingID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingRewardsGenesis","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakingRewardsInfoByStakingToken","outputs":[{"internalType":"address","name":"stakingRewards","type":"address"},{"internalType":"uint256","name":"rewardAmountDPX","type":"uint256"},{"internalType":"uint256","name":"rewardAmountRDPX","type":"uint256"},{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountDPX","type":"uint256"},{"internalType":"uint256","name":"amountRDPX","type":"uint256"}],"name":"withdrawRewardToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountDPX","type":"uint256"},{"internalType":"uint256","name":"amountRDPX","type":"uint256"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"withdrawRewardTokensFromContract","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60e060405234801561001057600080fd5b506040516139083803806139088339818101604052606081101561003357600080fd5b5080516020820151604090920151909190600061004e6100fe565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35060018055428110156100db5760405162461bcd60e51b81526004018080602001828103825260348152602001806138d46034913960400191505060405180910390fd5b6001600160601b0319606093841b81166080529190921b1660a05260c052610102565b3390565b60805160601c60a05160601c60c05161377d6101576000398061060a5280610e715250806108425280610b5e5280610d6f52806110b5525080610310528061074b5280610a945280610d4e525061377d6000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80639efbfd1011610097578063ba1572b811610066578063ba1572b814610297578063cfc48098146102b4578063e363208e146102e0578063f2fde38b146102e8576100f5565b80639efbfd10146101de578063a0928c1114610228578063a11273b314610242578063ae741d8d1461028f576100f5565b80633c6b16ab116100d35780633c6b16ab14610175578063715018a6146101925780638da5cb5b1461019a57806390155f9e146101a2576100f5565b80630131c870146100fa5780632aff67e71461011e5780633b03cb511461014c575b600080fd5b61010261030e565b604080516001600160a01b039092168252519081900360200190f35b61014a6004803603604081101561013457600080fd5b506001600160a01b038135169060200135610332565b005b61014a6004803603606081101561016257600080fd5b508035906020810135906040013561045f565b61014a6004803603602081101561018b57600080fd5b50356105af565b61014a610967565b610102610a0a565b6101c5600480360360408110156101b857600080fd5b5080359060200135610a19565b6040805192835260208301919091528051918290030190f35b61014a600480360360e08110156101f457600080fd5b506001600160a01b038135169060208101359060408101359060608101359060808101359060a08101359060c00135610bdf565b610230610e6f565b60408051918252519081900360200190f35b61025f6004803603602081101561025857600080fd5b5035610e93565b604080516001600160a01b0390951685526020850193909352838301919091526060830152519081900360800190f35b61014a610ec6565b610230600480360360208110156102ad57600080fd5b5035610f96565b61014a600480360360408110156102ca57600080fd5b506001600160a01b038135169060200135610fb7565b6101026110b3565b61014a600480360360208110156102fe57600080fd5b50356001600160a01b03166110d7565b7f000000000000000000000000000000000000000000000000000000000000000081565b61033a6111d1565b6000546001600160a01b0390811691161461038b576040805162461bcd60e51b815260206004820181905260248201526000805160206200363e833981519152604482015290519081900360640190fd5b600081815260036020526040902080546001600160a01b03166103e05760405162461bcd60e51b8152600401808060200182810382526032815260200180620035c26032913960400191505060405180910390fd5b805460408051635661d00360e11b81526001600160a01b0386811660048301529151919092169163acc3a0069160248083019260209291908290030181600087803b15801561042e57600080fd5b505af1158015610442573d6000803e3d6000fd5b505050506040513d602081101561045857600080fd5b5050505050565b6104676111d1565b6000546001600160a01b039081169116146104b8576040805162461bcd60e51b815260206004820181905260248201526000805160206200363e833981519152604482015290519081900360640190fd5b60006104c2610a0a565b90506001600160a01b0381163314156105a957600082815260036020526040902080546001600160a01b031661052a5760405162461bcd60e51b8152600401808060200182810382526037815260200180620037116037913960400191505060405180910390fd5b8054604080516309ca7d6160e21b8152600481018890526024810187905281516001600160a01b0390931692632729f584926044808401939192918290030181600087803b15801561057b57600080fd5b505af115801561058f573d6000803e3d6000fd5b505050506040513d60408110156105a557600080fd5b5050505b50505050565b6105b76111d1565b6000546001600160a01b03908116911614610608576040805162461bcd60e51b815260206004820181905260248201526000805160206200363e833981519152604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000004210156106685760405162461bcd60e51b8152600401808060200182810382526034815260200180620036dd6034913960400191505060405180910390fd5b600081815260036020526040902080546001600160a01b03166106bd5760405162461bcd60e51b8152600401808060200182810382526037815260200180620037116037913960400191505060405180910390fd5b60008160010154116107015760405162461bcd60e51b8152600401808060200182810382526024815260200180620035f46024913960400191505060405180910390fd5b6000806000836001015411156107fe5760018301805460009182905584546040805163a9059cbb60e01b81526001600160a01b0392831660048201526024810184905290519295507f00000000000000000000000000000000000000000000000000000000000000009091169263a9059cbb926044808401936020939083900390910190829087803b15801561079657600080fd5b505af11580156107aa573d6000803e3d6000fd5b505050506040513d60208110156107c057600080fd5b50516107fe5760405162461bcd60e51b815260040180806020018281038252603a815260200180620036a3603a913960400191505060405180910390fd5b6002830154156108f6575060028201805460009182905583546040805163a9059cbb60e01b81526001600160a01b03928316600482015260248101849052905192937f00000000000000000000000000000000000000000000000000000000000000009092169263a9059cbb92604480840193602093929083900390910190829087803b15801561088e57600080fd5b505af11580156108a2573d6000803e3d6000fd5b505050506040513d60208110156108b857600080fd5b50516108f65760405162461bcd60e51b815260040180806020018281038252603a815260200180620036a3603a913960400191505060405180910390fd5b82546040805163246132f960e01b8152600481018590526024810184905290516001600160a01b039092169163246132f99160448082019260009290919082900301818387803b15801561094957600080fd5b505af115801561095d573d6000803e3d6000fd5b5050505050505050565b61096f6111d1565b6000546001600160a01b039081169116146109c0576040805162461bcd60e51b815260206004820181905260248201526000805160206200363e833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b600080610a246111d1565b6000546001600160a01b03908116911614610a75576040805162461bcd60e51b815260206004820181905260248201526000805160206200363e833981519152604482015290519081900360640190fd5b6000610a7f610a0a565b90506001600160a01b038116331415610bd6577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a9059cbb82876040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610b0957600080fd5b505af1158015610b1d573d6000803e3d6000fd5b505050506040513d6020811015610b3357600080fd5b50506040805163a9059cbb60e01b81526001600160a01b0383811660048301526024820187905291517f00000000000000000000000000000000000000000000000000000000000000009092169163a9059cbb916044808201926020929091908290030181600087803b158015610ba957600080fd5b505af1158015610bbd573d6000803e3d6000fd5b505050506040513d6020811015610bd357600080fd5b50505b50929391925050565b610be76111d1565b6000546001600160a01b03908116911614610c38576040805162461bcd60e51b815260206004820181905260248201526000805160206200363e833981519152604482015290519081900360640190fd5b600081815260036020819052604090912090810154821415610ca1576040805162461bcd60e51b815260206004820152601760248201527f5374616b696e67494420616c72656164792074616b656e000000000000000000604482015290519081900360640190fd5b60008711610cf6576040805162461bcd60e51b815260206004820152601960248201527f496e76616c6964204450582072657761726420616d6f756e7400000000000000604482015290519081900360640190fd5b60008611610d4b576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420724450582072657761726420616d6f756e74000000000000604482015290519081900360640190fd5b307f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000008a88888888604051610d9f906111d5565b6001600160a01b0398891681529688166020880152948716604080880191909152939096166060860152608085019190915260a084015260c083019390935260e082015290519081900361010001906000f080158015610e03573d6000803e3d6000fd5b5081546001600160a01b0319166001600160a01b0391909116178155600180820197909755600280820196909655600301819055845495860185556000949094525050507f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace9091015550565b7f000000000000000000000000000000000000000000000000000000000000000081565b600360208190526000918252604090912080546001820154600283015492909301546001600160a01b0390911692919084565b610ece6111d1565b6000546001600160a01b03908116911614610f1f576040805162461bcd60e51b815260206004820181905260248201526000805160206200363e833981519152604482015290519081900360640190fd5b600254610f5e5760405162461bcd60e51b81526004018080602001828103825260458152602001806200365e6045913960600191505060405180910390fd5b60005b600254811015610f9357610f8b60028281548110610f7b57fe5b90600052602060002001546105af565b600101610f61565b50565b60028181548110610fa657600080fd5b600091825260209091200154905081565b610fbf6111d1565b6000546001600160a01b03908116911614611010576040805162461bcd60e51b815260206004820181905260248201526000805160206200363e833981519152604482015290519081900360640190fd5b600081815260036020526040902080546001600160a01b03166110655760405162461bcd60e51b8152600401808060200182810382526032815260200180620035c26032913960400191505060405180910390fd5b80546040805163c3d9ed3960e01b81526001600160a01b0386811660048301529151919092169163c3d9ed399160248083019260209291908290030181600087803b15801561042e57600080fd5b7f000000000000000000000000000000000000000000000000000000000000000081565b6110df6111d1565b6000546001600160a01b03908116911614611130576040805162461bcd60e51b815260206004820181905260248201526000805160206200363e833981519152604482015290519081900360640190fd5b6001600160a01b0381166111765760405162461bcd60e51b8152600401808060200182810382526026815260200180620036186026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6123de80620011e48339019056fe608060405260006006556000600755600060085560006009556000600a5534801561002957600080fd5b506040516123de3803806123de833981810160405261010081101561004d57600080fd5b508051602082015160408301516060840151608085015160a086015160c087015160e09097015160018055959694959394929391929091600061008e610144565b600280546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600380546001600160a01b03199081166001600160a01b03998a16179091556004805482169789169790971790965560058054871695881695909517909455600080549095169690951695909517909255600b91909155600f92909255600655601055610148565b3390565b612287806101576000396000f3fe6080604052600436106102245760003560e01c80638da5cb5b11610123578063c11e1e4b116100ab578063e363208e1161006f578063e363208e146106cf578063e9fad8ee146106e4578063ebe2b12b146106f9578063f2fde38b1461070e578063f69e20461461074157610224565b8063c11e1e4b1461062a578063c3d9ed391461065d578063c8f33c9114610690578063c9b6b2b1146106a5578063cd3daf9d146106ba57610224565b8063ac2c5413116100f2578063ac2c541314610585578063acc3a0061461059a578063ad46a40c146105cd578063af640d0f146105e2578063bc1e25dc146105f757610224565b80638da5cb5b1461050b578063a1411e6714610520578063a66f42c014610553578063a694fc3a1461056857610224565b80632e1a7d4d116101b157806370a082311161017557806370a0823114610484578063715018a6146104b757806372f702f3146104cc57806380faa57d146104e15780638a0dfa0d146104f657610224565b80632e1a7d4d146103e8578063386a95251461041257806338736f4914610427578063391feebb1461043c5780633fc6df6e1461046f57610224565b806318156416116101f8578063181564161461031457806318160ddd146103475780631c4b774b1461035c578063246132f9146103885780632729f584146103b857610224565b80628cc262146102295780630131c87014610275578063080b3ead146102a657806316279055146102cd575b600080fd5b34801561023557600080fd5b5061025c6004803603602081101561024c57600080fd5b50356001600160a01b0316610756565b6040805192835260208301919091528051918290030190f35b34801561028157600080fd5b5061028a61082d565b604080516001600160a01b039092168252519081900360200190f35b3480156102b257600080fd5b506102bb61083c565b60408051918252519081900360200190f35b3480156102d957600080fd5b50610300600480360360208110156102f057600080fd5b50356001600160a01b0316610842565b604080519115158252519081900360200190f35b34801561032057600080fd5b506102bb6004803603602081101561033757600080fd5b50356001600160a01b0316610848565b34801561035357600080fd5b506102bb61085a565b34801561036857600080fd5b506103866004803603602081101561037f57600080fd5b5035610860565b005b34801561039457600080fd5b50610386600480360360408110156103ab57600080fd5b5080359060200135610b71565b3480156103c457600080fd5b5061025c600480360360408110156103db57600080fd5b5080359060200135610d6c565b3480156103f457600080fd5b506103866004803603602081101561040b57600080fd5b5035610e1b565b34801561041e57600080fd5b506102bb611012565b34801561043357600080fd5b506102bb611018565b34801561044857600080fd5b506103006004803603602081101561045f57600080fd5b50356001600160a01b031661101e565b34801561047b57600080fd5b5061028a611033565b34801561049057600080fd5b506102bb600480360360208110156104a757600080fd5b50356001600160a01b0316611042565b3480156104c357600080fd5b5061038661105d565b3480156104d857600080fd5b5061028a6110ff565b3480156104ed57600080fd5b506102bb61110e565b34801561050257600080fd5b506102bb611123565b34801561051757600080fd5b5061028a611129565b34801561052c57600080fd5b506102bb6004803603602081101561054357600080fd5b50356001600160a01b0316611138565b34801561055f57600080fd5b506102bb61114a565b6103866004803603602081101561057e57600080fd5b5035611150565b34801561059157600080fd5b506102bb611347565b3480156105a657600080fd5b50610300600480360360208110156105bd57600080fd5b50356001600160a01b031661134d565b3480156105d957600080fd5b506102bb611494565b3480156105ee57600080fd5b506102bb61149a565b34801561060357600080fd5b506102bb6004803603602081101561061a57600080fd5b50356001600160a01b03166114a0565b34801561063657600080fd5b506102bb6004803603602081101561064d57600080fd5b50356001600160a01b03166114b2565b34801561066957600080fd5b506103006004803603602081101561068057600080fd5b50356001600160a01b03166114c4565b34801561069c57600080fd5b506102bb6115c3565b3480156106b157600080fd5b506102bb6115c9565b3480156106c657600080fd5b5061025c6115cf565b3480156106db57600080fd5b5061028a6117be565b3480156106f057600080fd5b506103866117cd565b34801561070557600080fd5b506102bb6117f2565b34801561071a57600080fd5b506103866004803603602081101561073157600080fd5b50356001600160a01b03166117f8565b34801561074d57600080fd5b506103866118f1565b6000806000806107646115cf565b6001600160a01b0387166000908152601460209081526040808320546012909252909120549294509092506107db916107d590670de0b6b3a7640000906107cf906107b0908890611b03565b6001600160a01b038b1660009081526016602052604090205490611b4e565b90611ba7565b90611be9565b6001600160a01b038616600090815260156020908152604080832054601390925290912054919550610824916107d590670de0b6b3a7640000906107cf906107b0908790611b03565b92505050915091565b6003546001600160a01b031681565b60095481565b3b151590565b60136020526000908152604090205481565b60175490565b600260015414156108a6576040805162461bcd60e51b815260206004820152601f602482015260008051602061209f833981519152604482015290519081900360640190fd5b6002600155336108b46115cf565b600e55600d556108c261110e565b600c556001600160a01b03811615610920576108dd81610756565b6001600160a01b0383166000908152601460209081526040808320601583528184209490945593909255600d546012835283822055600e54601390925291909120555b816109ec573360009081526014602052604090205480610987576040805162461bcd60e51b815260206004820152601d60248201527f63616e206e6f7420776974686472617720302044505820726577617264000000604482015290519081900360640190fd5b336000818152601460205260408120556003546109b0916001600160a01b039091169083611c43565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a250610b69565b8160011415610a80573360009081526015602052604090205480610a57576040805162461bcd60e51b815260206004820152601e60248201527f63616e206e6f7420776974686472617720302052445058207265776172640000604482015290519081900360640190fd5b336000818152601560205260408120556004546109b0916001600160a01b039091169083611c43565b336000908152601460209081526040808320546015909252909120548115610acb5733600081815260146020526040812055600354610acb916001600160a01b039091169084611c43565b8015610afa5733600081815260156020526040812055600454610afa916001600160a01b039091169083611c43565b60408051838152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a260408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a250505b505060018055565b6000546001600160a01b03163314610bba5760405162461bcd60e51b815260040180806020018281038252602a8152602001806121d6602a913960400191505060405180910390fd5b6000610bc46115cf565b600e55600d55610bd261110e565b600c556001600160a01b03811615610c3057610bed81610756565b6001600160a01b0383166000908152601460209081526040808320601583528184209490945593909255600d546012835283822055600e54601390925291909120555b600754610ca557610c58610c51600f54600b54611be990919063ffffffff16565b8490611ba7565b600955600f54600b54610c7691610c6f9190611be9565b8390611ba7565b600a5542600c819055600b54610c8c9190611be9565b600755600f54610c9d904290611be9565b600855610d2c565b600754600090610cb59042611b03565b90506000610cce60095483611b4e90919063ffffffff16565b90506000610ce7600a5484611b4e90919063ffffffff16565b600b54909150610cfb906107cf8885611be9565b600955600b54610d0f906107cf8784611be9565b600a5542600c819055600b54610d259190611be9565b6007555050505b604080518481526020810184905281517f6c07ee05dcf262f13abf9d87b846ee789d2f90fe991d495acd7d7fc109ee1f55929181900390910190a1505050565b600080610d77611c9a565b6002546001600160a01b03908116911614610dc7576040805162461bcd60e51b8152602060048201819052602482015260008051602061218a833981519152604482015290519081900360640190fd5b6000610dd1611129565b90506001600160a01b038116331415610e1257600354610dfb906001600160a01b03168287611c43565b600454610e12906001600160a01b03168286611c43565b50929391925050565b60026001541415610e61576040805162461bcd60e51b815260206004820152601f602482015260008051602061209f833981519152604482015290519081900360640190fd5b600260015533610e6f6115cf565b600e55600d55610e7d61110e565b600c556001600160a01b03811615610edb57610e9881610756565b6001600160a01b0383166000908152601460209081526040808320601583528184209490945593909255600d546012835283822055600e54601390925291909120555b60008211610f24576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b33600090815260166020526040902054821115610f7e576040805162461bcd60e51b8152602060048201526013602482015272496e737566666963656e742062616c616e636560681b604482015290519081900360640190fd5b601754610f8b9083611b03565b60175533600090815260166020526040902054610fa89083611b03565b33600081815260166020526040902091909155600554610fd4916001600160a01b039091169084611c43565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a2505060018055565b600b5481565b600d5481565b60116020526000908152604090205460ff1681565b6000546001600160a01b031681565b6001600160a01b031660009081526016602052604090205490565b611065611c9a565b6002546001600160a01b039081169116146110b5576040805162461bcd60e51b8152602060048201819052602482015260008051602061218a833981519152604482015290519081900360640190fd5b6002546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600280546001600160a01b0319169055565b6005546001600160a01b031681565b60008061111d42600754611c9e565b91505090565b600a5481565b6002546001600160a01b031690565b60156020526000908152604090205481565b60065481565b61115933610842565b156111ac573360009081526011602052604090205460ff166111ac5760405162461bcd60e51b815260040180806020018281038252602c8152602001806121aa602c913960400191505060405180910390fd5b600260015414156111f2576040805162461bcd60e51b815260206004820152601f602482015260008051602061209f833981519152604482015290519081900360640190fd5b6002600155336112006115cf565b600e55600d5561120e61110e565b600c556001600160a01b0381161561126c5761122981610756565b6001600160a01b0383166000908152601460209081526040808320601583528184209490945593909255600d546012835283822055600e54601390925291909120555b600082116112b2576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b6017546112bf9083611be9565b601755336000908152601660205260409020546112dc9083611be9565b33600081815260166020526040902091909155600554611309916001600160a01b03909116903085611cb4565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2505060018055565b60085481565b6000611357611c9a565b6002546001600160a01b039081169116146113a7576040805162461bcd60e51b8152602060048201819052602482015260008051602061218a833981519152604482015290519081900360640190fd5b6113b082610842565b6113eb5760405162461bcd60e51b81526004018080602001828103825260328152602001806121376032913960400191505060405180910390fd5b6001600160a01b03821660009081526011602052604090205460ff16156114435760405162461bcd60e51b815260040180806020018281038252602c8152602001806120bf602c913960400191505060405180910390fd5b6001600160a01b038216600081815260116020526040808220805460ff19166001179055517ffbd3cde7ff522a917e485c8ed2a6e87590887ab399f5ac312307903f498543079190a2506001919050565b600e5481565b60105481565b60126020526000908152604090205481565b60146020526000908152604090205481565b60006114ce611c9a565b6002546001600160a01b0390811691161461151e576040805162461bcd60e51b8152602060048201819052602482015260008051602061218a833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526011602052604090205460ff166115755760405162461bcd60e51b815260040180806020018281038252602881526020018061222a6028913960400191505060405180910390fd5b6001600160a01b038216600081815260116020526040808220805460ff19169055517f8e81447740597754af5db3e176253a36f7981a9549f48ace3f0cb233913f9d859190a2506001919050565b600c5481565b600f5481565b600080601754600014156115ea575050600d54600e546117ba565b60085442101561169157600061164861163f6017546107cf670de0b6b3a7640000611639611625600654600954611b4e90919063ffffffff16565b611639600c5461163361110e565b90611b03565b90611b4e565b600d5490611be9565b9050600061168461167b6017546107cf670de0b6b3a7640000611639611625600654600a54611b4e90919063ffffffff16565b600e5490611be9565b9193509091506117ba9050565b600854600c5410156117625760006117066116c86017546107cf670de0b6b3a764000061163960095461163960085461163361110e565b6107d561163f6017546107cf670de0b6b3a76400006116396116f7600654600954611b4e90919063ffffffff16565b600c5460085461163991611b03565b905060006116846117336017546107cf670de0b6b3a7640000611639600a5461163960085461163361110e565b6107d561167b6017546107cf670de0b6b3a76400006116396116f7600654600a54611b4e90919063ffffffff16565b600061178d61163f6017546107cf670de0b6b3a7640000611639600954611639600c5461163361110e565b9050600061168461167b6017546107cf670de0b6b3a7640000611639600a54611639600c5461163361110e565b9091565b6004546001600160a01b031681565b6117d76002610860565b336000908152601660205260409020546117f090610e1b565b565b60075481565b611800611c9a565b6002546001600160a01b03908116911614611850576040805162461bcd60e51b8152602060048201819052602482015260008051602061218a833981519152604482015290519081900360640190fd5b6001600160a01b0381166118955760405162461bcd60e51b81526004018080602001828103825260268152602001806120eb6026913960400191505060405180910390fd5b6002546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600280546001600160a01b0319166001600160a01b0392909216919091179055565b60026001541415611937576040805162461bcd60e51b815260206004820152601f602482015260008051602061209f833981519152604482015290519081900360640190fd5b6002600155336119456115cf565b600e55600d5561195361110e565b600c556001600160a01b038116156119b15761196e81610756565b6001600160a01b0383166000908152601460209081526040808320601583528184209490945593909255600d546012835283822055600e54601390925291909120555b3360009081526014602052604090205480611a13576040805162461bcd60e51b815260206004820152601760248201527f7374616b652061646472657373206e6f7420666f756e64000000000000000000604482015290519081900360640190fd5b6005546003546001600160a01b03908116911614611a78576040805162461bcd60e51b815260206004820152601d60248201527f43616e2774207374616b65207468652072657761726420746f6b656e2e000000604482015290519081900360640190fd5b33600090815260146020526040812055601754611a959082611be9565b60175533600090815260166020526040902054611ab29082611be9565b33600081815260166020908152604091829020939093558051848152905191927f6675fb32d259af2b7287aeeead9dc867fe8ca2cf653265dfadd302512ab59f0692918290030190a2505060018055565b6000611b4583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611d14565b90505b92915050565b600082611b5d57506000611b48565b82820282848281611b6a57fe5b0414611b455760405162461bcd60e51b81526004018080602001828103825260218152602001806121696021913960400191505060405180910390fd5b6000611b4583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611db0565b600082820183811015611b45576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611c95908490611e15565b505050565b3390565b6000818310611cad5781611b45565b5090919050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611d0e908590611e15565b50505050565b60008184841115611da35760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611d68578181015183820152602001611d50565b50505050905090810190601f168015611d955780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50508183035b9392505050565b60008183611dff5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611d68578181015183820152602001611d50565b506000838581611e0b57fe5b0495945050505050565b6000611e6a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611ec69092919063ffffffff16565b805190915015611c9557808060200190516020811015611e8957600080fd5b5051611c955760405162461bcd60e51b815260040180806020018281038252602a815260200180612200602a913960400191505060405180910390fd5b6060611ed58484600085611edd565b949350505050565b606082471015611f1e5760405162461bcd60e51b81526004018080602001828103825260268152602001806121116026913960400191505060405180910390fd5b611f2785610842565b611f78576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310611fb65780518252601f199092019160209182019101611f97565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612018576040519150601f19603f3d011682016040523d82523d6000602084013e61201d565b606091505b509150915061202d828286612038565b979650505050505050565b60608315612047575081611da9565b8251156120575782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315611d68578181015183820152602001611d5056fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c005374616b696e67526577617264733a20436f6e747261637420616c72656164792077686974656c69737465644f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5374616b696e67526577617264733a2041646472657373206d757374206265206120636f6e74726163742061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725374616b696e67526577617264733a20436f6e7472616374206d7573742062652077686974656c697374656443616c6c6572206973206e6f742052657761726473446973747269627574696f6e20636f6e74726163745361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645374616b696e67526577617264733a20436f6e7472616374206e6f742077686974656c6973746564a26469706673582212206400d657659722aa37069f750df6956dc2079e7cd1833e67a53800e4877395d264736f6c634300070600335374616b696e6752657761726473466163746f72793a205374616b696e6752657761726473206e6f74206465706c6f79656452657761726420616d6f756e74206d7573742062652067726561746572207468616e20304f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725374616b696e6752657761726473466163746f72793a3a6e6f74696679526577617264416d6f756e74733a2063616c6c6564206265666f726520616e79206465706c6f79735374616b696e6752657761726473466163746f72793a3a6e6f74696679526577617264416d6f756e743a207472616e73666572206661696c65645374616b696e6752657761726473466163746f72793a3a6e6f74696679526577617264416d6f756e743a206e6f742072656164795374616b696e6752657761726473466163746f72793a3a6e6f74696679526577617264416d6f756e743a206e6f74206465706c6f796564a2646970667358221220d4f538cb7cfb90ef6a089407b1d05425717bf954fb548e6cf4de581e65bdfc3464736f6c634300070600335374616b696e6752657761726473466163746f72793a3a636f6e7374727563746f723a2067656e6573697320746f6f20736f6f6e0000000000000000000000006c2c06790b3e3e3c38e12ee22f8183b37a13ee5500000000000000000000000032eb7902d4134bf98a28b963d26de779af92a2120000000000000000000000000000000000000000000000000000000061618d3d

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

0000000000000000000000006c2c06790b3e3e3c38e12ee22f8183b37a13ee5500000000000000000000000032eb7902d4134bf98a28b963d26de779af92a2120000000000000000000000000000000000000000000000000000000061618d3d

-----Decoded View---------------
Arg [0] : _rewardsTokenDPX (address): 0x6c2c06790b3e3e3c38e12ee22f8183b37a13ee55
Arg [1] : _rewardsTokenRDPX (address): 0x32eb7902d4134bf98a28b963d26de779af92a212
Arg [2] : _stakingRewardsGenesis (uint256): 1633783101

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000006c2c06790b3e3e3c38e12ee22f8183b37a13ee55
Arg [1] : 00000000000000000000000032eb7902d4134bf98a28b963d26de779af92a212
Arg [2] : 0000000000000000000000000000000000000000000000000000000061618d3d


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