contract_name
stringlengths 1
61
| file_path
stringlengths 5
50.4k
| contract_address
stringlengths 42
42
| language
stringclasses 1
value | class_name
stringlengths 1
61
| class_code
stringlengths 4
330k
| class_documentation
stringlengths 0
29.1k
| class_documentation_type
stringclasses 6
values | func_name
stringlengths 0
62
| func_code
stringlengths 1
303k
| func_documentation
stringlengths 2
14.9k
| func_documentation_type
stringclasses 4
values | compiler_version
stringlengths 15
42
| license_type
stringclasses 14
values | swarm_source
stringlengths 0
71
| meta
dict | __index_level_0__
int64 0
60.4k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DiceOnline | DiceOnline.sol | 0xd3b5e17e96fda663da9438f8e1f11185d3433d08 | Solidity | DiceOffline | contract DiceOffline is Config,RoomManager,UserManager {
// 事件
event withdraw_failed();
event withdraw_succeeded(address toUser,uint256 value);
event bet_failed(address indexed player,uint256 value,uint result,uint roomid,uint errorcode);
event bet_succeeded(address indexed player,uint256 value,uint result,uint roomid,bytes32 serialNumber);
event evt_createRoomFailed(address indexed player);
event evt_createRoomSucceeded(address indexed player,uint roomid);
event evt_closeRoomFailed(address indexed player,uint roomid);
event evt_closeRoomSucceeded(address indexed player,uint roomid);
// 下注信息
struct BetInfo{
address player;
uint result;
uint256 value;
uint roomid;
}
mapping (bytes32 => BetInfo) rollingBet;
uint256 public allWagered;
uint256 public allWon;
uint public allPlayCount;
function DiceOffline() public{
}
// 销毁合约
function destroy() onlyOwner public{
returnAllRoomsBalance();
selfdestruct(owner);
}
// 充值
function () public payable {
}
// 提现
function withdraw(uint256 value) public onlyOwner{
if(getAvailableBalance() < value){
emit withdraw_failed();
return;
}
owner.transfer(value);
emit withdraw_succeeded(owner,value);
}
// 获取可提现额度
function getAvailableBalance() public view returns (uint256){
return SafeMath.sub(getBalance(),getAllBalance());
}
function rollSystem (uint result,address referral) public payable returns(bool) {
if(msg.value == 0){
return;
}
BetInfo memory bet = BetInfo(msg.sender,result,msg.value,0);
if(bet.value < minStake){
bet.player.transfer(bet.value);
emit bet_failed(bet.player,bet.value,result,0,0);
return false;
}
uint256 maxBet = getAvailableBalance() / 10;
if(maxBet > maxStake){
maxBet = maxStake;
}
if(bet.value > maxBet){
bet.player.transfer(SafeMath.sub(bet.value,maxBet));
bet.value = maxBet;
}
allWagered += bet.value;
allPlayCount++;
addBet(msg.sender,bet.value);
setReferral(msg.sender,referral);
// 生成随机数
bytes32 serialNumber = doOraclize(true);
rollingBet[serialNumber] = bet;
emit bet_succeeded(bet.player,bet.value,result,0,serialNumber);
return true;
}
// 如果setCount为0,表示大小
function openRoom(uint setCount,uint roomData,address referral) public payable returns(bool) {
if(setCount > 0 && (setCount > maxSet || setCount < minSet)){
emit evt_createRoomFailed(msg.sender);
msg.sender.transfer(msg.value);
return false;
}
uint256 minValue = normalRoomMin;
uint256 maxValue = normalRoomMax;
if(setCount > 0){
minValue = tripleRoomMin;
maxValue = tripleRoomMax;
}
if(msg.value < minValue || msg.value > maxValue){
emit evt_createRoomFailed(msg.sender);
msg.sender.transfer(msg.value);
return false;
}
allWagered += msg.value;
uint roomid = tryOpenRoom(msg.sender,msg.value,setCount,roomData);
setReferral(msg.sender,referral);
addOpenRoomCount(msg.sender);
emit evt_createRoomSucceeded(msg.sender,roomid);
}
function closeRoom(uint roomid) public returns(bool) {
bool ret = false;
bool taxPayed = false;
(ret,taxPayed) = tryCloseRoom(msg.sender,roomid,taxRate);
if(!ret){
emit evt_closeRoomFailed(msg.sender,roomid);
return false;
}
emit evt_closeRoomSucceeded(msg.sender,roomid);
if(!taxPayed){
subOpenRoomCount(msg.sender);
}
return true;
}
function rollRoom(uint roomid,address referral) public payable returns(bool) {
bool ret = tryRollRoom(msg.sender,msg.value,roomid);
if(!ret){
emit bet_failed(msg.sender,msg.value,0,roomid,0);
msg.sender.transfer(msg.value);
return false;
}
BetInfo memory bet = BetInfo(msg.sender,0,msg.value,roomid);
allWagered += bet.value;
allPlayCount++;
setReferral(msg.sender,referral);
addBet(msg.sender,bet.value);
// 生成随机数
bytes32 serialNumber = doOraclize(false);
rollingBet[serialNumber] = bet;
emit bet_succeeded(msg.sender,msg.value,0,roomid,serialNumber);
return true;
}
function dismissRoom(uint roomid) public onlyOwner {
tryDismissRoom(roomid);
}
function doOraclize(bool isSystem) internal returns(bytes32) {
uint256 random = uint256(keccak256(block.difficulty,now));
return bytes32(random);
}
/*TLSNotary for oraclize call
function offlineCallback(bytes32 myid) internal {
uint num = uint256(keccak256(block.difficulty,now)) & 216;
uint num1 = num % 6 + 1;
uint num2 = (num / 6) % 6 + 1;
uint num3 = (num / 36) % 6 + 1;
doCalculate(num1 * 100 + num2 * 10 + num3,myid);
}*/
function doCalculate(uint num123,bytes32 myid) internal {
BetInfo memory bet = rollingBet[myid];
if(bet.player == 0){
return;
}
if(bet.roomid == 0){ // 普通房间
// 进行结算
int256 winAmount = -int256(bet.value);
if(bet.result == getResult(num123)){
uint256 tax = (bet.value + bet.value) * taxRate / 1000;
winAmount = int256(bet.value - tax);
addWin(bet.player,uint256(winAmount));
bet.player.transfer(bet.value + uint256(winAmount));
fundReferrel(bet.player,tax * referrelFund / 1000);
allWon += uint256(winAmount);
}
//addGameRecord(bet.player,bet.value,winAmount,bet.result,num123,0x0,0,0);
emit evt_calculate(bet.player,0x0,num123,winAmount,0,now,myid);
emit evt_gameRecord(bet.player,bet.value,winAmount,bet.result,now,num123,0x0,0,0);
delete rollingBet[myid];
return;
}
doCalculateRoom(num123,myid);
}
function doCalculateRoom(uint num123,bytes32 myid) internal {
// 多人房间
BetInfo memory bet = rollingBet[myid];
bool success;
bool isend;
address winer;
uint256 tax;
(success,isend,winer,tax) = calculateRoom(bet.roomid,num123,taxRate,myid);
delete rollingBet[myid];
if(!success){
return;
}
if(isend){
addWin(winer,tax * 1000 / taxRate);
fundReferrel(winer,SafeMath.div(SafeMath.mul(tax,referrelFund),1000));
}
}
function getBalance() public view returns(uint256){
return address(this).balance;
}
} | doCalculate | function doCalculate(uint num123,bytes32 myid) internal {
BetInfo memory bet = rollingBet[myid];
if(bet.player == 0){
return;
}
if(bet.roomid == 0){ // 普通房间
// 进行结算
int256 winAmount = -int256(bet.value);
if(bet.result == getResult(num123)){
uint256 tax = (bet.value + bet.value) * taxRate / 1000;
winAmount = int256(bet.value - tax);
addWin(bet.player,uint256(winAmount));
bet.player.transfer(bet.value + uint256(winAmount));
fundReferrel(bet.player,tax * referrelFund / 1000);
allWon += uint256(winAmount);
}
//addGameRecord(bet.player,bet.value,winAmount,bet.result,num123,0x0,0,0);
emit evt_calculate(bet.player,0x0,num123,winAmount,0,now,myid);
emit evt_gameRecord(bet.player,bet.value,winAmount,bet.result,now,num123,0x0,0,0);
delete rollingBet[myid];
return;
}
doCalculateRoom(num123,myid);
}
| /*TLSNotary for oraclize call
function offlineCallback(bytes32 myid) internal {
uint num = uint256(keccak256(block.difficulty,now)) & 216;
uint num1 = num % 6 + 1;
uint num2 = (num / 6) % 6 + 1;
uint num3 = (num / 36) % 6 + 1;
doCalculate(num1 * 100 + num2 * 10 + num3,myid);
}*/ | Comment | v0.4.24+commit.e67f0147 | bzzr://2f0065c395341e4968bc0667cbeafd2985e8db277889539c2b69d29b7f21f5c5 | {
"func_code_index": [
5598,
6753
]
} | 7,307 |
|||
DiceOnline | DiceOnline.sol | 0xd3b5e17e96fda663da9438f8e1f11185d3433d08 | Solidity | DiceOnline | contract DiceOnline is DiceOffline {
using strings for *;
// 随机序列号
uint randomQueryID;
function DiceOnline() public{
oraclizeLib.oraclize_setProof(oraclizeLib.proofType_TLSNotary() | oraclizeLib.proofStorage_IPFS());
oraclizeLib.oraclize_setCustomGasPrice(20000000000 wei);
randomQueryID = 0;
}
/*
* checks only Oraclize address is calling
*/
modifier onlyOraclize {
require(msg.sender == oraclizeLib.oraclize_cbAddress());
_;
}
function doOraclize(bool isSystem) internal returns(bytes32) {
randomQueryID += 1;
string memory queryString1 = "[URL] ['json(https://api.random.org/json-rpc/1/invoke).result.random[\"data\"]', '\\n{\"jsonrpc\":\"2.0\",\"method\":\"generateSignedIntegers\",\"params\":{\"apiKey\":\"";
string memory queryString2 = random_api_key;
string memory queryString3 = "\",\"n\":3,\"min\":1,\"max\":6},\"id\":";
string memory queryString4 = oraclizeLib.uint2str(randomQueryID);
string memory queryString5 = "}']";
string memory queryString1_2 = queryString1.toSlice().concat(queryString2.toSlice());
string memory queryString1_2_3 = queryString1_2.toSlice().concat(queryString3.toSlice());
string memory queryString1_2_3_4 = queryString1_2_3.toSlice().concat(queryString4.toSlice());
string memory queryString1_2_3_4_5 = queryString1_2_3_4.toSlice().concat(queryString5.toSlice());
//emit logString(queryString1_2_3_4_5,"queryString");
if(isSystem)
return oraclizeLib.oraclize_query("nested", queryString1_2_3_4_5,systemGasForOraclize);
else
return oraclizeLib.oraclize_query("nested", queryString1_2_3_4_5,gasForOraclize);
}
/*TLSNotary for oraclize call */
function __callback(bytes32 myid, string result, bytes proof) public onlyOraclize {
/* keep oraclize honest by retrieving the serialNumber from random.org result */
proof;
//emit logString(result,"result");
strings.slice memory sl_result = result.toSlice();
sl_result = sl_result.beyond("[".toSlice()).until("]".toSlice());
string memory numString = sl_result.split(', '.toSlice()).toString();
uint num1 = oraclizeLib.parseInt(numString);
numString = sl_result.split(', '.toSlice()).toString();
uint num2 = oraclizeLib.parseInt(numString);
numString = sl_result.split(', '.toSlice()).toString();
uint num3 = oraclizeLib.parseInt(numString);
if(num1 < 1 || num1 > 6){
return;
}
if(num2 < 1 || num2 > 6){
return;
}
if(num3 < 1 || num3 > 6){
return;
}
doCalculate(num1 * 100 + num2 * 10 + num3,myid);
}
} | __callback | function __callback(bytes32 myid, string result, bytes proof) public onlyOraclize {
/* keep oraclize honest by retrieving the serialNumber from random.org result */
proof;
//emit logString(result,"result");
strings.slice memory sl_result = result.toSlice();
sl_result = sl_result.beyond("[".toSlice()).until("]".toSlice());
string memory numString = sl_result.split(', '.toSlice()).toString();
uint num1 = oraclizeLib.parseInt(numString);
numString = sl_result.split(', '.toSlice()).toString();
uint num2 = oraclizeLib.parseInt(numString);
numString = sl_result.split(', '.toSlice()).toString();
uint num3 = oraclizeLib.parseInt(numString);
if(num1 < 1 || num1 > 6){
return;
}
if(num2 < 1 || num2 > 6){
return;
}
if(num3 < 1 || num3 > 6){
return;
}
doCalculate(num1 * 100 + num2 * 10 + num3,myid);
}
| /*TLSNotary for oraclize call */ | Comment | v0.4.24+commit.e67f0147 | bzzr://2f0065c395341e4968bc0667cbeafd2985e8db277889539c2b69d29b7f21f5c5 | {
"func_code_index": [
1887,
2977
]
} | 7,308 |
|||
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | BOA | function BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _totalSupply);
}
| // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
450,
814
]
} | 7,309 |
|
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | totalSupply | function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
| // ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
1002,
1123
]
} | 7,310 |
|
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | balanceOf | function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
| // ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
1343,
1472
]
} | 7,311 |
|
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transfer | 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;
}
| // ------------------------------------------------------------------------
// 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
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
1816,
2093
]
} | 7,312 |
|
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | approve | function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, 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
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
2601,
2809
]
} | 7,313 |
|
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transferFrom | 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;
}
| // ------------------------------------------------------------------------
// 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
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
3340,
3698
]
} | 7,314 |
|
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | allowance | function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
| // ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
3981,
4137
]
} | 7,315 |
|
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | approveAndCall | function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
| // ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
4492,
4809
]
} | 7,316 |
|
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | function () public payable {
revert();
}
| // ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
5001,
5060
]
} | 7,317 |
||
BOA | BOA.sol | 0xe7e9009df1ba468559fa2e617820c0f6b438b19c | Solidity | BOA | contract BOA 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 BOA() public {
symbol = "BOA";
name = "Bank of America Digital Payment Platform";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C] = _totalSupply;
Transfer(address(0), 0x797E2fa8c7B9A880d9867A5992A91330f56Ea03C, _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) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transferAnyERC20Token | function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
| // ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------ | LineComment | v0.4.19+commit.c4cbbb05 | bzzr://ddb04b932520b4dd986b796eed5da9aae9ab9c2f61b6cb55ea6db57db943b9fb | {
"func_code_index": [
5293,
5482
]
} | 7,318 |
|
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
require(a == 0 || c / a == b, 'Invalid values');
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, 'Substraction result smaller than zero');
return a - b;
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, 'Invalid values');
return c;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
require(a == 0 || c / a == b, 'Invalid values');
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
263,
448
]
} | 7,319 |
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
require(a == 0 || c / a == b, 'Invalid values');
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, 'Substraction result smaller than zero');
return a - b;
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, 'Invalid values');
return c;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
973,
1100
]
} | 7,320 |
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
require(a == 0 || c / a == b, 'Invalid values');
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, 'Substraction result smaller than zero');
return a - b;
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, 'Invalid values');
return c;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, 'Substraction result smaller than zero');
return a - b;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
1370,
1540
]
} | 7,321 |
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
require(a == 0 || c / a == b, 'Invalid values');
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, 'Substraction result smaller than zero');
return a - b;
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, 'Invalid values');
return c;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, 'Invalid values');
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
1773,
1944
]
} | 7,322 |
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | allowUser | function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
| // allow user in invite mode | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
5146,
5309
]
} | 7,323 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | battleMode | function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
| // disable inviting | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
5337,
5471
]
} | 7,324 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | setDAOAddress | function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
| // this function sets the DAO contract address | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
5526,
5719
]
} | 7,325 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | payToAdmin | function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
| // process payment to administrator wallet
// or DAO holders | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
5793,
6840
]
} | 7,326 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | regUser | function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
| // user registration | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
6869,
8970
]
} | 7,327 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | buyLevel | function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
| // buy level function | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
9000,
10494
]
} | 7,328 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | setMaxAutopayForLevelCount | function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
| // for interactive correction of the limitations | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
10987,
11112
]
} | 7,329 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | buyLevelByFund | function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
| // buyLevelByFund provides automatic payment for next level for user | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
11189,
12450
]
} | 7,330 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | updateCurrentLevel | function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
| // updateCurrentLevel calculate 'currentLvl' value for given user | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
12524,
12644
]
} | 7,331 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | actualLevel | function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
| // helper function | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
12671,
12979
]
} | 7,332 |
||
Absolutus | Absolutus.sol | 0x0c9e046e22a04ce91b6036f3f7496a4fbd827260 | Solidity | Absolutus | contract Absolutus is Ownable, WalletOnly {
// Events
event RegLevelEvent(address indexed _user, address indexed _referrer, uint _id, uint _time);
event BuyLevelEvent(address indexed _user, uint _level, uint _time);
event ProlongateLevelEvent(address indexed _user, uint _level, uint _time);
event GetMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
event LostMoneyForLevelEvent(address indexed _user, address indexed _referral, uint _level, uint _time, uint _price, bool _prevLost);
// New events
event PaymentForHolder(address indexed _addr, uint _index, uint _value);
event PaymentForHolderLost(address indexed _addr, uint _index, uint _value);
// Common values
mapping (uint => uint) public LEVEL_PRICE;
address canSetLevelPrice;
uint REFERRER_1_LEVEL_LIMIT = 3;
uint PERIOD_LENGTH = 365 days; // uncomment before production
uint MAX_AUTOPAY_COUNT = 5; // Automatic level buying limit per one transaction (to prevent gas limit reaching)
struct UserStruct {
bool isExist;
uint id;
uint referrerID;
uint fund; // Fund for the automatic level pushcase
uint currentLvl; // Current user's level
address[] referral;
mapping (uint => uint) levelExpired;
mapping (uint => uint) paymentsCount;
}
mapping (address => UserStruct) public users;
mapping (uint => address) public userList;
mapping (address => uint) public allowUsers;
uint public currUserID = 0;
bool nostarted = false;
AbsDAO _dao; // DAO contract
bool daoSet = false; // if true payment processed for DAO holders
using SafeMath for uint; // <== do not forget about this
constructor() public {
// Prices in ETH: production
LEVEL_PRICE[1] = 0.5 ether;
LEVEL_PRICE[2] = 1.0 ether;
LEVEL_PRICE[3] = 2.0 ether;
LEVEL_PRICE[4] = 4.0 ether;
LEVEL_PRICE[5] = 16.0 ether;
LEVEL_PRICE[6] = 32.0 ether;
LEVEL_PRICE[7] = 64.0 ether;
LEVEL_PRICE[8] = 128.0 ether;
UserStruct memory userStruct;
currUserID++;
canSetLevelPrice = owner;
// Create root user
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : 0,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[ownerWallet] = userStruct;
userList[currUserID] = ownerWallet;
users[ownerWallet].levelExpired[1] = 77777777777;
users[ownerWallet].levelExpired[2] = 77777777777;
users[ownerWallet].levelExpired[3] = 77777777777;
users[ownerWallet].levelExpired[4] = 77777777777;
users[ownerWallet].levelExpired[5] = 77777777777;
users[ownerWallet].levelExpired[6] = 77777777777;
users[ownerWallet].levelExpired[7] = 77777777777;
users[ownerWallet].levelExpired[8] = 77777777777;
// Set inviting registration only
nostarted = true;
}
function () external payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
uint level;
// Check for payment with level price
if (msg.value == LEVEL_PRICE[1]) {
level = 1;
} else if (msg.value == LEVEL_PRICE[2]) {
level = 2;
} else if (msg.value == LEVEL_PRICE[3]) {
level = 3;
} else if (msg.value == LEVEL_PRICE[4]) {
level = 4;
} else if (msg.value == LEVEL_PRICE[5]) {
level = 5;
} else if (msg.value == LEVEL_PRICE[6]) {
level = 6;
} else if (msg.value == LEVEL_PRICE[7]) {
level = 7;
} else if (msg.value == LEVEL_PRICE[8]) {
level = 8;
} else {
// Pay to user's fund
if (!users[msg.sender].isExist || users[msg.sender].currentLvl >= 8)
revert('Incorrect Value send');
users[msg.sender].fund += msg.value;
updateCurrentLevel(msg.sender);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[msg.sender].currentLvl+1] <= users[msg.sender].fund) {
buyLevelByFund(msg.sender, 0);
}
return;
}
// Buy level or register user
if (users[msg.sender].isExist) {
buyLevel(level);
} else if (level == 1) {
uint refId = 0;
address referrer = bytesToAddress(msg.data);
if (users[referrer].isExist) {
refId = users[referrer].id;
} else {
revert('Incorrect referrer');
// refId = 1;
}
regUser(refId);
} else {
revert("Please buy first level for 0.1 ETH");
}
}
// allow user in invite mode
function allowUser(address _user) public onlyOwner {
require(nostarted, 'You cant allow user in battle mode');
allowUsers[_user] = 1;
}
// disable inviting
function battleMode() public onlyOwner {
require(nostarted, 'Battle mode activated');
nostarted = false;
}
// this function sets the DAO contract address
function setDAOAddress(address payable _dao_addr) public onlyOwner {
require(!daoSet, 'DAO address already set');
_dao = AbsDAO(_dao_addr);
daoSet = true;
}
// process payment to administrator wallet
// or DAO holders
function payToAdmin(uint _amount) internal {
if (daoSet) {
// Pay for DAO
uint holderCount = _dao.getHolderCount(); // get the DAO holders count
for (uint i = 1; i <= holderCount; i++) {
uint val = _dao.getHolderPieAt(i); // get pie of holder with index == i
address payable holder = _dao.getHolder(i); // get the holder address
if (val > 0) { // check of the holder pie value
uint payValue = _amount.div(100).mul(val); // calculate amount for pay to the holder
holder.transfer(payValue);
emit PaymentForHolder(holder, i, payValue); // payment ok
} else {
emit PaymentForHolderLost(holder, i, val); // holder's pie value is zero
}
}
} else {
// pay to admin wallet
address(uint160(adminWallet)).transfer(_amount);
}
}
// user registration
function regUser(uint referrerID) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
if (nostarted) {
require(allowUsers[msg.sender] > 0, 'You cannot use this contract on start');
}
require(!users[msg.sender].isExist, 'User exist');
require(referrerID > 0 && referrerID <= currUserID, 'Incorrect referrer Id');
require(msg.value==LEVEL_PRICE[1], 'Incorrect Value');
// NOTE: use one more variable to prevent 'Security/No-assign-param' error (for vscode-solidity extension).
// Need to check the gas consumtion with it
uint _referrerID = referrerID;
if (users[userList[referrerID]].referral.length >= REFERRER_1_LEVEL_LIMIT) {
_referrerID = users[findFreeReferrer(userList[referrerID])].id;
}
UserStruct memory userStruct;
currUserID++;
// add user to list
userStruct = UserStruct({
isExist : true,
id : currUserID,
referrerID : _referrerID,
fund: 0,
currentLvl: 1,
referral : new address[](0)
});
users[msg.sender] = userStruct;
userList[currUserID] = msg.sender;
users[msg.sender].levelExpired[1] = now + PERIOD_LENGTH;
users[msg.sender].levelExpired[2] = 0;
users[msg.sender].levelExpired[3] = 0;
users[msg.sender].levelExpired[4] = 0;
users[msg.sender].levelExpired[5] = 0;
users[msg.sender].levelExpired[6] = 0;
users[msg.sender].levelExpired[7] = 0;
users[msg.sender].levelExpired[8] = 0;
users[userList[_referrerID]].referral.push(msg.sender);
// pay for referer
payForLevel(
1,
msg.sender,
msg.sender,
0,
false
);
emit RegLevelEvent(
msg.sender,
userList[_referrerID],
currUserID,
now
);
}
// buy level function
function buyLevel(uint _level) public payable {
require(!isContract(msg.sender), 'This contract cannot support payments from other contracts');
require(users[msg.sender].isExist, 'User not exist');
require(_level>0 && _level<=8, 'Incorrect level');
require(msg.value==LEVEL_PRICE[_level], 'Incorrect Value');
if (_level > 1) { // Replace for condition (_level == 1) on top (done)
for (uint i = _level-1; i>0; i--) {
require(users[msg.sender].levelExpired[i] >= now, 'Buy the previous level');
}
}
// if(users[msg.sender].levelExpired[_level] == 0){ <-- BUG
// if the level expired in the future, need add PERIOD_LENGTH to the level expiration time,
// or set the level expiration time to 'now + PERIOD_LENGTH' in other cases.
if (users[msg.sender].levelExpired[_level] > now) {
users[msg.sender].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[msg.sender].levelExpired[_level] = now + PERIOD_LENGTH;
}
// Set user's current level
if (users[msg.sender].currentLvl < _level)
users[msg.sender].currentLvl = _level;
// provide payment for the user's referer
payForLevel(
_level,
msg.sender,
msg.sender,
0,
false
);
emit BuyLevelEvent(msg.sender, _level, now);
}
function setLevelPrice(uint _level, uint _price) public {
require(_level >= 0 && _level <= 8, 'Invalid level');
require(msg.sender == canSetLevelPrice, 'Invalid caller');
require(_price > 0, 'Price cannot be zero or negative');
LEVEL_PRICE[_level] = _price * 1.0 finney;
}
function setCanUpdateLevelPrice(address addr) public onlyOwner {
canSetLevelPrice = addr;
}
// for interactive correction of the limitations
function setMaxAutopayForLevelCount(uint _count) public onlyOwnerOrManager {
MAX_AUTOPAY_COUNT = _count;
}
// buyLevelByFund provides automatic payment for next level for user
function buyLevelByFund(address referer, uint _counter) internal {
require(users[referer].isExist, 'User not exists');
uint _level = users[referer].currentLvl + 1; // calculate a next level
require(users[referer].fund >= LEVEL_PRICE[_level], 'Not have funds to autobuy level');
uint remaining = users[referer].fund - LEVEL_PRICE[_level]; // Amount for pay to the referer
// extend the level's expiration time
if (users[referer].levelExpired[_level] >= now) {
users[referer].levelExpired[_level] += PERIOD_LENGTH;
} else {
users[referer].levelExpired[_level] = now + PERIOD_LENGTH;
}
users[referer].currentLvl = _level; // set current level for referer
users[referer].fund = 0; // clear the referer's fund
// process payment for next referer with increment autopay counter
payForLevel(
_level,
referer,
referer,
_counter+1,
false
);
address(uint160(referer)).transfer(remaining); // send the remaining amount to referer
emit BuyLevelEvent(referer, _level, now); // emit the buy level event for referer
}
// updateCurrentLevel calculate 'currentLvl' value for given user
function updateCurrentLevel(address _user) internal {
users[_user].currentLvl = actualLevel(_user);
}
// helper function
function actualLevel(address _user) public view returns(uint) {
require(users[_user].isExist, 'User not found');
for (uint i = 1; i <= 8; i++) {
if (users[_user].levelExpired[i] <= now) {
return i-1;
}
}
return 8;
}
// payForLevel provides payment processing for user's referer and automatic buying referer's next
// level.
function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
function findFreeReferrer(address _user) public view returns(address) {
if (users[_user].referral.length < REFERRER_1_LEVEL_LIMIT) {
return _user;
}
address[] memory referrals = new address[](363);
referrals[0] = users[_user].referral[0];
referrals[1] = users[_user].referral[1];
referrals[2] = users[_user].referral[2];
address freeReferrer;
bool noFreeReferrer = true;
for (uint i = 0; i<363; i++) {
if (users[referrals[i]].referral.length == REFERRER_1_LEVEL_LIMIT) {
if (i<120) {
referrals[(i+1)*3] = users[referrals[i]].referral[0];
referrals[(i+1)*3+1] = users[referrals[i]].referral[1];
referrals[(i+1)*3+2] = users[referrals[i]].referral[2];
}
} else {
noFreeReferrer = false;
freeReferrer = referrals[i];
break;
}
}
require(!noFreeReferrer, 'No Free Referrer');
return freeReferrer;
}
function viewUserReferral(address _user) public view returns(address[] memory) {
return users[_user].referral;
}
function viewUserLevelExpired(address _user, uint _level) public view returns(uint) {
return users[_user].levelExpired[_level];
}
function bytesToAddress(bytes memory bys) private pure returns (address addr ) {
assembly {
addr := mload(add(bys, 20))
}
}
} | payForLevel | function payForLevel(uint _level, address _user, address _sender, uint _autoPayCtr, bool prevLost) internal {
address referer;
address referer1;
address referer2;
address referer3;
if (_level == 1 || _level == 5) {
referer = userList[users[_user].referrerID];
} else if (_level == 2 || _level == 6) {
referer1 = userList[users[_user].referrerID];
referer = userList[users[referer1].referrerID];
} else if (_level == 3 || _level == 7) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer = userList[users[referer2].referrerID];
} else if (_level == 4 || _level == 8) {
referer1 = userList[users[_user].referrerID];
referer2 = userList[users[referer1].referrerID];
referer3 = userList[users[referer2].referrerID];
referer = userList[users[referer3].referrerID];
}
if (!users[referer].isExist) {
referer = userList[1];
}
uint amountToUser;
uint amountToAdmin;
amountToAdmin = LEVEL_PRICE[_level] / 100 * adminPersent;
amountToUser = LEVEL_PRICE[_level] - amountToAdmin;
if (users[referer].id <= 4) {
payToAdmin(LEVEL_PRICE[_level]);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
return;
}
if (users[referer].levelExpired[_level] >= now) {
payToAdmin(amountToAdmin);
// update current referer's level
updateCurrentLevel(referer);
// check for the user has right level and automatic payment counter
// smaller than the 'MAX_AUTOPAY_COUNT' value
if (_level == users[referer].currentLvl && _autoPayCtr < MAX_AUTOPAY_COUNT && users[referer].currentLvl < 8) {
users[referer].fund += amountToUser;
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
// if the referer is have funds for autobuy next level
if (LEVEL_PRICE[users[referer].currentLvl+1] <= users[referer].fund) {
buyLevelByFund(referer, _autoPayCtr);
}
} else {
// send the ethers to referer
address(uint160(referer)).transfer(amountToUser);
emit GetMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
}
} else {
// pay for the referer's referer
emit LostMoneyForLevelEvent(
referer,
_sender,
_level,
now,
amountToUser,
prevLost
);
payForLevel(
_level,
referer,
_sender,
_autoPayCtr,
true
);
}
}
| // payForLevel provides payment processing for user's referer and automatic buying referer's next
// level. | LineComment | v0.5.11+commit.c082d0b4 | GNU LGPLv3 | bzzr://18e2dfe8ebf7cefa713c3c410c3ee6e5b2a8151cd8310b4c152a6bbe075d75d3 | {
"func_code_index": [
13100,
16613
]
} | 7,333 |
||
UniV3PairManagerFactory | solidity/interfaces/IPairManagerFactory.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IPairManagerFactory | interface IPairManagerFactory is IGovernable {
// Variables
/// @notice Maps the address of a Uniswap pool, to the address of the corresponding PairManager
/// For example, the uniswap address of DAI-WETH, will return the Keep3r/DAI-WETH pair manager address
/// @param _pool The address of the Uniswap pool
/// @return _pairManager The address of the corresponding pair manager
function pairManagers(address _pool) external view returns (address _pairManager);
// Events
/// @notice Emitted when a new pair manager is created
/// @param _pool The address of the corresponding Uniswap pool
/// @param _pairManager The address of the just-created pair manager
event PairCreated(address _pool, address _pairManager);
// Errors
/// @notice Throws an error if the pair manager is already initialized
error AlreadyInitialized();
/// @notice Throws an error if the caller is not the owner
error OnlyOwner();
// Methods
/// @notice Creates a new pair manager based on the address of a Uniswap pool
/// For example, the uniswap address of DAI-WETH, will create the Keep3r/DAI-WETH pool
/// @param _pool The address of the Uniswap pool the pair manager will be based of
/// @return _pairManager The address of the just-created pair manager
function createPairManager(address _pool) external returns (address _pairManager);
} | /// @title Factory of Pair Managers
/// @notice This contract creates new pair managers | NatSpecSingleLine | pairManagers | function pairManagers(address _pool) external view returns (address _pairManager);
| /// @notice Maps the address of a Uniswap pool, to the address of the corresponding PairManager
/// For example, the uniswap address of DAI-WETH, will return the Keep3r/DAI-WETH pair manager address
/// @param _pool The address of the Uniswap pool
/// @return _pairManager The address of the corresponding pair manager | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
398,
482
]
} | 7,334 |
||
UniV3PairManagerFactory | solidity/interfaces/IPairManagerFactory.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IPairManagerFactory | interface IPairManagerFactory is IGovernable {
// Variables
/// @notice Maps the address of a Uniswap pool, to the address of the corresponding PairManager
/// For example, the uniswap address of DAI-WETH, will return the Keep3r/DAI-WETH pair manager address
/// @param _pool The address of the Uniswap pool
/// @return _pairManager The address of the corresponding pair manager
function pairManagers(address _pool) external view returns (address _pairManager);
// Events
/// @notice Emitted when a new pair manager is created
/// @param _pool The address of the corresponding Uniswap pool
/// @param _pairManager The address of the just-created pair manager
event PairCreated(address _pool, address _pairManager);
// Errors
/// @notice Throws an error if the pair manager is already initialized
error AlreadyInitialized();
/// @notice Throws an error if the caller is not the owner
error OnlyOwner();
// Methods
/// @notice Creates a new pair manager based on the address of a Uniswap pool
/// For example, the uniswap address of DAI-WETH, will create the Keep3r/DAI-WETH pool
/// @param _pool The address of the Uniswap pool the pair manager will be based of
/// @return _pairManager The address of the just-created pair manager
function createPairManager(address _pool) external returns (address _pairManager);
} | /// @title Factory of Pair Managers
/// @notice This contract creates new pair managers | NatSpecSingleLine | createPairManager | function createPairManager(address _pool) external returns (address _pairManager);
| /// @notice Creates a new pair manager based on the address of a Uniswap pool
/// For example, the uniswap address of DAI-WETH, will create the Keep3r/DAI-WETH pool
/// @param _pool The address of the Uniswap pool the pair manager will be based of
/// @return _pairManager The address of the just-created pair manager | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
1297,
1381
]
} | 7,335 |
||
MetaFrenchies | contracts/MetaFrenchies.sol | 0x3b44044735a46272ba15569e918f3266965e0eae | Solidity | MetaFrenchies | contract MetaFrenchies is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.07 ether;
uint256 public maxSupply = 4444;
uint256 public maxMintAmount = 10;
bool public paused = true;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused, "Minting is Paused!");
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
// Airdrop
function airdrop(address _to, uint256 _tokenId) public onlyOwner {
require(
_tokenId >= 4445 && _tokenId <= 4471,
"Please input only legendry token ids"
);
_safeMint(_to, _tokenId);
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(
abi.encodePacked(
currentBaseURI,
tokenId.toString(),
baseExtension
)
)
: "";
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public payable onlyOwner {
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
}
} | _baseURI | function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
| // internal | LineComment | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
502,
612
]
} | 7,336 |
||||
MetaFrenchies | contracts/MetaFrenchies.sol | 0x3b44044735a46272ba15569e918f3266965e0eae | Solidity | MetaFrenchies | contract MetaFrenchies is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.07 ether;
uint256 public maxSupply = 4444;
uint256 public maxMintAmount = 10;
bool public paused = true;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused, "Minting is Paused!");
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
// Airdrop
function airdrop(address _to, uint256 _tokenId) public onlyOwner {
require(
_tokenId >= 4445 && _tokenId <= 4471,
"Please input only legendry token ids"
);
_safeMint(_to, _tokenId);
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(
abi.encodePacked(
currentBaseURI,
tokenId.toString(),
baseExtension
)
)
: "";
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public payable onlyOwner {
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
}
} | mint | function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused, "Minting is Paused!");
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
| // public | LineComment | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
628,
1129
]
} | 7,337 |
||||
MetaFrenchies | contracts/MetaFrenchies.sol | 0x3b44044735a46272ba15569e918f3266965e0eae | Solidity | MetaFrenchies | contract MetaFrenchies is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.07 ether;
uint256 public maxSupply = 4444;
uint256 public maxMintAmount = 10;
bool public paused = true;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused, "Minting is Paused!");
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount);
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
// Airdrop
function airdrop(address _to, uint256 _tokenId) public onlyOwner {
require(
_tokenId >= 4445 && _tokenId <= 4471,
"Please input only legendry token ids"
);
_safeMint(_to, _tokenId);
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(
abi.encodePacked(
currentBaseURI,
tokenId.toString(),
baseExtension
)
)
: "";
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public payable onlyOwner {
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
}
} | airdrop | function airdrop(address _to, uint256 _tokenId) public onlyOwner {
require(
_tokenId >= 4445 && _tokenId <= 4471,
"Please input only legendry token ids"
);
_safeMint(_to, _tokenId);
}
| // Airdrop | LineComment | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
1148,
1387
]
} | 7,338 |
||||
PINKSEXY | PINKSEXY.sol | 0x0f481cbf7bf9f503062d3d27db2eda331eab930b | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
} | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://4c7b3909eae483b0fb1c7ba59afccd9fd04bf9c0b154a3584791938c3b80dc69 | {
"func_code_index": [
268,
664
]
} | 7,339 |
||
PINKSEXY | PINKSEXY.sol | 0x0f481cbf7bf9f503062d3d27db2eda331eab930b | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
} | balanceOf | function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://4c7b3909eae483b0fb1c7ba59afccd9fd04bf9c0b154a3584791938c3b80dc69 | {
"func_code_index": [
870,
986
]
} | 7,340 |
||
PINKSEXY | PINKSEXY.sol | 0x0f481cbf7bf9f503062d3d27db2eda331eab930b | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://4c7b3909eae483b0fb1c7ba59afccd9fd04bf9c0b154a3584791938c3b80dc69 | {
"func_code_index": [
401,
858
]
} | 7,341 |
||
PINKSEXY | PINKSEXY.sol | 0x0f481cbf7bf9f503062d3d27db2eda331eab930b | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | approve | function approve(address _spender, uint256 _value) public returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://4c7b3909eae483b0fb1c7ba59afccd9fd04bf9c0b154a3584791938c3b80dc69 | {
"func_code_index": [
1490,
1754
]
} | 7,342 |
||
PINKSEXY | PINKSEXY.sol | 0x0f481cbf7bf9f503062d3d27db2eda331eab930b | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | allowance | function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.26+commit.4563c3fc | None | bzzr://4c7b3909eae483b0fb1c7ba59afccd9fd04bf9c0b154a3584791938c3b80dc69 | {
"func_code_index": [
2078,
2223
]
} | 7,343 |
||
UniV3PairManagerFactory | solidity/interfaces/peripherals/IGovernable.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IGovernable | interface IGovernable {
// Events
/// @notice Emitted when pendingGovernance accepts to be governance
/// @param _governance Address of the new governance
event GovernanceSet(address _governance);
/// @notice Emitted when a new governance is proposed
/// @param _pendingGovernance Address that is proposed to be the new governance
event GovernanceProposal(address _pendingGovernance);
// Errors
/// @notice Throws if the caller of the function is not governance
error OnlyGovernance();
/// @notice Throws if the caller of the function is not pendingGovernance
error OnlyPendingGovernance();
/// @notice Throws if trying to set governance to zero address
error NoGovernanceZeroAddress();
// Variables
/// @notice Stores the governance address
/// @return _governance The governance addresss
function governance() external view returns (address _governance);
/// @notice Stores the pendingGovernance address
/// @return _pendingGovernance The pendingGovernance addresss
function pendingGovernance() external view returns (address _pendingGovernance);
// Methods
/// @notice Proposes a new address to be governance
/// @param _governance The address of the user proposed to be the new governance
function setGovernance(address _governance) external;
/// @notice Changes the governance from the current governance to the previously proposed address
function acceptGovernance() external;
} | /// @title Governable contract
/// @notice Manages the governance role | NatSpecSingleLine | governance | function governance() external view returns (address _governance);
| /// @notice Stores the governance address
/// @return _governance The governance addresss | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
832,
900
]
} | 7,344 |
||
UniV3PairManagerFactory | solidity/interfaces/peripherals/IGovernable.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IGovernable | interface IGovernable {
// Events
/// @notice Emitted when pendingGovernance accepts to be governance
/// @param _governance Address of the new governance
event GovernanceSet(address _governance);
/// @notice Emitted when a new governance is proposed
/// @param _pendingGovernance Address that is proposed to be the new governance
event GovernanceProposal(address _pendingGovernance);
// Errors
/// @notice Throws if the caller of the function is not governance
error OnlyGovernance();
/// @notice Throws if the caller of the function is not pendingGovernance
error OnlyPendingGovernance();
/// @notice Throws if trying to set governance to zero address
error NoGovernanceZeroAddress();
// Variables
/// @notice Stores the governance address
/// @return _governance The governance addresss
function governance() external view returns (address _governance);
/// @notice Stores the pendingGovernance address
/// @return _pendingGovernance The pendingGovernance addresss
function pendingGovernance() external view returns (address _pendingGovernance);
// Methods
/// @notice Proposes a new address to be governance
/// @param _governance The address of the user proposed to be the new governance
function setGovernance(address _governance) external;
/// @notice Changes the governance from the current governance to the previously proposed address
function acceptGovernance() external;
} | /// @title Governable contract
/// @notice Manages the governance role | NatSpecSingleLine | pendingGovernance | function pendingGovernance() external view returns (address _pendingGovernance);
| /// @notice Stores the pendingGovernance address
/// @return _pendingGovernance The pendingGovernance addresss | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
1017,
1099
]
} | 7,345 |
||
UniV3PairManagerFactory | solidity/interfaces/peripherals/IGovernable.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IGovernable | interface IGovernable {
// Events
/// @notice Emitted when pendingGovernance accepts to be governance
/// @param _governance Address of the new governance
event GovernanceSet(address _governance);
/// @notice Emitted when a new governance is proposed
/// @param _pendingGovernance Address that is proposed to be the new governance
event GovernanceProposal(address _pendingGovernance);
// Errors
/// @notice Throws if the caller of the function is not governance
error OnlyGovernance();
/// @notice Throws if the caller of the function is not pendingGovernance
error OnlyPendingGovernance();
/// @notice Throws if trying to set governance to zero address
error NoGovernanceZeroAddress();
// Variables
/// @notice Stores the governance address
/// @return _governance The governance addresss
function governance() external view returns (address _governance);
/// @notice Stores the pendingGovernance address
/// @return _pendingGovernance The pendingGovernance addresss
function pendingGovernance() external view returns (address _pendingGovernance);
// Methods
/// @notice Proposes a new address to be governance
/// @param _governance The address of the user proposed to be the new governance
function setGovernance(address _governance) external;
/// @notice Changes the governance from the current governance to the previously proposed address
function acceptGovernance() external;
} | /// @title Governable contract
/// @notice Manages the governance role | NatSpecSingleLine | setGovernance | function setGovernance(address _governance) external;
| /// @notice Proposes a new address to be governance
/// @param _governance The address of the user proposed to be the new governance | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
1252,
1307
]
} | 7,346 |
||
UniV3PairManagerFactory | solidity/interfaces/peripherals/IGovernable.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IGovernable | interface IGovernable {
// Events
/// @notice Emitted when pendingGovernance accepts to be governance
/// @param _governance Address of the new governance
event GovernanceSet(address _governance);
/// @notice Emitted when a new governance is proposed
/// @param _pendingGovernance Address that is proposed to be the new governance
event GovernanceProposal(address _pendingGovernance);
// Errors
/// @notice Throws if the caller of the function is not governance
error OnlyGovernance();
/// @notice Throws if the caller of the function is not pendingGovernance
error OnlyPendingGovernance();
/// @notice Throws if trying to set governance to zero address
error NoGovernanceZeroAddress();
// Variables
/// @notice Stores the governance address
/// @return _governance The governance addresss
function governance() external view returns (address _governance);
/// @notice Stores the pendingGovernance address
/// @return _pendingGovernance The pendingGovernance addresss
function pendingGovernance() external view returns (address _pendingGovernance);
// Methods
/// @notice Proposes a new address to be governance
/// @param _governance The address of the user proposed to be the new governance
function setGovernance(address _governance) external;
/// @notice Changes the governance from the current governance to the previously proposed address
function acceptGovernance() external;
} | /// @title Governable contract
/// @notice Manages the governance role | NatSpecSingleLine | acceptGovernance | function acceptGovernance() external;
| /// @notice Changes the governance from the current governance to the previously proposed address | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
1409,
1448
]
} | 7,347 |
||
Slyguise | Slyguise.sol | 0xcefb4eee91a3ce1f3843f79450b13cfafd09f749 | Solidity | Slyguise | contract Slyguise is ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenId;
uint256 public constant MAX_GUISE = 1000;
string baseTokenURI;
event SlyguiseMinted(uint256 totalMinted);
constructor(string memory baseURI) ERC721("Slyguise", "GUISE") {
setBaseURI(baseURI);
}
//Get token Ids of all tokens owned by _owner
function walletOfOwner(address _owner)
external
view
returns (uint256[] memory)
{
uint256 tokenCount = balanceOf(_owner);
uint256[] memory tokensId = new uint256[](tokenCount);
for (uint256 i = 0; i < tokenCount; i++) {
tokensId[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokensId;
}
function setBaseURI(string memory baseURI) public onlyOwner {
baseTokenURI = baseURI;
}
function batchMint(address[] calldata _recipients) external onlyOwner {
require(
totalSupply() + _recipients.length <= MAX_GUISE,
"Presale minting will exceed maximum supply of Slyguise"
);
require(_recipients.length != 0, "No address found");
for (uint256 i = 0; i < _recipients.length; i++) {
require(_recipients[i] != address(0), "Minting to Null address");
_mint(_recipients[i]);
}
}
//mint Slyguise
function mintSlyguise(address _to, uint256 _count) external onlyOwner {
require(_count > 0, "Minimum 1 Slyguise has to be minted");
require(
totalSupply() + _count <= MAX_GUISE,
"Exceeds maximum supply of Slyguise"
);
for (uint256 i = 0; i < _count; i++) {
_mint(_to);
}
}
function _mint(address _to) private {
_tokenId.increment();
uint256 tokenId = _tokenId.current();
_safeMint(_to, tokenId);
emit SlyguiseMinted(tokenId);
}
function _baseURI() internal view virtual override returns (string memory) {
return baseTokenURI;
}
} | /// @author Hammad Ahmed Ghazi | NatSpecSingleLine | walletOfOwner | function walletOfOwner(address _owner)
external
view
returns (uint256[] memory)
{
uint256 tokenCount = balanceOf(_owner);
uint256[] memory tokensId = new uint256[](tokenCount);
for (uint256 i = 0; i < tokenCount; i++) {
tokensId[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokensId;
}
| //Get token Ids of all tokens owned by _owner | LineComment | v0.8.7+commit.e28d00a7 | MIT | ipfs://8aceae61199fb8a5b3b2b79d049daac9ddebefba2ecb139788a75caca847bd16 | {
"func_code_index": [
419,
809
]
} | 7,348 |
Slyguise | Slyguise.sol | 0xcefb4eee91a3ce1f3843f79450b13cfafd09f749 | Solidity | Slyguise | contract Slyguise is ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenId;
uint256 public constant MAX_GUISE = 1000;
string baseTokenURI;
event SlyguiseMinted(uint256 totalMinted);
constructor(string memory baseURI) ERC721("Slyguise", "GUISE") {
setBaseURI(baseURI);
}
//Get token Ids of all tokens owned by _owner
function walletOfOwner(address _owner)
external
view
returns (uint256[] memory)
{
uint256 tokenCount = balanceOf(_owner);
uint256[] memory tokensId = new uint256[](tokenCount);
for (uint256 i = 0; i < tokenCount; i++) {
tokensId[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokensId;
}
function setBaseURI(string memory baseURI) public onlyOwner {
baseTokenURI = baseURI;
}
function batchMint(address[] calldata _recipients) external onlyOwner {
require(
totalSupply() + _recipients.length <= MAX_GUISE,
"Presale minting will exceed maximum supply of Slyguise"
);
require(_recipients.length != 0, "No address found");
for (uint256 i = 0; i < _recipients.length; i++) {
require(_recipients[i] != address(0), "Minting to Null address");
_mint(_recipients[i]);
}
}
//mint Slyguise
function mintSlyguise(address _to, uint256 _count) external onlyOwner {
require(_count > 0, "Minimum 1 Slyguise has to be minted");
require(
totalSupply() + _count <= MAX_GUISE,
"Exceeds maximum supply of Slyguise"
);
for (uint256 i = 0; i < _count; i++) {
_mint(_to);
}
}
function _mint(address _to) private {
_tokenId.increment();
uint256 tokenId = _tokenId.current();
_safeMint(_to, tokenId);
emit SlyguiseMinted(tokenId);
}
function _baseURI() internal view virtual override returns (string memory) {
return baseTokenURI;
}
} | /// @author Hammad Ahmed Ghazi | NatSpecSingleLine | mintSlyguise | function mintSlyguise(address _to, uint256 _count) external onlyOwner {
require(_count > 0, "Minimum 1 Slyguise has to be minted");
require(
totalSupply() + _count <= MAX_GUISE,
"Exceeds maximum supply of Slyguise"
);
for (uint256 i = 0; i < _count; i++) {
_mint(_to);
}
}
| //mint Slyguise | LineComment | v0.8.7+commit.e28d00a7 | MIT | ipfs://8aceae61199fb8a5b3b2b79d049daac9ddebefba2ecb139788a75caca847bd16 | {
"func_code_index": [
1439,
1807
]
} | 7,349 |
UniV3PairManagerFactory | solidity/interfaces/IUniV3PairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IUniV3PairManager | interface IUniV3PairManager is IGovernable, IPairManager {
// Structs
/// @notice The data to be decoded by the UniswapV3MintCallback function
struct MintCallbackData {
PoolAddress.PoolKey _poolKey; // Struct that contains token0, token1, and fee of the pool passed into the constructor
address payer; // The address of the payer, which will be the msg.sender of the mint function
}
// Variables
/// @notice The fee of the Uniswap pool passed into the constructor
/// @return _fee The fee of the Uniswap pool passed into the constructor
function fee() external view returns (uint24 _fee);
/// @notice The sqrtRatioAX96 at the lowest tick (-887200) of the Uniswap pool
/// @return _sqrtPriceA96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the lowest tick
function sqrtRatioAX96() external view returns (uint160 _sqrtPriceA96);
/// @notice The sqrtRatioBX96 at the highest tick (887200) of the Uniswap pool
/// @return _sqrtPriceBX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the highest tick
function sqrtRatioBX96() external view returns (uint160 _sqrtPriceBX96);
// Errors
/// @notice Throws when the caller of the function is not the pool
error OnlyPool();
/// @notice Throws when the slippage exceeds what the user is comfortable with
error ExcessiveSlippage();
/// @notice Throws when a transfer is unsuccessful
error UnsuccessfulTransfer();
// Methods
/// @notice This function is called after a user calls IUniV3PairManager#mint function
/// It ensures that any tokens owed to the pool are paid by the msg.sender of IUniV3PairManager#mint function
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data The encoded token0, token1, fee (_poolKey) and the payer (msg.sender) of the IUniV3PairManager#mint function
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
/// @notice Mints kLP tokens to an address according to the liquidity the msg.sender provides to the UniswapV3 pool
/// @dev Triggers UniV3PairManager#uniswapV3MintCallback
/// @param amount0Desired The amount of token0 we would like to provide
/// @param amount1Desired The amount of token1 we would like to provide
/// @param amount0Min The minimum amount of token0 we want to provide
/// @param amount1Min The minimum amount of token1 we want to provide
/// @param to The address to which the kLP tokens are going to be minted to
/// @return liquidity kLP tokens sent in exchange for the provision of tokens
function mint(
uint256 amount0Desired,
uint256 amount1Desired,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint128 liquidity);
/// @notice Returns the pair manager's position in the corresponding UniswapV3 pool
/// @return liquidity The amount of liquidity provided to the UniswapV3 pool by the pair manager
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function position()
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Calls the UniswapV3 pool's collect function, which collects up to a maximum amount of fees
// owed to a specific position to the recipient, in this case, that recipient is the pair manager
/// @dev The collected fees will be sent to governance
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect() external returns (uint256 amount0, uint256 amount1);
/// @notice Burns the corresponding amount of kLP tokens from the msg.sender and withdraws the specified liquidity
// in the entire range
/// @param liquidity The amount of liquidity to be burned
/// @param amount0Min The minimum amount of token0 we want to send to the recipient (to)
/// @param amount1Min The minimum amount of token1 we want to send to the recipient (to)
/// @param to The address that will receive the due fees
/// @return amount0 The calculated amount of token0 that will be sent to the recipient
/// @return amount1 The calculated amount of token1 that will be sent to the recipient
function burn(
uint128 liquidity,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint256 amount0, uint256 amount1);
} | /// @title Pair Manager contract
/// @notice Creates a UniswapV3 position, and tokenizes in an ERC20 manner
/// so that the user can use it as liquidity for a Keep3rJob | NatSpecSingleLine | fee | function fee() external view returns (uint24 _fee);
| /// @notice The fee of the Uniswap pool passed into the constructor
/// @return _fee The fee of the Uniswap pool passed into the constructor | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
562,
615
]
} | 7,350 |
||
UniV3PairManagerFactory | solidity/interfaces/IUniV3PairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IUniV3PairManager | interface IUniV3PairManager is IGovernable, IPairManager {
// Structs
/// @notice The data to be decoded by the UniswapV3MintCallback function
struct MintCallbackData {
PoolAddress.PoolKey _poolKey; // Struct that contains token0, token1, and fee of the pool passed into the constructor
address payer; // The address of the payer, which will be the msg.sender of the mint function
}
// Variables
/// @notice The fee of the Uniswap pool passed into the constructor
/// @return _fee The fee of the Uniswap pool passed into the constructor
function fee() external view returns (uint24 _fee);
/// @notice The sqrtRatioAX96 at the lowest tick (-887200) of the Uniswap pool
/// @return _sqrtPriceA96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the lowest tick
function sqrtRatioAX96() external view returns (uint160 _sqrtPriceA96);
/// @notice The sqrtRatioBX96 at the highest tick (887200) of the Uniswap pool
/// @return _sqrtPriceBX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the highest tick
function sqrtRatioBX96() external view returns (uint160 _sqrtPriceBX96);
// Errors
/// @notice Throws when the caller of the function is not the pool
error OnlyPool();
/// @notice Throws when the slippage exceeds what the user is comfortable with
error ExcessiveSlippage();
/// @notice Throws when a transfer is unsuccessful
error UnsuccessfulTransfer();
// Methods
/// @notice This function is called after a user calls IUniV3PairManager#mint function
/// It ensures that any tokens owed to the pool are paid by the msg.sender of IUniV3PairManager#mint function
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data The encoded token0, token1, fee (_poolKey) and the payer (msg.sender) of the IUniV3PairManager#mint function
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
/// @notice Mints kLP tokens to an address according to the liquidity the msg.sender provides to the UniswapV3 pool
/// @dev Triggers UniV3PairManager#uniswapV3MintCallback
/// @param amount0Desired The amount of token0 we would like to provide
/// @param amount1Desired The amount of token1 we would like to provide
/// @param amount0Min The minimum amount of token0 we want to provide
/// @param amount1Min The minimum amount of token1 we want to provide
/// @param to The address to which the kLP tokens are going to be minted to
/// @return liquidity kLP tokens sent in exchange for the provision of tokens
function mint(
uint256 amount0Desired,
uint256 amount1Desired,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint128 liquidity);
/// @notice Returns the pair manager's position in the corresponding UniswapV3 pool
/// @return liquidity The amount of liquidity provided to the UniswapV3 pool by the pair manager
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function position()
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Calls the UniswapV3 pool's collect function, which collects up to a maximum amount of fees
// owed to a specific position to the recipient, in this case, that recipient is the pair manager
/// @dev The collected fees will be sent to governance
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect() external returns (uint256 amount0, uint256 amount1);
/// @notice Burns the corresponding amount of kLP tokens from the msg.sender and withdraws the specified liquidity
// in the entire range
/// @param liquidity The amount of liquidity to be burned
/// @param amount0Min The minimum amount of token0 we want to send to the recipient (to)
/// @param amount1Min The minimum amount of token1 we want to send to the recipient (to)
/// @param to The address that will receive the due fees
/// @return amount0 The calculated amount of token0 that will be sent to the recipient
/// @return amount1 The calculated amount of token1 that will be sent to the recipient
function burn(
uint128 liquidity,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint256 amount0, uint256 amount1);
} | /// @title Pair Manager contract
/// @notice Creates a UniswapV3 position, and tokenizes in an ERC20 manner
/// so that the user can use it as liquidity for a Keep3rJob | NatSpecSingleLine | sqrtRatioAX96 | function sqrtRatioAX96() external view returns (uint160 _sqrtPriceA96);
| /// @notice The sqrtRatioAX96 at the lowest tick (-887200) of the Uniswap pool
/// @return _sqrtPriceA96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the lowest tick | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
856,
929
]
} | 7,351 |
||
UniV3PairManagerFactory | solidity/interfaces/IUniV3PairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IUniV3PairManager | interface IUniV3PairManager is IGovernable, IPairManager {
// Structs
/// @notice The data to be decoded by the UniswapV3MintCallback function
struct MintCallbackData {
PoolAddress.PoolKey _poolKey; // Struct that contains token0, token1, and fee of the pool passed into the constructor
address payer; // The address of the payer, which will be the msg.sender of the mint function
}
// Variables
/// @notice The fee of the Uniswap pool passed into the constructor
/// @return _fee The fee of the Uniswap pool passed into the constructor
function fee() external view returns (uint24 _fee);
/// @notice The sqrtRatioAX96 at the lowest tick (-887200) of the Uniswap pool
/// @return _sqrtPriceA96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the lowest tick
function sqrtRatioAX96() external view returns (uint160 _sqrtPriceA96);
/// @notice The sqrtRatioBX96 at the highest tick (887200) of the Uniswap pool
/// @return _sqrtPriceBX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the highest tick
function sqrtRatioBX96() external view returns (uint160 _sqrtPriceBX96);
// Errors
/// @notice Throws when the caller of the function is not the pool
error OnlyPool();
/// @notice Throws when the slippage exceeds what the user is comfortable with
error ExcessiveSlippage();
/// @notice Throws when a transfer is unsuccessful
error UnsuccessfulTransfer();
// Methods
/// @notice This function is called after a user calls IUniV3PairManager#mint function
/// It ensures that any tokens owed to the pool are paid by the msg.sender of IUniV3PairManager#mint function
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data The encoded token0, token1, fee (_poolKey) and the payer (msg.sender) of the IUniV3PairManager#mint function
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
/// @notice Mints kLP tokens to an address according to the liquidity the msg.sender provides to the UniswapV3 pool
/// @dev Triggers UniV3PairManager#uniswapV3MintCallback
/// @param amount0Desired The amount of token0 we would like to provide
/// @param amount1Desired The amount of token1 we would like to provide
/// @param amount0Min The minimum amount of token0 we want to provide
/// @param amount1Min The minimum amount of token1 we want to provide
/// @param to The address to which the kLP tokens are going to be minted to
/// @return liquidity kLP tokens sent in exchange for the provision of tokens
function mint(
uint256 amount0Desired,
uint256 amount1Desired,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint128 liquidity);
/// @notice Returns the pair manager's position in the corresponding UniswapV3 pool
/// @return liquidity The amount of liquidity provided to the UniswapV3 pool by the pair manager
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function position()
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Calls the UniswapV3 pool's collect function, which collects up to a maximum amount of fees
// owed to a specific position to the recipient, in this case, that recipient is the pair manager
/// @dev The collected fees will be sent to governance
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect() external returns (uint256 amount0, uint256 amount1);
/// @notice Burns the corresponding amount of kLP tokens from the msg.sender and withdraws the specified liquidity
// in the entire range
/// @param liquidity The amount of liquidity to be burned
/// @param amount0Min The minimum amount of token0 we want to send to the recipient (to)
/// @param amount1Min The minimum amount of token1 we want to send to the recipient (to)
/// @param to The address that will receive the due fees
/// @return amount0 The calculated amount of token0 that will be sent to the recipient
/// @return amount1 The calculated amount of token1 that will be sent to the recipient
function burn(
uint128 liquidity,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint256 amount0, uint256 amount1);
} | /// @title Pair Manager contract
/// @notice Creates a UniswapV3 position, and tokenizes in an ERC20 manner
/// so that the user can use it as liquidity for a Keep3rJob | NatSpecSingleLine | sqrtRatioBX96 | function sqrtRatioBX96() external view returns (uint160 _sqrtPriceBX96);
| /// @notice The sqrtRatioBX96 at the highest tick (887200) of the Uniswap pool
/// @return _sqrtPriceBX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the highest tick | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
1172,
1246
]
} | 7,352 |
||
UniV3PairManagerFactory | solidity/interfaces/IUniV3PairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IUniV3PairManager | interface IUniV3PairManager is IGovernable, IPairManager {
// Structs
/// @notice The data to be decoded by the UniswapV3MintCallback function
struct MintCallbackData {
PoolAddress.PoolKey _poolKey; // Struct that contains token0, token1, and fee of the pool passed into the constructor
address payer; // The address of the payer, which will be the msg.sender of the mint function
}
// Variables
/// @notice The fee of the Uniswap pool passed into the constructor
/// @return _fee The fee of the Uniswap pool passed into the constructor
function fee() external view returns (uint24 _fee);
/// @notice The sqrtRatioAX96 at the lowest tick (-887200) of the Uniswap pool
/// @return _sqrtPriceA96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the lowest tick
function sqrtRatioAX96() external view returns (uint160 _sqrtPriceA96);
/// @notice The sqrtRatioBX96 at the highest tick (887200) of the Uniswap pool
/// @return _sqrtPriceBX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the highest tick
function sqrtRatioBX96() external view returns (uint160 _sqrtPriceBX96);
// Errors
/// @notice Throws when the caller of the function is not the pool
error OnlyPool();
/// @notice Throws when the slippage exceeds what the user is comfortable with
error ExcessiveSlippage();
/// @notice Throws when a transfer is unsuccessful
error UnsuccessfulTransfer();
// Methods
/// @notice This function is called after a user calls IUniV3PairManager#mint function
/// It ensures that any tokens owed to the pool are paid by the msg.sender of IUniV3PairManager#mint function
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data The encoded token0, token1, fee (_poolKey) and the payer (msg.sender) of the IUniV3PairManager#mint function
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
/// @notice Mints kLP tokens to an address according to the liquidity the msg.sender provides to the UniswapV3 pool
/// @dev Triggers UniV3PairManager#uniswapV3MintCallback
/// @param amount0Desired The amount of token0 we would like to provide
/// @param amount1Desired The amount of token1 we would like to provide
/// @param amount0Min The minimum amount of token0 we want to provide
/// @param amount1Min The minimum amount of token1 we want to provide
/// @param to The address to which the kLP tokens are going to be minted to
/// @return liquidity kLP tokens sent in exchange for the provision of tokens
function mint(
uint256 amount0Desired,
uint256 amount1Desired,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint128 liquidity);
/// @notice Returns the pair manager's position in the corresponding UniswapV3 pool
/// @return liquidity The amount of liquidity provided to the UniswapV3 pool by the pair manager
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function position()
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Calls the UniswapV3 pool's collect function, which collects up to a maximum amount of fees
// owed to a specific position to the recipient, in this case, that recipient is the pair manager
/// @dev The collected fees will be sent to governance
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect() external returns (uint256 amount0, uint256 amount1);
/// @notice Burns the corresponding amount of kLP tokens from the msg.sender and withdraws the specified liquidity
// in the entire range
/// @param liquidity The amount of liquidity to be burned
/// @param amount0Min The minimum amount of token0 we want to send to the recipient (to)
/// @param amount1Min The minimum amount of token1 we want to send to the recipient (to)
/// @param to The address that will receive the due fees
/// @return amount0 The calculated amount of token0 that will be sent to the recipient
/// @return amount1 The calculated amount of token1 that will be sent to the recipient
function burn(
uint128 liquidity,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint256 amount0, uint256 amount1);
} | /// @title Pair Manager contract
/// @notice Creates a UniswapV3 position, and tokenizes in an ERC20 manner
/// so that the user can use it as liquidity for a Keep3rJob | NatSpecSingleLine | uniswapV3MintCallback | function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
| /// @notice This function is called after a user calls IUniV3PairManager#mint function
/// It ensures that any tokens owed to the pool are paid by the msg.sender of IUniV3PairManager#mint function
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data The encoded token0, token1, fee (_poolKey) and the payer (msg.sender) of the IUniV3PairManager#mint function | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
2072,
2193
]
} | 7,353 |
||
UniV3PairManagerFactory | solidity/interfaces/IUniV3PairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IUniV3PairManager | interface IUniV3PairManager is IGovernable, IPairManager {
// Structs
/// @notice The data to be decoded by the UniswapV3MintCallback function
struct MintCallbackData {
PoolAddress.PoolKey _poolKey; // Struct that contains token0, token1, and fee of the pool passed into the constructor
address payer; // The address of the payer, which will be the msg.sender of the mint function
}
// Variables
/// @notice The fee of the Uniswap pool passed into the constructor
/// @return _fee The fee of the Uniswap pool passed into the constructor
function fee() external view returns (uint24 _fee);
/// @notice The sqrtRatioAX96 at the lowest tick (-887200) of the Uniswap pool
/// @return _sqrtPriceA96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the lowest tick
function sqrtRatioAX96() external view returns (uint160 _sqrtPriceA96);
/// @notice The sqrtRatioBX96 at the highest tick (887200) of the Uniswap pool
/// @return _sqrtPriceBX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the highest tick
function sqrtRatioBX96() external view returns (uint160 _sqrtPriceBX96);
// Errors
/// @notice Throws when the caller of the function is not the pool
error OnlyPool();
/// @notice Throws when the slippage exceeds what the user is comfortable with
error ExcessiveSlippage();
/// @notice Throws when a transfer is unsuccessful
error UnsuccessfulTransfer();
// Methods
/// @notice This function is called after a user calls IUniV3PairManager#mint function
/// It ensures that any tokens owed to the pool are paid by the msg.sender of IUniV3PairManager#mint function
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data The encoded token0, token1, fee (_poolKey) and the payer (msg.sender) of the IUniV3PairManager#mint function
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
/// @notice Mints kLP tokens to an address according to the liquidity the msg.sender provides to the UniswapV3 pool
/// @dev Triggers UniV3PairManager#uniswapV3MintCallback
/// @param amount0Desired The amount of token0 we would like to provide
/// @param amount1Desired The amount of token1 we would like to provide
/// @param amount0Min The minimum amount of token0 we want to provide
/// @param amount1Min The minimum amount of token1 we want to provide
/// @param to The address to which the kLP tokens are going to be minted to
/// @return liquidity kLP tokens sent in exchange for the provision of tokens
function mint(
uint256 amount0Desired,
uint256 amount1Desired,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint128 liquidity);
/// @notice Returns the pair manager's position in the corresponding UniswapV3 pool
/// @return liquidity The amount of liquidity provided to the UniswapV3 pool by the pair manager
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function position()
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Calls the UniswapV3 pool's collect function, which collects up to a maximum amount of fees
// owed to a specific position to the recipient, in this case, that recipient is the pair manager
/// @dev The collected fees will be sent to governance
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect() external returns (uint256 amount0, uint256 amount1);
/// @notice Burns the corresponding amount of kLP tokens from the msg.sender and withdraws the specified liquidity
// in the entire range
/// @param liquidity The amount of liquidity to be burned
/// @param amount0Min The minimum amount of token0 we want to send to the recipient (to)
/// @param amount1Min The minimum amount of token1 we want to send to the recipient (to)
/// @param to The address that will receive the due fees
/// @return amount0 The calculated amount of token0 that will be sent to the recipient
/// @return amount1 The calculated amount of token1 that will be sent to the recipient
function burn(
uint128 liquidity,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint256 amount0, uint256 amount1);
} | /// @title Pair Manager contract
/// @notice Creates a UniswapV3 position, and tokenizes in an ERC20 manner
/// so that the user can use it as liquidity for a Keep3rJob | NatSpecSingleLine | mint | function mint(
uint256 amount0Desired,
uint256 amount1Desired,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint128 liquidity);
| /// @notice Mints kLP tokens to an address according to the liquidity the msg.sender provides to the UniswapV3 pool
/// @dev Triggers UniV3PairManager#uniswapV3MintCallback
/// @param amount0Desired The amount of token0 we would like to provide
/// @param amount1Desired The amount of token1 we would like to provide
/// @param amount0Min The minimum amount of token0 we want to provide
/// @param amount1Min The minimum amount of token1 we want to provide
/// @param to The address to which the kLP tokens are going to be minted to
/// @return liquidity kLP tokens sent in exchange for the provision of tokens | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
2822,
2999
]
} | 7,354 |
||
UniV3PairManagerFactory | solidity/interfaces/IUniV3PairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IUniV3PairManager | interface IUniV3PairManager is IGovernable, IPairManager {
// Structs
/// @notice The data to be decoded by the UniswapV3MintCallback function
struct MintCallbackData {
PoolAddress.PoolKey _poolKey; // Struct that contains token0, token1, and fee of the pool passed into the constructor
address payer; // The address of the payer, which will be the msg.sender of the mint function
}
// Variables
/// @notice The fee of the Uniswap pool passed into the constructor
/// @return _fee The fee of the Uniswap pool passed into the constructor
function fee() external view returns (uint24 _fee);
/// @notice The sqrtRatioAX96 at the lowest tick (-887200) of the Uniswap pool
/// @return _sqrtPriceA96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the lowest tick
function sqrtRatioAX96() external view returns (uint160 _sqrtPriceA96);
/// @notice The sqrtRatioBX96 at the highest tick (887200) of the Uniswap pool
/// @return _sqrtPriceBX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the highest tick
function sqrtRatioBX96() external view returns (uint160 _sqrtPriceBX96);
// Errors
/// @notice Throws when the caller of the function is not the pool
error OnlyPool();
/// @notice Throws when the slippage exceeds what the user is comfortable with
error ExcessiveSlippage();
/// @notice Throws when a transfer is unsuccessful
error UnsuccessfulTransfer();
// Methods
/// @notice This function is called after a user calls IUniV3PairManager#mint function
/// It ensures that any tokens owed to the pool are paid by the msg.sender of IUniV3PairManager#mint function
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data The encoded token0, token1, fee (_poolKey) and the payer (msg.sender) of the IUniV3PairManager#mint function
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
/// @notice Mints kLP tokens to an address according to the liquidity the msg.sender provides to the UniswapV3 pool
/// @dev Triggers UniV3PairManager#uniswapV3MintCallback
/// @param amount0Desired The amount of token0 we would like to provide
/// @param amount1Desired The amount of token1 we would like to provide
/// @param amount0Min The minimum amount of token0 we want to provide
/// @param amount1Min The minimum amount of token1 we want to provide
/// @param to The address to which the kLP tokens are going to be minted to
/// @return liquidity kLP tokens sent in exchange for the provision of tokens
function mint(
uint256 amount0Desired,
uint256 amount1Desired,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint128 liquidity);
/// @notice Returns the pair manager's position in the corresponding UniswapV3 pool
/// @return liquidity The amount of liquidity provided to the UniswapV3 pool by the pair manager
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function position()
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Calls the UniswapV3 pool's collect function, which collects up to a maximum amount of fees
// owed to a specific position to the recipient, in this case, that recipient is the pair manager
/// @dev The collected fees will be sent to governance
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect() external returns (uint256 amount0, uint256 amount1);
/// @notice Burns the corresponding amount of kLP tokens from the msg.sender and withdraws the specified liquidity
// in the entire range
/// @param liquidity The amount of liquidity to be burned
/// @param amount0Min The minimum amount of token0 we want to send to the recipient (to)
/// @param amount1Min The minimum amount of token1 we want to send to the recipient (to)
/// @param to The address that will receive the due fees
/// @return amount0 The calculated amount of token0 that will be sent to the recipient
/// @return amount1 The calculated amount of token1 that will be sent to the recipient
function burn(
uint128 liquidity,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint256 amount0, uint256 amount1);
} | /// @title Pair Manager contract
/// @notice Creates a UniswapV3 position, and tokenizes in an ERC20 manner
/// so that the user can use it as liquidity for a Keep3rJob | NatSpecSingleLine | position | function position()
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
| /// @notice Returns the pair manager's position in the corresponding UniswapV3 pool
/// @return liquidity The amount of liquidity provided to the UniswapV3 pool by the pair manager
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
3626,
3848
]
} | 7,355 |
||
UniV3PairManagerFactory | solidity/interfaces/IUniV3PairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IUniV3PairManager | interface IUniV3PairManager is IGovernable, IPairManager {
// Structs
/// @notice The data to be decoded by the UniswapV3MintCallback function
struct MintCallbackData {
PoolAddress.PoolKey _poolKey; // Struct that contains token0, token1, and fee of the pool passed into the constructor
address payer; // The address of the payer, which will be the msg.sender of the mint function
}
// Variables
/// @notice The fee of the Uniswap pool passed into the constructor
/// @return _fee The fee of the Uniswap pool passed into the constructor
function fee() external view returns (uint24 _fee);
/// @notice The sqrtRatioAX96 at the lowest tick (-887200) of the Uniswap pool
/// @return _sqrtPriceA96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the lowest tick
function sqrtRatioAX96() external view returns (uint160 _sqrtPriceA96);
/// @notice The sqrtRatioBX96 at the highest tick (887200) of the Uniswap pool
/// @return _sqrtPriceBX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the highest tick
function sqrtRatioBX96() external view returns (uint160 _sqrtPriceBX96);
// Errors
/// @notice Throws when the caller of the function is not the pool
error OnlyPool();
/// @notice Throws when the slippage exceeds what the user is comfortable with
error ExcessiveSlippage();
/// @notice Throws when a transfer is unsuccessful
error UnsuccessfulTransfer();
// Methods
/// @notice This function is called after a user calls IUniV3PairManager#mint function
/// It ensures that any tokens owed to the pool are paid by the msg.sender of IUniV3PairManager#mint function
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data The encoded token0, token1, fee (_poolKey) and the payer (msg.sender) of the IUniV3PairManager#mint function
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
/// @notice Mints kLP tokens to an address according to the liquidity the msg.sender provides to the UniswapV3 pool
/// @dev Triggers UniV3PairManager#uniswapV3MintCallback
/// @param amount0Desired The amount of token0 we would like to provide
/// @param amount1Desired The amount of token1 we would like to provide
/// @param amount0Min The minimum amount of token0 we want to provide
/// @param amount1Min The minimum amount of token1 we want to provide
/// @param to The address to which the kLP tokens are going to be minted to
/// @return liquidity kLP tokens sent in exchange for the provision of tokens
function mint(
uint256 amount0Desired,
uint256 amount1Desired,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint128 liquidity);
/// @notice Returns the pair manager's position in the corresponding UniswapV3 pool
/// @return liquidity The amount of liquidity provided to the UniswapV3 pool by the pair manager
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function position()
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Calls the UniswapV3 pool's collect function, which collects up to a maximum amount of fees
// owed to a specific position to the recipient, in this case, that recipient is the pair manager
/// @dev The collected fees will be sent to governance
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect() external returns (uint256 amount0, uint256 amount1);
/// @notice Burns the corresponding amount of kLP tokens from the msg.sender and withdraws the specified liquidity
// in the entire range
/// @param liquidity The amount of liquidity to be burned
/// @param amount0Min The minimum amount of token0 we want to send to the recipient (to)
/// @param amount1Min The minimum amount of token1 we want to send to the recipient (to)
/// @param to The address that will receive the due fees
/// @return amount0 The calculated amount of token0 that will be sent to the recipient
/// @return amount1 The calculated amount of token1 that will be sent to the recipient
function burn(
uint128 liquidity,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint256 amount0, uint256 amount1);
} | /// @title Pair Manager contract
/// @notice Creates a UniswapV3 position, and tokenizes in an ERC20 manner
/// so that the user can use it as liquidity for a Keep3rJob | NatSpecSingleLine | collect | function collect() external returns (uint256 amount0, uint256 amount1);
| /// @dev The collected fees will be sent to governance
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1 | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
4243,
4316
]
} | 7,356 |
||
UniV3PairManagerFactory | solidity/interfaces/IUniV3PairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IUniV3PairManager | interface IUniV3PairManager is IGovernable, IPairManager {
// Structs
/// @notice The data to be decoded by the UniswapV3MintCallback function
struct MintCallbackData {
PoolAddress.PoolKey _poolKey; // Struct that contains token0, token1, and fee of the pool passed into the constructor
address payer; // The address of the payer, which will be the msg.sender of the mint function
}
// Variables
/// @notice The fee of the Uniswap pool passed into the constructor
/// @return _fee The fee of the Uniswap pool passed into the constructor
function fee() external view returns (uint24 _fee);
/// @notice The sqrtRatioAX96 at the lowest tick (-887200) of the Uniswap pool
/// @return _sqrtPriceA96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the lowest tick
function sqrtRatioAX96() external view returns (uint160 _sqrtPriceA96);
/// @notice The sqrtRatioBX96 at the highest tick (887200) of the Uniswap pool
/// @return _sqrtPriceBX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the highest tick
function sqrtRatioBX96() external view returns (uint160 _sqrtPriceBX96);
// Errors
/// @notice Throws when the caller of the function is not the pool
error OnlyPool();
/// @notice Throws when the slippage exceeds what the user is comfortable with
error ExcessiveSlippage();
/// @notice Throws when a transfer is unsuccessful
error UnsuccessfulTransfer();
// Methods
/// @notice This function is called after a user calls IUniV3PairManager#mint function
/// It ensures that any tokens owed to the pool are paid by the msg.sender of IUniV3PairManager#mint function
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data The encoded token0, token1, fee (_poolKey) and the payer (msg.sender) of the IUniV3PairManager#mint function
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
/// @notice Mints kLP tokens to an address according to the liquidity the msg.sender provides to the UniswapV3 pool
/// @dev Triggers UniV3PairManager#uniswapV3MintCallback
/// @param amount0Desired The amount of token0 we would like to provide
/// @param amount1Desired The amount of token1 we would like to provide
/// @param amount0Min The minimum amount of token0 we want to provide
/// @param amount1Min The minimum amount of token1 we want to provide
/// @param to The address to which the kLP tokens are going to be minted to
/// @return liquidity kLP tokens sent in exchange for the provision of tokens
function mint(
uint256 amount0Desired,
uint256 amount1Desired,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint128 liquidity);
/// @notice Returns the pair manager's position in the corresponding UniswapV3 pool
/// @return liquidity The amount of liquidity provided to the UniswapV3 pool by the pair manager
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function position()
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Calls the UniswapV3 pool's collect function, which collects up to a maximum amount of fees
// owed to a specific position to the recipient, in this case, that recipient is the pair manager
/// @dev The collected fees will be sent to governance
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect() external returns (uint256 amount0, uint256 amount1);
/// @notice Burns the corresponding amount of kLP tokens from the msg.sender and withdraws the specified liquidity
// in the entire range
/// @param liquidity The amount of liquidity to be burned
/// @param amount0Min The minimum amount of token0 we want to send to the recipient (to)
/// @param amount1Min The minimum amount of token1 we want to send to the recipient (to)
/// @param to The address that will receive the due fees
/// @return amount0 The calculated amount of token0 that will be sent to the recipient
/// @return amount1 The calculated amount of token1 that will be sent to the recipient
function burn(
uint128 liquidity,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint256 amount0, uint256 amount1);
} | /// @title Pair Manager contract
/// @notice Creates a UniswapV3 position, and tokenizes in an ERC20 manner
/// so that the user can use it as liquidity for a Keep3rJob | NatSpecSingleLine | burn | function burn(
uint128 liquidity,
uint256 amount0Min,
uint256 amount1Min,
address to
) external returns (uint256 amount0, uint256 amount1);
| /// @param liquidity The amount of liquidity to be burned
/// @param amount0Min The minimum amount of token0 we want to send to the recipient (to)
/// @param amount1Min The minimum amount of token1 we want to send to the recipient (to)
/// @param to The address that will receive the due fees
/// @return amount0 The calculated amount of token0 that will be sent to the recipient
/// @return amount1 The calculated amount of token1 that will be sent to the recipient | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
4948,
5107
]
} | 7,357 |
||
UniV3PairManagerFactory | solidity/interfaces/IPairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IPairManager | interface IPairManager is IERC20Metadata {
/// @notice Address of the pool from which the Keep3r pair manager will interact with
/// @return _pool The pool's address
function pool() external view returns (address _pool);
/// @notice Token0 of the pool
/// @return _token0 The address of token0
function token0() external view returns (address _token0);
/// @notice Token1 of the pool
/// @return _token1 The address of token1
function token1() external view returns (address _token1);
} | /// @title Pair Manager interface
/// @notice Generic interface for Keep3r liquidity pools (kLP) | NatSpecSingleLine | pool | function pool() external view returns (address _pool);
| /// @notice Address of the pool from which the Keep3r pair manager will interact with
/// @return _pool The pool's address | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
170,
226
]
} | 7,358 |
||
UniV3PairManagerFactory | solidity/interfaces/IPairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IPairManager | interface IPairManager is IERC20Metadata {
/// @notice Address of the pool from which the Keep3r pair manager will interact with
/// @return _pool The pool's address
function pool() external view returns (address _pool);
/// @notice Token0 of the pool
/// @return _token0 The address of token0
function token0() external view returns (address _token0);
/// @notice Token1 of the pool
/// @return _token1 The address of token1
function token1() external view returns (address _token1);
} | /// @title Pair Manager interface
/// @notice Generic interface for Keep3r liquidity pools (kLP) | NatSpecSingleLine | token0 | function token0() external view returns (address _token0);
| /// @notice Token0 of the pool
/// @return _token0 The address of token0 | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
305,
365
]
} | 7,359 |
||
UniV3PairManagerFactory | solidity/interfaces/IPairManager.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | IPairManager | interface IPairManager is IERC20Metadata {
/// @notice Address of the pool from which the Keep3r pair manager will interact with
/// @return _pool The pool's address
function pool() external view returns (address _pool);
/// @notice Token0 of the pool
/// @return _token0 The address of token0
function token0() external view returns (address _token0);
/// @notice Token1 of the pool
/// @return _token1 The address of token1
function token1() external view returns (address _token1);
} | /// @title Pair Manager interface
/// @notice Generic interface for Keep3r liquidity pools (kLP) | NatSpecSingleLine | token1 | function token1() external view returns (address _token1);
| /// @notice Token1 of the pool
/// @return _token1 The address of token1 | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
444,
504
]
} | 7,360 |
||
UniV3PairManagerFactory | solidity/contracts/peripherals/Governable.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | Governable | abstract contract Governable is IGovernable {
/// @inheritdoc IGovernable
address public override governance;
/// @inheritdoc IGovernable
address public override pendingGovernance;
constructor(address _governance) {
if (_governance == address(0)) revert NoGovernanceZeroAddress();
governance = _governance;
}
/// @inheritdoc IGovernable
function setGovernance(address _governance) external override onlyGovernance {
pendingGovernance = _governance;
emit GovernanceProposal(_governance);
}
/// @inheritdoc IGovernable
function acceptGovernance() external override onlyPendingGovernance {
governance = pendingGovernance;
delete pendingGovernance;
emit GovernanceSet(governance);
}
/// @notice Functions with this modifier can only be called by governance
modifier onlyGovernance {
if (msg.sender != governance) revert OnlyGovernance();
_;
}
/// @notice Functions with this modifier can only be called by pendingGovernance
modifier onlyPendingGovernance {
if (msg.sender != pendingGovernance) revert OnlyPendingGovernance();
_;
}
} | setGovernance | function setGovernance(address _governance) external override onlyGovernance {
pendingGovernance = _governance;
emit GovernanceProposal(_governance);
}
| /// @inheritdoc IGovernable | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
362,
525
]
} | 7,361 |
||||
UniV3PairManagerFactory | solidity/contracts/peripherals/Governable.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | Governable | abstract contract Governable is IGovernable {
/// @inheritdoc IGovernable
address public override governance;
/// @inheritdoc IGovernable
address public override pendingGovernance;
constructor(address _governance) {
if (_governance == address(0)) revert NoGovernanceZeroAddress();
governance = _governance;
}
/// @inheritdoc IGovernable
function setGovernance(address _governance) external override onlyGovernance {
pendingGovernance = _governance;
emit GovernanceProposal(_governance);
}
/// @inheritdoc IGovernable
function acceptGovernance() external override onlyPendingGovernance {
governance = pendingGovernance;
delete pendingGovernance;
emit GovernanceSet(governance);
}
/// @notice Functions with this modifier can only be called by governance
modifier onlyGovernance {
if (msg.sender != governance) revert OnlyGovernance();
_;
}
/// @notice Functions with this modifier can only be called by pendingGovernance
modifier onlyPendingGovernance {
if (msg.sender != pendingGovernance) revert OnlyPendingGovernance();
_;
}
} | acceptGovernance | function acceptGovernance() external override onlyPendingGovernance {
governance = pendingGovernance;
delete pendingGovernance;
emit GovernanceSet(governance);
}
| /// @inheritdoc IGovernable | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
557,
734
]
} | 7,362 |
||||
UniV3PairManagerFactory | solidity/contracts/UniV3PairManagerFactory.sol | 0x005634cfef45e5a19c84aede6f0af17833471852 | Solidity | UniV3PairManagerFactory | contract UniV3PairManagerFactory is IPairManagerFactory, Governable {
mapping(address => address) public override pairManagers;
constructor() Governable(msg.sender) {}
///@inheritdoc IPairManagerFactory
function createPairManager(address _pool) external override returns (address _pairManager) {
if (pairManagers[_pool] != address(0)) revert AlreadyInitialized();
_pairManager = address(new UniV3PairManager(_pool, governance));
pairManagers[_pool] = _pairManager;
emit PairCreated(_pool, _pairManager);
}
} | /// @title Factory of Pair Managers
/// @notice This contract creates new pair managers | NatSpecSingleLine | createPairManager | function createPairManager(address _pool) external override returns (address _pairManager) {
if (pairManagers[_pool] != address(0)) revert AlreadyInitialized();
_pairManager = address(new UniV3PairManager(_pool, governance));
pairManagers[_pool] = _pairManager;
emit PairCreated(_pool, _pairManager);
}
| ///@inheritdoc IPairManagerFactory | NatSpecSingleLine | v0.8.7+commit.e28d00a7 | {
"func_code_index": [
211,
533
]
} | 7,363 |
||
RetailLoyaltySystemToken | RetailLoyaltySystemToken.sol | 0xaabf1b6e4fbebb239e8a16deea11947bbcd1024a | Solidity | RetailLoyaltySystemBase | contract RetailLoyaltySystemBase is ERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*/
function RetailLoyaltySystemBase(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) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
/**
* 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;
}
/**
* 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) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
/**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
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;
}
} | RetailLoyaltySystemBase | function RetailLoyaltySystemBase(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
}
| /**
* Constructor function
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0833bb46dc7496f12ea9807cc3cd3ddf3452d26058e39f8d6c4193100545a4c7 | {
"func_code_index": [
525,
1104
]
} | 7,364 |
|||
RetailLoyaltySystemToken | RetailLoyaltySystemToken.sol | 0xaabf1b6e4fbebb239e8a16deea11947bbcd1024a | Solidity | RetailLoyaltySystemBase | contract RetailLoyaltySystemBase is ERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*/
function RetailLoyaltySystemBase(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) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
/**
* 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;
}
/**
* 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) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
/**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
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;
}
} | _transfer | 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;
}
| /**
* Internal transfer, only can be called by this contract
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0833bb46dc7496f12ea9807cc3cd3ddf3452d26058e39f8d6c4193100545a4c7 | {
"func_code_index": [
1447,
2318
]
} | 7,365 |
|||
RetailLoyaltySystemToken | RetailLoyaltySystemToken.sol | 0xaabf1b6e4fbebb239e8a16deea11947bbcd1024a | Solidity | RetailLoyaltySystemBase | contract RetailLoyaltySystemBase is ERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*/
function RetailLoyaltySystemBase(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) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
/**
* 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;
}
/**
* 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) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
/**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
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;
}
} | transfer | function transfer(address _to, uint256 _value) public returns(bool) {
return _transfer(msg.sender, _to, _value);
}
| /**
* Transfer tokens
*
* Send `_value` tokens to `_to` from your account
*
* @param _to The address of the recipient
* @param _value the amount to send
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0833bb46dc7496f12ea9807cc3cd3ddf3452d26058e39f8d6c4193100545a4c7 | {
"func_code_index": [
2524,
2657
]
} | 7,366 |
|||
RetailLoyaltySystemToken | RetailLoyaltySystemToken.sol | 0xaabf1b6e4fbebb239e8a16deea11947bbcd1024a | Solidity | RetailLoyaltySystemBase | contract RetailLoyaltySystemBase is ERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*/
function RetailLoyaltySystemBase(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) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
/**
* 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;
}
/**
* 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) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
/**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
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;
}
} | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns(bool) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _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
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0833bb46dc7496f12ea9807cc3cd3ddf3452d26058e39f8d6c4193100545a4c7 | {
"func_code_index": [
2932,
3211
]
} | 7,367 |
|||
RetailLoyaltySystemToken | RetailLoyaltySystemToken.sol | 0xaabf1b6e4fbebb239e8a16deea11947bbcd1024a | Solidity | RetailLoyaltySystemBase | contract RetailLoyaltySystemBase is ERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*/
function RetailLoyaltySystemBase(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) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
/**
* 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;
}
/**
* 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) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
/**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
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;
}
} | approve | function approve(address _spender, uint256 _value) public returns(bool) {
allowances[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _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
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0833bb46dc7496f12ea9807cc3cd3ddf3452d26058e39f8d6c4193100545a4c7 | {
"func_code_index": [
3475,
3683
]
} | 7,368 |
|||
RetailLoyaltySystemToken | RetailLoyaltySystemToken.sol | 0xaabf1b6e4fbebb239e8a16deea11947bbcd1024a | Solidity | RetailLoyaltySystemBase | contract RetailLoyaltySystemBase is ERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*/
function RetailLoyaltySystemBase(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) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
/**
* 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;
}
/**
* 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) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
/**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
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;
}
} | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns(bool) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
| /**
* 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
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0833bb46dc7496f12ea9807cc3cd3ddf3452d26058e39f8d6c4193100545a4c7 | {
"func_code_index": [
4077,
4429
]
} | 7,369 |
|||
RetailLoyaltySystemToken | RetailLoyaltySystemToken.sol | 0xaabf1b6e4fbebb239e8a16deea11947bbcd1024a | Solidity | RetailLoyaltySystemBase | contract RetailLoyaltySystemBase is ERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*/
function RetailLoyaltySystemBase(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) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
/**
* 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;
}
/**
* 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) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
/**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
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;
}
} | burn | function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
| /**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0833bb46dc7496f12ea9807cc3cd3ddf3452d26058e39f8d6c4193100545a4c7 | {
"func_code_index": [
4599,
4962
]
} | 7,370 |
|||
RetailLoyaltySystemToken | RetailLoyaltySystemToken.sol | 0xaabf1b6e4fbebb239e8a16deea11947bbcd1024a | Solidity | RetailLoyaltySystemBase | contract RetailLoyaltySystemBase is ERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*/
function RetailLoyaltySystemBase(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) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
/**
* 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;
}
/**
* 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) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
/**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
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;
}
} | burnFrom | function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
| /**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0833bb46dc7496f12ea9807cc3cd3ddf3452d26058e39f8d6c4193100545a4c7 | {
"func_code_index": [
5220,
5822
]
} | 7,371 |
|||
RetailLoyaltySystemToken | RetailLoyaltySystemToken.sol | 0xaabf1b6e4fbebb239e8a16deea11947bbcd1024a | Solidity | RetailLoyaltySystemBase | contract RetailLoyaltySystemBase is ERC20 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
// Balances
mapping (address => uint256) balances;
// Allowances
mapping (address => mapping (address => uint256)) allowances;
// ----- Events -----
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*/
function RetailLoyaltySystemBase(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) {
require(_value <= allowances[_from][msg.sender]); // Check allowance
allowances[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
/**
* 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;
}
/**
* 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) {
if (approve(_spender, _value)) {
TokenRecipient spender = TokenRecipient(_spender);
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
return false;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns(bool) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowances[_from][msg.sender]); // Check allowance
balances[_from] -= _value; // Subtract from the targeted balance
allowances[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
Burn(_from, _value);
return true;
}
/**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
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;
}
} | increaseApproval | 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;
}
| /**
* approve should be called when allowances[_spender] == 0. To increment
* allowances value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://0833bb46dc7496f12ea9807cc3cd3ddf3452d26058e39f8d6c4193100545a4c7 | {
"func_code_index": [
6085,
6472
]
} | 7,372 |
|||
KevTAMA | KevTAMA.sol | 0x371709ae8413ce755dc7ec5aec061700509c5a9e | Solidity | KevTAMA | contract KevTAMA is Context, IERC20, Ownable {
using SafeMath for uint256;
string private constant _name = "KevTAMA";
string private constant _symbol = "KEVTAMA";
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 = 1000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _redisFeeOnBuy = 0;
uint256 private _taxFeeOnBuy = 10;
uint256 private _redisFeeOnSell = 0;
uint256 private _taxFeeOnSell = 10;
//Original Fee
uint256 private _redisFee = _redisFeeOnSell;
uint256 private _taxFee = _taxFeeOnSell;
uint256 private _previousredisFee = _redisFee;
uint256 private _previoustaxFee = _taxFee;
mapping(address => bool) public bots; mapping (address => uint256) public _buyMap;
address payable private _developmentAddress = payable(0xe1CF1Ad71dcd3f077793192e955decb635cB844C);
address payable private _marketingAddress = payable(0xDF63Be20c1D3983F9B66663a2529D62f98aCc0f2);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = true;
uint256 public _maxTxAmount = 10000000 * 10**9;
uint256 public _maxWalletSize = 40000000 * 10**9;
uint256 public _swapTokensAtAmount = 10000 * 10**9;
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);//
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_developmentAddress] = true;
_isExcludedFromFee[_marketingAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function 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 (_redisFee == 0 && _taxFee == 0) return;
_previousredisFee = _redisFee;
_previoustaxFee = _taxFee;
_redisFee = 0;
_taxFee = 0;
}
function restoreAllFee() private {
_redisFee = _previousredisFee;
_taxFee = _previoustaxFee;
}
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()) {
//Trade start check
if (!tradingOpen) {
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
}
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
if(to != uniswapV2Pair) {
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
//Transfer Tokens
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
takeFee = false;
} else {
//Set Fee for Buys
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_redisFee = _redisFeeOnBuy;
_taxFee = _taxFeeOnBuy;
}
//Set Fee for Sells
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_redisFee = _redisFeeOnSell;
_taxFee = _taxFeeOnSell;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_marketingAddress.transfer(amount);
}
function setTrading(bool _tradingOpen) public onlyOwner {
tradingOpen = _tradingOpen;
}
function manualswap() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function blockBots(address[] memory bots_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function unblockBot(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 _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _redisFee, _taxFee);
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 redisFee,
uint256 taxFee
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = tAmount.mul(redisFee).div(100);
uint256 tTeam = tAmount.mul(taxFee).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);
}
function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
require(redisFeeOnBuy >= 0 && redisFeeOnBuy <= 2, "Buy rewards must be between 0% and 2%");
require(taxFeeOnBuy >= 0 && taxFeeOnBuy <= 14, "Buy tax must be between 0% and 14%");
require(redisFeeOnSell >= 0 && redisFeeOnSell <= 2, "Sell rewards must be between 0% and 2%");
require(taxFeeOnSell >= 0 && taxFeeOnSell <= 14, "Sell tax must be between 0% and 14%");
_redisFeeOnBuy = redisFeeOnBuy;
_redisFeeOnSell = redisFeeOnSell;
_taxFeeOnBuy = taxFeeOnBuy;
_taxFeeOnSell = taxFeeOnSell;
}
//Set minimum tokens required to swap.
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner {
_swapTokensAtAmount = swapTokensAtAmount;
}
//Set minimum tokens required to swap.
function toggleSwap(bool _swapEnabled) public onlyOwner {
swapEnabled = _swapEnabled;
}
//Set maximum transaction
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
if (maxTxAmount > 10000000 * 10**9) {
_maxTxAmount = maxTxAmount;
}
}
function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner {
_maxWalletSize = maxWalletSize;
}
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFee[accounts[i]] = excluded;
}
}
} | setMinSwapTokensThreshold | function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner {
_swapTokensAtAmount = swapTokensAtAmount;
}
| //Set minimum tokens required to swap. | LineComment | v0.8.9+commit.e5eed63a | Unlicense | ipfs://5fd9e120bb87ee369020df43ced696c5b795ea05fe85b9a82991060544af98bf | {
"func_code_index": [
13156,
13300
]
} | 7,373 |
||
KevTAMA | KevTAMA.sol | 0x371709ae8413ce755dc7ec5aec061700509c5a9e | Solidity | KevTAMA | contract KevTAMA is Context, IERC20, Ownable {
using SafeMath for uint256;
string private constant _name = "KevTAMA";
string private constant _symbol = "KEVTAMA";
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 = 1000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _redisFeeOnBuy = 0;
uint256 private _taxFeeOnBuy = 10;
uint256 private _redisFeeOnSell = 0;
uint256 private _taxFeeOnSell = 10;
//Original Fee
uint256 private _redisFee = _redisFeeOnSell;
uint256 private _taxFee = _taxFeeOnSell;
uint256 private _previousredisFee = _redisFee;
uint256 private _previoustaxFee = _taxFee;
mapping(address => bool) public bots; mapping (address => uint256) public _buyMap;
address payable private _developmentAddress = payable(0xe1CF1Ad71dcd3f077793192e955decb635cB844C);
address payable private _marketingAddress = payable(0xDF63Be20c1D3983F9B66663a2529D62f98aCc0f2);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = true;
uint256 public _maxTxAmount = 10000000 * 10**9;
uint256 public _maxWalletSize = 40000000 * 10**9;
uint256 public _swapTokensAtAmount = 10000 * 10**9;
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);//
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_developmentAddress] = true;
_isExcludedFromFee[_marketingAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function 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 (_redisFee == 0 && _taxFee == 0) return;
_previousredisFee = _redisFee;
_previoustaxFee = _taxFee;
_redisFee = 0;
_taxFee = 0;
}
function restoreAllFee() private {
_redisFee = _previousredisFee;
_taxFee = _previoustaxFee;
}
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()) {
//Trade start check
if (!tradingOpen) {
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
}
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
if(to != uniswapV2Pair) {
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
//Transfer Tokens
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
takeFee = false;
} else {
//Set Fee for Buys
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_redisFee = _redisFeeOnBuy;
_taxFee = _taxFeeOnBuy;
}
//Set Fee for Sells
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_redisFee = _redisFeeOnSell;
_taxFee = _taxFeeOnSell;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_marketingAddress.transfer(amount);
}
function setTrading(bool _tradingOpen) public onlyOwner {
tradingOpen = _tradingOpen;
}
function manualswap() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function blockBots(address[] memory bots_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function unblockBot(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 _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _redisFee, _taxFee);
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 redisFee,
uint256 taxFee
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = tAmount.mul(redisFee).div(100);
uint256 tTeam = tAmount.mul(taxFee).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);
}
function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
require(redisFeeOnBuy >= 0 && redisFeeOnBuy <= 2, "Buy rewards must be between 0% and 2%");
require(taxFeeOnBuy >= 0 && taxFeeOnBuy <= 14, "Buy tax must be between 0% and 14%");
require(redisFeeOnSell >= 0 && redisFeeOnSell <= 2, "Sell rewards must be between 0% and 2%");
require(taxFeeOnSell >= 0 && taxFeeOnSell <= 14, "Sell tax must be between 0% and 14%");
_redisFeeOnBuy = redisFeeOnBuy;
_redisFeeOnSell = redisFeeOnSell;
_taxFeeOnBuy = taxFeeOnBuy;
_taxFeeOnSell = taxFeeOnSell;
}
//Set minimum tokens required to swap.
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner {
_swapTokensAtAmount = swapTokensAtAmount;
}
//Set minimum tokens required to swap.
function toggleSwap(bool _swapEnabled) public onlyOwner {
swapEnabled = _swapEnabled;
}
//Set maximum transaction
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
if (maxTxAmount > 10000000 * 10**9) {
_maxTxAmount = maxTxAmount;
}
}
function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner {
_maxWalletSize = maxWalletSize;
}
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFee[accounts[i]] = excluded;
}
}
} | toggleSwap | function toggleSwap(bool _swapEnabled) public onlyOwner {
swapEnabled = _swapEnabled;
}
| //Set minimum tokens required to swap. | LineComment | v0.8.9+commit.e5eed63a | Unlicense | ipfs://5fd9e120bb87ee369020df43ced696c5b795ea05fe85b9a82991060544af98bf | {
"func_code_index": [
13348,
13454
]
} | 7,374 |
||
KevTAMA | KevTAMA.sol | 0x371709ae8413ce755dc7ec5aec061700509c5a9e | Solidity | KevTAMA | contract KevTAMA is Context, IERC20, Ownable {
using SafeMath for uint256;
string private constant _name = "KevTAMA";
string private constant _symbol = "KEVTAMA";
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 = 1000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _redisFeeOnBuy = 0;
uint256 private _taxFeeOnBuy = 10;
uint256 private _redisFeeOnSell = 0;
uint256 private _taxFeeOnSell = 10;
//Original Fee
uint256 private _redisFee = _redisFeeOnSell;
uint256 private _taxFee = _taxFeeOnSell;
uint256 private _previousredisFee = _redisFee;
uint256 private _previoustaxFee = _taxFee;
mapping(address => bool) public bots; mapping (address => uint256) public _buyMap;
address payable private _developmentAddress = payable(0xe1CF1Ad71dcd3f077793192e955decb635cB844C);
address payable private _marketingAddress = payable(0xDF63Be20c1D3983F9B66663a2529D62f98aCc0f2);
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private tradingOpen;
bool private inSwap = false;
bool private swapEnabled = true;
uint256 public _maxTxAmount = 10000000 * 10**9;
uint256 public _maxWalletSize = 40000000 * 10**9;
uint256 public _swapTokensAtAmount = 10000 * 10**9;
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor() {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);//
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_developmentAddress] = true;
_isExcludedFromFee[_marketingAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender)
public
view
override
returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount)
public
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
function 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 (_redisFee == 0 && _taxFee == 0) return;
_previousredisFee = _redisFee;
_previoustaxFee = _taxFee;
_redisFee = 0;
_taxFee = 0;
}
function restoreAllFee() private {
_redisFee = _previousredisFee;
_taxFee = _previoustaxFee;
}
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()) {
//Trade start check
if (!tradingOpen) {
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
}
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
if(to != uniswapV2Pair) {
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
//Transfer Tokens
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
takeFee = false;
} else {
//Set Fee for Buys
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
_redisFee = _redisFeeOnBuy;
_taxFee = _taxFeeOnBuy;
}
//Set Fee for Sells
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
_redisFee = _redisFeeOnSell;
_taxFee = _taxFeeOnSell;
}
}
_tokenTransfer(from, to, amount, takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_marketingAddress.transfer(amount);
}
function setTrading(bool _tradingOpen) public onlyOwner {
tradingOpen = _tradingOpen;
}
function manualswap() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function blockBots(address[] memory bots_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function unblockBot(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 _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _redisFee, _taxFee);
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 redisFee,
uint256 taxFee
)
private
pure
returns (
uint256,
uint256,
uint256
)
{
uint256 tFee = tAmount.mul(redisFee).div(100);
uint256 tTeam = tAmount.mul(taxFee).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);
}
function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
require(redisFeeOnBuy >= 0 && redisFeeOnBuy <= 2, "Buy rewards must be between 0% and 2%");
require(taxFeeOnBuy >= 0 && taxFeeOnBuy <= 14, "Buy tax must be between 0% and 14%");
require(redisFeeOnSell >= 0 && redisFeeOnSell <= 2, "Sell rewards must be between 0% and 2%");
require(taxFeeOnSell >= 0 && taxFeeOnSell <= 14, "Sell tax must be between 0% and 14%");
_redisFeeOnBuy = redisFeeOnBuy;
_redisFeeOnSell = redisFeeOnSell;
_taxFeeOnBuy = taxFeeOnBuy;
_taxFeeOnSell = taxFeeOnSell;
}
//Set minimum tokens required to swap.
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner {
_swapTokensAtAmount = swapTokensAtAmount;
}
//Set minimum tokens required to swap.
function toggleSwap(bool _swapEnabled) public onlyOwner {
swapEnabled = _swapEnabled;
}
//Set maximum transaction
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
if (maxTxAmount > 10000000 * 10**9) {
_maxTxAmount = maxTxAmount;
}
}
function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner {
_maxWalletSize = maxWalletSize;
}
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
for(uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFee[accounts[i]] = excluded;
}
}
} | setMaxTxnAmount | function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
if (maxTxAmount > 10000000 * 10**9) {
_maxTxAmount = maxTxAmount;
}
}
| //Set maximum transaction | LineComment | v0.8.9+commit.e5eed63a | Unlicense | ipfs://5fd9e120bb87ee369020df43ced696c5b795ea05fe85b9a82991060544af98bf | {
"func_code_index": [
13489,
13661
]
} | 7,375 |
||
KyberPriceFeed | ./src/registry/IRegistry.sol | 0x10a285ea8b9e0ff92a2de4ecf961293a6999f7e6 | Solidity | IRegistry | interface IRegistry {
struct Asset {
bool exists;
string name;
string symbol;
uint decimals;
string url;
uint reserveMin;
uint[] standards;
bytes4[] sigs;
}
struct Exchange {
bool exists;
address exchangeAddress;
bytes4[] sigs;
}
struct FundFactory {
bool exists;
bytes32 name;
}
// STORAGE
function assetInformation(address) external view returns(Asset memory);
function engine() external view returns(address);
function exchangeInformation(address) external view returns(Exchange memory);
function fundNameHashToOwner(bytes32) external view returns(address);
function fundsToFundFactories(address) external view returns(address);
function incentive() external view returns(uint256);
function isFeeRegistered(address) external view returns(bool);
function MAX_FUND_NAME_BYTES() external view returns(uint256);
function MAX_REGISTERED_ENTITIES() external view returns(uint256);
function MGM() external view returns(address);
function mlnToken() external view returns(address);
function nativeAsset() external view returns(address);
function priceSource() external view returns(address);
function registeredAssets(uint256 _index) external view returns(address);
function registeredExchangeAdapters(uint256 _index) external view returns(address);
function registeredFundFactories(uint256 _index) external view returns(address);
function fundFactoryInformation(address) external view returns(FundFactory memory);
function fundFactoryNameExists(bytes32) external view returns(bool);
// FUNCTIONS
function adapterMethodIsAllowed(address _adapter, bytes4 _sig) external view returns (bool);
function assetIsRegistered(address _asset) external view returns (bool);
function assetMethodIsAllowed(address _asset, bytes4 _sig) external view returns (bool);
function canUseFundName(address _user, string calldata _name) external view returns (bool);
function exchangeAdapterIsRegistered(address _adapter) external view returns (bool);
function exchangeForAdapter(address _adapter) external view returns (address);
function getAdapterFunctionSignatures(address _adapter)
external
view
returns (bytes4[] memory);
function getRegisteredFundFactories() external view returns (address[] memory);
function getDecimals(address _asset) external view returns (uint256);
function getName(address _asset) external view returns (string memory);
function getRegisteredAssets() external view returns (address[] memory);
function getRegisteredExchangeAdapters() external view returns (address[] memory);
function getReserveMin(address _asset) external view returns (uint256);
function getSymbol(address _asset) external view returns (string memory);
function isFund(address _who) external view returns (bool);
function isFundFactory(address _who) external view returns (bool);
function isValidFundName(string calldata _name) external pure returns (bool);
// Caller: FundFactory contract only:
function registerFund(address _fund, address _owner, string calldata _name) external;
function reserveFundName(address _owner, string calldata _name) external;
// Caller: Auth only:
function deregisterFees(address[] calldata _fees) external;
function registerAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint256 _reserveMin,
uint256[] calldata _standards,
bytes4[] calldata _sigs
) external;
function registerExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
function registerFees(address[] calldata _fees) external;
function registerFundFactory(address _fundFactory, bytes32 _name) external;
function removeAsset(address _asset, uint _assetIndex) external;
function removeExchangeAdapter(address _adapter, uint _adapterIndex) external;
function setEngine(address _engine) external;
function setIncentive(uint _weiAmount) external;
function setMGM(address _MGM) external;
function setMlnToken(address _mlnToken) external;
function setNativeAsset(address _nativeAsset) external;
function setPriceSource(address _priceSource) external;
function updateAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint _reserveMin,
uint[] calldata _standards,
bytes4[] calldata _sigs
) external;
function updateExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
// INHERITED: DSAuth
// STORAGE
// function authority() external view returns (DSAuthority);
function owner() external view returns(address);
// FUNCTIONS
// function setAuthority(DSAuthority authority_) external;
// function setOwner(address _owner) external;
} | // import "../dependencies/DSAuth.sol"; | LineComment | assetInformation | function assetInformation(address) external view returns(Asset memory);
| // STORAGE | LineComment | v0.6.1+commit.e6f7d5a4 | GNU GPLv3 | ://bfb6637c40f216637aec4ae865b552cdfb7385f35abfdc8605b64dfc9d3e53a3 | {
"func_code_index": [
426,
501
]
} | 7,376 |
KyberPriceFeed | ./src/registry/IRegistry.sol | 0x10a285ea8b9e0ff92a2de4ecf961293a6999f7e6 | Solidity | IRegistry | interface IRegistry {
struct Asset {
bool exists;
string name;
string symbol;
uint decimals;
string url;
uint reserveMin;
uint[] standards;
bytes4[] sigs;
}
struct Exchange {
bool exists;
address exchangeAddress;
bytes4[] sigs;
}
struct FundFactory {
bool exists;
bytes32 name;
}
// STORAGE
function assetInformation(address) external view returns(Asset memory);
function engine() external view returns(address);
function exchangeInformation(address) external view returns(Exchange memory);
function fundNameHashToOwner(bytes32) external view returns(address);
function fundsToFundFactories(address) external view returns(address);
function incentive() external view returns(uint256);
function isFeeRegistered(address) external view returns(bool);
function MAX_FUND_NAME_BYTES() external view returns(uint256);
function MAX_REGISTERED_ENTITIES() external view returns(uint256);
function MGM() external view returns(address);
function mlnToken() external view returns(address);
function nativeAsset() external view returns(address);
function priceSource() external view returns(address);
function registeredAssets(uint256 _index) external view returns(address);
function registeredExchangeAdapters(uint256 _index) external view returns(address);
function registeredFundFactories(uint256 _index) external view returns(address);
function fundFactoryInformation(address) external view returns(FundFactory memory);
function fundFactoryNameExists(bytes32) external view returns(bool);
// FUNCTIONS
function adapterMethodIsAllowed(address _adapter, bytes4 _sig) external view returns (bool);
function assetIsRegistered(address _asset) external view returns (bool);
function assetMethodIsAllowed(address _asset, bytes4 _sig) external view returns (bool);
function canUseFundName(address _user, string calldata _name) external view returns (bool);
function exchangeAdapterIsRegistered(address _adapter) external view returns (bool);
function exchangeForAdapter(address _adapter) external view returns (address);
function getAdapterFunctionSignatures(address _adapter)
external
view
returns (bytes4[] memory);
function getRegisteredFundFactories() external view returns (address[] memory);
function getDecimals(address _asset) external view returns (uint256);
function getName(address _asset) external view returns (string memory);
function getRegisteredAssets() external view returns (address[] memory);
function getRegisteredExchangeAdapters() external view returns (address[] memory);
function getReserveMin(address _asset) external view returns (uint256);
function getSymbol(address _asset) external view returns (string memory);
function isFund(address _who) external view returns (bool);
function isFundFactory(address _who) external view returns (bool);
function isValidFundName(string calldata _name) external pure returns (bool);
// Caller: FundFactory contract only:
function registerFund(address _fund, address _owner, string calldata _name) external;
function reserveFundName(address _owner, string calldata _name) external;
// Caller: Auth only:
function deregisterFees(address[] calldata _fees) external;
function registerAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint256 _reserveMin,
uint256[] calldata _standards,
bytes4[] calldata _sigs
) external;
function registerExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
function registerFees(address[] calldata _fees) external;
function registerFundFactory(address _fundFactory, bytes32 _name) external;
function removeAsset(address _asset, uint _assetIndex) external;
function removeExchangeAdapter(address _adapter, uint _adapterIndex) external;
function setEngine(address _engine) external;
function setIncentive(uint _weiAmount) external;
function setMGM(address _MGM) external;
function setMlnToken(address _mlnToken) external;
function setNativeAsset(address _nativeAsset) external;
function setPriceSource(address _priceSource) external;
function updateAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint _reserveMin,
uint[] calldata _standards,
bytes4[] calldata _sigs
) external;
function updateExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
// INHERITED: DSAuth
// STORAGE
// function authority() external view returns (DSAuthority);
function owner() external view returns(address);
// FUNCTIONS
// function setAuthority(DSAuthority authority_) external;
// function setOwner(address _owner) external;
} | // import "../dependencies/DSAuth.sol"; | LineComment | adapterMethodIsAllowed | function adapterMethodIsAllowed(address _adapter, bytes4 _sig) external view returns (bool);
| // FUNCTIONS | LineComment | v0.6.1+commit.e6f7d5a4 | GNU GPLv3 | ://bfb6637c40f216637aec4ae865b552cdfb7385f35abfdc8605b64dfc9d3e53a3 | {
"func_code_index": [
1704,
1800
]
} | 7,377 |
KyberPriceFeed | ./src/registry/IRegistry.sol | 0x10a285ea8b9e0ff92a2de4ecf961293a6999f7e6 | Solidity | IRegistry | interface IRegistry {
struct Asset {
bool exists;
string name;
string symbol;
uint decimals;
string url;
uint reserveMin;
uint[] standards;
bytes4[] sigs;
}
struct Exchange {
bool exists;
address exchangeAddress;
bytes4[] sigs;
}
struct FundFactory {
bool exists;
bytes32 name;
}
// STORAGE
function assetInformation(address) external view returns(Asset memory);
function engine() external view returns(address);
function exchangeInformation(address) external view returns(Exchange memory);
function fundNameHashToOwner(bytes32) external view returns(address);
function fundsToFundFactories(address) external view returns(address);
function incentive() external view returns(uint256);
function isFeeRegistered(address) external view returns(bool);
function MAX_FUND_NAME_BYTES() external view returns(uint256);
function MAX_REGISTERED_ENTITIES() external view returns(uint256);
function MGM() external view returns(address);
function mlnToken() external view returns(address);
function nativeAsset() external view returns(address);
function priceSource() external view returns(address);
function registeredAssets(uint256 _index) external view returns(address);
function registeredExchangeAdapters(uint256 _index) external view returns(address);
function registeredFundFactories(uint256 _index) external view returns(address);
function fundFactoryInformation(address) external view returns(FundFactory memory);
function fundFactoryNameExists(bytes32) external view returns(bool);
// FUNCTIONS
function adapterMethodIsAllowed(address _adapter, bytes4 _sig) external view returns (bool);
function assetIsRegistered(address _asset) external view returns (bool);
function assetMethodIsAllowed(address _asset, bytes4 _sig) external view returns (bool);
function canUseFundName(address _user, string calldata _name) external view returns (bool);
function exchangeAdapterIsRegistered(address _adapter) external view returns (bool);
function exchangeForAdapter(address _adapter) external view returns (address);
function getAdapterFunctionSignatures(address _adapter)
external
view
returns (bytes4[] memory);
function getRegisteredFundFactories() external view returns (address[] memory);
function getDecimals(address _asset) external view returns (uint256);
function getName(address _asset) external view returns (string memory);
function getRegisteredAssets() external view returns (address[] memory);
function getRegisteredExchangeAdapters() external view returns (address[] memory);
function getReserveMin(address _asset) external view returns (uint256);
function getSymbol(address _asset) external view returns (string memory);
function isFund(address _who) external view returns (bool);
function isFundFactory(address _who) external view returns (bool);
function isValidFundName(string calldata _name) external pure returns (bool);
// Caller: FundFactory contract only:
function registerFund(address _fund, address _owner, string calldata _name) external;
function reserveFundName(address _owner, string calldata _name) external;
// Caller: Auth only:
function deregisterFees(address[] calldata _fees) external;
function registerAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint256 _reserveMin,
uint256[] calldata _standards,
bytes4[] calldata _sigs
) external;
function registerExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
function registerFees(address[] calldata _fees) external;
function registerFundFactory(address _fundFactory, bytes32 _name) external;
function removeAsset(address _asset, uint _assetIndex) external;
function removeExchangeAdapter(address _adapter, uint _adapterIndex) external;
function setEngine(address _engine) external;
function setIncentive(uint _weiAmount) external;
function setMGM(address _MGM) external;
function setMlnToken(address _mlnToken) external;
function setNativeAsset(address _nativeAsset) external;
function setPriceSource(address _priceSource) external;
function updateAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint _reserveMin,
uint[] calldata _standards,
bytes4[] calldata _sigs
) external;
function updateExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
// INHERITED: DSAuth
// STORAGE
// function authority() external view returns (DSAuthority);
function owner() external view returns(address);
// FUNCTIONS
// function setAuthority(DSAuthority authority_) external;
// function setOwner(address _owner) external;
} | // import "../dependencies/DSAuth.sol"; | LineComment | registerFund | function registerFund(address _fund, address _owner, string calldata _name) external;
| // Caller: FundFactory contract only: | LineComment | v0.6.1+commit.e6f7d5a4 | GNU GPLv3 | ://bfb6637c40f216637aec4ae865b552cdfb7385f35abfdc8605b64dfc9d3e53a3 | {
"func_code_index": [
3176,
3265
]
} | 7,378 |
KyberPriceFeed | ./src/registry/IRegistry.sol | 0x10a285ea8b9e0ff92a2de4ecf961293a6999f7e6 | Solidity | IRegistry | interface IRegistry {
struct Asset {
bool exists;
string name;
string symbol;
uint decimals;
string url;
uint reserveMin;
uint[] standards;
bytes4[] sigs;
}
struct Exchange {
bool exists;
address exchangeAddress;
bytes4[] sigs;
}
struct FundFactory {
bool exists;
bytes32 name;
}
// STORAGE
function assetInformation(address) external view returns(Asset memory);
function engine() external view returns(address);
function exchangeInformation(address) external view returns(Exchange memory);
function fundNameHashToOwner(bytes32) external view returns(address);
function fundsToFundFactories(address) external view returns(address);
function incentive() external view returns(uint256);
function isFeeRegistered(address) external view returns(bool);
function MAX_FUND_NAME_BYTES() external view returns(uint256);
function MAX_REGISTERED_ENTITIES() external view returns(uint256);
function MGM() external view returns(address);
function mlnToken() external view returns(address);
function nativeAsset() external view returns(address);
function priceSource() external view returns(address);
function registeredAssets(uint256 _index) external view returns(address);
function registeredExchangeAdapters(uint256 _index) external view returns(address);
function registeredFundFactories(uint256 _index) external view returns(address);
function fundFactoryInformation(address) external view returns(FundFactory memory);
function fundFactoryNameExists(bytes32) external view returns(bool);
// FUNCTIONS
function adapterMethodIsAllowed(address _adapter, bytes4 _sig) external view returns (bool);
function assetIsRegistered(address _asset) external view returns (bool);
function assetMethodIsAllowed(address _asset, bytes4 _sig) external view returns (bool);
function canUseFundName(address _user, string calldata _name) external view returns (bool);
function exchangeAdapterIsRegistered(address _adapter) external view returns (bool);
function exchangeForAdapter(address _adapter) external view returns (address);
function getAdapterFunctionSignatures(address _adapter)
external
view
returns (bytes4[] memory);
function getRegisteredFundFactories() external view returns (address[] memory);
function getDecimals(address _asset) external view returns (uint256);
function getName(address _asset) external view returns (string memory);
function getRegisteredAssets() external view returns (address[] memory);
function getRegisteredExchangeAdapters() external view returns (address[] memory);
function getReserveMin(address _asset) external view returns (uint256);
function getSymbol(address _asset) external view returns (string memory);
function isFund(address _who) external view returns (bool);
function isFundFactory(address _who) external view returns (bool);
function isValidFundName(string calldata _name) external pure returns (bool);
// Caller: FundFactory contract only:
function registerFund(address _fund, address _owner, string calldata _name) external;
function reserveFundName(address _owner, string calldata _name) external;
// Caller: Auth only:
function deregisterFees(address[] calldata _fees) external;
function registerAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint256 _reserveMin,
uint256[] calldata _standards,
bytes4[] calldata _sigs
) external;
function registerExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
function registerFees(address[] calldata _fees) external;
function registerFundFactory(address _fundFactory, bytes32 _name) external;
function removeAsset(address _asset, uint _assetIndex) external;
function removeExchangeAdapter(address _adapter, uint _adapterIndex) external;
function setEngine(address _engine) external;
function setIncentive(uint _weiAmount) external;
function setMGM(address _MGM) external;
function setMlnToken(address _mlnToken) external;
function setNativeAsset(address _nativeAsset) external;
function setPriceSource(address _priceSource) external;
function updateAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint _reserveMin,
uint[] calldata _standards,
bytes4[] calldata _sigs
) external;
function updateExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
// INHERITED: DSAuth
// STORAGE
// function authority() external view returns (DSAuthority);
function owner() external view returns(address);
// FUNCTIONS
// function setAuthority(DSAuthority authority_) external;
// function setOwner(address _owner) external;
} | // import "../dependencies/DSAuth.sol"; | LineComment | deregisterFees | function deregisterFees(address[] calldata _fees) external;
| // Caller: Auth only: | LineComment | v0.6.1+commit.e6f7d5a4 | GNU GPLv3 | ://bfb6637c40f216637aec4ae865b552cdfb7385f35abfdc8605b64dfc9d3e53a3 | {
"func_code_index": [
3371,
3434
]
} | 7,379 |
KyberPriceFeed | ./src/registry/IRegistry.sol | 0x10a285ea8b9e0ff92a2de4ecf961293a6999f7e6 | Solidity | IRegistry | interface IRegistry {
struct Asset {
bool exists;
string name;
string symbol;
uint decimals;
string url;
uint reserveMin;
uint[] standards;
bytes4[] sigs;
}
struct Exchange {
bool exists;
address exchangeAddress;
bytes4[] sigs;
}
struct FundFactory {
bool exists;
bytes32 name;
}
// STORAGE
function assetInformation(address) external view returns(Asset memory);
function engine() external view returns(address);
function exchangeInformation(address) external view returns(Exchange memory);
function fundNameHashToOwner(bytes32) external view returns(address);
function fundsToFundFactories(address) external view returns(address);
function incentive() external view returns(uint256);
function isFeeRegistered(address) external view returns(bool);
function MAX_FUND_NAME_BYTES() external view returns(uint256);
function MAX_REGISTERED_ENTITIES() external view returns(uint256);
function MGM() external view returns(address);
function mlnToken() external view returns(address);
function nativeAsset() external view returns(address);
function priceSource() external view returns(address);
function registeredAssets(uint256 _index) external view returns(address);
function registeredExchangeAdapters(uint256 _index) external view returns(address);
function registeredFundFactories(uint256 _index) external view returns(address);
function fundFactoryInformation(address) external view returns(FundFactory memory);
function fundFactoryNameExists(bytes32) external view returns(bool);
// FUNCTIONS
function adapterMethodIsAllowed(address _adapter, bytes4 _sig) external view returns (bool);
function assetIsRegistered(address _asset) external view returns (bool);
function assetMethodIsAllowed(address _asset, bytes4 _sig) external view returns (bool);
function canUseFundName(address _user, string calldata _name) external view returns (bool);
function exchangeAdapterIsRegistered(address _adapter) external view returns (bool);
function exchangeForAdapter(address _adapter) external view returns (address);
function getAdapterFunctionSignatures(address _adapter)
external
view
returns (bytes4[] memory);
function getRegisteredFundFactories() external view returns (address[] memory);
function getDecimals(address _asset) external view returns (uint256);
function getName(address _asset) external view returns (string memory);
function getRegisteredAssets() external view returns (address[] memory);
function getRegisteredExchangeAdapters() external view returns (address[] memory);
function getReserveMin(address _asset) external view returns (uint256);
function getSymbol(address _asset) external view returns (string memory);
function isFund(address _who) external view returns (bool);
function isFundFactory(address _who) external view returns (bool);
function isValidFundName(string calldata _name) external pure returns (bool);
// Caller: FundFactory contract only:
function registerFund(address _fund, address _owner, string calldata _name) external;
function reserveFundName(address _owner, string calldata _name) external;
// Caller: Auth only:
function deregisterFees(address[] calldata _fees) external;
function registerAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint256 _reserveMin,
uint256[] calldata _standards,
bytes4[] calldata _sigs
) external;
function registerExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
function registerFees(address[] calldata _fees) external;
function registerFundFactory(address _fundFactory, bytes32 _name) external;
function removeAsset(address _asset, uint _assetIndex) external;
function removeExchangeAdapter(address _adapter, uint _adapterIndex) external;
function setEngine(address _engine) external;
function setIncentive(uint _weiAmount) external;
function setMGM(address _MGM) external;
function setMlnToken(address _mlnToken) external;
function setNativeAsset(address _nativeAsset) external;
function setPriceSource(address _priceSource) external;
function updateAsset(
address _asset,
string calldata _name,
string calldata _symbol,
string calldata _url,
uint _reserveMin,
uint[] calldata _standards,
bytes4[] calldata _sigs
) external;
function updateExchangeAdapter(
address _exchange,
address _adapter,
bytes4[] calldata _sigs
) external;
// INHERITED: DSAuth
// STORAGE
// function authority() external view returns (DSAuthority);
function owner() external view returns(address);
// FUNCTIONS
// function setAuthority(DSAuthority authority_) external;
// function setOwner(address _owner) external;
} | // import "../dependencies/DSAuth.sol"; | LineComment | owner | function owner() external view returns(address);
| // INHERITED: DSAuth
// STORAGE
// function authority() external view returns (DSAuthority); | LineComment | v0.6.1+commit.e6f7d5a4 | GNU GPLv3 | ://bfb6637c40f216637aec4ae865b552cdfb7385f35abfdc8605b64dfc9d3e53a3 | {
"func_code_index": [
4948,
5000
]
} | 7,380 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | IERC20 | interface IERC20 {
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
165,
238
]
} | 7,381 |
||
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | IERC20 | interface IERC20 {
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
462,
544
]
} | 7,382 |
||
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | IERC20 | interface IERC20 {
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
823,
911
]
} | 7,383 |
||
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | IERC20 | interface IERC20 {
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
1575,
1654
]
} | 7,384 |
||
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | IERC20 | interface IERC20 {
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
1967,
2069
]
} | 7,385 |
||
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
259,
445
]
} | 7,386 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
723,
864
]
} | 7,387 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
1162,
1359
]
} | 7,388 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
1613,
2089
]
} | 7,389 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
2560,
2697
]
} | 7,390 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
3188,
3471
]
} | 7,391 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
3931,
4066
]
} | 7,392 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
4546,
4717
]
} | 7,393 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | isContract | function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
606,
1230
]
} | 7,394 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
2160,
2562
]
} | 7,395 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
3318,
3496
]
} | 7,396 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
3721,
3922
]
} | 7,397 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
4292,
4523
]
} | 7,398 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
4774,
5095
]
} | 7,399 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | owner | function owner() public view returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
566,
650
]
} | 7,400 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| /**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
1209,
1362
]
} | 7,401 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
} | /**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
1512,
1761
]
} | 7,402 |
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | DegenGoose | contract DegenGoose 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 _isBlackListedBot;
address[] private _blackListedBots;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "Degen Goose";
string private _symbol = "DEGENGOOSE";
uint8 private _decimals = 9;
uint256 public _taxFee = 1;
uint256 private _previousTaxFee = _taxFee;
uint256 public _liquidityFee = 10;
uint256 private _previousLiquidityFee = _liquidityFee;
address payable public _devWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
bool public _antiwhale;
uint256 public _maxTxAmount = 1000000000 * 10**6 * 10**9;
uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event antiWaleUpdate(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor (address payable devWalletAddress) public {
_devWalletAddress = devWalletAddress;
_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
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(0xa1817B6d8D890F3943b61648992730373B71f156, _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 setDevFeeDisabled(bool _devFeeEnabled ) public returns (bool){
require(msg.sender == _devWalletAddress, "Only Dev Address can disable dev fee");
swapAndLiquifyEnabled = _devFeeEnabled;
return(swapAndLiquifyEnabled);
}
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 {
(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 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 setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() {
_liquidityFee = liquidityFee;
}
function _setdevWallet(address payable devWalletAddress) external onlyOwner() {
_devWalletAddress = devWalletAddress;
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(
10**2
);
}
function antiWhaleStatus(bool _state) public onlyOwner {
_antiwhale = _state;
emit antiWaleUpdate(_state);
}
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 addBotToBlackList(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.');
require(!_isBlackListedBot[account], "Account is already blacklisted");
_isBlackListedBot[account] = true;
_blackListedBots.push(account);
}
function removeBotFromBlackList(address account) external onlyOwner() {
require(_isBlackListedBot[account], "Account is not blacklisted");
for (uint256 i = 0; i < _blackListedBots.length; i++) {
if (_blackListedBots[i] == account) {
_blackListedBots[i] = _blackListedBots[_blackListedBots.length - 1];
_isBlackListedBot[account] = false;
_blackListedBots.pop();
break;
}
}
}
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");
require(!_isBlackListedBot[to], "You have no power here!");
require(!_isBlackListedBot[msg.sender], "You have no power here!");
require(!_isBlackListedBot[from], "You have no power here!");
if(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
if (!_antiwhale) {
require(
to != uniswapV2Pair,
"WE: antiwhale is not enabled yet"
);
}
// 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));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
//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(_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 {
// split the contract balance into halves
uint256 tokenBalance = contractTokenBalance;
// 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(tokenBalance); // <- 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);
sendETHTodev(newBalance);
// add liquidity to uniswap
emit SwapAndLiquify(tokenBalance, newBalance);
}
function sendETHTodev(uint256 amount) private {
_devWalletAddress.transfer(amount);
}
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(!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);
}
} | //to recieve ETH from uniswapV2Router when swaping | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
8985,
9019
]
} | 7,403 |
||||
DegenGoose | DegenGoose.sol | 0x367f8cf9b536cdd125c517877c1c59b2b738d788 | Solidity | DegenGoose | contract DegenGoose 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 _isBlackListedBot;
address[] private _blackListedBots;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "Degen Goose";
string private _symbol = "DEGENGOOSE";
uint8 private _decimals = 9;
uint256 public _taxFee = 1;
uint256 private _previousTaxFee = _taxFee;
uint256 public _liquidityFee = 10;
uint256 private _previousLiquidityFee = _liquidityFee;
address payable public _devWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
bool public _antiwhale;
uint256 public _maxTxAmount = 1000000000 * 10**6 * 10**9;
uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event antiWaleUpdate(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived
);
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor (address payable devWalletAddress) public {
_devWalletAddress = devWalletAddress;
_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
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(0xa1817B6d8D890F3943b61648992730373B71f156, _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 setDevFeeDisabled(bool _devFeeEnabled ) public returns (bool){
require(msg.sender == _devWalletAddress, "Only Dev Address can disable dev fee");
swapAndLiquifyEnabled = _devFeeEnabled;
return(swapAndLiquifyEnabled);
}
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 {
(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 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 setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() {
_liquidityFee = liquidityFee;
}
function _setdevWallet(address payable devWalletAddress) external onlyOwner() {
_devWalletAddress = devWalletAddress;
}
function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() {
_maxTxAmount = _tTotal.mul(maxTxPercent).div(
10**2
);
}
function antiWhaleStatus(bool _state) public onlyOwner {
_antiwhale = _state;
emit antiWaleUpdate(_state);
}
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 addBotToBlackList(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.');
require(!_isBlackListedBot[account], "Account is already blacklisted");
_isBlackListedBot[account] = true;
_blackListedBots.push(account);
}
function removeBotFromBlackList(address account) external onlyOwner() {
require(_isBlackListedBot[account], "Account is not blacklisted");
for (uint256 i = 0; i < _blackListedBots.length; i++) {
if (_blackListedBots[i] == account) {
_blackListedBots[i] = _blackListedBots[_blackListedBots.length - 1];
_isBlackListedBot[account] = false;
_blackListedBots.pop();
break;
}
}
}
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");
require(!_isBlackListedBot[to], "You have no power here!");
require(!_isBlackListedBot[msg.sender], "You have no power here!");
require(!_isBlackListedBot[from], "You have no power here!");
if(from != owner() && to != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
if (!_antiwhale) {
require(
to != uniswapV2Pair,
"WE: antiwhale is not enabled yet"
);
}
// 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));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity;
if (
overMinTokenBalance &&
!inSwapAndLiquify &&
from != uniswapV2Pair &&
swapAndLiquifyEnabled
) {
//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(_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 {
// split the contract balance into halves
uint256 tokenBalance = contractTokenBalance;
// 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(tokenBalance); // <- 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);
sendETHTodev(newBalance);
// add liquidity to uniswap
emit SwapAndLiquify(tokenBalance, newBalance);
}
function sendETHTodev(uint256 amount) private {
_devWalletAddress.transfer(amount);
}
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(!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);
}
} | _tokenTransfer | 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();
}
| //this method is responsible for taking all fee, if takeFee is true | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://52fde5425bc6b739f833f085d54ad8a7c501afaa98b68da07a010733156c972c | {
"func_code_index": [
17989,
18828
]
} | 7,404 |
||
EYESToken | project:/contracts/EYESToken.sol | 0x8c14a98a44dd5d73a1dec31b45d02c99c0c130b8 | Solidity | EYESToken | contract EYESToken is AccessControl, ERC20Burnable, ERC20Pausable {
using SafeMath for uint256;
uint256 constant EXPECTED_TOTAL_SUPPLY = 10000000000 ether;
uint256 public constant MINTAGE_SALE_TOKEN = 1500000000 ether;
uint256 public constant MINTAGE_PER_WALLET = 100000000 ether;
uint256 public constant MINTAGE_ECO_TOKEN = 5000000000 ether;
uint256 public constant MINTAGE_TEAM_TOKEN = 1500000000 ether;
uint256 public constant MINTAGE_MARKET_TOKEN = 2000000000 ether;
bytes32 public constant ROLE_ADMIN = keccak256("ROLE_ADMIN");
bytes32 public constant ROLE_ADMIN_ADMIN = keccak256("ROLE_ADMIN_ADMIN");
bytes32 public constant ROLE_MULTISIG = keccak256("ROLE_MULTISIG");
bytes32 public constant ROLE_PREVENT = keccak256("ROLE_PREVENT");
ITokenStorage[37] private _token_storages;
uint public constant INDEX_TOKEN_STORAGE_ECO = 0;
uint public constant INDEX_TOKEN_STORAGE_TEAM = 1;
uint public constant INDEX_TOKEN_STORAGE_SALE_ZERO = 2;
uint public constant INDEX_TOKEN_STORAGE_MARKET_ZERO = 17;
uint public constant NUMBER_TOKEN_STORAGE_SALE = 15;
uint public constant NUMBER_TOKEN_STORAGE_MARKET = 20;
uint public constant NUMBER_TOKEN_STORAGE = 37;
struct LockDataEntry {
uint256 unlock_timestamp;
uint256 locked_amount;
}
struct LockData {
mapping (uint256 => LockDataEntry[12]) entries;
uint256 length;
}
mapping (address => LockData) private _lock_data;
mapping (address => bool) private _locked_wallets;
bool private _minted;
bool private _inited;
constructor(address multisig) ERC20("EYES Protocol", "EYES") {
_minted = false;
_inited = false;
/*
* Transfer access
*
* 1. Multisig address has role `ROLE_MULTISIG`
* 2. Multisig address has role `ROLE_ADMIN`
* 3. Multisig address has role `ROLE_ADMIN_ADMIN`
*
* Addresses with `ROLE_MULTISIG` can
* 1. Pause/unpause token contract
* 2. Burn tokens held by 'eco'
* 3. Burn tokens held by 'sale'
* 4. Burn tokens held by 'team'
* 5. Burn tokens held by 'market'
*
* Addresses with `ROLE_ADMIN` can
* 1. Transfer tokens held by 'sale'
* 2. Transfer tokens held by 'eco'
* 3. Transfer tokens held by 'team'
* 4. Transfer tokens held by 'market'
*
* Addresses with `ROLE_ADMIN_ADMIN` can
* 1. Grant other addresses `ROLE_ADMIN` role
*/
_setupRole(ROLE_MULTISIG, multisig);
_setupRole(ROLE_ADMIN, multisig);
_setupRole(ROLE_ADMIN_ADMIN, multisig);
_setRoleAdmin(ROLE_ADMIN, ROLE_ADMIN_ADMIN);
/*
* By default `ROLE_ADMIN_ADMIN` and `ROLE_ADMIN_ADMIN`'s admin role
* are the same. Setting it to `ROLE_PREVENT` to prevent someone with
* `ROLE_ADMIN_ADMIN` role from granting others `ROLE_ADMIN_ADMIN` role.
*/
_setRoleAdmin(ROLE_ADMIN_ADMIN, ROLE_PREVENT);
}
function mint_reserved(uint index) public onlyRole(ROLE_ADMIN) {
require (!_minted);
require (index != INDEX_TOKEN_STORAGE_ECO);
require (index != INDEX_TOKEN_STORAGE_TEAM);
require (index < NUMBER_TOKEN_STORAGE);
require (address(_token_storages[index]) == address(0x0));
_token_storages[index] = new TokenStorage();
_mint(address(_token_storages[index]), MINTAGE_PER_WALLET);
}
function mint_other() public onlyRole(ROLE_ADMIN) {
require (!_minted);
require (!_inited);
_token_storages[INDEX_TOKEN_STORAGE_ECO] = new TokenStorage();
_mint(address(_token_storages[INDEX_TOKEN_STORAGE_ECO]), MINTAGE_ECO_TOKEN);
_token_storages[INDEX_TOKEN_STORAGE_TEAM] = new TokenStorage();
_mint(address(_token_storages[INDEX_TOKEN_STORAGE_TEAM]), MINTAGE_TEAM_TOKEN);
assert (totalSupply() == EXPECTED_TOTAL_SUPPLY);
_inited = true;
}
function get_locked_balance(address owner) public view returns (uint256) {
require (owner != address(0x0), "invalid address");
uint256 length = _lock_data[owner].length;
mapping (uint256 => LockDataEntry[12]) storage entries = _lock_data[owner].entries;
uint256 acc = 0;
for (uint256 i = 0; i < length; i = i.add(1)) {
for (uint j = 0; j < 12; j += 1) {
LockDataEntry storage e = entries[i][j];
if (block.timestamp < e.unlock_timestamp)
acc = acc.add(e.locked_amount);
}
}
return acc;
}
/*
* `_unlock` unlocks unlockable tokens and return locked balance.
* To get locked balance call `get_locked_balance` instead
*/
function _unlock(address owner) internal returns (uint256) {
require (owner != address(0x0), "invalid address");
uint256 length = _lock_data[owner].length;
mapping (uint256 => LockDataEntry[12]) storage entries = _lock_data[owner].entries;
uint256 acc_locked = 0;
for (uint256 i = 0; i < length; i = i.add(1)) {
for (uint j = 0; j < 12; j += 1) {
LockDataEntry storage e = entries[i][j];
if (block.timestamp < e.unlock_timestamp) {
acc_locked = acc_locked.add(e.locked_amount);
} else if (e.locked_amount != 0) {
// check for zero to prevent unnecessary write
e.locked_amount = 0;
}
}
}
return acc_locked;
}
function transfer(address to, uint256 value) public override returns (bool) {
require (balanceOf(msg.sender).sub(_unlock(msg.sender)) >= value, "insufficient unlocked token balance");
return super.transfer(to, value);
}
function transferFrom(address from, address to, uint256 value) public override returns (bool) {
require (balanceOf(from).sub(_unlock(from)) >= value, "insufficient unlocked token balance");
return super.transferFrom(from, to, value);
}
function transfer_sale_token(uint index, address to, uint256 amount) public onlyRole(ROLE_ADMIN) {
require (index < NUMBER_TOKEN_STORAGE_SALE);
_token_storages[INDEX_TOKEN_STORAGE_SALE_ZERO + index].transfer(this, to, amount);
}
function transfer_eco_token(address to, uint256 amount) public onlyRole(ROLE_ADMIN) {
_token_storages[INDEX_TOKEN_STORAGE_ECO].transfer(this, to, amount);
}
function transfer_team_token(address to, uint256 amount) public onlyRole(ROLE_ADMIN) {
_token_storages[INDEX_TOKEN_STORAGE_TEAM].transfer(this, to, amount);
}
function transfer_market_token(uint index, address to, uint256 amount) public onlyRole(ROLE_ADMIN) {
require (index < NUMBER_TOKEN_STORAGE_MARKET);
_token_storages[INDEX_TOKEN_STORAGE_MARKET_ZERO + index].transfer(this, to, amount);
}
function _transfer_locked_token(
ITokenStorage from,
address to,
uint256 amount,
uint256[12] memory locked_amounts,
uint256[12] memory unlock_timestamps
) internal {
uint256 lock_number = _lock_data[to].length;
_lock_data[to].length = lock_number.add(1);
LockDataEntry[12] storage entry = _lock_data[to].entries[lock_number];
uint256 acc_amount = 0;
for (uint i = 0; i < 12; i += 1) {
entry[i].locked_amount = locked_amounts[i];
acc_amount = acc_amount.add(locked_amounts[i]);
entry[i].unlock_timestamp = unlock_timestamps[i];
}
require (acc_amount == amount);
from.transfer(this, to, amount);
}
function transfer_locked_sale_token(
uint256 index,
address to,
uint256 amount,
uint256[12] memory locked_amounts,
uint256[12] memory unlock_timestamps
) public onlyRole(ROLE_ADMIN) {
require (index < NUMBER_TOKEN_STORAGE_SALE);
uint storage_index = index.add(INDEX_TOKEN_STORAGE_SALE_ZERO);
_transfer_locked_token(
_token_storages[storage_index],
to,
amount,
locked_amounts,
unlock_timestamps);
}
function transfer_locked_eco_token(
address to,
uint256 amount,
uint256[12] memory locked_amounts,
uint256[12] memory unlock_timestamps
) public onlyRole(ROLE_ADMIN) {
_transfer_locked_token(
_token_storages[INDEX_TOKEN_STORAGE_ECO],
to,
amount,
locked_amounts,
unlock_timestamps);
}
function transfer_locked_team_token(
address to,
uint256 amount,
uint256[12] memory locked_amounts,
uint256[12] memory unlock_timestamps
) public onlyRole(ROLE_ADMIN) {
_transfer_locked_token(
_token_storages[INDEX_TOKEN_STORAGE_TEAM],
to,
amount,
locked_amounts,
unlock_timestamps);
}
function transfer_locked_market_token(
uint256 index,
address to,
uint256 amount,
uint256[12] memory locked_amounts,
uint256[12] memory unlock_timestamps
) public onlyRole(ROLE_ADMIN) {
require (index < NUMBER_TOKEN_STORAGE_MARKET);
uint256 storage_index = index.add(INDEX_TOKEN_STORAGE_MARKET_ZERO);
_transfer_locked_token(
_token_storages[storage_index],
to,
amount,
locked_amounts,
unlock_timestamps);
}
function burn_sale_token(uint index, uint256 amount) public onlyRole(ROLE_MULTISIG) {
require (index < NUMBER_TOKEN_STORAGE_SALE);
_token_storages[INDEX_TOKEN_STORAGE_SALE_ZERO + index].burn(this, amount);
}
function burn_eco_token(uint256 amount) public onlyRole(ROLE_MULTISIG) {
_token_storages[INDEX_TOKEN_STORAGE_ECO].burn(this, amount);
}
function burn_team_token(uint256 amount) public onlyRole(ROLE_MULTISIG) {
_token_storages[INDEX_TOKEN_STORAGE_TEAM].burn(this, amount);
}
function burn_market_token(uint index, uint256 amount) public onlyRole(ROLE_MULTISIG) {
require (index < NUMBER_TOKEN_STORAGE_MARKET);
_token_storages[INDEX_TOKEN_STORAGE_MARKET_ZERO + index].burn(this, amount);
}
function pause() public onlyRole(ROLE_MULTISIG) {
_pause();
}
function unpause() public onlyRole(ROLE_MULTISIG) {
_unpause();
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal override(ERC20, ERC20Pausable) {
require (!_locked_wallets[from], "source wallet address is locked");
super._beforeTokenTransfer(from, to, amount);
}
function lock_wallet(address wallet, bool lock) public onlyRole(ROLE_MULTISIG) {
require (wallet != address(0x0), "you can't lock 0x0");
require (_locked_wallets[wallet] != lock, "the wallet is set to given state already");
_locked_wallets[wallet] = lock;
}
function burn_locked_from(address from) public onlyRole(ROLE_MULTISIG) {
require (from != address(0x0), "invalid address");
uint256 length = _lock_data[from].length;
mapping (uint256 => LockDataEntry[12]) storage entries = _lock_data[from].entries;
uint256 acc_burnt = 0;
for (uint256 i = 0; i < length; i = i.add(1)) {
for (uint j = 0; j < 12; j += 1) {
LockDataEntry storage e = entries[i][j];
if (block.timestamp < e.unlock_timestamp) {
acc_burnt = acc_burnt.add(e.locked_amount);
e.locked_amount = 0;
}
}
}
_burn(from, acc_burnt);
}
function balance_of_token_storage(uint index) public view returns (uint256) {
require (index < NUMBER_TOKEN_STORAGE);
return balanceOf(address(_token_storages[index]));
}
} | _unlock | function _unlock(address owner) internal returns (uint256) {
require (owner != address(0x0), "invalid address");
uint256 length = _lock_data[owner].length;
mapping (uint256 => LockDataEntry[12]) storage entries = _lock_data[owner].entries;
uint256 acc_locked = 0;
for (uint256 i = 0; i < length; i = i.add(1)) {
for (uint j = 0; j < 12; j += 1) {
LockDataEntry storage e = entries[i][j];
if (block.timestamp < e.unlock_timestamp) {
acc_locked = acc_locked.add(e.locked_amount);
} else if (e.locked_amount != 0) {
// check for zero to prevent unnecessary write
e.locked_amount = 0;
}
}
}
return acc_locked;
}
| /*
* `_unlock` unlocks unlockable tokens and return locked balance.
* To get locked balance call `get_locked_balance` instead
*/ | Comment | v0.8.9+commit.e5eed63a | None | ipfs://433fb0a0916a7b5036987f7d4198505bc2925a0895426514449fa27e34c28628 | {
"func_code_index": [
4910,
5732
]
} | 7,405 |
||
CryptoPimps | Pimps.sol | 0xb4c80c8df14ce0a1e7c500fdd4e2bda1644f89b6 | Solidity | CryptoPimps | contract CryptoPimps is ERC721, Ownable {
using SafeMath for uint256;
uint256 public constant maxSupply = 10000;
uint256 public constant price = 3*10**16;
uint256 public constant purchaseLimit = 50;
uint256 internal constant reservable = 240;
uint256 internal constant team = 40;
string internal constant _name = "Crypto Pimps";
string internal constant _symbol = "PIMPS";
address payable immutable public payee;
address internal immutable reservee = 0xd95740e361Fc851E1338A7E2E82255176417d4eD;
string public contractURI;
string public provenance;
bool public saleIsActive = true;
uint256 public saleStart = 1633046340;
constructor (
address payable _payee
) public ERC721(_name, _symbol) {
payee = _payee;
}
/**
* emergency withdraw function, callable by anyone
*/
function withdraw() public {
payee.transfer(address(this).balance);
}
/**
* reserve
*/
function reserve() public onlyOwner {
require(totalSupply() < reservable, "reserve would exceed reservable");
uint supply = totalSupply();
uint i;
for (i = 0; i < 55; i++) {
if (totalSupply() < reservable - team) {
_safeMint(reservee, supply + i);
} else if (totalSupply() < reservable){
_safeMint(msg.sender, supply + i);
}
}
}
/**
* set provenance if needed
*/
function setProvenance(string memory _provenance) public onlyOwner {
provenance = _provenance;
}
/*
* sets baseURI
*/
function setBaseURI(string memory baseURI) public onlyOwner {
_setBaseURI(baseURI);
}
/*
* set contractURI if needed
*/
function setContractURI(string memory _contractURI) public onlyOwner {
contractURI = (_contractURI);
}
/*
* Pause sale if active, make active if paused
*/
function flipSaleState() public onlyOwner {
saleIsActive = !saleIsActive;
}
/*
* updates saleStart
*/
function setSaleStart(uint256 _saleStart) public onlyOwner {
saleStart = _saleStart;
}
/**
* mint
*/
function mint(uint numberOfTokens) public payable {
require(saleIsActive, "Sale must be active to mint");
require(block.timestamp >= saleStart, "Sale has not started yet, timestamp too low");
require(numberOfTokens <= purchaseLimit, "Purchase would exceed purchase limit");
require(totalSupply().add(numberOfTokens) <= maxSupply, "Purchase would exceed maxSupply");
require(price.mul(numberOfTokens) <= msg.value, "Ether value sent is too low");
payee.transfer(address(this).balance);
for(uint i = 0; i < numberOfTokens; i++) {
uint mintIndex = totalSupply();
if (totalSupply() < maxSupply) {
_safeMint(msg.sender, mintIndex);
}
}
}
} | /**
* @title NFT contract - forked from BAYC
* @dev Extends ERC721 Non-Fungible Token Standard basic implementation
*/ | NatSpecMultiLine | withdraw | function withdraw() public {
payee.transfer(address(this).balance);
}
| /**
* emergency withdraw function, callable by anyone
*/ | NatSpecMultiLine | v0.6.6+commit.6c089d02 | MIT | {
"func_code_index": [
873,
958
]
} | 7,406 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.