Unnamed: 0
int64 0
7.36k
| comments
stringlengths 3
35.2k
| code_string
stringlengths 1
527k
| code
stringlengths 1
527k
| __index_level_0__
int64 0
88.6k
|
|---|---|---|---|---|
6
|
// If amountIn is low enough, than fee substraction may substract 1 And in case in low amountIn this can make big difference
|
amountIn -= 1;
uint256 maxSlippage = routes[source][destination].maxAllowedSlippage;
if (maxSlippage == 0) {
maxSlippage = defaultMaxAllowedSlippage;
}
|
amountIn -= 1;
uint256 maxSlippage = routes[source][destination].maxAllowedSlippage;
if (maxSlippage == 0) {
maxSlippage = defaultMaxAllowedSlippage;
}
| 1,546
|
7
|
// return Amount of FNX/USDC/FNX locked on the protocol by the given account. Implementation of ProtocolAdapter interface function. /
|
function getBalance(address token, address account) external view override returns (uint256) {
if (block.coinbase == FNX ) { //injected CONTRACT AFFECTED BY MINERS
return FinNexusCollecteralPool(COLLATERAL_POOL_FNX).getUserInputCollateral(account,token);
}
if( block.coinbase == USDC) { //injected CONTRACT AFFECTED BY MINERS
return FinNexusCollecteralPool(COLLATERAL_POOL_USDC).getUserInputCollateral(account,token);
}
return 0;
}
|
function getBalance(address token, address account) external view override returns (uint256) {
if (block.coinbase == FNX ) { //injected CONTRACT AFFECTED BY MINERS
return FinNexusCollecteralPool(COLLATERAL_POOL_FNX).getUserInputCollateral(account,token);
}
if( block.coinbase == USDC) { //injected CONTRACT AFFECTED BY MINERS
return FinNexusCollecteralPool(COLLATERAL_POOL_USDC).getUserInputCollateral(account,token);
}
return 0;
}
| 39,465
|
86
|
// Set inputBytes to the next free memory space
|
inputBytes := mload(0x40)
|
inputBytes := mload(0x40)
| 3,645
|
6
|
// set betId, change pool amomunt, and add players to their array
|
bets[betId].colorSelected = colorChoices(_colorSelected);
bets[betId].amountBet = msg.value;
bets[betId].gambler = msg.sender;
betIds.push(betId);
poolAmount = poolAmount + msg.value;
if(!duplicate){
players[amountOfPlayers] = msg.sender;
}
|
bets[betId].colorSelected = colorChoices(_colorSelected);
bets[betId].amountBet = msg.value;
bets[betId].gambler = msg.sender;
betIds.push(betId);
poolAmount = poolAmount + msg.value;
if(!duplicate){
players[amountOfPlayers] = msg.sender;
}
| 47,031
|
13
|
// Wrappers over Solidity's arithmetic operations with added overflowchecks.
|
library SafeMath {
// Counterpart to Solidity's `+` operator.
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
// Counterpart to Solidity's `-` operator.
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
// Counterpart to Solidity's `-` operator.
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
// Counterpart to Solidity's `*` operator.
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;
}
// Counterpart to Solidity's `/` operator.
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
// Counterpart to Solidity's `/` operator.
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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;
}
// Counterpart to Solidity's `%` operator.
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
// Counterpart to Solidity's `%` operator.
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
|
library SafeMath {
// Counterpart to Solidity's `+` operator.
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
// Counterpart to Solidity's `-` operator.
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
// Counterpart to Solidity's `-` operator.
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
// Counterpart to Solidity's `*` operator.
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;
}
// Counterpart to Solidity's `/` operator.
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
// Counterpart to Solidity's `/` operator.
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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;
}
// Counterpart to Solidity's `%` operator.
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
// Counterpart to Solidity's `%` operator.
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
| 43,200
|
3
|
// Creates ModaAware instance, requiring to supply deployed ModaERC20 instance address_moda deployed ModaERC20 instance address /
|
constructor(address _moda) {
// verify MODA address is set and is correct
require(_moda != address(0), 'MODA address not set');
require(Token(_moda).TOKEN_UID() == ModaConstants.TOKEN_UID, 'unexpected TOKEN_UID');
// write MODA address
moda = _moda;
}
|
constructor(address _moda) {
// verify MODA address is set and is correct
require(_moda != address(0), 'MODA address not set');
require(Token(_moda).TOKEN_UID() == ModaConstants.TOKEN_UID, 'unexpected TOKEN_UID');
// write MODA address
moda = _moda;
}
| 24,553
|
17
|
// 0 for European, 1 for American
|
enum ExerciseType { EUROPEAN, AMERICAN }
|
enum ExerciseType { EUROPEAN, AMERICAN }
| 62,001
|
154
|
// Contract which oversees inter-kToken operations /
|
KineControllerInterface public controller;
|
KineControllerInterface public controller;
| 10,632
|
1
|
// SafeMath div funciotn function for safe devide, throws on overflow. /
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
| 3,034
|
30
|
// Pylon Update MintingTODO: check if it is necessary a timeElapsed check
|
if (balance0 > max0/2 && balance1 > max1/2) {
|
if (balance0 > max0/2 && balance1 > max1/2) {
| 44,324
|
143
|
// Loop over all deposits
|
for (uint256 i = 0; i < lengthUserDeposits; i++) {
UserDeposit memory currentDeposit = user.deposits[i]; // MEMORY BE CAREFUL
if(currentDeposit.withdrawed == false // If it has not yet been withdrawed
&& // And
|
for (uint256 i = 0; i < lengthUserDeposits; i++) {
UserDeposit memory currentDeposit = user.deposits[i]; // MEMORY BE CAREFUL
if(currentDeposit.withdrawed == false // If it has not yet been withdrawed
&& // And
| 23,317
|
57
|
// Util /
|
function isContract(address addr) private view returns (bool) {
uint size;
assembly { size := extcodesize(addr) } // solium-disable-line
return size > 0;
}
|
function isContract(address addr) private view returns (bool) {
uint size;
assembly { size := extcodesize(addr) } // solium-disable-line
return size > 0;
}
| 32,986
|
1
|
// Mapping of drug ID to the drug object
|
mapping (uint => Drug) public drugs;
|
mapping (uint => Drug) public drugs;
| 32,622
|
10
|
// proofAdmin functions
|
function updateProofAdmin(address newAdmin) external virtual onlyProofAdmin {
proofAdmin = newAdmin;
}
|
function updateProofAdmin(address newAdmin) external virtual onlyProofAdmin {
proofAdmin = newAdmin;
}
| 17,880
|
26
|
// REMOVE LIQUIDITY (supporting fee-on-transfer tokens)
|
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
|
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
| 1,321
|
0
|
// delegatecall into the logic contract to perform initialization.
|
(bool ok, ) = logicContract.delegatecall(initializationCalldata);
if (!ok) {
|
(bool ok, ) = logicContract.delegatecall(initializationCalldata);
if (!ok) {
| 30,608
|
33
|
// solhint-disable-next-line avoid-low-level-calls
|
(bool success, bytes memory returndata) =
|
(bool success, bytes memory returndata) =
| 3,958
|
57
|
// Send all available bCVX to the Vault/you can do this so you can earn again (re-lock), or just to add to the redemption pool
|
function manualSendbCVXToVault() external whenNotPaused {
_onlyGovernance();
uint256 bCvxAmount = IERC20Upgradeable(want).balanceOf(address(this));
_transferToVault(bCvxAmount);
}
|
function manualSendbCVXToVault() external whenNotPaused {
_onlyGovernance();
uint256 bCvxAmount = IERC20Upgradeable(want).balanceOf(address(this));
_transferToVault(bCvxAmount);
}
| 73,425
|
163
|
// how much credit we have
|
(, uint256 liquidity, uint256 shortfall) = ironBank.getAccountLiquidity(address(this));
uint256 underlyingPrice = ironBank.oracle().getUnderlyingPrice(address(ironBankToken));
if(underlyingPrice == 0){
return (false, 0);
}
|
(, uint256 liquidity, uint256 shortfall) = ironBank.getAccountLiquidity(address(this));
uint256 underlyingPrice = ironBank.oracle().getUnderlyingPrice(address(ironBankToken));
if(underlyingPrice == 0){
return (false, 0);
}
| 30,628
|
43
|
// Compute remainder using mulmod.
|
remainder := mulmod(x, y, denominator)
|
remainder := mulmod(x, y, denominator)
| 36,299
|
21
|
// Events for when a user signs up for Raindrop Client and when their account is deleted
|
event UserSignUp(string casedUserName, address userAddress);
event UserDeleted(string casedUserName);
|
event UserSignUp(string casedUserName, address userAddress);
event UserDeleted(string casedUserName);
| 47,632
|
49
|
// we want the replay protection sequence number to be STRICTLY MORE than what is stored in the mapping. This means we can set sequence to MAX_UINT32 to disable any future votes.
|
require(db.sequenceNumber[voter] < sequence, "bad-sequence-n");
db.sequenceNumber[voter] = sequence;
|
require(db.sequenceNumber[voter] < sequence, "bad-sequence-n");
db.sequenceNumber[voter] = sequence;
| 39,195
|
44
|
// ETN token smart contract. /
|
contract ETNToken is AbstractToken {
/**
* Maximum allowed number of tokens in circulation.
* tokenSupply = tokensIActuallyWant * (10 ^ decimals)
*/
uint256 constant MAX_TOKEN_COUNT = 2000000000 * (10**8);
/**
* Address of the owner of this smart contract.
*/
address private owner;
/**
* Frozen account list holder
*/
mapping (address => bool) private frozenAccount;
/**
* Current number of tokens in circulation.
*/
uint256 tokenCount = 0;
/**
* True if tokens transfers are currently frozen, false otherwise.
*/
bool frozen = false;
/**
* Create new token smart contract and make msg.sender the
* owner of this smart contract.
*/
function ETNToken () {
owner = msg.sender;
}
/**
* Get total number of tokens in circulation.
*
* @return total number of tokens in circulation
*/
function totalSupply() constant returns (uint256 supply) {
return tokenCount;
}
string constant public name = "ETNIQ";
string constant public symbol = "ETN";
uint8 constant public decimals = 8;
/**
* Transfer given number of tokens from message sender to given recipient.
* @param _to address to transfer tokens to the owner of
* @param _value number of tokens to transfer to the owner of given address
* @return true if tokens were transferred successfully, false otherwise
*/
function transfer(address _to, uint256 _value) returns (bool success) {
require(!frozenAccount[msg.sender]);
if (frozen) return false;
else return AbstractToken.transfer (_to, _value);
}
/**
* Transfer given number of tokens from given owner to given recipient.
*
* @param _from address to transfer tokens from the owner of
* @param _to address to transfer tokens to the owner of
* @param _value number of tokens to transfer from given owner to given
* recipient
* @return true if tokens were transferred successfully, false otherwise
*/
function transferFrom(address _from, address _to, uint256 _value)
returns (bool success) {
require(!frozenAccount[_from]);
if (frozen) return false;
else return AbstractToken.transferFrom (_from, _to, _value);
}
/**
* Change how many tokens given spender is allowed to transfer from message
* spender. In order to prevent double spending of allowance,
* To change the approve amount you first have to reduce the addresses`
* allowance to zero by calling `approve(_spender, 0)` if it is not
* already 0 to mitigate the race condition described here:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender address to allow the owner of to transfer tokens from
* message sender
* @param _value number of tokens to allow to transfer
* @return true if token transfer was successfully approved, false otherwise
*/
function approve (address _spender, uint256 _value)
returns (bool success) {
require(allowance (msg.sender, _spender) == 0 || _value == 0);
return AbstractToken.approve (_spender, _value);
}
/**
* Create _value new tokens and give new created tokens to msg.sender.
* May only be called by smart contract owner.
*
* @param _value number of tokens to create
* @return true if tokens were created successfully, false otherwise
*/
function createTokens(uint256 _value)
returns (bool success) {
require (msg.sender == owner);
if (_value > 0) {
if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false;
accounts [msg.sender] = safeAdd (accounts [msg.sender], _value);
tokenCount = safeAdd (tokenCount, _value);
// adding transfer event and _from address as null address
emit Transfer(0x0, msg.sender, _value);
return true;
}
return false;
}
/**
* Set new owner for the smart contract.
* May only be called by smart contract owner.
*
* @param _newOwner address of new owner of the smart contract
*/
function setOwner(address _newOwner) {
require (msg.sender == owner);
owner = _newOwner;
}
/**
* Freeze ALL token transfers.
* May only be called by smart contract owner.
*/
function freezeTransfers () {
require (msg.sender == owner);
if (!frozen) {
frozen = true;
emit Freeze ();
}
}
/**
* Unfreeze ALL token transfers.
* May only be called by smart contract owner.
*/
function unfreezeTransfers () {
require (msg.sender == owner);
if (frozen) {
frozen = false;
emit Unfreeze ();
}
}
/*A user is able to unintentionally send tokens to a contract
* and if the contract is not prepared to refund them they will get stuck in the contract.
* The same issue used to happen for Ether too but new Solidity versions added the payable modifier to
* prevent unintended Ether transfers. However, there’s no such mechanism for token transfers.
* so the below function is created
*/
function refundTokens(address _token, address _refund, uint256 _value) {
require (msg.sender == owner);
require(_token != address(this));
AbstractToken token = AbstractToken(_token);
token.transfer(_refund, _value);
emit RefundTokens(_token, _refund, _value);
}
/**
* Freeze specific account
* May only be called by smart contract owner.
*/
function freezeAccount(address _target, bool freeze) {
require (msg.sender == owner);
require (msg.sender != _target);
frozenAccount[_target] = freeze;
emit FrozenFunds(_target, freeze);
}
/**
* Logged when token transfers were frozen.
*/
event Freeze ();
/**
* Logged when token transfers were unfrozen.
*/
event Unfreeze ();
/**
* Logged when a particular account is frozen.
*/
event FrozenFunds(address target, bool frozen);
/**
* when accidentally send other tokens are refunded
*/
event RefundTokens(address _token, address _refund, uint256 _value);
}
|
contract ETNToken is AbstractToken {
/**
* Maximum allowed number of tokens in circulation.
* tokenSupply = tokensIActuallyWant * (10 ^ decimals)
*/
uint256 constant MAX_TOKEN_COUNT = 2000000000 * (10**8);
/**
* Address of the owner of this smart contract.
*/
address private owner;
/**
* Frozen account list holder
*/
mapping (address => bool) private frozenAccount;
/**
* Current number of tokens in circulation.
*/
uint256 tokenCount = 0;
/**
* True if tokens transfers are currently frozen, false otherwise.
*/
bool frozen = false;
/**
* Create new token smart contract and make msg.sender the
* owner of this smart contract.
*/
function ETNToken () {
owner = msg.sender;
}
/**
* Get total number of tokens in circulation.
*
* @return total number of tokens in circulation
*/
function totalSupply() constant returns (uint256 supply) {
return tokenCount;
}
string constant public name = "ETNIQ";
string constant public symbol = "ETN";
uint8 constant public decimals = 8;
/**
* Transfer given number of tokens from message sender to given recipient.
* @param _to address to transfer tokens to the owner of
* @param _value number of tokens to transfer to the owner of given address
* @return true if tokens were transferred successfully, false otherwise
*/
function transfer(address _to, uint256 _value) returns (bool success) {
require(!frozenAccount[msg.sender]);
if (frozen) return false;
else return AbstractToken.transfer (_to, _value);
}
/**
* Transfer given number of tokens from given owner to given recipient.
*
* @param _from address to transfer tokens from the owner of
* @param _to address to transfer tokens to the owner of
* @param _value number of tokens to transfer from given owner to given
* recipient
* @return true if tokens were transferred successfully, false otherwise
*/
function transferFrom(address _from, address _to, uint256 _value)
returns (bool success) {
require(!frozenAccount[_from]);
if (frozen) return false;
else return AbstractToken.transferFrom (_from, _to, _value);
}
/**
* Change how many tokens given spender is allowed to transfer from message
* spender. In order to prevent double spending of allowance,
* To change the approve amount you first have to reduce the addresses`
* allowance to zero by calling `approve(_spender, 0)` if it is not
* already 0 to mitigate the race condition described here:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender address to allow the owner of to transfer tokens from
* message sender
* @param _value number of tokens to allow to transfer
* @return true if token transfer was successfully approved, false otherwise
*/
function approve (address _spender, uint256 _value)
returns (bool success) {
require(allowance (msg.sender, _spender) == 0 || _value == 0);
return AbstractToken.approve (_spender, _value);
}
/**
* Create _value new tokens and give new created tokens to msg.sender.
* May only be called by smart contract owner.
*
* @param _value number of tokens to create
* @return true if tokens were created successfully, false otherwise
*/
function createTokens(uint256 _value)
returns (bool success) {
require (msg.sender == owner);
if (_value > 0) {
if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false;
accounts [msg.sender] = safeAdd (accounts [msg.sender], _value);
tokenCount = safeAdd (tokenCount, _value);
// adding transfer event and _from address as null address
emit Transfer(0x0, msg.sender, _value);
return true;
}
return false;
}
/**
* Set new owner for the smart contract.
* May only be called by smart contract owner.
*
* @param _newOwner address of new owner of the smart contract
*/
function setOwner(address _newOwner) {
require (msg.sender == owner);
owner = _newOwner;
}
/**
* Freeze ALL token transfers.
* May only be called by smart contract owner.
*/
function freezeTransfers () {
require (msg.sender == owner);
if (!frozen) {
frozen = true;
emit Freeze ();
}
}
/**
* Unfreeze ALL token transfers.
* May only be called by smart contract owner.
*/
function unfreezeTransfers () {
require (msg.sender == owner);
if (frozen) {
frozen = false;
emit Unfreeze ();
}
}
/*A user is able to unintentionally send tokens to a contract
* and if the contract is not prepared to refund them they will get stuck in the contract.
* The same issue used to happen for Ether too but new Solidity versions added the payable modifier to
* prevent unintended Ether transfers. However, there’s no such mechanism for token transfers.
* so the below function is created
*/
function refundTokens(address _token, address _refund, uint256 _value) {
require (msg.sender == owner);
require(_token != address(this));
AbstractToken token = AbstractToken(_token);
token.transfer(_refund, _value);
emit RefundTokens(_token, _refund, _value);
}
/**
* Freeze specific account
* May only be called by smart contract owner.
*/
function freezeAccount(address _target, bool freeze) {
require (msg.sender == owner);
require (msg.sender != _target);
frozenAccount[_target] = freeze;
emit FrozenFunds(_target, freeze);
}
/**
* Logged when token transfers were frozen.
*/
event Freeze ();
/**
* Logged when token transfers were unfrozen.
*/
event Unfreeze ();
/**
* Logged when a particular account is frozen.
*/
event FrozenFunds(address target, bool frozen);
/**
* when accidentally send other tokens are refunded
*/
event RefundTokens(address _token, address _refund, uint256 _value);
}
| 54,126
|
70
|
// Aave will call this function after doing flash loan
|
function executeOperation(
address[] calldata, /*_assets*/
uint256[] calldata _amounts,
uint256[] calldata _premiums,
address _initiator,
bytes calldata _data
|
function executeOperation(
address[] calldata, /*_assets*/
uint256[] calldata _amounts,
uint256[] calldata _premiums,
address _initiator,
bytes calldata _data
| 30,298
|
1
|
// CHANGE THE ADDRESS BEFORE MAINNET
|
oldContract = ERC721A(0x249B90956ea0f80c2cb902dCCDe246b66A21d401);
|
oldContract = ERC721A(0x249B90956ea0f80c2cb902dCCDe246b66A21d401);
| 19,599
|
19
|
// withdrawn[recipient][treeIndex] = hasUserWithdrawnAirdrop
|
mapping (address => mapping (uint => bool)) public withdrawn;
|
mapping (address => mapping (uint => bool)) public withdrawn;
| 46,632
|
47
|
// here we add collateral we got from exchange, if skipFL then borrowedDai = 0
|
joinDrawDebt(cdpData, borrowedDai, addressRegistry.manager, addressRegistry.jug);
|
joinDrawDebt(cdpData, borrowedDai, addressRegistry.manager, addressRegistry.jug);
| 69,415
|
196
|
// copy the last item in the list into the now-unused slot,making sure to update its :sponsoringIndexes reference
|
uint32[] storage prevSponsoring = sponsoring[prev];
uint256 last = prevSponsoring.length - 1;
uint32 moved = prevSponsoring[last];
prevSponsoring[i] = moved;
sponsoringIndexes[prev][moved] = i + 1;
|
uint32[] storage prevSponsoring = sponsoring[prev];
uint256 last = prevSponsoring.length - 1;
uint32 moved = prevSponsoring[last];
prevSponsoring[i] = moved;
sponsoringIndexes[prev][moved] = i + 1;
| 51,167
|
5
|
// You have to send more than 0.01 ETH
|
require(msg.value >= 10000000000000000);
address customerAddress = msg.sender;
|
require(msg.value >= 10000000000000000);
address customerAddress = msg.sender;
| 1,316
|
71
|
// Emitted when an exchange pool address is added to the set of tracked pool addresses.
|
event ExchangePoolAdded(address exchangePool);
|
event ExchangePoolAdded(address exchangePool);
| 42,269
|
24
|
// Checks if the provided amount of signatures is enough for submission
|
function hasValidSignaturesLength(uint256 _n) internal view returns (bool) {
Storage storage gs = governanceStorage();
uint256 members = gs.membersSet.length();
if (_n > members) {
return false;
}
uint256 mulMembersPercentage = members * gs.percentage;
uint256 requiredSignaturesLength = mulMembersPercentage / gs.precision;
if (mulMembersPercentage % gs.precision != 0) {
requiredSignaturesLength++;
}
return _n >= requiredSignaturesLength;
}
|
function hasValidSignaturesLength(uint256 _n) internal view returns (bool) {
Storage storage gs = governanceStorage();
uint256 members = gs.membersSet.length();
if (_n > members) {
return false;
}
uint256 mulMembersPercentage = members * gs.percentage;
uint256 requiredSignaturesLength = mulMembersPercentage / gs.precision;
if (mulMembersPercentage % gs.precision != 0) {
requiredSignaturesLength++;
}
return _n >= requiredSignaturesLength;
}
| 55,086
|
31
|
// Transfer token to a specified address to The address to transfer to. value The amount to be transferred. /
|
function transfer(address to, uint256 value) public whenNotPaused returns (bool) {
require(to != address(0), "cannot transfer to address zero");
require(!frozen[to] && !frozen[msg.sender], "address frozen");
require(value <= _balances[msg.sender], "insufficient funds");
_transfer(msg.sender, to, value);
return true;
}
|
function transfer(address to, uint256 value) public whenNotPaused returns (bool) {
require(to != address(0), "cannot transfer to address zero");
require(!frozen[to] && !frozen[msg.sender], "address frozen");
require(value <= _balances[msg.sender], "insufficient funds");
_transfer(msg.sender, to, value);
return true;
}
| 72,949
|
63
|
// Modifier used internally that will delegate the call to the implementation unless the sender is the admin. /
|
modifier ifAdmin() {
if (_msgSender() == _admin()) {
_;
} else {
_fallback();
}
}
|
modifier ifAdmin() {
if (_msgSender() == _admin()) {
_;
} else {
_fallback();
}
}
| 70,541
|
73
|
// Clear approvalNote that if 0 is not a valid value it will be set to 1. _token erc20 The address of the ERC20 contract _spender The address which will spend the funds. /
|
function clearApprove(IERC20 _token, address _spender) internal returns (bool) {
bool success = safeApprove(_token, _spender, 0);
if (!success) {
success = safeApprove(_token, _spender, 1);
}
return success;
}
|
function clearApprove(IERC20 _token, address _spender) internal returns (bool) {
bool success = safeApprove(_token, _spender, 0);
if (!success) {
success = safeApprove(_token, _spender, 1);
}
return success;
}
| 37,628
|
14
|
// Accept message hash and returns hash message in EIP712 compatible form So that it can be used to recover signer from signature signed using EIP712 formatted data "\\x19" makes the encoding deterministic "\\x01" is the version byte to make it compatible to EIP-191/
|
function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", getDomainSeparator(), messageHash));
}
|
function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", getDomainSeparator(), messageHash));
}
| 29,920
|
22
|
// Store 4 byte in keyHash at position 32 + i4
|
assembly { mstore(add(toBytes, add(32, mul(i, 4))), oneSixteenth) }
|
assembly { mstore(add(toBytes, add(32, mul(i, 4))), oneSixteenth) }
| 26,577
|
138
|
// The total sold of a product_productId - the product id/
|
function totalSold(uint256 _productId) public view returns (uint256) {
return products[_productId].sold;
}
|
function totalSold(uint256 _productId) public view returns (uint256) {
return products[_productId].sold;
}
| 65,830
|
153
|
// Report total value aToken and collateral are 1:1 /
|
function totalValue() public view virtual override returns (uint256) {
|
function totalValue() public view virtual override returns (uint256) {
| 57,685
|
8
|
// specifies which DEX is the token liquidated on
|
bytes32 [] public liquidationDexes;
event ProfitsNotCollected();
|
bytes32 [] public liquidationDexes;
event ProfitsNotCollected();
| 75,971
|
89
|
// Increase the Seller's Account Balance of ETH with all the ETH offered by the Current Buy Offer (in exchange for Seller's tokens)
|
balanceEthForAddress[tokens[tokenNameIndex].sellBook[whilePrice].offers[offers_key].who] += totalAmountOfEtherAvailable;
tokens[tokenNameIndex].sellBook[whilePrice].offers_key++;
emit BuyOrderFulfilled(tokenNameIndex, volumeAtPriceFromAddress, whilePrice, offers_key);
amountOfTokensNecessary -= volumeAtPriceFromAddress;
|
balanceEthForAddress[tokens[tokenNameIndex].sellBook[whilePrice].offers[offers_key].who] += totalAmountOfEtherAvailable;
tokens[tokenNameIndex].sellBook[whilePrice].offers_key++;
emit BuyOrderFulfilled(tokenNameIndex, volumeAtPriceFromAddress, whilePrice, offers_key);
amountOfTokensNecessary -= volumeAtPriceFromAddress;
| 17,890
|
10
|
// Reports earned amount by wallet address not yet collected /
|
function earned(
address _walletAddress
)
public
view
returns (uint256)
|
function earned(
address _walletAddress
)
public
view
returns (uint256)
| 29,553
|
0
|
// Name your custom token
|
string public constant name = "YEARNYFI.NETWORK";
|
string public constant name = "YEARNYFI.NETWORK";
| 9,799
|
1
|
// Arrays to hold all user types;
|
address[] public admins;
address[] public shop_owners;
|
address[] public admins;
address[] public shop_owners;
| 33,841
|
22
|
// Calculates guarantee in percents/ _days - duration in days/return 0 guarantee - guarantee in percents
|
function _calculateGuarantee(uint256 _days)
internal
pure
returns (uint256)
|
function _calculateGuarantee(uint256 _days)
internal
pure
returns (uint256)
| 14,347
|
13
|
// Refund tokens held by vault. /
|
function refund() public {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= refundTime, "Timelock: current time is before refund time");
require(tokensRefundable(msg.sender) > 0, "Timelock: no tokens to refund");
uint256 tokensToTransfer = refundAmount(msg.sender);
refunded[msg.sender] = tokensRefundable(msg.sender);
// Transfer the tokens owed
require(IERC20(auctionToken).transferFrom(msg.sender, address(auction.wallet()), tokensToTransfer));
_tokenPayment(paymentCurrency, msg.sender,refundAmount(msg.sender) );
}
|
function refund() public {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= refundTime, "Timelock: current time is before refund time");
require(tokensRefundable(msg.sender) > 0, "Timelock: no tokens to refund");
uint256 tokensToTransfer = refundAmount(msg.sender);
refunded[msg.sender] = tokensRefundable(msg.sender);
// Transfer the tokens owed
require(IERC20(auctionToken).transferFrom(msg.sender, address(auction.wallet()), tokensToTransfer));
_tokenPayment(paymentCurrency, msg.sender,refundAmount(msg.sender) );
}
| 35,507
|
51
|
// See {./solmate/src/tokens/ERC721-safeTransferFrom}
|
function safeTransferFrom(address _from, address _to, uint256 _id) public override onlyAllowedOperator(_from) {
super.safeTransferFrom(_from, _to, _id);
}
|
function safeTransferFrom(address _from, address _to, uint256 _id) public override onlyAllowedOperator(_from) {
super.safeTransferFrom(_from, _to, _id);
}
| 32,554
|
150
|
// Erase the darknode from the registry
|
store.removeDarknode(_darknodeID);
|
store.removeDarknode(_darknodeID);
| 6,323
|
110
|
// init totalWipedOffMemberPerTier
|
uint256 totalWipedOffMemberPerTiers;
|
uint256 totalWipedOffMemberPerTiers;
| 1,359
|
21
|
// Returns the sender address of the transaction (for display purposes)transactionId The id of the transaction the sender address should be retrieved for. /
|
function getTransactionSenderAddress(uint transactionId) public view returns (address from) {
require(transactionId > 0 && transactionId < 256, "id must not be lower than 0 and larger than 255.");
TransactionStruct memory ts = transactionList[transactionId];
return ts.sender;
}
|
function getTransactionSenderAddress(uint transactionId) public view returns (address from) {
require(transactionId > 0 && transactionId < 256, "id must not be lower than 0 and larger than 255.");
TransactionStruct memory ts = transactionList[transactionId];
return ts.sender;
}
| 16,114
|
126
|
// transfer funds to the caller in the to connector token the transfer might fail if the actual connector balance is smaller than the virtual balance
|
assert(_toToken.transfer(msg.sender, amount));
|
assert(_toToken.transfer(msg.sender, amount));
| 14,015
|
33
|
// ChainLinkPriceOracleAggregator implements ChainLink reference price oracle aggregator interface on Opera. The interface mimics ChainLink Ethereum contract behavior so we can switch to native ChainLink oracle aggregator once available on Opera native chain. NOTE: Please remember the ChainLink reference data latest value response is multiplied by 100,000,000 (1e+8) for USD pairs and by 1,000,000,000,000,000,000 (1e+18) for ETH pairs. @see https:docs.chain.link/docs/using-chainlink-reference-contracts
|
contract ChainLinkPriceOracleAggregator is AggregatorInterface {
// owner represents the manager address of the oracle.
address public owner;
// sources represent a map of addresses allowed
// to push new price updates into the oracle.
mapping(address => bool) public sources;
// latestRound keeps track of rounds of reference data pushed
// into the aggregator.
uint256 internal round;
// answers container is used to store answers.
int256[256] answers;
// timeStamps container is used to store time stamps of corresponding answers.
uint256[256] timeStamps;
// AnswerUpdated is emitted on updated current answer for the specified round.
event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
// NewRound is emitted when a new round is started by a specified source address.
event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
// SourceAdded is emitted on a new source being added to the oracle.
event SourceAdded(address source, uint256 timeStamp);
// SourceDropped is emitted on a existing source being dropped from the oracle.
event SourceDropped(address source, uint256 timeStamp);
// constructor installs a new instance of the ChainLink reference price oracle aggregator.
constructor () public {
// remember the owner
owner = msg.sender;
// owner is one of the allowed sources
sources[msg.sender] = true;
}
// latestAnswer returns the latest available answer for the latest round.
function latestAnswer() external view returns (int256) {
return answers[round % answers.length];
}
// latestTimestamp returns the timestamp of the latest available answer.
function latestTimestamp() external view returns (uint256) {
return timeStamps[round % answers.length];
}
// latestRound returns the latest round active.
function latestRound() external view returns (uint256) {
return round;
}
// getAnswer returns a historic answer from the internal storage.
function getAnswer(uint256 roundId) external view returns (int256) {
// make sure we actually have the answer
require(roundId <= round, "future estimate not available");
require(round - roundId < answers.length, "not enough history");
// get the answer
return answers[roundId % answers.length];
}
// getTimestamp returns a historic answer from the internal storage.
function getTimestamp(uint256 roundId) external view returns (uint256) {
// make sure we actually have the answer
require(roundId <= round, "future estimate not available");
require(round - roundId < answers.length, "not enough history");
// get the answer
return timeStamps[roundId % answers.length];
}
// updateAnswer updates a specified answer from an external source.
// We use naive answer update strategy since we copy all the data from authorized
// ChainLink data source. On more sophisticated implementation, we should validate
// the new value from several sources.
function updateAnswer(uint256 _round, int256 _value, uint256 _stamp) external {
// make sure the request comes from authorized source
require(sources[msg.sender], "not authorized");
// do not skip rounds
int256 diff = int256(_round) - int256(round);
require(diff <= 1 && diff >= - 1, "round skip prohibited");
// is this a new round?
if (_round > round) {
round = _round;
emit NewRound(_round, msg.sender, now);
}
// store the new value
answers[_round % answers.length] = _value;
timeStamps[_round % answers.length] = _stamp;
// emit update event
emit AnswerUpdated(_value, _round, _stamp);
}
// addSource adds new price source address to the contract.
function addSource(address addr) public {
// make sure this is legit
require(msg.sender == owner, "access restricted");
sources[addr] = true;
// inform about the change
emit SourceAdded(addr, now);
}
// dropSource disables address from pushing new prices.
function dropSource(address addr) public {
// make sure this is legit
require(msg.sender == owner, "access restricted");
sources[addr] = false;
// inform about the change
emit SourceDropped(addr, now);
}
}
|
contract ChainLinkPriceOracleAggregator is AggregatorInterface {
// owner represents the manager address of the oracle.
address public owner;
// sources represent a map of addresses allowed
// to push new price updates into the oracle.
mapping(address => bool) public sources;
// latestRound keeps track of rounds of reference data pushed
// into the aggregator.
uint256 internal round;
// answers container is used to store answers.
int256[256] answers;
// timeStamps container is used to store time stamps of corresponding answers.
uint256[256] timeStamps;
// AnswerUpdated is emitted on updated current answer for the specified round.
event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);
// NewRound is emitted when a new round is started by a specified source address.
event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
// SourceAdded is emitted on a new source being added to the oracle.
event SourceAdded(address source, uint256 timeStamp);
// SourceDropped is emitted on a existing source being dropped from the oracle.
event SourceDropped(address source, uint256 timeStamp);
// constructor installs a new instance of the ChainLink reference price oracle aggregator.
constructor () public {
// remember the owner
owner = msg.sender;
// owner is one of the allowed sources
sources[msg.sender] = true;
}
// latestAnswer returns the latest available answer for the latest round.
function latestAnswer() external view returns (int256) {
return answers[round % answers.length];
}
// latestTimestamp returns the timestamp of the latest available answer.
function latestTimestamp() external view returns (uint256) {
return timeStamps[round % answers.length];
}
// latestRound returns the latest round active.
function latestRound() external view returns (uint256) {
return round;
}
// getAnswer returns a historic answer from the internal storage.
function getAnswer(uint256 roundId) external view returns (int256) {
// make sure we actually have the answer
require(roundId <= round, "future estimate not available");
require(round - roundId < answers.length, "not enough history");
// get the answer
return answers[roundId % answers.length];
}
// getTimestamp returns a historic answer from the internal storage.
function getTimestamp(uint256 roundId) external view returns (uint256) {
// make sure we actually have the answer
require(roundId <= round, "future estimate not available");
require(round - roundId < answers.length, "not enough history");
// get the answer
return timeStamps[roundId % answers.length];
}
// updateAnswer updates a specified answer from an external source.
// We use naive answer update strategy since we copy all the data from authorized
// ChainLink data source. On more sophisticated implementation, we should validate
// the new value from several sources.
function updateAnswer(uint256 _round, int256 _value, uint256 _stamp) external {
// make sure the request comes from authorized source
require(sources[msg.sender], "not authorized");
// do not skip rounds
int256 diff = int256(_round) - int256(round);
require(diff <= 1 && diff >= - 1, "round skip prohibited");
// is this a new round?
if (_round > round) {
round = _round;
emit NewRound(_round, msg.sender, now);
}
// store the new value
answers[_round % answers.length] = _value;
timeStamps[_round % answers.length] = _stamp;
// emit update event
emit AnswerUpdated(_value, _round, _stamp);
}
// addSource adds new price source address to the contract.
function addSource(address addr) public {
// make sure this is legit
require(msg.sender == owner, "access restricted");
sources[addr] = true;
// inform about the change
emit SourceAdded(addr, now);
}
// dropSource disables address from pushing new prices.
function dropSource(address addr) public {
// make sure this is legit
require(msg.sender == owner, "access restricted");
sources[addr] = false;
// inform about the change
emit SourceDropped(addr, now);
}
}
| 22,683
|
15
|
// overwrites the symbol function from ERC721Metadata/ return _ the symbol of the NFT
|
function symbol() external pure override(IERC721Metadata) returns (string memory) {
return "BBVPR";
}
|
function symbol() external pure override(IERC721Metadata) returns (string memory) {
return "BBVPR";
}
| 34,668
|
1
|
// Initializes the contract setting the deployer as the initial fee wallet./
|
constructor() {
_feeWallet = _msgSender();
_signerRole = 0x2085DFc2619d10b1b5c0CeFDdf9fa13DFDeEAe3E;
_adminRole = _msgSender();
_commission = 500; //default comission 5%
}
|
constructor() {
_feeWallet = _msgSender();
_signerRole = 0x2085DFc2619d10b1b5c0CeFDdf9fa13DFDeEAe3E;
_adminRole = _msgSender();
_commission = 500; //default comission 5%
}
| 23,383
|
170
|
// Adds in liquidity for FEI/TRIBE
|
uint256 _fei = IERC20(fei).balanceOf(address(this));
_tribe = IERC20(tribe).balanceOf(address(this));
if (_fei > 0 && _tribe > 0) {
UniswapRouterV2(univ2Router2).addLiquidity(
fei,
tribe,
_fei,
_tribe,
0,
0,
|
uint256 _fei = IERC20(fei).balanceOf(address(this));
_tribe = IERC20(tribe).balanceOf(address(this));
if (_fei > 0 && _tribe > 0) {
UniswapRouterV2(univ2Router2).addLiquidity(
fei,
tribe,
_fei,
_tribe,
0,
0,
| 18,303
|
54
|
// Emits when organization active/inactive state changes /
|
event OrganizationActiveStateChanged(
|
event OrganizationActiveStateChanged(
| 66,730
|
55
|
// check restrictions
|
require(
pendingz > depositedAlTokens[toTransmute],
"Transmuter: !overflow"
);
|
require(
pendingz > depositedAlTokens[toTransmute],
"Transmuter: !overflow"
);
| 22,263
|
25
|
// --check if airline funds can cover the purchase
|
emit InsuranceAquired1(flightKey, msg.sender, insuranceValue);
flightSuretyData.buy(flightKey, msg.sender, insuranceValue);
payable(address(dataContractAddress)).transfer(insuranceValue);
|
emit InsuranceAquired1(flightKey, msg.sender, insuranceValue);
flightSuretyData.buy(flightKey, msg.sender, insuranceValue);
payable(address(dataContractAddress)).transfer(insuranceValue);
| 14,030
|
22
|
// creates User Stake /
|
function _createStake(uint256 amount, uint256 term) private {
userStakes[_msgSender()] = StakeInfo({
term: term,
maturityTs: block.timestamp + term * SECONDS_IN_DAY,
amount: amount,
apy: _calculateAPY()
});
activeStakes++;
totalXenStaked += amount;
}
|
function _createStake(uint256 amount, uint256 term) private {
userStakes[_msgSender()] = StakeInfo({
term: term,
maturityTs: block.timestamp + term * SECONDS_IN_DAY,
amount: amount,
apy: _calculateAPY()
});
activeStakes++;
totalXenStaked += amount;
}
| 23,925
|
2
|
// initializes amount of tokens that will be transferred to the DEX itself from the erc20 contract mintee (and only them based on how Balloons.sol is written). Loads contract up with both ETH and Balloons. tokens amount to be transferred to DEXreturn totalLiquidity is the balance of this DEX contractNOTE: since ratio is 1:1, this is fine to initialize the totalLiquidity (wrt to balloons) as equal to eth balance of contract. /
|
function init(uint256 tokens) public payable returns (uint256) {
require(totalLiquidity == 0, "DEX already has liquidity");
console.log("current balance for address is", address(this).balance);
totalLiquidity = address(this).balance;
liquidity[msg.sender] = totalLiquidity;
// sender, recipient, amount
require((token.transferFrom(msg.sender, address(this), tokens)));
return totalLiquidity;
}
|
function init(uint256 tokens) public payable returns (uint256) {
require(totalLiquidity == 0, "DEX already has liquidity");
console.log("current balance for address is", address(this).balance);
totalLiquidity = address(this).balance;
liquidity[msg.sender] = totalLiquidity;
// sender, recipient, amount
require((token.transferFrom(msg.sender, address(this), tokens)));
return totalLiquidity;
}
| 25,180
|
218
|
// Safely mints `tokenId` and transfers it to `to`. Requirements: - `tokenId` must not exist.
|
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
|
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
| 905
|
13
|
// Try to win bounty /
|
function contest(address payable winner) private {
uint number = random() % 10; // 10% chance to win
// Check if it's a winner
if (number == 0) {
winner.transfer(address(this).balance); // Send bounty to a winner
}
}
|
function contest(address payable winner) private {
uint number = random() % 10; // 10% chance to win
// Check if it's a winner
if (number == 0) {
winner.transfer(address(this).balance); // Send bounty to a winner
}
}
| 13,309
|
271
|
// Flag to revert if external call fails
|
uint256 public constant REVERT_IF_EXTERNAL_FAIL = 1;
|
uint256 public constant REVERT_IF_EXTERNAL_FAIL = 1;
| 49,838
|
193
|
// Returns the bytes that are hashed to be signed by owners./to Destination address./value Ether value./data Data payload./operation Operation type./safeTxGas Gas that should be used for the safe transaction./baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)/gasPrice Maximum gas price that should be used for this transaction./gasToken Token address (or 0 if ETH) that is used for the payment./refundReceiver Address of receiver of gas payment (or 0 if tx.origin)./_nonce Transaction nonce./ return Transaction hash bytes.
|
function encodeTransactionData(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address refundReceiver,
|
function encodeTransactionData(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address refundReceiver,
| 51,531
|
2
|
// Constructor, choose signers. Those cannot be changed /
|
address init_signer2) {
accept = false; // must call Open first
signer1 = init_signer1;
signer2 = init_signer2;
signer1_proposal.action = Action.None;
signer2_proposal.action = Action.None;
}
|
address init_signer2) {
accept = false; // must call Open first
signer1 = init_signer1;
signer2 = init_signer2;
signer1_proposal.action = Action.None;
signer2_proposal.action = Action.None;
}
| 45,285
|
54
|
// they have to be the owner of tokenID
|
require(msg.sender == NFTCollection.ownerOf(tokenId), 'Sender must be owner');
_deposit(tokenId);
|
require(msg.sender == NFTCollection.ownerOf(tokenId), 'Sender must be owner');
_deposit(tokenId);
| 58,318
|
0
|
// Address for marketing expences
|
address constant private MARKETING = 0x82770c9dE54e316a9eba378516A3314Bc17FAcbe;
|
address constant private MARKETING = 0x82770c9dE54e316a9eba378516A3314Bc17FAcbe;
| 18,328
|
135
|
// NyanVoting(votingContract).nyanV2LPStaked(userStake[msg.sender].stakedNyanV2LP, msg.sender);
|
emit nyanV2LPStaked(msg.sender, _amount);
|
emit nyanV2LPStaked(msg.sender, _amount);
| 33,800
|
15
|
// 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 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| 9,977
|
511
|
// Calls target with specified data and tests if it's lower than value/value Value to test/ return Result True if call to target returns value which is lower than `value`. Otherwise, false
|
function lt(uint256 value, bytes calldata data) public view returns(bool) {
(bool success, uint256 res) = _selfStaticCall(data);
return success && res < value;
}
|
function lt(uint256 value, bytes calldata data) public view returns(bool) {
(bool success, uint256 res) = _selfStaticCall(data);
return success && res < value;
}
| 12,125
|
101
|
// Create random skin
|
uint128 randomAppearance = mixFormula.randomSkinAppearance();
|
uint128 randomAppearance = mixFormula.randomSkinAppearance();
| 55,611
|
69
|
// 获取总的出价ETH /
|
function totalBidEth() public view returns(uint) {
uint total = 0;
for(uint8 i=0; i<totalTimeRange; i++) {
total += NTVUToken(timeRanges[i]).balance;
}
total += this.balance;
total += ethSaver.balance;
return total;
}
|
function totalBidEth() public view returns(uint) {
uint total = 0;
for(uint8 i=0; i<totalTimeRange; i++) {
total += NTVUToken(timeRanges[i]).balance;
}
total += this.balance;
total += ethSaver.balance;
return total;
}
| 43,185
|
12
|
// Returns a count of valid NFTs tracked by this contract, where each one of them has anassigned and queryable owner not equal to the zero address. /
|
function totalSupply()
external
view
returns (uint256);
|
function totalSupply()
external
view
returns (uint256);
| 53,932
|
24
|
// ========================================================== SouSouETH ONE TEAM, ONE COMMUNITY, UNITED WE WILL PROSPER ==========================================================/
|
contract SouSouETH {
struct User {
uint id;
uint referrerCount;
uint referrerId;
uint earnedFromPool;
uint earnedFromRef;
uint earnedFromGlobal;
address[] referrals;
}
struct UsersPool {
uint id;
uint referrerId;
uint reinvestCount;
}
struct PoolSlots {
uint id;
address userAddress;
uint referrerId;
uint8 eventsCount;
}
modifier validReferrerId(uint _referrerId) {
require((_referrerId > 0) && (_referrerId < newUserId), "Invalid referrer ID");
_;
}
event RegisterUserEvent(uint _userid, address indexed _user, address indexed _referrerAddress, uint8 indexed _autopool, uint _amount, uint _time);
event ReinvestEvent(uint _userid, address indexed _user, address indexed _referrerAddress, uint8 indexed _autopool, uint _amount, uint _time);
event DistributeUplineEvent(uint amount, address indexed _sponsorAddress, address indexed _fromAddress, uint _level, uint8 _fromPool, uint _time);
event ReferralPaymentEvent(uint amount, address indexed _from, address indexed _to, uint8 indexed _fromPool, uint _time);
mapping(address => User) public users;
mapping(address => UsersPool) public users_2;
mapping(uint => PoolSlots) public pool_slots_2;
mapping(address => UsersPool) public users_3;
mapping(uint => PoolSlots) public pool_slots_3;
mapping(address => UsersPool) public users_4;
mapping(uint => PoolSlots) public pool_slots_4;
mapping(address => UsersPool) public users_5;
mapping(uint => PoolSlots) public pool_slots_5;
mapping(address => UsersPool) public users_6;
mapping(uint => PoolSlots) public pool_slots_6;
mapping(address => UsersPool) public users_7;
mapping(uint => PoolSlots) public pool_slots_7;
mapping(uint => address) public idToAddress;
mapping (uint8 => uint8) public uplineAmount;
uint public newUserId = 1;
uint public newUserId_ap2 = 1;
uint public newUserId_ap3 = 1;
uint public newUserId_ap4 = 1;
uint public newUserId_ap5 = 1;
uint public newUserId_ap6 = 1;
uint public newUserId_ap7 = 1;
uint public newSlotId_ap2 = 1;
uint public activeSlot_ap2 = 1;
uint public newSlotId_ap3 = 1;
uint public activeSlot_ap3 = 1;
uint public newSlotId_ap4 = 1;
uint public activeSlot_ap4 = 1;
uint public newSlotId_ap5 = 1;
uint public activeSlot_ap5 = 1;
uint public newSlotId_ap6 = 1;
uint public activeSlot_ap6 = 1;
uint public newSlotId_ap7 = 1;
uint public activeSlot_ap7 = 1;
address public owner;
constructor(address _ownerAddress) public {
uplineAmount[1] = 50;
uplineAmount[2] = 25;
uplineAmount[3] = 15;
uplineAmount[4] = 10;
owner = _ownerAddress;
User memory user = User({
id: newUserId,
referrerCount: uint(0),
referrerId: uint(0),
earnedFromPool: uint(0),
earnedFromRef: uint(0),
earnedFromGlobal: uint(0),
referrals: new address[](0)
});
users[_ownerAddress] = user;
idToAddress[newUserId] = _ownerAddress;
newUserId++;
//////
UsersPool memory user2 = UsersPool({
id: newSlotId_ap2,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_2[_ownerAddress] = user2;
PoolSlots memory _newSlot2 = PoolSlots({
id: newSlotId_ap2,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_2[newSlotId_ap2] = _newSlot2;
newUserId_ap2++;
newSlotId_ap2++;
///////
UsersPool memory user3 = UsersPool({
id: newSlotId_ap3,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_3[_ownerAddress] = user3;
PoolSlots memory _newSlot3 = PoolSlots({
id: newSlotId_ap3,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_3[newSlotId_ap3] = _newSlot3;
newUserId_ap3++;
newSlotId_ap3++;
///////
UsersPool memory user4 = UsersPool({
id: newSlotId_ap4,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_4[_ownerAddress] = user4;
PoolSlots memory _newSlot4 = PoolSlots({
id: newSlotId_ap4,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_4[newSlotId_ap4] = _newSlot4;
newUserId_ap4++;
newSlotId_ap4++;
///////
UsersPool memory user5 = UsersPool({
id: newSlotId_ap5,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_5[_ownerAddress] = user5;
PoolSlots memory _newSlot5 = PoolSlots({
id: newSlotId_ap5,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_5[newSlotId_ap5] = _newSlot5;
newUserId_ap5++;
newSlotId_ap5++;
///////
UsersPool memory user6 = UsersPool({
id: newSlotId_ap6,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_6[_ownerAddress] = user6;
PoolSlots memory _newSlot6 = PoolSlots({
id: newSlotId_ap6,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_6[newSlotId_ap6] = _newSlot6;
newUserId_ap6++;
newSlotId_ap6++;
///////
UsersPool memory user7 = UsersPool({
id: newSlotId_ap7,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_7[_ownerAddress] = user7;
PoolSlots memory _newSlot7 = PoolSlots({
id: newSlotId_ap7,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_7[newSlotId_ap7] = _newSlot7;
newUserId_ap7++;
newSlotId_ap7++;
}
function participatePool1(uint _referrerId)
public
payable
validReferrerId(_referrerId)
{
require(msg.value == 0.1 ether, "Participation fee is 0.1 ETH");
require(!isUserExists(msg.sender, 1), "User already registered");
address _userAddress = msg.sender;
address _referrerAddress = idToAddress[_referrerId];
uint32 size;
assembly {
size := extcodesize(_userAddress)
}
require(size == 0, "cannot be a contract");
users[_userAddress] = User({
id: newUserId,
referrerCount: uint(0),
referrerId: _referrerId,
earnedFromPool: uint(0),
earnedFromRef: uint(0),
earnedFromGlobal: uint(0),
referrals: new address[](0)
});
idToAddress[newUserId] = _userAddress;
emit RegisterUserEvent(newUserId, msg.sender, _referrerAddress, 1, msg.value, now);
newUserId++;
users[_referrerAddress].referrals.push(_userAddress);
users[_referrerAddress].referrerCount++;
uint amountToDistribute = msg.value;
address sponsorAddress = idToAddress[_referrerId];
for (uint8 i = 1; i <= 4; i++) {
if ( isUserExists(sponsorAddress, 1) ) {
uint paid = payUpline(sponsorAddress, i, 1);
amountToDistribute -= paid;
users[sponsorAddress].earnedFromPool += paid;
address _nextSponsorAddress = idToAddress[users[sponsorAddress].referrerId];
sponsorAddress = _nextSponsorAddress;
}
}
if (amountToDistribute > 0) {
payFirstLine(idToAddress[1], amountToDistribute, 1);
users[idToAddress[1]].earnedFromPool += amountToDistribute;
}
}
function participatePool2()
public
payable
{
require(msg.value == 0.2 ether, "Participation fee in Autopool is 0.2 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 2), "User already registered in AP2");
uint eventCount = pool_slots_2[activeSlot_ap2].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_2[activeSlot_ap2].userAddress,
pool_slots_2[activeSlot_ap2].id,
idToAddress[users[pool_slots_2[activeSlot_ap2].userAddress].referrerId],
2
));
pool_slots_2[activeSlot_ap2].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user2 = UsersPool({
id: newSlotId_ap2,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_2[msg.sender] = user2;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap2,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_2[newSlotId_ap2] = _newSlot;
newUserId_ap2++;
emit RegisterUserEvent(newSlotId_ap2, msg.sender, idToAddress[_referrerId], 2, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 2);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 2);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap2++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_2[activeSlot_ap2].userAddress, 1, 2);
users[pool_slots_2[activeSlot_ap2].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_2[activeSlot_ap2].referrerId > 0) {
payUpline(idToAddress[pool_slots_2[activeSlot_ap2].referrerId], 1, 2);
users[idToAddress[pool_slots_2[activeSlot_ap2].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 2);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_2[activeSlot_ap2].eventsCount++;
}
}
function participatePool3()
public
payable
{
require(msg.value == 0.3 ether, "Participation fee in Autopool is 0.3 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 3), "User already registered in AP3");
uint eventCount = pool_slots_3[activeSlot_ap3].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_3[activeSlot_ap3].userAddress,
pool_slots_3[activeSlot_ap3].id,
idToAddress[users[pool_slots_3[activeSlot_ap3].userAddress].referrerId],
3
));
pool_slots_3[activeSlot_ap3].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user3 = UsersPool({
id: newSlotId_ap3,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_3[msg.sender] = user3;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap3,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_3[newSlotId_ap3] = _newSlot;
newUserId_ap3++;
emit RegisterUserEvent(newSlotId_ap3, msg.sender, idToAddress[_referrerId], 3, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 3);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 3);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap3++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_3[activeSlot_ap3].userAddress, 1, 3);
users[pool_slots_3[activeSlot_ap3].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_3[activeSlot_ap3].referrerId > 0) {
payUpline(idToAddress[pool_slots_3[activeSlot_ap3].referrerId], 1, 3);
users[idToAddress[pool_slots_3[activeSlot_ap3].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 3);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_3[activeSlot_ap3].eventsCount++;
}
}
function participatePool4()
public
payable
{
require(msg.value == 0.4 ether, "Participation fee in Autopool is 0.4 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 4), "User already registered in AP4");
uint eventCount = pool_slots_4[activeSlot_ap4].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_4[activeSlot_ap4].userAddress,
pool_slots_4[activeSlot_ap4].id,
idToAddress[users[pool_slots_4[activeSlot_ap4].userAddress].referrerId],
4
));
pool_slots_4[activeSlot_ap4].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user4 = UsersPool({
id: newSlotId_ap4,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_4[msg.sender] = user4;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap4,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_4[newSlotId_ap4] = _newSlot;
newUserId_ap4++;
emit RegisterUserEvent(newSlotId_ap4, msg.sender, idToAddress[_referrerId], 4, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 4);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 4);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap4++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_4[activeSlot_ap4].userAddress, 1, 4);
users[pool_slots_4[activeSlot_ap4].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_4[activeSlot_ap4].referrerId > 0) {
payUpline(idToAddress[pool_slots_4[activeSlot_ap4].referrerId], 1, 4);
users[idToAddress[pool_slots_4[activeSlot_ap4].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 4);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_4[activeSlot_ap4].eventsCount++;
}
}
function participatePool5()
public
payable
{
require(msg.value == 0.5 ether, "Participation fee in Autopool is 0.5 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 5), "User already registered in AP5");
uint eventCount = pool_slots_5[activeSlot_ap5].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_5[activeSlot_ap5].userAddress,
pool_slots_5[activeSlot_ap5].id,
idToAddress[users[pool_slots_5[activeSlot_ap5].userAddress].referrerId],
5
));
pool_slots_5[activeSlot_ap5].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user5 = UsersPool({
id: newSlotId_ap5,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_5[msg.sender] = user5;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap5,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_5[newSlotId_ap5] = _newSlot;
newUserId_ap5++;
emit RegisterUserEvent(newSlotId_ap5, msg.sender, idToAddress[_referrerId], 5, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 5);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 5);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap5++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_5[activeSlot_ap5].userAddress, 1, 5);
users[pool_slots_5[activeSlot_ap5].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_5[activeSlot_ap5].referrerId > 0) {
payUpline(idToAddress[pool_slots_5[activeSlot_ap5].referrerId], 1, 5);
users[idToAddress[pool_slots_5[activeSlot_ap5].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 5);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_5[activeSlot_ap5].eventsCount++;
}
}
function participatePool6()
public
payable
{
require(msg.value == 0.7 ether, "Participation fee in Autopool is 0.7 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 6), "User already registered in AP6");
uint eventCount = pool_slots_6[activeSlot_ap6].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_6[activeSlot_ap6].userAddress,
pool_slots_6[activeSlot_ap6].id,
idToAddress[users[pool_slots_6[activeSlot_ap6].userAddress].referrerId],
6
));
pool_slots_6[activeSlot_ap6].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user6 = UsersPool({
id: newSlotId_ap6,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_6[msg.sender] = user6;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap6,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_6[newSlotId_ap6] = _newSlot;
newUserId_ap6++;
emit RegisterUserEvent(newSlotId_ap6, msg.sender, idToAddress[_referrerId], 6, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 6);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 6);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap6++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_6[activeSlot_ap6].userAddress, 1, 6);
users[pool_slots_6[activeSlot_ap6].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_6[activeSlot_ap6].referrerId > 0) {
payUpline(idToAddress[pool_slots_6[activeSlot_ap6].referrerId], 1, 6);
users[idToAddress[pool_slots_6[activeSlot_ap6].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 6);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_6[activeSlot_ap6].eventsCount++;
}
}
function participatePool7()
public
payable
{
require(msg.value == 1 ether, "Participation fee in Autopool is 1 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 7), "User already registered in AP7");
uint eventCount = pool_slots_7[activeSlot_ap7].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_7[activeSlot_ap7].userAddress,
pool_slots_7[activeSlot_ap7].id,
idToAddress[users[pool_slots_7[activeSlot_ap7].userAddress].referrerId],
7
));
pool_slots_7[activeSlot_ap7].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user7 = UsersPool({
id: newSlotId_ap7,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_7[msg.sender] = user7;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap7,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_7[newSlotId_ap7] = _newSlot;
newUserId_ap7++;
emit RegisterUserEvent(newSlotId_ap7, msg.sender, idToAddress[_referrerId], 7, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 7);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 7);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap7++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_7[activeSlot_ap7].userAddress, 1, 7);
users[pool_slots_7[activeSlot_ap7].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_7[activeSlot_ap7].referrerId > 0) {
payUpline(idToAddress[pool_slots_7[activeSlot_ap7].referrerId], 1, 7);
users[idToAddress[pool_slots_7[activeSlot_ap7].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 7);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_7[activeSlot_ap7].eventsCount++;
}
}
function reinvestSlot(address _userAddress, uint _userId, address _sponsorAddress, uint8 _fromPool) private returns (bool _isReinvested) {
uint _referrerId = users[_userAddress].referrerId;
PoolSlots memory _reinvestslot = PoolSlots({
id: _userId,
userAddress: _userAddress,
referrerId: _referrerId,
eventsCount: uint8(0)
});
if (_fromPool == 2) {
users_2[pool_slots_2[activeSlot_ap2].userAddress].reinvestCount++;
pool_slots_2[newSlotId_ap2] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap2, _userAddress, _sponsorAddress, 2, msg.value, now);
newSlotId_ap2++;
}
if (_fromPool == 3) {
users_3[pool_slots_3[activeSlot_ap3].userAddress].reinvestCount++;
pool_slots_3[newSlotId_ap3] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap3, _userAddress, _sponsorAddress, 3, msg.value, now);
newSlotId_ap3++;
}
if (_fromPool == 4) {
users_4[pool_slots_4[activeSlot_ap4].userAddress].reinvestCount++;
pool_slots_4[newSlotId_ap4] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap4, _userAddress, _sponsorAddress, 4, msg.value, now);
newSlotId_ap4++;
}
if (_fromPool == 5) {
users_5[pool_slots_5[activeSlot_ap5].userAddress].reinvestCount++;
pool_slots_5[newSlotId_ap5] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap5, _userAddress, _sponsorAddress, 5, msg.value, now);
newSlotId_ap5++;
}
if (_fromPool == 6) {
users_6[pool_slots_6[activeSlot_ap6].userAddress].reinvestCount++;
pool_slots_6[newSlotId_ap6] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap6, _userAddress, _sponsorAddress, 6, msg.value, now);
newSlotId_ap6++;
}
if (_fromPool == 7) {
users_7[pool_slots_7[activeSlot_ap7].userAddress].reinvestCount++;
pool_slots_7[newSlotId_ap7] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap7, _userAddress, _sponsorAddress, 7, msg.value, now);
newSlotId_ap7++;
}
if (_fromPool == 2) {
pool_slots_2[activeSlot_ap2].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap2+1;
payUpline(pool_slots_2[_nextActiveSlot].userAddress, 1, 2);
users[pool_slots_2[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap2++;
}
if (_fromPool == 3) {
pool_slots_3[activeSlot_ap3].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap3+1;
payUpline(pool_slots_3[_nextActiveSlot].userAddress, 1, 3);
users[pool_slots_3[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap3++;
}
if (_fromPool == 4) {
pool_slots_4[activeSlot_ap4].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap4+1;
payUpline(pool_slots_4[_nextActiveSlot].userAddress, 1, 4);
users[pool_slots_4[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap4++;
}
if (_fromPool == 5) {
pool_slots_5[activeSlot_ap5].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap5+1;
payUpline(pool_slots_5[_nextActiveSlot].userAddress, 1, 5);
users[pool_slots_5[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap5++;
}
if (_fromPool == 6) {
pool_slots_6[activeSlot_ap6].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap6+1;
payUpline(pool_slots_6[_nextActiveSlot].userAddress, 1, 6);
users[pool_slots_6[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap6++;
}
if (_fromPool == 7) {
pool_slots_7[activeSlot_ap7].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap7+1;
payUpline(pool_slots_7[_nextActiveSlot].userAddress, 1, 7);
users[pool_slots_7[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap7++;
}
_isReinvested = true;
return _isReinvested;
}
function payUpline(address _sponsorAddress, uint8 _refLevel, uint8 _fromPool) private returns (uint distributeAmount) {
require( _refLevel <= 4);
distributeAmount = msg.value / 100 * uplineAmount[_refLevel];
if (address(uint160(_sponsorAddress)).send(distributeAmount)) {
if (_fromPool > 1) {
emit ReferralPaymentEvent(distributeAmount, msg.sender, _sponsorAddress, _fromPool, now);
} else
emit DistributeUplineEvent(distributeAmount, _sponsorAddress, msg.sender, _refLevel, _fromPool, now);
}
return distributeAmount;
}
function payFirstLine(address _sponsorAddress, uint payAmount, uint8 _fromPool) private returns (uint distributeAmount) {
distributeAmount = payAmount;
if (address(uint160(_sponsorAddress)).send(distributeAmount)) {
if (_fromPool > 1) {
emit ReferralPaymentEvent(distributeAmount, msg.sender, _sponsorAddress, _fromPool, now);
} else emit DistributeUplineEvent(distributeAmount, _sponsorAddress, msg.sender, 1, _fromPool, now);
}
return distributeAmount;
}
function isUserQualified(address _userAddress) public view returns (bool) {
return (users[_userAddress].referrerCount > 0);
}
function isUserExists(address _userAddress, uint8 _autopool) public view returns (bool) {
require((_autopool > 0) && (_autopool <= 7));
if (_autopool == 1) return (users[_userAddress].id != 0);
if (_autopool == 2) return (users_2[_userAddress].id != 0);
if (_autopool == 3) return (users_3[_userAddress].id != 0);
if (_autopool == 4) return (users_4[_userAddress].id != 0);
if (_autopool == 5) return (users_5[_userAddress].id != 0);
if (_autopool == 6) return (users_6[_userAddress].id != 0);
if (_autopool == 7) return (users_7[_userAddress].id != 0);
}
function getUserReferrals(address _userAddress)
public
view
returns (address[] memory)
{
return users[_userAddress].referrals;
}
}
|
contract SouSouETH {
struct User {
uint id;
uint referrerCount;
uint referrerId;
uint earnedFromPool;
uint earnedFromRef;
uint earnedFromGlobal;
address[] referrals;
}
struct UsersPool {
uint id;
uint referrerId;
uint reinvestCount;
}
struct PoolSlots {
uint id;
address userAddress;
uint referrerId;
uint8 eventsCount;
}
modifier validReferrerId(uint _referrerId) {
require((_referrerId > 0) && (_referrerId < newUserId), "Invalid referrer ID");
_;
}
event RegisterUserEvent(uint _userid, address indexed _user, address indexed _referrerAddress, uint8 indexed _autopool, uint _amount, uint _time);
event ReinvestEvent(uint _userid, address indexed _user, address indexed _referrerAddress, uint8 indexed _autopool, uint _amount, uint _time);
event DistributeUplineEvent(uint amount, address indexed _sponsorAddress, address indexed _fromAddress, uint _level, uint8 _fromPool, uint _time);
event ReferralPaymentEvent(uint amount, address indexed _from, address indexed _to, uint8 indexed _fromPool, uint _time);
mapping(address => User) public users;
mapping(address => UsersPool) public users_2;
mapping(uint => PoolSlots) public pool_slots_2;
mapping(address => UsersPool) public users_3;
mapping(uint => PoolSlots) public pool_slots_3;
mapping(address => UsersPool) public users_4;
mapping(uint => PoolSlots) public pool_slots_4;
mapping(address => UsersPool) public users_5;
mapping(uint => PoolSlots) public pool_slots_5;
mapping(address => UsersPool) public users_6;
mapping(uint => PoolSlots) public pool_slots_6;
mapping(address => UsersPool) public users_7;
mapping(uint => PoolSlots) public pool_slots_7;
mapping(uint => address) public idToAddress;
mapping (uint8 => uint8) public uplineAmount;
uint public newUserId = 1;
uint public newUserId_ap2 = 1;
uint public newUserId_ap3 = 1;
uint public newUserId_ap4 = 1;
uint public newUserId_ap5 = 1;
uint public newUserId_ap6 = 1;
uint public newUserId_ap7 = 1;
uint public newSlotId_ap2 = 1;
uint public activeSlot_ap2 = 1;
uint public newSlotId_ap3 = 1;
uint public activeSlot_ap3 = 1;
uint public newSlotId_ap4 = 1;
uint public activeSlot_ap4 = 1;
uint public newSlotId_ap5 = 1;
uint public activeSlot_ap5 = 1;
uint public newSlotId_ap6 = 1;
uint public activeSlot_ap6 = 1;
uint public newSlotId_ap7 = 1;
uint public activeSlot_ap7 = 1;
address public owner;
constructor(address _ownerAddress) public {
uplineAmount[1] = 50;
uplineAmount[2] = 25;
uplineAmount[3] = 15;
uplineAmount[4] = 10;
owner = _ownerAddress;
User memory user = User({
id: newUserId,
referrerCount: uint(0),
referrerId: uint(0),
earnedFromPool: uint(0),
earnedFromRef: uint(0),
earnedFromGlobal: uint(0),
referrals: new address[](0)
});
users[_ownerAddress] = user;
idToAddress[newUserId] = _ownerAddress;
newUserId++;
//////
UsersPool memory user2 = UsersPool({
id: newSlotId_ap2,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_2[_ownerAddress] = user2;
PoolSlots memory _newSlot2 = PoolSlots({
id: newSlotId_ap2,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_2[newSlotId_ap2] = _newSlot2;
newUserId_ap2++;
newSlotId_ap2++;
///////
UsersPool memory user3 = UsersPool({
id: newSlotId_ap3,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_3[_ownerAddress] = user3;
PoolSlots memory _newSlot3 = PoolSlots({
id: newSlotId_ap3,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_3[newSlotId_ap3] = _newSlot3;
newUserId_ap3++;
newSlotId_ap3++;
///////
UsersPool memory user4 = UsersPool({
id: newSlotId_ap4,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_4[_ownerAddress] = user4;
PoolSlots memory _newSlot4 = PoolSlots({
id: newSlotId_ap4,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_4[newSlotId_ap4] = _newSlot4;
newUserId_ap4++;
newSlotId_ap4++;
///////
UsersPool memory user5 = UsersPool({
id: newSlotId_ap5,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_5[_ownerAddress] = user5;
PoolSlots memory _newSlot5 = PoolSlots({
id: newSlotId_ap5,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_5[newSlotId_ap5] = _newSlot5;
newUserId_ap5++;
newSlotId_ap5++;
///////
UsersPool memory user6 = UsersPool({
id: newSlotId_ap6,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_6[_ownerAddress] = user6;
PoolSlots memory _newSlot6 = PoolSlots({
id: newSlotId_ap6,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_6[newSlotId_ap6] = _newSlot6;
newUserId_ap6++;
newSlotId_ap6++;
///////
UsersPool memory user7 = UsersPool({
id: newSlotId_ap7,
referrerId: uint(0),
reinvestCount: uint(0)
});
users_7[_ownerAddress] = user7;
PoolSlots memory _newSlot7 = PoolSlots({
id: newSlotId_ap7,
userAddress: _ownerAddress,
referrerId: uint(0),
eventsCount: uint8(0)
});
pool_slots_7[newSlotId_ap7] = _newSlot7;
newUserId_ap7++;
newSlotId_ap7++;
}
function participatePool1(uint _referrerId)
public
payable
validReferrerId(_referrerId)
{
require(msg.value == 0.1 ether, "Participation fee is 0.1 ETH");
require(!isUserExists(msg.sender, 1), "User already registered");
address _userAddress = msg.sender;
address _referrerAddress = idToAddress[_referrerId];
uint32 size;
assembly {
size := extcodesize(_userAddress)
}
require(size == 0, "cannot be a contract");
users[_userAddress] = User({
id: newUserId,
referrerCount: uint(0),
referrerId: _referrerId,
earnedFromPool: uint(0),
earnedFromRef: uint(0),
earnedFromGlobal: uint(0),
referrals: new address[](0)
});
idToAddress[newUserId] = _userAddress;
emit RegisterUserEvent(newUserId, msg.sender, _referrerAddress, 1, msg.value, now);
newUserId++;
users[_referrerAddress].referrals.push(_userAddress);
users[_referrerAddress].referrerCount++;
uint amountToDistribute = msg.value;
address sponsorAddress = idToAddress[_referrerId];
for (uint8 i = 1; i <= 4; i++) {
if ( isUserExists(sponsorAddress, 1) ) {
uint paid = payUpline(sponsorAddress, i, 1);
amountToDistribute -= paid;
users[sponsorAddress].earnedFromPool += paid;
address _nextSponsorAddress = idToAddress[users[sponsorAddress].referrerId];
sponsorAddress = _nextSponsorAddress;
}
}
if (amountToDistribute > 0) {
payFirstLine(idToAddress[1], amountToDistribute, 1);
users[idToAddress[1]].earnedFromPool += amountToDistribute;
}
}
function participatePool2()
public
payable
{
require(msg.value == 0.2 ether, "Participation fee in Autopool is 0.2 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 2), "User already registered in AP2");
uint eventCount = pool_slots_2[activeSlot_ap2].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_2[activeSlot_ap2].userAddress,
pool_slots_2[activeSlot_ap2].id,
idToAddress[users[pool_slots_2[activeSlot_ap2].userAddress].referrerId],
2
));
pool_slots_2[activeSlot_ap2].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user2 = UsersPool({
id: newSlotId_ap2,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_2[msg.sender] = user2;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap2,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_2[newSlotId_ap2] = _newSlot;
newUserId_ap2++;
emit RegisterUserEvent(newSlotId_ap2, msg.sender, idToAddress[_referrerId], 2, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 2);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 2);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap2++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_2[activeSlot_ap2].userAddress, 1, 2);
users[pool_slots_2[activeSlot_ap2].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_2[activeSlot_ap2].referrerId > 0) {
payUpline(idToAddress[pool_slots_2[activeSlot_ap2].referrerId], 1, 2);
users[idToAddress[pool_slots_2[activeSlot_ap2].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 2);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_2[activeSlot_ap2].eventsCount++;
}
}
function participatePool3()
public
payable
{
require(msg.value == 0.3 ether, "Participation fee in Autopool is 0.3 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 3), "User already registered in AP3");
uint eventCount = pool_slots_3[activeSlot_ap3].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_3[activeSlot_ap3].userAddress,
pool_slots_3[activeSlot_ap3].id,
idToAddress[users[pool_slots_3[activeSlot_ap3].userAddress].referrerId],
3
));
pool_slots_3[activeSlot_ap3].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user3 = UsersPool({
id: newSlotId_ap3,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_3[msg.sender] = user3;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap3,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_3[newSlotId_ap3] = _newSlot;
newUserId_ap3++;
emit RegisterUserEvent(newSlotId_ap3, msg.sender, idToAddress[_referrerId], 3, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 3);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 3);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap3++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_3[activeSlot_ap3].userAddress, 1, 3);
users[pool_slots_3[activeSlot_ap3].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_3[activeSlot_ap3].referrerId > 0) {
payUpline(idToAddress[pool_slots_3[activeSlot_ap3].referrerId], 1, 3);
users[idToAddress[pool_slots_3[activeSlot_ap3].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 3);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_3[activeSlot_ap3].eventsCount++;
}
}
function participatePool4()
public
payable
{
require(msg.value == 0.4 ether, "Participation fee in Autopool is 0.4 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 4), "User already registered in AP4");
uint eventCount = pool_slots_4[activeSlot_ap4].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_4[activeSlot_ap4].userAddress,
pool_slots_4[activeSlot_ap4].id,
idToAddress[users[pool_slots_4[activeSlot_ap4].userAddress].referrerId],
4
));
pool_slots_4[activeSlot_ap4].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user4 = UsersPool({
id: newSlotId_ap4,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_4[msg.sender] = user4;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap4,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_4[newSlotId_ap4] = _newSlot;
newUserId_ap4++;
emit RegisterUserEvent(newSlotId_ap4, msg.sender, idToAddress[_referrerId], 4, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 4);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 4);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap4++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_4[activeSlot_ap4].userAddress, 1, 4);
users[pool_slots_4[activeSlot_ap4].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_4[activeSlot_ap4].referrerId > 0) {
payUpline(idToAddress[pool_slots_4[activeSlot_ap4].referrerId], 1, 4);
users[idToAddress[pool_slots_4[activeSlot_ap4].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 4);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_4[activeSlot_ap4].eventsCount++;
}
}
function participatePool5()
public
payable
{
require(msg.value == 0.5 ether, "Participation fee in Autopool is 0.5 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 5), "User already registered in AP5");
uint eventCount = pool_slots_5[activeSlot_ap5].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_5[activeSlot_ap5].userAddress,
pool_slots_5[activeSlot_ap5].id,
idToAddress[users[pool_slots_5[activeSlot_ap5].userAddress].referrerId],
5
));
pool_slots_5[activeSlot_ap5].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user5 = UsersPool({
id: newSlotId_ap5,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_5[msg.sender] = user5;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap5,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_5[newSlotId_ap5] = _newSlot;
newUserId_ap5++;
emit RegisterUserEvent(newSlotId_ap5, msg.sender, idToAddress[_referrerId], 5, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 5);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 5);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap5++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_5[activeSlot_ap5].userAddress, 1, 5);
users[pool_slots_5[activeSlot_ap5].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_5[activeSlot_ap5].referrerId > 0) {
payUpline(idToAddress[pool_slots_5[activeSlot_ap5].referrerId], 1, 5);
users[idToAddress[pool_slots_5[activeSlot_ap5].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 5);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_5[activeSlot_ap5].eventsCount++;
}
}
function participatePool6()
public
payable
{
require(msg.value == 0.7 ether, "Participation fee in Autopool is 0.7 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 6), "User already registered in AP6");
uint eventCount = pool_slots_6[activeSlot_ap6].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_6[activeSlot_ap6].userAddress,
pool_slots_6[activeSlot_ap6].id,
idToAddress[users[pool_slots_6[activeSlot_ap6].userAddress].referrerId],
6
));
pool_slots_6[activeSlot_ap6].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user6 = UsersPool({
id: newSlotId_ap6,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_6[msg.sender] = user6;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap6,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_6[newSlotId_ap6] = _newSlot;
newUserId_ap6++;
emit RegisterUserEvent(newSlotId_ap6, msg.sender, idToAddress[_referrerId], 6, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 6);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 6);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap6++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_6[activeSlot_ap6].userAddress, 1, 6);
users[pool_slots_6[activeSlot_ap6].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_6[activeSlot_ap6].referrerId > 0) {
payUpline(idToAddress[pool_slots_6[activeSlot_ap6].referrerId], 1, 6);
users[idToAddress[pool_slots_6[activeSlot_ap6].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 6);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_6[activeSlot_ap6].eventsCount++;
}
}
function participatePool7()
public
payable
{
require(msg.value == 1 ether, "Participation fee in Autopool is 1 ETH");
require(isUserExists(msg.sender, 1), "User not present in AP1");
require(isUserQualified(msg.sender), "User not qualified in AP1");
require(!isUserExists(msg.sender, 7), "User already registered in AP7");
uint eventCount = pool_slots_7[activeSlot_ap7].eventsCount;
uint newEventCount = eventCount + 1;
if (newEventCount == 3) {
require(reinvestSlot(
pool_slots_7[activeSlot_ap7].userAddress,
pool_slots_7[activeSlot_ap7].id,
idToAddress[users[pool_slots_7[activeSlot_ap7].userAddress].referrerId],
7
));
pool_slots_7[activeSlot_ap7].eventsCount++;
}
uint _referrerId = users[msg.sender].referrerId;
UsersPool memory user7 = UsersPool({
id: newSlotId_ap7,
referrerId: _referrerId,
reinvestCount: uint(0)
});
users_7[msg.sender] = user7;
PoolSlots memory _newSlot = PoolSlots({
id: newSlotId_ap7,
userAddress: msg.sender,
referrerId: _referrerId,
eventsCount: uint8(0)
});
pool_slots_7[newSlotId_ap7] = _newSlot;
newUserId_ap7++;
emit RegisterUserEvent(newSlotId_ap7, msg.sender, idToAddress[_referrerId], 7, msg.value, now);
if (_referrerId > 0) {
payUpline(idToAddress[_referrerId], 1, 7);
users[idToAddress[_referrerId]].earnedFromRef += msg.value/2;
}
else{
payUpline(idToAddress[1], 1, 7);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
newSlotId_ap7++;
if (eventCount < 2) {
if(eventCount == 0) {
payUpline(pool_slots_7[activeSlot_ap7].userAddress, 1, 7);
users[pool_slots_7[activeSlot_ap7].userAddress].earnedFromGlobal += msg.value/2;
}
if(eventCount == 1) {
if (pool_slots_7[activeSlot_ap7].referrerId > 0) {
payUpline(idToAddress[pool_slots_7[activeSlot_ap7].referrerId], 1, 7);
users[idToAddress[pool_slots_7[activeSlot_ap7].referrerId]].earnedFromRef += msg.value/2;
}
else {
payUpline(idToAddress[1], 1, 7);
users[idToAddress[1]].earnedFromRef += msg.value/2;
}
}
pool_slots_7[activeSlot_ap7].eventsCount++;
}
}
function reinvestSlot(address _userAddress, uint _userId, address _sponsorAddress, uint8 _fromPool) private returns (bool _isReinvested) {
uint _referrerId = users[_userAddress].referrerId;
PoolSlots memory _reinvestslot = PoolSlots({
id: _userId,
userAddress: _userAddress,
referrerId: _referrerId,
eventsCount: uint8(0)
});
if (_fromPool == 2) {
users_2[pool_slots_2[activeSlot_ap2].userAddress].reinvestCount++;
pool_slots_2[newSlotId_ap2] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap2, _userAddress, _sponsorAddress, 2, msg.value, now);
newSlotId_ap2++;
}
if (_fromPool == 3) {
users_3[pool_slots_3[activeSlot_ap3].userAddress].reinvestCount++;
pool_slots_3[newSlotId_ap3] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap3, _userAddress, _sponsorAddress, 3, msg.value, now);
newSlotId_ap3++;
}
if (_fromPool == 4) {
users_4[pool_slots_4[activeSlot_ap4].userAddress].reinvestCount++;
pool_slots_4[newSlotId_ap4] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap4, _userAddress, _sponsorAddress, 4, msg.value, now);
newSlotId_ap4++;
}
if (_fromPool == 5) {
users_5[pool_slots_5[activeSlot_ap5].userAddress].reinvestCount++;
pool_slots_5[newSlotId_ap5] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap5, _userAddress, _sponsorAddress, 5, msg.value, now);
newSlotId_ap5++;
}
if (_fromPool == 6) {
users_6[pool_slots_6[activeSlot_ap6].userAddress].reinvestCount++;
pool_slots_6[newSlotId_ap6] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap6, _userAddress, _sponsorAddress, 6, msg.value, now);
newSlotId_ap6++;
}
if (_fromPool == 7) {
users_7[pool_slots_7[activeSlot_ap7].userAddress].reinvestCount++;
pool_slots_7[newSlotId_ap7] = _reinvestslot;
emit ReinvestEvent(newSlotId_ap7, _userAddress, _sponsorAddress, 7, msg.value, now);
newSlotId_ap7++;
}
if (_fromPool == 2) {
pool_slots_2[activeSlot_ap2].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap2+1;
payUpline(pool_slots_2[_nextActiveSlot].userAddress, 1, 2);
users[pool_slots_2[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap2++;
}
if (_fromPool == 3) {
pool_slots_3[activeSlot_ap3].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap3+1;
payUpline(pool_slots_3[_nextActiveSlot].userAddress, 1, 3);
users[pool_slots_3[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap3++;
}
if (_fromPool == 4) {
pool_slots_4[activeSlot_ap4].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap4+1;
payUpline(pool_slots_4[_nextActiveSlot].userAddress, 1, 4);
users[pool_slots_4[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap4++;
}
if (_fromPool == 5) {
pool_slots_5[activeSlot_ap5].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap5+1;
payUpline(pool_slots_5[_nextActiveSlot].userAddress, 1, 5);
users[pool_slots_5[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap5++;
}
if (_fromPool == 6) {
pool_slots_6[activeSlot_ap6].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap6+1;
payUpline(pool_slots_6[_nextActiveSlot].userAddress, 1, 6);
users[pool_slots_6[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap6++;
}
if (_fromPool == 7) {
pool_slots_7[activeSlot_ap7].eventsCount = 3;
uint _nextActiveSlot = activeSlot_ap7+1;
payUpline(pool_slots_7[_nextActiveSlot].userAddress, 1, 7);
users[pool_slots_7[_nextActiveSlot].userAddress].earnedFromGlobal += msg.value/2;
activeSlot_ap7++;
}
_isReinvested = true;
return _isReinvested;
}
function payUpline(address _sponsorAddress, uint8 _refLevel, uint8 _fromPool) private returns (uint distributeAmount) {
require( _refLevel <= 4);
distributeAmount = msg.value / 100 * uplineAmount[_refLevel];
if (address(uint160(_sponsorAddress)).send(distributeAmount)) {
if (_fromPool > 1) {
emit ReferralPaymentEvent(distributeAmount, msg.sender, _sponsorAddress, _fromPool, now);
} else
emit DistributeUplineEvent(distributeAmount, _sponsorAddress, msg.sender, _refLevel, _fromPool, now);
}
return distributeAmount;
}
function payFirstLine(address _sponsorAddress, uint payAmount, uint8 _fromPool) private returns (uint distributeAmount) {
distributeAmount = payAmount;
if (address(uint160(_sponsorAddress)).send(distributeAmount)) {
if (_fromPool > 1) {
emit ReferralPaymentEvent(distributeAmount, msg.sender, _sponsorAddress, _fromPool, now);
} else emit DistributeUplineEvent(distributeAmount, _sponsorAddress, msg.sender, 1, _fromPool, now);
}
return distributeAmount;
}
function isUserQualified(address _userAddress) public view returns (bool) {
return (users[_userAddress].referrerCount > 0);
}
function isUserExists(address _userAddress, uint8 _autopool) public view returns (bool) {
require((_autopool > 0) && (_autopool <= 7));
if (_autopool == 1) return (users[_userAddress].id != 0);
if (_autopool == 2) return (users_2[_userAddress].id != 0);
if (_autopool == 3) return (users_3[_userAddress].id != 0);
if (_autopool == 4) return (users_4[_userAddress].id != 0);
if (_autopool == 5) return (users_5[_userAddress].id != 0);
if (_autopool == 6) return (users_6[_userAddress].id != 0);
if (_autopool == 7) return (users_7[_userAddress].id != 0);
}
function getUserReferrals(address _userAddress)
public
view
returns (address[] memory)
{
return users[_userAddress].referrals;
}
}
| 26,724
|
541
|
// Get the normalized price of the asset
|
vars.oraclePriceMantissa = oracle.getUnderlyingPrice(asset);
if (vars.oraclePriceMantissa == 0) {
return (Error.PRICE_ERROR, 0, 0);
}
|
vars.oraclePriceMantissa = oracle.getUnderlyingPrice(asset);
if (vars.oraclePriceMantissa == 0) {
return (Error.PRICE_ERROR, 0, 0);
}
| 6,366
|
57
|
// Internal function to determine if an address is a contract/_addr address The address being queried/ return True if `_addr` is a contract
|
function isContract(address _addr) constant internal returns(bool) {
if (_addr == 0) {
return false;
}
uint256 size;
assembly {
size: = extcodesize(_addr)
}
return (size > 0);
}
|
function isContract(address _addr) constant internal returns(bool) {
if (_addr == 0) {
return false;
}
uint256 size;
assembly {
size: = extcodesize(_addr)
}
return (size > 0);
}
| 40,705
|
4
|
// Set Native Token Address (only owner access) /
|
function setNativeTokenAddress(address newNativeTokenAddress)
public
onlyOwner
|
function setNativeTokenAddress(address newNativeTokenAddress)
public
onlyOwner
| 30,181
|
2
|
// Internal function string for removing liquidity
|
string internal constant REMOVE_LIQUIDITY =
"removeLiquidity(address,address,uint256,uint256,uint256,address,uint256)";
|
string internal constant REMOVE_LIQUIDITY =
"removeLiquidity(address,address,uint256,uint256,uint256,address,uint256)";
| 2,114
|
98
|
// item RLP encoded bytes /
|
function toRlpItem(bytes memory item)
internal
pure
returns (RLPItem memory)
|
function toRlpItem(bytes memory item)
internal
pure
returns (RLPItem memory)
| 49,437
|
114
|
// https:etherscan.io/address/0xe2f532c389deb5E42DCe53e78A9762949A885455;
|
Synth newSynth = Synth(0xe2f532c389deb5E42DCe53e78A9762949A885455);
newSynth.setTotalSupply(existingSynth.totalSupply());
|
Synth newSynth = Synth(0xe2f532c389deb5E42DCe53e78A9762949A885455);
newSynth.setTotalSupply(existingSynth.totalSupply());
| 45,593
|
12
|
// reference to $WOOL for burning on mint
|
WOOL public wool;
|
WOOL public wool;
| 14,833
|
10
|
// ERC1404 check if _value token can be transferred from _from to _to from address The address which you want to send tokens from to address The address which you want to transfer to amount uint256 the amount of tokens to be transferredreturn code of the rejection reason /
|
function detectTransferRestriction(
address from,
address to,
uint256 amount
|
function detectTransferRestriction(
address from,
address to,
uint256 amount
| 29,828
|
81
|
// uint256 public constant startBlock = 11226037 + 100; uint256 public endBlock = startBlock + 2425846;
|
uint256 public lastBlock; // last block the distribution has ran
uint256 public tokensAccrued; // tokens to distribute per weight scaled by 1e18
|
uint256 public lastBlock; // last block the distribution has ran
uint256 public tokensAccrued; // tokens to distribute per weight scaled by 1e18
| 45,011
|
235
|
// Transfers control of the contract to a newOwner. newOwner The address to transfer ownership to. /
|
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
|
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| 2,619
|
51
|
// Hook that is called after any transfer of tokens. This includes minting and burning. Calling conditions: - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens has been transferred to `to`. - when `from` is zero, `amount` tokens have been minted for `to`. - when `to` is zero, `amount` of ``from``'s tokens have been burned. - `from` and `to` are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adocusing-hooks[Using Hooks]./
|
function _afterTokenTransfer(
address from,
address to,
uint256 amount
|
function _afterTokenTransfer(
address from,
address to,
uint256 amount
| 54,384
|
104
|
// last update time will be right when epoch starts
|
newEpoch.lastUpdateTime = startEpoch;
epochData[newEpoch.id] = newEpoch;
emit EpochAdded(newEpoch.id, startEpoch, finishEpoch, reward);
|
newEpoch.lastUpdateTime = startEpoch;
epochData[newEpoch.id] = newEpoch;
emit EpochAdded(newEpoch.id, startEpoch, finishEpoch, reward);
| 27,853
|
0
|
// Implement DAO Treasury
|
IERC20 khanToken;
address immutable owner;
address secondOwner;
address [] public members;
|
IERC20 khanToken;
address immutable owner;
address secondOwner;
address [] public members;
| 19,062
|
183
|
// The fee is expressed as a base fee in wei plus percentage on actual charge./ E.g. a value of 40 stands for a 40% fee, so the recipient will be/ charged for 1.4 times the spent amount.
|
function calculateCharge(uint256 gasUsed, GsnTypes.RelayData calldata relayData) external view returns (uint256);
|
function calculateCharge(uint256 gasUsed, GsnTypes.RelayData calldata relayData) external view returns (uint256);
| 126
|
206
|
// FEE PAYER DATA STRUCTURES/ The collateral currency used to back the positions in this contract.
|
IERC20 public collateralCurrency;
|
IERC20 public collateralCurrency;
| 7,762
|
3
|
// the ordered list of target addresses for calls to be made
|
address[] targets;
|
address[] targets;
| 42,187
|
140
|
// Enable investment in specified assets/ofAssets Array of assets to enable investment in
|
function enableInvestment(address[] ofAssets)
external
pre_cond(isOwner())
|
function enableInvestment(address[] ofAssets)
external
pre_cond(isOwner())
| 8,575
|
89
|
// VestingAllocation contructor.RemainingTokensPerPeriod variable which representsthe remaining amount of tokens to be distributed / Invoking parent constructor (OwnedBySignaturers) with signatures addresses
|
function VestingAllocation(uint256 _tokensPerPeriod, uint256 _periods, uint256 _minutesInPeriod, uint256 _initalTimestamp) Ownable() public {
totalSupply = _tokensPerPeriod * _periods;
periods = _periods;
minutesInPeriod = _minutesInPeriod;
remainingTokensPerPeriod = _tokensPerPeriod;
initTimestamp = _initalTimestamp;
}
|
function VestingAllocation(uint256 _tokensPerPeriod, uint256 _periods, uint256 _minutesInPeriod, uint256 _initalTimestamp) Ownable() public {
totalSupply = _tokensPerPeriod * _periods;
periods = _periods;
minutesInPeriod = _minutesInPeriod;
remainingTokensPerPeriod = _tokensPerPeriod;
initTimestamp = _initalTimestamp;
}
| 53,971
|
147
|
// Update the token URI /
|
function updateTokenURI(uint256 tokenId, string calldata tokenURI) external;
|
function updateTokenURI(uint256 tokenId, string calldata tokenURI) external;
| 34,680
|
109
|
// Recursively distribute deposit fee between parents _node Parent address _prevPercentage The percentage for previous parent _depositsCount Count of depositer deposits _amount The amount of deposit /
|
function distribute(
address _node,
uint _prevPercentage,
uint8 _depositsCount,
uint _amount
)
private
|
function distribute(
address _node,
uint _prevPercentage,
uint8 _depositsCount,
uint _amount
)
private
| 72,155
|
81
|
// Places buy offer for the canvas. It cannot be called by the owner of the canvas. New offer has to be bigger than existing offer. Returns ethers to the previous bidder, if any./
|
function makeBuyOffer(uint32 _canvasId) external payable stateOwned(_canvasId) forceOwned(_canvasId) {
Canvas storage canvas = _getCanvas(_canvasId);
BuyOffer storage existing = buyOffers[_canvasId];
require(canvas.owner != msg.sender);
require(canvas.owner != 0x0);
require(msg.value > existing.amount);
if (existing.amount > 0) {
//refund previous buy offer.
addPendingWithdrawal(existing.buyer, existing.amount);
}
buyOffers[_canvasId] = BuyOffer(true, msg.sender, msg.value);
emit BuyOfferMade(_canvasId, msg.sender, msg.value);
}
|
function makeBuyOffer(uint32 _canvasId) external payable stateOwned(_canvasId) forceOwned(_canvasId) {
Canvas storage canvas = _getCanvas(_canvasId);
BuyOffer storage existing = buyOffers[_canvasId];
require(canvas.owner != msg.sender);
require(canvas.owner != 0x0);
require(msg.value > existing.amount);
if (existing.amount > 0) {
//refund previous buy offer.
addPendingWithdrawal(existing.buyer, existing.amount);
}
buyOffers[_canvasId] = BuyOffer(true, msg.sender, msg.value);
emit BuyOfferMade(_canvasId, msg.sender, msg.value);
}
| 40,752
|
251
|
// Send liquidator CollateralLiquidated
|
msg.sender.transfer(totalCollateralLiquidated);
|
msg.sender.transfer(totalCollateralLiquidated);
| 21,598
|
297
|
// populate the most-significant character
|
result[40 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
|
result[40 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
| 9,248
|
72
|
// Token Issuance
|
function isIssuable() external view returns (bool); // 4/9
function issueByPartition(bytes32 partition, address tokenHolder, uint256 value, bytes calldata data) external; // 5/9
event IssuedByPartition(bytes32 indexed partition, address indexed operator, address indexed to, uint256 value, bytes data, bytes operatorData);
|
function isIssuable() external view returns (bool); // 4/9
function issueByPartition(bytes32 partition, address tokenHolder, uint256 value, bytes calldata data) external; // 5/9
event IssuedByPartition(bytes32 indexed partition, address indexed operator, address indexed to, uint256 value, bytes data, bytes operatorData);
| 48,126
|
39
|
// In case the ownership needs to be transferred
|
function transferOwnership(address newOwner)public onlyOwner
|
function transferOwnership(address newOwner)public onlyOwner
| 20,615
|
35
|
// A contract attempts to get the coins. Tokens should be previously allocated_to - address to transfer tokens to_from - address to transfer tokens from_value - number of tokens to transfer return True in case of success, otherwise false/
|
function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed onlyPayloadSize(3*32) returns (bool success) {
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;
}
|
function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed onlyPayloadSize(3*32) returns (bool success) {
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;
}
| 11,998
|
59
|
// Burns a specified amount of tokens.Overrides the burn() function with modifier that prevents the ability to burn tokensby holders excluding the sale agent.
|
* @param _value {uint256} the amount of token to be burned.
*/
function burn(uint256 _value) public onlySaleAgent {
super.burn(_value);
}
|
* @param _value {uint256} the amount of token to be burned.
*/
function burn(uint256 _value) public onlySaleAgent {
super.burn(_value);
}
| 39,204
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.