contract PrivateSale is TokenlessCrowdsale, WhitelistedAICrowdsale, FiatCappedCrowdsale, PausableCrowdsale {
  using SafeMath for uint256;

  // The 2 tokens being sold
  RestrictedToken public tokenR0; // SPX-R0 - restricted token with no vesting
  RestrictedToken public tokenR6; // SPX-R6 - restricted token with 6-month vesting

  uint8 constant bonusPct = 30;

  constructor (address _wallet, uint256 _millWeiRate) TokenlessCrowdsale(_wallet)
    FiatCappedCrowdsale(
      5000000 * (10 ** 3), // millCap: USD 5 million
      10000 * (10 ** 3), // minMillPurchase: USD 10,000
      (10 ** 18) / 50, // millLeconteRate: 1 SPX = USD 0.05
      _millWeiRate
    )
  public {
    tokenR0 = new RestrictedToken(
      2 * 100000000 * (10 ** 18), // supply: 100 million (* 2 for edge safety)
      'Sparrow Token (Restricted)', // name
      'SPX-R0', // symbol
      18, // decimals
      0, // no vesting
      msg.sender, // owner
      this // issuer
    );

    // SPX-R6: Only 30 mil needed if all contributors are AI, 130 mil needed if all contributors are non-AIs
    tokenR6 = new RestrictedToken(
      2 * 130000000 * (10 ** 18), // supply: 130 million (* 2 for edge safety)
      'Sparrow Token (Restricted with 6-month vesting)', // name
      'SPX-R6', // symbol
      18, // decimals
      6 * 30 * 86400, // vesting: 6 months
      msg.sender, // owner
      this // issuer
    );
  }

  // If accredited, non-bonus tokens are given as tokenR0, bonus tokens are given as tokenR6
  // If non-accredited, non-bonus and bonus tokens are given as tokenR6
  function _processPurchaseInWei(address _beneficiary, uint256 _weiAmount) internal {
    super._processPurchaseInWei(_beneficiary, _weiAmount);

    uint256 tokens = _toLeconte(_weiAmount);
    uint256 bonus = tokens.mul(bonusPct).div(100);

    // Accredited
    if (accredited[_beneficiary]) {
      tokenR0.issue(_beneficiary, tokens);
      tokenR6.issue(_beneficiary, bonus);
    } else {
      tokenR6.issue(_beneficiary, tokens.add(bonus));
    }
  }
}
/**
 * @title Sparrow Token private sale
 */
function _processPurchaseInWei(address _beneficiary, uint256 _weiAmount) internal {
  super._processPurchaseInWei(_beneficiary, _weiAmount);

  uint256 tokens = _toLeconte(_weiAmount);
  uint256 bonus = tokens.mul(bonusPct).div(100);

  // Accredited
  if (accredited[_beneficiary]) {
    tokenR0.issue(_beneficiary, tokens);
    tokenR6.issue(_beneficiary, bonus);
  } else {
    tokenR6.issue(_beneficiary, tokens.add(bonus));
  }
}

// If accredited, non-bonus tokens are given as tokenR0, bonus tokens are given as tokenR6
// If non-accredited, non-bonus and bonus tokens are given as tokenR6