Contract 0x3caae25ee616f2c8e13c74da0813402eae3f496b 4

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x57dd876db12bcf2f797fa69425ea56c2dba0fc4200bbf616d3437b4fabd97643Allocate719099172023-03-20 22:01:271 min ago0xb1f47275b57e3288545a21846d45f754a78cef21 IN  Camelot: xGRAIL Token0 ETH0.00007194 0.1
0x15579d53eed94984be1905690666841e7dcd141c861bff6b845a4b41bd486d4eAllocate719098012023-03-20 22:00:571 min ago0x40d158f19fc5fedf1e527062964952219fedf1f7 IN  Camelot: xGRAIL Token0 ETH0.00006648 0.1
0x09b98c24b1cdad5189cdc78cb6df9a27c758059184004459f06b783ca0404510Convert719097062023-03-20 22:00:321 min ago0x40d158f19fc5fedf1e527062964952219fedf1f7 IN  Camelot: xGRAIL Token0 ETH0.00004099 0.1
0xef4c4582ca611103e0637d2c61d5ca3e4c2c217e1345f0bc2dd17764dd7fef92Allocate719090862023-03-20 21:57:464 mins ago0x41ed288dbf8493310d2bd57067c226a96610d2f9 IN  Camelot: xGRAIL Token0 ETH0.0000810.1
0x9ab06d305428b3649ba82fdc63899b2d7a437ad4d371e1ff5154c5f354f4fd60Approve Usage719089512023-03-20 21:57:095 mins ago0x41ed288dbf8493310d2bd57067c226a96610d2f9 IN  Camelot: xGRAIL Token0 ETH0.000046010.1
0xada71bee0c528ce857ff43594c445198539a74b19f665e332c44099dba35486aDeallocate719088152023-03-20 21:56:335 mins ago0x41ed288dbf8493310d2bd57067c226a96610d2f9 IN  Camelot: xGRAIL Token0 ETH0.000073360.1
0x53d04b7baaa2690845f6ae8c6593ffe15c4bc44774befdcf44c4afe37ad30779Convert719083132023-03-20 21:54:258 mins ago0x77adab35d82833c22008cfefc7e2b03f232602db IN  Camelot: xGRAIL Token0 ETH0.00004322 0.1
0x6125c15c773a5ce2322f15bc36cace26c7ec77fb857566a4332abb7912a82876Allocate719076012023-03-20 21:51:1811 mins ago0x2dcf3613f8b28c8ac645f58bd1d8ee1c539306a0 IN  Camelot: xGRAIL Token0 ETH0.00007812 0.1
0x0b4024d690798da0a02dcd9aec2dbaf12d45002a526758c96f3970356762a772Allocate719053752023-03-20 21:41:4820 mins ago0x9112790248638d4bc4a7686f15fcdcbe4ae97430 IN  Camelot: xGRAIL Token0 ETH0.00010538 0.1
0x7e5013b6469a9d2448c20ec52bf291235f716bc68d85e932cbad5e602122857aAllocate719053562023-03-20 21:41:4220 mins ago0x76c8a1c74fdc88072f4582830ddbe588388c055b IN  Camelot: xGRAIL Token0 ETH0.000069490.1
0x08b2e1e4ba66bd15efa9b36290f6bf20d4976d4a42272a260b34b62bdb0859e2Deallocate719052692023-03-20 21:41:2021 mins ago0x76c8a1c74fdc88072f4582830ddbe588388c055b IN  Camelot: xGRAIL Token0 ETH0.000104160.1
0xdf0649a3804ed2b3a34efc264c4ee32bd36796cddc7894c29de0684c875b4c31Allocate719052432023-03-20 21:41:1321 mins ago0x7a2c47ff062049b337bc39d8d51c5b2b71c2d2c7 IN  Camelot: xGRAIL Token0 ETH0.00008256 0.1
0x6f2b4d5c20f0d29ab1380a8669c1e14dd9b56391bb5c87ae6b4c7e739ddff601Approve Usage719051932023-03-20 21:40:5921 mins ago0x7a2c47ff062049b337bc39d8d51c5b2b71c2d2c7 IN  Camelot: xGRAIL Token0 ETH0.00004888 0.1
0x588a357ae29b913a11040753b386084df2b50b7333588041e7a96ac3b88261ebAllocate719042292023-03-20 21:36:4025 mins ago0x76c8a1c74fdc88072f4582830ddbe588388c055b IN  Camelot: xGRAIL Token0 ETH0.000082770.1
0x68a41b1c39a98f4a5c8c8ed03abf9ff98eef4083ba4ee5bb64768f4df0792be0Approve Usage719041262023-03-20 21:36:2026 mins ago0x76c8a1c74fdc88072f4582830ddbe588388c055b IN  Camelot: xGRAIL Token0 ETH0.000050710.1
0xb7a5f73bc80231597386b19c16e64a094a8c5991ed213a04b5db9406351429c9Convert719038612023-03-20 21:35:0827 mins ago0x7a2c47ff062049b337bc39d8d51c5b2b71c2d2c7 IN  Camelot: xGRAIL Token0 ETH0.00004515 0.1
0x47029bd58ccce98a610563febc0b5ffc3e1190b9951af671e2edf43bb33dd960Allocate719009732023-03-20 21:22:3939 mins ago0x94172ef86cb242b61147fccadf42a38dd03f7d49 IN  Camelot: xGRAIL Token0 ETH0.000112930.1
0x3e8f8d45f2b09e096b572921d1be2bd7e77c09db1e39bb1537d3c4820bac018cAllocate718995292023-03-20 21:16:2746 mins ago0x7c296a96c21a007ba044ab17ae4e3f3444a5a568 IN  Camelot: xGRAIL Token0 ETH0.00008403 0.1
0xa66e78b2882766f14dd9694ec951a8356ab4259713ad4556bdb66adcc932f91eApprove Usage718994702023-03-20 21:16:1246 mins ago0x7c296a96c21a007ba044ab17ae4e3f3444a5a568 IN  Camelot: xGRAIL Token0 ETH0.00004996 0.1
0x8fb82217ba570fbe8708b792eefa828587d476bbc1a31b8320a0a5d92935c947Convert718992622023-03-20 21:15:1747 mins ago0x7c296a96c21a007ba044ab17ae4e3f3444a5a568 IN  Camelot: xGRAIL Token0 ETH0.00004385 0.1
0xa2978e49105af4763ee128b01ef17d758be7261a0db193473f9f671d74da399fRedeem718976592023-03-20 21:08:2554 mins ago0x5b558496fa9f93942974740d6609da174e489ad5 IN  Camelot: xGRAIL Token0 ETH0.00007455 0.1
0x37c7b9d9dedb4f51fd59c58b61f69ef40be82791dd6ca011ae9f6ce41b5fe7dbAllocate718975042023-03-20 21:07:4654 mins ago0x1805de850c478769860504978770d9afbf082071 IN  Camelot: xGRAIL Token0 ETH0.00008987 0.1
0xee49db1cb1b1d029ed57bf79dd793cf4ad8a6203727190c26193aac66c4207ecApprove Usage718973732023-03-20 21:07:1255 mins ago0x1805de850c478769860504978770d9afbf082071 IN  Camelot: xGRAIL Token0 ETH0.00005275 0.1
0x14302d08308be75353f9474a597b8428fb02ceadaeacdca91c6dc9399ca2bb1dConvert718969682023-03-20 21:05:2957 mins ago0x37d0b63bfdb172a2b0125dad6f844daad5789782 IN  Camelot: xGRAIL Token0 ETH0.00004639 0.1
0x180f1793f76c5d65ea70d186c34dc4e397c7a654efc6ce73a9d5b9ad9a0bbd67Redeem718966242023-03-20 21:04:0658 mins ago0x9ea2259b731cabd28fb39e0acd4b671c93183f49 IN  Camelot: xGRAIL Token0 ETH0.00008443 0.1
[ Download CSV Export 

OVERVIEW

Camelot is an ecosystem-focused and community-driven DEX built on Arbitrum.

Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x57dd876db12bcf2f797fa69425ea56c2dba0fc4200bbf616d3437b4fabd97643719099172023-03-20 22:01:271 min ago Camelot: xGRAIL Token 0x594fb2ec5c7adf3cb68db1e90ace58e643c118a50 ETH
0x15579d53eed94984be1905690666841e7dcd141c861bff6b845a4b41bd486d4e719098012023-03-20 22:00:571 min ago Camelot: xGRAIL Token 0x594fb2ec5c7adf3cb68db1e90ace58e643c118a50 ETH
0x09b98c24b1cdad5189cdc78cb6df9a27c758059184004459f06b783ca0404510719097062023-03-20 22:00:321 min ago Camelot: xGRAIL Token Camelot: GRAIL Token0 ETH
0x708e434385557e61051e2eafd3f8f5e5cc71b88a81387f4126f33662ed2004cc719096982023-03-20 22:00:292 mins ago Camelot: Dividends V2 Camelot: xGRAIL Token0 ETH
0x708e434385557e61051e2eafd3f8f5e5cc71b88a81387f4126f33662ed2004cc719096982023-03-20 22:00:292 mins ago Camelot: Dividends V2 Camelot: xGRAIL Token0 ETH
0x2eadfb3d985adc3075bc25bd611719b97d5bfd5330fa93cca2cf40a5f6394a51719096822023-03-20 22:00:252 mins ago 0xf952f00ed83999625a4d6c72a3671ed72b2bcafb Camelot: xGRAIL Token0 ETH
0x2eadfb3d985adc3075bc25bd611719b97d5bfd5330fa93cca2cf40a5f6394a51719096822023-03-20 22:00:252 mins ago 0xf952f00ed83999625a4d6c72a3671ed72b2bcafb Camelot: xGRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago Camelot: xGRAIL Token Camelot: GRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago 0xe20ce7d800934ec568fe94e135e84b1e919abb2a Camelot: xGRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago Camelot: xGRAIL Token Camelot: GRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago 0xe20ce7d800934ec568fe94e135e84b1e919abb2a Camelot: xGRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago Camelot: xGRAIL Token Camelot: GRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago 0xe20ce7d800934ec568fe94e135e84b1e919abb2a Camelot: xGRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago Camelot: xGRAIL Token Camelot: GRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago 0xe20ce7d800934ec568fe94e135e84b1e919abb2a Camelot: xGRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago Camelot: xGRAIL Token Camelot: GRAIL Token0 ETH
0x8e46ccbbbf9a4ae58ea0e4c0ff17fe88f0aed00f69dd03ed556bb78ba3a1fd16719096652023-03-20 22:00:212 mins ago 0xe20ce7d800934ec568fe94e135e84b1e919abb2a Camelot: xGRAIL Token0 ETH
0x81f673f7ddfc3ed822acf513b96f58d0ef7f380c34a54178aa28fbf2fea10fa0719091032023-03-20 21:57:514 mins ago 0x7fe0265ebcee930ecb8f9f3d30aa20a8d1b8e521 Camelot: xGRAIL Token0 ETH
0x81f673f7ddfc3ed822acf513b96f58d0ef7f380c34a54178aa28fbf2fea10fa0719091032023-03-20 21:57:514 mins ago 0x7fe0265ebcee930ecb8f9f3d30aa20a8d1b8e521 Camelot: xGRAIL Token0 ETH
0xef4c4582ca611103e0637d2c61d5ca3e4c2c217e1345f0bc2dd17764dd7fef92719090862023-03-20 21:57:464 mins ago Camelot: xGRAIL Token 0x594fb2ec5c7adf3cb68db1e90ace58e643c118a50 ETH
0xb018a2803b58d709308f603c83478750f46c2b8258a186a7395f4587b398ca98719088602023-03-20 21:56:455 mins ago Camelot: Dividends V2 Camelot: xGRAIL Token0 ETH
0xb018a2803b58d709308f603c83478750f46c2b8258a186a7395f4587b398ca98719088602023-03-20 21:56:455 mins ago Camelot: Dividends V2 Camelot: xGRAIL Token0 ETH
0xada71bee0c528ce857ff43594c445198539a74b19f665e332c44099dba35486a719088152023-03-20 21:56:335 mins ago Camelot: xGRAIL Token Camelot: Dividends V20 ETH
0xada71bee0c528ce857ff43594c445198539a74b19f665e332c44099dba35486a719088152023-03-20 21:56:335 mins ago Camelot: xGRAIL Token Camelot: GRAIL Token0 ETH
0x53d04b7baaa2690845f6ae8c6593ffe15c4bc44774befdcf44c4afe37ad30779719083132023-03-20 21:54:258 mins ago Camelot: xGRAIL Token Camelot: GRAIL Token0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
XGrailToken

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 50000 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 13 : XGrailToken.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

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

import "./interfaces/tokens/IGrailTokenV2.sol";
import "./interfaces/tokens/IXGrailToken.sol";
import "./interfaces/IXGrailTokenUsage.sol";


/*
 * xGRAIL is Camelot's escrowed governance token obtainable by converting GRAIL to it
 * It's non-transferable, except from/to whitelisted addresses
 * It can be converted back to GRAIL through a vesting process
 * This contract is made to receive xGRAIL deposits from users in order to allocate them to Usages (plugins) contracts
 */
contract XGrailToken is Ownable, ReentrancyGuard, ERC20("Camelot escrowed token", "xGRAIL"), IXGrailToken {
  using Address for address;
  using SafeMath for uint256;
  using EnumerableSet for EnumerableSet.AddressSet;
  using SafeERC20 for IGrailTokenV2;

  struct XGrailBalance {
    uint256 allocatedAmount; // Amount of xGRAIL allocated to a Usage
    uint256 redeemingAmount; // Total amount of xGRAIL currently being redeemed
  }

  struct RedeemInfo {
    uint256 grailAmount; // GRAIL amount to receive when vesting has ended
    uint256 xGrailAmount; // xGRAIL amount to redeem
    uint256 endTime;
    IXGrailTokenUsage dividendsAddress;
    uint256 dividendsAllocation; // Share of redeeming xGRAIL to allocate to the Dividends Usage contract
  }

  IGrailTokenV2 public immutable grailToken; // GRAIL token to convert to/from
  IXGrailTokenUsage public dividendsAddress; // Camelot dividends contract

  EnumerableSet.AddressSet private _transferWhitelist; // addresses allowed to send/receive xGRAIL

  mapping(address => mapping(address => uint256)) public usageApprovals; // Usage approvals to allocate xGRAIL
  mapping(address => mapping(address => uint256)) public override usageAllocations; // Active xGRAIL allocations to usages

  uint256 public constant MAX_DEALLOCATION_FEE = 200; // 2%
  mapping(address => uint256) public usagesDeallocationFee; // Fee paid when deallocating xGRAIL

  uint256 public constant MAX_FIXED_RATIO = 100; // 100%

  // Redeeming min/max settings
  uint256 public minRedeemRatio = 50; // 1:0.5
  uint256 public maxRedeemRatio = 100; // 1:1
  uint256 public minRedeemDuration = 15 days; // 1296000s
  uint256 public maxRedeemDuration = 90 days; // 7776000s
  // Adjusted dividends rewards for redeeming xGRAIL
  uint256 public redeemDividendsAdjustment = 50; // 50%

  mapping(address => XGrailBalance) public xGrailBalances; // User's xGRAIL balances
  mapping(address => RedeemInfo[]) public userRedeems; // User's redeeming instances


  constructor(IGrailTokenV2 grailToken_) {
    grailToken = grailToken_;
    _transferWhitelist.add(address(this));
  }

  /********************************************/
  /****************** EVENTS ******************/
  /********************************************/

  event ApproveUsage(address indexed userAddress, address indexed usageAddress, uint256 amount);
  event Convert(address indexed from, address to, uint256 amount);
  event UpdateRedeemSettings(uint256 minRedeemRatio, uint256 maxRedeemRatio, uint256 minRedeemDuration, uint256 maxRedeemDuration, uint256 redeemDividendsAdjustment);
  event UpdateDividendsAddress(address previousDividendsAddress, address newDividendsAddress);
  event UpdateDeallocationFee(address indexed usageAddress, uint256 fee);
  event SetTransferWhitelist(address account, bool add);
  event Redeem(address indexed userAddress, uint256 xGrailAmount, uint256 grailAmount, uint256 duration);
  event FinalizeRedeem(address indexed userAddress, uint256 xGrailAmount, uint256 grailAmount);
  event CancelRedeem(address indexed userAddress, uint256 xGrailAmount);
  event UpdateRedeemDividendsAddress(address indexed userAddress, uint256 redeemIndex, address previousDividendsAddress, address newDividendsAddress);
  event Allocate(address indexed userAddress, address indexed usageAddress, uint256 amount);
  event Deallocate(address indexed userAddress, address indexed usageAddress, uint256 amount, uint256 fee);

  /***********************************************/
  /****************** MODIFIERS ******************/
  /***********************************************/

  /*
   * @dev Check if a redeem entry exists
   */
  modifier validateRedeem(address userAddress, uint256 redeemIndex) {
    require(redeemIndex < userRedeems[userAddress].length, "validateRedeem: redeem entry does not exist");
    _;
  }

  /**************************************************/
  /****************** PUBLIC VIEWS ******************/
  /**************************************************/

  /*
   * @dev Returns user's xGRAIL balances
   */
  function getXGrailBalance(address userAddress) external view returns (uint256 allocatedAmount, uint256 redeemingAmount) {
    XGrailBalance storage balance = xGrailBalances[userAddress];
    return (balance.allocatedAmount, balance.redeemingAmount);
  }

  /*
   * @dev returns redeemable GRAIL for "amount" of xGRAIL vested for "duration" seconds
   */
  function getGrailByVestingDuration(uint256 amount, uint256 duration) public view returns (uint256) {
    if(duration < minRedeemDuration) {
      return 0;
    }

    // capped to maxRedeemDuration
    if (duration > maxRedeemDuration) {
      return amount.mul(maxRedeemRatio).div(100);
    }

    uint256 ratio = minRedeemRatio.add(
      (duration.sub(minRedeemDuration)).mul(maxRedeemRatio.sub(minRedeemRatio))
      .div(maxRedeemDuration.sub(minRedeemDuration))
    );

    return amount.mul(ratio).div(100);
  }

  /**
   * @dev returns quantity of "userAddress" pending redeems
   */
  function getUserRedeemsLength(address userAddress) external view returns (uint256) {
    return userRedeems[userAddress].length;
  }

  /**
   * @dev returns "userAddress" info for a pending redeem identified by "redeemIndex"
   */
  function getUserRedeem(address userAddress, uint256 redeemIndex) external view validateRedeem(userAddress, redeemIndex) returns (uint256 grailAmount, uint256 xGrailAmount, uint256 endTime, address dividendsContract, uint256 dividendsAllocation) {
    RedeemInfo storage _redeem = userRedeems[userAddress][redeemIndex];
    return (_redeem.grailAmount, _redeem.xGrailAmount, _redeem.endTime, address(_redeem.dividendsAddress), _redeem.dividendsAllocation);
  }

  /**
   * @dev returns approved xGrail to allocate from "userAddress" to "usageAddress"
   */
  function getUsageApproval(address userAddress, address usageAddress) external view returns (uint256) {
    return usageApprovals[userAddress][usageAddress];
  }

  /**
   * @dev returns allocated xGrail from "userAddress" to "usageAddress"
   */
  function getUsageAllocation(address userAddress, address usageAddress) external view returns (uint256) {
    return usageAllocations[userAddress][usageAddress];
  }

  /**
   * @dev returns length of transferWhitelist array
   */
  function transferWhitelistLength() external view returns (uint256) {
    return _transferWhitelist.length();
  }

  /**
   * @dev returns transferWhitelist array item's address for "index"
   */
  function transferWhitelist(uint256 index) external view returns (address) {
    return _transferWhitelist.at(index);
  }

  /**
   * @dev returns if "account" is allowed to send/receive xGRAIL
   */
  function isTransferWhitelisted(address account) external override view returns (bool) {
    return _transferWhitelist.contains(account);
  }

  /*******************************************************/
  /****************** OWNABLE FUNCTIONS ******************/
  /*******************************************************/

  /**
   * @dev Updates all redeem ratios and durations
   *
   * Must only be called by owner
   */
  function updateRedeemSettings(uint256 minRedeemRatio_, uint256 maxRedeemRatio_, uint256 minRedeemDuration_, uint256 maxRedeemDuration_, uint256 redeemDividendsAdjustment_) external onlyOwner {
    require(minRedeemRatio_ <= maxRedeemRatio_, "updateRedeemSettings: wrong ratio values");
    require(minRedeemDuration_ < maxRedeemDuration_, "updateRedeemSettings: wrong duration values");
    // should never exceed 100%
    require(maxRedeemRatio_ <= MAX_FIXED_RATIO && redeemDividendsAdjustment_ <= MAX_FIXED_RATIO, "updateRedeemSettings: wrong ratio values");

    minRedeemRatio = minRedeemRatio_;
    maxRedeemRatio = maxRedeemRatio_;
    minRedeemDuration = minRedeemDuration_;
    maxRedeemDuration = maxRedeemDuration_;
    redeemDividendsAdjustment = redeemDividendsAdjustment_;

    emit UpdateRedeemSettings(minRedeemRatio_, maxRedeemRatio_, minRedeemDuration_, maxRedeemDuration_, redeemDividendsAdjustment_);
  }

  /**
   * @dev Updates dividends contract address
   *
   * Must only be called by owner
   */
  function updateDividendsAddress(IXGrailTokenUsage dividendsAddress_) external onlyOwner {
    // if set to 0, also set divs earnings while redeeming to 0
    if(address(dividendsAddress_) == address(0)) {
      redeemDividendsAdjustment = 0;
    }

    emit UpdateDividendsAddress(address(dividendsAddress), address(dividendsAddress_));
    dividendsAddress = dividendsAddress_;
  }

  /**
   * @dev Updates fee paid by users when deallocating from "usageAddress"
   */
  function updateDeallocationFee(address usageAddress, uint256 fee) external onlyOwner {
    require(fee <= MAX_DEALLOCATION_FEE, "updateDeallocationFee: too high");

    usagesDeallocationFee[usageAddress] = fee;
    emit UpdateDeallocationFee(usageAddress, fee);
  }

  /**
   * @dev Adds or removes addresses from the transferWhitelist
   */
  function updateTransferWhitelist(address account, bool add) external onlyOwner {
    require(account != address(this), "updateTransferWhitelist: Cannot remove xGrail from whitelist");

    if(add) _transferWhitelist.add(account);
    else _transferWhitelist.remove(account);

    emit SetTransferWhitelist(account, add);
  }

  /*****************************************************************/
  /******************  EXTERNAL PUBLIC FUNCTIONS  ******************/
  /*****************************************************************/

  /**
   * @dev Approves "usage" address to get allocations up to "amount" of xGRAIL from msg.sender
   */
  function approveUsage(IXGrailTokenUsage usage, uint256 amount) external nonReentrant {
    require(address(usage) != address(0), "approveUsage: approve to the zero address");

    usageApprovals[msg.sender][address(usage)] = amount;
    emit ApproveUsage(msg.sender, address(usage), amount);
  }

  /**
   * @dev Convert caller's "amount" of GRAIL to xGRAIL
   */
  function convert(uint256 amount) external nonReentrant {
    _convert(amount, msg.sender);
  }

  /**
   * @dev Convert caller's "amount" of GRAIL to xGRAIL to "to" address
   */
  function convertTo(uint256 amount, address to) external override nonReentrant {
    require(address(msg.sender).isContract(), "convertTo: not allowed");
    _convert(amount, to);
  }

  /**
   * @dev Initiates redeem process (xGRAIL to GRAIL)
   *
   * Handles dividends' compensation allocation during the vesting process if needed
   */
  function redeem(uint256 xGrailAmount, uint256 duration) external nonReentrant {
    require(xGrailAmount > 0, "redeem: xGrailAmount cannot be null");
    require(duration >= minRedeemDuration, "redeem: duration too low");

    _transfer(msg.sender, address(this), xGrailAmount);
    XGrailBalance storage balance = xGrailBalances[msg.sender];

    // get corresponding GRAIL amount
    uint256 grailAmount = getGrailByVestingDuration(xGrailAmount, duration);
    emit Redeem(msg.sender, xGrailAmount, grailAmount, duration);

    // if redeeming is not immediate, go through vesting process
    if(duration > 0) {
      // add to SBT total
      balance.redeemingAmount = balance.redeemingAmount.add(xGrailAmount);

      // handle dividends during the vesting process
      uint256 dividendsAllocation = xGrailAmount.mul(redeemDividendsAdjustment).div(100);
      // only if compensation is active
      if(dividendsAllocation > 0) {
        // allocate to dividends
        dividendsAddress.allocate(msg.sender, dividendsAllocation, new bytes(0));
      }

      // add redeeming entry
      userRedeems[msg.sender].push(RedeemInfo(grailAmount, xGrailAmount, _currentBlockTimestamp().add(duration), dividendsAddress, dividendsAllocation));
    } else {
      // immediately redeem for GRAIL
      _finalizeRedeem(msg.sender, xGrailAmount, grailAmount);
    }
  }

  /**
   * @dev Finalizes redeem process when vesting duration has been reached
   *
   * Can only be called by the redeem entry owner
   */
  function finalizeRedeem(uint256 redeemIndex) external nonReentrant validateRedeem(msg.sender, redeemIndex) {
    XGrailBalance storage balance = xGrailBalances[msg.sender];
    RedeemInfo storage _redeem = userRedeems[msg.sender][redeemIndex];
    require(_currentBlockTimestamp() >= _redeem.endTime, "finalizeRedeem: vesting duration has not ended yet");

    // remove from SBT total
    balance.redeemingAmount = balance.redeemingAmount.sub(_redeem.xGrailAmount);
    _finalizeRedeem(msg.sender, _redeem.xGrailAmount, _redeem.grailAmount);

    // handle dividends compensation if any was active
    if(_redeem.dividendsAllocation > 0) {
      // deallocate from dividends
      IXGrailTokenUsage(_redeem.dividendsAddress).deallocate(msg.sender, _redeem.dividendsAllocation, new bytes(0));
    }

    // remove redeem entry
    _deleteRedeemEntry(redeemIndex);
  }

  /**
   * @dev Updates dividends address for an existing active redeeming process
   *
   * Can only be called by the involved user
   * Should only be used if dividends contract was to be migrated
   */
  function updateRedeemDividendsAddress(uint256 redeemIndex) external nonReentrant validateRedeem(msg.sender, redeemIndex) {
    RedeemInfo storage _redeem = userRedeems[msg.sender][redeemIndex];

    // only if the active dividends contract is not the same anymore
    if(dividendsAddress != _redeem.dividendsAddress && address(dividendsAddress) != address(0)) {
      if(_redeem.dividendsAllocation > 0) {
        // deallocate from old dividends contract
        _redeem.dividendsAddress.deallocate(msg.sender, _redeem.dividendsAllocation, new bytes(0));
        // allocate to new used dividends contract
        dividendsAddress.allocate(msg.sender, _redeem.dividendsAllocation, new bytes(0));
      }

      emit UpdateRedeemDividendsAddress(msg.sender, redeemIndex, address(_redeem.dividendsAddress), address(dividendsAddress));
      _redeem.dividendsAddress = dividendsAddress;
    }
  }

  /**
   * @dev Cancels an ongoing redeem entry
   *
   * Can only be called by its owner
   */
  function cancelRedeem(uint256 redeemIndex) external nonReentrant validateRedeem(msg.sender, redeemIndex) {
    XGrailBalance storage balance = xGrailBalances[msg.sender];
    RedeemInfo storage _redeem = userRedeems[msg.sender][redeemIndex];

    // make redeeming xGRAIL available again
    balance.redeemingAmount = balance.redeemingAmount.sub(_redeem.xGrailAmount);
    _transfer(address(this), msg.sender, _redeem.xGrailAmount);

    // handle dividends compensation if any was active
    if(_redeem.dividendsAllocation > 0) {
      // deallocate from dividends
      IXGrailTokenUsage(_redeem.dividendsAddress).deallocate(msg.sender, _redeem.dividendsAllocation, new bytes(0));
    }

    emit CancelRedeem(msg.sender, _redeem.xGrailAmount);

    // remove redeem entry
    _deleteRedeemEntry(redeemIndex);
  }


  /**
   * @dev Allocates caller's "amount" of available xGRAIL to "usageAddress" contract
   *
   * args specific to usage contract must be passed into "usageData"
   */
  function allocate(address usageAddress, uint256 amount, bytes calldata usageData) external nonReentrant {
    _allocate(msg.sender, usageAddress, amount);

    // allocates xGRAIL to usageContract
    IXGrailTokenUsage(usageAddress).allocate(msg.sender, amount, usageData);
  }

  /**
   * @dev Allocates "amount" of available xGRAIL from "userAddress" to caller (ie usage contract)
   *
   * Caller must have an allocation approval for the required xGrail xGRAIL from "userAddress"
   */
  function allocateFromUsage(address userAddress, uint256 amount) external override nonReentrant {
    _allocate(userAddress, msg.sender, amount);
  }

  /**
   * @dev Deallocates caller's "amount" of available xGRAIL from "usageAddress" contract
   *
   * args specific to usage contract must be passed into "usageData"
   */
  function deallocate(address usageAddress, uint256 amount, bytes calldata usageData) external nonReentrant {
    _deallocate(msg.sender, usageAddress, amount);

    // deallocate xGRAIL into usageContract
    IXGrailTokenUsage(usageAddress).deallocate(msg.sender, amount, usageData);
  }

  /**
   * @dev Deallocates "amount" of allocated xGRAIL belonging to "userAddress" from caller (ie usage contract)
   *
   * Caller can only deallocate xGRAIL from itself
   */
  function deallocateFromUsage(address userAddress, uint256 amount) external override nonReentrant {
    _deallocate(userAddress, msg.sender, amount);
  }

  /********************************************************/
  /****************** INTERNAL FUNCTIONS ******************/
  /********************************************************/

  /**
   * @dev Convert caller's "amount" of GRAIL into xGRAIL to "to"
   */
  function _convert(uint256 amount, address to) internal {
    require(amount != 0, "convert: amount cannot be null");

    // mint new xGRAIL
    _mint(to, amount);

    emit Convert(msg.sender, to, amount);
    grailToken.safeTransferFrom(msg.sender, address(this), amount);
  }

  /**
   * @dev Finalizes the redeeming process for "userAddress" by transferring him "grailAmount" and removing "xGrailAmount" from supply
   *
   * Any vesting check should be ran before calling this
   * GRAIL excess is automatically burnt
   */
  function _finalizeRedeem(address userAddress, uint256 xGrailAmount, uint256 grailAmount) internal {
    uint256 grailExcess = xGrailAmount.sub(grailAmount);

    // sends due GRAIL tokens
    grailToken.safeTransfer(userAddress, grailAmount);

    // burns GRAIL excess if any
    grailToken.burn(grailExcess);
    _burn(address(this), xGrailAmount);

    emit FinalizeRedeem(userAddress, xGrailAmount, grailAmount);
  }

  /**
   * @dev Allocates "userAddress" user's "amount" of available xGRAIL to "usageAddress" contract
   *
   */
  function _allocate(address userAddress, address usageAddress, uint256 amount) internal {
    require(amount > 0, "allocate: amount cannot be null");

    XGrailBalance storage balance = xGrailBalances[userAddress];

    // approval checks if allocation request amount has been approved by userAddress to be allocated to this usageAddress
    uint256 approvedXGrail = usageApprovals[userAddress][usageAddress];
    require(approvedXGrail >= amount, "allocate: non authorized amount");

    // remove allocated amount from usage's approved amount
    usageApprovals[userAddress][usageAddress] = approvedXGrail.sub(amount);

    // update usage's allocatedAmount for userAddress
    usageAllocations[userAddress][usageAddress] = usageAllocations[userAddress][usageAddress].add(amount);

    // adjust user's xGRAIL balances
    balance.allocatedAmount = balance.allocatedAmount.add(amount);
    _transfer(userAddress, address(this), amount);

    emit Allocate(userAddress, usageAddress, amount);
  }

  /**
   * @dev Deallocates "amount" of available xGRAIL to "usageAddress" contract
   *
   * args specific to usage contract must be passed into "usageData"
   */
  function _deallocate(address userAddress, address usageAddress, uint256 amount) internal {
    require(amount > 0, "deallocate: amount cannot be null");

    // check if there is enough allocated xGRAIL to this usage to deallocate
    uint256 allocatedAmount = usageAllocations[userAddress][usageAddress];
    require(allocatedAmount >= amount, "deallocate: non authorized amount");

    // remove deallocated amount from usage's allocation
    usageAllocations[userAddress][usageAddress] = allocatedAmount.sub(amount);

    uint256 deallocationFeeAmount = amount.mul(usagesDeallocationFee[usageAddress]).div(10000);

    // adjust user's xGRAIL balances
    XGrailBalance storage balance = xGrailBalances[userAddress];
    balance.allocatedAmount = balance.allocatedAmount.sub(amount);
    _transfer(address(this), userAddress, amount.sub(deallocationFeeAmount));
    // burn corresponding GRAIL and XGRAIL
    grailToken.burn(deallocationFeeAmount);
    _burn(address(this), deallocationFeeAmount);

    emit Deallocate(userAddress, usageAddress, amount, deallocationFeeAmount);
  }

  function _deleteRedeemEntry(uint256 index) internal {
    userRedeems[msg.sender][index] = userRedeems[msg.sender][userRedeems[msg.sender].length - 1];
    userRedeems[msg.sender].pop();
  }

  /**
   * @dev Hook override to forbid transfers except from whitelisted addresses and minting
   */
  function _beforeTokenTransfer(address from, address to, uint256 /*amount*/) internal view override {
    require(from == address(0) || _transferWhitelist.contains(from) || _transferWhitelist.contains(to), "transfer: not allowed");
  }

  /**
   * @dev Utility function to get the current block timestamp
   */
  function _currentBlockTimestamp() internal view virtual returns (uint256) {
    /* solhint-disable not-rely-on-time */
    return block.timestamp;
  }

}

File 2 of 13 : IXGrailToken.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

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

interface IXGrailToken is IERC20 {
  function usageAllocations(address userAddress, address usageAddress) external view returns (uint256 allocation);

  function allocateFromUsage(address userAddress, uint256 amount) external;
  function convertTo(uint256 amount, address to) external;
  function deallocateFromUsage(address userAddress, uint256 amount) external;

  function isTransferWhitelisted(address account) external view returns (bool);
}

File 3 of 13 : IGrailTokenV2.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

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

interface IGrailTokenV2 is IERC20{
  function lastEmissionTime() external view returns (uint256);

  function claimMasterRewards(uint256 amount) external returns (uint256 effectiveAmount);
  function masterEmissionRate() external view returns (uint256);
  function burn(uint256 amount) external;
}

File 4 of 13 : IXGrailTokenUsage.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

interface IXGrailTokenUsage {
    function allocate(address userAddress, uint256 amount, bytes calldata data) external;
    function deallocate(address userAddress, uint256 amount, bytes calldata data) external;
}

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

pragma solidity ^0.7.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 () {
        _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 6 of 13 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

    struct Set {
        // Storage of set values
        bytes32[] _values;

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

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

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

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

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

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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


    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

File 7 of 13 : 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 8 of 13 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.7.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 10 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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 11 of 13 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

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

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

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

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

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

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

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

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

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

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

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

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

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

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

pragma solidity ^0.7.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

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

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

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

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

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

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

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

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

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

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

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

pragma solidity ^0.7.0;

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

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

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

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

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

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

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

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

Contract ABI

[{"inputs":[{"internalType":"contract IGrailTokenV2","name":"grailToken_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Allocate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ApproveUsage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"xGrailAmount","type":"uint256"}],"name":"CancelRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Convert","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"Deallocate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"xGrailAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"grailAmount","type":"uint256"}],"name":"FinalizeRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"xGrailAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"grailAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"add","type":"bool"}],"name":"SetTransferWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"UpdateDeallocationFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousDividendsAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newDividendsAddress","type":"address"}],"name":"UpdateDividendsAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"redeemIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"previousDividendsAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newDividendsAddress","type":"address"}],"name":"UpdateRedeemDividendsAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minRedeemRatio","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxRedeemRatio","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minRedeemDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxRedeemDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemDividendsAdjustment","type":"uint256"}],"name":"UpdateRedeemSettings","type":"event"},{"inputs":[],"name":"MAX_DEALLOCATION_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FIXED_RATIO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usageAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"usageData","type":"bytes"}],"name":"allocate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"allocateFromUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IXGrailTokenUsage","name":"usage","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"cancelRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"convert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"convertTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"usageAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"usageData","type":"bytes"}],"name":"deallocate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deallocateFromUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dividendsAddress","outputs":[{"internalType":"contract IXGrailTokenUsage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"finalizeRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"getGrailByVestingDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"usageAddress","type":"address"}],"name":"getUsageAllocation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"usageAddress","type":"address"}],"name":"getUsageApproval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"getUserRedeem","outputs":[{"internalType":"uint256","name":"grailAmount","type":"uint256"},{"internalType":"uint256","name":"xGrailAmount","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"address","name":"dividendsContract","type":"address"},{"internalType":"uint256","name":"dividendsAllocation","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserRedeemsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getXGrailBalance","outputs":[{"internalType":"uint256","name":"allocatedAmount","type":"uint256"},{"internalType":"uint256","name":"redeemingAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"grailToken","outputs":[{"internalType":"contract IGrailTokenV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isTransferWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRedeemDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRedeemRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minRedeemDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minRedeemRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"xGrailAmount","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemDividendsAdjustment","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"transferWhitelist","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferWhitelistLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usageAddress","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"updateDeallocationFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IXGrailTokenUsage","name":"dividendsAddress_","type":"address"}],"name":"updateDividendsAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"updateRedeemDividendsAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minRedeemRatio_","type":"uint256"},{"internalType":"uint256","name":"maxRedeemRatio_","type":"uint256"},{"internalType":"uint256","name":"minRedeemDuration_","type":"uint256"},{"internalType":"uint256","name":"maxRedeemDuration_","type":"uint256"},{"internalType":"uint256","name":"redeemDividendsAdjustment_","type":"uint256"}],"name":"updateRedeemSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateTransferWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"usageAllocations","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"usageApprovals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"usagesDeallocationFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userRedeems","outputs":[{"internalType":"uint256","name":"grailAmount","type":"uint256"},{"internalType":"uint256","name":"xGrailAmount","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"contract IXGrailTokenUsage","name":"dividendsAddress","type":"address"},{"internalType":"uint256","name":"dividendsAllocation","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"xGrailBalances","outputs":[{"internalType":"uint256","name":"allocatedAmount","type":"uint256"},{"internalType":"uint256","name":"redeemingAmount","type":"uint256"}],"stateMutability":"view","type":"function"}]

60a06040526032600d556064600e556213c680600f556276a70060105560326011553480156200002e57600080fd5b5060405162004fd438038062004fd4833981810160405260208110156200005457600080fd5b5051604080518082018252601681527f43616d656c6f7420657363726f77656420746f6b656e00000000000000000000602082810191909152825180840190935260068352651e11d490525360d21b90830152906000620000b462000172565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35060018055815162000117906005906020850190620001fd565b5080516200012d906006906020840190620001fd565b505060078054601260ff1990911617905550606081901b6001600160601b0319166080526200016a60083062000176602090811b620031b417901c565b5050620002a9565b3390565b60006200018d836001600160a01b03841662000196565b90505b92915050565b6000620001a48383620001e5565b620001dc5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000190565b50600062000190565b60009081526001919091016020526040902054151590565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928262000235576000855562000280565b82601f106200025057805160ff191683800117855562000280565b8280016001018555821562000280579182015b828111156200028057825182559160200191906001019062000263565b506200028e92915062000292565b5090565b5b808211156200028e576000815560010162000293565b60805160601c614cf9620002db60003980612e6a5280613c2b5280613e195280613f655280613f8e5250614cf96000f3fe608060405234801561001057600080fd5b506004361061034c5760003560e01c8063549230c9116101bd578063a9059cbb116100f9578063c4b10766116100a2578063dd62ed3e1161007c578063dd62ed3e14610c69578063e3a2950b14610ca4578063e9ed87f814610cac578063f2fde38b14610cb45761034c565b8063c4b1076614610bf5578063c5702dfa14610bfd578063cc6c542314610c305761034c565b8063b90c2b52116100d3578063b90c2b5214610b81578063c360ed1c14610bb4578063c414c58414610bed5761034c565b8063a9059cbb14610b08578063aaef3e1714610b41578063aff6cbf114610b645761034c565b8063890836541161016657806395d89b411161014057806395d89b4114610a71578063a0bdc7cb14610a79578063a3908e1b14610ab2578063a457c2d714610acf5761034c565b806389083654146109fb5780638975f91814610a365780638da5cb5b14610a695761034c565b806370a082311161019757806370a082311461099d578063715018a6146109d05780637cbc2373146109d85761034c565b8063549230c9146108ca5780635a1d34dc1461095c578063619ac95b146109955761034c565b80632c509ca91161028c5780633b90f9a0116102355780634a5b406e1161020f5780634a5b406e1461080e5780634b359d38146108165780634f62b7ec14610833578063539ffb77146108ad5761034c565b80633b90f9a014610769578063488c8303146107a2578063497965ee146107dd5761034c565b806331124ce31161026657806331124ce3146106f5578063313ce5671461071257806339509351146107305761034c565b80632c509ca9146106335780632cc2f5ce1461067f5780632e9a76e4146106ba5761034c565b8063161aab43116102f95780631c75e369116102d35780631c75e369146104f05780631eee7e601461058257806323b872dd146105b55780632b489679146105f85761034c565b8063161aab43146104d857806318160ddd146104e05780631c352679146104e85761034c565b8063093220b71161032a578063093220b71461041d578063095ea7b3146104525780630f7d3a691461049f5761034c565b806302f91e551461035157806306045a211461036b57806306fdde03146103a0575b600080fd5b610359610ce7565b60408051918252519081900360200190f35b61039e6004803603602081101561038157600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610cec565b005b6103a8610e5b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103e25781810151838201526020016103ca565b50505050905090810190601f16801561040f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61039e600480360360a081101561043357600080fd5b5080359060208101359060408101359060608101359060800135610f0f565b61048b6004803603604081101561046857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561113d565b604080519115158252519081900360200190f35b61039e600480360360408110156104b557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561115b565b6103596112d4565b6103596112e5565b6103596112eb565b61039e6004803603606081101561050657600080fd5b73ffffffffffffffffffffffffffffffffffffffff8235169160208101359181019060608101604082013564010000000081111561054357600080fd5b82018360208201111561055557600080fd5b8035906020019184600183028401116401000000008311171561057757600080fd5b5090925090506112f1565b61048b6004803603602081101561059857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661143a565b61048b600480360360608110156105cb57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135611447565b6103596004803603604081101561060e57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166114e9565b6106666004803603602081101561064957600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611521565b6040805192835260208301919091528051918290030190f35b6103596004803603604081101561069557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661153a565b610359600480360360408110156106d057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611557565b61039e6004803603602081101561070b57600080fd5b503561158f565b61071a6119e6565b6040805160ff9092168252519081900360200190f35b61048b6004803603604081101561074657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356119ef565b61039e6004803603604081101561077f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135611a4a565b610359600480360360408110156107b857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611ad4565b6107e5611af1565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b610359611b12565b6107e56004803603602081101561082c57600080fd5b5035611b18565b61086c6004803603604081101561084957600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135611b25565b6040805195865260208601949094528484019290925273ffffffffffffffffffffffffffffffffffffffff1660608401526080830152519081900360a00190f35b61039e600480360360208110156108c357600080fd5b5035611b89565b61039e600480360360608110156108e057600080fd5b73ffffffffffffffffffffffffffffffffffffffff8235169160208101359181019060608101604082013564010000000081111561091d57600080fd5b82018360208201111561092f57600080fd5b8035906020019184600183028401116401000000008311171561095157600080fd5b509092509050611e3f565b61039e6004803603604081101561097257600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff16611f66565b61035961205b565b610359600480360360208110156109b357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612060565b61039e612088565b61039e600480360360408110156109ee57600080fd5b508035906020013561219f565b61039e60048036036040811015610a1157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135151561259a565b61035960048036036020811015610a4c57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661272b565b6107e561273d565b6103a8612759565b61039e60048036036040811015610a8f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356127d8565b61039e60048036036020811015610ac857600080fd5b503561285a565b61048b60048036036040811015610ae557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356128e2565b61048b60048036036040811015610b1e57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135612957565b61035960048036036040811015610b5757600080fd5b508035906020013561296b565b61039e60048036036020811015610b7a57600080fd5b5035612a19565b61035960048036036020811015610b9757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612cea565b61039e60048036036040811015610bca57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135612d12565b6107e5612e68565b610359612e8c565b61066660048036036020811015610c1357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612e92565b61086c60048036036040811015610c4657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135612ec2565b61035960048036036040811015610c7f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516612fcf565b610359613007565b61035961300d565b61039e60048036036020811015610cca57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16613013565b60c881565b610cf46131d6565b73ffffffffffffffffffffffffffffffffffffffff16610d1261273d565b73ffffffffffffffffffffffffffffffffffffffff1614610d9457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610db55760006011555b6007546040805173ffffffffffffffffffffffffffffffffffffffff61010090930483168152918316602083015280517f044c75b8fa43ce72364b4c23fdb8451beafbda46505bf44c76f0853a01ed4ade9281900390910190a16007805473ffffffffffffffffffffffffffffffffffffffff909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b60058054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610f055780601f10610eda57610100808354040283529160200191610f05565b820191906000526020600020905b815481529060010190602001808311610ee857829003601f168201915b5050505050905090565b610f176131d6565b73ffffffffffffffffffffffffffffffffffffffff16610f3561273d565b73ffffffffffffffffffffffffffffffffffffffff1614610fb757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b83851115611010576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180614a226028913960400191505060405180910390fd5b818310611068576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180614a86602b913960400191505060405180910390fd5b6064841115801561107a575060648111155b6110cf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180614a226028913960400191505060405180910390fd5b600d859055600e849055600f839055601082905560118190556040805186815260208101869052808201859052606081018490526080810183905290517f5b37d10782e41a6539b50d59366d4112a880236e4187e85b6d1514d20e07d9b89181900360a00190a15050505050565b600061115161114a6131d6565b84846131da565b5060015b92915050565b6111636131d6565b73ffffffffffffffffffffffffffffffffffffffff1661118161273d565b73ffffffffffffffffffffffffffffffffffffffff161461120357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60c881111561127357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f7570646174654465616c6c6f636174696f6e4665653a20746f6f206869676800604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff82166000818152600c6020908152604091829020849055815184815291517f6ff024152fc2cd8071bc701f966036513eb03e243863f21d8218646faac0eaef9281900390910190a25050565b60006112e06008613321565b905090565b60045490565b600d5481565b6002600154141561136357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260015561137333858561332c565b8373ffffffffffffffffffffffffffffffffffffffff16631c75e369338585856040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b15801561141857600080fd5b505af115801561142c573d6000803e3d6000fd5b505060018055505050505050565b600061115560088361355d565b600061145484848461357f565b6114de846114606131d6565b6114d985604051806060016040528060288152602001614b636028913973ffffffffffffffffffffffffffffffffffffffff8a166000908152600360205260408120906114ab6131d6565b73ffffffffffffffffffffffffffffffffffffffff1681526020810191909152604001600020549190613751565b6131da565b5060015b9392505050565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152600a6020908152604080832093909416825291909152205490565b6012602052600090815260409020805460019091015482565b600b60209081526000928352604080842090915290825290205481565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152600b6020908152604080832093909416825291909152205490565b6002600154141561160157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155336000818152601360205260409020548290811061166f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180614c18602b913960400191505060405180910390fd5b33600090815260136020526040812080548590811061168a57fe5b60009182526020909120600590910201600381015460075491925073ffffffffffffffffffffffffffffffffffffffff90811661010090920416148015906116ee5750600754610100900473ffffffffffffffffffffffffffffffffffffffff1615155b156119dc57600481015415611924576003810154600482015460408051600080825260208201928390527f549230c900000000000000000000000000000000000000000000000000000000835233602483018181526044840186905260606064850190815284516084860181905273ffffffffffffffffffffffffffffffffffffffff9098169763549230c99793969395949293919260a486019291908190849084905b838110156117aa578181015183820152602001611792565b50505050905090810190601f1680156117d75780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1580156117f857600080fd5b505af115801561180c573d6000803e3d6000fd5b5050600754600484015460408051600080825260208201928390527f1c75e36900000000000000000000000000000000000000000000000000000000835233602483018181526044840186905260606064850190815284516084860181905261010090980473ffffffffffffffffffffffffffffffffffffffff169950631c75e3699850919693949093919260a4860192908190849084905b838110156118bd5781810151838201526020016118a5565b50505050905090810190601f1680156118ea5780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561190b57600080fd5b505af115801561191f573d6000803e3d6000fd5b505050505b60038101546007546040805187815273ffffffffffffffffffffffffffffffffffffffff938416602082015261010090920490921681830152905133917fa60c8f9118be22c9277a8129333d64ffda3de44ca7a5831d077a3127f1237a18919081900360600190a260075460038201805461010090920473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffff00000000000000000000000000000000000000009092169190911790555b5050600180555050565b60075460ff1690565b60006111516119fc6131d6565b846114d98560036000611a0d6131d6565b73ffffffffffffffffffffffffffffffffffffffff908116825260208083019390935260409182016000908120918c168152925290205490613802565b60026001541415611abc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155611acc82338361332c565b505060018055565b600a60209081526000928352604080842090915290825290205481565b600754610100900473ffffffffffffffffffffffffffffffffffffffff1681565b60115481565b6000611155600883613876565b60136020528160005260406000208181548110611b4157600080fd5b6000918252602090912060059091020180546001820154600283015460038401546004909401549295509093509173ffffffffffffffffffffffffffffffffffffffff169085565b60026001541415611bfb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001553360008181526013602052604090205482908110611c69576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180614c18602b913960400191505060405180910390fd5b33600090815260126020908152604080832060139092528220805491929186908110611c9157fe5b90600052602060002090600502019050611cbc8160010154836001015461388290919063ffffffff16565b8260010181905550611cd33033836001015461357f565b600481015415611df1576003810154600482015460408051600080825260208201928390527f549230c900000000000000000000000000000000000000000000000000000000835233602483018181526044840186905260606064850190815284516084860181905273ffffffffffffffffffffffffffffffffffffffff9098169763549230c99793969395949293919260a486019291908190849084905b83811015611d8a578181015183820152602001611d72565b50505050905090810190601f168015611db75780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015611dd857600080fd5b505af1158015611dec573d6000803e3d6000fd5b505050505b6001810154604080519182525133917f56d7520e387607a8daa892e3fed116badc2a636307bdc794b1c1aed97ae203f4919081900360200190a2611e34856138f9565b505060018055505050565b60026001541415611eb157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155611ec1338585613a9c565b8373ffffffffffffffffffffffffffffffffffffffff1663549230c9338585856040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b15801561141857600080fd5b60026001541415611fd857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155611fe633613d33565b61205157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f636f6e76657274546f3a206e6f7420616c6c6f77656400000000000000000000604482015290519081900360640190fd5b611acc8282613d39565b606481565b73ffffffffffffffffffffffffffffffffffffffff1660009081526002602052604090205490565b6120906131d6565b73ffffffffffffffffffffffffffffffffffffffff166120ae61273d565b73ffffffffffffffffffffffffffffffffffffffff161461213057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6002600154141561221157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001558161226c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614bac6023913960400191505060405180910390fd5b600f548110156122dd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f72656465656d3a206475726174696f6e20746f6f206c6f770000000000000000604482015290519081900360640190fd5b6122e833308461357f565b33600090815260126020526040812090612302848461296b565b6040805186815260208101839052808201869052905191925033917fbd5034ffbd47e4e72a94baa2cdb74c6fad73cb3bcdc13036b72ec8306f5a76469181900360600190a2821561258f57600182015461235c9085613802565b600183015560115460009061237f90606490612379908890613e45565b90613eb8565b905080156124ae57600754610100900473ffffffffffffffffffffffffffffffffffffffff16631c75e369338360006040519080825280601f01601f1916602001820160405280156123d8576020820181803683370190505b506040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561244757818101518382015260200161242f565b50505050905090810190601f1680156124745780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561249557600080fd5b505af11580156124a9573d6000803e3d6000fd5b505050505b33600090815260136020908152604091829020825160a0810184528581529182018890529181016124e7876124e1613f39565b90613802565b8152600754610100900473ffffffffffffffffffffffffffffffffffffffff90811660208084019190915260409283019590955283546001808201865560009586529486902084516005909202019081559483015193850193909355810151600284015560608101516003840180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169190931617909155608001516004909101556119dc565b6119dc338583613f3d565b6125a26131d6565b73ffffffffffffffffffffffffffffffffffffffff166125c061273d565b73ffffffffffffffffffffffffffffffffffffffff161461264257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff82163014156126b1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603c815260200180614a4a603c913960400191505060405180910390fd5b80156126c8576126c26008836131b4565b506126d5565b6126d3600883614077565b505b6040805173ffffffffffffffffffffffffffffffffffffffff84168152821515602082015281517f3a34209cb941a5d23a56dea730a13738454bc7daefd4bb32e8d7df58c1bd920d929181900390910190a15050565b600c6020526000908152604090205481565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60068054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610f055780601f10610eda57610100808354040283529160200191610f05565b6002600154141561284a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155611acc823383613a9c565b600260015414156128cc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001556128db8133613d39565b5060018055565b60006111516128ef6131d6565b846114d985604051806060016040528060258152602001614c9f60259139600360006129196131d6565b73ffffffffffffffffffffffffffffffffffffffff908116825260208083019390935260409182016000908120918d16815292529020549190613751565b60006111516129646131d6565b848461357f565b6000600f5482101561297f57506000611155565b6010548211156129aa576129a36064612379600e5486613e4590919063ffffffff16565b9050611155565b6000612a006129f76129c9600f5460105461388290919063ffffffff16565b6123796129e3600d54600e5461388290919063ffffffff16565b600f546129f1908990613882565b90613e45565b600d5490613802565b9050612a1160646123798684613e45565b949350505050565b60026001541415612a8b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001553360008181526013602052604090205482908110612af9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180614c18602b913960400191505060405180910390fd5b33600090815260126020908152604080832060139092528220805491929186908110612b2157fe5b906000526020600020906005020190508060020154612b3e613f39565b1015612b95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180614c436032913960400191505060405180910390fd5b60018082015490830154612ba891613882565b8260010181905550612bc33382600101548360000154613f3d565b600481015415612ce1576003810154600482015460408051600080825260208201928390527f549230c900000000000000000000000000000000000000000000000000000000835233602483018181526044840186905260606064850190815284516084860181905273ffffffffffffffffffffffffffffffffffffffff9098169763549230c99793969395949293919260a486019291908190849084905b83811015612c7a578181015183820152602001612c62565b50505050905090810190601f168015612ca75780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015612cc857600080fd5b505af1158015612cdc573d6000803e3d6000fd5b505050505b611e34856138f9565b73ffffffffffffffffffffffffffffffffffffffff1660009081526013602052604090205490565b60026001541415612d8457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260015573ffffffffffffffffffffffffffffffffffffffff8216612df5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180614af86029913960400191505060405180910390fd5b336000818152600a6020908152604080832073ffffffffffffffffffffffffffffffffffffffff871680855290835292819020859055805185815290519293927fe75ec259c38e4601f24580968665ec00b21cca4f996689b260ec598aec5c08db929181900390910190a3505060018055565b7f000000000000000000000000000000000000000000000000000000000000000081565b600f5481565b73ffffffffffffffffffffffffffffffffffffffff16600090815260126020526040902080546001909101549091565b73ffffffffffffffffffffffffffffffffffffffff82166000908152601360205260408120548190819081908190879087908110612f4b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180614c18602b913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8916600090815260136020526040812080548a908110612f7c57fe5b600091825260209091206005909102018054600182015460028301546003840154600490940154929e919d509b5073ffffffffffffffffffffffffffffffffffffffff9092169950975095505050505050565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260036020908152604080832093909416825291909152205490565b600e5481565b60105481565b61301b6131d6565b73ffffffffffffffffffffffffffffffffffffffff1661303961273d565b73ffffffffffffffffffffffffffffffffffffffff16146130bb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116613127576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806149da6026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60006114e28373ffffffffffffffffffffffffffffffffffffffff8416614099565b3390565b73ffffffffffffffffffffffffffffffffffffffff8316613246576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614bf46024913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82166132b2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180614a006022913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff808416600081815260036020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6000611155826140e3565b6000811161339b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f616c6c6f636174653a20616d6f756e742063616e6e6f74206265206e756c6c00604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8084166000908152601260209081526040808320600a83528184209487168452939091529020548281101561344657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f616c6c6f636174653a206e6f6e20617574686f72697a656420616d6f756e7400604482015290519081900360640190fd5b6134508184613882565b73ffffffffffffffffffffffffffffffffffffffff8087166000818152600a60209081526040808320948a1680845294825280832095909555918152600b825283812092815291905220546134a59084613802565b73ffffffffffffffffffffffffffffffffffffffff8087166000908152600b602090815260408083209389168352929052205581546134e49084613802565b82556134f185308561357f565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f5168bfb88d6125d4580e2b91ecb103a730312c3e8b0be9c4031a0fc794e2cd5f856040518082815260200191505060405180910390a35050505050565b60006114e28373ffffffffffffffffffffffffffffffffffffffff84166140e7565b73ffffffffffffffffffffffffffffffffffffffff83166135eb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180614bcf6025913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216613657576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806149956023913960400191505060405180910390fd5b6136628383836140ff565b6136ac81604051806060016040528060268152602001614ab16026913973ffffffffffffffffffffffffffffffffffffffff86166000908152600260205260409020549190613751565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526002602052604080822093909355908416815220546136e89082613802565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526002602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156137fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156137bf5781810151838201526020016137a7565b50505050905090810190601f1680156137ec5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828201838110156114e257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60006114e283836141a9565b6000828211156138f357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b33600090815260136020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811061393657fe5b9060005260206000209060050201601360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020828154811061398e57fe5b600091825260208083208454600590930201918255600180850154908301556002808501549083015560038085015490830180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9092169190911790556004938401549390910192909255338152601390915260409020805480613a2557fe5b60008281526020812060057fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9093019283020181815560018101829055600281018290556003810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905560040155905550565b60008111613af5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614b216021913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8084166000908152600b602090815260408083209386168352929052205481811015613b81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614ad76021913960400191505060405180910390fd5b613b8b8183613882565b73ffffffffffffffffffffffffffffffffffffffff8086166000908152600b60209081526040808320938816835292815282822093909355600c909252812054613bde9061271090612379908690613e45565b73ffffffffffffffffffffffffffffffffffffffff86166000908152601260205260409020805491925090613c139085613882565b8155613c293087613c248786613882565b61357f565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166342966c68836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015613c9c57600080fd5b505af1158015613cb0573d6000803e3d6000fd5b50505050613cbe3083614227565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167f7d613f7bd1a777aeeefdd38ae61201003086575188df50618d02482220f5c1478685604051808381526020018281526020019250505060405180910390a3505050505050565b3b151590565b81613da557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f636f6e766572743a20616d6f756e742063616e6e6f74206265206e756c6c0000604482015290519081900360640190fd5b613daf8183614371565b6040805173ffffffffffffffffffffffffffffffffffffffff8316815260208101849052815133927fccfaeb3043a96a967dc036ab72e078a9632af809671bc2a1ac30a8043645f89e928290030190a2613e4173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163330856144a4565b5050565b600082613e5457506000611155565b82820282848281613e6157fe5b04146114e2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614b426021913960400191505060405180910390fd5b6000808211613f2857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613f3157fe5b049392505050565b4290565b6000613f498383613882565b9050613f8c73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016858461453f565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166342966c68826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015613fff57600080fd5b505af1158015614013573d6000803e3d6000fd5b505050506140213084614227565b6040805184815260208101849052815173ffffffffffffffffffffffffffffffffffffffff8716927f0da072ebd7a5649099f43a3776eb0cda17aca79426ee9f28aae203f5dfa04eda928290030190a250505050565b60006114e28373ffffffffffffffffffffffffffffffffffffffff84166145cc565b60006140a583836140e7565b6140db57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611155565b506000611155565b5490565b60009081526001919091016020526040902054151590565b73ffffffffffffffffffffffffffffffffffffffff83161580614128575061412860088461355d565b80614139575061413960088361355d565b6141a457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f7472616e736665723a206e6f7420616c6c6f7765640000000000000000000000604482015290519081900360640190fd5b505050565b81546000908210614205576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806149736022913960400191505060405180910390fd5b82600001828154811061421457fe5b9060005260206000200154905092915050565b73ffffffffffffffffffffffffffffffffffffffff8216614293576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614b8b6021913960400191505060405180910390fd5b61429f826000836140ff565b6142e9816040518060600160405280602281526020016149b86022913973ffffffffffffffffffffffffffffffffffffffff85166000908152600260205260409020549190613751565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604090205560045461431c9082613882565b60045560408051828152905160009173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b73ffffffffffffffffffffffffffffffffffffffff82166143f357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6143ff600083836140ff565b60045461440c9082613802565b60045573ffffffffffffffffffffffffffffffffffffffff821660009081526002602052604090205461443f9082613802565b73ffffffffffffffffffffffffffffffffffffffff831660008181526002602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6040805173ffffffffffffffffffffffffffffffffffffffff80861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790526145399085906146b0565b50505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526141a49084906146b0565b600081815260018301602052604081205480156146a65783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808301919081019060009087908390811061461d57fe5b906000526020600020015490508087600001848154811061463a57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061466a57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611155565b6000915050611155565b6000614712826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166147889092919063ffffffff16565b8051909150156141a45780806020019051602081101561473157600080fd5b50516141a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614c75602a913960400191505060405180910390fd5b6060612a1184846000858561479c85613d33565b61480757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061487057805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101614833565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146148d2576040519150601f19603f3d011682016040523d82523d6000602084013e6148d7565b606091505b50915091506148e78282866148f2565b979650505050505050565b606083156149015750816114e2565b8251156149115782518084602001fd5b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526020600482018181528451602484015284518593919283926044019190850190808383600083156137bf5781810151838201526020016137a756fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e647345524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737375706461746552656465656d53657474696e67733a2077726f6e6720726174696f2076616c7565737570646174655472616e7366657257686974656c6973743a2043616e6e6f742072656d6f76652078477261696c2066726f6d2077686974656c69737475706461746552656465656d53657474696e67733a2077726f6e67206475726174696f6e2076616c75657345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63656465616c6c6f636174653a206e6f6e20617574686f72697a656420616d6f756e74617070726f766555736167653a20617070726f766520746f20746865207a65726f20616464726573736465616c6c6f636174653a20616d6f756e742063616e6e6f74206265206e756c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737372656465656d3a2078477261696c416d6f756e742063616e6e6f74206265206e756c6c45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737376616c696461746552656465656d3a2072656465656d20656e74727920646f6573206e6f7420657869737466696e616c697a6552656465656d3a2076657374696e67206475726174696f6e20686173206e6f7420656e646564207965745361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212205314526ff0d15730527b77f49931a05ad8f488c21adde691ae4ae1e8824f6c5664736f6c634300070600330000000000000000000000003d9907f9a368ad0a51be60f7da3b97cf940982d8

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

0000000000000000000000003d9907f9a368ad0a51be60f7da3b97cf940982d8

-----Decoded View---------------
Arg [0] : grailToken_ (address): 0x3d9907f9a368ad0a51be60f7da3b97cf940982d8

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000003d9907f9a368ad0a51be60f7da3b97cf940982d8


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.