Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xB1Cd0BF79d7F7282CC053e9121164B3B8a4f54E7
Balance 0 ETH
Nonce 1
Code Size 7283 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7283 bytes
0x608060405234801561001057600080fd5b506004361061010f5760003560e060020a90048063996a63b9116100a6578063cbf0b0c011610075578063cbf0b0c01461039a578063e1af3c05146103c0578063f2fde38b14610410578063f9214eec14610436578063fc0c546a1461045c5761010f565b8063996a63b9146102c9578063abd4818414610309578063abe72d3e1461032f578063b74e452b146103795761010f565b80636db656c3116100e25780636db656c3146101c6578063715018a6146102205780638da5cb5b146102285780638dc651fd1461024c5761010f565b806306b091f9146101145780631817c5a71461014257806336ccda4f1461016857806356492406146101be575b600080fd5b6101406004803603604081101561012a57600080fd5b50600160a060020a038135169060200135610464565b005b6101406004803603602081101561015857600080fd5b5035600160a060020a03166104d7565b61018e6004803603602081101561017e57600080fd5b5035600160a060020a0316610670565b60408051941515855263ffffffff9384166020860152918316848301529091166060830152519081900360800190f35b6101406106b3565b610140600480360360e08110156101dc57600080fd5b50600160a060020a038135169060208101359063ffffffff60408201358116916060810135821691608082013581169160a08101359091169060c00135151561075a565b610140610852565b61023061090e565b60408051600160a060020a039092168252519081900360200190f35b61027e6004803603604081101561026257600080fd5b508035600160a060020a0316906020013563ffffffff1661091d565b604080519889526020890197909752878701959095526060870193909352608086019190915263ffffffff1660a0850152151560c0840152151560e083015251908190036101000190f35b610140600480360360808110156102df57600080fd5b50600160a060020a03813581169160208101359163ffffffff6040830135169160600135166109b0565b61018e6004803603602081101561031f57600080fd5b5035600160a060020a0316610a27565b610140600480360360a081101561034557600080fd5b50600160a060020a038135169063ffffffff6020820135811691604081013582169160608201351690608001351515610a71565b610381610aea565b6040805163ffffffff9092168252519081900360200190f35b610140600480360360208110156103b057600080fd5b5035600160a060020a0316610af3565b610140600480360360c08110156103d657600080fd5b50600160a060020a038135169060208101359063ffffffff604082013581169160608101358216916080820135169060a001351515610bf0565b6101406004803603602081101561042657600080fd5b5035600160a060020a0316610c73565b6101406004803603602081101561044c57600080fd5b5035600160a060020a0316610d88565b610230610e2c565b61046c610e3b565b600160a060020a031661047d61090e565b600160a060020a0316146104c9576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b6104d38282610e3f565b5050565b6104df610e3b565b600160a060020a03166104f061090e565b600160a060020a03161461053c576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b600160a060020a03808216600090815260026020818152604080842092830154909416835260019052919020815460ff166105c1576040805160e560020a62461bcd02815260206004820152600f60248201527f6e6f20616374697665206772616e740000000000000000000000000000000000604482015290519081900360640190fd5b805460ff1661061a576040805160e560020a62461bcd02815260206004820152600b60248201527f69727265766f6361626c65000000000000000000000000000000000000000000604482015290519081900360640190fd5b600160a060020a038316600081815260026020526040808220805460ff1961ff001990911661010017169055517fbadc5b2ca6241beb42d4f1c0481f982a91e7aceaca195b8825f6187ad50018e59190a2505050565b600160a060020a038082166000908152600260208190526040822090810154919283928392839290916106a39116610a27565b9450945094509450509193509193565b6106bb610e3b565b600160a060020a03166106cc61090e565b600160a060020a031614610718576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b60005b6003548110156107575761074f6003828154811061073557fe5b600091825260209091200154600160a060020a0316610ff1565b60010161071b565b50565b610762610e3b565b600160a060020a031661077361090e565b600160a060020a0316146107bf576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b600160a060020a03871660009081526002602052604090205460ff1615610830576040805160e560020a62461bcd02815260206004820152601460248201527f6772616e7420616c726561647920657869737473000000000000000000000000604482015290519081900360640190fd5b61083d878486858561108f565b6108498787878a611315565b50505050505050565b61085a610e3b565b600160a060020a031661086b61090e565b600160a060020a0316146108b7576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b60008054604051600160a060020a03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031690565b600160a060020a038216600090815260026020526040812081908190819081908190819081908161094e8c8c6115c8565b6001830154909150610960908261174b565b81836001015461097085856117ab565b60038601549554939d50919b50995097509195505063ffffffff62010000820416935060ff80821693506101009091041690509295985092959890939650565b6109b8610e3b565b600160a060020a03166109c961090e565b600160a060020a031614610a15576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b610a2184848484611315565b50505050565b600160a060020a031660009081526001602052604090205460ff81169163ffffffff6501000000000083048116926101008104821692690100000000000000000090910490911690565b610a79610e3b565b600160a060020a0316610a8a61090e565b600160a060020a031614610ad6576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b610ae3858585858561108f565b5050505050565b62015180420490565b610afb610e3b565b600160a060020a0316610b0c61090e565b600160a060020a031614610b58576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b610be481610b64610e2c565b600160a060020a03166370a08231306040518263ffffffff1660e060020a0281526004018082600160a060020a0316815260200191505060206040518083038186803b158015610bb357600080fd5b505afa158015610bc7573d6000803e3d6000fd5b505050506040513d6020811015610bdd57600080fd5b5051610e3f565b80600160a060020a0316ff5b610bf8610e3b565b600160a060020a0316610c0961090e565b600160a060020a031614610c55576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b610c6b8686610c62610aea565b8787878761075a565b505050505050565b610c7b610e3b565b600160a060020a0316610c8c61090e565b600160a060020a031614610cd8576040805160e560020a62461bcd0281526020600482018190526024820152600080516020611baa833981519152604482015290519081900360640190fd5b600160a060020a038116610d205760405160e560020a62461bcd028152600401808060200182810382526026815260200180611b636026913960400191505060405180910390fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b80610d9161090e565b600160a060020a0316610da2610e3b565b600160a060020a03161480610dcf575080600160a060020a0316610dc4610e3b565b600160a060020a0316145b610e23576040805160e560020a62461bcd02815260206004820152600f60248201527f6f6e6c794f776e65724f7253656c660000000000000000000000000000000000604482015290519081900360640190fd5b6104d382610ff1565b600454600160a060020a031690565b3390565b60008111610e97576040805160e560020a62461bcd02815260206004820152601260248201527f616d6f756e74206d757374206265203e20300000000000000000000000000000604482015290519081900360640190fd5b610e9f610e2c565b600160a060020a03166370a08231306040518263ffffffff1660e060020a0281526004018082600160a060020a0316815260200191505060206040518083038186803b158015610eee57600080fd5b505afa158015610f02573d6000803e3d6000fd5b505050506040513d6020811015610f1857600080fd5b5051811115610f5b5760405160e560020a62461bcd028152600401808060200182810382526021815260200180611bed6021913960400191505060405180910390fd5b610f63610e2c565b600160a060020a031663a9059cbb83836040518363ffffffff1660e060020a0281526004018083600160a060020a0316815260200182815260200192505050602060405180830381600087803b158015610fbc57600080fd5b505af1158015610fd0573d6000803e3d6000fd5b505050506040513d6020811015610fe657600080fd5b50516104d357600080fd5b6000610ffe826000611868565b905080156104d3576110108282611893565b600160a060020a0382166000908152600260205260409020600301546110369082611a1c565b600160a060020a038316600081815260026020908152604091829020600301939093558051848152905191927f5952e800de5564aff4cc315e219327cf6d706cbba481d1613c32f4b1aa17dcdd92918290030190a25050565b60008363ffffffff161180156110ad5750610e4463ffffffff841611155b80156110c457508263ffffffff168463ffffffff16105b80156110d7575060018263ffffffff1610155b61112b576040805160e560020a62461bcd02815260206004820152601860248201527f696e76616c69642076657374696e67207363686564756c650000000000000000604482015290519081900360640190fd5b8163ffffffff168363ffffffff168161114057fe5b0663ffffffff16600014801561117157508163ffffffff168463ffffffff168161116657fe5b0663ffffffff166000145b6111af5760405160e560020a62461bcd028152600401808060200182810382526023815260200180611bca6023913960400191505060405180910390fd5b604051806080016040528082151581526020018563ffffffff1681526020018463ffffffff1681526020018363ffffffff168152506001600087600160a060020a0316600160a060020a0316815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a81548163ffffffff021916908363ffffffff16021790555060408201518160000160056101000a81548163ffffffff021916908363ffffffff16021790555060608201518160000160096101000a81548163ffffffff021916908363ffffffff16021790555090505084600160a060020a03167fb84219eaee5910cc5311a393fbd4287b14bc791973b97f64d4b61b6d8554adc785858585604051808563ffffffff1681526020018463ffffffff1681526020018363ffffffff168152602001821515815260200194505050505060405180910390a25050505050565b600160a060020a03841660009081526002602052604090205460ff1615611386576040805160e560020a62461bcd02815260206004820152601460248201527f6772616e7420616c726561647920657869737473000000000000000000000000604482015290519081900360640190fd5b60008311801561139e5750612acd63ffffffff831610155b80156113b257506205bd8863ffffffff8316105b611406576040805160e560020a62461bcd02815260206004820152601660248201527f696e76616c69642076657374696e6720706172616d7300000000000000000000604482015290519081900360640190fd5b6040518060c001604052806001151581526020016000151581526020018363ffffffff16815260200184815260200182600160a060020a0316815260200160008152506002600086600160a060020a0316600160a060020a0316815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a81548160ff02191690831515021790555060408201518160000160026101000a81548163ffffffff021916908363ffffffff1602179055506060820151816001015560808201518160020160006101000a815481600160a060020a030219169083600160a060020a0316021790555060a082015181600301559050506003849080600181540180825580915050600190039060005260206000200160009091909190916101000a815481600160a060020a030219169083600160a060020a0316021790555083600160a060020a03167f4c8446f7c7d1fef2c389127c7f901f8b56c628cea596ad7ce805fa5f89097ccb848484604051808481526020018363ffffffff16815260200182600160a060020a03168152602001935050505060405180910390a250505050565b600160a060020a038083166000908152600260208181526040808420928301549094168352600190529181209091908261160185611a80565b835490915060ff16158061163557508154835462010000900463ffffffff9081166101009092048116919091018116908216105b15611647575050600101549050611745565b8154835462010000900463ffffffff9081166501000000000090920481169190910181169082161061167f5760009350505050611745565b8254825463ffffffff6201000090920482168303916000916901000000000000000000900481169081908416816116b257fe5b0402905060006116f98560000160059054906101000a900463ffffffff1663ffffffff166116f38463ffffffff168960010154611a9c90919063ffffffff16565b90611af8565b9050600061171482886001015461174b90919063ffffffff16565b90508660010154811115801561172e575086600101548211155b61173757600080fd5b965061174595505050505050565b92915050565b6000828211156117a5576040805160e560020a62461bcd02815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000806117c583856001015461174b90919063ffffffff16565b905083600301548110156117fa57801580156117e757508354610100900460ff165b6117f057600080fd5b6000915050611745565b600061181385600301548361174b90919063ffffffff16565b90508460010154811115801561183b5750600185015460038601546118389083611a1c565b11155b80156118475750818111155b8015611857575084600101548211155b61186057600080fd5b949350505050565b600160a060020a03821660009081526002602052604081206118608161188e86866115c8565b6117ab565b600081116118eb576040805160e560020a62461bcd02815260206004820152601260248201527f616d6f756e74206d757374206265203e20300000000000000000000000000000604482015290519081900360640190fd5b6118f3610e2c565b600160a060020a03166370a08231306040518263ffffffff1660e060020a0281526004018082600160a060020a0316815260200191505060206040518083038186803b15801561194257600080fd5b505afa158015611956573d6000803e3d6000fd5b505050506040513d602081101561196c57600080fd5b50518111156119af5760405160e560020a62461bcd028152600401808060200182810382526021815260200180611bed6021913960400191505060405180910390fd5b600160a060020a038216600090815260026020526040902060018101546003909101546119dc9083611a1c565b1115610f5b5760405160e560020a62461bcd028152600401808060200182810382526030815260200180611c0e6030913960400191505060405180910390fd5b600082820183811015611a79576040805160e560020a62461bcd02815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600063ffffffff821615611a945781611745565b611745610aea565b600082611aab57506000611745565b82820282848281611ab857fe5b0414611a795760405160e560020a62461bcd028152600401808060200182810382526021815260200180611b896021913960400191505060405180910390fd5b6000808211611b51576040805160e560020a62461bcd02815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381611b5a57fe5b04939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572696e76616c696420636c6966662f6475726174696f6e20666f7220696e74657276616c616d6f756e74206d757374206265203c3d2063757272656e742062616c616e63656e657720636c61696d656420616d6f756e74206d757374206265203c3d20746f74616c206772616e7420616d6f756e74a2646970667358221220c03975bcf66602b0851a5d505de8b5094bd9c09c2e30e653c82d7f499935e9f764736f6c634300060c0033

Verified Source Code Partial Match

Compiler: v0.6.12+commit.27d51765 EVM: byzantium Optimization: Yes (200 runs)
TokenVesting.sol 1077 lines
// File: @openzeppelin/contracts/utils/Context.sol

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: @openzeppelin/contracts/access/Ownable.sol

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/math/SafeMath.sol

/**
 * @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: contracts/Interfaces/TokenVestingInterface.sol

pragma solidity 0.6.12;

abstract contract TokenVestingInterface {
  event VestingScheduleCreated(
    address indexed vestingLocation,
    uint32 cliffDuration,
    uint32 duration,
    uint32 interval,
    bool isRevocable
  );

  event VestingTokensGranted(
    address indexed beneficiary,
    uint256 vestingAmount,
    uint32 startDay,
    address vestingLocation
  );

  event VestingTokensClaimed(address indexed beneficiary, uint256 amount);

  event GrantRevoked(address indexed grantHolder);

  struct vestingSchedule {
    bool isRevocable; /* true if the vesting option is revocable (a gift), false if irrevocable (purchased) */
    uint32 cliffDuration; /* Duration of the cliff, with respect to the grant start day, in days. */
    uint32 duration; /* Duration of the vesting schedule, with respect to the grant start day, in days. */
    uint32 interval; /* Duration in days of the vesting interval. */
  }

  struct tokenGrant {
    bool isActive; /* true if this vesting entry is active and in-effect entry. */
    bool wasRevoked; /* true if this vesting schedule was revoked. */
    uint32 startDay; /* Start day of the grant, in days since the UNIX epoch (start of day). */
    uint256 amount; /* Total number of tokens that vest. */
    address vestingLocation; /* Address of wallet that is holding the vesting schedule. */
    uint256 claimedAmount; /* Out of vested amount, the amount that has been already transferred to beneficiary */
  }

  function token() public view virtual returns (IERC20);

  function kill(address payable beneficiary) external virtual;

  function withdrawTokens(address beneficiary, uint256 amount) external virtual;

  // =========================================================================
  // === Methods for claiming tokens.
  // =========================================================================

  function claimVestingTokens(address beneficiary) external virtual;

  function claimVestingTokensForAll() external virtual;

  // =========================================================================
  // === Methods for administratively creating a vesting schedule for an account.
  // =========================================================================

  function setVestingSchedule(
    address vestingLocation,
    uint32 cliffDuration,
    uint32 duration,
    uint32 interval,
    bool isRevocable
  ) external virtual;

  // =========================================================================
  // === Token grants (general-purpose)
  // === Methods to be used for administratively creating one-off token grants with vesting schedules.
  // =========================================================================

  function addGrant(
    address beneficiary,
    uint256 vestingAmount,
    uint32 startDay,
    uint32 duration,
    uint32 cliffDuration,
    uint32 interval,
    bool isRevocable
  ) public virtual;

  function addGrantWithScheduleAt(
    address beneficiary,
    uint256 vestingAmount,
    uint32 startDay,
    address vestingLocation
  ) external virtual;

  function addGrantFromToday(
    address beneficiary,
    uint256 vestingAmount,
    uint32 duration,
    uint32 cliffDuration,
    uint32 interval,
    bool isRevocable
  ) external virtual;

  // =========================================================================
  // === Check vesting.
  // =========================================================================

  function today() public view virtual returns (uint32 dayNumber);

  function getGrantInfo(address grantHolder, uint32 onDayOrToday)
    external
    view
    virtual
    returns (
      uint256 amountVested,
      uint256 amountNotVested,
      uint256 amountOfGrant,
      uint256 amountAvailable,
      uint256 amountClaimed,
      uint32 vestStartDay,
      bool isActive,
      bool wasRevoked
    );

  function getScheduleAtInfo(address vestingLocation)
    public
    view
    virtual
    returns (
      bool isRevocable,
      uint32 vestDuration,
      uint32 cliffDuration,
      uint32 vestIntervalDays
    );

  function getScheduleInfo(address grantHolder)
    external
    view
    virtual
    returns (
      bool isRevocable,
      uint32 vestDuration,
      uint32 cliffDuration,
      uint32 vestIntervalDays
    );

  // =========================================================================
  // === Grant revocation
  // =========================================================================

  function revokeGrant(address grantHolder) external virtual;
}

// File: contracts/Vesting/TokenVesting.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

/**
 * @title Contract for token vesting schedules
 *
 * @dev Contract which gives the ability to act as a pool of funds for allocating
 *   tokens to any number of other addresses. Token grants support the ability to vest over time in
 *   accordance a predefined vesting schedule. A given wallet can receive no more than one token grant.
 */
contract TokenVesting is TokenVestingInterface, Context, Ownable {
  using SafeMath for uint256;

  // Date-related constants for sanity-checking dates to reject obvious erroneous inputs
  // and conversions from seconds to days and years that are more or less leap year-aware.
  uint32 private constant _THOUSAND_YEARS_DAYS = 365243; /* See https://www.timeanddate.com/date/durationresult.html?m1=1&d1=1&y1=2000&m2=1&d2=1&y2=3000 */
  uint32 private constant _TEN_YEARS_DAYS = _THOUSAND_YEARS_DAYS / 100; /* Includes leap years (though it doesn't really matter) */
  uint32 private constant _SECONDS_PER_DAY = 24 * 60 * 60; /* 86400 seconds in a day */
  uint32 private constant _JAN_1_2000_SECONDS = 946684800; /* Saturday, January 1, 2000 0:00:00 (GMT) (see https://www.epochconverter.com/) */
  uint32 private constant _JAN_1_2000_DAYS =
    _JAN_1_2000_SECONDS / _SECONDS_PER_DAY;
  uint32 private constant _JAN_1_3000_DAYS =
    _JAN_1_2000_DAYS + _THOUSAND_YEARS_DAYS;

  modifier onlyOwnerOrSelf(address account) {
    require(
      _msgSender() == owner() || _msgSender() == account,
      "onlyOwnerOrSelf"
    );
    _;
  }

  mapping(address => vestingSchedule) private _vestingSchedules;
  mapping(address => tokenGrant) private _tokenGrants;
  address[] private _allBeneficiaries;
  IERC20 private _token;

  constructor(IERC20 token_) public {
    require(address(token_) != address(0), "token must be non-zero address");
    _token = token_;
  }

  function token() public view override returns (IERC20) {
    return _token;
  }

  function kill(address payable beneficiary) external override onlyOwner {
    _withdrawTokens(beneficiary, token().balanceOf(address(this)));
    selfdestruct(beneficiary);
  }

  function withdrawTokens(address beneficiary, uint256 amount)
    external
    override
    onlyOwner
  {
    _withdrawTokens(beneficiary, amount);
  }

  function _withdrawTokens(address beneficiary, uint256 amount) internal {
    require(amount > 0, "amount must be > 0");
    require(
      amount <= token().balanceOf(address(this)),
      "amount must be <= current balance"
    );

    require(token().transfer(beneficiary, amount));
  }

  // =========================================================================
  // === Methods for claiming tokens.
  // =========================================================================

  function claimVestingTokens(address beneficiary)
    external
    override
    onlyOwnerOrSelf(beneficiary)
  {
    _claimVestingTokens(beneficiary);
  }

  function claimVestingTokensForAll() external override onlyOwner {
    for (uint256 i = 0; i < _allBeneficiaries.length; i++) {
      _claimVestingTokens(_allBeneficiaries[i]);
    }
  }

  function _claimVestingTokens(address beneficiary) internal {
    uint256 amount = _getAvailableAmount(beneficiary, 0);
    if (amount > 0) {
      _deliverTokens(beneficiary, amount);
      _tokenGrants[beneficiary].claimedAmount = _tokenGrants[beneficiary]
        .claimedAmount
        .add(amount);
      emit VestingTokensClaimed(beneficiary, amount);
    }
  }

  function _deliverTokens(address beneficiary, uint256 amount) internal {
    require(amount > 0, "amount must be > 0");
    require(
      amount <= token().balanceOf(address(this)),
      "amount must be <= current balance"
    );
    require(
      _tokenGrants[beneficiary].claimedAmount.add(amount) <=
        _tokenGrants[beneficiary].amount,
      "new claimed amount must be <= total grant amount"
    );

    require(token().transfer(beneficiary, amount));
  }

  // =========================================================================
  // === Methods for administratively creating a vesting schedule for an account.
  // =========================================================================

  /**
   * @dev This one-time operation permanently establishes a vesting schedule in the given account.
   *
   * @param cliffDuration = Duration of the cliff, with respect to the grant start day, in days.
   * @param duration = Duration of the vesting schedule, with respect to the grant start day, in days.
   * @param interval = Number of days between vesting increases.
   * @param isRevocable = True if the grant can be revoked (i.e. was a gift) or false if it cannot
   *   be revoked (i.e. tokens were purchased).
   */
  function setVestingSchedule(
    address vestingLocation,
    uint32 cliffDuration,
    uint32 duration,
    uint32 interval,
    bool isRevocable
  ) external override onlyOwner {
    _setVestingSchedule(
      vestingLocation,
      cliffDuration,
      duration,
      interval,
      isRevocable
    );
  }

  function _setVestingSchedule(
    address vestingLocation,
    uint32 cliffDuration,
    uint32 duration,
    uint32 interval,
    bool isRevocable
  ) internal {
    // Check for a valid vesting schedule given (disallow absurd values to reject likely bad input).
    require(
      duration > 0 &&
        duration <= _TEN_YEARS_DAYS &&
        cliffDuration < duration &&
        interval >= 1,
      "invalid vesting schedule"
    );

    // Make sure the duration values are in harmony with interval (both should be an exact multiple of interval).
    require(
      duration % interval == 0 && cliffDuration % interval == 0,
      "invalid cliff/duration for interval"
    );

    // Create and populate a vesting schedule.
    _vestingSchedules[vestingLocation] = vestingSchedule(
      isRevocable,
      cliffDuration,
      duration,
      interval
    );

    // Emit the event.
    emit VestingScheduleCreated(
      vestingLocation,
      cliffDuration,
      duration,
      interval,
      isRevocable
    );
  }

  // =========================================================================
  // === Token grants (general-purpose)
  // === Methods to be used for administratively creating one-off token grants with vesting schedules.
  // =========================================================================

  /**
   * @dev Grants tokens to an account.
   *
   * @param beneficiary = Address to which tokens will be granted.
   * @param vestingAmount = The number of tokens subject to vesting.
   * @param startDay = Start day of the grant's vesting schedule, in days since the UNIX epoch
   *   (start of day). The startDay may be given as a date in the future or in the past, going as far
   *   back as year 2000.
   * @param vestingLocation = Account where the vesting schedule is held (must already exist).
   */
  function _addGrant(
    address beneficiary,
    uint256 vestingAmount,
    uint32 startDay,
    address vestingLocation
  ) internal {
    // Make sure no prior grant is in effect.
    require(!_tokenGrants[beneficiary].isActive, "grant already exists");

    // Check for valid vestingAmount
    require(
      vestingAmount > 0 &&
        startDay >= _JAN_1_2000_DAYS &&
        startDay < _JAN_1_3000_DAYS,
      "invalid vesting params"
    );

    // Create and populate a token grant, referencing vesting schedule.
    _tokenGrants[beneficiary] = tokenGrant(
      true, // isActive
      false, // wasRevoked
      startDay,
      vestingAmount,
      vestingLocation, // The wallet address where the vesting schedule is kept.
      0 // claimedAmount
    );
    _allBeneficiaries.push(beneficiary);

    // Emit the event.
    emit VestingTokensGranted(
      beneficiary,
      vestingAmount,
      startDay,
      vestingLocation
    );
  }

  /**
   * @dev Grants tokens to an address, including a portion that will vest over time
   * according to a set vesting schedule. The overall duration and cliff duration of the grant must
   * be an even multiple of the vesting interval.
   *
   * @param beneficiary = Address to which tokens will be granted.
   * @param vestingAmount = The number of tokens subject to vesting.
   * @param startDay = Start day of the grant's vesting schedule, in days since the UNIX epoch
   *   (start of day). The startDay may be given as a date in the future or in the past, going as far
   *   back as year 2000.
   * @param duration = Duration of the vesting schedule, with respect to the grant start day, in days.
   * @param cliffDuration = Duration of the cliff, with respect to the grant start day, in days.
   * @param interval = Number of days between vesting increases.
   * @param isRevocable = True if the grant can be revoked (i.e. was a gift) or false if it cannot
   *   be revoked (i.e. tokens were purchased).
   */
  function addGrant(
    address beneficiary,
    uint256 vestingAmount,
    uint32 startDay,
    uint32 duration,
    uint32 cliffDuration,
    uint32 interval,
    bool isRevocable
  ) public override onlyOwner {
    // Make sure no prior vesting schedule has been set.
    require(!_tokenGrants[beneficiary].isActive, "grant already exists");

    // The vesting schedule is unique to this wallet and so will be stored here,
    _setVestingSchedule(
      beneficiary,
      cliffDuration,
      duration,
      interval,
      isRevocable
    );

    // Issue tokens to the beneficiary, using beneficiary's own vesting schedule.
    _addGrant(beneficiary, vestingAmount, startDay, beneficiary);
  }

  function addGrantWithScheduleAt(
    address beneficiary,
    uint256 vestingAmount,
    uint32 startDay,
    address vestingLocation
  ) external override onlyOwner {
    // Issue tokens to the beneficiary, using custom vestingLocation.
    _addGrant(beneficiary, vestingAmount, startDay, vestingLocation);
  }

  function addGrantFromToday(
    address beneficiary,
    uint256 vestingAmount,
    uint32 duration,
    uint32 cliffDuration,
    uint32 interval,
    bool isRevocable
  ) external override onlyOwner {
    addGrant(
      beneficiary,
      vestingAmount,
      today(),
      duration,
      cliffDuration,
      interval,
      isRevocable
    );
  }

  // =========================================================================
  // === Check vesting.
  // =========================================================================
  function today() public view virtual override returns (uint32 dayNumber) {
    return uint32(block.timestamp / _SECONDS_PER_DAY);
  }

  function _effectiveDay(uint32 onDayOrToday)
    internal
    view
    returns (uint32 dayNumber)
  {
    return onDayOrToday == 0 ? today() : onDayOrToday;
  }

  /**
   * @dev Determines the amount of tokens that have not vested in the given account.
   *
   * The math is: not vested amount = vesting amount * (end date - on date)/(end date - start date)
   *
   * @param grantHolder = The account to check.
   * @param onDayOrToday = The day to check for, in days since the UNIX epoch. Can pass
   *   the special value 0 to indicate today.
   */
  function _getNotVestedAmount(address grantHolder, uint32 onDayOrToday)
    internal
    view
    returns (uint256 amountNotVested)
  {
    tokenGrant storage grant = _tokenGrants[grantHolder];
    vestingSchedule storage vesting = _vestingSchedules[grant.vestingLocation];
    uint32 onDay = _effectiveDay(onDayOrToday);

    // If there's no schedule, or before the vesting cliff, then the full amount is not vested.
    if (!grant.isActive || onDay < grant.startDay + vesting.cliffDuration) {
      // None are vested (all are not vested)
      return grant.amount;
    }
    // If after end of vesting, then the not vested amount is zero (all are vested).
    else if (onDay >= grant.startDay + vesting.duration) {
      // All are vested (none are not vested)
      return uint256(0);
    }
    // Otherwise a fractional amount is vested.
    else {
      // Compute the exact number of days vested.
      uint32 daysVested = onDay - grant.startDay;
      // Adjust result rounding down to take into consideration the interval.
      uint32 effectiveDaysVested = (daysVested / vesting.interval) *
        vesting.interval;

      // Compute the fraction vested from schedule using 224.32 fixed point math for date range ratio.
      // Note: This is safe in 256-bit math because max value of X billion tokens = X*10^27 wei, and
      // typical token amounts can fit into 90 bits. Scaling using a 32 bits value results in only 125
      // bits before reducing back to 90 bits by dividing. There is plenty of room left, even for token
      // amounts many orders of magnitude greater than mere billions.
      uint256 vested = grant.amount.mul(effectiveDaysVested).div(
        vesting.duration
      );
      uint256 result = grant.amount.sub(vested);
      require(result <= grant.amount && vested <= grant.amount);

      return result;
    }
  }

  /**
   * @dev Computes the amount of funds in the given account which are available for use as of
   * the given day, i.e. the claimable amount.
   *
   * The math is: available amount = totalGrantAmount - notVestedAmount - claimedAmount.
   *
   * @param grantHolder = The account to check.
   * @param onDay = The day to check for, in days since the UNIX epoch.
   */
  function _getAvailableAmount(address grantHolder, uint32 onDay)
    internal
    view
    returns (uint256 amountAvailable)
  {
    tokenGrant storage grant = _tokenGrants[grantHolder];
    return
      _getAvailableAmountImpl(grant, _getNotVestedAmount(grantHolder, onDay));
  }

  function _getAvailableAmountImpl(
    tokenGrant storage grant,
    uint256 notVastedOnDay
  ) internal view returns (uint256 amountAvailable) {
    uint256 vested = grant.amount.sub(notVastedOnDay);
    if (vested < grant.claimedAmount) {
      // .sub below will fail, only possible when grant revoked
      require(vested == 0 && grant.wasRevoked);
      return 0;
    }

    uint256 result = vested.sub(grant.claimedAmount);
    require(
      result <= grant.amount &&
        grant.claimedAmount.add(result) <= grant.amount &&
        result <= vested &&
        vested <= grant.amount
    );

    return result;
  }

  /**
   * @dev returns all information about the grant's vesting as of the given day
   * for the given account. Only callable by the account holder or a contract owner.
   *
   * @param grantHolder = The address to do this for.
   * @param onDayOrToday = The day to check for, in days since the UNIX epoch. Can pass
   *   the special value 0 to indicate today.
   * return = A tuple with the following values:
   *   amountVested = the amount that is already vested
   *   amountNotVested = the amount that is not yet vested (equal to vestingAmount - vestedAmount)
   *   amountOfGrant = the total amount of tokens subject to vesting.
   *   amountAvailable = the amount of funds in the given account which are available for use as of the given day
   *   amountClaimed = out of amountVested, the amount that has been already transferred to beneficiary
   *   vestStartDay = starting day of the grant (in days since the UNIX epoch).
   *   isActive = true if the vesting schedule is currently active.
   *   wasRevoked = true if the vesting schedule was revoked.
   */
  function getGrantInfo(address grantHolder, uint32 onDayOrToday)
    external
    view
    override
    returns (
      uint256 amountVested,
      uint256 amountNotVested,
      uint256 amountOfGrant,
      uint256 amountAvailable,
      uint256 amountClaimed,
      uint32 vestStartDay,
      bool isActive,
      bool wasRevoked
    )
  {
    tokenGrant storage grant = _tokenGrants[grantHolder];
    uint256 notVestedAmount = _getNotVestedAmount(grantHolder, onDayOrToday);

    return (
      grant.amount.sub(notVestedAmount),
      notVestedAmount,
      grant.amount,
      _getAvailableAmountImpl(grant, notVestedAmount),
      grant.claimedAmount,
      grant.startDay,
      grant.isActive,
      grant.wasRevoked
    );
  }

  function getScheduleAtInfo(address vestingLocation)
    public
    view
    override
    returns (
      bool isRevocable,
      uint32 vestDuration,
      uint32 cliffDuration,
      uint32 vestIntervalDays
    )
  {
    vestingSchedule storage vesting = _vestingSchedules[vestingLocation];

    return (
      vesting.isRevocable,
      vesting.duration,
      vesting.cliffDuration,
      vesting.interval
    );
  }

  function getScheduleInfo(address grantHolder)
    external
    view
    override
    returns (
      bool isRevocable,
      uint32 vestDuration,
      uint32 cliffDuration,
      uint32 vestIntervalDays
    )
  {
    tokenGrant storage grant = _tokenGrants[grantHolder];
    return getScheduleAtInfo(grant.vestingLocation);
  }

  // =========================================================================
  // === Grant revocation
  // =========================================================================

  /**
   * @dev If the account has a revocable grant, this forces the grant to end immediately.
   * After this function is called, getGrantInfo will return incomplete data
   * and there will be no possibility to claim non-claimed tokens
   *
   * @param grantHolder = Address to which tokens will be granted.
   */
  function revokeGrant(address grantHolder) external override onlyOwner {
    tokenGrant storage grant = _tokenGrants[grantHolder];
    vestingSchedule storage vesting = _vestingSchedules[grant.vestingLocation];

    // Make sure a vesting schedule has previously been set.
    require(grant.isActive, "no active grant");
    // Make sure it's revocable.
    require(vesting.isRevocable, "irrevocable");

    // Kill the grant by updating wasRevoked and isActive.
    _tokenGrants[grantHolder].wasRevoked = true;
    _tokenGrants[grantHolder].isActive = false;

    // Emits the GrantRevoked event.
    emit GrantRevoked(grantHolder);
  }
}

Read Contract

getGrantInfo 0x8dc651fd → uint256, uint256, uint256, uint256, uint256, uint32, bool, bool
getScheduleAtInfo 0xabd48184 → bool, uint32, uint32, uint32
getScheduleInfo 0x36ccda4f → bool, uint32, uint32, uint32
owner 0x8da5cb5b → address
today 0xb74e452b → uint32
token 0xfc0c546a → address

Write Contract 11 functions

These functions modify contract state and require a wallet transaction to execute.

addGrant 0x6db656c3
address beneficiary
uint256 vestingAmount
uint32 startDay
uint32 duration
uint32 cliffDuration
uint32 interval
bool isRevocable
addGrantFromToday 0xe1af3c05
address beneficiary
uint256 vestingAmount
uint32 duration
uint32 cliffDuration
uint32 interval
bool isRevocable
addGrantWithScheduleAt 0x996a63b9
address beneficiary
uint256 vestingAmount
uint32 startDay
address vestingLocation
claimVestingTokens 0xf9214eec
address beneficiary
claimVestingTokensForAll 0x56492406
No parameters
kill 0xcbf0b0c0
address beneficiary
renounceOwnership 0x715018a6
No parameters
revokeGrant 0x1817c5a7
address grantHolder
setVestingSchedule 0xabe72d3e
address vestingLocation
uint32 cliffDuration
uint32 duration
uint32 interval
bool isRevocable
transferOwnership 0xf2fde38b
address newOwner
withdrawTokens 0x06b091f9
address beneficiary
uint256 amount

Recent Transactions

No transactions found for this address