contract_name
stringlengths 1
61
| file_path
stringlengths 5
50.4k
| contract_address
stringlengths 42
42
| language
stringclasses 1
value | class_name
stringlengths 1
61
| class_code
stringlengths 4
330k
| class_documentation
stringlengths 0
29.1k
| class_documentation_type
stringclasses 6
values | func_name
stringlengths 0
62
| func_code
stringlengths 1
303k
| func_documentation
stringlengths 2
14.9k
| func_documentation_type
stringclasses 4
values | compiler_version
stringlengths 15
42
| license_type
stringclasses 14
values | swarm_source
stringlengths 0
71
| meta
dict | __index_level_0__
int64 0
60.4k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
NimbusPair | NimbusPair.sol | 0xdb4a372c113df57e8b15c9f67bc7c74bf887644e | Solidity | NimbusPair | contract NimbusPair is INimbusPair, NimbusERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant override MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public override factory;
address public override token0;
address public override token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public override price0CumulativeLast;
uint public override price1CumulativeLast;
uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'Nimbus: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view override returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'Nimbus: TRANSFER_FAILED');
}
constructor() {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external override {
require(msg.sender == factory, 'Nimbus: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= (2**112 - 1) && balance1 <= (2**112 - 1), 'Nimbus: OVERFLOW'); // uint112(-1) = 2 ** 112 - 1
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = INimbusFactory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external override lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external override lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock {
require(amount0Out > 0 || amount1Out > 0, 'Nimbus: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Nimbus: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'Nimbus: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) INimbusCallee(to).NimbusCall(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'Nimbus: INSUFFICIENT_INPUT_AMOUNT');
{
address referralProgram = INimbusFactory(factory).nimbusReferralProgram();
if (amount0In > 0) {
address _token0 = token0;
uint refFee = amount0In.mul(3)/ 2000;
_safeTransfer(_token0, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token0, to, refFee);
balance0 = balance0.sub(refFee);
}
if (amount1In > 0) {
uint refFee = amount1In.mul(3) / 2000;
address _token1 = token1;
_safeTransfer(_token1, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token1, to, refFee);
balance1 = balance1.sub(refFee);
}
}
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(10000).sub(amount0In.mul(15));
uint balance1Adjusted = balance1.mul(10000).sub(amount1In.mul(15));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(10000**2), 'Nimbus: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external override lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external override lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
} | initialize | function initialize(address _token0, address _token1) external override {
require(msg.sender == factory, 'Nimbus: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
| // called once by the factory at time of deployment | LineComment | v0.8.0+commit.c7dfd78e | None | ipfs://09efbdfdcf59ab0458bca530ac4494d67402d03a2b29e6e342b085575633b976 | {
"func_code_index": [
1726,
1947
]
} | 4,307 |
||
NimbusPair | NimbusPair.sol | 0xdb4a372c113df57e8b15c9f67bc7c74bf887644e | Solidity | NimbusPair | contract NimbusPair is INimbusPair, NimbusERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant override MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public override factory;
address public override token0;
address public override token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public override price0CumulativeLast;
uint public override price1CumulativeLast;
uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'Nimbus: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view override returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'Nimbus: TRANSFER_FAILED');
}
constructor() {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external override {
require(msg.sender == factory, 'Nimbus: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= (2**112 - 1) && balance1 <= (2**112 - 1), 'Nimbus: OVERFLOW'); // uint112(-1) = 2 ** 112 - 1
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = INimbusFactory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external override lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external override lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock {
require(amount0Out > 0 || amount1Out > 0, 'Nimbus: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Nimbus: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'Nimbus: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) INimbusCallee(to).NimbusCall(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'Nimbus: INSUFFICIENT_INPUT_AMOUNT');
{
address referralProgram = INimbusFactory(factory).nimbusReferralProgram();
if (amount0In > 0) {
address _token0 = token0;
uint refFee = amount0In.mul(3)/ 2000;
_safeTransfer(_token0, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token0, to, refFee);
balance0 = balance0.sub(refFee);
}
if (amount1In > 0) {
uint refFee = amount1In.mul(3) / 2000;
address _token1 = token1;
_safeTransfer(_token1, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token1, to, refFee);
balance1 = balance1.sub(refFee);
}
}
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(10000).sub(amount0In.mul(15));
uint balance1Adjusted = balance1.mul(10000).sub(amount1In.mul(15));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(10000**2), 'Nimbus: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external override lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external override lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
} | _update | function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= (2**112 - 1) && balance1 <= (2**112 - 1), 'Nimbus: OVERFLOW'); // uint112(-1) = 2 ** 112 - 1
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
| // update reserves and, on the first call per block, price accumulators | LineComment | v0.8.0+commit.c7dfd78e | None | ipfs://09efbdfdcf59ab0458bca530ac4494d67402d03a2b29e6e342b085575633b976 | {
"func_code_index": [
2027,
2921
]
} | 4,308 |
||
NimbusPair | NimbusPair.sol | 0xdb4a372c113df57e8b15c9f67bc7c74bf887644e | Solidity | NimbusPair | contract NimbusPair is INimbusPair, NimbusERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant override MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public override factory;
address public override token0;
address public override token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public override price0CumulativeLast;
uint public override price1CumulativeLast;
uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'Nimbus: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view override returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'Nimbus: TRANSFER_FAILED');
}
constructor() {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external override {
require(msg.sender == factory, 'Nimbus: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= (2**112 - 1) && balance1 <= (2**112 - 1), 'Nimbus: OVERFLOW'); // uint112(-1) = 2 ** 112 - 1
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = INimbusFactory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external override lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external override lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock {
require(amount0Out > 0 || amount1Out > 0, 'Nimbus: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Nimbus: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'Nimbus: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) INimbusCallee(to).NimbusCall(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'Nimbus: INSUFFICIENT_INPUT_AMOUNT');
{
address referralProgram = INimbusFactory(factory).nimbusReferralProgram();
if (amount0In > 0) {
address _token0 = token0;
uint refFee = amount0In.mul(3)/ 2000;
_safeTransfer(_token0, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token0, to, refFee);
balance0 = balance0.sub(refFee);
}
if (amount1In > 0) {
uint refFee = amount1In.mul(3) / 2000;
address _token1 = token1;
_safeTransfer(_token1, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token1, to, refFee);
balance1 = balance1.sub(refFee);
}
}
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(10000).sub(amount0In.mul(15));
uint balance1Adjusted = balance1.mul(10000).sub(amount1In.mul(15));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(10000**2), 'Nimbus: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external override lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external override lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
} | _mintFee | function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = INimbusFactory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
| // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) | LineComment | v0.8.0+commit.c7dfd78e | None | ipfs://09efbdfdcf59ab0458bca530ac4494d67402d03a2b29e6e342b085575633b976 | {
"func_code_index": [
3006,
3845
]
} | 4,309 |
||
NimbusPair | NimbusPair.sol | 0xdb4a372c113df57e8b15c9f67bc7c74bf887644e | Solidity | NimbusPair | contract NimbusPair is INimbusPair, NimbusERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant override MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public override factory;
address public override token0;
address public override token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public override price0CumulativeLast;
uint public override price1CumulativeLast;
uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'Nimbus: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view override returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'Nimbus: TRANSFER_FAILED');
}
constructor() {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external override {
require(msg.sender == factory, 'Nimbus: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= (2**112 - 1) && balance1 <= (2**112 - 1), 'Nimbus: OVERFLOW'); // uint112(-1) = 2 ** 112 - 1
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = INimbusFactory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external override lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external override lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock {
require(amount0Out > 0 || amount1Out > 0, 'Nimbus: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Nimbus: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'Nimbus: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) INimbusCallee(to).NimbusCall(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'Nimbus: INSUFFICIENT_INPUT_AMOUNT');
{
address referralProgram = INimbusFactory(factory).nimbusReferralProgram();
if (amount0In > 0) {
address _token0 = token0;
uint refFee = amount0In.mul(3)/ 2000;
_safeTransfer(_token0, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token0, to, refFee);
balance0 = balance0.sub(refFee);
}
if (amount1In > 0) {
uint refFee = amount1In.mul(3) / 2000;
address _token1 = token1;
_safeTransfer(_token1, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token1, to, refFee);
balance1 = balance1.sub(refFee);
}
}
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(10000).sub(amount0In.mul(15));
uint balance1Adjusted = balance1.mul(10000).sub(amount1In.mul(15));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(10000**2), 'Nimbus: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external override lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external override lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
} | mint | function mint(address to) external override lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
| // this low-level function should be called from a contract which performs important safety checks | LineComment | v0.8.0+commit.c7dfd78e | None | ipfs://09efbdfdcf59ab0458bca530ac4494d67402d03a2b29e6e342b085575633b976 | {
"func_code_index": [
3952,
5203
]
} | 4,310 |
||
NimbusPair | NimbusPair.sol | 0xdb4a372c113df57e8b15c9f67bc7c74bf887644e | Solidity | NimbusPair | contract NimbusPair is INimbusPair, NimbusERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant override MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public override factory;
address public override token0;
address public override token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public override price0CumulativeLast;
uint public override price1CumulativeLast;
uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'Nimbus: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view override returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'Nimbus: TRANSFER_FAILED');
}
constructor() {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external override {
require(msg.sender == factory, 'Nimbus: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= (2**112 - 1) && balance1 <= (2**112 - 1), 'Nimbus: OVERFLOW'); // uint112(-1) = 2 ** 112 - 1
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = INimbusFactory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external override lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external override lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock {
require(amount0Out > 0 || amount1Out > 0, 'Nimbus: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Nimbus: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'Nimbus: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) INimbusCallee(to).NimbusCall(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'Nimbus: INSUFFICIENT_INPUT_AMOUNT');
{
address referralProgram = INimbusFactory(factory).nimbusReferralProgram();
if (amount0In > 0) {
address _token0 = token0;
uint refFee = amount0In.mul(3)/ 2000;
_safeTransfer(_token0, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token0, to, refFee);
balance0 = balance0.sub(refFee);
}
if (amount1In > 0) {
uint refFee = amount1In.mul(3) / 2000;
address _token1 = token1;
_safeTransfer(_token1, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token1, to, refFee);
balance1 = balance1.sub(refFee);
}
}
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(10000).sub(amount0In.mul(15));
uint balance1Adjusted = balance1.mul(10000).sub(amount1In.mul(15));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(10000**2), 'Nimbus: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external override lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external override lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
} | burn | function burn(address to) external override lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
| // this low-level function should be called from a contract which performs important safety checks | LineComment | v0.8.0+commit.c7dfd78e | None | ipfs://09efbdfdcf59ab0458bca530ac4494d67402d03a2b29e6e342b085575633b976 | {
"func_code_index": [
5310,
6787
]
} | 4,311 |
||
NimbusPair | NimbusPair.sol | 0xdb4a372c113df57e8b15c9f67bc7c74bf887644e | Solidity | NimbusPair | contract NimbusPair is INimbusPair, NimbusERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant override MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public override factory;
address public override token0;
address public override token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public override price0CumulativeLast;
uint public override price1CumulativeLast;
uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'Nimbus: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view override returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'Nimbus: TRANSFER_FAILED');
}
constructor() {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external override {
require(msg.sender == factory, 'Nimbus: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= (2**112 - 1) && balance1 <= (2**112 - 1), 'Nimbus: OVERFLOW'); // uint112(-1) = 2 ** 112 - 1
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = INimbusFactory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external override lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external override lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock {
require(amount0Out > 0 || amount1Out > 0, 'Nimbus: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Nimbus: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'Nimbus: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) INimbusCallee(to).NimbusCall(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'Nimbus: INSUFFICIENT_INPUT_AMOUNT');
{
address referralProgram = INimbusFactory(factory).nimbusReferralProgram();
if (amount0In > 0) {
address _token0 = token0;
uint refFee = amount0In.mul(3)/ 2000;
_safeTransfer(_token0, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token0, to, refFee);
balance0 = balance0.sub(refFee);
}
if (amount1In > 0) {
uint refFee = amount1In.mul(3) / 2000;
address _token1 = token1;
_safeTransfer(_token1, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token1, to, refFee);
balance1 = balance1.sub(refFee);
}
}
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(10000).sub(amount0In.mul(15));
uint balance1Adjusted = balance1.mul(10000).sub(amount1In.mul(15));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(10000**2), 'Nimbus: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external override lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external override lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
} | swap | function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock {
require(amount0Out > 0 || amount1Out > 0, 'Nimbus: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Nimbus: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'Nimbus: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) INimbusCallee(to).NimbusCall(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'Nimbus: INSUFFICIENT_INPUT_AMOUNT');
{
address referralProgram = INimbusFactory(factory).nimbusReferralProgram();
if (amount0In > 0) {
address _token0 = token0;
uint refFee = amount0In.mul(3)/ 2000;
_safeTransfer(_token0, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token0, to, refFee);
balance0 = balance0.sub(refFee);
}
if (amount1In > 0) {
uint refFee = amount1In.mul(3) / 2000;
address _token1 = token1;
_safeTransfer(_token1, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token1, to, refFee);
balance1 = balance1.sub(refFee);
}
}
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(10000).sub(amount0In.mul(15));
uint balance1Adjusted = balance1.mul(10000).sub(amount1In.mul(15));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(10000**2), 'Nimbus: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
| // this low-level function should be called from a contract which performs important safety checks | LineComment | v0.8.0+commit.c7dfd78e | None | ipfs://09efbdfdcf59ab0458bca530ac4494d67402d03a2b29e6e342b085575633b976 | {
"func_code_index": [
6894,
9549
]
} | 4,312 |
||
NimbusPair | NimbusPair.sol | 0xdb4a372c113df57e8b15c9f67bc7c74bf887644e | Solidity | NimbusPair | contract NimbusPair is INimbusPair, NimbusERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant override MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public override factory;
address public override token0;
address public override token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public override price0CumulativeLast;
uint public override price1CumulativeLast;
uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'Nimbus: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view override returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'Nimbus: TRANSFER_FAILED');
}
constructor() {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external override {
require(msg.sender == factory, 'Nimbus: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= (2**112 - 1) && balance1 <= (2**112 - 1), 'Nimbus: OVERFLOW'); // uint112(-1) = 2 ** 112 - 1
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = INimbusFactory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external override lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external override lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock {
require(amount0Out > 0 || amount1Out > 0, 'Nimbus: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Nimbus: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'Nimbus: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) INimbusCallee(to).NimbusCall(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'Nimbus: INSUFFICIENT_INPUT_AMOUNT');
{
address referralProgram = INimbusFactory(factory).nimbusReferralProgram();
if (amount0In > 0) {
address _token0 = token0;
uint refFee = amount0In.mul(3)/ 2000;
_safeTransfer(_token0, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token0, to, refFee);
balance0 = balance0.sub(refFee);
}
if (amount1In > 0) {
uint refFee = amount1In.mul(3) / 2000;
address _token1 = token1;
_safeTransfer(_token1, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token1, to, refFee);
balance1 = balance1.sub(refFee);
}
}
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(10000).sub(amount0In.mul(15));
uint balance1Adjusted = balance1.mul(10000).sub(amount1In.mul(15));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(10000**2), 'Nimbus: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external override lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external override lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
} | skim | function skim(address to) external override lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
| // force balances to match reserves | LineComment | v0.8.0+commit.c7dfd78e | None | ipfs://09efbdfdcf59ab0458bca530ac4494d67402d03a2b29e6e342b085575633b976 | {
"func_code_index": [
9593,
9941
]
} | 4,313 |
||
NimbusPair | NimbusPair.sol | 0xdb4a372c113df57e8b15c9f67bc7c74bf887644e | Solidity | NimbusPair | contract NimbusPair is INimbusPair, NimbusERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant override MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public override factory;
address public override token0;
address public override token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public override price0CumulativeLast;
uint public override price1CumulativeLast;
uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'Nimbus: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view override returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'Nimbus: TRANSFER_FAILED');
}
constructor() {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external override {
require(msg.sender == factory, 'Nimbus: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= (2**112 - 1) && balance1 <= (2**112 - 1), 'Nimbus: OVERFLOW'); // uint112(-1) = 2 ** 112 - 1
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = INimbusFactory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external override lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external override lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'Nimbus: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock {
require(amount0Out > 0 || amount1Out > 0, 'Nimbus: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Nimbus: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'Nimbus: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) INimbusCallee(to).NimbusCall(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'Nimbus: INSUFFICIENT_INPUT_AMOUNT');
{
address referralProgram = INimbusFactory(factory).nimbusReferralProgram();
if (amount0In > 0) {
address _token0 = token0;
uint refFee = amount0In.mul(3)/ 2000;
_safeTransfer(_token0, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token0, to, refFee);
balance0 = balance0.sub(refFee);
}
if (amount1In > 0) {
uint refFee = amount1In.mul(3) / 2000;
address _token1 = token1;
_safeTransfer(_token1, referralProgram, refFee);
INimbusReferralProgram(referralProgram).recordFee(_token1, to, refFee);
balance1 = balance1.sub(refFee);
}
}
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(10000).sub(amount0In.mul(15));
uint balance1Adjusted = balance1.mul(10000).sub(amount1In.mul(15));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(10000**2), 'Nimbus: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external override lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external override lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
} | sync | function sync() external override lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
| // force reserves to match balances | LineComment | v0.8.0+commit.c7dfd78e | None | ipfs://09efbdfdcf59ab0458bca530ac4494d67402d03a2b29e6e342b085575633b976 | {
"func_code_index": [
9985,
10157
]
} | 4,314 |
||
FraxLiquidityBridger_OPTI_Celer | contracts/Bridges/Optimism/FraxLiquidityBridger_OPTI_Celer.sol | 0x7f35dc487a5422d6946aad733c6018f163084ed0 | Solidity | FraxLiquidityBridger_OPTI_Celer | contract FraxLiquidityBridger_OPTI_Celer is FraxLiquidityBridger {
uint32 public max_slippage = 50000;
uint32 public l2_gas = 2000000;
constructor (
address _owner,
address _timelock_address,
address _amo_minter_address,
address[3] memory _bridge_addresses,
address _destination_address_override,
string memory _non_evm_destination_address,
string memory _name
)
FraxLiquidityBridger(_owner, _timelock_address, _amo_minter_address, _bridge_addresses, _destination_address_override, _non_evm_destination_address, _name)
{}
function setMaxSlippage(uint32 _max_slippage) external onlyByOwnGov {
max_slippage = _max_slippage;
}
function setL2Gas(uint32 _l2_gas) external onlyByOwnGov {
l2_gas = _l2_gas;
}
// Override with logic specific to this chain
function _bridgingLogic(uint256 token_type, address address_to_send_to, uint256 token_amount) internal override {
// [Optimism]
if (token_type == 0){
// L1 FRAX -> celrFRAX --(autoswap)-> canFRAX
// Celer Bridge
// Approve
ERC20(address(FRAX)).approve(bridge_addresses[token_type], token_amount);
// Deposit
IOriginalTokenVault(bridge_addresses[token_type]).deposit(
address(FRAX),
token_amount,
10,
address_to_send_to,
uint64(block.timestamp)
);
}
else if (token_type == 1) {
// L1 FXS -> celrFXS --(autoswap)-> canFXS
// Celer Bridge
// Approve
ERC20(address(FXS)).approve(bridge_addresses[token_type], token_amount);
// Deposit
IOriginalTokenVault(bridge_addresses[token_type]).deposit(
address(FXS),
token_amount,
10,
address_to_send_to,
uint64(block.timestamp)
);
}
else {
// L1 USDC -> optiUSDC
// Optimism Gateway
// Approve
collateral_token.approve(bridge_addresses[token_type], token_amount);
// DepositERC20
IL1StandardBridge(bridge_addresses[token_type]).depositERC20To(
address(collateral_token),
0x7F5c764cBc14f9669B88837ca1490cCa17c31607,
address_to_send_to,
token_amount,
l2_gas,
""
);
}
}
} | _bridgingLogic | function _bridgingLogic(uint256 token_type, address address_to_send_to, uint256 token_amount) internal override {
// [Optimism]
if (token_type == 0){
// L1 FRAX -> celrFRAX --(autoswap)-> canFRAX
// Celer Bridge
// Approve
ERC20(address(FRAX)).approve(bridge_addresses[token_type], token_amount);
// Deposit
IOriginalTokenVault(bridge_addresses[token_type]).deposit(
address(FRAX),
token_amount,
10,
address_to_send_to,
uint64(block.timestamp)
);
}
else if (token_type == 1) {
// L1 FXS -> celrFXS --(autoswap)-> canFXS
// Celer Bridge
// Approve
ERC20(address(FXS)).approve(bridge_addresses[token_type], token_amount);
// Deposit
IOriginalTokenVault(bridge_addresses[token_type]).deposit(
address(FXS),
token_amount,
10,
address_to_send_to,
uint64(block.timestamp)
);
}
else {
// L1 USDC -> optiUSDC
// Optimism Gateway
// Approve
collateral_token.approve(bridge_addresses[token_type], token_amount);
// DepositERC20
IL1StandardBridge(bridge_addresses[token_type]).depositERC20To(
address(collateral_token),
0x7F5c764cBc14f9669B88837ca1490cCa17c31607,
address_to_send_to,
token_amount,
l2_gas,
""
);
}
}
| // Override with logic specific to this chain | LineComment | v0.8.10+commit.fc410830 | GNU GPLv2 | ipfs://29ea31bc9638a94f76663523d8540a204d180787020cef5d63ecfb3e70f5f875 | {
"func_code_index": [
896,
2636
]
} | 4,315 |
||
ERC721ConverterWithMCHExtension | localhost/contracts/lib/github.com/doublejumptokyo/mchplus-contracts-0.0.1/contracts/interfaces/IERC721TokenReceiver.sol | 0x9f90324b0da6adee99aebb467faf20278767d76a | Solidity | IERC721TokenReceiver | interface IERC721TokenReceiver {
/// @notice Handle the receipt of an NFT
/// @dev The ERC721 smart contract calls this function on the recipient
/// after a `transfer`. This function MAY throw to revert and reject the
/// transfer. Return of other than the magic value MUST result in the
/// transaction being reverted.
/// Note: the contract address is always the message sender.
/// @param _operator The address which called `safeTransferFrom` function
/// @param _from The address which previously owned the token
/// @param _tokenId The NFT identifier which is being transferred
/// @param _data Additional data with no specified format
/// @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
/// unless throwing
function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data
)
external
returns(bytes4);
} | /// @dev Note: the ERC-165 identifier for this interface is 0x150b7a02. | NatSpecSingleLine | onERC721Received | function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data
)
external
returns(bytes4);
| /// @notice Handle the receipt of an NFT
/// @dev The ERC721 smart contract calls this function on the recipient
/// after a `transfer`. This function MAY throw to revert and reject the
/// transfer. Return of other than the magic value MUST result in the
/// transaction being reverted.
/// Note: the contract address is always the message sender.
/// @param _operator The address which called `safeTransferFrom` function
/// @param _from The address which previously owned the token
/// @param _tokenId The NFT identifier which is being transferred
/// @param _data Additional data with no specified format
/// @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
/// unless throwing | NatSpecSingleLine | v0.5.12+commit.7709ece9 | None | bzzr://926bccbe332c07417064aa5f59875af8d4cf1a589500f169577a89e811d8125a | {
"func_code_index": [
811,
1002
]
} | 4,316 |
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
mapping(address => bool) blockListed;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(
balances[msg.sender] >= _value
&& _value > 0
&& !blockListed[_to]
&& !blockListed[msg.sender]
);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
} | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(
balances[msg.sender] >= _value
&& _value > 0
&& !blockListed[_to]
&& !blockListed[msg.sender]
);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
325,
889
]
} | 4,317 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
mapping(address => bool) blockListed;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(
balances[msg.sender] >= _value
&& _value > 0
&& !blockListed[_to]
&& !blockListed[msg.sender]
);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
} | balanceOf | function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
1105,
1225
]
} | 4,318 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(
_to != address(0)
&& balances[msg.sender] >= _value
&& balances[_from] >= _value
&& _value > 0
&& !blockListed[_to]
&& !blockListed[msg.sender]
);
uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require (_value <= _allowance);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* 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
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(
_to != address(0)
&& balances[msg.sender] >= _value
&& balances[_from] >= _value
&& _value > 0
&& !blockListed[_to]
&& !blockListed[msg.sender]
);
uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require (_value <= _allowance);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
401,
1210
]
} | 4,319 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(
_to != address(0)
&& balances[msg.sender] >= _value
&& balances[_from] >= _value
&& _value > 0
&& !blockListed[_to]
&& !blockListed[msg.sender]
);
uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require (_value <= _allowance);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* 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
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | approve | function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* 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
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
1853,
2064
]
} | 4,320 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(
_to != address(0)
&& balances[msg.sender] >= _value
&& balances[_from] >= _value
&& _value > 0
&& !blockListed[_to]
&& !blockListed[msg.sender]
);
uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require (_value <= _allowance);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* 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
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | allowance | function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
2395,
2544
]
} | 4,321 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | BurnableToken | contract BurnableToken is StandardToken {
event Burn(address indexed burner, uint256 value);
/**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/
function burn(uint256 _value) public {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
emit Burn(burner, _value);
}
} | burn | function burn(uint256 _value) public {
require(_value > 0);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
emit Burn(burner, _value);
}
| /**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
225,
487
]
} | 4,322 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Ownable | contract Ownable {
address internal owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | transferOwnership | function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
679,
876
]
} | 4,323 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(msg.sender, _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
function addBlockeddUser(address user) public onlyOwner {
blockListed[user] = true;
}
function removeBlockeddUser(address user) public onlyOwner {
blockListed[user] = false;
}
} | mint | function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(msg.sender, _to, _amount);
return true;
}
| /**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
510,
768
]
} | 4,324 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(msg.sender, _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
function addBlockeddUser(address user) public onlyOwner {
blockListed[user] = true;
}
function removeBlockeddUser(address user) public onlyOwner {
blockListed[user] = false;
}
} | finishMinting | function finishMinting() onlyOwner public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
| /**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
890,
1045
]
} | 4,325 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | PullPayment | contract PullPayment {
using SafeMath for uint256;
mapping(address => uint256) public payments;
uint256 public totalPayments;
/**
* @dev Called by the payer to store the sent amount as credit to be pulled.
* @param dest The destination address of the funds.
* @param amount The amount to transfer.
*/
function asyncSend(address dest, uint256 amount) internal {
payments[dest] = payments[dest].add(amount);
totalPayments = totalPayments.add(amount);
}
/**
* @dev withdraw accumulated balance, called by payee.
*/
function withdrawPayments() public {
address payee = msg.sender;
uint256 payment = payments[payee];
require(payment != 0);
require(this.balance >= payment);
totalPayments = totalPayments.sub(payment);
payments[payee] = 0;
assert(payee.send(payment));
}
} | asyncSend | function asyncSend(address dest, uint256 amount) internal {
payments[dest] = payments[dest].add(amount);
totalPayments = totalPayments.add(amount);
}
| /**
* @dev Called by the payer to store the sent amount as credit to be pulled.
* @param dest The destination address of the funds.
* @param amount The amount to transfer.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
346,
523
]
} | 4,326 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | PullPayment | contract PullPayment {
using SafeMath for uint256;
mapping(address => uint256) public payments;
uint256 public totalPayments;
/**
* @dev Called by the payer to store the sent amount as credit to be pulled.
* @param dest The destination address of the funds.
* @param amount The amount to transfer.
*/
function asyncSend(address dest, uint256 amount) internal {
payments[dest] = payments[dest].add(amount);
totalPayments = totalPayments.add(amount);
}
/**
* @dev withdraw accumulated balance, called by payee.
*/
function withdrawPayments() public {
address payee = msg.sender;
uint256 payment = payments[payee];
require(payment != 0);
require(this.balance >= payment);
totalPayments = totalPayments.sub(payment);
payments[payee] = 0;
assert(payee.send(payment));
}
} | withdrawPayments | function withdrawPayments() public {
address payee = msg.sender;
uint256 payment = payments[payee];
require(payment != 0);
require(this.balance >= payment);
totalPayments = totalPayments.sub(payment);
payments[payee] = 0;
assert(payee.send(payment));
}
| /**
* @dev withdraw accumulated balance, called by payee.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
602,
933
]
} | 4,327 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Pausable | contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
} | pause | function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
| /**
* @dev called by the owner to pause, triggers stopped state
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
555,
663
]
} | 4,328 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Pausable | contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
} | unpause | function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
| /**
* @dev called by the owner to unpause, returns to normal state
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
751,
861
]
} | 4,329 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | createTokenContract | function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
| /**
* function createTokenContract - Mintable Token Created
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
6279,
6393
]
} | 4,330 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | function () payable public {
buyTokens(msg.sender);
}
| /**
* function Fallback - Receives Ethers
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
6462,
6534
]
} | 4,331 |
||||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | privateSaleTokens | function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
| /**
* function preSaleTokens - Calculate Tokens in PreSale
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
6620,
7157
]
} | 4,332 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | preSaleTokens | function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
| /**
* function preSaleTokens - Calculate Tokens in PreSale
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
7241,
7987
]
} | 4,333 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | preICOTokens | function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
| /**
* function preICOTokens - Calculate Tokens in PreICO
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
8075,
8828
]
} | 4,334 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | icoTokens | function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
| /**
* function icoTokens - Calculate Tokens in ICO
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
8906,
9986
]
} | 4,335 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | buyTokens | function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
| /**
* function buyTokens - Collect Ethers and transfer tokens
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
10071,
11309
]
} | 4,336 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | forwardFunds | function forwardFunds() internal {
wallet.transfer(msg.value);
}
| /**
* function forwardFunds - Transfer funds to wallet
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
11387,
11470
]
} | 4,337 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | validPurchase | function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
| /**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
11617,
11860
]
} | 4,338 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | hasEnded | function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
| /**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
11971,
12065
]
} | 4,339 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | unsoldToken | function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
| /**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
12208,
12469
]
} | 4,340 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | Crowdsale | contract Crowdsale is Ownable, Pausable {
using SafeMath for uint256;
/**
* @MintableToken token - Token Object
* @address wallet - Wallet Address
* @uint8 rate - Tokens per Ether
* @uint256 weiRaised - Total funds raised in Ethers
*/
MintableToken internal token;
address internal wallet;
uint256 public rate;
uint256 internal weiRaised;
/**
* @uint256 privateSaleStartTime - Private-Sale Start Time
* @uint256 privateSaleEndTime - Private-Sale End Time
* @uint256 preSaleStartTime - Pre-Sale Start Time
* @uint256 preSaleEndTime - Pre-Sale End Time
* @uint256 preICOStartTime - Pre-ICO Start Time
* @uint256 preICOEndTime - Pre-ICO End Time
* @uint256 ICOstartTime - ICO Start Time
* @uint256 ICOEndTime - ICO End Time
*/
uint256 public privateSaleStartTime;
uint256 public privateSaleEndTime;
uint256 public preSaleStartTime;
uint256 public preSaleEndTime;
uint256 public preICOStartTime;
uint256 public preICOEndTime;
uint256 public ICOstartTime;
uint256 public ICOEndTime;
/**
* @uint privateBonus - Private Bonus
* @uint preSaleBonus - Pre-Sale Bonus
* @uint preICOBonus - Pre-Sale Bonus
* @uint firstWeekBonus - ICO 1st Week Bonus
* @uint secondWeekBonus - ICO 2nd Week Bonus
* @uint thirdWeekBonus - ICO 3rd Week Bonus
* @uint forthWeekBonus - ICO 4th Week Bonus
* @uint fifthWeekBonus - ICO 5th Week Bonus
*/
uint256 internal privateSaleBonus;
uint256 internal preSaleBonus;
uint256 internal preICOBonus;
uint256 internal firstWeekBonus;
uint256 internal secondWeekBonus;
uint256 internal thirdWeekBonus;
uint256 internal forthWeekBonus;
uint256 internal fifthWeekBonus;
uint256 internal weekOne;
uint256 internal weekTwo;
uint256 internal weekThree;
uint256 internal weekFour;
uint256 internal weekFive;
uint256 internal privateSaleTarget;
uint256 internal preSaleTarget;
uint256 internal preICOTarget;
/**
* @uint256 totalSupply - Total supply of tokens
* @uint256 publicSupply - Total public Supply
* @uint256 bountySupply - Total Bounty Supply
* @uint256 reservedSupply - Total Reserved Supply
* @uint256 privateSaleSupply - Total Private Supply from Public Supply
* @uint256 preSaleSupply - Total PreSale Supply from Public Supply
* @uint256 preICOSupply - Total PreICO Supply from Public Supply
* @uint256 icoSupply - Total ICO Supply from Public Supply
*/
uint256 public totalSupply = SafeMath.mul(400000000, 1 ether);
uint256 internal publicSupply = SafeMath.mul(SafeMath.div(totalSupply,100),55);
uint256 internal bountySupply = SafeMath.mul(SafeMath.div(totalSupply,100),6);
uint256 internal reservedSupply = SafeMath.mul(SafeMath.div(totalSupply,100),39);
uint256 internal privateSaleSupply = SafeMath.mul(24750000, 1 ether);
uint256 internal preSaleSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal preICOSupply = SafeMath.mul(39187500, 1 ether);
uint256 internal icoSupply = SafeMath.mul(116875000, 1 ether);
/**
* @bool checkUnsoldTokens - Tokens will be added to bounty supply
* @bool upgradePreSaleSupply - Boolean variable updates when the PrivateSale tokens added to PreSale supply
* @bool upgradePreICOSupply - Boolean variable updates when the PreSale tokens added to PreICO supply
* @bool upgradeICOSupply - Boolean variable updates when the PreICO tokens added to ICO supply
* @bool grantFounderTeamSupply - Boolean variable updates when Team and Founder tokens minted
*/
bool public checkUnsoldTokens;
bool internal upgradePreSaleSupply;
bool internal upgradePreICOSupply;
bool internal upgradeICOSupply;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value Wei's paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* function Crowdsale - Parameterized Constructor
* @param _startTime - StartTime of Crowdsale
* @param _endTime - EndTime of Crowdsale
* @param _rate - Tokens against Ether
* @param _wallet - MultiSignature Wallet Address
*/
constructor(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) internal {
require(_wallet != 0x0);
token = createTokenContract();
privateSaleStartTime = _startTime;
privateSaleEndTime = 1537952399;
preSaleStartTime = 1537952400;
preSaleEndTime = 1541581199;
preICOStartTime = 1541581200;
preICOEndTime = 1544000399;
ICOstartTime = 1544000400;
ICOEndTime = _endTime;
rate = _rate;
wallet = _wallet;
privateSaleBonus = SafeMath.div(SafeMath.mul(rate,50),100);
preSaleBonus = SafeMath.div(SafeMath.mul(rate,30),100);
preICOBonus = SafeMath.div(SafeMath.mul(rate,30),100);
firstWeekBonus = SafeMath.div(SafeMath.mul(rate,20),100);
secondWeekBonus = SafeMath.div(SafeMath.mul(rate,15),100);
thirdWeekBonus = SafeMath.div(SafeMath.mul(rate,10),100);
forthWeekBonus = SafeMath.div(SafeMath.mul(rate,5),100);
weekOne = SafeMath.add(ICOstartTime, 14 days);
weekTwo = SafeMath.add(weekOne, 14 days);
weekThree = SafeMath.add(weekTwo, 14 days);
weekFour = SafeMath.add(weekThree, 14 days);
weekFive = SafeMath.add(weekFour, 14 days);
privateSaleTarget = SafeMath.mul(4500, 1 ether);
preSaleTarget = SafeMath.mul(7125, 1 ether);
preICOTarget = SafeMath.mul(7125, 1 ether);
checkUnsoldTokens = false;
upgradeICOSupply = false;
upgradePreICOSupply = false;
upgradePreSaleSupply = false;
}
/**
* function createTokenContract - Mintable Token Created
*/
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
/**
* function Fallback - Receives Ethers
*/
function () payable public {
buyTokens(msg.sender);
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function privateSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(privateSaleSupply > 0);
require(weiAmount <= privateSaleTarget);
tokens = SafeMath.add(tokens, weiAmount.mul(privateSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(privateSaleSupply >= tokens);
privateSaleSupply = privateSaleSupply.sub(tokens);
privateSaleTarget = privateSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preSaleTokens - Calculate Tokens in PreSale
*/
function preSaleTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preSaleSupply > 0);
require(weiAmount <= preSaleTarget);
if (!upgradePreSaleSupply) {
preSaleSupply = SafeMath.add(preSaleSupply, privateSaleSupply);
preSaleTarget = SafeMath.add(preSaleTarget, privateSaleTarget);
upgradePreSaleSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preSaleBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preSaleSupply >= tokens);
preSaleSupply = preSaleSupply.sub(tokens);
preSaleTarget = preSaleTarget.sub(weiAmount);
return tokens;
}
/**
* function preICOTokens - Calculate Tokens in PreICO
*/
function preICOTokens(uint256 weiAmount, uint256 tokens) internal returns (uint256) {
require(preICOSupply > 0);
require(weiAmount <= preICOTarget);
if (!upgradePreICOSupply) {
preICOSupply = SafeMath.add(preICOSupply, preSaleSupply);
preICOTarget = SafeMath.add(preICOTarget, preSaleTarget);
upgradePreICOSupply = true;
}
tokens = SafeMath.add(tokens, weiAmount.mul(preICOBonus));
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
require(preICOSupply >= tokens);
preICOSupply = preICOSupply.sub(tokens);
preICOTarget = preICOTarget.sub(weiAmount);
return tokens;
}
/**
* function icoTokens - Calculate Tokens in ICO
*/
function icoTokens(uint256 weiAmount, uint256 tokens, uint256 accessTime) internal returns (uint256) {
require(icoSupply > 0);
if (!upgradeICOSupply) {
icoSupply = SafeMath.add(icoSupply,preICOSupply);
upgradeICOSupply = true;
}
if (accessTime <= weekOne) {
tokens = SafeMath.add(tokens, weiAmount.mul(firstWeekBonus));
} else if (accessTime <= weekTwo) {
tokens = SafeMath.add(tokens, weiAmount.mul(secondWeekBonus));
} else if ( accessTime < weekThree ) {
tokens = SafeMath.add(tokens, weiAmount.mul(thirdWeekBonus));
} else if ( accessTime < weekFour ) {
tokens = SafeMath.add(tokens, weiAmount.mul(forthWeekBonus));
} else if ( accessTime < weekFive ) {
tokens = SafeMath.add(tokens, weiAmount.mul(fifthWeekBonus));
}
tokens = SafeMath.add(tokens, weiAmount.mul(rate));
icoSupply = icoSupply.sub(tokens);
return tokens;
}
/**
* function buyTokens - Collect Ethers and transfer tokens
*/
function buyTokens(address beneficiary) whenNotPaused internal {
require(beneficiary != 0x0);
require(validPurchase());
uint256 accessTime = now;
uint256 tokens = 0;
uint256 weiAmount = msg.value;
require((weiAmount >= (100000000000000000)) && (weiAmount <= (20000000000000000000)));
if ((accessTime >= privateSaleStartTime) && (accessTime < privateSaleEndTime)) {
tokens = privateSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preSaleStartTime) && (accessTime < preSaleEndTime)) {
tokens = preSaleTokens(weiAmount, tokens);
} else if ((accessTime >= preICOStartTime) && (accessTime < preICOEndTime)) {
tokens = preICOTokens(weiAmount, tokens);
} else if ((accessTime >= ICOstartTime) && (accessTime <= ICOEndTime)) {
tokens = icoTokens(weiAmount, tokens, accessTime);
} else {
revert();
}
publicSupply = publicSupply.sub(tokens);
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
/**
* function forwardFunds - Transfer funds to wallet
*/
function forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* function validPurchase - Checks the purchase is valid or not
* @return true - Purchase is withPeriod and nonZero
*/
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= privateSaleStartTime && now <= ICOEndTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
/**
* function hasEnded - Checks the ICO ends or not
* @return true - ICO Ends
*/
function hasEnded() public view returns (bool) {
return now > ICOEndTime;
}
/**
* function unsoldToken - Function used to transfer all
* unsold public tokens to reserve supply
*/
function unsoldToken() onlyOwner public {
require(hasEnded());
require(!checkUnsoldTokens);
checkUnsoldTokens = true;
bountySupply = SafeMath.add(bountySupply, publicSupply);
publicSupply = 0;
}
/**
* function getTokenAddress - Get Token Address
*/
function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
} | getTokenAddress | function getTokenAddress() onlyOwner view public returns (address) {
return token;
}
| /**
* function getTokenAddress - Get Token Address
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
12545,
12648
]
} | 4,341 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | CappedCrowdsale | contract CappedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public cap;
constructor(uint256 _cap) public {
require(_cap > 0);
cap = _cap;
}
// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
function validPurchase() internal view returns (bool) {
return super.validPurchase() && weiRaised.add(msg.value) <= cap;
}
// overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return super.hasEnded() || weiRaised >= cap;
}
} | validPurchase | function validPurchase() internal view returns (bool) {
return super.validPurchase() && weiRaised.add(msg.value) <= cap;
}
| // overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
323,
464
]
} | 4,342 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | CappedCrowdsale | contract CappedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public cap;
constructor(uint256 _cap) public {
require(_cap > 0);
cap = _cap;
}
// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
function validPurchase() internal view returns (bool) {
return super.validPurchase() && weiRaised.add(msg.value) <= cap;
}
// overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return super.hasEnded() || weiRaised >= cap;
}
} | hasEnded | function hasEnded() public view returns (bool) {
return super.hasEnded() || weiRaised >= cap;
}
| // overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
572,
686
]
} | 4,343 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | CrowdsaleFunctions | contract CrowdsaleFunctions is Crowdsale {
/**
* function bountyFunds - Transfer bounty tokens via AirDrop
* @param beneficiary address where owner wants to transfer tokens
* @param tokens value of token
*/
function bountyFunds(address[] beneficiary, uint256[] tokens) public onlyOwner {
for (uint256 i = 0; i < beneficiary.length; i++) {
tokens[i] = SafeMath.mul(tokens[i],1 ether);
require(beneficiary[i] != 0x0);
require(bountySupply >= tokens[i]);
bountySupply = SafeMath.sub(bountySupply,tokens[i]);
token.mint(beneficiary[i], tokens[i]);
}
}
/**
* function grantReservedToken - Transfer advisor,team and founder tokens
*/
function grantReservedToken(address beneficiary, uint256 tokens) public onlyOwner {
require(beneficiary != 0x0);
require(reservedSupply > 0);
tokens = SafeMath.mul(tokens,1 ether);
require(reservedSupply >= tokens);
reservedSupply = SafeMath.sub(reservedSupply,tokens);
token.mint(beneficiary, tokens);
}
/**
*.function transferToken - Used to transfer tokens to investors who pays us other than Ethers
* @param beneficiary - Address where owner wants to transfer tokens
* @param tokens - Number of tokens
*/
function transferToken(address beneficiary, uint256 tokens) onlyOwner public {
require(beneficiary != 0x0);
require(publicSupply > 0);
tokens = SafeMath.mul(tokens,1 ether);
require(publicSupply >= tokens);
publicSupply = SafeMath.sub(publicSupply,tokens);
token.mint(beneficiary, tokens);
}
function addBlockListed(address user) public onlyOwner {
token.addBlockeddUser(user);
}
function removeBlockListed(address user) public onlyOwner {
token.removeBlockeddUser(user);
}
} | bountyFunds | function bountyFunds(address[] beneficiary, uint256[] tokens) public onlyOwner {
for (uint256 i = 0; i < beneficiary.length; i++) {
tokens[i] = SafeMath.mul(tokens[i],1 ether);
require(beneficiary[i] != 0x0);
require(bountySupply >= tokens[i]);
bountySupply = SafeMath.sub(bountySupply,tokens[i]);
token.mint(beneficiary[i], tokens[i]);
}
}
| /**
* function bountyFunds - Transfer bounty tokens via AirDrop
* @param beneficiary address where owner wants to transfer tokens
* @param tokens value of token
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
227,
679
]
} | 4,344 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | CrowdsaleFunctions | contract CrowdsaleFunctions is Crowdsale {
/**
* function bountyFunds - Transfer bounty tokens via AirDrop
* @param beneficiary address where owner wants to transfer tokens
* @param tokens value of token
*/
function bountyFunds(address[] beneficiary, uint256[] tokens) public onlyOwner {
for (uint256 i = 0; i < beneficiary.length; i++) {
tokens[i] = SafeMath.mul(tokens[i],1 ether);
require(beneficiary[i] != 0x0);
require(bountySupply >= tokens[i]);
bountySupply = SafeMath.sub(bountySupply,tokens[i]);
token.mint(beneficiary[i], tokens[i]);
}
}
/**
* function grantReservedToken - Transfer advisor,team and founder tokens
*/
function grantReservedToken(address beneficiary, uint256 tokens) public onlyOwner {
require(beneficiary != 0x0);
require(reservedSupply > 0);
tokens = SafeMath.mul(tokens,1 ether);
require(reservedSupply >= tokens);
reservedSupply = SafeMath.sub(reservedSupply,tokens);
token.mint(beneficiary, tokens);
}
/**
*.function transferToken - Used to transfer tokens to investors who pays us other than Ethers
* @param beneficiary - Address where owner wants to transfer tokens
* @param tokens - Number of tokens
*/
function transferToken(address beneficiary, uint256 tokens) onlyOwner public {
require(beneficiary != 0x0);
require(publicSupply > 0);
tokens = SafeMath.mul(tokens,1 ether);
require(publicSupply >= tokens);
publicSupply = SafeMath.sub(publicSupply,tokens);
token.mint(beneficiary, tokens);
}
function addBlockListed(address user) public onlyOwner {
token.addBlockeddUser(user);
}
function removeBlockListed(address user) public onlyOwner {
token.removeBlockeddUser(user);
}
} | grantReservedToken | function grantReservedToken(address beneficiary, uint256 tokens) public onlyOwner {
require(beneficiary != 0x0);
require(reservedSupply > 0);
tokens = SafeMath.mul(tokens,1 ether);
require(reservedSupply >= tokens);
reservedSupply = SafeMath.sub(reservedSupply,tokens);
token.mint(beneficiary, tokens);
}
| /**
* function grantReservedToken - Transfer advisor,team and founder tokens
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
780,
1150
]
} | 4,345 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | CrowdsaleFunctions | contract CrowdsaleFunctions is Crowdsale {
/**
* function bountyFunds - Transfer bounty tokens via AirDrop
* @param beneficiary address where owner wants to transfer tokens
* @param tokens value of token
*/
function bountyFunds(address[] beneficiary, uint256[] tokens) public onlyOwner {
for (uint256 i = 0; i < beneficiary.length; i++) {
tokens[i] = SafeMath.mul(tokens[i],1 ether);
require(beneficiary[i] != 0x0);
require(bountySupply >= tokens[i]);
bountySupply = SafeMath.sub(bountySupply,tokens[i]);
token.mint(beneficiary[i], tokens[i]);
}
}
/**
* function grantReservedToken - Transfer advisor,team and founder tokens
*/
function grantReservedToken(address beneficiary, uint256 tokens) public onlyOwner {
require(beneficiary != 0x0);
require(reservedSupply > 0);
tokens = SafeMath.mul(tokens,1 ether);
require(reservedSupply >= tokens);
reservedSupply = SafeMath.sub(reservedSupply,tokens);
token.mint(beneficiary, tokens);
}
/**
*.function transferToken - Used to transfer tokens to investors who pays us other than Ethers
* @param beneficiary - Address where owner wants to transfer tokens
* @param tokens - Number of tokens
*/
function transferToken(address beneficiary, uint256 tokens) onlyOwner public {
require(beneficiary != 0x0);
require(publicSupply > 0);
tokens = SafeMath.mul(tokens,1 ether);
require(publicSupply >= tokens);
publicSupply = SafeMath.sub(publicSupply,tokens);
token.mint(beneficiary, tokens);
}
function addBlockListed(address user) public onlyOwner {
token.addBlockeddUser(user);
}
function removeBlockListed(address user) public onlyOwner {
token.removeBlockeddUser(user);
}
} | transferToken | function transferToken(address beneficiary, uint256 tokens) onlyOwner public {
require(beneficiary != 0x0);
require(publicSupply > 0);
tokens = SafeMath.mul(tokens,1 ether);
require(publicSupply >= tokens);
publicSupply = SafeMath.sub(publicSupply,tokens);
token.mint(beneficiary, tokens);
}
| /**
*.function transferToken - Used to transfer tokens to investors who pays us other than Ethers
* @param beneficiary - Address where owner wants to transfer tokens
* @param tokens - Number of tokens
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
1368,
1733
]
} | 4,346 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | FinalizableCrowdsale | contract FinalizableCrowdsale is Crowdsale {
using SafeMath for uint256;
bool isFinalized = false;
event Finalized();
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() onlyOwner public {
require(!isFinalized);
require(hasEnded());
finalization();
emit Finalized();
isFinalized = true;
}
/**
* @dev Can be overridden to add finalization logic. The overriding function
* should call super.finalization() to ensure the chain of finalization is
* executed entirely.
*/
function finalization() internal view {
}
} | finalize | function finalize() onlyOwner public {
require(!isFinalized);
require(hasEnded());
finalization();
emit Finalized();
isFinalized = true;
}
| /**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
293,
490
]
} | 4,347 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | FinalizableCrowdsale | contract FinalizableCrowdsale is Crowdsale {
using SafeMath for uint256;
bool isFinalized = false;
event Finalized();
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() onlyOwner public {
require(!isFinalized);
require(hasEnded());
finalization();
emit Finalized();
isFinalized = true;
}
/**
* @dev Can be overridden to add finalization logic. The overriding function
* should call super.finalization() to ensure the chain of finalization is
* executed entirely.
*/
function finalization() internal view {
}
} | finalization | function finalization() internal view {
}
| /**
* @dev Can be overridden to add finalization logic. The overriding function
* should call super.finalization() to ensure the chain of finalization is
* executed entirely.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
696,
747
]
} | 4,348 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | RefundableCrowdsale | contract RefundableCrowdsale is FinalizableCrowdsale {
using SafeMath for uint256;
// minimum amount of funds to be raised in weis
uint256 public goal;
bool private _goalReached = false;
// refund vault used to hold funds while crowdsale is running
RefundVault private vault;
constructor(uint256 _goal) public {
require(_goal > 0);
vault = new RefundVault(wallet);
goal = _goal;
}
// We're overriding the fund forwarding from Crowdsale.
// In addition to sending the funds, we want to call
// the RefundVault deposit function
function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}
// if crowdsale is unsuccessful, investors can claim refunds here
function claimRefund() public {
require(isFinalized);
require(!goalReached());
vault.refund(msg.sender);
}
// vault finalization task, called when owner calls finalize()
function finalization() internal view {
if (goalReached()) {
vault.close();
} else {
vault.enableRefunds();
}
super.finalization();
}
function goalReached() public payable returns (bool) {
if (weiRaised >= goal) {
_goalReached = true;
return true;
} else if (_goalReached) {
return true;
}
else {
return false;
}
}
function updateGoalCheck() onlyOwner public {
_goalReached = true;
}
function getVaultAddress() onlyOwner view public returns (address) {
return vault;
}
} | forwardFunds | function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}
| // We're overriding the fund forwarding from Crowdsale.
// In addition to sending the funds, we want to call
// the RefundVault deposit function | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
615,
714
]
} | 4,349 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | RefundableCrowdsale | contract RefundableCrowdsale is FinalizableCrowdsale {
using SafeMath for uint256;
// minimum amount of funds to be raised in weis
uint256 public goal;
bool private _goalReached = false;
// refund vault used to hold funds while crowdsale is running
RefundVault private vault;
constructor(uint256 _goal) public {
require(_goal > 0);
vault = new RefundVault(wallet);
goal = _goal;
}
// We're overriding the fund forwarding from Crowdsale.
// In addition to sending the funds, we want to call
// the RefundVault deposit function
function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}
// if crowdsale is unsuccessful, investors can claim refunds here
function claimRefund() public {
require(isFinalized);
require(!goalReached());
vault.refund(msg.sender);
}
// vault finalization task, called when owner calls finalize()
function finalization() internal view {
if (goalReached()) {
vault.close();
} else {
vault.enableRefunds();
}
super.finalization();
}
function goalReached() public payable returns (bool) {
if (weiRaised >= goal) {
_goalReached = true;
return true;
} else if (_goalReached) {
return true;
}
else {
return false;
}
}
function updateGoalCheck() onlyOwner public {
_goalReached = true;
}
function getVaultAddress() onlyOwner view public returns (address) {
return vault;
}
} | claimRefund | function claimRefund() public {
require(isFinalized);
require(!goalReached());
vault.refund(msg.sender);
}
| // if crowdsale is unsuccessful, investors can claim refunds here | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
788,
933
]
} | 4,350 |
|||
AutoCoinToken | AutoCoinToken.sol | 0x46e8b4890ff60aa2a37c5a4514cb38ee359f70b3 | Solidity | RefundableCrowdsale | contract RefundableCrowdsale is FinalizableCrowdsale {
using SafeMath for uint256;
// minimum amount of funds to be raised in weis
uint256 public goal;
bool private _goalReached = false;
// refund vault used to hold funds while crowdsale is running
RefundVault private vault;
constructor(uint256 _goal) public {
require(_goal > 0);
vault = new RefundVault(wallet);
goal = _goal;
}
// We're overriding the fund forwarding from Crowdsale.
// In addition to sending the funds, we want to call
// the RefundVault deposit function
function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}
// if crowdsale is unsuccessful, investors can claim refunds here
function claimRefund() public {
require(isFinalized);
require(!goalReached());
vault.refund(msg.sender);
}
// vault finalization task, called when owner calls finalize()
function finalization() internal view {
if (goalReached()) {
vault.close();
} else {
vault.enableRefunds();
}
super.finalization();
}
function goalReached() public payable returns (bool) {
if (weiRaised >= goal) {
_goalReached = true;
return true;
} else if (_goalReached) {
return true;
}
else {
return false;
}
}
function updateGoalCheck() onlyOwner public {
_goalReached = true;
}
function getVaultAddress() onlyOwner view public returns (address) {
return vault;
}
} | finalization | function finalization() internal view {
if (goalReached()) {
vault.close();
} else {
vault.enableRefunds();
}
super.finalization();
}
| // vault finalization task, called when owner calls finalize() | LineComment | v0.4.25+commit.59dbf8f1 | bzzr://7d4c4302d0a26cf51a0d8b47208678631c851feb273e8874cdd6c3106023182c | {
"func_code_index": [
1004,
1209
]
} | 4,351 |
|||
DropPresaleShop721 | contracts/drops/DropPresaleShop721.sol | 0xe182af6be923b29f6a53855d5571fdd96b21d93a | Solidity | DropPresaleShop721 | contract DropPresaleShop721 is
Ownable, ReentrancyGuard
{
using SafeERC20 for IERC20;
/// The address of the ERC-721 item being sold.
address public immutable collection;
/// The time when the public sale begins.
uint256 public immutable startTime;
/// The time when the public sale ends.
uint256 public immutable endTime;
/// The maximum number of items from the `collection` that may be sold.
uint256 public immutable totalCap;
/// The maximum number of items that a single address may purchase.
uint256 public immutable callerCap;
/// The maximum number of items that may be purchased in a single transaction.
uint256 public immutable transactionCap;
/// The price at which to sell the item.
uint256 public immutable price;
/**
The number of whitelists that have been added. This is used for looking up
specific whitelist details from the `whitelists` mapping.
*/
uint256 public immutable whitelistCount;
/**
This struct is used at the moment of contract construction to specify a
presale whitelist that should apply to the sale this shop runs.
@param root The hash root of merkle tree uses to validate a caller's
inclusion in this whitelist.
@param startTime The starting time of this whitelist. When this is set to a
time earlier than the contract's `startTime` storage variable, that means
that this whitelist will begin earlier than the public sale. In effect,
that means that this whitelist will define a presale.
@param endTime The ending time of this whitelist. For standard presale
behavior, this should be set equal to the contract's `startTime` storage
variable to end the presale when the public sale begins. This can be set
later than the contract's `startTime` storage variable, but it will have
no effect. A presale whitelist may not be used once the public sale has
begun. Likewise, a presale may not run longer than the public item sale.
The public item sale `endTime` storage variable of this contract will
always override a whitelist's ending time.
@param price The price that applies to this presale whitelist.
@param token The address of the token with which purchases in this whitelist
will be made. If this is the zero address, then this whitelist will
conduct purchases using ETH.
*/
struct CreateWhitelist {
bytes32 root;
uint256 startTime;
uint256 endTime;
uint256 price;
address token;
}
/// A mapping to look up whitelist details for a given whitelist ID.
mapping ( uint256 => CreateWhitelist ) public whitelists;
/// A mapping to track the number of items purchases by each caller.
mapping ( address => uint256 ) public purchaseCounts;
/// The total number of items sold by the shop.
uint256 public sold;
/**
This struct is used at the moment of NFT purchase to let a caller submit
proof that they are actually entitled to a position on a presale whitelist.
@param id The ID of the whitelist to check proof against.
@param index The element index in the original array for proof verification.
@param allowance The quantity available to the caller for presale purchase.
@param proof A submitted proof that the user is on the whitelist.
*/
struct WhitelistProof {
uint256 id;
uint256 index;
uint256 allowance;
bytes32[] proof;
}
/*
A struct used to pass shop configuration details upon contract construction.
@param startTime The time when the public sale begins.
@param endTime The time when the public sale ends.
@param totalCap The maximum number of items from the `collection` that may
be sold.
@param callerCap The maximum number of items that a single address may
purchase.
@param transactionCap The maximum number of items that may be purchased in
a single transaction.
@param price The price to sell the item at.
*/
struct ShopConfiguration {
uint256 startTime;
uint256 endTime;
uint256 totalCap;
uint256 callerCap;
uint256 transactionCap;
uint256 price;
}
/**
Construct a new shop with configuration details about the intended sale.
@param _collection The address of the ERC-721 item being sold.
@param _configuration A parameter containing shop configuration information,
passed here as a struct to avoid a stack-to-deep error.
@param _whitelists The array of whitelist creation data containing details
for any presales being run.
*/
constructor (
address _collection,
ShopConfiguration memory _configuration,
CreateWhitelist[] memory _whitelists
) {
// Perform basic input validation.
if (_configuration.endTime < _configuration.startTime) {
revert CannotEndSaleBeforeItStarts();
}
// Once input parameters have been validated, set storage.
collection = _collection;
startTime = _configuration.startTime;
endTime = _configuration.endTime;
totalCap = _configuration.totalCap;
callerCap = _configuration.callerCap;
transactionCap = _configuration.transactionCap;
price = _configuration.price;
// Store all of the whitelists.
whitelistCount = _whitelists.length;
for (uint256 i = 0; i < _whitelists.length; i++) {
whitelists[i] = _whitelists[i];
}
}
/**
A private helper function to sell an item to a public sale participant. This
selling function refunds any overpayment to the user; refunding overpayment
is expected to be a common situation given the price decay in the Dutch
auction.
@param _amount The number of items that the caller would like to purchase.
*/
function sellPublic (
uint256 _amount
) private {
uint256 totalCharge = price * _amount;
// Reject the purchase if the caller is underpaying.
if (msg.value < totalCharge) { revert CannotUnderpayForMint(); }
// Refund the caller's excess payment if they overpaid.
if (msg.value > totalCharge) {
uint256 excess = msg.value - totalCharge;
(bool returned, ) = payable(_msgSender()).call{ value: excess }("");
if (!returned) { revert RefundTransferFailed(); }
}
}
/**
Calculate a root hash from given parameters.
@param _index The index of the hashed node from the list.
@param _node The index of the hashed node at that index.
@param _merkleProof An array of one required merkle hash per level.
@return The root hash from given parameters.
*/
function getRootHash (
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private pure returns (bytes32) {
uint256 path = _index;
for (uint256 i = 0; i < _merkleProof.length; i++) {
if ((path & 0x01) == 1) {
_node = keccak256(abi.encodePacked(_merkleProof[i], _node));
} else {
_node = keccak256(abi.encodePacked(_node, _merkleProof[i]));
}
path /= 2;
}
return _node;
}
/**
A helper function to verify an access against a targeted on-chain merkle
root.
@param _accesslistId The id of the accesslist containing the merkleRoot.
@param _index The index of the hashed node from off-chain list.
@param _node The actual hashed node which needs to be verified.
@param _merkleProof The merkle hashes from the off-chain merkle tree.
@return Whether the provided merkle proof is verifiably part of the on-chain
root.
*/
function verify (
uint256 _accesslistId,
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private view returns (bool) {
if (whitelists[_accesslistId].root == 0) {
return false;
} else if (block.timestamp < whitelists[_accesslistId].startTime) {
return false;
} else if (block.timestamp > whitelists[_accesslistId].endTime) {
return false;
} else if (
getRootHash(_index, _node, _merkleProof) != whitelists[_accesslistId].root
) {
return false;
}
return true;
}
/**
A private helper function to sell an item to a whitelist presale
participant.
@param _amount The number of items that the caller would like to purchase.
@param _whitelist A whitelist proof for users to submit with their claim to
verify that they are in fact on the whitelist.
*/
function sellWhitelist (
uint256 _amount,
WhitelistProof calldata _whitelist
) private {
// Verify that the caller is on the merkle whitelist.
bool verified = verify(
_whitelist.id,
_whitelist.index,
keccak256(
abi.encodePacked(
_whitelist.index,
_msgSender(),
_whitelist.allowance
)
),
_whitelist.proof
);
// Reject the purchase if the caller is not a valid whitelist member.
if (!verified) { revert CannotVerifyAsWhitelistMember(); }
// Reject the purchase if the caller is exceeding their whitelist allowance.
if (purchaseCounts[_msgSender()] + _amount > _whitelist.allowance) {
revert CannotExceedWhitelistAllowance();
}
// Calculate the sale token and price.
address token = whitelists[_whitelist.id].token;
uint256 whitelistPrice = whitelists[_whitelist.id].price * _amount;
// The zero address indicates that the purchase asset is Ether.
if (token == address(0)) {
if (msg.value != whitelistPrice) {
revert CannotTransferIncorrectAmount();
}
// Otherwise, the caller is making their purchase with an ERC-20 token.
} else {
IERC20(token).safeTransferFrom(
_msgSender(),
address(this),
whitelistPrice
);
}
}
/**
Allow a caller to purchase an item.
@param _amount The amount of items that the caller would like to purchase.
@param _whitelist The caller-subumitted whitelist proof to check if they
belong on a presale whitelist.
*/
function mint (
uint256 _amount,
WhitelistProof calldata _whitelist
) external payable nonReentrant {
// Reject purchases for no items.
if (_amount < 1) { revert CannotBuyZeroItems(); }
/*
Reject purchases that happen after the end of the public sale. Do note
that this means that whitelist sales with an ending duration _after_ the
end of the public sale are ignored completely. In other words: the ending
time of the public sale takes precedent over the ending time of a
whitelisted presale. A whitelisted presale may not continue selling items
after the public sale has ended.
*/
if (block.timestamp >= endTime) { revert CannotBuyFromEndedSale(); }
// Reject purchases that exceed the per-transaction cap.
if (_amount > transactionCap) {
revert CannotExceedPerTransactionCap();
}
// Reject purchases that exceed the per-caller cap.
if (purchaseCounts[_msgSender()] + _amount > callerCap) {
revert CannotExceedPerCallerCap();
}
// Reject purchases that exceed the total sale cap.
if (sold + _amount > totalCap) { revert CannotExceedTotalCap(); }
/*
If the current timestamp is greater than this contract's `startTime`, the
public sale has begun and all users will be directed to the public sale
functionality.
*/
if (block.timestamp >= startTime) {
sellPublic(_amount);
/*
Otherwise, since the public sale has not begun, attempt to sell to this
user as a member of the presale whitelist.
*/
} else {
sellWhitelist(_amount, _whitelist);
}
// Update the count of items sold.
sold += _amount;
// Update the caller's purchase count.
purchaseCounts[_msgSender()] += _amount;
// Mint the items.
ITiny721(collection).mint_Qgo(_msgSender(), _amount);
}
/**
Allow the owner to sweep either Ether or a particular ERC-20 token from the
contract and send it to another address. This allows the owner of the shop
to withdraw their funds after the sale is completed.
@param _token The token to sweep the balance from; if a zero address is sent
then the contract's balance of Ether will be swept.
@param _amount The amount of token to sweep.
@param _destination The address to send the swept tokens to.
*/
function sweep (
address _token,
address _destination,
uint256 _amount
) external onlyOwner nonReentrant {
// A zero address means we should attempt to sweep Ether.
if (_token == address(0)) {
(bool success, ) = payable(_destination).call{ value: _amount }("");
if (!success) { revert SweepingTransferFailed(); }
// Otherwise, we should try to sweep an ERC-20 token.
} else {
IERC20(_token).safeTransfer(_destination, _amount);
}
}
} | /**
@title A contract for selling NFTs via a merkle-based whitelist presale with
conversion into a public sale.
@author Tim Clancy
@author Qazawat Zirak
@author Rostislav Khlebnikov
@author Nikita Elunin
@author 0xthrpw
This contract is a modified version of SuperFarm mint shops optimized for the
specific use case of:
1. selling a single type of ERC-721 item from a single contract
2. running potentially multiple whitelisted presales with potentially
multiple different participants and different prices
3. selling the item for both ETH and an ERC-20 token during the presale
4. converting into a public sale that can sell for ETH only
This launchpad contract sells new items by minting them into existence. It
cannot be used to sell items that already exist.
March 10th, 2022.
*/ | NatSpecMultiLine | sellPublic | function sellPublic (
uint256 _amount
) private {
uint256 totalCharge = price * _amount;
// Reject the purchase if the caller is underpaying.
if (msg.value < totalCharge) { revert CannotUnderpayForMint(); }
// Refund the caller's excess payment if they overpaid.
if (msg.value > totalCharge) {
uint256 excess = msg.value - totalCharge;
(bool returned, ) = payable(_msgSender()).call{ value: excess }("");
if (!returned) { revert RefundTransferFailed(); }
}
}
| /**
A private helper function to sell an item to a public sale participant. This
selling function refunds any overpayment to the user; refunding overpayment
is expected to be a common situation given the price decay in the Dutch
auction.
@param _amount The number of items that the caller would like to purchase.
*/ | NatSpecMultiLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
5845,
6372
]
} | 4,352 |
||
DropPresaleShop721 | contracts/drops/DropPresaleShop721.sol | 0xe182af6be923b29f6a53855d5571fdd96b21d93a | Solidity | DropPresaleShop721 | contract DropPresaleShop721 is
Ownable, ReentrancyGuard
{
using SafeERC20 for IERC20;
/// The address of the ERC-721 item being sold.
address public immutable collection;
/// The time when the public sale begins.
uint256 public immutable startTime;
/// The time when the public sale ends.
uint256 public immutable endTime;
/// The maximum number of items from the `collection` that may be sold.
uint256 public immutable totalCap;
/// The maximum number of items that a single address may purchase.
uint256 public immutable callerCap;
/// The maximum number of items that may be purchased in a single transaction.
uint256 public immutable transactionCap;
/// The price at which to sell the item.
uint256 public immutable price;
/**
The number of whitelists that have been added. This is used for looking up
specific whitelist details from the `whitelists` mapping.
*/
uint256 public immutable whitelistCount;
/**
This struct is used at the moment of contract construction to specify a
presale whitelist that should apply to the sale this shop runs.
@param root The hash root of merkle tree uses to validate a caller's
inclusion in this whitelist.
@param startTime The starting time of this whitelist. When this is set to a
time earlier than the contract's `startTime` storage variable, that means
that this whitelist will begin earlier than the public sale. In effect,
that means that this whitelist will define a presale.
@param endTime The ending time of this whitelist. For standard presale
behavior, this should be set equal to the contract's `startTime` storage
variable to end the presale when the public sale begins. This can be set
later than the contract's `startTime` storage variable, but it will have
no effect. A presale whitelist may not be used once the public sale has
begun. Likewise, a presale may not run longer than the public item sale.
The public item sale `endTime` storage variable of this contract will
always override a whitelist's ending time.
@param price The price that applies to this presale whitelist.
@param token The address of the token with which purchases in this whitelist
will be made. If this is the zero address, then this whitelist will
conduct purchases using ETH.
*/
struct CreateWhitelist {
bytes32 root;
uint256 startTime;
uint256 endTime;
uint256 price;
address token;
}
/// A mapping to look up whitelist details for a given whitelist ID.
mapping ( uint256 => CreateWhitelist ) public whitelists;
/// A mapping to track the number of items purchases by each caller.
mapping ( address => uint256 ) public purchaseCounts;
/// The total number of items sold by the shop.
uint256 public sold;
/**
This struct is used at the moment of NFT purchase to let a caller submit
proof that they are actually entitled to a position on a presale whitelist.
@param id The ID of the whitelist to check proof against.
@param index The element index in the original array for proof verification.
@param allowance The quantity available to the caller for presale purchase.
@param proof A submitted proof that the user is on the whitelist.
*/
struct WhitelistProof {
uint256 id;
uint256 index;
uint256 allowance;
bytes32[] proof;
}
/*
A struct used to pass shop configuration details upon contract construction.
@param startTime The time when the public sale begins.
@param endTime The time when the public sale ends.
@param totalCap The maximum number of items from the `collection` that may
be sold.
@param callerCap The maximum number of items that a single address may
purchase.
@param transactionCap The maximum number of items that may be purchased in
a single transaction.
@param price The price to sell the item at.
*/
struct ShopConfiguration {
uint256 startTime;
uint256 endTime;
uint256 totalCap;
uint256 callerCap;
uint256 transactionCap;
uint256 price;
}
/**
Construct a new shop with configuration details about the intended sale.
@param _collection The address of the ERC-721 item being sold.
@param _configuration A parameter containing shop configuration information,
passed here as a struct to avoid a stack-to-deep error.
@param _whitelists The array of whitelist creation data containing details
for any presales being run.
*/
constructor (
address _collection,
ShopConfiguration memory _configuration,
CreateWhitelist[] memory _whitelists
) {
// Perform basic input validation.
if (_configuration.endTime < _configuration.startTime) {
revert CannotEndSaleBeforeItStarts();
}
// Once input parameters have been validated, set storage.
collection = _collection;
startTime = _configuration.startTime;
endTime = _configuration.endTime;
totalCap = _configuration.totalCap;
callerCap = _configuration.callerCap;
transactionCap = _configuration.transactionCap;
price = _configuration.price;
// Store all of the whitelists.
whitelistCount = _whitelists.length;
for (uint256 i = 0; i < _whitelists.length; i++) {
whitelists[i] = _whitelists[i];
}
}
/**
A private helper function to sell an item to a public sale participant. This
selling function refunds any overpayment to the user; refunding overpayment
is expected to be a common situation given the price decay in the Dutch
auction.
@param _amount The number of items that the caller would like to purchase.
*/
function sellPublic (
uint256 _amount
) private {
uint256 totalCharge = price * _amount;
// Reject the purchase if the caller is underpaying.
if (msg.value < totalCharge) { revert CannotUnderpayForMint(); }
// Refund the caller's excess payment if they overpaid.
if (msg.value > totalCharge) {
uint256 excess = msg.value - totalCharge;
(bool returned, ) = payable(_msgSender()).call{ value: excess }("");
if (!returned) { revert RefundTransferFailed(); }
}
}
/**
Calculate a root hash from given parameters.
@param _index The index of the hashed node from the list.
@param _node The index of the hashed node at that index.
@param _merkleProof An array of one required merkle hash per level.
@return The root hash from given parameters.
*/
function getRootHash (
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private pure returns (bytes32) {
uint256 path = _index;
for (uint256 i = 0; i < _merkleProof.length; i++) {
if ((path & 0x01) == 1) {
_node = keccak256(abi.encodePacked(_merkleProof[i], _node));
} else {
_node = keccak256(abi.encodePacked(_node, _merkleProof[i]));
}
path /= 2;
}
return _node;
}
/**
A helper function to verify an access against a targeted on-chain merkle
root.
@param _accesslistId The id of the accesslist containing the merkleRoot.
@param _index The index of the hashed node from off-chain list.
@param _node The actual hashed node which needs to be verified.
@param _merkleProof The merkle hashes from the off-chain merkle tree.
@return Whether the provided merkle proof is verifiably part of the on-chain
root.
*/
function verify (
uint256 _accesslistId,
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private view returns (bool) {
if (whitelists[_accesslistId].root == 0) {
return false;
} else if (block.timestamp < whitelists[_accesslistId].startTime) {
return false;
} else if (block.timestamp > whitelists[_accesslistId].endTime) {
return false;
} else if (
getRootHash(_index, _node, _merkleProof) != whitelists[_accesslistId].root
) {
return false;
}
return true;
}
/**
A private helper function to sell an item to a whitelist presale
participant.
@param _amount The number of items that the caller would like to purchase.
@param _whitelist A whitelist proof for users to submit with their claim to
verify that they are in fact on the whitelist.
*/
function sellWhitelist (
uint256 _amount,
WhitelistProof calldata _whitelist
) private {
// Verify that the caller is on the merkle whitelist.
bool verified = verify(
_whitelist.id,
_whitelist.index,
keccak256(
abi.encodePacked(
_whitelist.index,
_msgSender(),
_whitelist.allowance
)
),
_whitelist.proof
);
// Reject the purchase if the caller is not a valid whitelist member.
if (!verified) { revert CannotVerifyAsWhitelistMember(); }
// Reject the purchase if the caller is exceeding their whitelist allowance.
if (purchaseCounts[_msgSender()] + _amount > _whitelist.allowance) {
revert CannotExceedWhitelistAllowance();
}
// Calculate the sale token and price.
address token = whitelists[_whitelist.id].token;
uint256 whitelistPrice = whitelists[_whitelist.id].price * _amount;
// The zero address indicates that the purchase asset is Ether.
if (token == address(0)) {
if (msg.value != whitelistPrice) {
revert CannotTransferIncorrectAmount();
}
// Otherwise, the caller is making their purchase with an ERC-20 token.
} else {
IERC20(token).safeTransferFrom(
_msgSender(),
address(this),
whitelistPrice
);
}
}
/**
Allow a caller to purchase an item.
@param _amount The amount of items that the caller would like to purchase.
@param _whitelist The caller-subumitted whitelist proof to check if they
belong on a presale whitelist.
*/
function mint (
uint256 _amount,
WhitelistProof calldata _whitelist
) external payable nonReentrant {
// Reject purchases for no items.
if (_amount < 1) { revert CannotBuyZeroItems(); }
/*
Reject purchases that happen after the end of the public sale. Do note
that this means that whitelist sales with an ending duration _after_ the
end of the public sale are ignored completely. In other words: the ending
time of the public sale takes precedent over the ending time of a
whitelisted presale. A whitelisted presale may not continue selling items
after the public sale has ended.
*/
if (block.timestamp >= endTime) { revert CannotBuyFromEndedSale(); }
// Reject purchases that exceed the per-transaction cap.
if (_amount > transactionCap) {
revert CannotExceedPerTransactionCap();
}
// Reject purchases that exceed the per-caller cap.
if (purchaseCounts[_msgSender()] + _amount > callerCap) {
revert CannotExceedPerCallerCap();
}
// Reject purchases that exceed the total sale cap.
if (sold + _amount > totalCap) { revert CannotExceedTotalCap(); }
/*
If the current timestamp is greater than this contract's `startTime`, the
public sale has begun and all users will be directed to the public sale
functionality.
*/
if (block.timestamp >= startTime) {
sellPublic(_amount);
/*
Otherwise, since the public sale has not begun, attempt to sell to this
user as a member of the presale whitelist.
*/
} else {
sellWhitelist(_amount, _whitelist);
}
// Update the count of items sold.
sold += _amount;
// Update the caller's purchase count.
purchaseCounts[_msgSender()] += _amount;
// Mint the items.
ITiny721(collection).mint_Qgo(_msgSender(), _amount);
}
/**
Allow the owner to sweep either Ether or a particular ERC-20 token from the
contract and send it to another address. This allows the owner of the shop
to withdraw their funds after the sale is completed.
@param _token The token to sweep the balance from; if a zero address is sent
then the contract's balance of Ether will be swept.
@param _amount The amount of token to sweep.
@param _destination The address to send the swept tokens to.
*/
function sweep (
address _token,
address _destination,
uint256 _amount
) external onlyOwner nonReentrant {
// A zero address means we should attempt to sweep Ether.
if (_token == address(0)) {
(bool success, ) = payable(_destination).call{ value: _amount }("");
if (!success) { revert SweepingTransferFailed(); }
// Otherwise, we should try to sweep an ERC-20 token.
} else {
IERC20(_token).safeTransfer(_destination, _amount);
}
}
} | /**
@title A contract for selling NFTs via a merkle-based whitelist presale with
conversion into a public sale.
@author Tim Clancy
@author Qazawat Zirak
@author Rostislav Khlebnikov
@author Nikita Elunin
@author 0xthrpw
This contract is a modified version of SuperFarm mint shops optimized for the
specific use case of:
1. selling a single type of ERC-721 item from a single contract
2. running potentially multiple whitelisted presales with potentially
multiple different participants and different prices
3. selling the item for both ETH and an ERC-20 token during the presale
4. converting into a public sale that can sell for ETH only
This launchpad contract sells new items by minting them into existence. It
cannot be used to sell items that already exist.
March 10th, 2022.
*/ | NatSpecMultiLine | getRootHash | function getRootHash (
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private pure returns (bytes32) {
uint256 path = _index;
for (uint256 i = 0; i < _merkleProof.length; i++) {
if ((path & 0x01) == 1) {
_node = keccak256(abi.encodePacked(_merkleProof[i], _node));
} else {
_node = keccak256(abi.encodePacked(_node, _merkleProof[i]));
}
path /= 2;
}
return _node;
}
| /**
Calculate a root hash from given parameters.
@param _index The index of the hashed node from the list.
@param _node The index of the hashed node at that index.
@param _merkleProof An array of one required merkle hash per level.
@return The root hash from given parameters.
*/ | NatSpecMultiLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
6690,
7163
]
} | 4,353 |
||
DropPresaleShop721 | contracts/drops/DropPresaleShop721.sol | 0xe182af6be923b29f6a53855d5571fdd96b21d93a | Solidity | DropPresaleShop721 | contract DropPresaleShop721 is
Ownable, ReentrancyGuard
{
using SafeERC20 for IERC20;
/// The address of the ERC-721 item being sold.
address public immutable collection;
/// The time when the public sale begins.
uint256 public immutable startTime;
/// The time when the public sale ends.
uint256 public immutable endTime;
/// The maximum number of items from the `collection` that may be sold.
uint256 public immutable totalCap;
/// The maximum number of items that a single address may purchase.
uint256 public immutable callerCap;
/// The maximum number of items that may be purchased in a single transaction.
uint256 public immutable transactionCap;
/// The price at which to sell the item.
uint256 public immutable price;
/**
The number of whitelists that have been added. This is used for looking up
specific whitelist details from the `whitelists` mapping.
*/
uint256 public immutable whitelistCount;
/**
This struct is used at the moment of contract construction to specify a
presale whitelist that should apply to the sale this shop runs.
@param root The hash root of merkle tree uses to validate a caller's
inclusion in this whitelist.
@param startTime The starting time of this whitelist. When this is set to a
time earlier than the contract's `startTime` storage variable, that means
that this whitelist will begin earlier than the public sale. In effect,
that means that this whitelist will define a presale.
@param endTime The ending time of this whitelist. For standard presale
behavior, this should be set equal to the contract's `startTime` storage
variable to end the presale when the public sale begins. This can be set
later than the contract's `startTime` storage variable, but it will have
no effect. A presale whitelist may not be used once the public sale has
begun. Likewise, a presale may not run longer than the public item sale.
The public item sale `endTime` storage variable of this contract will
always override a whitelist's ending time.
@param price The price that applies to this presale whitelist.
@param token The address of the token with which purchases in this whitelist
will be made. If this is the zero address, then this whitelist will
conduct purchases using ETH.
*/
struct CreateWhitelist {
bytes32 root;
uint256 startTime;
uint256 endTime;
uint256 price;
address token;
}
/// A mapping to look up whitelist details for a given whitelist ID.
mapping ( uint256 => CreateWhitelist ) public whitelists;
/// A mapping to track the number of items purchases by each caller.
mapping ( address => uint256 ) public purchaseCounts;
/// The total number of items sold by the shop.
uint256 public sold;
/**
This struct is used at the moment of NFT purchase to let a caller submit
proof that they are actually entitled to a position on a presale whitelist.
@param id The ID of the whitelist to check proof against.
@param index The element index in the original array for proof verification.
@param allowance The quantity available to the caller for presale purchase.
@param proof A submitted proof that the user is on the whitelist.
*/
struct WhitelistProof {
uint256 id;
uint256 index;
uint256 allowance;
bytes32[] proof;
}
/*
A struct used to pass shop configuration details upon contract construction.
@param startTime The time when the public sale begins.
@param endTime The time when the public sale ends.
@param totalCap The maximum number of items from the `collection` that may
be sold.
@param callerCap The maximum number of items that a single address may
purchase.
@param transactionCap The maximum number of items that may be purchased in
a single transaction.
@param price The price to sell the item at.
*/
struct ShopConfiguration {
uint256 startTime;
uint256 endTime;
uint256 totalCap;
uint256 callerCap;
uint256 transactionCap;
uint256 price;
}
/**
Construct a new shop with configuration details about the intended sale.
@param _collection The address of the ERC-721 item being sold.
@param _configuration A parameter containing shop configuration information,
passed here as a struct to avoid a stack-to-deep error.
@param _whitelists The array of whitelist creation data containing details
for any presales being run.
*/
constructor (
address _collection,
ShopConfiguration memory _configuration,
CreateWhitelist[] memory _whitelists
) {
// Perform basic input validation.
if (_configuration.endTime < _configuration.startTime) {
revert CannotEndSaleBeforeItStarts();
}
// Once input parameters have been validated, set storage.
collection = _collection;
startTime = _configuration.startTime;
endTime = _configuration.endTime;
totalCap = _configuration.totalCap;
callerCap = _configuration.callerCap;
transactionCap = _configuration.transactionCap;
price = _configuration.price;
// Store all of the whitelists.
whitelistCount = _whitelists.length;
for (uint256 i = 0; i < _whitelists.length; i++) {
whitelists[i] = _whitelists[i];
}
}
/**
A private helper function to sell an item to a public sale participant. This
selling function refunds any overpayment to the user; refunding overpayment
is expected to be a common situation given the price decay in the Dutch
auction.
@param _amount The number of items that the caller would like to purchase.
*/
function sellPublic (
uint256 _amount
) private {
uint256 totalCharge = price * _amount;
// Reject the purchase if the caller is underpaying.
if (msg.value < totalCharge) { revert CannotUnderpayForMint(); }
// Refund the caller's excess payment if they overpaid.
if (msg.value > totalCharge) {
uint256 excess = msg.value - totalCharge;
(bool returned, ) = payable(_msgSender()).call{ value: excess }("");
if (!returned) { revert RefundTransferFailed(); }
}
}
/**
Calculate a root hash from given parameters.
@param _index The index of the hashed node from the list.
@param _node The index of the hashed node at that index.
@param _merkleProof An array of one required merkle hash per level.
@return The root hash from given parameters.
*/
function getRootHash (
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private pure returns (bytes32) {
uint256 path = _index;
for (uint256 i = 0; i < _merkleProof.length; i++) {
if ((path & 0x01) == 1) {
_node = keccak256(abi.encodePacked(_merkleProof[i], _node));
} else {
_node = keccak256(abi.encodePacked(_node, _merkleProof[i]));
}
path /= 2;
}
return _node;
}
/**
A helper function to verify an access against a targeted on-chain merkle
root.
@param _accesslistId The id of the accesslist containing the merkleRoot.
@param _index The index of the hashed node from off-chain list.
@param _node The actual hashed node which needs to be verified.
@param _merkleProof The merkle hashes from the off-chain merkle tree.
@return Whether the provided merkle proof is verifiably part of the on-chain
root.
*/
function verify (
uint256 _accesslistId,
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private view returns (bool) {
if (whitelists[_accesslistId].root == 0) {
return false;
} else if (block.timestamp < whitelists[_accesslistId].startTime) {
return false;
} else if (block.timestamp > whitelists[_accesslistId].endTime) {
return false;
} else if (
getRootHash(_index, _node, _merkleProof) != whitelists[_accesslistId].root
) {
return false;
}
return true;
}
/**
A private helper function to sell an item to a whitelist presale
participant.
@param _amount The number of items that the caller would like to purchase.
@param _whitelist A whitelist proof for users to submit with their claim to
verify that they are in fact on the whitelist.
*/
function sellWhitelist (
uint256 _amount,
WhitelistProof calldata _whitelist
) private {
// Verify that the caller is on the merkle whitelist.
bool verified = verify(
_whitelist.id,
_whitelist.index,
keccak256(
abi.encodePacked(
_whitelist.index,
_msgSender(),
_whitelist.allowance
)
),
_whitelist.proof
);
// Reject the purchase if the caller is not a valid whitelist member.
if (!verified) { revert CannotVerifyAsWhitelistMember(); }
// Reject the purchase if the caller is exceeding their whitelist allowance.
if (purchaseCounts[_msgSender()] + _amount > _whitelist.allowance) {
revert CannotExceedWhitelistAllowance();
}
// Calculate the sale token and price.
address token = whitelists[_whitelist.id].token;
uint256 whitelistPrice = whitelists[_whitelist.id].price * _amount;
// The zero address indicates that the purchase asset is Ether.
if (token == address(0)) {
if (msg.value != whitelistPrice) {
revert CannotTransferIncorrectAmount();
}
// Otherwise, the caller is making their purchase with an ERC-20 token.
} else {
IERC20(token).safeTransferFrom(
_msgSender(),
address(this),
whitelistPrice
);
}
}
/**
Allow a caller to purchase an item.
@param _amount The amount of items that the caller would like to purchase.
@param _whitelist The caller-subumitted whitelist proof to check if they
belong on a presale whitelist.
*/
function mint (
uint256 _amount,
WhitelistProof calldata _whitelist
) external payable nonReentrant {
// Reject purchases for no items.
if (_amount < 1) { revert CannotBuyZeroItems(); }
/*
Reject purchases that happen after the end of the public sale. Do note
that this means that whitelist sales with an ending duration _after_ the
end of the public sale are ignored completely. In other words: the ending
time of the public sale takes precedent over the ending time of a
whitelisted presale. A whitelisted presale may not continue selling items
after the public sale has ended.
*/
if (block.timestamp >= endTime) { revert CannotBuyFromEndedSale(); }
// Reject purchases that exceed the per-transaction cap.
if (_amount > transactionCap) {
revert CannotExceedPerTransactionCap();
}
// Reject purchases that exceed the per-caller cap.
if (purchaseCounts[_msgSender()] + _amount > callerCap) {
revert CannotExceedPerCallerCap();
}
// Reject purchases that exceed the total sale cap.
if (sold + _amount > totalCap) { revert CannotExceedTotalCap(); }
/*
If the current timestamp is greater than this contract's `startTime`, the
public sale has begun and all users will be directed to the public sale
functionality.
*/
if (block.timestamp >= startTime) {
sellPublic(_amount);
/*
Otherwise, since the public sale has not begun, attempt to sell to this
user as a member of the presale whitelist.
*/
} else {
sellWhitelist(_amount, _whitelist);
}
// Update the count of items sold.
sold += _amount;
// Update the caller's purchase count.
purchaseCounts[_msgSender()] += _amount;
// Mint the items.
ITiny721(collection).mint_Qgo(_msgSender(), _amount);
}
/**
Allow the owner to sweep either Ether or a particular ERC-20 token from the
contract and send it to another address. This allows the owner of the shop
to withdraw their funds after the sale is completed.
@param _token The token to sweep the balance from; if a zero address is sent
then the contract's balance of Ether will be swept.
@param _amount The amount of token to sweep.
@param _destination The address to send the swept tokens to.
*/
function sweep (
address _token,
address _destination,
uint256 _amount
) external onlyOwner nonReentrant {
// A zero address means we should attempt to sweep Ether.
if (_token == address(0)) {
(bool success, ) = payable(_destination).call{ value: _amount }("");
if (!success) { revert SweepingTransferFailed(); }
// Otherwise, we should try to sweep an ERC-20 token.
} else {
IERC20(_token).safeTransfer(_destination, _amount);
}
}
} | /**
@title A contract for selling NFTs via a merkle-based whitelist presale with
conversion into a public sale.
@author Tim Clancy
@author Qazawat Zirak
@author Rostislav Khlebnikov
@author Nikita Elunin
@author 0xthrpw
This contract is a modified version of SuperFarm mint shops optimized for the
specific use case of:
1. selling a single type of ERC-721 item from a single contract
2. running potentially multiple whitelisted presales with potentially
multiple different participants and different prices
3. selling the item for both ETH and an ERC-20 token during the presale
4. converting into a public sale that can sell for ETH only
This launchpad contract sells new items by minting them into existence. It
cannot be used to sell items that already exist.
March 10th, 2022.
*/ | NatSpecMultiLine | verify | function verify (
uint256 _accesslistId,
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private view returns (bool) {
if (whitelists[_accesslistId].root == 0) {
return false;
} else if (block.timestamp < whitelists[_accesslistId].startTime) {
return false;
} else if (block.timestamp > whitelists[_accesslistId].endTime) {
return false;
} else if (
getRootHash(_index, _node, _merkleProof) != whitelists[_accesslistId].root
) {
return false;
}
return true;
}
| /**
A helper function to verify an access against a targeted on-chain merkle
root.
@param _accesslistId The id of the accesslist containing the merkleRoot.
@param _index The index of the hashed node from off-chain list.
@param _node The actual hashed node which needs to be verified.
@param _merkleProof The merkle hashes from the off-chain merkle tree.
@return Whether the provided merkle proof is verifiably part of the on-chain
root.
*/ | NatSpecMultiLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
7658,
8233
]
} | 4,354 |
||
DropPresaleShop721 | contracts/drops/DropPresaleShop721.sol | 0xe182af6be923b29f6a53855d5571fdd96b21d93a | Solidity | DropPresaleShop721 | contract DropPresaleShop721 is
Ownable, ReentrancyGuard
{
using SafeERC20 for IERC20;
/// The address of the ERC-721 item being sold.
address public immutable collection;
/// The time when the public sale begins.
uint256 public immutable startTime;
/// The time when the public sale ends.
uint256 public immutable endTime;
/// The maximum number of items from the `collection` that may be sold.
uint256 public immutable totalCap;
/// The maximum number of items that a single address may purchase.
uint256 public immutable callerCap;
/// The maximum number of items that may be purchased in a single transaction.
uint256 public immutable transactionCap;
/// The price at which to sell the item.
uint256 public immutable price;
/**
The number of whitelists that have been added. This is used for looking up
specific whitelist details from the `whitelists` mapping.
*/
uint256 public immutable whitelistCount;
/**
This struct is used at the moment of contract construction to specify a
presale whitelist that should apply to the sale this shop runs.
@param root The hash root of merkle tree uses to validate a caller's
inclusion in this whitelist.
@param startTime The starting time of this whitelist. When this is set to a
time earlier than the contract's `startTime` storage variable, that means
that this whitelist will begin earlier than the public sale. In effect,
that means that this whitelist will define a presale.
@param endTime The ending time of this whitelist. For standard presale
behavior, this should be set equal to the contract's `startTime` storage
variable to end the presale when the public sale begins. This can be set
later than the contract's `startTime` storage variable, but it will have
no effect. A presale whitelist may not be used once the public sale has
begun. Likewise, a presale may not run longer than the public item sale.
The public item sale `endTime` storage variable of this contract will
always override a whitelist's ending time.
@param price The price that applies to this presale whitelist.
@param token The address of the token with which purchases in this whitelist
will be made. If this is the zero address, then this whitelist will
conduct purchases using ETH.
*/
struct CreateWhitelist {
bytes32 root;
uint256 startTime;
uint256 endTime;
uint256 price;
address token;
}
/// A mapping to look up whitelist details for a given whitelist ID.
mapping ( uint256 => CreateWhitelist ) public whitelists;
/// A mapping to track the number of items purchases by each caller.
mapping ( address => uint256 ) public purchaseCounts;
/// The total number of items sold by the shop.
uint256 public sold;
/**
This struct is used at the moment of NFT purchase to let a caller submit
proof that they are actually entitled to a position on a presale whitelist.
@param id The ID of the whitelist to check proof against.
@param index The element index in the original array for proof verification.
@param allowance The quantity available to the caller for presale purchase.
@param proof A submitted proof that the user is on the whitelist.
*/
struct WhitelistProof {
uint256 id;
uint256 index;
uint256 allowance;
bytes32[] proof;
}
/*
A struct used to pass shop configuration details upon contract construction.
@param startTime The time when the public sale begins.
@param endTime The time when the public sale ends.
@param totalCap The maximum number of items from the `collection` that may
be sold.
@param callerCap The maximum number of items that a single address may
purchase.
@param transactionCap The maximum number of items that may be purchased in
a single transaction.
@param price The price to sell the item at.
*/
struct ShopConfiguration {
uint256 startTime;
uint256 endTime;
uint256 totalCap;
uint256 callerCap;
uint256 transactionCap;
uint256 price;
}
/**
Construct a new shop with configuration details about the intended sale.
@param _collection The address of the ERC-721 item being sold.
@param _configuration A parameter containing shop configuration information,
passed here as a struct to avoid a stack-to-deep error.
@param _whitelists The array of whitelist creation data containing details
for any presales being run.
*/
constructor (
address _collection,
ShopConfiguration memory _configuration,
CreateWhitelist[] memory _whitelists
) {
// Perform basic input validation.
if (_configuration.endTime < _configuration.startTime) {
revert CannotEndSaleBeforeItStarts();
}
// Once input parameters have been validated, set storage.
collection = _collection;
startTime = _configuration.startTime;
endTime = _configuration.endTime;
totalCap = _configuration.totalCap;
callerCap = _configuration.callerCap;
transactionCap = _configuration.transactionCap;
price = _configuration.price;
// Store all of the whitelists.
whitelistCount = _whitelists.length;
for (uint256 i = 0; i < _whitelists.length; i++) {
whitelists[i] = _whitelists[i];
}
}
/**
A private helper function to sell an item to a public sale participant. This
selling function refunds any overpayment to the user; refunding overpayment
is expected to be a common situation given the price decay in the Dutch
auction.
@param _amount The number of items that the caller would like to purchase.
*/
function sellPublic (
uint256 _amount
) private {
uint256 totalCharge = price * _amount;
// Reject the purchase if the caller is underpaying.
if (msg.value < totalCharge) { revert CannotUnderpayForMint(); }
// Refund the caller's excess payment if they overpaid.
if (msg.value > totalCharge) {
uint256 excess = msg.value - totalCharge;
(bool returned, ) = payable(_msgSender()).call{ value: excess }("");
if (!returned) { revert RefundTransferFailed(); }
}
}
/**
Calculate a root hash from given parameters.
@param _index The index of the hashed node from the list.
@param _node The index of the hashed node at that index.
@param _merkleProof An array of one required merkle hash per level.
@return The root hash from given parameters.
*/
function getRootHash (
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private pure returns (bytes32) {
uint256 path = _index;
for (uint256 i = 0; i < _merkleProof.length; i++) {
if ((path & 0x01) == 1) {
_node = keccak256(abi.encodePacked(_merkleProof[i], _node));
} else {
_node = keccak256(abi.encodePacked(_node, _merkleProof[i]));
}
path /= 2;
}
return _node;
}
/**
A helper function to verify an access against a targeted on-chain merkle
root.
@param _accesslistId The id of the accesslist containing the merkleRoot.
@param _index The index of the hashed node from off-chain list.
@param _node The actual hashed node which needs to be verified.
@param _merkleProof The merkle hashes from the off-chain merkle tree.
@return Whether the provided merkle proof is verifiably part of the on-chain
root.
*/
function verify (
uint256 _accesslistId,
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private view returns (bool) {
if (whitelists[_accesslistId].root == 0) {
return false;
} else if (block.timestamp < whitelists[_accesslistId].startTime) {
return false;
} else if (block.timestamp > whitelists[_accesslistId].endTime) {
return false;
} else if (
getRootHash(_index, _node, _merkleProof) != whitelists[_accesslistId].root
) {
return false;
}
return true;
}
/**
A private helper function to sell an item to a whitelist presale
participant.
@param _amount The number of items that the caller would like to purchase.
@param _whitelist A whitelist proof for users to submit with their claim to
verify that they are in fact on the whitelist.
*/
function sellWhitelist (
uint256 _amount,
WhitelistProof calldata _whitelist
) private {
// Verify that the caller is on the merkle whitelist.
bool verified = verify(
_whitelist.id,
_whitelist.index,
keccak256(
abi.encodePacked(
_whitelist.index,
_msgSender(),
_whitelist.allowance
)
),
_whitelist.proof
);
// Reject the purchase if the caller is not a valid whitelist member.
if (!verified) { revert CannotVerifyAsWhitelistMember(); }
// Reject the purchase if the caller is exceeding their whitelist allowance.
if (purchaseCounts[_msgSender()] + _amount > _whitelist.allowance) {
revert CannotExceedWhitelistAllowance();
}
// Calculate the sale token and price.
address token = whitelists[_whitelist.id].token;
uint256 whitelistPrice = whitelists[_whitelist.id].price * _amount;
// The zero address indicates that the purchase asset is Ether.
if (token == address(0)) {
if (msg.value != whitelistPrice) {
revert CannotTransferIncorrectAmount();
}
// Otherwise, the caller is making their purchase with an ERC-20 token.
} else {
IERC20(token).safeTransferFrom(
_msgSender(),
address(this),
whitelistPrice
);
}
}
/**
Allow a caller to purchase an item.
@param _amount The amount of items that the caller would like to purchase.
@param _whitelist The caller-subumitted whitelist proof to check if they
belong on a presale whitelist.
*/
function mint (
uint256 _amount,
WhitelistProof calldata _whitelist
) external payable nonReentrant {
// Reject purchases for no items.
if (_amount < 1) { revert CannotBuyZeroItems(); }
/*
Reject purchases that happen after the end of the public sale. Do note
that this means that whitelist sales with an ending duration _after_ the
end of the public sale are ignored completely. In other words: the ending
time of the public sale takes precedent over the ending time of a
whitelisted presale. A whitelisted presale may not continue selling items
after the public sale has ended.
*/
if (block.timestamp >= endTime) { revert CannotBuyFromEndedSale(); }
// Reject purchases that exceed the per-transaction cap.
if (_amount > transactionCap) {
revert CannotExceedPerTransactionCap();
}
// Reject purchases that exceed the per-caller cap.
if (purchaseCounts[_msgSender()] + _amount > callerCap) {
revert CannotExceedPerCallerCap();
}
// Reject purchases that exceed the total sale cap.
if (sold + _amount > totalCap) { revert CannotExceedTotalCap(); }
/*
If the current timestamp is greater than this contract's `startTime`, the
public sale has begun and all users will be directed to the public sale
functionality.
*/
if (block.timestamp >= startTime) {
sellPublic(_amount);
/*
Otherwise, since the public sale has not begun, attempt to sell to this
user as a member of the presale whitelist.
*/
} else {
sellWhitelist(_amount, _whitelist);
}
// Update the count of items sold.
sold += _amount;
// Update the caller's purchase count.
purchaseCounts[_msgSender()] += _amount;
// Mint the items.
ITiny721(collection).mint_Qgo(_msgSender(), _amount);
}
/**
Allow the owner to sweep either Ether or a particular ERC-20 token from the
contract and send it to another address. This allows the owner of the shop
to withdraw their funds after the sale is completed.
@param _token The token to sweep the balance from; if a zero address is sent
then the contract's balance of Ether will be swept.
@param _amount The amount of token to sweep.
@param _destination The address to send the swept tokens to.
*/
function sweep (
address _token,
address _destination,
uint256 _amount
) external onlyOwner nonReentrant {
// A zero address means we should attempt to sweep Ether.
if (_token == address(0)) {
(bool success, ) = payable(_destination).call{ value: _amount }("");
if (!success) { revert SweepingTransferFailed(); }
// Otherwise, we should try to sweep an ERC-20 token.
} else {
IERC20(_token).safeTransfer(_destination, _amount);
}
}
} | /**
@title A contract for selling NFTs via a merkle-based whitelist presale with
conversion into a public sale.
@author Tim Clancy
@author Qazawat Zirak
@author Rostislav Khlebnikov
@author Nikita Elunin
@author 0xthrpw
This contract is a modified version of SuperFarm mint shops optimized for the
specific use case of:
1. selling a single type of ERC-721 item from a single contract
2. running potentially multiple whitelisted presales with potentially
multiple different participants and different prices
3. selling the item for both ETH and an ERC-20 token during the presale
4. converting into a public sale that can sell for ETH only
This launchpad contract sells new items by minting them into existence. It
cannot be used to sell items that already exist.
March 10th, 2022.
*/ | NatSpecMultiLine | sellWhitelist | function sellWhitelist (
uint256 _amount,
WhitelistProof calldata _whitelist
) private {
// Verify that the caller is on the merkle whitelist.
bool verified = verify(
_whitelist.id,
_whitelist.index,
keccak256(
abi.encodePacked(
_whitelist.index,
_msgSender(),
_whitelist.allowance
)
),
_whitelist.proof
);
// Reject the purchase if the caller is not a valid whitelist member.
if (!verified) { revert CannotVerifyAsWhitelistMember(); }
// Reject the purchase if the caller is exceeding their whitelist allowance.
if (purchaseCounts[_msgSender()] + _amount > _whitelist.allowance) {
revert CannotExceedWhitelistAllowance();
}
// Calculate the sale token and price.
address token = whitelists[_whitelist.id].token;
uint256 whitelistPrice = whitelists[_whitelist.id].price * _amount;
// The zero address indicates that the purchase asset is Ether.
if (token == address(0)) {
if (msg.value != whitelistPrice) {
revert CannotTransferIncorrectAmount();
}
// Otherwise, the caller is making their purchase with an ERC-20 token.
} else {
IERC20(token).safeTransferFrom(
_msgSender(),
address(this),
whitelistPrice
);
}
}
| /**
A private helper function to sell an item to a whitelist presale
participant.
@param _amount The number of items that the caller would like to purchase.
@param _whitelist A whitelist proof for users to submit with their claim to
verify that they are in fact on the whitelist.
*/ | NatSpecMultiLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
8554,
9934
]
} | 4,355 |
||
DropPresaleShop721 | contracts/drops/DropPresaleShop721.sol | 0xe182af6be923b29f6a53855d5571fdd96b21d93a | Solidity | DropPresaleShop721 | contract DropPresaleShop721 is
Ownable, ReentrancyGuard
{
using SafeERC20 for IERC20;
/// The address of the ERC-721 item being sold.
address public immutable collection;
/// The time when the public sale begins.
uint256 public immutable startTime;
/// The time when the public sale ends.
uint256 public immutable endTime;
/// The maximum number of items from the `collection` that may be sold.
uint256 public immutable totalCap;
/// The maximum number of items that a single address may purchase.
uint256 public immutable callerCap;
/// The maximum number of items that may be purchased in a single transaction.
uint256 public immutable transactionCap;
/// The price at which to sell the item.
uint256 public immutable price;
/**
The number of whitelists that have been added. This is used for looking up
specific whitelist details from the `whitelists` mapping.
*/
uint256 public immutable whitelistCount;
/**
This struct is used at the moment of contract construction to specify a
presale whitelist that should apply to the sale this shop runs.
@param root The hash root of merkle tree uses to validate a caller's
inclusion in this whitelist.
@param startTime The starting time of this whitelist. When this is set to a
time earlier than the contract's `startTime` storage variable, that means
that this whitelist will begin earlier than the public sale. In effect,
that means that this whitelist will define a presale.
@param endTime The ending time of this whitelist. For standard presale
behavior, this should be set equal to the contract's `startTime` storage
variable to end the presale when the public sale begins. This can be set
later than the contract's `startTime` storage variable, but it will have
no effect. A presale whitelist may not be used once the public sale has
begun. Likewise, a presale may not run longer than the public item sale.
The public item sale `endTime` storage variable of this contract will
always override a whitelist's ending time.
@param price The price that applies to this presale whitelist.
@param token The address of the token with which purchases in this whitelist
will be made. If this is the zero address, then this whitelist will
conduct purchases using ETH.
*/
struct CreateWhitelist {
bytes32 root;
uint256 startTime;
uint256 endTime;
uint256 price;
address token;
}
/// A mapping to look up whitelist details for a given whitelist ID.
mapping ( uint256 => CreateWhitelist ) public whitelists;
/// A mapping to track the number of items purchases by each caller.
mapping ( address => uint256 ) public purchaseCounts;
/// The total number of items sold by the shop.
uint256 public sold;
/**
This struct is used at the moment of NFT purchase to let a caller submit
proof that they are actually entitled to a position on a presale whitelist.
@param id The ID of the whitelist to check proof against.
@param index The element index in the original array for proof verification.
@param allowance The quantity available to the caller for presale purchase.
@param proof A submitted proof that the user is on the whitelist.
*/
struct WhitelistProof {
uint256 id;
uint256 index;
uint256 allowance;
bytes32[] proof;
}
/*
A struct used to pass shop configuration details upon contract construction.
@param startTime The time when the public sale begins.
@param endTime The time when the public sale ends.
@param totalCap The maximum number of items from the `collection` that may
be sold.
@param callerCap The maximum number of items that a single address may
purchase.
@param transactionCap The maximum number of items that may be purchased in
a single transaction.
@param price The price to sell the item at.
*/
struct ShopConfiguration {
uint256 startTime;
uint256 endTime;
uint256 totalCap;
uint256 callerCap;
uint256 transactionCap;
uint256 price;
}
/**
Construct a new shop with configuration details about the intended sale.
@param _collection The address of the ERC-721 item being sold.
@param _configuration A parameter containing shop configuration information,
passed here as a struct to avoid a stack-to-deep error.
@param _whitelists The array of whitelist creation data containing details
for any presales being run.
*/
constructor (
address _collection,
ShopConfiguration memory _configuration,
CreateWhitelist[] memory _whitelists
) {
// Perform basic input validation.
if (_configuration.endTime < _configuration.startTime) {
revert CannotEndSaleBeforeItStarts();
}
// Once input parameters have been validated, set storage.
collection = _collection;
startTime = _configuration.startTime;
endTime = _configuration.endTime;
totalCap = _configuration.totalCap;
callerCap = _configuration.callerCap;
transactionCap = _configuration.transactionCap;
price = _configuration.price;
// Store all of the whitelists.
whitelistCount = _whitelists.length;
for (uint256 i = 0; i < _whitelists.length; i++) {
whitelists[i] = _whitelists[i];
}
}
/**
A private helper function to sell an item to a public sale participant. This
selling function refunds any overpayment to the user; refunding overpayment
is expected to be a common situation given the price decay in the Dutch
auction.
@param _amount The number of items that the caller would like to purchase.
*/
function sellPublic (
uint256 _amount
) private {
uint256 totalCharge = price * _amount;
// Reject the purchase if the caller is underpaying.
if (msg.value < totalCharge) { revert CannotUnderpayForMint(); }
// Refund the caller's excess payment if they overpaid.
if (msg.value > totalCharge) {
uint256 excess = msg.value - totalCharge;
(bool returned, ) = payable(_msgSender()).call{ value: excess }("");
if (!returned) { revert RefundTransferFailed(); }
}
}
/**
Calculate a root hash from given parameters.
@param _index The index of the hashed node from the list.
@param _node The index of the hashed node at that index.
@param _merkleProof An array of one required merkle hash per level.
@return The root hash from given parameters.
*/
function getRootHash (
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private pure returns (bytes32) {
uint256 path = _index;
for (uint256 i = 0; i < _merkleProof.length; i++) {
if ((path & 0x01) == 1) {
_node = keccak256(abi.encodePacked(_merkleProof[i], _node));
} else {
_node = keccak256(abi.encodePacked(_node, _merkleProof[i]));
}
path /= 2;
}
return _node;
}
/**
A helper function to verify an access against a targeted on-chain merkle
root.
@param _accesslistId The id of the accesslist containing the merkleRoot.
@param _index The index of the hashed node from off-chain list.
@param _node The actual hashed node which needs to be verified.
@param _merkleProof The merkle hashes from the off-chain merkle tree.
@return Whether the provided merkle proof is verifiably part of the on-chain
root.
*/
function verify (
uint256 _accesslistId,
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private view returns (bool) {
if (whitelists[_accesslistId].root == 0) {
return false;
} else if (block.timestamp < whitelists[_accesslistId].startTime) {
return false;
} else if (block.timestamp > whitelists[_accesslistId].endTime) {
return false;
} else if (
getRootHash(_index, _node, _merkleProof) != whitelists[_accesslistId].root
) {
return false;
}
return true;
}
/**
A private helper function to sell an item to a whitelist presale
participant.
@param _amount The number of items that the caller would like to purchase.
@param _whitelist A whitelist proof for users to submit with their claim to
verify that they are in fact on the whitelist.
*/
function sellWhitelist (
uint256 _amount,
WhitelistProof calldata _whitelist
) private {
// Verify that the caller is on the merkle whitelist.
bool verified = verify(
_whitelist.id,
_whitelist.index,
keccak256(
abi.encodePacked(
_whitelist.index,
_msgSender(),
_whitelist.allowance
)
),
_whitelist.proof
);
// Reject the purchase if the caller is not a valid whitelist member.
if (!verified) { revert CannotVerifyAsWhitelistMember(); }
// Reject the purchase if the caller is exceeding their whitelist allowance.
if (purchaseCounts[_msgSender()] + _amount > _whitelist.allowance) {
revert CannotExceedWhitelistAllowance();
}
// Calculate the sale token and price.
address token = whitelists[_whitelist.id].token;
uint256 whitelistPrice = whitelists[_whitelist.id].price * _amount;
// The zero address indicates that the purchase asset is Ether.
if (token == address(0)) {
if (msg.value != whitelistPrice) {
revert CannotTransferIncorrectAmount();
}
// Otherwise, the caller is making their purchase with an ERC-20 token.
} else {
IERC20(token).safeTransferFrom(
_msgSender(),
address(this),
whitelistPrice
);
}
}
/**
Allow a caller to purchase an item.
@param _amount The amount of items that the caller would like to purchase.
@param _whitelist The caller-subumitted whitelist proof to check if they
belong on a presale whitelist.
*/
function mint (
uint256 _amount,
WhitelistProof calldata _whitelist
) external payable nonReentrant {
// Reject purchases for no items.
if (_amount < 1) { revert CannotBuyZeroItems(); }
/*
Reject purchases that happen after the end of the public sale. Do note
that this means that whitelist sales with an ending duration _after_ the
end of the public sale are ignored completely. In other words: the ending
time of the public sale takes precedent over the ending time of a
whitelisted presale. A whitelisted presale may not continue selling items
after the public sale has ended.
*/
if (block.timestamp >= endTime) { revert CannotBuyFromEndedSale(); }
// Reject purchases that exceed the per-transaction cap.
if (_amount > transactionCap) {
revert CannotExceedPerTransactionCap();
}
// Reject purchases that exceed the per-caller cap.
if (purchaseCounts[_msgSender()] + _amount > callerCap) {
revert CannotExceedPerCallerCap();
}
// Reject purchases that exceed the total sale cap.
if (sold + _amount > totalCap) { revert CannotExceedTotalCap(); }
/*
If the current timestamp is greater than this contract's `startTime`, the
public sale has begun and all users will be directed to the public sale
functionality.
*/
if (block.timestamp >= startTime) {
sellPublic(_amount);
/*
Otherwise, since the public sale has not begun, attempt to sell to this
user as a member of the presale whitelist.
*/
} else {
sellWhitelist(_amount, _whitelist);
}
// Update the count of items sold.
sold += _amount;
// Update the caller's purchase count.
purchaseCounts[_msgSender()] += _amount;
// Mint the items.
ITiny721(collection).mint_Qgo(_msgSender(), _amount);
}
/**
Allow the owner to sweep either Ether or a particular ERC-20 token from the
contract and send it to another address. This allows the owner of the shop
to withdraw their funds after the sale is completed.
@param _token The token to sweep the balance from; if a zero address is sent
then the contract's balance of Ether will be swept.
@param _amount The amount of token to sweep.
@param _destination The address to send the swept tokens to.
*/
function sweep (
address _token,
address _destination,
uint256 _amount
) external onlyOwner nonReentrant {
// A zero address means we should attempt to sweep Ether.
if (_token == address(0)) {
(bool success, ) = payable(_destination).call{ value: _amount }("");
if (!success) { revert SweepingTransferFailed(); }
// Otherwise, we should try to sweep an ERC-20 token.
} else {
IERC20(_token).safeTransfer(_destination, _amount);
}
}
} | /**
@title A contract for selling NFTs via a merkle-based whitelist presale with
conversion into a public sale.
@author Tim Clancy
@author Qazawat Zirak
@author Rostislav Khlebnikov
@author Nikita Elunin
@author 0xthrpw
This contract is a modified version of SuperFarm mint shops optimized for the
specific use case of:
1. selling a single type of ERC-721 item from a single contract
2. running potentially multiple whitelisted presales with potentially
multiple different participants and different prices
3. selling the item for both ETH and an ERC-20 token during the presale
4. converting into a public sale that can sell for ETH only
This launchpad contract sells new items by minting them into existence. It
cannot be used to sell items that already exist.
March 10th, 2022.
*/ | NatSpecMultiLine | mint | function mint (
uint256 _amount,
WhitelistProof calldata _whitelist
) external payable nonReentrant {
// Reject purchases for no items.
if (_amount < 1) { revert CannotBuyZeroItems(); }
/*
Reject purchases that happen after the end of the public sale. Do note
that this means that whitelist sales with an ending duration _after_ the
end of the public sale are ignored completely. In other words: the ending
time of the public sale takes precedent over the ending time of a
whitelisted presale. A whitelisted presale may not continue selling items
after the public sale has ended.
*/
if (block.timestamp >= endTime) { revert CannotBuyFromEndedSale(); }
// Reject purchases that exceed the per-transaction cap.
if (_amount > transactionCap) {
revert CannotExceedPerTransactionCap();
}
// Reject purchases that exceed the per-caller cap.
if (purchaseCounts[_msgSender()] + _amount > callerCap) {
revert CannotExceedPerCallerCap();
}
// Reject purchases that exceed the total sale cap.
if (sold + _amount > totalCap) { revert CannotExceedTotalCap(); }
/*
If the current timestamp is greater than this contract's `startTime`, the
public sale has begun and all users will be directed to the public sale
functionality.
*/
if (block.timestamp >= startTime) {
sellPublic(_amount);
/*
Otherwise, since the public sale has not begun, attempt to sell to this
user as a member of the presale whitelist.
*/
} else {
sellWhitelist(_amount, _whitelist);
}
// Update the count of items sold.
sold += _amount;
// Update the caller's purchase count.
purchaseCounts[_msgSender()] += _amount;
// Mint the items.
ITiny721(collection).mint_Qgo(_msgSender(), _amount);
}
| /**
Allow a caller to purchase an item.
@param _amount The amount of items that the caller would like to purchase.
@param _whitelist The caller-subumitted whitelist proof to check if they
belong on a presale whitelist.
*/ | NatSpecMultiLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
10189,
12109
]
} | 4,356 |
||
DropPresaleShop721 | contracts/drops/DropPresaleShop721.sol | 0xe182af6be923b29f6a53855d5571fdd96b21d93a | Solidity | DropPresaleShop721 | contract DropPresaleShop721 is
Ownable, ReentrancyGuard
{
using SafeERC20 for IERC20;
/// The address of the ERC-721 item being sold.
address public immutable collection;
/// The time when the public sale begins.
uint256 public immutable startTime;
/// The time when the public sale ends.
uint256 public immutable endTime;
/// The maximum number of items from the `collection` that may be sold.
uint256 public immutable totalCap;
/// The maximum number of items that a single address may purchase.
uint256 public immutable callerCap;
/// The maximum number of items that may be purchased in a single transaction.
uint256 public immutable transactionCap;
/// The price at which to sell the item.
uint256 public immutable price;
/**
The number of whitelists that have been added. This is used for looking up
specific whitelist details from the `whitelists` mapping.
*/
uint256 public immutable whitelistCount;
/**
This struct is used at the moment of contract construction to specify a
presale whitelist that should apply to the sale this shop runs.
@param root The hash root of merkle tree uses to validate a caller's
inclusion in this whitelist.
@param startTime The starting time of this whitelist. When this is set to a
time earlier than the contract's `startTime` storage variable, that means
that this whitelist will begin earlier than the public sale. In effect,
that means that this whitelist will define a presale.
@param endTime The ending time of this whitelist. For standard presale
behavior, this should be set equal to the contract's `startTime` storage
variable to end the presale when the public sale begins. This can be set
later than the contract's `startTime` storage variable, but it will have
no effect. A presale whitelist may not be used once the public sale has
begun. Likewise, a presale may not run longer than the public item sale.
The public item sale `endTime` storage variable of this contract will
always override a whitelist's ending time.
@param price The price that applies to this presale whitelist.
@param token The address of the token with which purchases in this whitelist
will be made. If this is the zero address, then this whitelist will
conduct purchases using ETH.
*/
struct CreateWhitelist {
bytes32 root;
uint256 startTime;
uint256 endTime;
uint256 price;
address token;
}
/// A mapping to look up whitelist details for a given whitelist ID.
mapping ( uint256 => CreateWhitelist ) public whitelists;
/// A mapping to track the number of items purchases by each caller.
mapping ( address => uint256 ) public purchaseCounts;
/// The total number of items sold by the shop.
uint256 public sold;
/**
This struct is used at the moment of NFT purchase to let a caller submit
proof that they are actually entitled to a position on a presale whitelist.
@param id The ID of the whitelist to check proof against.
@param index The element index in the original array for proof verification.
@param allowance The quantity available to the caller for presale purchase.
@param proof A submitted proof that the user is on the whitelist.
*/
struct WhitelistProof {
uint256 id;
uint256 index;
uint256 allowance;
bytes32[] proof;
}
/*
A struct used to pass shop configuration details upon contract construction.
@param startTime The time when the public sale begins.
@param endTime The time when the public sale ends.
@param totalCap The maximum number of items from the `collection` that may
be sold.
@param callerCap The maximum number of items that a single address may
purchase.
@param transactionCap The maximum number of items that may be purchased in
a single transaction.
@param price The price to sell the item at.
*/
struct ShopConfiguration {
uint256 startTime;
uint256 endTime;
uint256 totalCap;
uint256 callerCap;
uint256 transactionCap;
uint256 price;
}
/**
Construct a new shop with configuration details about the intended sale.
@param _collection The address of the ERC-721 item being sold.
@param _configuration A parameter containing shop configuration information,
passed here as a struct to avoid a stack-to-deep error.
@param _whitelists The array of whitelist creation data containing details
for any presales being run.
*/
constructor (
address _collection,
ShopConfiguration memory _configuration,
CreateWhitelist[] memory _whitelists
) {
// Perform basic input validation.
if (_configuration.endTime < _configuration.startTime) {
revert CannotEndSaleBeforeItStarts();
}
// Once input parameters have been validated, set storage.
collection = _collection;
startTime = _configuration.startTime;
endTime = _configuration.endTime;
totalCap = _configuration.totalCap;
callerCap = _configuration.callerCap;
transactionCap = _configuration.transactionCap;
price = _configuration.price;
// Store all of the whitelists.
whitelistCount = _whitelists.length;
for (uint256 i = 0; i < _whitelists.length; i++) {
whitelists[i] = _whitelists[i];
}
}
/**
A private helper function to sell an item to a public sale participant. This
selling function refunds any overpayment to the user; refunding overpayment
is expected to be a common situation given the price decay in the Dutch
auction.
@param _amount The number of items that the caller would like to purchase.
*/
function sellPublic (
uint256 _amount
) private {
uint256 totalCharge = price * _amount;
// Reject the purchase if the caller is underpaying.
if (msg.value < totalCharge) { revert CannotUnderpayForMint(); }
// Refund the caller's excess payment if they overpaid.
if (msg.value > totalCharge) {
uint256 excess = msg.value - totalCharge;
(bool returned, ) = payable(_msgSender()).call{ value: excess }("");
if (!returned) { revert RefundTransferFailed(); }
}
}
/**
Calculate a root hash from given parameters.
@param _index The index of the hashed node from the list.
@param _node The index of the hashed node at that index.
@param _merkleProof An array of one required merkle hash per level.
@return The root hash from given parameters.
*/
function getRootHash (
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private pure returns (bytes32) {
uint256 path = _index;
for (uint256 i = 0; i < _merkleProof.length; i++) {
if ((path & 0x01) == 1) {
_node = keccak256(abi.encodePacked(_merkleProof[i], _node));
} else {
_node = keccak256(abi.encodePacked(_node, _merkleProof[i]));
}
path /= 2;
}
return _node;
}
/**
A helper function to verify an access against a targeted on-chain merkle
root.
@param _accesslistId The id of the accesslist containing the merkleRoot.
@param _index The index of the hashed node from off-chain list.
@param _node The actual hashed node which needs to be verified.
@param _merkleProof The merkle hashes from the off-chain merkle tree.
@return Whether the provided merkle proof is verifiably part of the on-chain
root.
*/
function verify (
uint256 _accesslistId,
uint256 _index,
bytes32 _node,
bytes32[] calldata _merkleProof
) private view returns (bool) {
if (whitelists[_accesslistId].root == 0) {
return false;
} else if (block.timestamp < whitelists[_accesslistId].startTime) {
return false;
} else if (block.timestamp > whitelists[_accesslistId].endTime) {
return false;
} else if (
getRootHash(_index, _node, _merkleProof) != whitelists[_accesslistId].root
) {
return false;
}
return true;
}
/**
A private helper function to sell an item to a whitelist presale
participant.
@param _amount The number of items that the caller would like to purchase.
@param _whitelist A whitelist proof for users to submit with their claim to
verify that they are in fact on the whitelist.
*/
function sellWhitelist (
uint256 _amount,
WhitelistProof calldata _whitelist
) private {
// Verify that the caller is on the merkle whitelist.
bool verified = verify(
_whitelist.id,
_whitelist.index,
keccak256(
abi.encodePacked(
_whitelist.index,
_msgSender(),
_whitelist.allowance
)
),
_whitelist.proof
);
// Reject the purchase if the caller is not a valid whitelist member.
if (!verified) { revert CannotVerifyAsWhitelistMember(); }
// Reject the purchase if the caller is exceeding their whitelist allowance.
if (purchaseCounts[_msgSender()] + _amount > _whitelist.allowance) {
revert CannotExceedWhitelistAllowance();
}
// Calculate the sale token and price.
address token = whitelists[_whitelist.id].token;
uint256 whitelistPrice = whitelists[_whitelist.id].price * _amount;
// The zero address indicates that the purchase asset is Ether.
if (token == address(0)) {
if (msg.value != whitelistPrice) {
revert CannotTransferIncorrectAmount();
}
// Otherwise, the caller is making their purchase with an ERC-20 token.
} else {
IERC20(token).safeTransferFrom(
_msgSender(),
address(this),
whitelistPrice
);
}
}
/**
Allow a caller to purchase an item.
@param _amount The amount of items that the caller would like to purchase.
@param _whitelist The caller-subumitted whitelist proof to check if they
belong on a presale whitelist.
*/
function mint (
uint256 _amount,
WhitelistProof calldata _whitelist
) external payable nonReentrant {
// Reject purchases for no items.
if (_amount < 1) { revert CannotBuyZeroItems(); }
/*
Reject purchases that happen after the end of the public sale. Do note
that this means that whitelist sales with an ending duration _after_ the
end of the public sale are ignored completely. In other words: the ending
time of the public sale takes precedent over the ending time of a
whitelisted presale. A whitelisted presale may not continue selling items
after the public sale has ended.
*/
if (block.timestamp >= endTime) { revert CannotBuyFromEndedSale(); }
// Reject purchases that exceed the per-transaction cap.
if (_amount > transactionCap) {
revert CannotExceedPerTransactionCap();
}
// Reject purchases that exceed the per-caller cap.
if (purchaseCounts[_msgSender()] + _amount > callerCap) {
revert CannotExceedPerCallerCap();
}
// Reject purchases that exceed the total sale cap.
if (sold + _amount > totalCap) { revert CannotExceedTotalCap(); }
/*
If the current timestamp is greater than this contract's `startTime`, the
public sale has begun and all users will be directed to the public sale
functionality.
*/
if (block.timestamp >= startTime) {
sellPublic(_amount);
/*
Otherwise, since the public sale has not begun, attempt to sell to this
user as a member of the presale whitelist.
*/
} else {
sellWhitelist(_amount, _whitelist);
}
// Update the count of items sold.
sold += _amount;
// Update the caller's purchase count.
purchaseCounts[_msgSender()] += _amount;
// Mint the items.
ITiny721(collection).mint_Qgo(_msgSender(), _amount);
}
/**
Allow the owner to sweep either Ether or a particular ERC-20 token from the
contract and send it to another address. This allows the owner of the shop
to withdraw their funds after the sale is completed.
@param _token The token to sweep the balance from; if a zero address is sent
then the contract's balance of Ether will be swept.
@param _amount The amount of token to sweep.
@param _destination The address to send the swept tokens to.
*/
function sweep (
address _token,
address _destination,
uint256 _amount
) external onlyOwner nonReentrant {
// A zero address means we should attempt to sweep Ether.
if (_token == address(0)) {
(bool success, ) = payable(_destination).call{ value: _amount }("");
if (!success) { revert SweepingTransferFailed(); }
// Otherwise, we should try to sweep an ERC-20 token.
} else {
IERC20(_token).safeTransfer(_destination, _amount);
}
}
} | /**
@title A contract for selling NFTs via a merkle-based whitelist presale with
conversion into a public sale.
@author Tim Clancy
@author Qazawat Zirak
@author Rostislav Khlebnikov
@author Nikita Elunin
@author 0xthrpw
This contract is a modified version of SuperFarm mint shops optimized for the
specific use case of:
1. selling a single type of ERC-721 item from a single contract
2. running potentially multiple whitelisted presales with potentially
multiple different participants and different prices
3. selling the item for both ETH and an ERC-20 token during the presale
4. converting into a public sale that can sell for ETH only
This launchpad contract sells new items by minting them into existence. It
cannot be used to sell items that already exist.
March 10th, 2022.
*/ | NatSpecMultiLine | sweep | function sweep (
address _token,
address _destination,
uint256 _amount
) external onlyOwner nonReentrant {
// A zero address means we should attempt to sweep Ether.
if (_token == address(0)) {
(bool success, ) = payable(_destination).call{ value: _amount }("");
if (!success) { revert SweepingTransferFailed(); }
// Otherwise, we should try to sweep an ERC-20 token.
} else {
IERC20(_token).safeTransfer(_destination, _amount);
}
}
| /**
Allow the owner to sweep either Ether or a particular ERC-20 token from the
contract and send it to another address. This allows the owner of the shop
to withdraw their funds after the sale is completed.
@param _token The token to sweep the balance from; if a zero address is sent
then the contract's balance of Ether will be swept.
@param _amount The amount of token to sweep.
@param _destination The address to send the swept tokens to.
*/ | NatSpecMultiLine | v0.8.11+commit.d7f03943 | {
"func_code_index": [
12603,
13108
]
} | 4,357 |
||
DELTAToken | contracts/v076/Token/Handlers/post_first_rebasing/OVLTransferHandler.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | OVLTransferHandler | contract OVLTransferHandler is OVLBase, OVLVestingCalculator, IOVLTransferHandler {
using SafeMath for uint256;
using Address for address;
address public immutable UNI_DELTA_WETH_PAIR;
address public immutable DEEP_FARMING_VAULT;
event Transfer(address indexed from, address indexed to, uint256 value);
constructor(address pair, address dfv) {
UNI_DELTA_WETH_PAIR = pair;
DEEP_FARMING_VAULT = dfv;
}
function _removeBalanceFromSender(UserInformation storage senderInfo, address sender, bool immatureReceiverWhitelisted, uint256 amount) internal returns (uint256 totalRemoved) {
uint256 mostMatureTxIndex = senderInfo.mostMatureTxIndex;
uint256 lastInTxIndex = senderInfo.lastInTxIndex;
// We check if recipent can get immature tokens, if so we go from the most imature first to be most fair to the user
if (immatureReceiverWhitelisted) {
//////
////
// we go from the least mature balance to the msot mature meaning --
////
/////
uint256 accumulatedBalance;
while (true) {
uint256 leastMatureTxAmount = vestingTransactions[sender][lastInTxIndex].amount;
// Can never underflow due to if conditional
uint256 remainingBalanceNeeded = amount - accumulatedBalance;
if (leastMatureTxAmount >= remainingBalanceNeeded) {
// We got enough in this bucket to cover the amount
// We remove it from total and dont adjust the fully vesting timestamp
// Because there might be tokens left still in it
totalRemoved += remainingBalanceNeeded;
vestingTransactions[sender][lastInTxIndex].amount = leastMatureTxAmount - remainingBalanceNeeded; // safe math already checked
// We got what we wanted we leave the loop
break;
} else {
//we add the whole amount of this bucket to the accumulated balance
accumulatedBalance = accumulatedBalance.add(leastMatureTxAmount);
totalRemoved += leastMatureTxAmount;
delete vestingTransactions[sender][lastInTxIndex];
// And go to the more mature tx
if (lastInTxIndex == 0) {
lastInTxIndex = QTY_EPOCHS;
}
lastInTxIndex--;
// If we can't get enough in this tx and this is the last one, then we bail
if (lastInTxIndex == mostMatureTxIndex) {
// If we still have enough to cover in the mature balance we use that
uint256 maturedBalanceNeeded = amount - accumulatedBalance;
// Exhaustive underflow check
senderInfo.maturedBalance = senderInfo.maturedBalance.sub(maturedBalanceNeeded, "OVLTransferHandler: Insufficient funds");
totalRemoved += maturedBalanceNeeded;
break;
}
}
}
// We write to storage the lastTx Index, which was in memory and we looped over it (or not)
senderInfo.lastInTxIndex = lastInTxIndex;
return totalRemoved;
// End of logic in case reciever is whitelisted ( return assures)
}
uint256 maturedBalance = senderInfo.maturedBalance;
//////
////
// we go from the most mature balance up
////
/////
if (maturedBalance >= amount) {
senderInfo.maturedBalance = maturedBalance - amount; // safemath safe
totalRemoved = amount;
} else {
// Possibly using a partially vested transaction
uint256 accumulatedBalance = maturedBalance;
totalRemoved = maturedBalance;
// Use the entire balance to start
senderInfo.maturedBalance = 0;
while (amount > accumulatedBalance) {
VestingTransaction memory mostMatureTx = vestingTransactions[sender][mostMatureTxIndex];
// Guaranteed by `while` condition
uint256 remainingBalanceNeeded = amount - accumulatedBalance;
// Reduce this transaction as the final one
VestingTransactionDetailed memory dtx = getTransactionDetails(mostMatureTx, block.timestamp);
// credit is how much i got from this bucket
// So if i didnt get enough from this bucket here we zero it and move to the next one
if (remainingBalanceNeeded >= dtx.mature) {
totalRemoved += dtx.amount;
accumulatedBalance = accumulatedBalance.add(dtx.mature);
delete vestingTransactions[sender][mostMatureTxIndex]; // refund gas
} else {
// Remove the only needed amount
// Calculating debt based on the actual clamped credit eliminates
// the need for debit/credit ratio checks we initially had.
// Big gas savings using this one weird trick. Vitalik HATES it.
uint256 outputDebit = calculateTransactionDebit(dtx, remainingBalanceNeeded, block.timestamp);
remainingBalanceNeeded = outputDebit.add(remainingBalanceNeeded);
totalRemoved += remainingBalanceNeeded;
// We dont need to adjust timestamp
vestingTransactions[sender][mostMatureTxIndex].amount = mostMatureTx.amount.sub(remainingBalanceNeeded, "Removing too much from bucket");
break;
}
// If we just went throught he lasttx bucket, and we did not get enough then we bail
// Note if its the lastTransaction it already had a break;
if (mostMatureTxIndex == lastInTxIndex && accumulatedBalance < amount) { // accumulatedBalance < amount because of the case its exactly equal with first if
// Avoid ever looping around a second time because that would be bad
revert("OVLTransferHandler: Insufficient funds");
}
// We just emptied this so most mature one must be the next one
mostMatureTxIndex++;
if(mostMatureTxIndex == QTY_EPOCHS) {
mostMatureTxIndex = 0;
}
}
// We remove the entire amount removed
// We already added amount
senderInfo.mostMatureTxIndex = mostMatureTxIndex;
}
}
// function _transferTokensToRecipient(address recipient, UserInformation memory senderInfo, UserInformation memory recipientInfo, uint256 amount) internal {
function _transferTokensToRecipient(UserInformation storage recipientInfo, bool isSenderWhitelisted, address recipient, uint256 amount) internal {
// If the sender can send fully or this recipent is whitelisted to not get vesting we just add it to matured balance
(bool noVestingWhitelisted, uint256 maturedBalance, uint256 lastTransactionIndex) = (recipientInfo.noVestingWhitelisted, recipientInfo.maturedBalance, recipientInfo.lastInTxIndex);
if(isSenderWhitelisted || noVestingWhitelisted) {
recipientInfo.maturedBalance = maturedBalance.add(amount);
return;
}
VestingTransaction storage lastTransaction = vestingTransactions[recipient][lastTransactionIndex];
// Do i fit in this bucket?
// conditions for fitting inside a bucket are
// 1 ) Either its less than 2 days old
// 2 ) Or its more than 14 days old
// 3 ) Or we move to the next one - which is empty or already matured
// Note that only the first bucket checked can logically be less than 2 days old, this is a important optimization
// So lets take care of that case now, so its not checked in the loop.
uint256 timestampNow = block.timestamp;
uint256 fullVestingTimestamp = lastTransaction.fullVestingTimestamp;
if (timestampNow >= fullVestingTimestamp) {// Its mature we move it to mature and override or we move to the next one, which is always either 0 or matured
recipientInfo.maturedBalance = maturedBalance.add(lastTransaction.amount);
lastTransaction.amount = amount;
lastTransaction.fullVestingTimestamp = timestampNow + FULL_EPOCH_TIME;
} else if (fullVestingTimestamp >= timestampNow + SECONDS_PER_EPOCH * (QTY_EPOCHS - 1)) {// we add 12 days
// we avoid overflows from 0 fullyvestedtimestamp
// if fullyVestingTimestamp is bigger than that we should increment
// but not bigger than fullyVesting
// This check is exhaustive
// If this is the case we just put it in this bucket.
lastTransaction.amount = lastTransaction.amount.add(amount);
/// No need to adjust timestamp`
} else {
// We move into the next one
lastTransactionIndex++;
if (lastTransactionIndex == QTY_EPOCHS) { lastTransactionIndex = 0; } // Loop over
recipientInfo.lastInTxIndex = lastTransactionIndex;
// To figure out if this is a empty bucket or a stale one
// Its either the most mature one
// Or its 0
// There is no other logical options
// If this is the most mature one then we go > with most mature
uint256 mostMature = recipientInfo.mostMatureTxIndex;
if (mostMature == lastTransactionIndex) {
// It was the most mature one, so we have to increment the most mature index
mostMature++;
if (mostMature == QTY_EPOCHS) { mostMature = 0; }
recipientInfo.mostMatureTxIndex = mostMature;
}
VestingTransaction storage evenLatestTransaction = vestingTransactions[recipient][lastTransactionIndex];
// Its mature we move it to mature and override or we move to the next one, which is always either 0 or matured
recipientInfo.maturedBalance = maturedBalance.add(evenLatestTransaction.amount);
evenLatestTransaction.amount = amount;
evenLatestTransaction.fullVestingTimestamp = timestampNow + FULL_EPOCH_TIME;
}
}
function addAllowanceToDFV(address sender) internal {
// If you transferFrom from anyone even 1 gwei unit
// This will force dfv to have infinite allowance
// But this is not abug because DFV has defacto infinite allowance becaose of this function
// So there is no change
_allowances[sender][DEEP_FARMING_VAULT] = uint(-1);
}
function handleUniswapAdjustmenets() internal{
uint256 newLPSupply = IERC20(UNI_DELTA_WETH_PAIR).balanceOf(UNI_DELTA_WETH_PAIR);
require(newLPSupply >= lpTokensInPair, "DELTAToken: Liquidity removals are forbidden");
// We allow people to bump the number of LP tokens inside the pair, but we dont allow them to go lower
// Making liquidity withdrawals impossible
// Because uniswap queries banaceOf before doing a burn, that means we can detect a inflow of LP tokens
// But someone could send them and then reset with this function
// This is why we "lock" the bigger amount here and dont allow a lower amount than the last time
// Making it impossible to anyone who sent the liquidity tokens to the pair (which is nessesary to burn) not be able to burn them
lpTokensInPair = newLPSupply;
}
// This function does not need authentication, because this is EXCLUSIVELY
// ever meant to be called using delegatecall() from the main token.
// The memory it modifies in DELTAToken is what effects user balances.
function handleTransfer(address sender, address recipient, uint256 amount) external override {
require(sender != recipient, "DELTAToken: Can not send DELTA to yourself");
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
/// Liquidity removal protection
if (!liquidityRebasingPermitted && (sender == UNI_DELTA_WETH_PAIR || recipient == UNI_DELTA_WETH_PAIR)) {
handleUniswapAdjustmenets();
}
if(recipient == DEEP_FARMING_VAULT) {
addAllowanceToDFV(sender);
}
UserInformation storage recipientInfo = _userInformation[recipient];
UserInformation storage senderInfo = _userInformation[sender];
uint256 totalRemoved = _removeBalanceFromSender(senderInfo, sender, recipientInfo.immatureReceiverWhitelisted, amount);
uint256 toDistributor = totalRemoved.sub(amount, "OVLTransferHandler: Insufficient funds");
// We remove from max balance totals
senderInfo.maxBalance = senderInfo.maxBalance.sub(totalRemoved, "OVLTransferHandler: Insufficient funds");
// Sanity check
require(totalRemoved >= amount, "OVLTransferHandler: Insufficient funds");
// Max is 90% of total removed
require(amount.mul(9) >= toDistributor, "DELTAToken: Burned too many tokens");
_creditDistributor(sender, toDistributor);
//////
/// We add tokens to the recipient
//////
_transferTokensToRecipient(recipientInfo, senderInfo.fullSenderWhitelisted, recipient, amount);
// We add to total balance for sanity checks and uniswap router
recipientInfo.maxBalance = recipientInfo.maxBalance.add(amount);
emit Transfer(sender, recipient, amount);
}
function _creditDistributor(address creditedBy, uint256 amount) internal {
address _distributor = distributor; // gas savings for storage reads
UserInformation storage distributorInfo = _userInformation[distributor];
distributorInfo.maturedBalance = distributorInfo.maturedBalance.add(amount); // Should trigger an event here
distributorInfo.maxBalance = distributorInfo.maxBalance.add(amount);
IDeltaDistributor(_distributor).creditUser(creditedBy, amount);
emit Transfer(creditedBy, _distributor, amount);
}
} | _transferTokensToRecipient | function _transferTokensToRecipient(UserInformation storage recipientInfo, bool isSenderWhitelisted, address recipient, uint256 amount) internal {
// If the sender can send fully or this recipent is whitelisted to not get vesting we just add it to matured balance
(bool noVestingWhitelisted, uint256 maturedBalance, uint256 lastTransactionIndex) = (recipientInfo.noVestingWhitelisted, recipientInfo.maturedBalance, recipientInfo.lastInTxIndex);
if(isSenderWhitelisted || noVestingWhitelisted) {
recipientInfo.maturedBalance = maturedBalance.add(amount);
return;
}
VestingTransaction storage lastTransaction = vestingTransactions[recipient][lastTransactionIndex];
// Do i fit in this bucket?
// conditions for fitting inside a bucket are
// 1 ) Either its less than 2 days old
// 2 ) Or its more than 14 days old
// 3 ) Or we move to the next one - which is empty or already matured
// Note that only the first bucket checked can logically be less than 2 days old, this is a important optimization
// So lets take care of that case now, so its not checked in the loop.
uint256 timestampNow = block.timestamp;
uint256 fullVestingTimestamp = lastTransaction.fullVestingTimestamp;
if (timestampNow >= fullVestingTimestamp) {// Its mature we move it to mature and override or we move to the next one, which is always either 0 or matured
recipientInfo.maturedBalance = maturedBalance.add(lastTransaction.amount);
lastTransaction.amount = amount;
lastTransaction.fullVestingTimestamp = timestampNow + FULL_EPOCH_TIME;
} else if (fullVestingTimestamp >= timestampNow + SECONDS_PER_EPOCH * (QTY_EPOCHS - 1)) {// we add 12 days
// we avoid overflows from 0 fullyvestedtimestamp
// if fullyVestingTimestamp is bigger than that we should increment
// but not bigger than fullyVesting
// This check is exhaustive
// If this is the case we just put it in this bucket.
lastTransaction.amount = lastTransaction.amount.add(amount);
/// No need to adjust timestamp`
} else {
// We move into the next one
lastTransactionIndex++;
if (lastTransactionIndex == QTY_EPOCHS) { lastTransactionIndex = 0; } // Loop over
recipientInfo.lastInTxIndex = lastTransactionIndex;
// To figure out if this is a empty bucket or a stale one
// Its either the most mature one
// Or its 0
// There is no other logical options
// If this is the most mature one then we go > with most mature
uint256 mostMature = recipientInfo.mostMatureTxIndex;
if (mostMature == lastTransactionIndex) {
// It was the most mature one, so we have to increment the most mature index
mostMature++;
if (mostMature == QTY_EPOCHS) { mostMature = 0; }
recipientInfo.mostMatureTxIndex = mostMature;
}
VestingTransaction storage evenLatestTransaction = vestingTransactions[recipient][lastTransactionIndex];
// Its mature we move it to mature and override or we move to the next one, which is always either 0 or matured
recipientInfo.maturedBalance = maturedBalance.add(evenLatestTransaction.amount);
evenLatestTransaction.amount = amount;
evenLatestTransaction.fullVestingTimestamp = timestampNow + FULL_EPOCH_TIME;
}
}
| // function _transferTokensToRecipient(address recipient, UserInformation memory senderInfo, UserInformation memory recipientInfo, uint256 amount) internal { | LineComment | v0.7.6+commit.7338295f | {
"func_code_index": [
6967,
10616
]
} | 4,358 |
||||
DELTAToken | contracts/v076/Token/Handlers/post_first_rebasing/OVLTransferHandler.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | OVLTransferHandler | contract OVLTransferHandler is OVLBase, OVLVestingCalculator, IOVLTransferHandler {
using SafeMath for uint256;
using Address for address;
address public immutable UNI_DELTA_WETH_PAIR;
address public immutable DEEP_FARMING_VAULT;
event Transfer(address indexed from, address indexed to, uint256 value);
constructor(address pair, address dfv) {
UNI_DELTA_WETH_PAIR = pair;
DEEP_FARMING_VAULT = dfv;
}
function _removeBalanceFromSender(UserInformation storage senderInfo, address sender, bool immatureReceiverWhitelisted, uint256 amount) internal returns (uint256 totalRemoved) {
uint256 mostMatureTxIndex = senderInfo.mostMatureTxIndex;
uint256 lastInTxIndex = senderInfo.lastInTxIndex;
// We check if recipent can get immature tokens, if so we go from the most imature first to be most fair to the user
if (immatureReceiverWhitelisted) {
//////
////
// we go from the least mature balance to the msot mature meaning --
////
/////
uint256 accumulatedBalance;
while (true) {
uint256 leastMatureTxAmount = vestingTransactions[sender][lastInTxIndex].amount;
// Can never underflow due to if conditional
uint256 remainingBalanceNeeded = amount - accumulatedBalance;
if (leastMatureTxAmount >= remainingBalanceNeeded) {
// We got enough in this bucket to cover the amount
// We remove it from total and dont adjust the fully vesting timestamp
// Because there might be tokens left still in it
totalRemoved += remainingBalanceNeeded;
vestingTransactions[sender][lastInTxIndex].amount = leastMatureTxAmount - remainingBalanceNeeded; // safe math already checked
// We got what we wanted we leave the loop
break;
} else {
//we add the whole amount of this bucket to the accumulated balance
accumulatedBalance = accumulatedBalance.add(leastMatureTxAmount);
totalRemoved += leastMatureTxAmount;
delete vestingTransactions[sender][lastInTxIndex];
// And go to the more mature tx
if (lastInTxIndex == 0) {
lastInTxIndex = QTY_EPOCHS;
}
lastInTxIndex--;
// If we can't get enough in this tx and this is the last one, then we bail
if (lastInTxIndex == mostMatureTxIndex) {
// If we still have enough to cover in the mature balance we use that
uint256 maturedBalanceNeeded = amount - accumulatedBalance;
// Exhaustive underflow check
senderInfo.maturedBalance = senderInfo.maturedBalance.sub(maturedBalanceNeeded, "OVLTransferHandler: Insufficient funds");
totalRemoved += maturedBalanceNeeded;
break;
}
}
}
// We write to storage the lastTx Index, which was in memory and we looped over it (or not)
senderInfo.lastInTxIndex = lastInTxIndex;
return totalRemoved;
// End of logic in case reciever is whitelisted ( return assures)
}
uint256 maturedBalance = senderInfo.maturedBalance;
//////
////
// we go from the most mature balance up
////
/////
if (maturedBalance >= amount) {
senderInfo.maturedBalance = maturedBalance - amount; // safemath safe
totalRemoved = amount;
} else {
// Possibly using a partially vested transaction
uint256 accumulatedBalance = maturedBalance;
totalRemoved = maturedBalance;
// Use the entire balance to start
senderInfo.maturedBalance = 0;
while (amount > accumulatedBalance) {
VestingTransaction memory mostMatureTx = vestingTransactions[sender][mostMatureTxIndex];
// Guaranteed by `while` condition
uint256 remainingBalanceNeeded = amount - accumulatedBalance;
// Reduce this transaction as the final one
VestingTransactionDetailed memory dtx = getTransactionDetails(mostMatureTx, block.timestamp);
// credit is how much i got from this bucket
// So if i didnt get enough from this bucket here we zero it and move to the next one
if (remainingBalanceNeeded >= dtx.mature) {
totalRemoved += dtx.amount;
accumulatedBalance = accumulatedBalance.add(dtx.mature);
delete vestingTransactions[sender][mostMatureTxIndex]; // refund gas
} else {
// Remove the only needed amount
// Calculating debt based on the actual clamped credit eliminates
// the need for debit/credit ratio checks we initially had.
// Big gas savings using this one weird trick. Vitalik HATES it.
uint256 outputDebit = calculateTransactionDebit(dtx, remainingBalanceNeeded, block.timestamp);
remainingBalanceNeeded = outputDebit.add(remainingBalanceNeeded);
totalRemoved += remainingBalanceNeeded;
// We dont need to adjust timestamp
vestingTransactions[sender][mostMatureTxIndex].amount = mostMatureTx.amount.sub(remainingBalanceNeeded, "Removing too much from bucket");
break;
}
// If we just went throught he lasttx bucket, and we did not get enough then we bail
// Note if its the lastTransaction it already had a break;
if (mostMatureTxIndex == lastInTxIndex && accumulatedBalance < amount) { // accumulatedBalance < amount because of the case its exactly equal with first if
// Avoid ever looping around a second time because that would be bad
revert("OVLTransferHandler: Insufficient funds");
}
// We just emptied this so most mature one must be the next one
mostMatureTxIndex++;
if(mostMatureTxIndex == QTY_EPOCHS) {
mostMatureTxIndex = 0;
}
}
// We remove the entire amount removed
// We already added amount
senderInfo.mostMatureTxIndex = mostMatureTxIndex;
}
}
// function _transferTokensToRecipient(address recipient, UserInformation memory senderInfo, UserInformation memory recipientInfo, uint256 amount) internal {
function _transferTokensToRecipient(UserInformation storage recipientInfo, bool isSenderWhitelisted, address recipient, uint256 amount) internal {
// If the sender can send fully or this recipent is whitelisted to not get vesting we just add it to matured balance
(bool noVestingWhitelisted, uint256 maturedBalance, uint256 lastTransactionIndex) = (recipientInfo.noVestingWhitelisted, recipientInfo.maturedBalance, recipientInfo.lastInTxIndex);
if(isSenderWhitelisted || noVestingWhitelisted) {
recipientInfo.maturedBalance = maturedBalance.add(amount);
return;
}
VestingTransaction storage lastTransaction = vestingTransactions[recipient][lastTransactionIndex];
// Do i fit in this bucket?
// conditions for fitting inside a bucket are
// 1 ) Either its less than 2 days old
// 2 ) Or its more than 14 days old
// 3 ) Or we move to the next one - which is empty or already matured
// Note that only the first bucket checked can logically be less than 2 days old, this is a important optimization
// So lets take care of that case now, so its not checked in the loop.
uint256 timestampNow = block.timestamp;
uint256 fullVestingTimestamp = lastTransaction.fullVestingTimestamp;
if (timestampNow >= fullVestingTimestamp) {// Its mature we move it to mature and override or we move to the next one, which is always either 0 or matured
recipientInfo.maturedBalance = maturedBalance.add(lastTransaction.amount);
lastTransaction.amount = amount;
lastTransaction.fullVestingTimestamp = timestampNow + FULL_EPOCH_TIME;
} else if (fullVestingTimestamp >= timestampNow + SECONDS_PER_EPOCH * (QTY_EPOCHS - 1)) {// we add 12 days
// we avoid overflows from 0 fullyvestedtimestamp
// if fullyVestingTimestamp is bigger than that we should increment
// but not bigger than fullyVesting
// This check is exhaustive
// If this is the case we just put it in this bucket.
lastTransaction.amount = lastTransaction.amount.add(amount);
/// No need to adjust timestamp`
} else {
// We move into the next one
lastTransactionIndex++;
if (lastTransactionIndex == QTY_EPOCHS) { lastTransactionIndex = 0; } // Loop over
recipientInfo.lastInTxIndex = lastTransactionIndex;
// To figure out if this is a empty bucket or a stale one
// Its either the most mature one
// Or its 0
// There is no other logical options
// If this is the most mature one then we go > with most mature
uint256 mostMature = recipientInfo.mostMatureTxIndex;
if (mostMature == lastTransactionIndex) {
// It was the most mature one, so we have to increment the most mature index
mostMature++;
if (mostMature == QTY_EPOCHS) { mostMature = 0; }
recipientInfo.mostMatureTxIndex = mostMature;
}
VestingTransaction storage evenLatestTransaction = vestingTransactions[recipient][lastTransactionIndex];
// Its mature we move it to mature and override or we move to the next one, which is always either 0 or matured
recipientInfo.maturedBalance = maturedBalance.add(evenLatestTransaction.amount);
evenLatestTransaction.amount = amount;
evenLatestTransaction.fullVestingTimestamp = timestampNow + FULL_EPOCH_TIME;
}
}
function addAllowanceToDFV(address sender) internal {
// If you transferFrom from anyone even 1 gwei unit
// This will force dfv to have infinite allowance
// But this is not abug because DFV has defacto infinite allowance becaose of this function
// So there is no change
_allowances[sender][DEEP_FARMING_VAULT] = uint(-1);
}
function handleUniswapAdjustmenets() internal{
uint256 newLPSupply = IERC20(UNI_DELTA_WETH_PAIR).balanceOf(UNI_DELTA_WETH_PAIR);
require(newLPSupply >= lpTokensInPair, "DELTAToken: Liquidity removals are forbidden");
// We allow people to bump the number of LP tokens inside the pair, but we dont allow them to go lower
// Making liquidity withdrawals impossible
// Because uniswap queries banaceOf before doing a burn, that means we can detect a inflow of LP tokens
// But someone could send them and then reset with this function
// This is why we "lock" the bigger amount here and dont allow a lower amount than the last time
// Making it impossible to anyone who sent the liquidity tokens to the pair (which is nessesary to burn) not be able to burn them
lpTokensInPair = newLPSupply;
}
// This function does not need authentication, because this is EXCLUSIVELY
// ever meant to be called using delegatecall() from the main token.
// The memory it modifies in DELTAToken is what effects user balances.
function handleTransfer(address sender, address recipient, uint256 amount) external override {
require(sender != recipient, "DELTAToken: Can not send DELTA to yourself");
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
/// Liquidity removal protection
if (!liquidityRebasingPermitted && (sender == UNI_DELTA_WETH_PAIR || recipient == UNI_DELTA_WETH_PAIR)) {
handleUniswapAdjustmenets();
}
if(recipient == DEEP_FARMING_VAULT) {
addAllowanceToDFV(sender);
}
UserInformation storage recipientInfo = _userInformation[recipient];
UserInformation storage senderInfo = _userInformation[sender];
uint256 totalRemoved = _removeBalanceFromSender(senderInfo, sender, recipientInfo.immatureReceiverWhitelisted, amount);
uint256 toDistributor = totalRemoved.sub(amount, "OVLTransferHandler: Insufficient funds");
// We remove from max balance totals
senderInfo.maxBalance = senderInfo.maxBalance.sub(totalRemoved, "OVLTransferHandler: Insufficient funds");
// Sanity check
require(totalRemoved >= amount, "OVLTransferHandler: Insufficient funds");
// Max is 90% of total removed
require(amount.mul(9) >= toDistributor, "DELTAToken: Burned too many tokens");
_creditDistributor(sender, toDistributor);
//////
/// We add tokens to the recipient
//////
_transferTokensToRecipient(recipientInfo, senderInfo.fullSenderWhitelisted, recipient, amount);
// We add to total balance for sanity checks and uniswap router
recipientInfo.maxBalance = recipientInfo.maxBalance.add(amount);
emit Transfer(sender, recipient, amount);
}
function _creditDistributor(address creditedBy, uint256 amount) internal {
address _distributor = distributor; // gas savings for storage reads
UserInformation storage distributorInfo = _userInformation[distributor];
distributorInfo.maturedBalance = distributorInfo.maturedBalance.add(amount); // Should trigger an event here
distributorInfo.maxBalance = distributorInfo.maxBalance.add(amount);
IDeltaDistributor(_distributor).creditUser(creditedBy, amount);
emit Transfer(creditedBy, _distributor, amount);
}
} | handleTransfer | function handleTransfer(address sender, address recipient, uint256 amount) external override {
require(sender != recipient, "DELTAToken: Can not send DELTA to yourself");
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
/// Liquidity removal protection
if (!liquidityRebasingPermitted && (sender == UNI_DELTA_WETH_PAIR || recipient == UNI_DELTA_WETH_PAIR)) {
handleUniswapAdjustmenets();
}
if(recipient == DEEP_FARMING_VAULT) {
addAllowanceToDFV(sender);
}
UserInformation storage recipientInfo = _userInformation[recipient];
UserInformation storage senderInfo = _userInformation[sender];
uint256 totalRemoved = _removeBalanceFromSender(senderInfo, sender, recipientInfo.immatureReceiverWhitelisted, amount);
uint256 toDistributor = totalRemoved.sub(amount, "OVLTransferHandler: Insufficient funds");
// We remove from max balance totals
senderInfo.maxBalance = senderInfo.maxBalance.sub(totalRemoved, "OVLTransferHandler: Insufficient funds");
// Sanity check
require(totalRemoved >= amount, "OVLTransferHandler: Insufficient funds");
// Max is 90% of total removed
require(amount.mul(9) >= toDistributor, "DELTAToken: Burned too many tokens");
_creditDistributor(sender, toDistributor);
//////
/// We add tokens to the recipient
//////
_transferTokensToRecipient(recipientInfo, senderInfo.fullSenderWhitelisted, recipient, amount);
// We add to total balance for sanity checks and uniswap router
recipientInfo.maxBalance = recipientInfo.maxBalance.add(amount);
emit Transfer(sender, recipient, amount);
}
| // This function does not need authentication, because this is EXCLUSIVELY
// ever meant to be called using delegatecall() from the main token.
// The memory it modifies in DELTAToken is what effects user balances. | LineComment | v0.7.6+commit.7338295f | {
"func_code_index": [
12096,
14071
]
} | 4,359 |
||||
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | ERC20 | contract ERC20 {
uint256 public totalSupply;
// ERC223 and ERC20 functions and events
function totalSupply() constant public returns (uint256 _supply);
function balanceOf(address who) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool ok);
function name() constant public returns (string _name);
function symbol() constant public returns (string _symbol);
function decimals() constant public returns (uint8 _decimals);
// ERC20 Event
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event FrozenFunds(address target, bool frozen);
event Burn(address indexed from, uint256 value);
} | /// ERC20 contract interface With ERC23/ERC223 Extensions | NatSpecSingleLine | totalSupply | function totalSupply() constant public returns (uint256 _supply);
| // ERC223 and ERC20 functions and events | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
99,
169
]
} | 4,360 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | TokenRK70Z | function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
me = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
Date Deploy Contract
teCreateToken = now;
}
| // Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification) | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
565,
1216
]
} | 4,361 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | DateCreateToken | function DateCreateToken() public view returns (uint256 _DateCreateToken) {
turn DateCreateToken;
| // Function to create date token. | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
1344,
1455
]
} | 4,362 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | name | function name() view public returns (string _name) {
turn name;
| // Function to access name of token . | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
1505,
1582
]
} | 4,363 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | symbol | function symbol() public view returns (string _symbol) {
turn symbol;
}
| // Function to access symbol of token . | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
1631,
1717
]
} | 4,364 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | decimals | function decimals() public view returns (uint8 _decimals) {
turn decimals;
}
| // Function to access decimals of token . | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
1767,
1859
]
} | 4,365 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | totalSupply | function totalSupply() public view returns (uint256 _totalSupply) {
turn totalSupply;
| // Function to access total supply of tokens . | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
1914,
2013
]
} | 4,366 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | balanceOf | function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
| // Get balance of the address provided | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
2058,
2182
]
} | 4,367 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | SmartContract_Allowed | function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
| // Get Smart Contract of the address approved | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
2233,
2393
]
} | 4,368 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | transfer | function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
quire(!frozenAccount[msg.sender]);
quire(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
| // Added due to backwards compatibility reasons . | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
2451,
2944
]
} | 4,369 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | isContract | function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
| // assemble the given address bytecode. If bytecode exists then the _addr is a contract. | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
3038,
3335
]
} | 4,370 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | transferToAddress | function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| // function that is called when transaction target is an address | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
3408,
3764
]
} | 4,371 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | transferToContract | function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
(balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| // function that is called when transaction target is a contract | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
3837,
4238
]
} | 4,372 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | function () public payable {
(msg.sender != owner) { revert(); }
}
| // Function to activate Ether reception in the smart Contract address only by the Owner | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
4331,
4413
]
} | 4,373 |
||
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | OWN_contractlocked | function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
| // Creator/Owner can Locked/Unlock smart contract | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
4468,
4570
]
} | 4,374 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | OWN_burnToken | function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
| // Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back) | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
4688,
4966
]
} | 4,375 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | OWN_mintToken | function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
| //Generate other tokens after starting the program | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
5023,
5329
]
} | 4,376 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | OWN_freezeAddress | function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
| // Block / Unlock address handling tokens | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
5377,
5547
]
} | 4,377 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | OWN_kill | function OWN_kill() onlyOwner public {
lfdestruct(owner);
}
| // Function to destroy the smart contract | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
5596,
5672
]
} | 4,378 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | OWN_transferOwnership | function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
| // Function Change Owner | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
5703,
5916
]
} | 4,379 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | OWN_SmartContract_Allowed | function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
function allowed only for smart contract
if (isContract(target)) {
martContract_Allowed[target] = _allowed;
}
| // Smart Contract approved | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
5949,
6178
]
} | 4,380 |
|
TokenRK70Z | TokenRK70Z.sol | 0x13b849156c1e6d0ead6605562ed9268b9ffd1736 | Solidity | TokenRK70Z | contract TokenRK70Z is ERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
bool public SC_locked = false;
bool public tokenCreated = false;
uint public DateCreateToken;
mapping(address => uint256) balances;
mapping(address => bool) public frozenAccount;
mapping(address => bool) public SmartContract_Allowed;
// Initialize
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function TokenRK70Z() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
require(tokenCreated == false);
owner = msg.sender;
name = "RK70Z";
symbol = "RK70Z";
decimals = 5;
totalSupply = 500000000 * 10 ** uint256(decimals);
balances[owner] = totalSupply;
emit Transfer(owner, owner, totalSupply);
tokenCreated = true;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
// Date Deploy Contract
DateCreateToken = now;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to create date token.
function DateCreateToken() public view returns (uint256 _DateCreateToken) {
return DateCreateToken;
}
// Function to access name of token .
function name() view public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() public view returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Get Smart Contract of the address approved
function SmartContract_Allowed(address _target) constant public returns (bool _sc_address_allowed) {
return SmartContract_Allowed[_target];
}
// Added due to backwards compatibility reasons .
function transfer(address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once Locked
require(!SC_locked);
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_to]);
//standard function transfer similar to ERC20 transfer with no _data
if (isContract(_to)) {
return transferToContract(_to, _value);
}
else {
return transferToAddress(_to, _value);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint256 _value) private returns (bool success) {
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint256 _value) private returns (bool success) {
require(SmartContract_Allowed[_to]);
if (balanceOf(msg.sender) < _value) revert();
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
// Function to activate Ether reception in the smart Contract address only by the Owner
function () public payable {
if(msg.sender != owner) { revert(); }
}
// Creator/Owner can Locked/Unlock smart contract
function OWN_contractlocked(bool _locked) onlyOwner public {
SC_locked = _locked;
}
// Destroy tokens amount from another account (Caution!!! the operation is destructive and you can not go back)
function OWN_burnToken(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value);
balances[_from] -= _value;
totalSupply -= _value;
emit Burn(_from, _value);
return true;
}
//Generate other tokens after starting the program
function OWN_mintToken(uint256 mintedAmount) onlyOwner public {
//aggiungo i decimali al valore che imposto
balances[owner] += mintedAmount;
totalSupply += mintedAmount;
emit Transfer(0, this, mintedAmount);
emit Transfer(this, owner, mintedAmount);
}
// Block / Unlock address handling tokens
function OWN_freezeAddress(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
// Function to destroy the smart contract
function OWN_kill() onlyOwner public {
selfdestruct(owner);
}
// Function Change Owner
function OWN_transferOwnership(address newOwner) onlyOwner public {
// function allowed only if the address is not smart contract
if (!isContract(newOwner)) {
owner = newOwner;
}
}
// Smart Contract approved
function OWN_SmartContract_Allowed(address target, bool _allowed) onlyOwner public {
// function allowed only for smart contract
if (isContract(target)) {
SmartContract_Allowed[target] = _allowed;
}
}
// Distribution Token from Admin
function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
} | /// RK70Z is an ERC20 token with ERC223 Extensions | NatSpecSingleLine | OWN_DistributeTokenAdmin_Multi | function OWN_DistributeTokenAdmin_Multi(address[] addresses, uint256 _value, bool freeze) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
//Block / Unlock address handling tokens
frozenAccount[addresses[i]] = freeze;
emit FrozenFunds(addresses[i], freeze);
if (isContract(addresses[i])) {
transferToContract(addresses[i], _value);
}
else {
transferToAddress(addresses[i], _value);
}
}
}
| // Distribution Token from Admin | LineComment | v0.4.24+commit.e67f0147 | bzzr://4482afc8398e59eedfbfb32eae8b0d404bd8f3edbcf9529a021efee3836c77dd | {
"func_code_index": [
6216,
6673
]
} | 4,381 |
|
DELTAToken | contracts/v076/Token/DELTAToken.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | DELTAToken | contract DELTAToken is OVLBase, Context, IERC20 {
using SafeMath for uint256;
using Address for address;
address public governance;
address public tokenTransferHandler;
address public rebasingLPAddress;
address public tokenBalanceHandler;
address public pendingGovernance;
// ERC-20 Variables
string private constant NAME = "DELTA.financial - deep DeFi derivatives";
string private constant SYMBOL = "DELTA";
uint8 private constant DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 45_000_000e18;
// Configuration
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant BURNER = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;
address private constant LSW_ADDRESS = 0xdaFCE5670d3F67da9A3A44FE6bc36992e5E2beaB;
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
// Handler for activation after first rebasing
address private immutable tokenBalanceHandlerMain;
address private immutable tokenTransferHandlerMain;
// Lookup for pair
address immutable public _PAIR_ADDRESS;
constructor (address rebasingLP, address multisig, address dfv) {
require(address(this) < WETH_ADDRESS, "DELTAToken: Invalid Token Address");
require(multisig != address(0));
require(dfv != address(0));
require(rebasingLP != address(0));
// We get the pair address
// token0 is the smaller address
address uniswapPair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainnet uniswap factory
keccak256(abi.encodePacked(address(this), WETH_ADDRESS)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
// We whitelist the pair to have no vesting on reception
governance = msg.sender; // bypass !gov checks
_PAIR_ADDRESS = uniswapPair;
setNoVestingWhitelist(uniswapPair, true);
setNoVestingWhitelist(BURNER, true);
setNoVestingWhitelist(rebasingLP, true);
setNoVestingWhitelist(UNISWAP_V2_ROUTER, true); // We set the router to no vesting so we dont need to check it in the balance handler to return maxbalance.
// Since we return maxbalance of everyone who has no vesting.
setWhitelists(multisig, true, true, true);
// We are not setting dfv here intentionally because we have a check inside the dfv that it has them
// Since DFV needs to be able to set whitelists itself, so it needs to be a part of the modules
setFullSenderWhitelist(LSW_ADDRESS, true); // Nessesary for lsw because it doesnt just send to the pair
governance = multisig;
rebasingLPAddress = rebasingLP;
_provideInitialSupply(LSW_ADDRESS, TOTAL_SUPPLY);
// Set post first rebasing ones now into private variables
address transferHandler = address(new OVLTransferHandler(uniswapPair, dfv));
tokenTransferHandlerMain = transferHandler;
tokenBalanceHandlerMain = address(new OVLBalanceHandler(IOVLTransferHandler(transferHandler), IERC20(uniswapPair)));
//Set pre rebasing ones as main ones
tokenTransferHandler = address(new OVLLPRebasingHandler(uniswapPair));
tokenBalanceHandler = address(new OVLLPRebasingBalanceHandler());
}
function activatePostFirstRebasingState() public isGovernance() {
require(distributor != address(0), "Set the distributor first!");
tokenTransferHandler = tokenTransferHandlerMain;
tokenBalanceHandler = tokenBalanceHandlerMain;
}
function name() public pure returns (string memory) {
return NAME;
}
function symbol() public pure returns (string memory) {
return SYMBOL;
}
function decimals() public pure returns (uint8) {
return DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return TOTAL_SUPPLY - balanceOf(BURNER);
}
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function matureAllTokensOf(UserInformation storage ui, address account) internal {
delete vestingTransactions[account]; // remove all vesting buckets
ui.maturedBalance = ui.maxBalance;
}
function setFullSenderWhitelist(address account, bool canSendToMatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
function setImmatureRecipentWhitelist(address account, bool canRecieveImmatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
}
function setNoVestingWhitelist(address account, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
}
function setWhitelists(address account, bool canSendToMatureBalances, bool canRecieveImmatureBalances, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
// Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after
function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
// Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process
function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
// allow only RLP to call functions that call this function
function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
bytes memory callData = abi.encodeWithSelector(IOVLTransferHandler.handleTransfer.selector, sender, recipient, amount);
(bool success, bytes memory result) = tokenTransferHandler.delegatecall(callData);
if (!success) {
revert(_getRevertMsg(result));
}
}
function balanceOf(address account) public view override returns (uint256) {
return IOVLBalanceHandler(tokenBalanceHandler).handleBalanceCalculations(account, msg.sender);
}
function _provideInitialSupply(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: supplying zero address");
UserInformation storage ui = _userInformation[account];
ui.maturedBalance = ui.maturedBalance.add(amount);
ui.maxBalance = ui.maxBalance.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/// @notice sets a new distributor potentially with new distribution rules
function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
/// @notice initializes the change of governance
function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
function acceptGovernance() public {
require(msg.sender == pendingGovernance);
governance = msg.sender;
setWhitelists(msg.sender, true, true, true);
delete pendingGovernance;
}
/// @notice sets the function that calculates returns from balanceOF
function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
/// @notice sets a contract with new logic for transfer handlers (contract upgrade)
function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return 'Transaction reverted silently';
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
function totalsForWallet(address account) public view returns (WalletTotals memory totals) {
uint256 mature = _userInformation[account].maturedBalance;
uint256 immature;
for(uint256 i = 0; i < QTY_EPOCHS; i++) {
uint256 amount = vestingTransactions[account][i].amount;
uint256 matureTxBalance = IOVLVestingCalculator(tokenBalanceHandler).getMatureBalance(vestingTransactions[account][i], block.timestamp);
mature = mature.add(matureTxBalance);
immature = immature.add(amount.sub(matureTxBalance));
}
totals.mature = mature;
totals.immature = immature;
totals.total = mature.add(immature);
}
// Optimization for Balance Handler
function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
// Optimization for `require` checks
modifier isGovernance() {
_isGovernance();
_;
}
function _isGovernance() private view {
require(msg.sender == governance, "!gov");
}
// Remaining for js tests only before refactor
function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
function userInformation(address user) external view returns (UserInformation memory) {
return _userInformation[user];
}
} | // Implementation of the DELTA token responsible
// for the CORE ecosystem options layer
// guarding unlocked liquidity inside of the ecosystem
// This token is time lock guarded by 90% FoT which disappears after 2 weeks to 0%
// balanceOf will return the spendable amount outside of the fee on transfer. | LineComment | performLiquidityRebasing | function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
| // Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after | LineComment | v0.7.6+commit.7338295f | {
"func_code_index": [
7172,
7688
]
} | 4,382 |
||
DELTAToken | contracts/v076/Token/DELTAToken.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | DELTAToken | contract DELTAToken is OVLBase, Context, IERC20 {
using SafeMath for uint256;
using Address for address;
address public governance;
address public tokenTransferHandler;
address public rebasingLPAddress;
address public tokenBalanceHandler;
address public pendingGovernance;
// ERC-20 Variables
string private constant NAME = "DELTA.financial - deep DeFi derivatives";
string private constant SYMBOL = "DELTA";
uint8 private constant DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 45_000_000e18;
// Configuration
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant BURNER = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;
address private constant LSW_ADDRESS = 0xdaFCE5670d3F67da9A3A44FE6bc36992e5E2beaB;
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
// Handler for activation after first rebasing
address private immutable tokenBalanceHandlerMain;
address private immutable tokenTransferHandlerMain;
// Lookup for pair
address immutable public _PAIR_ADDRESS;
constructor (address rebasingLP, address multisig, address dfv) {
require(address(this) < WETH_ADDRESS, "DELTAToken: Invalid Token Address");
require(multisig != address(0));
require(dfv != address(0));
require(rebasingLP != address(0));
// We get the pair address
// token0 is the smaller address
address uniswapPair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainnet uniswap factory
keccak256(abi.encodePacked(address(this), WETH_ADDRESS)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
// We whitelist the pair to have no vesting on reception
governance = msg.sender; // bypass !gov checks
_PAIR_ADDRESS = uniswapPair;
setNoVestingWhitelist(uniswapPair, true);
setNoVestingWhitelist(BURNER, true);
setNoVestingWhitelist(rebasingLP, true);
setNoVestingWhitelist(UNISWAP_V2_ROUTER, true); // We set the router to no vesting so we dont need to check it in the balance handler to return maxbalance.
// Since we return maxbalance of everyone who has no vesting.
setWhitelists(multisig, true, true, true);
// We are not setting dfv here intentionally because we have a check inside the dfv that it has them
// Since DFV needs to be able to set whitelists itself, so it needs to be a part of the modules
setFullSenderWhitelist(LSW_ADDRESS, true); // Nessesary for lsw because it doesnt just send to the pair
governance = multisig;
rebasingLPAddress = rebasingLP;
_provideInitialSupply(LSW_ADDRESS, TOTAL_SUPPLY);
// Set post first rebasing ones now into private variables
address transferHandler = address(new OVLTransferHandler(uniswapPair, dfv));
tokenTransferHandlerMain = transferHandler;
tokenBalanceHandlerMain = address(new OVLBalanceHandler(IOVLTransferHandler(transferHandler), IERC20(uniswapPair)));
//Set pre rebasing ones as main ones
tokenTransferHandler = address(new OVLLPRebasingHandler(uniswapPair));
tokenBalanceHandler = address(new OVLLPRebasingBalanceHandler());
}
function activatePostFirstRebasingState() public isGovernance() {
require(distributor != address(0), "Set the distributor first!");
tokenTransferHandler = tokenTransferHandlerMain;
tokenBalanceHandler = tokenBalanceHandlerMain;
}
function name() public pure returns (string memory) {
return NAME;
}
function symbol() public pure returns (string memory) {
return SYMBOL;
}
function decimals() public pure returns (uint8) {
return DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return TOTAL_SUPPLY - balanceOf(BURNER);
}
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function matureAllTokensOf(UserInformation storage ui, address account) internal {
delete vestingTransactions[account]; // remove all vesting buckets
ui.maturedBalance = ui.maxBalance;
}
function setFullSenderWhitelist(address account, bool canSendToMatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
function setImmatureRecipentWhitelist(address account, bool canRecieveImmatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
}
function setNoVestingWhitelist(address account, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
}
function setWhitelists(address account, bool canSendToMatureBalances, bool canRecieveImmatureBalances, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
// Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after
function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
// Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process
function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
// allow only RLP to call functions that call this function
function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
bytes memory callData = abi.encodeWithSelector(IOVLTransferHandler.handleTransfer.selector, sender, recipient, amount);
(bool success, bytes memory result) = tokenTransferHandler.delegatecall(callData);
if (!success) {
revert(_getRevertMsg(result));
}
}
function balanceOf(address account) public view override returns (uint256) {
return IOVLBalanceHandler(tokenBalanceHandler).handleBalanceCalculations(account, msg.sender);
}
function _provideInitialSupply(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: supplying zero address");
UserInformation storage ui = _userInformation[account];
ui.maturedBalance = ui.maturedBalance.add(amount);
ui.maxBalance = ui.maxBalance.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/// @notice sets a new distributor potentially with new distribution rules
function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
/// @notice initializes the change of governance
function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
function acceptGovernance() public {
require(msg.sender == pendingGovernance);
governance = msg.sender;
setWhitelists(msg.sender, true, true, true);
delete pendingGovernance;
}
/// @notice sets the function that calculates returns from balanceOF
function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
/// @notice sets a contract with new logic for transfer handlers (contract upgrade)
function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return 'Transaction reverted silently';
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
function totalsForWallet(address account) public view returns (WalletTotals memory totals) {
uint256 mature = _userInformation[account].maturedBalance;
uint256 immature;
for(uint256 i = 0; i < QTY_EPOCHS; i++) {
uint256 amount = vestingTransactions[account][i].amount;
uint256 matureTxBalance = IOVLVestingCalculator(tokenBalanceHandler).getMatureBalance(vestingTransactions[account][i], block.timestamp);
mature = mature.add(matureTxBalance);
immature = immature.add(amount.sub(matureTxBalance));
}
totals.mature = mature;
totals.immature = immature;
totals.total = mature.add(immature);
}
// Optimization for Balance Handler
function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
// Optimization for `require` checks
modifier isGovernance() {
_isGovernance();
_;
}
function _isGovernance() private view {
require(msg.sender == governance, "!gov");
}
// Remaining for js tests only before refactor
function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
function userInformation(address user) external view returns (UserInformation memory) {
return _userInformation[user];
}
} | // Implementation of the DELTA token responsible
// for the CORE ecosystem options layer
// guarding unlocked liquidity inside of the ecosystem
// This token is time lock guarded by 90% FoT which disappears after 2 weeks to 0%
// balanceOf will return the spendable amount outside of the fee on transfer. | LineComment | adjustBalanceOfNoVestingAccount | function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
| // Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process | LineComment | v0.7.6+commit.7338295f | {
"func_code_index": [
7813,
8396
]
} | 4,383 |
||
DELTAToken | contracts/v076/Token/DELTAToken.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | DELTAToken | contract DELTAToken is OVLBase, Context, IERC20 {
using SafeMath for uint256;
using Address for address;
address public governance;
address public tokenTransferHandler;
address public rebasingLPAddress;
address public tokenBalanceHandler;
address public pendingGovernance;
// ERC-20 Variables
string private constant NAME = "DELTA.financial - deep DeFi derivatives";
string private constant SYMBOL = "DELTA";
uint8 private constant DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 45_000_000e18;
// Configuration
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant BURNER = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;
address private constant LSW_ADDRESS = 0xdaFCE5670d3F67da9A3A44FE6bc36992e5E2beaB;
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
// Handler for activation after first rebasing
address private immutable tokenBalanceHandlerMain;
address private immutable tokenTransferHandlerMain;
// Lookup for pair
address immutable public _PAIR_ADDRESS;
constructor (address rebasingLP, address multisig, address dfv) {
require(address(this) < WETH_ADDRESS, "DELTAToken: Invalid Token Address");
require(multisig != address(0));
require(dfv != address(0));
require(rebasingLP != address(0));
// We get the pair address
// token0 is the smaller address
address uniswapPair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainnet uniswap factory
keccak256(abi.encodePacked(address(this), WETH_ADDRESS)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
// We whitelist the pair to have no vesting on reception
governance = msg.sender; // bypass !gov checks
_PAIR_ADDRESS = uniswapPair;
setNoVestingWhitelist(uniswapPair, true);
setNoVestingWhitelist(BURNER, true);
setNoVestingWhitelist(rebasingLP, true);
setNoVestingWhitelist(UNISWAP_V2_ROUTER, true); // We set the router to no vesting so we dont need to check it in the balance handler to return maxbalance.
// Since we return maxbalance of everyone who has no vesting.
setWhitelists(multisig, true, true, true);
// We are not setting dfv here intentionally because we have a check inside the dfv that it has them
// Since DFV needs to be able to set whitelists itself, so it needs to be a part of the modules
setFullSenderWhitelist(LSW_ADDRESS, true); // Nessesary for lsw because it doesnt just send to the pair
governance = multisig;
rebasingLPAddress = rebasingLP;
_provideInitialSupply(LSW_ADDRESS, TOTAL_SUPPLY);
// Set post first rebasing ones now into private variables
address transferHandler = address(new OVLTransferHandler(uniswapPair, dfv));
tokenTransferHandlerMain = transferHandler;
tokenBalanceHandlerMain = address(new OVLBalanceHandler(IOVLTransferHandler(transferHandler), IERC20(uniswapPair)));
//Set pre rebasing ones as main ones
tokenTransferHandler = address(new OVLLPRebasingHandler(uniswapPair));
tokenBalanceHandler = address(new OVLLPRebasingBalanceHandler());
}
function activatePostFirstRebasingState() public isGovernance() {
require(distributor != address(0), "Set the distributor first!");
tokenTransferHandler = tokenTransferHandlerMain;
tokenBalanceHandler = tokenBalanceHandlerMain;
}
function name() public pure returns (string memory) {
return NAME;
}
function symbol() public pure returns (string memory) {
return SYMBOL;
}
function decimals() public pure returns (uint8) {
return DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return TOTAL_SUPPLY - balanceOf(BURNER);
}
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function matureAllTokensOf(UserInformation storage ui, address account) internal {
delete vestingTransactions[account]; // remove all vesting buckets
ui.maturedBalance = ui.maxBalance;
}
function setFullSenderWhitelist(address account, bool canSendToMatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
function setImmatureRecipentWhitelist(address account, bool canRecieveImmatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
}
function setNoVestingWhitelist(address account, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
}
function setWhitelists(address account, bool canSendToMatureBalances, bool canRecieveImmatureBalances, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
// Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after
function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
// Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process
function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
// allow only RLP to call functions that call this function
function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
bytes memory callData = abi.encodeWithSelector(IOVLTransferHandler.handleTransfer.selector, sender, recipient, amount);
(bool success, bytes memory result) = tokenTransferHandler.delegatecall(callData);
if (!success) {
revert(_getRevertMsg(result));
}
}
function balanceOf(address account) public view override returns (uint256) {
return IOVLBalanceHandler(tokenBalanceHandler).handleBalanceCalculations(account, msg.sender);
}
function _provideInitialSupply(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: supplying zero address");
UserInformation storage ui = _userInformation[account];
ui.maturedBalance = ui.maturedBalance.add(amount);
ui.maxBalance = ui.maxBalance.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/// @notice sets a new distributor potentially with new distribution rules
function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
/// @notice initializes the change of governance
function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
function acceptGovernance() public {
require(msg.sender == pendingGovernance);
governance = msg.sender;
setWhitelists(msg.sender, true, true, true);
delete pendingGovernance;
}
/// @notice sets the function that calculates returns from balanceOF
function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
/// @notice sets a contract with new logic for transfer handlers (contract upgrade)
function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return 'Transaction reverted silently';
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
function totalsForWallet(address account) public view returns (WalletTotals memory totals) {
uint256 mature = _userInformation[account].maturedBalance;
uint256 immature;
for(uint256 i = 0; i < QTY_EPOCHS; i++) {
uint256 amount = vestingTransactions[account][i].amount;
uint256 matureTxBalance = IOVLVestingCalculator(tokenBalanceHandler).getMatureBalance(vestingTransactions[account][i], block.timestamp);
mature = mature.add(matureTxBalance);
immature = immature.add(amount.sub(matureTxBalance));
}
totals.mature = mature;
totals.immature = immature;
totals.total = mature.add(immature);
}
// Optimization for Balance Handler
function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
// Optimization for `require` checks
modifier isGovernance() {
_isGovernance();
_;
}
function _isGovernance() private view {
require(msg.sender == governance, "!gov");
}
// Remaining for js tests only before refactor
function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
function userInformation(address user) external view returns (UserInformation memory) {
return _userInformation[user];
}
} | // Implementation of the DELTA token responsible
// for the CORE ecosystem options layer
// guarding unlocked liquidity inside of the ecosystem
// This token is time lock guarded by 90% FoT which disappears after 2 weeks to 0%
// balanceOf will return the spendable amount outside of the fee on transfer. | LineComment | onlyRLP | function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
| // allow only RLP to call functions that call this function | LineComment | v0.7.6+commit.7338295f | {
"func_code_index": [
8462,
8620
]
} | 4,384 |
||
DELTAToken | contracts/v076/Token/DELTAToken.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | DELTAToken | contract DELTAToken is OVLBase, Context, IERC20 {
using SafeMath for uint256;
using Address for address;
address public governance;
address public tokenTransferHandler;
address public rebasingLPAddress;
address public tokenBalanceHandler;
address public pendingGovernance;
// ERC-20 Variables
string private constant NAME = "DELTA.financial - deep DeFi derivatives";
string private constant SYMBOL = "DELTA";
uint8 private constant DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 45_000_000e18;
// Configuration
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant BURNER = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;
address private constant LSW_ADDRESS = 0xdaFCE5670d3F67da9A3A44FE6bc36992e5E2beaB;
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
// Handler for activation after first rebasing
address private immutable tokenBalanceHandlerMain;
address private immutable tokenTransferHandlerMain;
// Lookup for pair
address immutable public _PAIR_ADDRESS;
constructor (address rebasingLP, address multisig, address dfv) {
require(address(this) < WETH_ADDRESS, "DELTAToken: Invalid Token Address");
require(multisig != address(0));
require(dfv != address(0));
require(rebasingLP != address(0));
// We get the pair address
// token0 is the smaller address
address uniswapPair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainnet uniswap factory
keccak256(abi.encodePacked(address(this), WETH_ADDRESS)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
// We whitelist the pair to have no vesting on reception
governance = msg.sender; // bypass !gov checks
_PAIR_ADDRESS = uniswapPair;
setNoVestingWhitelist(uniswapPair, true);
setNoVestingWhitelist(BURNER, true);
setNoVestingWhitelist(rebasingLP, true);
setNoVestingWhitelist(UNISWAP_V2_ROUTER, true); // We set the router to no vesting so we dont need to check it in the balance handler to return maxbalance.
// Since we return maxbalance of everyone who has no vesting.
setWhitelists(multisig, true, true, true);
// We are not setting dfv here intentionally because we have a check inside the dfv that it has them
// Since DFV needs to be able to set whitelists itself, so it needs to be a part of the modules
setFullSenderWhitelist(LSW_ADDRESS, true); // Nessesary for lsw because it doesnt just send to the pair
governance = multisig;
rebasingLPAddress = rebasingLP;
_provideInitialSupply(LSW_ADDRESS, TOTAL_SUPPLY);
// Set post first rebasing ones now into private variables
address transferHandler = address(new OVLTransferHandler(uniswapPair, dfv));
tokenTransferHandlerMain = transferHandler;
tokenBalanceHandlerMain = address(new OVLBalanceHandler(IOVLTransferHandler(transferHandler), IERC20(uniswapPair)));
//Set pre rebasing ones as main ones
tokenTransferHandler = address(new OVLLPRebasingHandler(uniswapPair));
tokenBalanceHandler = address(new OVLLPRebasingBalanceHandler());
}
function activatePostFirstRebasingState() public isGovernance() {
require(distributor != address(0), "Set the distributor first!");
tokenTransferHandler = tokenTransferHandlerMain;
tokenBalanceHandler = tokenBalanceHandlerMain;
}
function name() public pure returns (string memory) {
return NAME;
}
function symbol() public pure returns (string memory) {
return SYMBOL;
}
function decimals() public pure returns (uint8) {
return DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return TOTAL_SUPPLY - balanceOf(BURNER);
}
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function matureAllTokensOf(UserInformation storage ui, address account) internal {
delete vestingTransactions[account]; // remove all vesting buckets
ui.maturedBalance = ui.maxBalance;
}
function setFullSenderWhitelist(address account, bool canSendToMatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
function setImmatureRecipentWhitelist(address account, bool canRecieveImmatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
}
function setNoVestingWhitelist(address account, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
}
function setWhitelists(address account, bool canSendToMatureBalances, bool canRecieveImmatureBalances, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
// Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after
function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
// Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process
function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
// allow only RLP to call functions that call this function
function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
bytes memory callData = abi.encodeWithSelector(IOVLTransferHandler.handleTransfer.selector, sender, recipient, amount);
(bool success, bytes memory result) = tokenTransferHandler.delegatecall(callData);
if (!success) {
revert(_getRevertMsg(result));
}
}
function balanceOf(address account) public view override returns (uint256) {
return IOVLBalanceHandler(tokenBalanceHandler).handleBalanceCalculations(account, msg.sender);
}
function _provideInitialSupply(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: supplying zero address");
UserInformation storage ui = _userInformation[account];
ui.maturedBalance = ui.maturedBalance.add(amount);
ui.maxBalance = ui.maxBalance.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/// @notice sets a new distributor potentially with new distribution rules
function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
/// @notice initializes the change of governance
function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
function acceptGovernance() public {
require(msg.sender == pendingGovernance);
governance = msg.sender;
setWhitelists(msg.sender, true, true, true);
delete pendingGovernance;
}
/// @notice sets the function that calculates returns from balanceOF
function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
/// @notice sets a contract with new logic for transfer handlers (contract upgrade)
function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return 'Transaction reverted silently';
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
function totalsForWallet(address account) public view returns (WalletTotals memory totals) {
uint256 mature = _userInformation[account].maturedBalance;
uint256 immature;
for(uint256 i = 0; i < QTY_EPOCHS; i++) {
uint256 amount = vestingTransactions[account][i].amount;
uint256 matureTxBalance = IOVLVestingCalculator(tokenBalanceHandler).getMatureBalance(vestingTransactions[account][i], block.timestamp);
mature = mature.add(matureTxBalance);
immature = immature.add(amount.sub(matureTxBalance));
}
totals.mature = mature;
totals.immature = immature;
totals.total = mature.add(immature);
}
// Optimization for Balance Handler
function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
// Optimization for `require` checks
modifier isGovernance() {
_isGovernance();
_;
}
function _isGovernance() private view {
require(msg.sender == governance, "!gov");
}
// Remaining for js tests only before refactor
function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
function userInformation(address user) external view returns (UserInformation memory) {
return _userInformation[user];
}
} | // Implementation of the DELTA token responsible
// for the CORE ecosystem options layer
// guarding unlocked liquidity inside of the ecosystem
// This token is time lock guarded by 90% FoT which disappears after 2 weeks to 0%
// balanceOf will return the spendable amount outside of the fee on transfer. | LineComment | setDistributor | function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
| /// @notice sets a new distributor potentially with new distribution rules | NatSpecSingleLine | v0.7.6+commit.7338295f | {
"func_code_index": [
10035,
10214
]
} | 4,385 |
||
DELTAToken | contracts/v076/Token/DELTAToken.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | DELTAToken | contract DELTAToken is OVLBase, Context, IERC20 {
using SafeMath for uint256;
using Address for address;
address public governance;
address public tokenTransferHandler;
address public rebasingLPAddress;
address public tokenBalanceHandler;
address public pendingGovernance;
// ERC-20 Variables
string private constant NAME = "DELTA.financial - deep DeFi derivatives";
string private constant SYMBOL = "DELTA";
uint8 private constant DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 45_000_000e18;
// Configuration
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant BURNER = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;
address private constant LSW_ADDRESS = 0xdaFCE5670d3F67da9A3A44FE6bc36992e5E2beaB;
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
// Handler for activation after first rebasing
address private immutable tokenBalanceHandlerMain;
address private immutable tokenTransferHandlerMain;
// Lookup for pair
address immutable public _PAIR_ADDRESS;
constructor (address rebasingLP, address multisig, address dfv) {
require(address(this) < WETH_ADDRESS, "DELTAToken: Invalid Token Address");
require(multisig != address(0));
require(dfv != address(0));
require(rebasingLP != address(0));
// We get the pair address
// token0 is the smaller address
address uniswapPair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainnet uniswap factory
keccak256(abi.encodePacked(address(this), WETH_ADDRESS)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
// We whitelist the pair to have no vesting on reception
governance = msg.sender; // bypass !gov checks
_PAIR_ADDRESS = uniswapPair;
setNoVestingWhitelist(uniswapPair, true);
setNoVestingWhitelist(BURNER, true);
setNoVestingWhitelist(rebasingLP, true);
setNoVestingWhitelist(UNISWAP_V2_ROUTER, true); // We set the router to no vesting so we dont need to check it in the balance handler to return maxbalance.
// Since we return maxbalance of everyone who has no vesting.
setWhitelists(multisig, true, true, true);
// We are not setting dfv here intentionally because we have a check inside the dfv that it has them
// Since DFV needs to be able to set whitelists itself, so it needs to be a part of the modules
setFullSenderWhitelist(LSW_ADDRESS, true); // Nessesary for lsw because it doesnt just send to the pair
governance = multisig;
rebasingLPAddress = rebasingLP;
_provideInitialSupply(LSW_ADDRESS, TOTAL_SUPPLY);
// Set post first rebasing ones now into private variables
address transferHandler = address(new OVLTransferHandler(uniswapPair, dfv));
tokenTransferHandlerMain = transferHandler;
tokenBalanceHandlerMain = address(new OVLBalanceHandler(IOVLTransferHandler(transferHandler), IERC20(uniswapPair)));
//Set pre rebasing ones as main ones
tokenTransferHandler = address(new OVLLPRebasingHandler(uniswapPair));
tokenBalanceHandler = address(new OVLLPRebasingBalanceHandler());
}
function activatePostFirstRebasingState() public isGovernance() {
require(distributor != address(0), "Set the distributor first!");
tokenTransferHandler = tokenTransferHandlerMain;
tokenBalanceHandler = tokenBalanceHandlerMain;
}
function name() public pure returns (string memory) {
return NAME;
}
function symbol() public pure returns (string memory) {
return SYMBOL;
}
function decimals() public pure returns (uint8) {
return DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return TOTAL_SUPPLY - balanceOf(BURNER);
}
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function matureAllTokensOf(UserInformation storage ui, address account) internal {
delete vestingTransactions[account]; // remove all vesting buckets
ui.maturedBalance = ui.maxBalance;
}
function setFullSenderWhitelist(address account, bool canSendToMatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
function setImmatureRecipentWhitelist(address account, bool canRecieveImmatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
}
function setNoVestingWhitelist(address account, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
}
function setWhitelists(address account, bool canSendToMatureBalances, bool canRecieveImmatureBalances, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
// Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after
function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
// Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process
function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
// allow only RLP to call functions that call this function
function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
bytes memory callData = abi.encodeWithSelector(IOVLTransferHandler.handleTransfer.selector, sender, recipient, amount);
(bool success, bytes memory result) = tokenTransferHandler.delegatecall(callData);
if (!success) {
revert(_getRevertMsg(result));
}
}
function balanceOf(address account) public view override returns (uint256) {
return IOVLBalanceHandler(tokenBalanceHandler).handleBalanceCalculations(account, msg.sender);
}
function _provideInitialSupply(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: supplying zero address");
UserInformation storage ui = _userInformation[account];
ui.maturedBalance = ui.maturedBalance.add(amount);
ui.maxBalance = ui.maxBalance.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/// @notice sets a new distributor potentially with new distribution rules
function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
/// @notice initializes the change of governance
function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
function acceptGovernance() public {
require(msg.sender == pendingGovernance);
governance = msg.sender;
setWhitelists(msg.sender, true, true, true);
delete pendingGovernance;
}
/// @notice sets the function that calculates returns from balanceOF
function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
/// @notice sets a contract with new logic for transfer handlers (contract upgrade)
function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return 'Transaction reverted silently';
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
function totalsForWallet(address account) public view returns (WalletTotals memory totals) {
uint256 mature = _userInformation[account].maturedBalance;
uint256 immature;
for(uint256 i = 0; i < QTY_EPOCHS; i++) {
uint256 amount = vestingTransactions[account][i].amount;
uint256 matureTxBalance = IOVLVestingCalculator(tokenBalanceHandler).getMatureBalance(vestingTransactions[account][i], block.timestamp);
mature = mature.add(matureTxBalance);
immature = immature.add(amount.sub(matureTxBalance));
}
totals.mature = mature;
totals.immature = immature;
totals.total = mature.add(immature);
}
// Optimization for Balance Handler
function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
// Optimization for `require` checks
modifier isGovernance() {
_isGovernance();
_;
}
function _isGovernance() private view {
require(msg.sender == governance, "!gov");
}
// Remaining for js tests only before refactor
function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
function userInformation(address user) external view returns (UserInformation memory) {
return _userInformation[user];
}
} | // Implementation of the DELTA token responsible
// for the CORE ecosystem options layer
// guarding unlocked liquidity inside of the ecosystem
// This token is time lock guarded by 90% FoT which disappears after 2 weeks to 0%
// balanceOf will return the spendable amount outside of the fee on transfer. | LineComment | setPendingGovernance | function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
| /// @notice initializes the change of governance | NatSpecSingleLine | v0.7.6+commit.7338295f | {
"func_code_index": [
10269,
10386
]
} | 4,386 |
||
DELTAToken | contracts/v076/Token/DELTAToken.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | DELTAToken | contract DELTAToken is OVLBase, Context, IERC20 {
using SafeMath for uint256;
using Address for address;
address public governance;
address public tokenTransferHandler;
address public rebasingLPAddress;
address public tokenBalanceHandler;
address public pendingGovernance;
// ERC-20 Variables
string private constant NAME = "DELTA.financial - deep DeFi derivatives";
string private constant SYMBOL = "DELTA";
uint8 private constant DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 45_000_000e18;
// Configuration
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant BURNER = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;
address private constant LSW_ADDRESS = 0xdaFCE5670d3F67da9A3A44FE6bc36992e5E2beaB;
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
// Handler for activation after first rebasing
address private immutable tokenBalanceHandlerMain;
address private immutable tokenTransferHandlerMain;
// Lookup for pair
address immutable public _PAIR_ADDRESS;
constructor (address rebasingLP, address multisig, address dfv) {
require(address(this) < WETH_ADDRESS, "DELTAToken: Invalid Token Address");
require(multisig != address(0));
require(dfv != address(0));
require(rebasingLP != address(0));
// We get the pair address
// token0 is the smaller address
address uniswapPair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainnet uniswap factory
keccak256(abi.encodePacked(address(this), WETH_ADDRESS)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
// We whitelist the pair to have no vesting on reception
governance = msg.sender; // bypass !gov checks
_PAIR_ADDRESS = uniswapPair;
setNoVestingWhitelist(uniswapPair, true);
setNoVestingWhitelist(BURNER, true);
setNoVestingWhitelist(rebasingLP, true);
setNoVestingWhitelist(UNISWAP_V2_ROUTER, true); // We set the router to no vesting so we dont need to check it in the balance handler to return maxbalance.
// Since we return maxbalance of everyone who has no vesting.
setWhitelists(multisig, true, true, true);
// We are not setting dfv here intentionally because we have a check inside the dfv that it has them
// Since DFV needs to be able to set whitelists itself, so it needs to be a part of the modules
setFullSenderWhitelist(LSW_ADDRESS, true); // Nessesary for lsw because it doesnt just send to the pair
governance = multisig;
rebasingLPAddress = rebasingLP;
_provideInitialSupply(LSW_ADDRESS, TOTAL_SUPPLY);
// Set post first rebasing ones now into private variables
address transferHandler = address(new OVLTransferHandler(uniswapPair, dfv));
tokenTransferHandlerMain = transferHandler;
tokenBalanceHandlerMain = address(new OVLBalanceHandler(IOVLTransferHandler(transferHandler), IERC20(uniswapPair)));
//Set pre rebasing ones as main ones
tokenTransferHandler = address(new OVLLPRebasingHandler(uniswapPair));
tokenBalanceHandler = address(new OVLLPRebasingBalanceHandler());
}
function activatePostFirstRebasingState() public isGovernance() {
require(distributor != address(0), "Set the distributor first!");
tokenTransferHandler = tokenTransferHandlerMain;
tokenBalanceHandler = tokenBalanceHandlerMain;
}
function name() public pure returns (string memory) {
return NAME;
}
function symbol() public pure returns (string memory) {
return SYMBOL;
}
function decimals() public pure returns (uint8) {
return DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return TOTAL_SUPPLY - balanceOf(BURNER);
}
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function matureAllTokensOf(UserInformation storage ui, address account) internal {
delete vestingTransactions[account]; // remove all vesting buckets
ui.maturedBalance = ui.maxBalance;
}
function setFullSenderWhitelist(address account, bool canSendToMatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
function setImmatureRecipentWhitelist(address account, bool canRecieveImmatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
}
function setNoVestingWhitelist(address account, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
}
function setWhitelists(address account, bool canSendToMatureBalances, bool canRecieveImmatureBalances, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
// Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after
function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
// Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process
function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
// allow only RLP to call functions that call this function
function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
bytes memory callData = abi.encodeWithSelector(IOVLTransferHandler.handleTransfer.selector, sender, recipient, amount);
(bool success, bytes memory result) = tokenTransferHandler.delegatecall(callData);
if (!success) {
revert(_getRevertMsg(result));
}
}
function balanceOf(address account) public view override returns (uint256) {
return IOVLBalanceHandler(tokenBalanceHandler).handleBalanceCalculations(account, msg.sender);
}
function _provideInitialSupply(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: supplying zero address");
UserInformation storage ui = _userInformation[account];
ui.maturedBalance = ui.maturedBalance.add(amount);
ui.maxBalance = ui.maxBalance.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/// @notice sets a new distributor potentially with new distribution rules
function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
/// @notice initializes the change of governance
function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
function acceptGovernance() public {
require(msg.sender == pendingGovernance);
governance = msg.sender;
setWhitelists(msg.sender, true, true, true);
delete pendingGovernance;
}
/// @notice sets the function that calculates returns from balanceOF
function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
/// @notice sets a contract with new logic for transfer handlers (contract upgrade)
function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return 'Transaction reverted silently';
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
function totalsForWallet(address account) public view returns (WalletTotals memory totals) {
uint256 mature = _userInformation[account].maturedBalance;
uint256 immature;
for(uint256 i = 0; i < QTY_EPOCHS; i++) {
uint256 amount = vestingTransactions[account][i].amount;
uint256 matureTxBalance = IOVLVestingCalculator(tokenBalanceHandler).getMatureBalance(vestingTransactions[account][i], block.timestamp);
mature = mature.add(matureTxBalance);
immature = immature.add(amount.sub(matureTxBalance));
}
totals.mature = mature;
totals.immature = immature;
totals.total = mature.add(immature);
}
// Optimization for Balance Handler
function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
// Optimization for `require` checks
modifier isGovernance() {
_isGovernance();
_;
}
function _isGovernance() private view {
require(msg.sender == governance, "!gov");
}
// Remaining for js tests only before refactor
function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
function userInformation(address user) external view returns (UserInformation memory) {
return _userInformation[user];
}
} | // Implementation of the DELTA token responsible
// for the CORE ecosystem options layer
// guarding unlocked liquidity inside of the ecosystem
// This token is time lock guarded by 90% FoT which disappears after 2 weeks to 0%
// balanceOf will return the spendable amount outside of the fee on transfer. | LineComment | setBalanceCalculator | function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
| /// @notice sets the function that calculates returns from balanceOF | NatSpecSingleLine | v0.7.6+commit.7338295f | {
"func_code_index": [
10679,
10826
]
} | 4,387 |
||
DELTAToken | contracts/v076/Token/DELTAToken.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | DELTAToken | contract DELTAToken is OVLBase, Context, IERC20 {
using SafeMath for uint256;
using Address for address;
address public governance;
address public tokenTransferHandler;
address public rebasingLPAddress;
address public tokenBalanceHandler;
address public pendingGovernance;
// ERC-20 Variables
string private constant NAME = "DELTA.financial - deep DeFi derivatives";
string private constant SYMBOL = "DELTA";
uint8 private constant DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 45_000_000e18;
// Configuration
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant BURNER = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;
address private constant LSW_ADDRESS = 0xdaFCE5670d3F67da9A3A44FE6bc36992e5E2beaB;
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
// Handler for activation after first rebasing
address private immutable tokenBalanceHandlerMain;
address private immutable tokenTransferHandlerMain;
// Lookup for pair
address immutable public _PAIR_ADDRESS;
constructor (address rebasingLP, address multisig, address dfv) {
require(address(this) < WETH_ADDRESS, "DELTAToken: Invalid Token Address");
require(multisig != address(0));
require(dfv != address(0));
require(rebasingLP != address(0));
// We get the pair address
// token0 is the smaller address
address uniswapPair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainnet uniswap factory
keccak256(abi.encodePacked(address(this), WETH_ADDRESS)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
// We whitelist the pair to have no vesting on reception
governance = msg.sender; // bypass !gov checks
_PAIR_ADDRESS = uniswapPair;
setNoVestingWhitelist(uniswapPair, true);
setNoVestingWhitelist(BURNER, true);
setNoVestingWhitelist(rebasingLP, true);
setNoVestingWhitelist(UNISWAP_V2_ROUTER, true); // We set the router to no vesting so we dont need to check it in the balance handler to return maxbalance.
// Since we return maxbalance of everyone who has no vesting.
setWhitelists(multisig, true, true, true);
// We are not setting dfv here intentionally because we have a check inside the dfv that it has them
// Since DFV needs to be able to set whitelists itself, so it needs to be a part of the modules
setFullSenderWhitelist(LSW_ADDRESS, true); // Nessesary for lsw because it doesnt just send to the pair
governance = multisig;
rebasingLPAddress = rebasingLP;
_provideInitialSupply(LSW_ADDRESS, TOTAL_SUPPLY);
// Set post first rebasing ones now into private variables
address transferHandler = address(new OVLTransferHandler(uniswapPair, dfv));
tokenTransferHandlerMain = transferHandler;
tokenBalanceHandlerMain = address(new OVLBalanceHandler(IOVLTransferHandler(transferHandler), IERC20(uniswapPair)));
//Set pre rebasing ones as main ones
tokenTransferHandler = address(new OVLLPRebasingHandler(uniswapPair));
tokenBalanceHandler = address(new OVLLPRebasingBalanceHandler());
}
function activatePostFirstRebasingState() public isGovernance() {
require(distributor != address(0), "Set the distributor first!");
tokenTransferHandler = tokenTransferHandlerMain;
tokenBalanceHandler = tokenBalanceHandlerMain;
}
function name() public pure returns (string memory) {
return NAME;
}
function symbol() public pure returns (string memory) {
return SYMBOL;
}
function decimals() public pure returns (uint8) {
return DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return TOTAL_SUPPLY - balanceOf(BURNER);
}
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function matureAllTokensOf(UserInformation storage ui, address account) internal {
delete vestingTransactions[account]; // remove all vesting buckets
ui.maturedBalance = ui.maxBalance;
}
function setFullSenderWhitelist(address account, bool canSendToMatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
function setImmatureRecipentWhitelist(address account, bool canRecieveImmatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
}
function setNoVestingWhitelist(address account, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
}
function setWhitelists(address account, bool canSendToMatureBalances, bool canRecieveImmatureBalances, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
// Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after
function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
// Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process
function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
// allow only RLP to call functions that call this function
function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
bytes memory callData = abi.encodeWithSelector(IOVLTransferHandler.handleTransfer.selector, sender, recipient, amount);
(bool success, bytes memory result) = tokenTransferHandler.delegatecall(callData);
if (!success) {
revert(_getRevertMsg(result));
}
}
function balanceOf(address account) public view override returns (uint256) {
return IOVLBalanceHandler(tokenBalanceHandler).handleBalanceCalculations(account, msg.sender);
}
function _provideInitialSupply(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: supplying zero address");
UserInformation storage ui = _userInformation[account];
ui.maturedBalance = ui.maturedBalance.add(amount);
ui.maxBalance = ui.maxBalance.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/// @notice sets a new distributor potentially with new distribution rules
function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
/// @notice initializes the change of governance
function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
function acceptGovernance() public {
require(msg.sender == pendingGovernance);
governance = msg.sender;
setWhitelists(msg.sender, true, true, true);
delete pendingGovernance;
}
/// @notice sets the function that calculates returns from balanceOF
function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
/// @notice sets a contract with new logic for transfer handlers (contract upgrade)
function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return 'Transaction reverted silently';
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
function totalsForWallet(address account) public view returns (WalletTotals memory totals) {
uint256 mature = _userInformation[account].maturedBalance;
uint256 immature;
for(uint256 i = 0; i < QTY_EPOCHS; i++) {
uint256 amount = vestingTransactions[account][i].amount;
uint256 matureTxBalance = IOVLVestingCalculator(tokenBalanceHandler).getMatureBalance(vestingTransactions[account][i], block.timestamp);
mature = mature.add(matureTxBalance);
immature = immature.add(amount.sub(matureTxBalance));
}
totals.mature = mature;
totals.immature = immature;
totals.total = mature.add(immature);
}
// Optimization for Balance Handler
function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
// Optimization for `require` checks
modifier isGovernance() {
_isGovernance();
_;
}
function _isGovernance() private view {
require(msg.sender == governance, "!gov");
}
// Remaining for js tests only before refactor
function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
function userInformation(address user) external view returns (UserInformation memory) {
return _userInformation[user];
}
} | // Implementation of the DELTA token responsible
// for the CORE ecosystem options layer
// guarding unlocked liquidity inside of the ecosystem
// This token is time lock guarded by 90% FoT which disappears after 2 weeks to 0%
// balanceOf will return the spendable amount outside of the fee on transfer. | LineComment | setTokenTransferHandler | function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
| /// @notice sets a contract with new logic for transfer handlers (contract upgrade) | NatSpecSingleLine | v0.7.6+commit.7338295f | {
"func_code_index": [
10916,
11047
]
} | 4,388 |
||
DELTAToken | contracts/v076/Token/DELTAToken.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | DELTAToken | contract DELTAToken is OVLBase, Context, IERC20 {
using SafeMath for uint256;
using Address for address;
address public governance;
address public tokenTransferHandler;
address public rebasingLPAddress;
address public tokenBalanceHandler;
address public pendingGovernance;
// ERC-20 Variables
string private constant NAME = "DELTA.financial - deep DeFi derivatives";
string private constant SYMBOL = "DELTA";
uint8 private constant DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 45_000_000e18;
// Configuration
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant BURNER = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;
address private constant LSW_ADDRESS = 0xdaFCE5670d3F67da9A3A44FE6bc36992e5E2beaB;
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
// Handler for activation after first rebasing
address private immutable tokenBalanceHandlerMain;
address private immutable tokenTransferHandlerMain;
// Lookup for pair
address immutable public _PAIR_ADDRESS;
constructor (address rebasingLP, address multisig, address dfv) {
require(address(this) < WETH_ADDRESS, "DELTAToken: Invalid Token Address");
require(multisig != address(0));
require(dfv != address(0));
require(rebasingLP != address(0));
// We get the pair address
// token0 is the smaller address
address uniswapPair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainnet uniswap factory
keccak256(abi.encodePacked(address(this), WETH_ADDRESS)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
// We whitelist the pair to have no vesting on reception
governance = msg.sender; // bypass !gov checks
_PAIR_ADDRESS = uniswapPair;
setNoVestingWhitelist(uniswapPair, true);
setNoVestingWhitelist(BURNER, true);
setNoVestingWhitelist(rebasingLP, true);
setNoVestingWhitelist(UNISWAP_V2_ROUTER, true); // We set the router to no vesting so we dont need to check it in the balance handler to return maxbalance.
// Since we return maxbalance of everyone who has no vesting.
setWhitelists(multisig, true, true, true);
// We are not setting dfv here intentionally because we have a check inside the dfv that it has them
// Since DFV needs to be able to set whitelists itself, so it needs to be a part of the modules
setFullSenderWhitelist(LSW_ADDRESS, true); // Nessesary for lsw because it doesnt just send to the pair
governance = multisig;
rebasingLPAddress = rebasingLP;
_provideInitialSupply(LSW_ADDRESS, TOTAL_SUPPLY);
// Set post first rebasing ones now into private variables
address transferHandler = address(new OVLTransferHandler(uniswapPair, dfv));
tokenTransferHandlerMain = transferHandler;
tokenBalanceHandlerMain = address(new OVLBalanceHandler(IOVLTransferHandler(transferHandler), IERC20(uniswapPair)));
//Set pre rebasing ones as main ones
tokenTransferHandler = address(new OVLLPRebasingHandler(uniswapPair));
tokenBalanceHandler = address(new OVLLPRebasingBalanceHandler());
}
function activatePostFirstRebasingState() public isGovernance() {
require(distributor != address(0), "Set the distributor first!");
tokenTransferHandler = tokenTransferHandlerMain;
tokenBalanceHandler = tokenBalanceHandlerMain;
}
function name() public pure returns (string memory) {
return NAME;
}
function symbol() public pure returns (string memory) {
return SYMBOL;
}
function decimals() public pure returns (uint8) {
return DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return TOTAL_SUPPLY - balanceOf(BURNER);
}
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function matureAllTokensOf(UserInformation storage ui, address account) internal {
delete vestingTransactions[account]; // remove all vesting buckets
ui.maturedBalance = ui.maxBalance;
}
function setFullSenderWhitelist(address account, bool canSendToMatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
function setImmatureRecipentWhitelist(address account, bool canRecieveImmatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
}
function setNoVestingWhitelist(address account, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
}
function setWhitelists(address account, bool canSendToMatureBalances, bool canRecieveImmatureBalances, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
// Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after
function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
// Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process
function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
// allow only RLP to call functions that call this function
function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
bytes memory callData = abi.encodeWithSelector(IOVLTransferHandler.handleTransfer.selector, sender, recipient, amount);
(bool success, bytes memory result) = tokenTransferHandler.delegatecall(callData);
if (!success) {
revert(_getRevertMsg(result));
}
}
function balanceOf(address account) public view override returns (uint256) {
return IOVLBalanceHandler(tokenBalanceHandler).handleBalanceCalculations(account, msg.sender);
}
function _provideInitialSupply(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: supplying zero address");
UserInformation storage ui = _userInformation[account];
ui.maturedBalance = ui.maturedBalance.add(amount);
ui.maxBalance = ui.maxBalance.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/// @notice sets a new distributor potentially with new distribution rules
function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
/// @notice initializes the change of governance
function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
function acceptGovernance() public {
require(msg.sender == pendingGovernance);
governance = msg.sender;
setWhitelists(msg.sender, true, true, true);
delete pendingGovernance;
}
/// @notice sets the function that calculates returns from balanceOF
function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
/// @notice sets a contract with new logic for transfer handlers (contract upgrade)
function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return 'Transaction reverted silently';
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
function totalsForWallet(address account) public view returns (WalletTotals memory totals) {
uint256 mature = _userInformation[account].maturedBalance;
uint256 immature;
for(uint256 i = 0; i < QTY_EPOCHS; i++) {
uint256 amount = vestingTransactions[account][i].amount;
uint256 matureTxBalance = IOVLVestingCalculator(tokenBalanceHandler).getMatureBalance(vestingTransactions[account][i], block.timestamp);
mature = mature.add(matureTxBalance);
immature = immature.add(amount.sub(matureTxBalance));
}
totals.mature = mature;
totals.immature = immature;
totals.total = mature.add(immature);
}
// Optimization for Balance Handler
function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
// Optimization for `require` checks
modifier isGovernance() {
_isGovernance();
_;
}
function _isGovernance() private view {
require(msg.sender == governance, "!gov");
}
// Remaining for js tests only before refactor
function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
function userInformation(address user) external view returns (UserInformation memory) {
return _userInformation[user];
}
} | // Implementation of the DELTA token responsible
// for the CORE ecosystem options layer
// guarding unlocked liquidity inside of the ecosystem
// This token is time lock guarded by 90% FoT which disappears after 2 weeks to 0%
// balanceOf will return the spendable amount outside of the fee on transfer. | LineComment | getUserInfo | function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
| // Optimization for Balance Handler | LineComment | v0.7.6+commit.7338295f | {
"func_code_index": [
12287,
12565
]
} | 4,389 |
||
DELTAToken | contracts/v076/Token/DELTAToken.sol | 0x9ea3b5b4ec044b70375236a281986106457b20ef | Solidity | DELTAToken | contract DELTAToken is OVLBase, Context, IERC20 {
using SafeMath for uint256;
using Address for address;
address public governance;
address public tokenTransferHandler;
address public rebasingLPAddress;
address public tokenBalanceHandler;
address public pendingGovernance;
// ERC-20 Variables
string private constant NAME = "DELTA.financial - deep DeFi derivatives";
string private constant SYMBOL = "DELTA";
uint8 private constant DECIMALS = 18;
uint256 private constant TOTAL_SUPPLY = 45_000_000e18;
// Configuration
address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant BURNER = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;
address private constant LSW_ADDRESS = 0xdaFCE5670d3F67da9A3A44FE6bc36992e5E2beaB;
address private constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
// Handler for activation after first rebasing
address private immutable tokenBalanceHandlerMain;
address private immutable tokenTransferHandlerMain;
// Lookup for pair
address immutable public _PAIR_ADDRESS;
constructor (address rebasingLP, address multisig, address dfv) {
require(address(this) < WETH_ADDRESS, "DELTAToken: Invalid Token Address");
require(multisig != address(0));
require(dfv != address(0));
require(rebasingLP != address(0));
// We get the pair address
// token0 is the smaller address
address uniswapPair = address(uint(keccak256(abi.encodePacked(
hex'ff',
0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, // Mainnet uniswap factory
keccak256(abi.encodePacked(address(this), WETH_ADDRESS)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
// We whitelist the pair to have no vesting on reception
governance = msg.sender; // bypass !gov checks
_PAIR_ADDRESS = uniswapPair;
setNoVestingWhitelist(uniswapPair, true);
setNoVestingWhitelist(BURNER, true);
setNoVestingWhitelist(rebasingLP, true);
setNoVestingWhitelist(UNISWAP_V2_ROUTER, true); // We set the router to no vesting so we dont need to check it in the balance handler to return maxbalance.
// Since we return maxbalance of everyone who has no vesting.
setWhitelists(multisig, true, true, true);
// We are not setting dfv here intentionally because we have a check inside the dfv that it has them
// Since DFV needs to be able to set whitelists itself, so it needs to be a part of the modules
setFullSenderWhitelist(LSW_ADDRESS, true); // Nessesary for lsw because it doesnt just send to the pair
governance = multisig;
rebasingLPAddress = rebasingLP;
_provideInitialSupply(LSW_ADDRESS, TOTAL_SUPPLY);
// Set post first rebasing ones now into private variables
address transferHandler = address(new OVLTransferHandler(uniswapPair, dfv));
tokenTransferHandlerMain = transferHandler;
tokenBalanceHandlerMain = address(new OVLBalanceHandler(IOVLTransferHandler(transferHandler), IERC20(uniswapPair)));
//Set pre rebasing ones as main ones
tokenTransferHandler = address(new OVLLPRebasingHandler(uniswapPair));
tokenBalanceHandler = address(new OVLLPRebasingBalanceHandler());
}
function activatePostFirstRebasingState() public isGovernance() {
require(distributor != address(0), "Set the distributor first!");
tokenTransferHandler = tokenTransferHandlerMain;
tokenBalanceHandler = tokenBalanceHandlerMain;
}
function name() public pure returns (string memory) {
return NAME;
}
function symbol() public pure returns (string memory) {
return SYMBOL;
}
function decimals() public pure returns (uint8) {
return DECIMALS;
}
function totalSupply() public view override returns (uint256) {
return TOTAL_SUPPLY - balanceOf(BURNER);
}
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, "ERC20: 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, "ERC20: decreased allowance below zero"));
return true;
}
function matureAllTokensOf(UserInformation storage ui, address account) internal {
delete vestingTransactions[account]; // remove all vesting buckets
ui.maturedBalance = ui.maxBalance;
}
function setFullSenderWhitelist(address account, bool canSendToMatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
function setImmatureRecipentWhitelist(address account, bool canRecieveImmatureBalances) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
}
function setNoVestingWhitelist(address account, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
}
function setWhitelists(address account, bool canSendToMatureBalances, bool canRecieveImmatureBalances, bool recievesBalancesWithoutVestingProcess) public isGovernance() {
UserInformation storage ui = _userInformation[account];
matureAllTokensOf(ui,account);
ui.noVestingWhitelisted = recievesBalancesWithoutVestingProcess;
ui.immatureReceiverWhitelisted = canRecieveImmatureBalances;
ui.fullSenderWhitelisted = canSendToMatureBalances;
}
// Allows for liquidity rebasing atomically
// Does a callback to rlp and closes right after
function performLiquidityRebasing() public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
liquidityRebasingPermitted = true;
IRebasingLiquidityToken(rebasingLPAddress).tokenCaller();
liquidityRebasingPermitted = false;
// Rebasing will adjust the lp tokens balance of the pair. Most likely to 0. This means without setting this here there is an attack vector
lpTokensInPair = IERC20(_PAIR_ADDRESS).balanceOf(_PAIR_ADDRESS);
}
// Allows the rebasing LP to change balance of an account
// Nessesary for fee efficiency of the rebasing process
function adjustBalanceOfNoVestingAccount(address account, uint256 amount, bool isAddition) public {
onlyRLP(); // guarantees this call can be only done by the rebasing lp contract
UserInformation storage ui = _userInformation[account];
require(ui.noVestingWhitelisted, "Account is a vesting address");
if(isAddition) {
ui.maxBalance = ui.maxBalance.add(amount);
ui.maturedBalance = ui.maturedBalance.add(amount);
} else {
ui.maxBalance = amount;
ui.maturedBalance = amount;
}
}
// allow only RLP to call functions that call this function
function onlyRLP() internal view {
require(msg.sender == rebasingLPAddress, "DELTAToken: Only Rebasing LP contract can call this function");
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
bytes memory callData = abi.encodeWithSelector(IOVLTransferHandler.handleTransfer.selector, sender, recipient, amount);
(bool success, bytes memory result) = tokenTransferHandler.delegatecall(callData);
if (!success) {
revert(_getRevertMsg(result));
}
}
function balanceOf(address account) public view override returns (uint256) {
return IOVLBalanceHandler(tokenBalanceHandler).handleBalanceCalculations(account, msg.sender);
}
function _provideInitialSupply(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: supplying zero address");
UserInformation storage ui = _userInformation[account];
ui.maturedBalance = ui.maturedBalance.add(amount);
ui.maxBalance = ui.maxBalance.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/// @notice sets a new distributor potentially with new distribution rules
function setDistributor(address _newDistributor) public isGovernance() {
distributor = _newDistributor;
setWhitelists(_newDistributor, true, true, true);
}
/// @notice initializes the change of governance
function setPendingGovernance(address _newGov) public isGovernance() {
pendingGovernance = _newGov;
}
function acceptGovernance() public {
require(msg.sender == pendingGovernance);
governance = msg.sender;
setWhitelists(msg.sender, true, true, true);
delete pendingGovernance;
}
/// @notice sets the function that calculates returns from balanceOF
function setBalanceCalculator(address _newBalanceCalculator) public isGovernance() {
tokenBalanceHandler = _newBalanceCalculator;
}
/// @notice sets a contract with new logic for transfer handlers (contract upgrade)
function setTokenTransferHandler(address _newHandler) public isGovernance() {
tokenTransferHandler = _newHandler;
}
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return 'Transaction reverted silently';
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
function totalsForWallet(address account) public view returns (WalletTotals memory totals) {
uint256 mature = _userInformation[account].maturedBalance;
uint256 immature;
for(uint256 i = 0; i < QTY_EPOCHS; i++) {
uint256 amount = vestingTransactions[account][i].amount;
uint256 matureTxBalance = IOVLVestingCalculator(tokenBalanceHandler).getMatureBalance(vestingTransactions[account][i], block.timestamp);
mature = mature.add(matureTxBalance);
immature = immature.add(amount.sub(matureTxBalance));
}
totals.mature = mature;
totals.immature = immature;
totals.total = mature.add(immature);
}
// Optimization for Balance Handler
function getUserInfo(address user) external view returns (UserInformationLite memory) {
UserInformation storage info = _userInformation[user];
return UserInformationLite(info.maturedBalance, info.maxBalance, info.mostMatureTxIndex, info.lastInTxIndex);
}
// Optimization for `require` checks
modifier isGovernance() {
_isGovernance();
_;
}
function _isGovernance() private view {
require(msg.sender == governance, "!gov");
}
// Remaining for js tests only before refactor
function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
function userInformation(address user) external view returns (UserInformation memory) {
return _userInformation[user];
}
} | // Implementation of the DELTA token responsible
// for the CORE ecosystem options layer
// guarding unlocked liquidity inside of the ecosystem
// This token is time lock guarded by 90% FoT which disappears after 2 weeks to 0%
// balanceOf will return the spendable amount outside of the fee on transfer. | LineComment | getTransactionDetail | function getTransactionDetail(VestingTransaction memory _tx) public view returns (VestingTransactionDetailed memory dtx) {
return IOVLVestingCalculator(tokenBalanceHandler).getTransactionDetails(_tx, block.timestamp);
}
| // Remaining for js tests only before refactor | LineComment | v0.7.6+commit.7338295f | {
"func_code_index": [
12834,
13068
]
} | 4,390 |
||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | Crowdsale | function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
| /**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
853,
1097
]
} | 4,391 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | function () external payable {
buyTokens(msg.sender);
}
| /**
* @dev fallback function ***DO NOT OVERRIDE***
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
1298,
1364
]
} | 4,392 |
||||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | buyTokens | function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
| /**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
1503,
2106
]
} | 4,393 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | _preValidatePurchase | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
| /**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
2538,
2701
]
} | 4,394 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | _postValidatePurchase | function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
| /**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
2983,
3100
]
} | 4,395 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | _deliverTokens | function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
| /**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
3367,
3502
]
} | 4,396 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | _processPurchase | function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
| /**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
3753,
3890
]
} | 4,397 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | _updatePurchasingState | function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
| /**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
4147,
4265
]
} | 4,398 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | _getTokenAmount | function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
| /**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
4507,
4627
]
} | 4,399 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
} | _forwardFunds | function _forwardFunds() internal {
wallet.transfer(msg.value);
}
| /**
* @dev Determines how ETH is stored/forwarded on purchases.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
4708,
4784
]
} | 4,400 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | TimedCrowdsale | contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public openingTime;
uint256 public closingTime;
/**
* @dev Reverts if not in crowdsale time range.
*/
modifier onlyWhileOpen {
// solium-disable-next-line security/no-block-members
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_;
}
/**
* @dev Constructor, takes crowdsale opening and closing times.
* @param _openingTime Crowdsale opening time
* @param _closingTime Crowdsale closing time
*/
function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public {
// solium-disable-next-line security/no-block-members
require(_openingTime >= block.timestamp);
require(_closingTime >= _openingTime);
openingTime = _openingTime;
closingTime = _closingTime;
}
/**
* @dev Checks whether the period in which the crowdsale is open has already elapsed.
* @return Whether crowdsale period has elapsed
*/
function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return block.timestamp > closingTime;
}
/**
* @dev Extend parent behavior requiring to be within contributing period
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen {
super._preValidatePurchase(_beneficiary, _weiAmount);
}
} | TimedCrowdsale | function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public {
// solium-disable-next-line security/no-block-members
require(_openingTime >= block.timestamp);
require(_closingTime >= _openingTime);
openingTime = _openingTime;
closingTime = _closingTime;
}
| /**
* @dev Constructor, takes crowdsale opening and closing times.
* @param _openingTime Crowdsale opening time
* @param _closingTime Crowdsale closing time
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
563,
865
]
} | 4,401 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | TimedCrowdsale | contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public openingTime;
uint256 public closingTime;
/**
* @dev Reverts if not in crowdsale time range.
*/
modifier onlyWhileOpen {
// solium-disable-next-line security/no-block-members
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_;
}
/**
* @dev Constructor, takes crowdsale opening and closing times.
* @param _openingTime Crowdsale opening time
* @param _closingTime Crowdsale closing time
*/
function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public {
// solium-disable-next-line security/no-block-members
require(_openingTime >= block.timestamp);
require(_closingTime >= _openingTime);
openingTime = _openingTime;
closingTime = _closingTime;
}
/**
* @dev Checks whether the period in which the crowdsale is open has already elapsed.
* @return Whether crowdsale period has elapsed
*/
function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return block.timestamp > closingTime;
}
/**
* @dev Extend parent behavior requiring to be within contributing period
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen {
super._preValidatePurchase(_beneficiary, _weiAmount);
}
} | hasClosed | function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return block.timestamp > closingTime;
}
| /**
* @dev Checks whether the period in which the crowdsale is open has already elapsed.
* @return Whether crowdsale period has elapsed
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
1022,
1181
]
} | 4,402 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | TimedCrowdsale | contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public openingTime;
uint256 public closingTime;
/**
* @dev Reverts if not in crowdsale time range.
*/
modifier onlyWhileOpen {
// solium-disable-next-line security/no-block-members
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_;
}
/**
* @dev Constructor, takes crowdsale opening and closing times.
* @param _openingTime Crowdsale opening time
* @param _closingTime Crowdsale closing time
*/
function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public {
// solium-disable-next-line security/no-block-members
require(_openingTime >= block.timestamp);
require(_closingTime >= _openingTime);
openingTime = _openingTime;
closingTime = _closingTime;
}
/**
* @dev Checks whether the period in which the crowdsale is open has already elapsed.
* @return Whether crowdsale period has elapsed
*/
function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return block.timestamp > closingTime;
}
/**
* @dev Extend parent behavior requiring to be within contributing period
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen {
super._preValidatePurchase(_beneficiary, _weiAmount);
}
} | _preValidatePurchase | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen {
super._preValidatePurchase(_beneficiary, _weiAmount);
}
| /**
* @dev Extend parent behavior requiring to be within contributing period
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
1367,
1530
]
} | 4,403 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | Ownable | function Ownable() public {
owner = msg.sender;
}
| /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
261,
321
]
} | 4,404 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | transferOwnership | function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
640,
821
]
} | 4,405 |
|||
MonoretoPreIco | MonoretoPreIco.sol | 0x94dec5b089cd891ebe84f66f5ed8ab105895faab | Solidity | RefundVault | contract RefundVault is Ownable {
using SafeMath for uint256;
enum State { Active, Refunding, Closed }
mapping (address => uint256) public deposited;
address public wallet;
State public state;
event Closed();
event RefundsEnabled();
event Refunded(address indexed beneficiary, uint256 weiAmount);
/**
* @param _wallet Vault address
*/
function RefundVault(address _wallet) public {
require(_wallet != address(0));
wallet = _wallet;
state = State.Active;
}
/**
* @param investor Investor address
*/
function deposit(address investor) onlyOwner public payable {
require(state == State.Active);
deposited[investor] = deposited[investor].add(msg.value);
}
function close() onlyOwner public {
require(state == State.Active);
state = State.Closed;
emit Closed();
wallet.transfer(address(this).balance);
}
function enableRefunds() onlyOwner public {
require(state == State.Active);
state = State.Refunding;
emit RefundsEnabled();
}
/**
* @param investor Investor address
*/
function refund(address investor) public {
require(state == State.Refunding);
uint256 depositedValue = deposited[investor];
deposited[investor] = 0;
investor.transfer(depositedValue);
emit Refunded(investor, depositedValue);
}
} | RefundVault | function RefundVault(address _wallet) public {
require(_wallet != address(0));
wallet = _wallet;
state = State.Active;
}
| /**
* @param _wallet Vault address
*/ | NatSpecMultiLine | v0.4.23+commit.124ca40d | bzzr://16a3efb0ae5cc12a7443d9bb205cfb230a7333bdd659240e28a91243f0a44a74 | {
"func_code_index": [
379,
520
]
} | 4,406 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.