文件 1 的 24:Address.sol
pragma solidity ^0.7.0;
library Address {
function isContract(address account) internal view returns (bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
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");
}
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");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 24:CappedTimedCrowdsale.sol
pragma solidity ^0.7.0;
import "./SafeMath.sol";
import "./TimedCrowdsale.sol";
abstract contract CappedTimedCrowdsale is TimedCrowdsale {
using SafeMath for uint256;
uint256 private _cap;
constructor (uint256 capReceived) {
require(capReceived > 0, "CappedCrowdsale: cap is 0");
_cap = capReceived;
}
function cap() public view returns (uint256) {
return _cap;
}
function changeCap(uint256 newCap) internal {
_cap = newCap;
}
function hasClosed() public view override virtual returns (bool) {
return capReached() || super.hasClosed();
}
function capReached() public view returns (bool) {
return weiRaised() >= _cap;
}
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal override virtual view {
super._preValidatePurchase(beneficiary, weiAmount);
require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: cap exceeded");
}
}
文件 3 的 24:ConditionalEscrow.sol
pragma solidity ^0.7.0;
import "./Escrow.sol";
abstract contract ConditionalEscrow is Escrow {
function withdrawalAllowed(address payee) public view virtual returns (bool);
function withdraw(address payable payee) public virtual override {
require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw");
super.withdraw(payee);
}
}
文件 4 的 24:Context.sol
pragma solidity ^0.7.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return msg.data;
}
}
文件 5 的 24:CrowdsaleMint.sol
pragma solidity ^0.7.0;
import "./Context.sol";
import "./IERC20.sol";
import "./SafeERC20.sol";
import "./SafeMath.sol";
import "./LBCToken.sol";
import "./ReentrancyGuard.sol";
contract CrowdsaleMint is Context, ReentrancyGuard {
using SafeMath for uint256;
using SafeERC20 for IERC20;
LBCToken private _token;
address payable private _wallet;
uint256 private _rate;
uint256 private _weiRaised;
event TokensPurchased(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
constructor (uint256 rateReceived, address payable walletReceived, LBCToken tokenReceived) {
require(rateReceived > 0, "Crowdsale: rate is 0");
require(walletReceived != address(0), "Crowdsale: wallet is the zero address");
require(address(tokenReceived) != address(0), "Crowdsale: token is the zero address");
_rate = rateReceived;
_wallet = walletReceived;
_token = tokenReceived;
}
receive() external payable {
buyTokens(_msgSender());
}
fallback() external payable {
buyTokens(_msgSender());
}
function token() public view returns (LBCToken) {
return _token;
}
function _changeToken(LBCToken newToken) internal {
_token = newToken;
}
function wallet() public view returns (address payable) {
return _wallet;
}
function rate() public view virtual returns (uint256) {
return _rate;
}
function weiRaised() public view returns (uint256) {
return _weiRaised;
}
function buyTokens(address beneficiary) public nonReentrant payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(beneficiary, weiAmount);
uint256 tokens = _getTokenAmount(weiAmount);
_weiRaised = _weiRaised.add(weiAmount);
_processPurchase(beneficiary, tokens);
emit TokensPurchased(_msgSender(), beneficiary, weiAmount, tokens);
_updatePurchasingState(beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(beneficiary, weiAmount);
}
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal virtual view {
require(beneficiary != address(0), "Crowdsale: beneficiary is the zero address");
require(weiAmount != 0, "Crowdsale: weiAmount is 0");
this;
}
function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal virtual {
}
function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {
require( _token.mint(beneficiary, tokenAmount) == true, "Crowdsale: minting failed");
}
function _processPurchase(address beneficiary, uint256 tokenAmount) internal virtual {
_deliverTokens(beneficiary, tokenAmount);
}
function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
}
function _getTokenAmount(uint256 weiAmount) internal virtual returns (uint256) {
return weiAmount.mul(_rate);
}
function _forwardFunds() virtual internal {
_wallet.transfer(msg.value);
}
}
文件 6 的 24:ERC20CappedUnburnable.sol
pragma solidity ^0.7.0;
import "./ERC20PausableUnburnable.sol";
abstract contract ERC20CappedUnburnable is ERC20PausableUnburnable {
using SafeMath for uint256;
uint256 private _cap;
constructor (uint256 capGiven) {
require(capGiven > 0, "ERC20Capped: cap is 0");
_cap = capGiven;
}
function cap() public view returns (uint256) {
return _cap;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
if (from == address(0)) {
require(totalSupply().add(amount) <= _cap, "ERC20Capped: cap exceeded");
}
}
}
文件 7 的 24:ERC20PausableUnburnable.sol
pragma solidity ^0.7.0;
import "./ERC20Unburnable.sol";
import "./Pausable.sol";
abstract contract ERC20PausableUnburnable is ERC20Unburnable, Pausable {
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
require(!paused(), "ERC20PausableUnburnable: token transfer while paused");
}
}
文件 8 的 24:ERC20Unburnable.sol
pragma solidity ^0.7.0;
import "./Context.sol";
import "./IERC20.sol";
import "./SafeMath.sol";
import "./Address.sol";
contract ERC20Unburnable is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor (string memory nameGiven, string memory symbolGiven) {
_name = nameGiven;
_symbol = symbolGiven;
_decimals = 18;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
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, "ERC20Unburnable: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20Unburnable: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20Unburnable: transfer from the zero address");
require(recipient != address(0), "ERC20Unburnable: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20Unburnable: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20Unburnable: 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);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20Unburnable: approve from the zero address");
require(spender != address(0), "ERC20Unburnable: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {
}
}
文件 9 的 24:Escrow.sol
pragma solidity ^0.7.0;
import "./SafeMath.sol";
import "./Ownable.sol";
import "./Address.sol";
contract Escrow is Ownable {
using SafeMath for uint256;
using Address for address payable;
event Deposited(address indexed payee, uint256 weiAmount);
event Withdrawn(address indexed payee, uint256 weiAmount);
mapping(address => uint256) private _deposits;
function depositsOf(address payee) public view returns (uint256) {
return _deposits[payee];
}
function deposit(address payee) public virtual payable onlyOwner {
uint256 amount = msg.value;
_deposits[payee] = _deposits[payee].add(amount);
emit Deposited(payee, amount);
}
function withdraw(address payable payee) public virtual onlyOwner {
uint256 payment = _deposits[payee];
_deposits[payee] = 0;
payee.sendValue(payment);
emit Withdrawn(payee, payment);
}
}
文件 10 的 24:FinalizableCrowdsale.sol
pragma solidity ^0.7.0;
import "./SafeMath.sol";
import "./TimedCrowdsale.sol";
abstract contract FinalizableCrowdsale is TimedCrowdsale {
using SafeMath for uint256;
bool private _finalized;
event CrowdsaleFinalized();
constructor () {
_finalized = false;
}
function finalized() public view returns (bool) {
return _finalized;
}
function finalize() public {
require(!_finalized, "FinalizableCrowdsale: already finalized");
require(hasClosed(), "FinalizableCrowdsale: not closed");
_finalized = true;
_finalization();
emit CrowdsaleFinalized();
}
function _finalization() internal virtual {
}
}
文件 11 的 24:HLBICO.sol
pragma solidity ^0.7.0;
import "./SafeMath.sol";
import "./CappedTimedCrowdsale.sol";
import "./RefundPostdevCrowdsale.sol";
contract HLBICO is CappedTimedCrowdsale, RefundablePostDeliveryCrowdsale {
using SafeMath for uint256;
bool public initialized;
address public _deployingAddress;
address public _whitelistingAddress;
address public _reserveAddress;
event InitializedContract(address indexed changerAddress, address indexed whitelistingAddress);
event ChangedWhitelisterAddress(address indexed whitelisterAddress, address indexed changerAddress);
event ChangedReserveAddress(address indexed reserveAddress, address indexed changerAddress);
event ChangedDeployerAddress(address indexed deployerAddress, address indexed changerAddress);
event BlacklistedAdded(address indexed account);
event BlacklistedRemoved(address indexed account);
event UpdatedCaps(uint256 newGoal, uint256 newCap, uint256 newTranche, uint256 newMaxInvest, uint256 newRate, uint256 newRateCoef);
uint256 private _currentRate;
uint256 private _rateCoef;
mapping(address => bool) private _blacklistedAddrs;
mapping(address => uint256) private _investmentAddrs;
uint256 private _weiMaxInvest;
uint256 private _etherTranche;
uint256 private _currentWeiTranche;
uint256 private _deliverToReserve;
uint256 private _minimumInvest;
constructor(uint256 initialRateReceived,
uint256 rateCoefficientReceived,
address payable walletReceived,
LBCToken tokenReceived,
uint256 openingTimeReceived,
uint256 closingTimeReceived,
uint256 capReceived,
uint256 goalReceived)
CrowdsaleMint(initialRateReceived, walletReceived, tokenReceived)
TimedCrowdsale(openingTimeReceived, closingTimeReceived)
CappedTimedCrowdsale(capReceived)
RefundableCrowdsale(goalReceived) {
_deployingAddress = msg.sender;
_etherTranche = 250000000000000000000;
_weiMaxInvest = 8340000000000000000;
_currentRate = initialRateReceived;
_rateCoef = rateCoefficientReceived;
_currentWeiTranche = 0;
_deliverToReserve = 0;
_minimumInvest = 1000000000000000;
}
function init(
address whitelistingAddress,
address reserveAddress
)
public
isNotInitialized
onlyDeployingAddress
{
require(whitelistingAddress != address(0), "HLBICO: whitelistingAddress cannot be 0x");
require(reserveAddress != address(0), "HLBICO: reserveAddress cannot be 0x");
_whitelistingAddress = whitelistingAddress;
_reserveAddress = reserveAddress;
initialized = true;
emit InitializedContract(_msgSender(), whitelistingAddress);
}
function _getCustomAmount(uint256 weiAmount) internal returns (uint256) {
if (!isOpen()) {
return 0;
}
uint256 calculatedAmount = 0;
_currentWeiTranche = _currentWeiTranche.add(weiAmount);
if (_currentWeiTranche > _etherTranche) {
_currentWeiTranche = _currentWeiTranche.sub(_etherTranche);
uint256 manualSkew = weiAmount.sub(_currentWeiTranche);
if (manualSkew >= 0) {
calculatedAmount = calculatedAmount.add(weiAmount.sub(_currentWeiTranche).mul(rate()));
_currentRate -= _rateCoef;
calculatedAmount = calculatedAmount.add(_currentWeiTranche.mul(rate()));
}
else {
_currentRate -= _rateCoef;
calculatedAmount = calculatedAmount.add(weiAmount.mul(rate()));
}
}
else
calculatedAmount = calculatedAmount.add(weiAmount.mul(rate()));
uint256 participationAmount = calculatedAmount.mul(5).div(100);
calculatedAmount = calculatedAmount.sub(participationAmount);
_deliverToReserve = _deliverToReserve.add(participationAmount);
return calculatedAmount;
}
function adjustEtherValue(uint256 coef)
public
onlyDeployingAddress {
require(coef > 0 && coef < 10000, "HLBICO: coef isn't within range of authorized values");
uint256 baseCoef = 1000;
changeGoal(goal().mul(coef).div(1000));
changeCap(cap().mul(coef).div(1000));
_etherTranche = _etherTranche.mul(coef).div(1000);
_weiMaxInvest = _weiMaxInvest.mul(coef).div(1000);
if (coef > 1000) {
coef = coef.sub(1000);
_currentRate = _currentRate.sub(_currentRate.mul(coef).div(1000));
_rateCoef = _rateCoef.sub(_rateCoef.mul(coef).div(1000));
} else {
coef = baseCoef.sub(coef);
_currentRate = _currentRate.add(_currentRate.mul(coef).div(1000));
_rateCoef = _rateCoef.add(_rateCoef.mul(coef).div(1000));
}
emit UpdatedCaps(goal(), cap(), _etherTranche, _weiMaxInvest, _currentRate, _rateCoef);
}
function rate() public view override returns (uint256) {
return _currentRate;
}
function getNextRate() public view returns (uint256) {
return _currentRate.sub(_rateCoef);
}
function changeToken(LBCToken newToken)
public
onlyDeployingAddress
{
_changeToken(newToken);
}
function changeWhitelister(address newWhitelisterAddress)
public
onlyDeployingAddress
{
_whitelistingAddress = newWhitelisterAddress;
emit ChangedWhitelisterAddress(newWhitelisterAddress, _msgSender());
}
function changeDeployer(address newDeployerAddress)
public
onlyDeployingAddress
{
_deployingAddress = newDeployerAddress;
emit ChangedDeployerAddress(_deployingAddress, _msgSender());
}
function changeReserveAddress(address newReserveAddress)
public
onlyDeployingAddress
{
_reserveAddress = newReserveAddress;
emit ChangedReserveAddress(newReserveAddress, _msgSender());
}
function _finalization() override virtual internal {
if (goalReached()) {
_deliverTokens(_reserveAddress, _deliverToReserve);
}
super._finalization();
}
function withdrawTokens(address beneficiary) override virtual public {
require(!isBlacklisted(beneficiary), "HLBICO: account is blacklisted");
super.withdrawTokens(beneficiary);
}
function _getTokenAmount(uint256 weiAmount) internal override returns (uint256) {
return _getCustomAmount(weiAmount);
}
function _forwardFunds() internal override(CrowdsaleMint, RefundablePostDeliveryCrowdsale) {
RefundablePostDeliveryCrowdsale._forwardFunds();
}
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal override(TimedCrowdsale, CappedTimedCrowdsale) view {
require(weiAmount >= _minimumInvest, "HLBICO: Investment must be greater than or equal to 0.001 eth");
_dontExceedAmount(beneficiary, weiAmount);
CappedTimedCrowdsale._preValidatePurchase(beneficiary, weiAmount);
}
function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal override {
require(beneficiary != address(0), "HLBICO: _postValidatePurchase benificiary is the zero address");
_investmentAddrs[beneficiary] = _investmentAddrs[beneficiary].add(weiAmount);
}
function _processPurchase(address beneficiary, uint256 tokenAmount) internal override(CrowdsaleMint, RefundablePostDeliveryCrowdsale) {
RefundablePostDeliveryCrowdsale._processPurchase(beneficiary, tokenAmount);
}
function hasClosed() public view override(TimedCrowdsale, CappedTimedCrowdsale) returns (bool) {
return CappedTimedCrowdsale.hasClosed();
}
function etherTranche() public view returns (uint256) {
return _etherTranche;
}
function maxInvest() public view returns (uint256) {
return _weiMaxInvest;
}
function addBlacklisted(address account) public onlyWhitelistingAddress {
_addBlacklisted(account);
}
function removeBlacklisted(address account) public onlyWhitelistingAddress {
_removeBlacklisted(account);
}
function isBlacklisted(address account) public view returns (bool) {
require(account != address(0), "HLBICO: account is zero address");
return _blacklistedAddrs[account];
}
function _addBlacklisted(address account) internal {
require(!isBlacklisted(account), "HLBICO: account already blacklisted");
_blacklistedAddrs[account] = true;
emit BlacklistedAdded(account);
}
function _removeBlacklisted(address account) internal {
require(isBlacklisted(account), "HLBICO: account is not blacklisted");
_blacklistedAddrs[account] = true;
emit BlacklistedRemoved(account);
}
function _dontExceedAmount(address beneficiary, uint256 weiAmount) internal view {
require(_investmentAddrs[beneficiary].add(weiAmount) <= _weiMaxInvest,
"HLBICO: Cannot invest more than KYC limit.");
}
modifier onlyWhitelistingAddress() {
require(_msgSender() == _whitelistingAddress, "HLBICO: caller does not have the Whitelisted role");
_;
}
modifier isNotInitialized() {
require(initialized == false, "HLBICO: contract is already initialized.");
_;
}
modifier onlyDeployingAddress() {
require(msg.sender == _deployingAddress, "HLBICO: only the deploying address can call this method.");
_;
}
}
文件 12 的 24:IERC20.sol
pragma solidity ^0.7.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 13 的 24:LBCToken.sol
pragma solidity ^0.7.0;
import "./Context.sol";
import "./ERC20CappedUnburnable.sol";
import "./ERC20Unburnable.sol";
import "./ERC20PausableUnburnable.sol";
contract LBCToken is Context, ERC20CappedUnburnable {
bool public initialized;
address public _deployingAddress;
address public _pauserAddress;
address public _minterAddress;
address public _reserveAddress;
event InitializedContract(address indexed reserveAddress);
event ChangedMinterAddress(address indexed minterAddress, address indexed changerAddress);
event ChangedPauserAddress(address indexed pauserAddress, address indexed changerAddress);
event ChangedReserveAddress(address indexed reserveAddress, address indexed changerAddress);
event ChangedDeployerAddress(address indexed deployerAddress, address indexed changerAddress);
constructor(
string memory name,
string memory symbol
)
ERC20Unburnable(name, symbol)
ERC20CappedUnburnable(300000000000000000000000000)
{
_deployingAddress = msg.sender;
}
function init(
address minterAddress,
address pauserAddress,
address reserveAddress
)
public
isNotInitialized
onlyDeployingAddress
{
require(minterAddress != address(0), "_minterAddress cannot be 0x");
require(pauserAddress != address(0), "_pauserAddress cannot be 0x");
require(reserveAddress != address(0), "_reserveAddress cannot be 0x");
_minterAddress = minterAddress;
_pauserAddress = pauserAddress;
_reserveAddress = reserveAddress;
initialized = true;
emit InitializedContract(reserveAddress);
}
function mint(address to, uint256 amount)
public
onlyMinterAddress
virtual
returns (bool) {
_mint(to, amount);
return true;
}
function pause()
public
onlyPauserAddress
virtual {
_pause();
}
function unpause()
public
onlyPauserAddress
virtual {
_unpause();
}
function changePauser(address newPauserAddress)
public
onlyDeployingAddress
whenNotPaused
{
_pauserAddress = newPauserAddress;
emit ChangedPauserAddress(newPauserAddress, _msgSender());
}
function changeMinter(address newMinterAddress)
public
onlyDeployingAddress
whenNotPaused
{
_minterAddress = newMinterAddress;
emit ChangedMinterAddress(newMinterAddress, _msgSender());
}
function changeDeployer(address newDeployerAddress)
public
onlyDeployingAddress
{
_deployingAddress = newDeployerAddress;
emit ChangedDeployerAddress(_deployingAddress, _msgSender());
}
modifier onlyDeployingAddress() {
require(msg.sender == _deployingAddress, "Only the deploying address can call this method.");
_;
}
modifier onlyMinterAddress() {
require(msg.sender == _minterAddress, "Only the minter address can call this method.");
_;
}
modifier onlyPauserAddress() {
require(msg.sender == _pauserAddress, "Only the pauser address can call this method.");
_;
}
modifier isNotInitialized() {
require(initialized == false, "Contract is already initialized.");
_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20CappedUnburnable) {
super._beforeTokenTransfer(from, to, amount);
}
}
文件 14 的 24:Ownable.sol
pragma solidity ^0.7.0;
import "./Context.sol";
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
文件 15 的 24:Pausable.sol
pragma solidity ^0.7.0;
import "./Context.sol";
contract Pausable is Context {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor () {
_paused = false;
}
function paused() public view returns (bool) {
return _paused;
}
modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
文件 16 的 24:PostDeliveryCrowdsale.sol
pragma solidity ^0.7.0;
import "./TimedCrowdsale.sol";
import "./SafeMath.sol";
import "./Secondary.sol";
import "./IERC20.sol";
abstract contract PostDeliveryCrowdsale is TimedCrowdsale {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
__unstable__TokenVault private _vault;
constructor() {
_vault = new __unstable__TokenVault();
}
function withdrawTokens(address beneficiary) public virtual {
require(hasClosed(), "PostDeliveryCrowdsale: not closed");
uint256 amount = _balances[beneficiary];
require(amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens");
_balances[beneficiary] = 0;
_vault.transfer(token(), beneficiary, amount);
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function _processPurchase(address beneficiary, uint256 tokenAmount) override virtual internal {
_balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
_deliverTokens(address(_vault), tokenAmount);
}
}
contract __unstable__TokenVault is Secondary {
function transfer(IERC20 token, address to, uint256 amount) public onlyPrimary {
token.transfer(to, amount);
}
}
文件 17 的 24:ReentrancyGuard.sol
pragma solidity ^0.7.0;
contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor () {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
文件 18 的 24:RefundEscrow.sol
pragma solidity ^0.7.0;
import "./ConditionalEscrow.sol";
contract RefundEscrow is ConditionalEscrow {
enum State { Active, Refunding, Closed }
event RefundsClosed();
event RefundsEnabled();
State private _state;
address payable private _beneficiary;
constructor (address payable beneficiaryReceived) {
require(beneficiaryReceived != address(0), "RefundEscrow: beneficiary is the zero address");
_beneficiary = beneficiaryReceived;
_state = State.Active;
}
function state() public view returns (State) {
return _state;
}
function beneficiary() public view returns (address) {
return _beneficiary;
}
function deposit(address refundee) public payable virtual override {
require(_state == State.Active, "RefundEscrow: can only deposit while active");
super.deposit(refundee);
}
function close() public onlyOwner virtual {
require(_state == State.Active, "RefundEscrow: can only close while active");
_state = State.Closed;
emit RefundsClosed();
}
function enableRefunds() public onlyOwner virtual {
require(_state == State.Active, "RefundEscrow: can only enable refunds while active");
_state = State.Refunding;
emit RefundsEnabled();
}
function beneficiaryWithdraw() public virtual {
require(_state == State.Closed, "RefundEscrow: beneficiary can only withdraw while closed");
_beneficiary.transfer(address(this).balance);
}
function withdrawalAllowed(address) public view override returns (bool) {
return _state == State.Refunding;
}
}
文件 19 的 24:RefundPostdevCrowdsale.sol
pragma solidity ^0.7.0;
import "./RefundableCrowdsale.sol";
import "./PostDeliveryCrowdsale.sol";
abstract contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale {
function _forwardFunds() internal override(CrowdsaleMint,RefundableCrowdsale) virtual {
RefundableCrowdsale._forwardFunds();
}
function _processPurchase(address beneficiary, uint256 tokenAmount) internal override(CrowdsaleMint, PostDeliveryCrowdsale) virtual {
PostDeliveryCrowdsale._processPurchase(beneficiary, tokenAmount);
}
function withdrawTokens(address beneficiary) override virtual public {
require(finalized(), "RefundablePostDeliveryCrowdsale: not finalized");
require(goalReached(), "RefundablePostDeliveryCrowdsale: goal not reached");
super.withdrawTokens(beneficiary);
}
}
文件 20 的 24:RefundableCrowdsale.sol
pragma solidity ^0.7.0;
import "./Context.sol";
import "./SafeERC20.sol";
import "./FinalizableCrowdsale.sol";
import "./RefundEscrow.sol";
abstract contract RefundableCrowdsale is Context, FinalizableCrowdsale {
using SafeMath for uint256;
uint256 private _goal;
RefundEscrow private _escrow;
constructor (uint256 goalReceived) {
require(goalReceived > 0, "RefundableCrowdsale: goal is 0");
_escrow = new RefundEscrow(wallet());
_goal = goalReceived;
}
function goal() public view returns (uint256) {
return _goal;
}
function changeGoal(uint256 newGoal) internal {
_goal = newGoal;
}
function claimRefund(address payable refundee) public {
require(finalized(), "RefundableCrowdsale: not finalized");
require(!goalReached(), "RefundableCrowdsale: goal reached");
_escrow.withdraw(refundee);
}
function goalReached() public view returns (bool) {
return weiRaised() >= _goal;
}
function _finalization() override virtual internal {
if (goalReached()) {
_escrow.close();
_escrow.beneficiaryWithdraw();
} else {
_escrow.enableRefunds();
}
super._finalization();
}
function _forwardFunds() override virtual internal {
_escrow.deposit{value : msg.value}(_msgSender());
}
}
文件 21 的 24:SafeERC20.sol
pragma solidity ^0.7.0;
import "./IERC20.sol";
import "./SafeMath.sol";
import "./Address.sol";
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
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));
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
文件 22 的 24:SafeMath.sol
pragma solidity ^0.7.0;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
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;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
文件 23 的 24:Secondary.sol
pragma solidity ^0.7.0;
import "./Context.sol";
abstract contract Secondary is Context {
address private _primary;
event PrimaryTransferred(
address recipient
);
constructor () {
address msgSender = _msgSender();
_primary = msgSender;
emit PrimaryTransferred(msgSender);
}
modifier onlyPrimary() {
require(_msgSender() == _primary, "Secondary: caller is not the primary account");
_;
}
function primary() public view returns (address) {
return _primary;
}
function transferPrimary(address recipient) public onlyPrimary {
require(recipient != address(0), "Secondary: new primary is the zero address");
_primary = recipient;
emit PrimaryTransferred(recipient);
}
}
文件 24 的 24:TimedCrowdsale.sol
pragma solidity ^0.7.0;
import "./SafeMath.sol";
import "./CrowdsaleMint.sol";
abstract contract TimedCrowdsale is CrowdsaleMint {
using SafeMath for uint256;
uint256 private _openingTime;
uint256 private _closingTime;
event TimedCrowdsaleExtended(uint256 prevClosingTime, uint256 newClosingTime);
modifier onlyWhileOpen {
require(isOpen(), "TimedCrowdsale: not open");
_;
}
constructor (uint256 openingTimeReceived, uint256 closingTimeReceived) {
require(openingTimeReceived >= block.timestamp, "TimedCrowdsale: opening time is before current time");
require(closingTimeReceived > openingTimeReceived, "TimedCrowdsale: opening time is not before closing time");
_openingTime = openingTimeReceived;
_closingTime = closingTimeReceived;
}
function openingTime() public view returns (uint256) {
return _openingTime;
}
function closingTime() public view returns (uint256) {
return _closingTime;
}
function isOpen() public view returns (bool) {
return block.timestamp >= _openingTime && block.timestamp <= _closingTime;
}
function hasClosed() public view virtual returns (bool) {
return block.timestamp > _closingTime;
}
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal override virtual onlyWhileOpen view {
super._preValidatePurchase(beneficiary, weiAmount);
}
function _extendTime(uint256 newClosingTime) internal {
require(!hasClosed(), "TimedCrowdsale: already closed");
require(newClosingTime > _closingTime, "TimedCrowdsale: new closing time is before current closing time");
emit TimedCrowdsaleExtended(_closingTime, newClosingTime);
_closingTime = newClosingTime;
}
}
{
"compilationTarget": {
"HLBICO.sol": "HLBICO"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"uint256","name":"initialRateReceived","type":"uint256"},{"internalType":"uint256","name":"rateCoefficientReceived","type":"uint256"},{"internalType":"address payable","name":"walletReceived","type":"address"},{"internalType":"contract LBCToken","name":"tokenReceived","type":"address"},{"internalType":"uint256","name":"openingTimeReceived","type":"uint256"},{"internalType":"uint256","name":"closingTimeReceived","type":"uint256"},{"internalType":"uint256","name":"capReceived","type":"uint256"},{"internalType":"uint256","name":"goalReceived","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"BlacklistedAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"BlacklistedRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"deployerAddress","type":"address"},{"indexed":true,"internalType":"address","name":"changerAddress","type":"address"}],"name":"ChangedDeployerAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"reserveAddress","type":"address"},{"indexed":true,"internalType":"address","name":"changerAddress","type":"address"}],"name":"ChangedReserveAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"whitelisterAddress","type":"address"},{"indexed":true,"internalType":"address","name":"changerAddress","type":"address"}],"name":"ChangedWhitelisterAddress","type":"event"},{"anonymous":false,"inputs":[],"name":"CrowdsaleFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"changerAddress","type":"address"},{"indexed":true,"internalType":"address","name":"whitelistingAddress","type":"address"}],"name":"InitializedContract","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"prevClosingTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newClosingTime","type":"uint256"}],"name":"TimedCrowdsaleExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"purchaser","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokensPurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newGoal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTranche","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxInvest","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRateCoef","type":"uint256"}],"name":"UpdatedCaps","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"_deployingAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_reserveAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_whitelistingAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addBlacklisted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"coef","type":"uint256"}],"name":"adjustEtherValue","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":"address","name":"beneficiary","type":"address"}],"name":"buyTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"cap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"capReached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newDeployerAddress","type":"address"}],"name":"changeDeployer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newReserveAddress","type":"address"}],"name":"changeReserveAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract LBCToken","name":"newToken","type":"address"}],"name":"changeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newWhitelisterAddress","type":"address"}],"name":"changeWhitelister","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"refundee","type":"address"}],"name":"claimRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"closingTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"etherTranche","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"finalized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"goal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"goalReached","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasClosed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"whitelistingAddress","type":"address"},{"internalType":"address","name":"reserveAddress","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isBlacklisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxInvest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openingTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeBlacklisted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract LBCToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wallet","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weiRaised","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"beneficiary","type":"address"}],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]